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 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(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 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_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 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 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 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: Optional[RotationQuery] = None, ch2: Optional[RotationQuery] = None, ch3: Optional[RotationQuery] = None)¶
Bases:
Parseable
MixingQuery class for querying transition mixing between events.
- ch1¶
An optional RotationQuery object for channel at index 0 of method’s channels.”
- Type:
Optional[mrsimulator.method.query.RotationQuery]
- ch2¶
An optional RotationQuery object for channel at index 1 of method’s channels.”
- Type:
Optional[mrsimulator.method.query.RotationQuery]
- ch3¶
An optional RotationQuery object for channel at index 2 of method’s channels.”
- Type:
Optional[mrsimulator.method.query.RotationQuery]
Example
>>> query = MixingQuery(ch1={"angle": 1.570796, "phase": 3.141593})
- property channels: List[RotationQuery]¶
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.RotationQuery(*, 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 RotationQuery 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 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.MixingEnum(value)¶
Bases:
Enum
Enumerations for defining common mixing queries. The enumerations are as follows:
- TotalMixing¶
Setting query attribute to TotalMixing causes all transitions in one spectral event to all other transitions. This is the same behavior when no MixingEvent is defined between SpectralEvents.
- Type:
str
- NoMixing¶
Defines mixing query where no pathways connect
Example
The query attribute of the
MixingEvent
can be set to the Enum itself or a string representing the Enum.>>> from mrsimulator.method import MixingEvent >>> from mrsimulator.method.query import MixingEnum >>> # From Enum object >>> total_mix = MixingEvent(query=MixingEnum.TotalMixing) >>> no_mix = MixingEvent(query=MixingEnum.NoMixing) >>> # From string representing Enum >>> total_mix = MixingEvent(query="TotalMixing") >>> no_mix = MixingEvent(query="NoMixing")
- classmethod allowed_enums()¶
Returns list of str corresponding to all valid enumerations
- json(**kwargs)¶
Return a JSON-compliant serialization of the enumeration