NRAO Home > CASA > CASA Toolkit Reference Manual
##### coordsys.setconversiontype - Function

1.1.3 Set extra reference conversion layer

Description

Some coordinates contain a reference code. Examples of reference codes are B1950 and J2000 for direction coordinates, or LSRK and BARY for spectral coordinates. When you do conversions between pixel and world coordinate, the coordinates are in the reference frame corresponding to these codes.

This function allows you to specify a different reference frame which is used when converting between world and pixel coordinate (see function conversiontype to recover the conversion types). If it returns F, it means that although the conversion machines were successfully created, a trial conversion failed. This usually means the REST frame was involved which requires a radial velocity (not yet implemented). If this happens, the conversion type will be left as it was. The function fails if more blatant things are wrong like a missing coordinate, or an incorrect reference code.

The list of possible reference codes can be obtained via function referencecode.

With this function, you specify the desired reference code. Then, when a conversion between pixel and world is requested, an extra conversion is done to (toWorld) or from (toPixel) the specified reference frame.

The summary function shows the extra conversion reference system to the right of the native reference system (if it is different) and in parentheses.

Note that to convert between different spectral reference frames, you need a position, epoch and direction. The position (telescope) and epoch (date of observation), if not in your coordinate system can be set with functions settelescope and setepoch. The direction is the reference direction of the required direction coordinate in the coordinate system.

As an example, let us say you are working with a spectral coordinate which was constructed with the LSRK reference frame. You want to convert some pixel coordinates to barycentric velocities (reference code BARY).

"""
#
print "\t----\t setconversiontype Ex 1 \t----"
csys = cs.newcoordsys(direction=T, spectral=T); # Create coordinate system
rtn=csys.findcoordinate(’spectral’)             # Find spectral coordinate
wa=rtn[’world’]
pa=rtn[’pixel’]
u = csys.units()[wa]                            # Spectral unit
print csys.referencecode(type=’spectral’)       # Which is  in LSRK reference frame
#LSRK
p = [10,20,30]
w = csys.toworld(p, format=’n’)           # Convert a pixel to LSRK world
print ’pixel, world = ’, p, w[’numeric’]
#pixel, world =  [10, 20, 30] [21589.999816660376, 20.000112822985134, 1415030000.0]
p2 = csys.topixel(w)                      # and back to pixel
print ’world, pixel = ’, w[’numeric’], p2
#world, pixel =  [21589.999816660376, 20.000112822985134, 1415030000.0]
# [10.00000000000248, 19.999999999999801, 30.0]
# Convert LSRK frequency to LSRK velocity
v = csys.frequencytovelocity(value=w[’numeric’][wa], frequnit=u,
print ’pixel, frequency, velocity = ’, p[pa], w[’numeric’][wa], v
#pixel, frequency, velocity =  30 1415030000.0 1134612.30321
csys.setconversiontype(spectral=’BARY’)   # Specify BARY reference code
w = csys.toworld(p, format=’n’)           # Convert a pixel to BARY world
print ’pixel, world = ’, p, w[’numeric’]
#pixel, world =  [10, 20, 30] [21589.999816660376, 20.000112822985134, 1415031369.0081882]
p2 = csys.topixel(w)                      # and back to pixel
print ’world, pixel = ’, w[’numeric’], p2
#world, pixel =  [21589.999816660376, 20.000112822985134, 1415031369.0081882]
# [10.00000000000248, 19.999999999999801, 30.0]
# Convert BARY frequency to BARY velocity
v = csys.frequencytovelocity(value=w[’numeric’][wa], frequnit=u,
print ’pixel, frequency, velocity = ’, p[pa], w[’numeric’][wa], v
#pixel, frequency, velocity =  30 1415031369.01 1134323.35878
#
"""

You must also be aware of when this extra layer is active and when it is not. It’s a bit nasty.

• - Whenever you use toWorld, toPixel toWorldMany, or toPixelMany the layer is active.
• - Whenever you use convert or convertMany the layer may be active. Here are the rules !

It is only relevant to spectral and direction coordinates.

For the direction coordinate part of your conversion, if you request a pure world or pixel conversion it is active. Any pixel/world mix will not invoke it (because it is ill defined).

For the spectral coordinate part it is always active (only one axis so must be pixel or world).

• - This layer is irrelevant to all functions converting between frequency and velocity, and absolute and relative. The values are in whatever frame you are working with.

The summary function lists the reference frame for direction and spectral coordinates. If you have also set a conversion reference code it also lists that (to the right in parentheses).

Arguments

 Inputs direction Reference code allowed: string Default: spectral Reference code allowed: string Default:
Returns
bool
__________________________________________________________________