Multi-quantum variable-angle spinning¶
The following classes are used when simulating a multi-quantum variable-angle spinning spectrum which correlates the frequencies from the symmetric multiple-quantum transition to the central transition frequencies. The \(p\) and \(d\) pathways for the MQVAS methods are
where \(M\) is the multiple-quantum number. The value of \(M\) depends on the spin quantum number, \(I\), and is listed in Table 15.
Affine mapping
The resulting spectrum is sheared and scaled, such that the frequencies along the indirect dimension are given as
Here, \(\langle \Omega\rangle_\text{MQ-VAS}\) is the average frequency along the indirect dimension, \(\Omega_{m, -m}\) and \(\Omega_{1/2, -1/2}\) are the frequency contributions from the \(|m\rangle \rightarrow |-m\rangle\) symmetric multiple-quantum transition and the central transition, respectively, and \(\kappa\) is the shear factor. The values of the shear factor for various transitions are listed in Table 15.
Spin |
Symmetric multi-quantum transition |
\(M\) |
\(\kappa\) |
---|---|---|---|
3/2 |
\(\left(\frac{3}{2} \rightarrow -\frac{3}{2}\right)\) |
\(-3\) |
21/27 |
5/2 |
\(\left(-\frac{3}{2} \rightarrow \frac{3}{2}\right)\) |
\(3\) |
114/72 |
5/2 |
\(\left(\frac{5}{2} \rightarrow -\frac{5}{2}\right)\) |
\(-5\) |
150/72 |
7/2 |
\(\left(-\frac{3}{2} \rightarrow \frac{3}{2}\right)\) |
\(3\) |
303/135 |
7/2 |
\(\left(-\frac{5}{2} \rightarrow \frac{5}{2}\right)\) |
\(5\) |
165/135 |
7/2 |
\(\left(\frac{7}{2} \rightarrow -\frac{7}{2}\right)\) |
\(-7\) |
483/135 |
9/2 |
\(\left(-\frac{3}{2} \rightarrow \frac{3}{2}\right)\) |
\(3\) |
546/216 |
9/2 |
\(\left(-\frac{5}{2} \rightarrow \frac{5}{2}\right)\) |
\(5\) |
570/216 |
9/2 |
\(\left(-\frac{7}{2} \rightarrow \frac{7}{2}\right)\) |
\(5\) |
84/216 |
Triple-quantum variable-angle spinning method¶
- class mrsimulator.method.lib.ThreeQ_VAS(*, name: str = None, description: str = None, label: str = None, property_units: Dict = {'magnetic_flux_density': 'T', 'rotor_angle': 'rad', 'rotor_frequency': 'Hz'}, channels: List[Union[str, dict, Isotope]], spectral_dimensions: List[SpectralDimension] = [SpectralDimension(name=None, description=None, label=None, property_units={'spectral_width': 'Hz', 'reference_offset': 'Hz', 'origin_offset': 'Hz'}, count=1024, spectral_width=25000.0, reference_offset=0.0, origin_offset=None, reciprocal=None, events=[])], affine_matrix: List = None, simulation: Union[CSDM, ndarray] = None, experiment: Union[CSDM, ndarray] = None, magnetic_flux_density: ConstrainedFloatValue = 9.4, rotor_frequency: ConstrainedFloatValue = 1000000000000.0, rotor_angle: ConstrainedFloatValue = 0.9553166181245)¶
Bases:
MQ_VAS
Simulate a sheared and scaled 3Q 2D variable-angle spinning spectrum.
Note
The attribute rotor_frequency cannot be modified for this method and is set to simulate an infinite speed spectrum.
- Returns:
A
Method
instance.
Example
>>> method = ThreeQ_VAS( ... channels=["87Rb"], ... magnetic_flux_density=7, # in T ... spectral_dimensions=[ ... { ... "count": 128, ... "spectral_width": 3e3, # in Hz ... "reference_offset": -2e3, # in Hz ... "label": "Isotropic dimension", ... }, ... { ... "count": 512, ... "spectral_width": 1e4, # in Hz ... "reference_offset": -5e3, # in Hz ... "label": "MAS dimension", ... }, ... ], ... ) >>> sys = SpinSystem(sites=[Site(isotope='87Rb')]) >>> method.get_transition_pathways(sys) [|-1.5⟩⟨1.5| ⟶ |-0.5⟩⟨0.5|, weight=(1+0j)]
- classmethod check_event_objects_for_compatibility(default_dim, obj_dim, method_dict)¶
Checks Events for compatibility and sets global method attributes
- Parameters:
default_dim (dict) – Dict representation of SpectralDimension in base method
obj_dim (SpectralDimension) – User-passed SpectralDimension object to check
method_dict (dict) – Dict representation of passed method
- classmethod check_method_compatibility(py_dict)¶
Check for events attribute inside the spectral_dimensions. Events are not allowed for NamedMethods.
- dict(**kwargs)¶
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- get_symmetry_pathways(symmetry_element: str) List[SymmetryPathway] ¶
Return a list of symmetry pathways of the method.
- Parameters:
symmetry_element (str) – The symmetry element, ‘P’ or ‘D’.
- Returns:
A list of SymmetryPathway objects.
Single channel example
Example
>>> from mrsimulator.method import Method >>> method = Method( ... channels=['1H'], ... spectral_dimensions=[ ... { ... "events": [ ... { ... "fraction": 0.5, ... "transition_queries": [{"ch1": {"P": [1]}}] ... }, ... { ... "fraction": 0.5, ... "transition_queries": [{"ch1": {"P": [0]}}] ... } ... ], ... }, ... { ... "events": [ ... {"transition_queries": [{"ch1": {"P": [-1]}}]}, ... ], ... } ... ] ... ) >>> pprint(method.get_symmetry_pathways("P")) [SymmetryPathway( ch1(1H): [1] ⟶ [0] ⟶ [-1] total: 1.0 ⟶ 0.0 ⟶ -1.0 )]
Dual channels example
Example
>>> from mrsimulator.method import Method >>> method = Method( ... channels=['1H', '13C'], ... spectral_dimensions=[ ... { ... "events": [{ ... "fraction": 0.5, ... "transition_queries": [ ... {"ch1": {"P": [1]}}, ... {"ch1": {"P": [-1]}}, ... ] ... }, ... { ... "fraction": 0.5, ... "transition_queries": [ # selecting double quantum ... {"ch1": {"P": [-1]}, "ch2": {"P": [-1]}}, ... {"ch1": {"P": [1]}, "ch2": {"P": [1]}}, ... ] ... }], ... }, ... { ... "events": [{ ... "transition_queries": [ # selecting single quantum ... {"ch1": {"P": [-1]}}, ... ] ... }], ... } ... ] ... ) >>> pprint(method.get_symmetry_pathways("P")) [SymmetryPathway( ch1(1H): [1] ⟶ [-1] ⟶ [-1] ch2(13C): None ⟶ [-1] ⟶ None total: 1.0 ⟶ -2.0 ⟶ -1.0 ), SymmetryPathway( ch1(1H): [1] ⟶ [1] ⟶ [-1] ch2(13C): None ⟶ [1] ⟶ None total: 1.0 ⟶ 2.0 ⟶ -1.0 ), SymmetryPathway( ch1(1H): [-1] ⟶ [-1] ⟶ [-1] ch2(13C): None ⟶ [-1] ⟶ None total: -1.0 ⟶ -2.0 ⟶ -1.0 ), SymmetryPathway( ch1(1H): [-1] ⟶ [1] ⟶ [-1] ch2(13C): None ⟶ [1] ⟶ None total: -1.0 ⟶ 2.0 ⟶ -1.0 )]
- get_transition_pathways(spin_system) List[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:
A list of TransitionPathway objects. Each TransitionPathway object is an ordered collection of Transition objects.
Example
>>> from mrsimulator import SpinSystem >>> from mrsimulator.method.lib 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|, weight=(1+0j), |1.5, -0.5⟩⟨-1.5, -0.5| ⟶ |-0.5, 0.5⟩⟨0.5, 0.5|, weight=(1+0j), |1.5, 0.5⟩⟨-1.5, 0.5| ⟶ |-0.5, -0.5⟩⟨0.5, -0.5|, weight=(1+0j), |1.5, 0.5⟩⟨-1.5, 0.5| ⟶ |-0.5, 0.5⟩⟨0.5, 0.5|, weight=(1+0j)]
- json(units=True) dict ¶
Parse the class object to a JSON-compliant Python dictionary object.
- Parameters:
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(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.
- plot(df=None, include_legend=False) figure ¶
Creates a diagram representing the method. By default, only parameters that vary throughout the method are plotted. The figure can be finely adjusted using the matplotlib rcParams.
- Parameters:
df (DataFrame) – DataFrame to plot data from. By default, DataFrame is calculated from summary() and will show only parameters that vary throughout the method plus ‘p’ symmetry pathway and ‘d’ symmetry pathway if it is not none or defined
include_legend (bool) – Optional argument to include a key for event colors. The default is False and no key will be included in the figure
- Returns:
matplotlib.pyplot.figure
Example
>>> from mrsimulator.method.lib import BlochDecaySpectrum >>> method = BlochDecaySpectrum(channels=["13C"]) >>> fig = method.plot()
Adjusting Figure Size rcParams
>>> import matplotlib as mpl >>> from mrsimulator.method.lib import FiveQ_VAS >>> mpl.rcParams["figure.figsize"] = [14, 10] >>> mpl.rcParams["font.size"] = 14 >>> method = FiveQ_VAS(channels=["27Al"]) >>> fig = method.plot(include_legend=True)
Plotting all Parameters, including Constant
>>> from mrsimulator.method.lib import FiveQ_VAS >>> method = FiveQ_VAS(channels=["27Al"]) >>> df = method.summary(drop_constant_columns=False) >>> fig = method.plot(df=df)
- 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.
- shape() tuple ¶
The shape of the method’s spectral dimension array.
- Returns:
tuple
Example
>>> from mrsimulator.method import Method >>> method = Method( ... channels=['1H'], ... spectral_dimensions=[{'count': 40}, {'count': 10}] ... ) >>> method.shape() (40, 10)
- summary(drop_constant_columns=True) DataFrame ¶
Returns a DataFrame giving a summary of the Method. A user can specify optional attributes to include which appear as columns in the DataFrame. A user can also ask to leave out attributes that remain constant throughout the method. Invalid attributes for an Event will be replaced with NAN.
- Parameters:
drop_constant_columns ((bool)) – Removes constant properties if True. The default is True.
- Returns:
- Event number as row and property as column. Invalid properties for an
event type are filled with np.nan
Columns
(str) type: Event type
(int) spec_dim_index: Index of spectral dimension which event belongs to
(str) label: Event label
(float) duration: Duration of the DelayEvent
(float) fraction: Fraction of the SpectralEvent
(Rtotaion) channels: Rotation object of the MixingEvent/RotationEvent
(float) magnetic_flux_density: Magnetic flux density during an event (T)
(float) rotor_frequency: Rotor frequency during an event (Hz)
(float) rotor_angle: Rotor angle during an event converted to Degrees
(FrequencyEnum) freq_contrib: Frequency
- Return type:
pd.DataFrame df
Example
All Possible Columns
>>> from mrsimulator.method.lib import ThreeQ_VAS >>> method = ThreeQ_VAS(channels=["17O"]) >>> df = method.summary(drop_constant_columns=False) >>> pprint(list(df.columns)) ['type', 'spec_dim_index', 'spec_dim_label', 'label', 'duration', 'fraction', 'channels', 'magnetic_flux_density', 'rotor_frequency', 'rotor_angle', 'freq_contrib', 'p', 'd']
Five-quantum variable-angle spinning method¶
- class mrsimulator.method.lib.FiveQ_VAS(*, name: str = None, description: str = None, label: str = None, property_units: Dict = {'magnetic_flux_density': 'T', 'rotor_angle': 'rad', 'rotor_frequency': 'Hz'}, channels: List[Union[str, dict, Isotope]], spectral_dimensions: List[SpectralDimension] = [SpectralDimension(name=None, description=None, label=None, property_units={'spectral_width': 'Hz', 'reference_offset': 'Hz', 'origin_offset': 'Hz'}, count=1024, spectral_width=25000.0, reference_offset=0.0, origin_offset=None, reciprocal=None, events=[])], affine_matrix: List = None, simulation: Union[CSDM, ndarray] = None, experiment: Union[CSDM, ndarray] = None, magnetic_flux_density: ConstrainedFloatValue = 9.4, rotor_frequency: ConstrainedFloatValue = 1000000000000.0, rotor_angle: ConstrainedFloatValue = 0.9553166181245)¶
Bases:
MQ_VAS
Simulate a sheared and scaled 5Q variable-angle spinning spectrum.
Note
The attribute rotor_frequency cannot be modified for this method and is set to simulate an infinite speed spectrum.
- Returns:
A
Method
instance.
Example
>>> method = FiveQ_VAS( ... channels=["17O"], ... magnetic_flux_density=11.7, # in T ... spectral_dimensions=[ ... { ... "count": 512, ... "spectral_width": 5e3, # in Hz ... "reference_offset": -3e3, # in Hz ... "label": "Isotropic dimension", ... }, ... { ... "count": 512, ... "spectral_width": 2e4, # in Hz ... "reference_offset": -2e3, # in Hz ... "label": "MAS dimension", ... }, ... ], ... ) >>> sys = SpinSystem(sites=[Site(isotope='17O')]) >>> method.get_transition_pathways(sys) [|-2.5⟩⟨2.5| ⟶ |-0.5⟩⟨0.5|, weight=(1+0j)]
- classmethod check_event_objects_for_compatibility(default_dim, obj_dim, method_dict)¶
Checks Events for compatibility and sets global method attributes
- Parameters:
default_dim (dict) – Dict representation of SpectralDimension in base method
obj_dim (SpectralDimension) – User-passed SpectralDimension object to check
method_dict (dict) – Dict representation of passed method
- classmethod check_method_compatibility(py_dict)¶
Check for events attribute inside the spectral_dimensions. Events are not allowed for NamedMethods.
- dict(**kwargs)¶
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- get_symmetry_pathways(symmetry_element: str) List[SymmetryPathway] ¶
Return a list of symmetry pathways of the method.
- Parameters:
symmetry_element (str) – The symmetry element, ‘P’ or ‘D’.
- Returns:
A list of SymmetryPathway objects.
Single channel example
Example
>>> from mrsimulator.method import Method >>> method = Method( ... channels=['1H'], ... spectral_dimensions=[ ... { ... "events": [ ... { ... "fraction": 0.5, ... "transition_queries": [{"ch1": {"P": [1]}}] ... }, ... { ... "fraction": 0.5, ... "transition_queries": [{"ch1": {"P": [0]}}] ... } ... ], ... }, ... { ... "events": [ ... {"transition_queries": [{"ch1": {"P": [-1]}}]}, ... ], ... } ... ] ... ) >>> pprint(method.get_symmetry_pathways("P")) [SymmetryPathway( ch1(1H): [1] ⟶ [0] ⟶ [-1] total: 1.0 ⟶ 0.0 ⟶ -1.0 )]
Dual channels example
Example
>>> from mrsimulator.method import Method >>> method = Method( ... channels=['1H', '13C'], ... spectral_dimensions=[ ... { ... "events": [{ ... "fraction": 0.5, ... "transition_queries": [ ... {"ch1": {"P": [1]}}, ... {"ch1": {"P": [-1]}}, ... ] ... }, ... { ... "fraction": 0.5, ... "transition_queries": [ # selecting double quantum ... {"ch1": {"P": [-1]}, "ch2": {"P": [-1]}}, ... {"ch1": {"P": [1]}, "ch2": {"P": [1]}}, ... ] ... }], ... }, ... { ... "events": [{ ... "transition_queries": [ # selecting single quantum ... {"ch1": {"P": [-1]}}, ... ] ... }], ... } ... ] ... ) >>> pprint(method.get_symmetry_pathways("P")) [SymmetryPathway( ch1(1H): [1] ⟶ [-1] ⟶ [-1] ch2(13C): None ⟶ [-1] ⟶ None total: 1.0 ⟶ -2.0 ⟶ -1.0 ), SymmetryPathway( ch1(1H): [1] ⟶ [1] ⟶ [-1] ch2(13C): None ⟶ [1] ⟶ None total: 1.0 ⟶ 2.0 ⟶ -1.0 ), SymmetryPathway( ch1(1H): [-1] ⟶ [-1] ⟶ [-1] ch2(13C): None ⟶ [-1] ⟶ None total: -1.0 ⟶ -2.0 ⟶ -1.0 ), SymmetryPathway( ch1(1H): [-1] ⟶ [1] ⟶ [-1] ch2(13C): None ⟶ [1] ⟶ None total: -1.0 ⟶ 2.0 ⟶ -1.0 )]
- get_transition_pathways(spin_system) List[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:
A list of TransitionPathway objects. Each TransitionPathway object is an ordered collection of Transition objects.
Example
>>> from mrsimulator import SpinSystem >>> from mrsimulator.method.lib 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|, weight=(1+0j), |1.5, -0.5⟩⟨-1.5, -0.5| ⟶ |-0.5, 0.5⟩⟨0.5, 0.5|, weight=(1+0j), |1.5, 0.5⟩⟨-1.5, 0.5| ⟶ |-0.5, -0.5⟩⟨0.5, -0.5|, weight=(1+0j), |1.5, 0.5⟩⟨-1.5, 0.5| ⟶ |-0.5, 0.5⟩⟨0.5, 0.5|, weight=(1+0j)]
- json(units=True) dict ¶
Parse the class object to a JSON-compliant Python dictionary object.
- Parameters:
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(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.
- plot(df=None, include_legend=False) figure ¶
Creates a diagram representing the method. By default, only parameters that vary throughout the method are plotted. The figure can be finely adjusted using the matplotlib rcParams.
- Parameters:
df (DataFrame) – DataFrame to plot data from. By default, DataFrame is calculated from summary() and will show only parameters that vary throughout the method plus ‘p’ symmetry pathway and ‘d’ symmetry pathway if it is not none or defined
include_legend (bool) – Optional argument to include a key for event colors. The default is False and no key will be included in the figure
- Returns:
matplotlib.pyplot.figure
Example
>>> from mrsimulator.method.lib import BlochDecaySpectrum >>> method = BlochDecaySpectrum(channels=["13C"]) >>> fig = method.plot()
Adjusting Figure Size rcParams
>>> import matplotlib as mpl >>> from mrsimulator.method.lib import FiveQ_VAS >>> mpl.rcParams["figure.figsize"] = [14, 10] >>> mpl.rcParams["font.size"] = 14 >>> method = FiveQ_VAS(channels=["27Al"]) >>> fig = method.plot(include_legend=True)
Plotting all Parameters, including Constant
>>> from mrsimulator.method.lib import FiveQ_VAS >>> method = FiveQ_VAS(channels=["27Al"]) >>> df = method.summary(drop_constant_columns=False) >>> fig = method.plot(df=df)
- 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.
- shape() tuple ¶
The shape of the method’s spectral dimension array.
- Returns:
tuple
Example
>>> from mrsimulator.method import Method >>> method = Method( ... channels=['1H'], ... spectral_dimensions=[{'count': 40}, {'count': 10}] ... ) >>> method.shape() (40, 10)
- summary(drop_constant_columns=True) DataFrame ¶
Returns a DataFrame giving a summary of the Method. A user can specify optional attributes to include which appear as columns in the DataFrame. A user can also ask to leave out attributes that remain constant throughout the method. Invalid attributes for an Event will be replaced with NAN.
- Parameters:
drop_constant_columns ((bool)) – Removes constant properties if True. The default is True.
- Returns:
- Event number as row and property as column. Invalid properties for an
event type are filled with np.nan
Columns
(str) type: Event type
(int) spec_dim_index: Index of spectral dimension which event belongs to
(str) label: Event label
(float) duration: Duration of the DelayEvent
(float) fraction: Fraction of the SpectralEvent
(Rtotaion) channels: Rotation object of the MixingEvent/RotationEvent
(float) magnetic_flux_density: Magnetic flux density during an event (T)
(float) rotor_frequency: Rotor frequency during an event (Hz)
(float) rotor_angle: Rotor angle during an event converted to Degrees
(FrequencyEnum) freq_contrib: Frequency
- Return type:
pd.DataFrame df
Example
All Possible Columns
>>> from mrsimulator.method.lib import ThreeQ_VAS >>> method = ThreeQ_VAS(channels=["17O"]) >>> df = method.summary(drop_constant_columns=False) >>> pprint(list(df.columns)) ['type', 'spec_dim_index', 'spec_dim_label', 'label', 'duration', 'fraction', 'channels', 'magnetic_flux_density', 'rotor_frequency', 'rotor_angle', 'freq_contrib', 'p', 'd']
Seven-quantum variable-angle spinning method¶
- class mrsimulator.method.lib.SevenQ_VAS(*, name: str = None, description: str = None, label: str = None, property_units: Dict = {'magnetic_flux_density': 'T', 'rotor_angle': 'rad', 'rotor_frequency': 'Hz'}, channels: List[Union[str, dict, Isotope]], spectral_dimensions: List[SpectralDimension] = [SpectralDimension(name=None, description=None, label=None, property_units={'spectral_width': 'Hz', 'reference_offset': 'Hz', 'origin_offset': 'Hz'}, count=1024, spectral_width=25000.0, reference_offset=0.0, origin_offset=None, reciprocal=None, events=[])], affine_matrix: List = None, simulation: Union[CSDM, ndarray] = None, experiment: Union[CSDM, ndarray] = None, magnetic_flux_density: ConstrainedFloatValue = 9.4, rotor_frequency: ConstrainedFloatValue = 1000000000000.0, rotor_angle: ConstrainedFloatValue = 0.9553166181245)¶
Bases:
MQ_VAS
Simulate a sheared and scaled 7Q variable-angle spinning spectrum.
Note
The attribute rotor_frequency cannot be modified for this method and is set to simulate an infinite speed spectrum.
- Returns:
A
Method
instance.
Example
>>> method = SevenQ_VAS( ... channels=["51V"], ... magnetic_flux_density=4.7, # in T ... spectral_dimensions=[ ... { ... "count": 256, ... "spectral_width": 1e3, # in Hz ... "reference_offset": 1e3, # in Hz ... "label": "Isotropic dimension", ... }, ... { ... "count": 1024, ... "spectral_width": 1e4, # in Hz ... "reference_offset": -2e3, # in Hz ... "label": "MAS dimension", ... }, ... ], ... ) >>> sys = SpinSystem(sites=[Site(isotope='51V')]) >>> method.get_transition_pathways(sys) [|-3.5⟩⟨3.5| ⟶ |-0.5⟩⟨0.5|, weight=(1+0j)]
- classmethod check_event_objects_for_compatibility(default_dim, obj_dim, method_dict)¶
Checks Events for compatibility and sets global method attributes
- Parameters:
default_dim (dict) – Dict representation of SpectralDimension in base method
obj_dim (SpectralDimension) – User-passed SpectralDimension object to check
method_dict (dict) – Dict representation of passed method
- classmethod check_method_compatibility(py_dict)¶
Check for events attribute inside the spectral_dimensions. Events are not allowed for NamedMethods.
- dict(**kwargs)¶
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- get_symmetry_pathways(symmetry_element: str) List[SymmetryPathway] ¶
Return a list of symmetry pathways of the method.
- Parameters:
symmetry_element (str) – The symmetry element, ‘P’ or ‘D’.
- Returns:
A list of SymmetryPathway objects.
Single channel example
Example
>>> from mrsimulator.method import Method >>> method = Method( ... channels=['1H'], ... spectral_dimensions=[ ... { ... "events": [ ... { ... "fraction": 0.5, ... "transition_queries": [{"ch1": {"P": [1]}}] ... }, ... { ... "fraction": 0.5, ... "transition_queries": [{"ch1": {"P": [0]}}] ... } ... ], ... }, ... { ... "events": [ ... {"transition_queries": [{"ch1": {"P": [-1]}}]}, ... ], ... } ... ] ... ) >>> pprint(method.get_symmetry_pathways("P")) [SymmetryPathway( ch1(1H): [1] ⟶ [0] ⟶ [-1] total: 1.0 ⟶ 0.0 ⟶ -1.0 )]
Dual channels example
Example
>>> from mrsimulator.method import Method >>> method = Method( ... channels=['1H', '13C'], ... spectral_dimensions=[ ... { ... "events": [{ ... "fraction": 0.5, ... "transition_queries": [ ... {"ch1": {"P": [1]}}, ... {"ch1": {"P": [-1]}}, ... ] ... }, ... { ... "fraction": 0.5, ... "transition_queries": [ # selecting double quantum ... {"ch1": {"P": [-1]}, "ch2": {"P": [-1]}}, ... {"ch1": {"P": [1]}, "ch2": {"P": [1]}}, ... ] ... }], ... }, ... { ... "events": [{ ... "transition_queries": [ # selecting single quantum ... {"ch1": {"P": [-1]}}, ... ] ... }], ... } ... ] ... ) >>> pprint(method.get_symmetry_pathways("P")) [SymmetryPathway( ch1(1H): [1] ⟶ [-1] ⟶ [-1] ch2(13C): None ⟶ [-1] ⟶ None total: 1.0 ⟶ -2.0 ⟶ -1.0 ), SymmetryPathway( ch1(1H): [1] ⟶ [1] ⟶ [-1] ch2(13C): None ⟶ [1] ⟶ None total: 1.0 ⟶ 2.0 ⟶ -1.0 ), SymmetryPathway( ch1(1H): [-1] ⟶ [-1] ⟶ [-1] ch2(13C): None ⟶ [-1] ⟶ None total: -1.0 ⟶ -2.0 ⟶ -1.0 ), SymmetryPathway( ch1(1H): [-1] ⟶ [1] ⟶ [-1] ch2(13C): None ⟶ [1] ⟶ None total: -1.0 ⟶ 2.0 ⟶ -1.0 )]
- get_transition_pathways(spin_system) List[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:
A list of TransitionPathway objects. Each TransitionPathway object is an ordered collection of Transition objects.
Example
>>> from mrsimulator import SpinSystem >>> from mrsimulator.method.lib 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|, weight=(1+0j), |1.5, -0.5⟩⟨-1.5, -0.5| ⟶ |-0.5, 0.5⟩⟨0.5, 0.5|, weight=(1+0j), |1.5, 0.5⟩⟨-1.5, 0.5| ⟶ |-0.5, -0.5⟩⟨0.5, -0.5|, weight=(1+0j), |1.5, 0.5⟩⟨-1.5, 0.5| ⟶ |-0.5, 0.5⟩⟨0.5, 0.5|, weight=(1+0j)]
- json(units=True) dict ¶
Parse the class object to a JSON-compliant Python dictionary object.
- Parameters:
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(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.
- plot(df=None, include_legend=False) figure ¶
Creates a diagram representing the method. By default, only parameters that vary throughout the method are plotted. The figure can be finely adjusted using the matplotlib rcParams.
- Parameters:
df (DataFrame) – DataFrame to plot data from. By default, DataFrame is calculated from summary() and will show only parameters that vary throughout the method plus ‘p’ symmetry pathway and ‘d’ symmetry pathway if it is not none or defined
include_legend (bool) – Optional argument to include a key for event colors. The default is False and no key will be included in the figure
- Returns:
matplotlib.pyplot.figure
Example
>>> from mrsimulator.method.lib import BlochDecaySpectrum >>> method = BlochDecaySpectrum(channels=["13C"]) >>> fig = method.plot()
Adjusting Figure Size rcParams
>>> import matplotlib as mpl >>> from mrsimulator.method.lib import FiveQ_VAS >>> mpl.rcParams["figure.figsize"] = [14, 10] >>> mpl.rcParams["font.size"] = 14 >>> method = FiveQ_VAS(channels=["27Al"]) >>> fig = method.plot(include_legend=True)
Plotting all Parameters, including Constant
>>> from mrsimulator.method.lib import FiveQ_VAS >>> method = FiveQ_VAS(channels=["27Al"]) >>> df = method.summary(drop_constant_columns=False) >>> fig = method.plot(df=df)
- 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.
- shape() tuple ¶
The shape of the method’s spectral dimension array.
- Returns:
tuple
Example
>>> from mrsimulator.method import Method >>> method = Method( ... channels=['1H'], ... spectral_dimensions=[{'count': 40}, {'count': 10}] ... ) >>> method.shape() (40, 10)
- summary(drop_constant_columns=True) DataFrame ¶
Returns a DataFrame giving a summary of the Method. A user can specify optional attributes to include which appear as columns in the DataFrame. A user can also ask to leave out attributes that remain constant throughout the method. Invalid attributes for an Event will be replaced with NAN.
- Parameters:
drop_constant_columns ((bool)) – Removes constant properties if True. The default is True.
- Returns:
- Event number as row and property as column. Invalid properties for an
event type are filled with np.nan
Columns
(str) type: Event type
(int) spec_dim_index: Index of spectral dimension which event belongs to
(str) label: Event label
(float) duration: Duration of the DelayEvent
(float) fraction: Fraction of the SpectralEvent
(Rtotaion) channels: Rotation object of the MixingEvent/RotationEvent
(float) magnetic_flux_density: Magnetic flux density during an event (T)
(float) rotor_frequency: Rotor frequency during an event (Hz)
(float) rotor_angle: Rotor angle during an event converted to Degrees
(FrequencyEnum) freq_contrib: Frequency
- Return type:
pd.DataFrame df
Example
All Possible Columns
>>> from mrsimulator.method.lib import ThreeQ_VAS >>> method = ThreeQ_VAS(channels=["17O"]) >>> df = method.summary(drop_constant_columns=False) >>> pprint(list(df.columns)) ['type', 'spec_dim_index', 'spec_dim_label', 'label', 'duration', 'fraction', 'channels', 'magnetic_flux_density', 'rotor_frequency', 'rotor_angle', 'freq_contrib', 'p', 'd']