##
Converting between Spectral Coordinate Systems

The principles described in the previous section for converting between celestial coordinate systems also apply to the task of converting between spectral coordinate systems. As an example, let's look at how we might convert between frequency measured in 190#190 as measured in the rest frame of the telescope, and radio velocity measured in 162#162 measured with respect the kinematic Local Standard of Rest.

First we create a default SpecFrameSpecFrame, and then set its attributes to describe the required radio velocity system (this is slightly more convenient, given the relatively large number of attributes, than specifying the attribute values in a single string such as would be passed to the SpecFrame constructor). We then take a copy of this SpecFrame, and change the attribute values so that the copy describes the original frequency system (modifying a copy, rather than creating a new SpecFrame from scratch, avoids the need to specify the epoch, reference position, etc a second time since they are all inherited by the copy):

191#191

Note, the fact that a SpecFrame has only a single axis means that we were able to refer to the Unit attribute without an axis index. The other attributes are: the time of of observation (EpochEpoch), the geographical position of the telescope (ObsLatObsLat & ObsLonObsLon), the position of the source on the sky (RefRARefRA & RefDecRefDec), the rest frequency (RestFreqRestFreq) and the standard of rest (StdOfRestStdOfRest).

The next step is to find a way of converting between these SpecFrames. We use exactly the same code that we did in the previous section where we were converting between celestial coordinate systems:

192#192

A before, this will give us a FrameSetFrameSet (assuming conversion is possible, which should always be the case for our example), and we can use the FrameSet to convert between the two spectral coordinate systems. We use astTran1astTran1 in place of astTran2astTran2 since a SpecFrame has only one axis (unlike a SkyFrameSkyFrame which has two).

For example, if “frq” is an array containing the observed frequency, in GHz, of N spectral channels (describe by “specframe1”), then they could be converted into the new coordinate system (represented by “specframe2”) as follows:

193#193

The radio velocity values are returned in the “vel” array.