REFERENCES · EXAMPLES · TIME_REQUIREMENTS · BUGS · SEE_ALSO

## NAME

skymap -- compute the spatial transformation function required to register a list of images using celestial coordinate WCS information

## USAGE

`skymap input reference database`

## PARAMETERS

- input
- The list of input images containing the input celestial coordinate wcs.

- reference
- The list of reference images containing the reference celestial coordinate wcs. The number of reference images must be one or equal to the number of input images.

- database
- The name of the output text database file containing the computed transformations.

- transforms = ""
- An option transform name list. If transforms is undefined then the transforms are assigned record names equal to the input image names.

- results = ""
- Optional output files containing a summary of the results including a description of the transform geometry and a listing of the input coordinates, the fitted coordinates, and the fit residuals. The number of results files must be one or equal to the number of input files. If results is "STDOUT" the results summary is printed on the standard output.

- xmin = INDEF, xmax = INDEF, ymin = INDEF, ymax = INDEF
- The minimum and maximum logical x and logical y coordinates used to generate the grid of reference image control points and define the region of validity of the spatial transformation. Xmin, xmax, ymin, and ymax are assigned defaults of 1, the number of columns in the reference image, 1, and the number of lines in the reference image, respectively.

- nx = 10, ny = 10
- The number of points in x and y used to generate the coordinate grid.

- wcs = "world"
- The world coordinate system of the coordinates. The options are:
- physical
- Physical coordinates are pixel coordinates which are invariant with respect to linear transformations of the physical image data. For example, if the reference image is a rotated section of a larger input image, the physical coordinates of an object in the reference image are equal to the physical coordinates of the same object in the input image, although the logical pixel coordinates are different.

- world
- World coordinates are image coordinates which are invariant with respect to linear transformations of the physical image data and which are in degrees for all celestial coordinate systems. Obviously if the wcs is correct the ra and dec of an object should remain the same no matter how the image is linearly transformed. The default world coordinate system is either 1) the value of the environment variable "defwcs" if set in the user's IRAF environment (normally it is undefined) and present in the image header, 2) the value of the "system" attribute in the image header keyword WAT0_001 if present in the image header or, 3) the "physical" coordinate system.

- xformat = "%10.3f", yformat = "%10.3f"
- The format of the output logical x and y reference and input pixel coordinates in columns 1 and 2 and 3 and 4 respectively. By default the coordinates are output right justified in a field of ten spaces with 3 digits following the decimal point.

- rwxformat = "", rwyformat = ""
- The format of the output reference image celestial coordinates in columns 5 and 6 respectively. The internal default formats will give reasonable output formats and precision for all celestial coordinate systems.

- wxformat = "", wyformat = ""
- The format of the output input image celestial coordinates in columns 7 and 8 respectively. The internal default formats will give reasonable output formats and precision for all celestial coordinate systems.

- fitgeometry = "general"
- The fitting geometry to be used. The options are the following.
- shift
- X and y shifts only are fit.

- xyscale
- X and y shifts and x and y magnification factors are fit. Axis flips are allowed for.

- rotate
- X and y shifts and a rotation angle are fit. Axis flips are allowed for.

- rscale
- X and y shifts, a magnification factor assumed to be the same in x and y, and a rotation angle are fit. Axis flips are allowed for.

- rxyscale
- X and y shifts, x and y magnifications factors, and a rotation angle are fit. Axis flips are allowed for.

- general
- A polynomial of arbitrary order in x and y is fit. A linear term and a distortion term are computed separately. The linear term includes an x and y shift, an x and y scale factor, a rotation and a skew. Axis flips are also allowed for in the linear portion of the fit. The distortion term consists of a polynomial fit to the residuals of the linear term. By default the distortion terms is set to zero.

For all the fitting geometries except "general" no distortion term is fit, i.e. the x and y polynomial orders are assumed to be 2 and the cross term switches are set to "none" regardless of the values of the

*xxorder*,*xyorder*,*xxterms*,*yxorder*,*yyorder*and*yxterms*parameters set by the user.

- function = "polynomial"
- The type of analytic coordinate surfaces to be fit. The options are the
following.
- legendre
- Legendre polynomials in x and y.

- chebyshev
- Chebyshev polynomials in x and y.

- polynomial
- Power series polynomials in x and y.

- xxorder = 2, xyorder = 2, yxorder = 2, yyorder = 2
- The order of the polynomials in x and y for the x and y fits respectively.
The default order and cross term settings define the linear term in x
and y, where the 6 coefficients can be interpreted in terms of an x and y shift,
an x and y scale change, and rotations of the x and y axes. The "shift",
"xyscale", "rotation", "rscale", and "rxyscale", fitting geometries
assume that the polynomial order parameters are 2 regardless of the values
set by the user. If any of the order parameters are higher than 2 and
*fitgeometry*is "general", then a distortion surface is fit to the residuals from the linear portion of the fit.

- xxterms = "half", yxterms = "half"
- The options are:
- none
- The individual polynomial terms contain powers of x or powers of y but not powers of both.

- half
- The individual polynomial terms contain powers of x and powers of y, whose maximum combined power is MAX (xxorder - 1, xyorder - 1) for the x fit and MAX (yxorder - 1, yyorder - 1) for the y fit.

- full
- The individual polynomial terms contain powers of x and powers of y, whose maximum combined power is MAX (xxorder - 1 + xyorder - 1) for the x fit and MAX (yxorder - 1 + yyorder - 1) for the y fit.

The "shift", "xyscale", "rotation", "rscale", and "rxyscale" fitting geometries, assume that the cross term switches are set to "none"regardless of the values set by the user. If either of the cross terms parameters is set to "half" or "full" and

*fitgeometry*is "general" then a distortion surface is fit to the residuals from the linear portion of the fit.

- reject = INDEF
- The rejection limit in units of sigma. The default is no rejection.

- calctype = "real"
- The precision of coordinate transformation calculations. The options are "real" and "double".

- verbose = yes
- Print messages about the progress of the task?

- interactive = yes
- Run the task interactively ? In interactive mode the user may interact with the fitting process, e.g. change the order of the fit, delete points, replot the data etc.

- graphics = "stdgraph"
- The graphics device.

- gcommands = ""
- The graphics cursor.

## DESCRIPTION

SKYMAP computes the spatial transformation function required to map the
celestial coordinate system of the reference image *reference*
to
the celestial coordinate
system of the input image *input*
, and stores the computed function in
the output text database file *database*
.
The input and reference images may be 1D or 2D but
must have the same dimensionality. The input image and output
text database file can be input to the REGISTER or GEOTRAN tasks to
perform the actual image registration. SKYMAP assumes that the world
coordinate systems in the input and reference
image headers are accurate and that the two systems are compatible, e.g. both
images have a celestial coordinate system WCS.

SKYMAP computes the required spatial transformation by matching the logical
x and y pixel coordinates of a grid of points
in the input image with the logical x and y pixels coordinates
of the same grid of points in the reference image,
using celestial coordinate information stored in the two image headers.
The coordinate grid consists of *nx * ny*
points evenly distributed
over the logical pixel space of interest in the reference image defined by the
*xmin*
, *xmax*
, *ymin*
, *ymax*
parameters.
The logical x and y reference image pixel coordinates are transformed to
reference image celestial coordinates using
world coordinate information stored in the reference image header.
The reference image celestial coordinates are transformed to
input image celestial coordinates using world coordinate
system information in both the reference and the input image headers.
Finally the input image celestial coordinates are transformed to logical x and y
input image pixel coordinates using world coordinate system information
stored in the input image header. The transformation sequence looks
like the following for an equatorial celestial coordinate system:

(x,y) reference -> (ra,dec) reference (reference image wcs) (ra,dec) reference -> (ra,dec) input (reference and input image wcs) (ra,dec) input -> (x,y) input (input image wcs)

The computed reference and input logical coordinates and the
world coordinates are written to temporary coordinates file which is
deleleted on task termination.
The pixel and celestial coordinates are written using
the *xformat*
and *yformat*
and the *rwxformat*
, *rwyformat*
,
*wxformat*
and *wxformat*
parameters respectively. If these formats are undefined and, in the
case of the celestial coordinates a format attribute cannot be
read from either the reference or the input images, reasonable default
formats are chosen.
If the reference and input images are 1D then all the output logical and
world y coordinates are set to 1.

SKYMAP computes a spatial transformation of the following form.

xin = f (xref, yref) yin = g (xref, yref)

The functions f and g are either a power series polynomial or a Legendre or
Chebyshev polynomial surface of order *xxorder*
and *xyorder*
in x
and *yxorder*
and *yyorder*
in y.

Several polynomial cross terms options are avaible. Options "none", "half", and "full" are illustrated below for a quadratic polynomial in x and y.

xxterms = "none", xyterms = "none" xxorder = 3, xyorder = 3, yxorder = 3, yyorder = 3 xin = a11 + a21 * xref + a12 * yref + a31 * xref ** 2 + a13 * yref ** 2 yin = a11' + a21' * xref + a12' * yref + a31' * xref ** 2 + a13' * yref ** 2 xxterms = "half", xyterms = "half" xxorder = 3, xyorder = 3, yxorder = 3, yyorder = 3 xin = a11 + a21 * xref + a12 * yref + a31 * xref ** 2 + a22 * xref * yref + a13 * yref ** 2 yin = a11' + a21' * xref + a12' * yref + a31' * xref ** 2 + a22' * xref * yref + a13' * yref ** 2 xxterms = "full", xyterms = "full" xxorder = 3, xyorder = 3, yxorder = 3, yyorder = 3 xin = a11 + a21 * xref + a31 * xref ** 2 + a12 * yref + a22 * xref * yref + a32 * xref ** 2 * yref + a13 * yref ** 2 + a23 * xref * yref ** 2 + a33 * xref ** 2 * yref ** 2 yin = a11' + a21' * xref + a31' * xref ** 2 + a12' * yref + a22' * xref * yref + a32' * xref ** 2 * yref + a13' * yref ** 2 + a23' * xref * yref ** 2 + a33' * xref ** 2 * yref ** 2

If the **fitgeometry**
parameter is anything other than "general", the
order parameters assume the value 2 and the cross terms switches assume
the value "none", regardless of the values set by the user. The computation
can be done in either real or double precision by setting the *calctype*
parameter. Automatic pixel rejection may be enabled by setting the *reject*
parameter to a positive number other than INDEF.

The transformation computed by the "general" fitting geometry is arbitrary and does not necesarily correspond to a physically meaningful model. However the computed coefficients for the linear term can be given a simple geometrical geometric interpretation for all the fitting geometries as shown below.

fitting geometry = general (linear term) xin = a + b * xref + c * yref yin = d + e * xref + f * yref fitting geometry = shift xin = a + xref yin = d + yref fitting geometry = xyscale xin = a + b * xref yin = d + f * yref fitting geometry = rotate xin = a + b * xref + c * yref yin = d + e * xref + f * yref b * f - c * e = +/-1 b = f, c = -e or b = -f, c = e fitting geometry = rscale xin = a + b * xref + c * yref yin = d + e * xref + f * yref b * f - c * e = +/- const b = f, c = -e or b = -f, c = e fitting geometry = rxyscale xin = a + b * xref + c * yref yin = d + e * xref + f * yref b * f - c * e = +/- const

The coefficients can be interpreted as follows. Xref0, yref0, xin0, yin0 are the origins in the reference and input frames respectively. Orientation and skew are the orientation of the x and y axes and their deviation from perpendicularity respectively. Xmag and ymag are the scaling factors in x and y and are assumed to be positive.

general (linear term) xrotation = rotation - skew / 2 yrotation = rotation + skew / 2 b = xmag * cos (xrotation) c = ymag * sin (yrotation) e = -xmag * sin (xrotation) f = ymag * cos (yrotation) a = xin0 - b * xref0 - c * yref0 = xshift d = yin0 - e * xref0 - f * yref0 = yshift shift xrotation = 0.0, yrotation = 0.0 xmag = ymag = 1.0 b = 1.0 c = 0.0 e = 0.0 f = 1.0 a = xin0 - xref0 = xshift d = yin0 - yref0 = yshift xyscale xrotation 0.0 / 180.0 yrotation = 0.0 b = + /- xmag c = 0.0 e = 0.0 f = ymag a = xin0 - b * xref0 = xshift d = yin0 - f * yref0 = yshift rscale xrotation = rotation + 0 / 180, yrotation = rotation mag = xmag = ymag const = mag * mag b = mag * cos (xrotation) c = mag * sin (yrotation) e = -mag * sin (xrotation) f = mag * cos (yrotation) a = xin0 - b * xref0 - c * yref0 = xshift d = yin0 - e * xref0 - f * yref0 = yshift rxyscale xrotation = rotation + 0 / 180, yrotation = rotation const = xmag * ymag b = xmag * cos (xrotation) c = ymag * sin (yrotation) e = -xmag * sin (xrotation) f = ymag * cos (yrotation) a = xin0 - b * xref0 - c * yref0 = xshift d = yin0 - e * xref0 - f * yref0 = yshift

*Xmin*
, *xmax*
, *ymin*
and *ymax*
define the region of
validity of the fit as well as the limits of the grid
in the reference coordinate system. These parameters are also used to
reject out of range data before the actual fitting is done.

Each computed transformation is written to the output file *database*
in a record whose name is supplied by the user via the *transforms*
parameter or set to the name of the corresponding input image.
The database file is opened in append mode and new records are written
to the end of the existing file. If more that one record of the same
name is written to the database file, the last record written is the
valid record, i.e. the one that will be used by the REGISTER or
GEOTRAN tasks.

SKYMAP will terminate with an error if the reference and input images are not both either 1D or 2D. If the celestial coordinate system information cannot be read from either the reference or input image header, the requested transformations from the celestial <-> logical coordinate systems cannot be compiled for either or both images, or the celestial coordinate systems of the reference and input images are fundamentally incompatible in some way, the output logical reference and input image coordinates are both set to a grid of points spanning the logical pixel space of the input, not the reference image. This grid of points defines an identity transformation which will leave the input image unchanged if applied by the REGISTER or GEOTRAN tasks.

If *verbose*
is "yes" then messages about the progress of the task
as well as warning messages indicating potential problems are written to
the standard output. If *results*
is set to a file name then the input
coordinates, the fitted coordinates, and the residuals of the fit are
written to that file.

SKYMAP may be run interactively by setting the *interactive*
parameter to "yes".
In interactive mode the user has the option of viewing the fit, changing the
fit parameters, deleting and undeleting points, and replotting
the data until a satisfactory
fit has been achieved.

## CURSOR COMMANDS

In interactive mode the the following cursor commands are currently available.

Interactive Keystroke Commands ? Print options f Fit the data and graph with the current graph type (g, x, r, y, s) g Graph the data and the current fit x,r Graph the x fit residuals versus x and y respectively y,s Graph the y fit residuals versus x and y respectively d,u Delete or undelete the data point nearest the cursor o Overplot the next graph c Toggle the constant x, y plotting option t Plot a line of constant x, y through the nearest data point l Print xshift, yshift, xmag, ymag, xrotate, yrotate q Exit the interactive curve fitting

The parameters listed below can be changed interactively with simple colon commands. Typing the parameter name alone will list the current value.

Colon Parameter Editing Commands :show List parameters :fitgeometry Fitting geometry (shift,xyscale,rotate, rscale,rxyscale,general) :function [value] Fitting function (chebyshev,legendre, polynomial) :xxorder :xyorder [value] X fitting function xorder, yorder :yxorder :yyorder [value] Y fitting function xorder, yorder :xxterms :yxterms [n/h/f] X, Y fit cross terms type :reject [value] Rejection threshold

## FORMATS

A format specification has the form "%w.dCn", where w is the field width, d is the number of decimal places or the number of digits of precision, C is the format code, and n is radix character for format code "r" only. The w and d fields are optional. The format codes C are as follows:

b boolean (YES or NO) c single character (c or '\c' or '\0nnn') d decimal integer e exponential format (D specifies the precision) f fixed format (D specifies the number of decimal places) g general format (D specifies the precision) h hms format (hh:mm:ss.ss, D = no. decimal places) m minutes, seconds (or hours, minutes) (mm:ss.ss) o octal integer rN convert integer in any radix N s string (D field specifies max chars to print) t advance To column given as field W u unsigned decimal integer w output the number of spaces given by field W x hexadecimal integer z complex format (r,r) (D = precision) Conventions for w (field width) specification: W = n right justify in field of N characters, blank fill -n left justify in field of N characters, blank fill 0n zero fill at left (only if right justified) absent, 0 use as much space as needed (D field sets precision) Escape sequences (e.g. "\n" for newline): \b backspace (not implemented) \f formfeed \n newline (crlf) \r carriage return \t tab \" string delimiter character \' character constant delimiter character \\ backslash character \nnn octal value of character Examples %s format a string using as much space as required %-10s left justify a string in a field of 10 characters %-10.10s left justify and truncate a string in a field of 10 characters %10s right justify a string in a field of 10 characters %10.10s right justify and truncate a string in a field of 10 characters %7.3f print a real number right justified in floating point format %-7.3f same as above but left justified %15.7e print a real number right justified in exponential format %-15.7e same as above but left justified %12.5g print a real number right justified in general format %-12.5g same as above but left justified %h format as nn:nn:nn.n %15h right justify nn:nn:nn.n in field of 15 characters %-15h left justify nn:nn:nn.n in a field of 15 characters %12.2h right justify nn:nn:nn.nn %-12.2h left justify nn:nn:nn.nn %H / by 15 and format as nn:nn:nn.n %15H / by 15 and right justify nn:nn:nn.n in field of 15 characters %-15H / by 15 and left justify nn:nn:nn.n in field of 15 characters %12.2H / by 15 and right justify nn:nn:nn.nn %-12.2H / by 15 and left justify nn:nn:nn.nn \n insert a newline

## REFERENCES

Additional information on IRAF world coordinate systems including more detailed descriptions of the "logical", "physical", and "world" coordinate systems can be found in the help pages for the WCSEDIT and WCRESET tasks. Detailed documentation for the IRAF world coordinate system interface MWCS can be found in the file "iraf$sys/mwcs/MWCS.hlp". This file can be formatted and printed with the command "help iraf$sys/mwcs/MWCS.hlp fi+ | lprint".

Details of the FITS header world coordinate system interface can be found in the draft paper "World Coordinate Systems Representations Within the FITS Format" by Hanisch and Wells, available from the iraf anonymous ftp archive and the draft paper which supersedes it "Representations of Celestial Coordinates in FITS" by Greisen and Calabretta available from the nrao anonymous ftp archives.

The spherical astronomy routines employed here are derived from the Starlink SLALIB library provided courtesy of Patrick Wallace. These routines are very well documented internally with extensive references provided where appropriate. Interested users are encouraged to examine the routines for this information. Type "help slalib" to get a listing of the SLALIB routines, "help slalib opt=sys" to get a concise summary of the library, and "help <routine>" to get a description of each routine's calling sequence, required input and output, etc. An overview of the library can be found in the paper "SLALIB - A Library of Subprograms", Starlink User Note 67.7 by P.T. Wallace, available from the Starlink archives.

## EXAMPLES

1. Compute the spatial transformation required to match a radio image to an X-ray image of the same field field using a 100 point coordinate grid and a simple linear transformation. Both images have accurate sky equatorial world coordinate systems define at different equinoxes. Print the output world coordinates in the coords file in hh:mm:ss.ss and dd:mm:ss.s format. Run geotran on the results to do the actual registration.

cl> skymap radio xray geodb rwxformat=%12.2H rwyformat=%12.1h \ wxformat=%12.2H wyformat=%12.1h interactive- cl> geotran radio radio.tran geodb radio

2. Repeat the previous command but begin with a higher order fit and run the task in interactive mode in order to examine the fit residuals.

cl> skymap radio xray geodb rwxformat=%12.2H rwyformat=%12.1h \ wxformat=%12.2H wyformat=%12.1h xxo=4 xyo=4 xxt=half \ yxo=4 yyo=4 yxt=half ... a plot of the fit appears ... type x and r to examine the residuals of the x surface fit versus x and y ... type y and s to examine the residuals of the y surface fit versus x and y ... delete 2 deviant points with the d key and recompute the fit with the f key ... type q to quit and save the fit cl> geotran radio radio.tran geodb radio

3. Repeat example 1 but set the transform name specifically.

cl> skymap radio xray geodb trans=m82 rwxformat=%12.2H \ rwyformat=%12.1h wxformat=%12.2H wyformat=%12.1h \ interactive- cl> geotran radio radio.tran geodb m82

## TIME REQUIREMENTS

## BUGS