pypret.frequencies module

This module handles conversion between frequency units.

The supported units and their shorthands are:

  • wl : wavelength in meter
  • om: angular frequency in rad/s
  • f: frequency in 1/s
  • k: angular wavenumber in rad/m

The conversion functions have the form shorthand2shorthand which is not pythonic but very short. A more pythonic conversion can be achieved by using the convert function

>>> convert(x, 'wl', 'om')

The shorthands will be used throughout the package to identify frequency units.

The functions in this module should be used wherever a frequency convention is necessary to avoid mistakes and make the code more expressive.

pypret.frequencies.convert(x, unit1, unit2)[source]

Convert between two frequency units.

Parameters:
  • x (float or array_like) – Numerical value or array that should be converted.
  • unit2 (unit1,) – Shorthands for the original unit (unit1) and the destination unit (unit2).
Returns:

The converted numerical value or array. It will always be a copy, even if unit1 == unit2.

Return type:

float or array_like

Notes

Unit shorthands can be any of wl : wavelength in meter om : angular frequency in rad/s f : frequency in 1/s k : angular wavenumber in rad/m

pypret.frequencies.f2k(f)[source]
pypret.frequencies.f2om(f)[source]
pypret.frequencies.f2wl(f)[source]
pypret.frequencies.k2f(k)[source]
pypret.frequencies.k2om(k)[source]
pypret.frequencies.k2wl(k)[source]
pypret.frequencies.om2f(om)[source]
pypret.frequencies.om2k(om)[source]
pypret.frequencies.om2wl(om)[source]
pypret.frequencies.wl2f(wl)[source]
pypret.frequencies.wl2k(wl)[source]
pypret.frequencies.wl2om(wl)[source]