SpectralData#
The madcubapy.coordinates package offers a set of utility functions to work
with spectral data.
Using the SpectralData class#
SpectralData is a wrapper for Astropy’s
SpectralCoord that lets the user specify the input data
as the rest frequency instead of observed frequency.
We can initialize a SpectralData instance using a
value and a unit, or a Quantity object:
>>> from madcubapy.coordinates import SpectralData
>>> sd = SpectralData((266, 267) * u.GHz,
frame_type="rest",
radial_velocity=50 * u.km / u.s,)
>>> sd
[265.95564, 266.95547] GHz
Note that the representation of SpectralData and
SpectralCoord is the observed frequency corresponding
to the input rest frequency and radial velocity.
We can obtain the rest frequency again with:
>>> sd.to_rest()
[266, 267] GHz
We can obtain the array in velocity by providing the rest frequency and doppler
convention (the doppler_rest and doppler_convention parameters can also
be set when initializing the SpectralData object).
>>> sd.to(u.km / u.s, doppler_rest=267.01 * u.GHz, doppler_convention="radio")
[1183.8106, 61.22172] km / s
Extra functionality#
Since this class is based on SpectralCoord, it retains
all of its functionality. Check the
Using SpectralCoord page
for an overview on all of its functionality.