Query objects¶
- class mrsimulator.method.query.TransitionQuery(*, name: str = None, description: str = None, label: str = None, property_units: Dict = {}, ch1: SymmetryQuery = SymmetryQuery(name=None, description=None, label=None, property_units={}, P=[0], D=None, F=None, transitions=None), ch2: SymmetryQuery = None, ch3: SymmetryQuery = None)¶
Bases:
Parseable
TransitionQuery class for querying transition symmetry function.
- ch1¶
An optional SymmetryQuery object for querying symmetry functions at 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 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 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(permutation)¶
Return Cartesian product of indexes
- 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.
- permutation(isotopes, channels)¶
Permutation 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’].
- reduced_dict(exclude={}) dict ¶
Returns a reduced dictionary representation of the class object by removing all key-value pair corresponding to keys listed in the exclude argument, and keys with value as 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_query[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_query[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.
- permutate_query(symmetry, n_site_at_channel_id)¶
Permutation of symmetry query based on the number of sites in given 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 and permutate to [-1, 0, 0], [0, -1, 0], and [0, 0, -1] 2. D query will expand and permutate to [1, 0, 0], [0, 1, 0], and [0, 0, 1]
- reduced_dict(exclude={}) dict ¶
Returns a reduced dictionary representation of the class object by removing all key-value pair corresponding to keys listed in the exclude argument, and keys with value as None.
- Parameters
exclude – A list of keys to exclude from the dictionary.
Return: A dict.
- class mrsimulator.method.query.MixingQuery(*, name: str = None, description: str = None, label: str = None, property_units: Dict = {}, ch1: RotationalQuery = None, ch2: RotationalQuery = None, ch3: RotationalQuery = None)¶
Bases:
Parseable
MixingQuery class for querying transition mixing between events.
- ch1¶
An optional RotationalQuery object for channel at index 0 of method’s channels.”
- Type
Optional[mrsimulator.method.query.RotationalQuery]
- ch2¶
An optional RotationalQuery object for channel at index 1 of method’s channels.”
- Type
Optional[mrsimulator.method.query.RotationalQuery]
- ch3¶
An optional RotationalQuery object for channel at index 2 of method’s channels.”
- Type
Optional[mrsimulator.method.query.RotationalQuery]
Example
>>> query = MixingQuery(ch1={"angle": 1.570796, "phase": 3.141593})
- property channels: List[RotationalQuery]¶
Returns an ordered list of all channels
- 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(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.
- reduced_dict(exclude={}) dict ¶
Returns a reduced dictionary representation of the class object by removing all key-value pair corresponding to keys listed in the exclude argument, and keys with value as None.
- Parameters
exclude – A list of keys to exclude from the dictionary.
Return: A dict.
- class mrsimulator.method.query.RotationalQuery(*, 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 RotationalQuery class.
- angle¶
The rf rotation angle in units of radians.
- Type
float
- phase¶
The rf rotation phase in units of radians.
- Type
float
- 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 pair corresponding to keys listed in the exclude argument, and keys with value as None.
- Parameters
exclude – A list of keys to exclude from the dictionary.
Return: A dict.