SpectralQuantity#

class astropy.coordinates.SpectralQuantity(value, unit=None, doppler_rest=None, doppler_convention=None, **kwargs)[source]#

Bases: SpecificTypeQuantity

One 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 Quantity class is that in SpectralQuantity, the u.spectral equivalency 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:
valuendarray or Quantity or SpectralQuantity

Spectral axis data values.

unitastropy:unit-like

Unit for the given data.

doppler_restQuantity [:ref: ‘speed’], optional

The rest value to use for conversions from/to velocities

doppler_conventionstr, optional

The convention to use when converting the spectral data to/from velocities.

Attributes Summary

doppler_convention

The defined convention for conversions to/from velocity space.

doppler_rest

The rest value of the spectrum used for transformations to/from velocity space.

Methods Summary

to(unit[, equivalencies, doppler_rest, ...])

Return a new SpectralQuantity object 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:
str

One 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 Quantity object.

Methods Documentation

to(unit, equivalencies=[], doppler_rest=None, doppler_convention=None)[source]#

Return a new SpectralQuantity object with the specified unit.

By default, the spectral equivalency 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 UnitBase object or a string parseable by the units package, and should be a spectral unit.

equivalencieslist of Equivalency, 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. If None, no equivalencies will be applied at all, not even any set globally or within a context.

doppler_restQuantity [: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:
SpectralQuantity

New 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.

equivalencieslist of 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 for Quantity, but may be set for subclasses). If None, no equivalencies will be applied at all, not even any set globally or within a context.

Returns:
valuendarray or scalar

The value in the units specified. For arrays, this will be a view of the data if no unit conversion was necessary.

See also

to

Get a new instance in a different unit.