SpectralDimension

class mrsimulator.SpectralDimension(*, name: str = None, description: str = None, label: str = None, property_units: Dict = {'origin_offset': 'Hz', 'reference_offset': 'Hz', 'spectral_width': 'Hz'}, count: ConstrainedIntValue = 1024, spectral_width: float = 25000.0, reference_offset: float = 0.0, origin_offset: float = None, reciprocal: Reciprocal = None, events: List[Union[MixingEvent, ConstantDurationEvent, SpectralEvent]] = [])

Bases: Parseable

Base SpectralDimension class defines a spectroscopic dimension of the method.

count

The number of points, \(N\), along the spectroscopic dimension. The default value is 1024.

Type

int (optional).

spectral_width

The spectral width, \(\Delta x\), of the spectroscopic dimension in units of Hz. The default value is 25000.

Type

float (optional).

reference_offset

The reference offset, \(x_0\), of the spectroscopic dimension in units of Hz. The default value is 0.

Type

float (optional).

origin_offset

The origin offset (Larmor frequency) along the spectroscopic dimension in units of Hz. The default value is None. When the value is None, the origin offset is set to the Larmor frequency of the isotope from the channels attribute of the method.

Type

float (optional).

label

The value is a label of the spectroscopic dimension. The default value is None.

Type

str (optional).

description

The value is a description of the spectroscopic dimension. The default value is None.

Type

str (optional).

events

The value describes a series of events along the spectroscopic dimension.

Type

A list of Events or equivalent dict objects (optional).

coordinates_Hz() ndarray

The grid coordinates along the dimension in units of Hz, evaluated as

(44)\[x_\text{Hz} = \left([0, 1, ... N-1] - T\right) \frac{\Delta x}{N} + x_0\]

where \(T=N/2\) and \(T=(N-1)/2\) for even and odd values of \(N\), respectively.

coordinates_ppm() ndarray

The grid coordinates along the dimension as dimension frequency ratio in units of ppm. The coordinates are evaluated as

(45)\[x_\text{ppm} = \frac{x_\text{Hz}} {x_0 + \omega_0}\]

where \(\omega_0\) is the Larmor frequency.

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: dict)

Parse the physical quantities of a SpectralDimension object from a python dictionary object.

Parameters

py_dict (dict) – 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.

to_csdm_dimension() Dimension

Return the spectral dimension as a CSDM dimension object.

classmethod validate_events(**kwargs)

Ensure at least one spectralEvent and warn is the sum of fraction in SpectralEvents is not 1.

classmethod validate_spectral_width(value)

Spectral width cannot be zero.