Query objects

class mrsimulator.method.query.TransitionQuery(*, name: str = None, description: str = None, label: str = None, property_units: Dict = {}, ch1: Optional[SymmetryQuery] = SymmetryQuery(name=None, description=None, label=None, property_units={}, P=[0], D=None, F=None, transitions=None), ch2: Optional[SymmetryQuery] = None, ch3: Optional[SymmetryQuery] = None)

Bases: Parseable

TransitionQuery class for querying transition symmetry function.

ch1

An optional SymmetryQuery object for querying symmetry functions at the channel index 0 of the method’s channels array.”

Type:

Optional[mrsimulator.method.query.SymmetryQuery]

ch2

An optional SymmetryQuery object for querying symmetry functions at the channel index 1 of the method’s channels array.”

Type:

Optional[mrsimulator.method.query.SymmetryQuery]

ch3

An optional SymmetryQuery object for querying symmetry functions at the channel index 2 of the method’s channels array.”

Type:

Optional[mrsimulator.method.query.SymmetryQuery]

Example

>>> query = TransitionQuery(ch1={'P': [1], 'D': [0]}, ch2={'P': [-1]})
static cartesian_product_indexing(combinations)

Return Cartesian product of indexes

combination(isotopes, channels)

Combinations of TransitionQuery based on the number of sites per channel.

Parameters:
  • isotopes ((list)) – List of isotope symbols, [‘29Si, ‘13C’, ‘13C’, ‘1H’].

  • channels ((int)) – List of method channels, [‘29Si, ‘13C’].

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.

class mrsimulator.method.query.SymmetryQuery(*, name: str = None, description: str = None, label: str = None, property_units: Dict = {}, P: List[int] = [0], D: List[int] = None, F: List[float] = None, transitions: List[Transition] = None)

Bases: Parseable

Base SymmetryQuery class.

P

A list of p symmetry functions per site. Here p = Δm = \(m_f - m_i\) is the difference between the spin quantum numbers of the final and initial states.

Example

>>> method = Method(channels=['1H'], spectral_dimensions=[{"events": [
...     {"fraction": 1}
... ]}])
>>> method.spectral_dimensions[0].events[0].transition_queries[0].ch1.P = [-1]
Type:

List[int]

D

A list of d symmetry functions per site. Here d = \(m_f^2 - m_i^2\) is the difference between the square of the spin quantum numbers of the final and initial states.

Example

>>> method.spectral_dimensions[0].events[0].transition_queries[0].ch1.D = [0]
Type:

List[int]

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.

query_combination(symmetry, n_site_at_channel_id)

Combination of symmetry query based on the number of sites in a channel.

Parameters:
  • symmetry ((str)) – The symmetry element, ‘P’ or ‘D’.

  • n_site_at_channel ((int)) – Number of sites for the given channel.

Example

Consider the following

query = {P: [-1], D: [1]} n_isotopes = [3] channels = [‘A’]

then, 1. P query will expand to [-1, 0, 0], [0, -1, 0], and [0, 0, -1] combinations 2. D query will expand to [1, 0, 0], [0, 1, 0], and [0, 0, 1] combinations

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.

class mrsimulator.method.query.Rotation(*, name: str = None, description: str = None, label: str = None, property_units: Dict = {'angle': 'rad', 'phase': 'rad'}, angle: ConstrainedFloatValue = 0.0, phase: float = 0.0)

Bases: Parseable

Base Rotation class.

angle

The rf rotation angle in units of radians.

Type:

float

phase

The rf rotation phase in units of radians.

Type:

float

json(units=True, **kwargs)

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.