Getting Started Documentation Glish Learn More Programming Contact Us
Version 1.9 Build 1488
News FAQ
Search Home


next up previous contents index
Next: coordsys.fromrecord - Function Up: coordsys - Tool Previous: coordsys.frequencytofrequency - Function


coordsys.frequencytovelocity - Function



Package general
Module images
Tool coordsys


Convert frequency to velocity


Synopsis
frequencytovelocity(value, frequnit, doppler, velunit)


Arguments

value in Frequency to convert
    Allowed: Numeric or vector of numeric
frequnit in Unit of input frequencies
    Allowed: String
    Default: Intrinsic units
doppler in Velocity doppler definition
    Allowed: String
    Default: 'radio'
velunit in Unit of output velocities
    Allowed: String
    Default: 'km/s'


Returns
Double or vector of double or fail


Description

This function (short-hand name ftv) 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 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 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.



Example
- im := image('hcn.cube')
- cs := im.coordsys()
-
- local pa, wa;
- cs.findcoordinate(pa, wa, 'spectral')     # Find spectral axis
- pixel := cs.referencepixel();             # Use reference pixel for non-spectral
-
- nFreq := im.shape()[pa[1]];               # Length of spectral axis
- freq := [];
- for (i in 1:nFreq) { 
    pixel[pa[1]] := i;                      # Assign value for spectral axis of pixel coordinate
    w := cs.toworld(value=pixel, format='n')# Convert pixel to world
    freq[i] := w[wa[1]];                    # Fish out frequency
  }
- vel := cs.frequencytovelocity(value=freq, doppler='optical', velunit='km/s')
- print vel
[137.868718 133.690916 129.513229 125.33566 121.158206 116.980869 
 112.803649 108.626544 104.449556 100.272685 96.0959294 91.9192905 
  87.7427679 83.5663616 79.3900717 75.213898 71.0378408 66.8618999 
  62.6860752 58.5103668 54.3347748 50.159299 45.9839395 41.8086963 
  37.6335694 33.4585588 29.2836644 25.1088863 20.9342244 16.7596788 
  12.5852495  8.41093638 4.23673952 0.0626588884 -4.11130551 -8.28515368 
 -12.4588856 -16.6325014 -20.8060009 -24.9793842 -29.1526513 -33.3258023 
 -37.498837 -41.6717555 -45.8445579 -50.0172441 -54.1898141 -58.3622679 
 -62.5346056 -66.7068272 -70.8789325 -75.0509218 -79.2227948 -83.3945518 
 -87.5661926 -91.7377173 -95.9091259 -100.080418 -104.251595 -108.422655 
-112.593599 -116.764427 -120.935139 -125.105735]

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.





next up previous contents index
Next: coordsys.fromrecord - Function Up: coordsys - Tool Previous: coordsys.frequencytofrequency - Function   Contents   Index
Please send questions or comments about AIPS++ to aips2-request@nrao.edu.
Copyright © 1995-2000 Associated Universities Inc., Washington, D.C.

Return to AIPS++ Home Page
2006-08-01