NRAO Home > CASA > CASA Toolkit Reference Manual
coordsys.frequencytovelocity - Function

1.1.3 Convert frequency to velocity


Description

This function converts frequencies to velocities.

The input frequencies are specified via a vector of numeric values and a specified unit (frequnit). If you don’t give a frequency unit, it is assumed that the units are those given by function coordsys units() for the spectral coordinate.

This function does not make any frame conversions (e.g. LSR to BARY) but you can specifiy the velocity doppler definition via the doppler argument (see image summary() for possible values).

The velocities are returned in a vector for which you specify the units (velunit - default is km/s).

This function will return a fail if there is no spectral coordinate in the Coordinate System. See also function velocitytofrequency.

Arguments





Inputs

value

Frequency to convert

allowed:

doubleArray

Default:

frequnit

Unit of input frequencies. Default is unit of the spectral coordinate.

allowed:

string

Default:

doppler

Velocity doppler definition

allowed:

string

Default:

radio

velunit

Unit of output velocities

allowed:

string

Default:

km/s

Returns
doubleArray

Example

 
 
"""  
#  
print "\t----\t frequencytovelocity Ex 1 \t----"  
im = ia.fromshape(shape=[10,10,10])  
csys = ia.coordsys()  
rtn = csys.findcoordinate(’spectral’)   # Find spectral axis  
pa=rtn[’pixel’]  
wa=rtn[’world’]  
pixel = csys.referencepixel();          # Use reference pixel for non-spectral  
nFreq = ia.shape()[pa];                 # Length of spectral axis  
freq = [];  
for i in range(nFreq):  
  pixel[pa] = i            # Assign value for spectral axis of pixel coordinate  
  w = csys.toworld(value=pixel, format=’n’)   # Convert pixel to world  
  freq.append(w[’numeric’][wa]);              # Fish out frequency  
print "freq=", freq  
#freq= [1414995000.0, 1414996000.0, 1414997000.0, 1414998000.0,  
# 1414999000.0, 1415000000.0, 1415001000.0, 1415002000.0, 1415003000.0, 1415004000.0]  
vel = csys.frequencytovelocity(value=freq, doppler=’optical’, velunit=’km/s’)  
print "vel=", vel  
#vel= [1146.3662963847394, 1146.153618169159, 1145.9409402542183, 1145.7282626398826,  
# 1145.5155853261515, 1145.3029083129911, 1145.0902316004676, 1144.8775551885467,  
# 1144.6648790772279, 1144.4522032665104]  
#  
"""  
 
 
In this example, we find the optical velocity in km/s of every pixel  
along the spectral axis of our image.  First we  obtain the Coordinate  
System from the image.  Then we find which axis of the Coordinate System  
(image) pertain to the spectral coordinate.  Then we loop over each  
pixel of the spectral axis, and convert a pixel coordinate (one for each  
axis of the image) to world.  We obtain the value for the spectral axis  
from that world vector, and add it to the vector of frequencies.  Then  
we convert that vector of frequencies to velocity.  
 

__________________________________________________________________


More information about CASA may be found at the CASA web page

Copyright 2016 Associated Universities Inc., Washington, D.C.

This code is available under the terms of the GNU General Public Lincense


Home | Contact Us | Directories | Site Map | Help | Privacy Policy | Search