mmt_multipole_inversion.multipole_inversion
#
Module Contents#
Classes#
Class to perform multipole inversions |
Functions#
|
Calculate magnetic flux B generated by dipole |
Attributes#
- mmt_multipole_inversion.multipole_inversion.HASCUDA = True#
- mmt_multipole_inversion.multipole_inversion._SusOptions#
- mmt_multipole_inversion.multipole_inversion._ExpOptions#
- mmt_multipole_inversion.multipole_inversion._MethodOptions#
- mmt_multipole_inversion.multipole_inversion._InvMethodOps#
- 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
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. The sensors of the magnetic scan surface are modelled either as point sensors or sensor with cuboid shape (volume).
- 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
- Parameters
optimization (_MethodOptions) –
Notes
In case of using one of the _area or _volume susceptibility modules, where the sensor is modelled in 2D or 3D, remember to specify the self.sensor_dims tuple with the dimensions of the sensor
- compute_inversion(self, method='sp_pinv', sigma_field_noise=None, **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)
- sigma_field_noise
If a float is specified, a covariance matrix is produced and stored in the covariance_matrix variable. This matrix uses the value of sigma as the standard deviation of uncorrelated noise in the magnetic flux field. Units are T m^2. In addition, the standard deviation of the magnetic moments are calculated and stored in the inv_moments_std 2D array where every row has the results per grain. For details, see [F. Out et al. Geochemistry, Geophysics, Geosystems 23(4). 2022]
- **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.
- Parameters
method (_InvMethodOps) –
sigma_field_noise (Optional[float]) –
- save_multipole_moments(self, save_name='TIME_STAMP', basedir='.', save_moments_std=False)#
Save the multipole values in npz files.
Values need to be computed using the compute_inversion method.
- Parameters
- save_name
File name of the npz file
- basedir
Base directory where results are saved. Will be created if it does not exist
- save_moments_std
Add the standard deviation of the magnetic moments to the npz file in case the sigma_field_noise was specified in the inversion
- Parameters
save_name (str) –
basedir (Union[pathlib.Path, str]) –
save_moments_std (bool) –
- Return type
None
- 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