Bloch Decay Central Transition Spectrum method

class mrsimulator.method.lib.BlochDecayCTSpectrum(*, name: str = 'BlochDecayCTSpectrum', description: str = 'A one-dimensional central transition selective Bloch decay spectrum method.', 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 = 0.0, rotor_angle: ConstrainedFloatValue = 0.9553166181245)

Bases: BaseNamedMethod1D

Simulate a Bloch decay central transition selective spectrum.

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']

Example

>>> from mrsimulator.method.lib import BlochDecayCTSpectrum
>>> from mrsimulator.method import SpectralDimension
>>> bloch_decay_ct = BlochDecayCTSpectrum(
...     channels=["1H"],
...     rotor_frequency=5000,  # in Hz
...     rotor_angle=54.735 * 3.14159 / 180,  # in rad
...     magnetic_flux_density=9.4,  # in T
...     spectral_dimensions=[
...         SpectralDimension(count=1024, spectral_width=50000, reference_offset=-8000)
...     ],
... )

Bloch decay central transition selective method is part of the methods library, but can be constructed with a generic method as follows

>>> from mrsimulator.method import Method
>>> bloch_decay_ct = Method(
...     channels=["1H"],
...     rotor_frequency=5000,  # in Hz
...     rotor_angle=54.735 * 3.14159 / 180,  # in rad
...     magnetic_flux_density=9.4,  # in T
...     spectral_dimensions=[
...         {
...             "count": 1024,
...             "spectral_width": 50000,  # in Hz
...             "reference_offset": -8000,  # in Hz
...             "events": [{"transition_queries": [{"ch1": {"P": [-1], "D": [0]}}]}],
...         }
...     ],
... )