Units
WrightTools provides its own units system. You can use it directly, if you wish.
>>> import WrightTools as wt
>>> wt.units.convert(2., 'eV', 'nm')
619.9209921660013
Under the hood, the WrightTools units system is backed by a Pint <https://pint.readthedocs.io unit registry. This registry has all of the units in the default Pint registry, plus a few added by WrightTools (including some extra aliases of pint units for backwards compatibility with older WrightTools). Additionally this unit registry automatically enables the spectroscopy context as well as a custom context for handling delay behavior (which inserts a factor of 2 as delays typically increase the path of light by two times their physical movement).
The pint unit registry can be directly accessed at wt.units.ureg
.
To query whether a specific conversion is applicable, you can use wt.units.is_valid_conversion()
.
To get a list of commonly used units that are valid conversions, you can use wt.units.get_valid_conversions()
.
This same units system enables the units-aware properties throughout WrightTools.
The units system also provides a symbol for many units, enabling easy plotting.
You can get the symbol using wt.units.get_symbol()
.
The following table contains units commonly used in WrightTools, though many others (including compound units) may be used if desired.
name |
description |
symbol |
rad |
radian |
\(\omega\) |
deg |
degrees |
\(\omega\) |
fs |
femtoseconds |
\(\tau\) |
ps |
picoseconds |
\(\tau\) |
ns |
nanoseconds |
\(\tau\) |
nm |
nanometers |
\(\lambda\) |
wn |
wavenumbers |
\(\bar{\nu}\) |
eV |
electronvolts |
\(\hslash\omega\) |
meV |
millielectronvolts |
\(\hslash\omega\) |
Hz |
hertz |
\(f\) |
THz |
terahertz |
\(f\) |
GHz |
gigahertz |
\(f\) |
K |
kelvin |
\(T\) |
deg_C |
celsius |
\(T\) |
deg_F |
fahrenheit |
\(T\) |
mOD |
mOD |
None |
OD |
OD |
None |
nm_p |
nanometers |
None |
um |
microns |
\(\lambda\) |
mm |
millimeters |
\(\lambda\) |
cm |
centimeters |
\(\lambda\) |
in |
inches |
\(\lambda\) |
fs_t |
femtoseconds |
\(\tau\) |
ps_t |
picoseconds |
\(\tau\) |
ns_t |
nanoseconds |
\(\tau\) |
us_t |
microseconds |
\(\tau\) |
ms_t |
milliseconds |
\(\tau\) |
s_t |
seconds |
\(\tau\) |
m_t |
minutes |
\(\tau\) |
h_t |
hours |
\(\tau\) |
d_t |
days |
\(\tau\) |