ConfigSimulator¶
- class mrsimulator.simulator.ConfigSimulator(*, name: str = None, description: str = None, label: str = None, property_units: Dict = {}, number_of_sidebands: ConstrainedIntValue = 64, number_of_gamma_angles: ConstrainedIntValue = 1, integration_volume: Literal['octant', 'hemisphere', 'sphere'] = 'octant', integration_density: ConstrainedIntValue = 70, decompose_spectrum: Literal['none', 'spin_system'] = 'none', isotropic_interpolation: Literal['linear', 'gaussian'] = 'linear', custom_sampling: Optional[CustomSampling] = None, is_complex: bool = True)¶
Bases:
ParseableThe configurable attributes for the Simulator class used in the simulation.
- number_of_sidebands¶
Number of sidebands to evaluate in the simulation. The default value is 64. Value cannot be negative or zero.
- Type:
int (optional).
- number_of_gamma_angles¶
Number of gamma angles averages in the simulation. The default value is 1. Value cannot be negative or zero.
- Type:
int (optional).
- integration_volume¶
The spatial volume over which the spectral frequency integration/averaging is performed. The valid literals of this enumeration are
octant(default),hemisphere, andsphere
- Type:
enum (optional).
- integration_density¶
The integration/sampling density or equivalently the number of (alpha, beta) orientations over which the frequency spatial averaging is performed within the given volume. If \(n\) is the integration_density, then the total number of orientations is given as
(56)¶\[n_\text{octants} \frac{(n+1)(n+2)}{2} n_\gamma,\]where \(n_\text{octants}\) is the number of octants in the given volume and \(n_\gamma\) is the number of gamma angles. The default value is 70.
- Type:
int (optional).
- decompose_spectrum¶
The value specifies how a simulation result is decomposed into an array of spectra. The valid literals of this enumeration are
none(default): When the value is none, the resulting simulation is a single spectrum, which is an integration of the spectra over all spin systems.spin_system: When the value is spin_system, the resulting simulation is an array of spectra, where each spectrum arises from a spin system within the Simulator object.
- Type:
enum (optional).
- isotropic_interpolation¶
Interpolation scheme for isotropic binning. The valid literals are
linear(default): linear interpolation.gaussian: Gaussian interpolation with sigma=0.25*bin_width.
- Type:
enum (optional).
- custom_sampling¶
A CustomSampling object specifying the coordinates and weights used in powder averaging.
- Type:
- is_complex¶
When True, the simulation computes both real and imaginary components of the signal. When False, only the real component is computed. Default is True.
- Type:
bool
Example
>>> a = Simulator() >>> a.config.number_of_sidebands = 128 >>> a.config.number_of_gamma_angles = 10 >>> a.config.integration_density = 96 >>> a.config.integration_volume = 'hemisphere' >>> a.config.decompose_spectrum = 'spin_system'
- get_orientations_count()¶
Return the total number of orientations.
Example
>>> a = Simulator() >>> a.config.integration_density = 20 >>> a.config.integration_volume = 'hemisphere' >>> a.config.get_orientations_count() # (4 * 21 * 22 / 2) = 924 924
- json(exclude={}, units=True) dict¶
Parse the class object to a JSON compliant Python dictionary object.
- Parameters:
exclude – Set of keys that will be excluded from the result.
units – If true, the attribute value is a physical quantity expressed as a string with a number and a unit, else a float.
Returns: dict
- classmethod parse_dict_with_units(json_dict: dict)¶
Parse the physical quantity from a dictionary representation of the class object, where the physical quantity is expressed as a string with a number and a unit.
- Parameters:
json_dict (dict) – A required python dict object.
- reduced_dict(exclude={}) dict¶
Returns a reduced dictionary representation of the class object by removing all key-value pairs corresponding to keys listed in the exclude argument, and keys with a value of None.
- Parameters:
exclude – A list of keys to exclude from the dictionary.
Return: A dict.
CustomSampling¶
- class mrsimulator.simulator.config.CustomSampling(*, alpha: Optional[ndarray] = None, beta: Optional[ndarray] = None, weight: Optional[ndarray] = None, vertex_indexes: Optional[ndarray] = None)¶
Bases:
BaseModelCustom orientational sampling for powder averaging.
- alpha¶
An array of size N of \(\alpha\) angle coordinates in radians.
- Type:
ndarray
- beta¶
An array of size N of \(\beta\) angle coordinates in radians.
- Type:
ndarray
- weight¶
An array of size N of weights corresponding to \((\alpha, \beta)\) coordinates.
- Type:
ndarray
- vertex_indexes¶
A 2D array of shape (N, 3) with each row listing the three indexes of \((\alpha, \beta)\) coordinates that forms a triangular mesh on a unit sphere. The indexes are used in frequency interpolation. The default value is None and corresponds to no interpolation.
- Type:
ndarray (optional)