unitconvert#

torchspin.unitconvert(value, units, g=GFREE)[source]#

Convert EPR-relevant energy/field quantities between units.

Supported units: cm^-1, eV, K, mT, MHz. Use the form 'unit_a->unit_b'.

Parameters:
  • value (array-like) – Input value(s) in the source unit. Scalar or array.

  • units (str) – Conversion string, e.g. 'cm^-1->MHz' or 'mT->K'.

  • g (float) – g-factor used for conversions involving field (mT). Defaults to the free-electron g-value.

Returns:

out (ndarray) – Converted value(s) in the target unit.

Return type:

np.ndarray

Examples

>>> unitconvert(1.0, 'cm^-1->MHz')        # 29979.2458 MHz
>>> unitconvert(340.0, 'mT->MHz', g=2.0)  # ≈ 9520 MHz