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

1.1.3 Convert velocity to frequency


Description

This function converts velocities to frequencies.

The input velocities are specified via a vector of numeric values, a specified unit (velunit), and a velocity doppler definition (doppler).

The frequencies are returned in a vector for which you specify the units (frequnit). If you don’t give the unit, it is assumed that the units are those given by function units for the spectral coordinate.

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

Arguments





Inputs

value

Velocity to convert

allowed:

doubleArray

Default:

frequnit

Unit of output frequencies. Default is intrinisic units.

allowed:

string

Default:

doppler

Velocity doppler definition

allowed:

string

Default:

radio

velunit

Unit of input velocities

allowed:

string

Default:

km/s

Returns
doubleArray

Example

 
 
"""  
#  
print "\t----\t velocitytofrequency Ex 1 \t----"  
ia.fromshape(’hcn.cube’,[64,64,32,4], overwrite=true)  
csys = ia.coordsys()  
rtn = csys.findcoordinate(’spectral’)   # Find spectral axis  
pixel = csys.referencepixel();          # Use reference pixel for non-spectral  
pa = rtn[’pixel’]  
wa = rtn[’world’]  
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  
vel = csys.frequencytovelocity(value=freq, doppler=’optical’, velunit=’km/s’)  
freq2 = csys.velocitytofrequency(value=vel, doppler=’optical’, velunit=’km/s’)  
print "vel=",vel  
print "freq2=",freq2  
csys.done()  
#  
exit() # This is last example so exit casapy if you wish.  
#  
"""  
 
 
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.  Then we convert it  
back to frequency.  They better agree.  
 

__________________________________________________________________


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