IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 24, 2006, 3:49:50 PM (20 years ago)
Author:
magnier
Message:

some API work to reduce dependencies on the recipes, support for mosaic astrometry

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/astrom/pmAstrometryWCS.c

    r10825 r10829  
    77 *  @author EAM, IfA
    88 *
    9  *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2006-12-22 21:23:06 $
     9 *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2006-12-25 01:49:49 $
    1111 *
    1212 *  Copyright 2006 Institute for Astronomy, University of Hawaii
     
    3232
    3333// interpret header WCS (only handles traditional WCS for the moment)
    34 // plateScale is nominal physical scale on tangent plane (radians / TPA physical units)
    35 bool pmAstromReadWCS (pmFPA *fpa, pmChip *chip, const psMetadata *header, double plateScale)
     34// pixelScale is microns per pixel
     35bool pmAstromReadWCS (pmFPA *fpa, pmChip *chip, const psMetadata *header, double pixelScale)
    3636{
    3737    pmAstromWCS *wcs = pmAstromWCSfromHeader (header);
     
    4040    }
    4141
    42     bool status = pmAstromWCStoFPA (fpa, chip, wcs, plateScale);
     42    bool status = pmAstromWCStoFPA (fpa, chip, wcs, pixelScale);
    4343
    4444    psFree (wcs);
     
    6767
    6868// interpret chip header WCS as bilevel chip components
    69 // plateScale is nominal physical scale on tangent plane (radians / TPA physical units)
    7069bool pmAstromReadBilevelChip (pmChip *chip, const psMetadata *header)
    7170{
     
    8281
    8382// convert toFPA / toSky components to traditional WCS
    84 // plateScale is nominal physical scale on tangent plane (microns / arcsecond)
    8583bool pmAstromReadBilevelMosaic (pmFPA *fpa, const psMetadata *header)
    8684{
     
    359357
    360358// interpret header WCS (only handles traditional WCS for the moment)
    361 // plateScale is nominal physical scale on tangent plane (radians / TPA physical units)
    362 bool pmAstromWCStoFPA (pmFPA *fpa, pmChip *chip, const pmAstromWCS *wcs, double plateScale)
     359// pixelScale is the pixel size in microns per pixel
     360bool pmAstromWCStoFPA (pmFPA *fpa, pmChip *chip, const pmAstromWCS *wcs, double pixelScale)
    363361{
    364362    psPlaneTransform *toFPA;
     
    367365     * wcs->trans, which will convert X,Y in pixels to L,M in degrees.  we also have the following
    368366     * elements defined:
    369      * type (CTYPE)
     367     * type (projection type)
    370368     * crval1,2 (in RA,DEC degrees)
    371369     * crpix1,2
    372370     * cdelt1,2 (in degrees / pixel)
    373      * plateScale (radians / physical TPA units)
     371     * pixelScale (microns / pixel)
    374372     *
    375373     * now we convert wcs->trans to toFPA, which is different from wcs->trans in 3 important ways:
    376      * 1) the output is in pixels (not degrees): divide by cdelt1,2 raised to an appropriate power
     374     * 1) the output is in microns (not degrees): divide by cdelt1,2
    377375     * 2) X,Y are applied directly, without an applied Xo,Yo offset
    378376     * 3) there is an allowed Lo,Mo term ([0][0] coefficients)
    379377     */
    380378
    381     // convert wcs->trans to a matrix which yields L,M in pixels
    382     double cdelt1 = hypot (wcs->trans->x->coeff[1][0], wcs->trans->x->coeff[0][1]);
    383     double cdelt2 = hypot (wcs->trans->y->coeff[1][0], wcs->trans->y->coeff[0][1]);
    384     for (int i = 0; i <= wcs->trans->x->nX; i++) {
    385         for (int j = 0; j <= wcs->trans->x->nX; j++) {
    386             wcs->trans->x->coeff[i][j] /= cdelt1;
    387             wcs->trans->y->coeff[i][j] /= cdelt2;
    388         }
    389     }
    390 
    391379    // create transformation with 0,0 reference pixel
    392380    toFPA = psPlaneTransformSetCenter (NULL, wcs->trans, -wcs->crpix1, -wcs->crpix2);
    393381
    394     // scale from FPA to TPA (microns / pixel)
    395     double pdelt1 = cdelt1*PM_RAD_DEG / plateScale;
    396     double pdelt2 = cdelt2*PM_RAD_DEG / plateScale;
     382    // modify scale of toFPA to yield L,M in microns
     383    double cdelt1 = hypot (toFPA->x->coeff[1][0], toFPA->x->coeff[0][1]);
     384    double cdelt2 = hypot (toFPA->y->coeff[1][0], toFPA->y->coeff[0][1]);
     385    for (int i = 0; i <= toFPA->x->nX; i++) {
     386        for (int j = 0; j <= toFPA->x->nX; j++) {
     387            toFPA->x->coeff[i][j] *= pixelScale/cdelt1;
     388            toFPA->y->coeff[i][j] *= pixelScale/cdelt2;
     389        }
     390    }
     391
     392    // scale from FPA to TPA (degrees / micron)
     393    double pdelt1 = cdelt1 / pixelScale;
     394    double pdelt2 = cdelt2 / pixelScale;
    397395    float rX = 1.0;
    398396    float rY = 1.0;
    399397
    400     // projection from TPA to SKY
    401     psProjection *toSky = psProjectionAlloc (wcs->toSky->R, wcs->toSky->D, plateScale, plateScale, wcs->toSky->type);
     398    // projection from TPA ("linear" degrees) to SKY (radians)
     399    psProjection *toSky = psProjectionAlloc (wcs->toSky->R, wcs->toSky->D, PM_RAD_DEG, PM_RAD_DEG, wcs->toSky->type);
    402400
    403401    if (fpa->toSky == NULL) {
     
    558556
    559557    // cdelt1,2 convert from pixels->degrees
    560     double cdelt1 = fpa->toTPA->x->coeff[1][0]*fpa->toSky->Xs*PM_DEG_RAD;
    561     double cdelt2 = fpa->toTPA->y->coeff[0][1]*fpa->toSky->Ys*PM_DEG_RAD;
     558    double cdelt1 = fpa->toTPA->x->coeff[1][0];
     559    double cdelt2 = fpa->toTPA->y->coeff[0][1];
    562560    wcs->cdelt1 = cdelt1;
    563561    wcs->cdelt2 = cdelt2;
Note: See TracChangeset for help on using the changeset viewer.