Method

class mrsimulator.Method(*, property_units: Dict = {'magnetic_flux_density': 'T', 'rotor_angle': 'rad', 'rotor_frequency': 'Hz'}, name: str = None, label: str = None, description: str = None, channels: List[str] = [], spectral_dimensions: List[mrsimulator.method.spectral_dimension.SpectralDimension] = [SpectralDimension(property_units={'spectral_width': 'Hz', 'reference_offset': 'Hz', 'origin_offset': 'Hz'}, count=1024, spectral_width=25000.0, reference_offset=0.0, origin_offset=None, label=None, description=None, events=[])], affine_matrix: Union[numpy.ndarray, List] = None, simulation: Union[csdmpy.csdm.CSDM, numpy.ndarray] = None, experiment: Union[csdmpy.csdm.CSDM, numpy.ndarray] = None)

Bases: mrsimulator.utils.parseable.Parseable

Base Method class. A method class represents the NMR method.

channels

The value is a list of isotope symbols over which the given method applies. An isotope symbol is given as a string with the atomic number followed by its atomic symbol, for example, ‘1H’, ‘13C’, and ‘33S’. The default is an empty list. The number of isotopes in a channel depends on the method. For example, a BlochDecaySpectrum method is a single channel method, in which case, the value of this attribute is a list with a single isotope symbol, [‘13C’].

Example

>>> bloch = Method()
>>> bloch.channels = ['1H']
Type

List[str] (optional)

spectral_dimensions

The number of spectral dimensions depends on the given method. For example, a BlochDecaySpectrum method is a one-dimensional method and thus requires a single spectral dimension. The default is a single default SpectralDimension object.

Example

>>> bloch = Method()
>>> bloch.spectral_dimensions = [SpectralDimension(count=8, spectral_width=50)]
>>> # or equivalently
>>> bloch.spectral_dimensions = [{'count': 8, 'spectral_width': 50}]
Type

List[SpectralDimension] or List[dict] (optional).

simulation

An object holding the result of the simulation. The initial value of this attribute is None. A value is assigned to this attribute when you run the simulation using the run() method.

Type

CSDM or ndarray (N/A)

experiment

An object holding the experimental measurement for the given method, if available. The default value is None.

Example

>>> bloch.experiment = my_data 
Type

CSDM or ndarray (optional)

name

Name or id of the method. The default value is None.

Example

>>> bloch.name = 'BlochDecaySpectrum'
>>> bloch.name
'BlochDecaySpectrum'
Type

str (optional)

label

Label for the method. The default value is None.

Example

>>> bloch.label = 'One pulse acquired spectrum'
>>> bloch.label
'One pulse acquired spectrum'
Type

str (optional)

description

A description of the method. The default value is None.

Example

>>> bloch.description = 'Huh!'
>>> bloch.description
'Huh!'
Type

str (optional)

affine_matrix

A (n x n) affine transformation matrix, where n is the number of spectral_dimensions. If provided, the corresponding affine transformation is applied to the computed frequencies. The default is None, i.e., no transformation is applied.

Example

>>> method = Method2D()
>>> method.affine_matrix = [[1, -1], [0, 1]]
>>> print(method.affine_matrix)
[[ 1 -1]
 [ 0  1]]
Type

np.ndarray or 2D list (optional)

Method Documentation

classmethod parse_dict_with_units(py_dict)

Parse the physical quantity from a dictionary representation of the Method object, where the physical quantity is expressed as a string with a number and a unit.

Parameters

py_dict (dict) – A python dict representation of the Method object.

Returns

A Method object.

json() mrsimulator.method.Method.dict

Parse the class object to a JSON compliant python dictionary object, where the attribute value with physical quantity is expressed as a string with a value and a unit.

Returns

A python dict object.

update_spectral_dimension_attributes_from_experiment()

Update the spectral dimension attributes of the method to match the attributes of the experiment from the experiment attribute.

get_transition_pathways(spin_system) List[mrsimulator.transition.pathway.TransitionPathway]

Return a list of transition pathways from the given spin system that satisfy the query selection criterion of the method.

Parameters

spin_system (SpinSystem) – A SpinSystem object.

Returns

An array of TransitionPathway objects. Each TransitionPathway object is an ordered collection of Transition objects.

Example

>>> from mrsimulator import SpinSystem
>>> from mrsimulator.methods import ThreeQ_VAS
>>> sys = SpinSystem(sites=[{'isotope': '27Al'}, {'isotope': '29Si'}])
>>> method = ThreeQ_VAS(channels=['27Al'])
>>> pprint(method.get_transition_pathways(sys))
[|1.5, -0.5⟩⟨-1.5, -0.5| ⟶ |-0.5, -0.5⟩⟨0.5, -0.5|,
 |1.5, -0.5⟩⟨-1.5, -0.5| ⟶ |-0.5, 0.5⟩⟨0.5, 0.5|,
 |1.5, 0.5⟩⟨-1.5, 0.5| ⟶ |-0.5, -0.5⟩⟨0.5, -0.5|,
 |1.5, 0.5⟩⟨-1.5, 0.5| ⟶ |-0.5, 0.5⟩⟨0.5, 0.5|]
shape() tuple

The shape of the method’s spectral dimension array.

Returns

tuple

Example

>>> from mrsimulator.methods import Method2D
>>> method = Method2D(spectral_dimensions=[{'count': 40}, {'count': 10}])
>>> method.shape()
(40, 10)