The Spectrum Class¶
Spectrum objects are used link values in an array to a specific physical quantity and associated units. Conversion between different quantities and units is automated via this class.
spectrum_type¶
- wavelength
- frequency
- energy
- angularfrequency
- wavenumber
unit¶
- meter [wavelength]
- micrometer [wavelength]
- nanometer [wavelength]
- hertz [frequency]
- electronvolt [energy]
- 1/s [angular frequency]
- 1/cm [wavenumber]
Full API¶
spectrum is an array of data which defines a physical spectrum
A Spectrum is a numpy array with an associated type which describes the physical quantity (e.g. wavelength, energy, etc.) and a unit for specifiying the SI unit of the spectrum (e.g. meter, electronVolt)
-
class
spectrum.
Spectrum
(values, spectrum_type='wavelength', unit='m')¶ Class for converting between wavelength/frequency/energy when defining spectral quantities
Methods
check_type
(type_to_check, is_type)test if two spectrum_type strings are equal taking aliases into account check_unit
(unit, is_unit)test if two unit strings are equal taking aliases into account contains
(self, other)detects if the values of another Spectrum object are completely contained within the range of the values defined in this Spectrum object convert_from
(spectrum_type, unit, values)converts units from given type into wavelength/meter representation convert_to
(self, spectrum_type, unit[, in_place])converts units from wavelength/meter representation to given type/unit display_string
(unit)gets the SI standard form of a unit string for printing get_type_unit_string
(self)formats the unit and spectrum_type for display as an axis label standardise_unit
(spectrum_type, unit)takes a spectrum_type and unit string and returns them in a standardised form standardise_values
(self, values)check if we need to convert the value in order to obtain the wavelength/meter representation -
static
check_type
(type_to_check, is_type)¶ test if two spectrum_type strings are equal taking aliases into account
-
static
check_unit
(unit, is_unit)¶ test if two unit strings are equal taking aliases into account
-
contains
(self, other)¶ detects if the values of another Spectrum object are completely contained within the range of the values defined in this Spectrum object
-
static
convert_from
(spectrum_type, unit, values)¶ converts units from given type into wavelength/meter representation
-
convert_to
(self, spectrum_type, unit, in_place=False)¶ converts units from wavelength/meter representation to given type/unit
-
static
display_string
(unit)¶ gets the SI standard form of a unit string for printing
-
get_type_unit_string
(self)¶ formats the unit and spectrum_type for display as an axis label
-
static
standardise_unit
(spectrum_type, unit)¶ takes a spectrum_type and unit string and returns them in a standardised form
-
standardise_values
(self, values)¶ check if we need to convert the value in order to obtain the wavelength/meter representation
-
static
-
spectrum.
ang_freq_to_standard
(unit, values)¶ converts angular frequency values to standardised representation
-
spectrum.
energy_to_standard
(unit, values)¶ converts energy values to standardised representation
-
spectrum.
frequency_to_standard
(unit, values)¶ converts frequency values to standardised representation
-
spectrum.
safe_inverse
(values)¶ returns the inverse of a scalar or array while converting values of 0 to inf and values of inf to 0
-
spectrum.
safe_inverse_array
(values)¶ takes the inverse of an array while converting values of 0 to inf and values of inf to 0
-
spectrum.
safe_inverse_scalar
(value)¶ takes the inverse of a scalar while converting values of 0 to inf and values of inf to 0
-
spectrum.
to_ang_freq
(unit, values)¶ converts values from standard to angular frequency representation
-
spectrum.
to_energy
(unit, values)¶ converts values from standard to energy representation
-
spectrum.
to_frequency
(unit, values)¶ converts values from standard to frequency representation
-
spectrum.
to_wavelength
(unit, values)¶ converts values from standard to wavelength representation
-
spectrum.
to_wavenumber
(unit, values)¶ converts values from standard to wavenumber representation
-
spectrum.
wavelength_to_standard
(unit, values)¶ converts wavelength values to standardised representation
-
spectrum.
wavenumber_to_standard
(unit, values)¶ converts wavenumber values to standardised representation