SEE_ALSO

## NAME

p2geo -- Convert polynomial fit file to geometric calibration file.

## USAGE

`p2geo inpoly entry output npix1 npix2`

## DESCRIPTION

This task evaluates a polynomial fit file on a grid which will be
the corners of pixels of an image to be created by the `newgeom` task
or by the `calfoc` pipeline task.
The output from `p2geo` is an image containing the X and Y values
of the polynomial fit.
Each row contains the X coordinates followed by the Y coordinates.
If a 512 x 512 image is to be created by `newgeom`, for example,
the output image from `p2geo` will have size 1026 x 513,
because 513 is the number of corners along a row of 512 pixels.
This image is taken as input for `newgeom` or for `calfoc`.
See the help for `newgeom`
for a description of the pixel coordinate convention
and for an example of actual data values.

This task assumes that the fit was performed by `rfitx`
using reseau table entries in the coordinates system of
a full-format dezoomed image (i.e. 1024 by 1024).
The `input` reseau entry should have been
the distorted (i.e. observed) positions,
while the `reference` reseau entry should have been
the undistorted (sky) positions.
These are photocathode coordinates except that
they have been flipped around the Y axis.
In order to do this, the pxformt, samppln, sampoff and lineoff
parameters must be set correctly.

The values in the output GEO file will be the coordinates in the distorted image for each pixel in the corrected (undistorted) image.

Most of the hidden parameters are only used for
assigning header values in the output image.
These parameters will have no effect on the geometric correction
performed by `newgeom`.
If `newgeom.coord_trans` is set to "set_values", however,
some of the parameters will be used.
If `smmmode` is "notused" (normal image mode),
then `imscale` will be used to calculate the CD matrix.
If `smmmode` is set to "inbeam" (long-slit spectrographic mode),
all the coordinate parameters will be copied
to the geometrically corrected image
(`imscale` is not used at all in this case).
See the help for `newgeom` for further information.

## PARAMETERS

- inpoly = "focgeom$x96n512.fit" [file name]
- Name of the input polynomial fit file. The fit should have been computed using the undistorted positions (i.e. sky coordinates) as the reference.

- entry = "respos" [string]
- Entry in fit file.

- output = "" [file name]
- Output geometric reference (GEO) file.

- npix= 512 [integer, min=1, max=INDEF]
- X axis size for corrected image.

- npix= 512 [integer, min=1, max=INDEF]
- Y axis size for corrected image.

- (pedigree = "change this") [string]
- This string will be copied to the output header
as the value of the
`pedigree`keyword.

- (optcrly = "f96") [string, Allowed values: f| f48]
- Which relay was used for the observation to be geometrically corrected?

- (pxformt = "normal") [string, allowed values: normal | zoom]
- Pixel format.

- (cammode = "notused") [string, allowed values: inbeam | notused]
- Was the high resolution apodizer used?

- (smmmode = "notused") [string, allowed values: inbeam | notused]
- Spectrographic mode?

- (sampoff = 256.) [real, min=0.0, max=1024.0]
- X offset from beginning of photocathode.

- (lineoff = 256.) [real, min=0.0, max=1024.0]
- Y offset from beginning of photocathode.

- (samppln = 512) [integer, min=1, max=1024]
- X size of image to be corrected.

- (linepfm = 512) [integer, min=1, max=1024]
- Y size of image to be corrected.

- (optelt= 0) [integer, min=0, max=7]
- Filter number in wheel 1.

- (optelt= 0) [integer, min=0, max=7]
- Filter number in wheel 2.

- (imscale = 0.01435) [real]
- Image scale in arcseconds per pixel.
This is the pixel spacing in the output calibrated image.
See the help for
`newgeom.coord_trans`for further information.

- (crval= 0.) [real]
- Position along slit.

- (crval= 4500.) [real]
- Wavelength (in Angstroms) at reference pixel.

- (crpix= 256.) [real]
- Reference pixel in X direction.

- (crpix= 256.) [real]
- Reference pixel in Y direction.

- (cd1_= 1.245e-5) [real]
- Degrees per pixel along slit.

- (cd1_= 0.) [real]
- Cross term. This should be zero since the slit images should be parallel to the X axis and the dispersion parallel to the Y axis.

- (cd2_= 0.) [real]
- Cross term.

- (cd2_= 1.7) [real]
- Wavelength increment (Angstroms) per pixel.

- (ctype= "ANGLE") [string]
- Type of coordinate for X axis.

- (ctype= "LAMBDA") [string]
- Type of coordinate for Y axis.

- (verbose = yes) [boolean]
- Print percent done?

- (template = "focgeom$tmplgeox.hhh") [string]
- Template header.

## EXAMPLES

1. Convert a polynomial fit file "x96n512.fit" with entry name "respos"
to a geometric reference file "b191525mx.r5h".
The fit will be evaluated over a 512 x 512 grid so that `newgeom`
or `calfoc` will produce an output image of that size.

fo> p2geo x96n512.fit respos b191525mx.r5h 512 512

## BUGS

## REFERENCES

This task was written by Robert Jedrzejewski as a part of `newgeom`
and was subsequently extracted into a separate task by Phil Hodge.

## SEE ALSO

The `newgeom` and `calfoc` tasks use the output of `p2geo` to perform
geometric correction.

Type "help focgeom option=sys" for a higher-level description of
the `focgeom` package.