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


next up previous contents index
Next: is_coordsys - Function Up: coordsys - Tool Previous: coordsys.units - Function


coordsys.velocitytofrequency - Function



Package general
Module images
Tool coordsys


Convert velocity to frequency


Synopsis
velocitytofrequency(value, frequnit, doppler, velunit)


Arguments

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


Returns
Double or vector of double or fail


Description

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



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')
- freq2 := cs.velocitytofrequency(value=vel, doppler='optical', velunit='km/s')

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.








next up previous contents index
Next: is_coordsys - Function Up: coordsys - Tool Previous: coordsys.units - 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