# HOW-TO Derive astrometry¶

To derive an astrometric calibration for a given reduced science frame, a AstrometricParametersTask object is used. A global astrometric solution can be derived using the .

## AstrometricParametersTask Example¶

If an astrometric solution is suspect in any way, or if the methods or calibration catalogs are improved, a new astrometric solution can be derived without having to recalibrate the RawScienceFrame from scratch. This is accomplished with the AstrometricParametersTask. The most ideal way to do this is with the DPU and is illustrated below:

awe> dpu.run('Astrometry', i='WFI', red_filenames=['Sci-USER-WFI-#877-red-53664 .5.fits', ...], C=0)


where i is the instrument name (mandatory argument), red_filenames is a file list of ReducedScienceFrames, and C is the commit switch used to commit the results to the database. Without the DPU, the task would be run like:

awe> task = AstrometricParametersTask(red_filenames=['Sci-USER-WFI-#877-red-536 64.5.fits'], commit=0)
awe> task.execute()


where red_filenames is a list of filenames of ReducedScienceFrames and commit is the commit switch. The advantage of using the DPU over this method is that it automatically loops over a list of ReducedScienceFrame objects and can run the task on more than one CPU simultaneously.

## Astrometric calibration - a detailed description¶

Under the hood of the pre-cooked recipes described in HOW-TO Derive astrometry, a set of LDAC routines is called. This section describes these routines and their role in deriving the astrometric calibration. All steps are performed on catalogs of extracted objects and a reference catalog of astrometric stars. For single frame and global frame astrometric processing, the following steps are made:

1. Preastrometric pairing and approximate determination of the affine transformation parameters (preastrom)
2. Application of the affine transformation to the extraction catalog (aplastrom)
3. Association of extracted and reference catalogs (associate)
4. Filter extranous pairs
5. Building of a pairs catalog based on the derived associations (make_ssc)
6. Derivation of the full astrometric solution (astrom)
7. Conversion of the astrometric solution parameters to PV parameters (make_distort)

### preastrom¶

Preastrometric pairing is done on the basis of the WCS information in the FITS header of the image. For the image area the reference objects are extracted from the reference catalog and their (alpha, delta) values are converted to the (x, y) coordinates of the image. Then the x and y distances between all extracted and reference objects are derived. In this distances space a concentration is found through boxcar smoothing. The boxcar has a width of $$2\times$$POS_ERROR and the maximum distance area used for searching is $$2\times$$MAX_OFFSET. The found peak defines the offset between the WCS information from the FITS header and the actual pointing of the instrument. If the scaling and rotation of the image is well represented by the WCS the peak in the distance plane will be tight. The peak will be smeared, however, if scaling and/or rotation are incorrectly stated in the WCS header information. For example, a scaling error of 1% in a 4000 pixel high CCD will cause the distances to vary over 4000/100 = 40 pixels, so a POS_ERROR of 20 is appropriate in that case.

This offset thus found is applied to the extraction catalog and then a triangulation method is used to derive the remaining affine parameters. For a detailed description of the triangulation method see the LDAC pipeline documentation. In short, vectors connecting triplet of objects are used and a peak is sought in the length/position-angle plane of the vectors. The resulting affine parameters are applied and the number and rms of the fit are reported. To accept the derived affine transformation the reported rms should be less than RMS_TOL.

### aplastrom¶

Application of the derive affine transformation to the extracted objects catalogs results in adding a Ra and Dec column to this catalog that represent a good approximation of the true object position. In addition to the position the shape parameters (A_WCS, B_WCS, E_WCS, THETA_WCS) are also transformed using the affine transformation.

### associate¶

Association of the extracted objects catalog with the reference catalog is done on the basis of the positional coincidence of extracted and reference objects based on the overlap of their shape parameters. Each object is represented by the 5-tuplet (Ra, Dec, A_WCS, B_WCS, THETA_WCS). Whenever an extracted object and a reference object overlap with eachother so that for one object the (Ra, Dec) falls within the (Ra, Dec, S$$\times$$A_WCS, S$$\times$$B_WCS, THETA_WCS) area a pair is created, where S = INTER_COLOR_TOL. For good seeing conditions stellar images have A_WCS values in the order of 0.5 arcsec. Given the inaccuracies of the preastrometric affine transformation one wants to seek a larger area for the associated reference object then just inside the stellar image area. This is done by multiplying the shape parameters by a factor S.

Note that when A_WCS and B_WCS are large, because their is a very bright object in the field, the S multiplication size may cause all reference stars in that large area to be associated with the one bright star. For this reason the next step is run.

### Filtering¶

Filter extranous pairing removes all very large associations. A good filtering criterion is a pairing distance less than 3 arcseconds.

### make_ssc¶

Given the output from the filtered association result for administrative reasons a shuffling of information is necessary and a pairs catalog is build.

### astrom¶

Deriving an astrometric solutions is what we are all after here. For a detailed description of how the astrometric solution is determined see the LDAC pipeline documentation. Here a short description of this process is given. The affine transformation is extended to a multidimensional polynomial of degree AstrometricParameters.astromconf.PDEG. In general a 2 dimensional polynomial is good enough to represent the deformation of the light path through the telescope and the imperfections of the plate mount in the focal plane of the telescope. The least square fit of the estimated astrometric solution using the pair information is performed in an iterative process where 3 sigma outliers (pairs) are discarded for the next iterative step. Outliers are removed because propper motion or image artifacts may have created erroneous pairs. The number of iterations steps NITER should be enough, 5 seems a good choice for many applications.

For multi frame processing, Global astrometry, pairs among extracted objects were also created in the previous steps. These pairs participate in the solution as well and because they generally are in over abundance with respect to the extracted objects vs. reference objects pairs they dominate the solution accuracy. Presuming the pointing differences among overlappin exposures are small, the astrometric solution for each pointing could be identical (FDEG = 1 0 0). This may not be the case. In extreme conditions the astrometric solution among the different pointing could be independent of eachother, however, their might be a gradual change of each of the astrometric parameters with pointing. This is represented by a Chebychev polynomial of a certain degree. For each astrometric solution polynomial parameter one can choose a Chebychev polynomial degree. FDEG = 1 0 0 means a Chebychev polynomial of degree 1 for the astrometric distortion polynomial of degree 1, a Chebychev polynomial of degree 0 for the astrometric distortion polynomial of degree 2, etc.

### make_distort¶

The final result of the astrometric solution is represented in an internal format that has to be converted to standard WCS patameters.