mmt_multipole_inversion.multipole_inversion#

Module Contents#

Classes#

MultipoleInversion

Class to perform multipole inversions of a magnetic scan surface into

Functions#

dipole_field(dip_r, dip_m, pos_r)

Calculate magnetic flux B generated by dipole

plot_sample(Inversion, ax, contourf_args={'levels': 50}, contour_args={}, scatter_args={'c': 'k', 's': 1}, imshow_args=None, dimension_scale=1.0, data_scale=1.0)

plot_inversion_Bz(Inversion, ax, contours=20, contourlines=10, dimension_scale=1.0, data_scale=1.0, imshow_args=None, contourf_args={'cmap': 'RdYlBu'}, contour_args={'colors': 'k', 'linewidths': 0.2}, scatter_args={'c': 'k'})

plot_difference_Bz(Inversion, ax, contours=50, dimension_scale=1.0, data_scale=1.0, contourf_args={'cmap': 'RdYlBu'}, imshow_args=None, scatter_args={'c': 'k', 's': 1})

Attributes#

mmt_multipole_inversion.multipole_inversion.HASCUDA = True#
mmt_multipole_inversion.multipole_inversion.dipole_field(dip_r, dip_m, pos_r)#

Calculate magnetic flux B generated by dipole with magnetic moment dip_m (Am2) located in position dip_r (m) at position pos_r (m) unit of result is T

mmt_multipole_inversion.multipole_inversion.SusOptions#
mmt_multipole_inversion.multipole_inversion.ExpOptions#
class mmt_multipole_inversion.multipole_inversion.MultipoleInversion(sample_config_file, sample_arrays, expansion_limit='quadrupole', verbose=True, sus_functions_module='spherical_harmonics_basis')#

Bases: object

Class to perform multipole inversions of a magnetic scan surface into multiple magnetic sources located within a sample. Specifications of the scan grid and the magnetic particles in the sample can be generated using the MagneticSample class.

Parameters
  • sample_config_file (Union[str, pathlib.Path]) –

  • sample_arrays (Optional[Union[str, pathlib.Path]]) –

  • expansion_limit (ExpOptions) –

  • verbose (bool) –

  • sus_functions_module (SusOptions) –

property expansion_limit(self)#
generate_measurement_mesh(self)#

Generate coordinates for the measurement mesh The number of grid points in each direction (xy) are calculated by rounding the lateral size by the grid step size, e.g. round(Sx / Sdx)

generate_forward_matrix(self, optimization='numba')#

Generate the forward matrix adding the field contribution from all the particles for every grid point at the scan surface. The field is computed from the scalar potential of the particles approximated with the multipole expansion up to the order specified by self.expansion_limit

Parameters
optimization

The method to optimize the calculation of the matrix elements: numba or cuda

compute_inversion(self, method='sp_pinv', **method_kwargs)#

Computes the multipole inversion. Results are saved in the inv_multipole_moments and inv_Bz_array variables. This method requires the generation of the Q matrix, hence the generate_forward_matrix method using numba is called if Q has not been set. To optimize the calculation of Q, call the function before this method.

Parameters
method
The numerical method to perform the inversion. Options:

np_pinv -> Numpy’s pinv sp_pinv -> Scipy’s pinv (not recommended -> memory issues) sp_pinv2 -> Scipy’s pinv2 (this will call sp_pinv instead)

**method_kwargs

Extra parameters passed to Numpy or Scipy functions. For Numpy, the tolerance can be set using rcond while for Scipy it is recommended to use atol and rtol. See their documentations for detailed information.

save_multipole_moments(self, save_name='TIME_STAMP', basedir='.')#

Save the multipole values in npz files. Values are computed from the inversion using the compute_inversion method.

mmt_multipole_inversion.multipole_inversion.plot_sample(Inversion, ax, contourf_args={'levels': 50}, contour_args={}, scatter_args={'c': 'k', 's': 1}, imshow_args=None, dimension_scale=1.0, data_scale=1.0)#
mmt_multipole_inversion.multipole_inversion.plot_inversion_Bz(Inversion, ax, contours=20, contourlines=10, dimension_scale=1.0, data_scale=1.0, imshow_args=None, contourf_args={'cmap': 'RdYlBu'}, contour_args={'colors': 'k', 'linewidths': 0.2}, scatter_args={'c': 'k'})#
mmt_multipole_inversion.multipole_inversion.plot_difference_Bz(Inversion, ax, contours=50, dimension_scale=1.0, data_scale=1.0, contourf_args={'cmap': 'RdYlBu'}, imshow_args=None, scatter_args={'c': 'k', 's': 1})#