SpectralQuantity#
- class astropy.coordinates.SpectralQuantity(value, unit=None, doppler_rest=None, doppler_convention=None, **kwargs)[source]#
 Bases:
SpecificTypeQuantityOne or more value(s) with spectral units.
The spectral units should be those for frequencies, wavelengths, energies, wavenumbers, or velocities (interpreted as Doppler velocities relative to a rest spectral value). The advantage of using this class over the regular
Quantityclass is that inSpectralQuantity, theu.spectralequivalency is enabled by default (allowing automatic conversion between spectral units), and a preferred Doppler rest value and convention can be stored for easy conversion to/from velocities.- Parameters:
 - value
ndarrayorQuantityorSpectralQuantity Spectral axis data values.
- unitastropy:unit-like
 Unit for the given data.
- doppler_rest
Quantity[:ref: ‘speed’], optional The rest value to use for conversions from/to velocities
- doppler_convention
python:str, optional The convention to use when converting the spectral data to/from velocities.
- value
 
Attributes Summary
The defined convention for conversions to/from velocity space.
The rest value of the spectrum used for transformations to/from velocity space.
Methods Summary
to(unit[, equivalencies, doppler_rest, ...])Return a new
SpectralQuantityobject with the specified unit.to_value([unit])The numerical value, possibly in a different unit.
Attributes Documentation
- doppler_convention#
 The defined convention for conversions to/from velocity space.
- Returns:
 python:strOne of ‘optical’, ‘radio’, or ‘relativistic’ representing the equivalency used in the unit conversions.
- doppler_rest#
 The rest value of the spectrum used for transformations to/from velocity space.
- Returns:
 Quantity[:ref: ‘speed’]Rest value as an astropy
Quantityobject.
Methods Documentation
- to(unit, equivalencies=[], doppler_rest=None, doppler_convention=None)[source]#
 Return a new
SpectralQuantityobject with the specified unit.By default, the
spectralequivalency will be enabled, as well as one of the Doppler equivalencies if converting to/from velocities.- Parameters:
 - unitastropy:unit-like
 An object that represents the unit to convert to. Must be an
UnitBaseobject or a string parseable by theunitspackage, and should be a spectral unit.- equivalencies
python:listofEquivalency, optional A list of equivalence pairs to try if the units are not directly convertible (along with spectral). See Equivalencies. If not provided or
[], spectral equivalencies will be used. IfNone, no equivalencies will be applied at all, not even any set globally or within a context.- doppler_rest
Quantity[:ref: ‘speed’], optional The rest value used when converting to/from velocities. This will also be set at an attribute on the output
SpectralQuantity.- doppler_convention{‘relativistic’, ‘optical’, ‘radio’}, optional
 The Doppler convention used when converting to/from velocities. This will also be set at an attribute on the output
SpectralQuantity.
- Returns:
 SpectralQuantityNew spectral coordinate object with data converted to the new unit.
- to_value(unit=None, *args, **kwargs)[source]#
 The numerical value, possibly in a different unit.
- Parameters:
 - unitastropy:unit-like, optional
 The unit in which the value should be given. If not given or
None, use the current unit.- equivalencies
python:listofpython:tuple, optional A list of equivalence pairs to try if the units are not directly convertible (see Equivalencies). If not provided or
[], class default equivalencies will be used (none forQuantity, but may be set for subclasses). IfNone, no equivalencies will be applied at all, not even any set globally or within a context.
- Returns:
 - value
ndarrayor scalar The value in the units specified. For arrays, this will be a view of the data if no unit conversion was necessary.
- value
 
See also
toGet a new instance in a different unit.