You're reading the documentation for a development version. For the latest released version, please have a look at v0.5.
cwepr.utils module
General purpose functions and classes used in other modules.
To avoid circular dependencies, this module does not depend on any other modules of the cwepr package, but it can be imported into every other module.
Added in version 0.2.
- cwepr.utils.convert_g2mT(values, mw_freq=None)
Convert g values to millitesla (mT).
Important
Magnetic field values are assumed to be in millitesla (mT) and the microwave frequency to be in Gigahertz (GHz).
- cwepr.utils.convert_mT2g(values, mw_freq=None)
Convert magnetic field values (in millitesla, mT) to g values.
Important
Magnetic field values are assumed to be in millitesla (mT) and the microwave frequency to be in Gigahertz (GHz).
- cwepr.utils.not_zero(value)
Return a value that is not zero to prevent DivisionByZero errors.
Dividing by zero results in NaN values and often hinders evaluating mathematical models. A solution adopted from the lmfit Python package (https://doi.org/10.5281/zenodo.598352) returns a value equivalent to the resolution of a numpy float.
Note
If you use this function excessively within a module, mostly within rather complicated mathematical equations, it might be a good idea to import this function explicitly, to shorten the code, such as:
from cwepr.utils import not_zero
. As usual, readability is king.