IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 15, 2006, 7:34:54 PM (19 years ago)
Author:
magnier
Message:

polynomial fits

File:
1 edited

Legend:

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

    r10712 r10775  
    77 *  @author EAM, IfA
    88 *
    9  *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2006-12-14 06:26:15 $
     9 *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2006-12-16 05:34:54 $
    1111 *
    1212 *  Copyright 2006 Institute for Astronomy, University of Hawaii
     
    190190            wcs->trans->x->coeff[0][1] = -wcs->cdelt2 * sin(rotate*PM_RAD_DEG); // == PC1_2
    191191            wcs->trans->y->coeff[1][0] = +wcs->cdelt1 * sin(rotate*PM_RAD_DEG); // == PC2_1
    192             wcs->trans->y->coeff[1][0] = +wcs->cdelt2 * cos(rotate*PM_RAD_DEG); // == PC2_2
     192            wcs->trans->y->coeff[0][1] = +wcs->cdelt2 * cos(rotate*PM_RAD_DEG); // == PC2_2
    193193            return wcs;
    194194        }
     
    207207                    if (i + j < 2)
    208208                        continue;
    209                     if (i + j > fitOrder)
     209                    if (i + j > fitOrder) {
     210                        wcs->trans->x->mask[i][j] = 1;
     211                        wcs->trans->y->mask[i][j] = 1;
    210212                        continue;
     213                    }
    211214                    sprintf (name, "PCA1X%1dY%1d", i, j);
    212215                    wcs->trans->x->coeff[i][j] = pow(wcs->cdelt1, i) * pow(wcs->cdelt2, j) * psMetadataLookupF32 (&status, header, name);
     
    487490{
    488491    // techinically, we can have a plate scale here (fpa->toTPA:dx,dy != 1)
    489     if (!psPlaneDistortIsIdentity (fpa->toTPA))
     492    if (!psPlaneDistortIsDiagonal (fpa->toTPA))
    490493        psAbort ("psastro", "invalid TPA transformation");
    491494
     
    505508    // crpix1,2 = X,Y(crval1,2)
    506509    // start with linear solution for Xo,Yo:
    507     double R  = (chip->toFPA->x->coeff[1][0]*chip->toFPA->x->coeff[0][1] - chip->toFPA->x->coeff[0][1]*chip->toFPA->x->coeff[1][0]);
    508     double Xo = (chip->toFPA->x->coeff[0][0]*chip->toFPA->x->coeff[0][1] - chip->toFPA->x->coeff[0][0]*chip->toFPA->x->coeff[0][1])/R;
    509     double Yo = (chip->toFPA->x->coeff[0][0]*chip->toFPA->x->coeff[1][0] - chip->toFPA->x->coeff[0][0]*chip->toFPA->x->coeff[1][0])/R;
     510    double R  = (chip->toFPA->x->coeff[1][0]*chip->toFPA->y->coeff[0][1] - chip->toFPA->x->coeff[0][1]*chip->toFPA->y->coeff[0][1]);
     511    double Xo = (chip->toFPA->y->coeff[0][0]*chip->toFPA->x->coeff[0][1] - chip->toFPA->x->coeff[0][0]*chip->toFPA->y->coeff[0][1])/R;
     512    double Yo = (chip->toFPA->x->coeff[0][0]*chip->toFPA->y->coeff[1][0] - chip->toFPA->y->coeff[0][0]*chip->toFPA->x->coeff[1][0])/R;
    510513
    511514    // iterate to actual solution: requires small non-linear terms
     
    582585    double cdelt1 = fpa->toTPA->x->coeff[1][0][0][0]*fpa->toSky->Xs*PM_DEG_RAD;
    583586    double cdelt2 = fpa->toTPA->y->coeff[0][1][0][0]*fpa->toSky->Ys*PM_DEG_RAD;
     587    wcs->cdelt1 = cdelt1;
     588    wcs->cdelt2 = cdelt2;
    584589
    585590    // convert wcs->trans to a matrix which yields L,M in pixels
     
    741746}
    742747
    743 // check that the given psPlaneDistort is the identity
    744 bool psPlaneDistortIsIdentity (psPlaneDistort *distort)
     748// check that the given psPlaneDistort is the identity * (Xs,Ys)
     749bool psPlaneDistortIsDiagonal (psPlaneDistort *distort)
    745750{
    746751
     
    787792            if (i + j > order) {
    788793                // high-order cross terms must be masked (eg, x^3 y^2)
     794                status &= distort->x->mask[i][j][0][0];
     795            } else {
    789796                status &= !distort->x->mask[i][j][0][0];
    790             } else {
    791                 if (i + j != 1) {
     797                if ((i == 1) && (i + j == 1)) {
     798                    // linear, diagonal terms must be 1.0
     799                    status &= (fabs(distort->x->coeff[i][j][0][0]) > FLT_EPSILON);
     800                } else {
    792801                    // non-linear and off-diagonal terms must be 0 (eg, x^2, x y)
    793                     status &= (distort->x->coeff[i][j][0][0] == 0.0);
    794                 } else {
    795                     // linear, diagonal terms must be 1.0
    796                     status &= (distort->x->coeff[i][j][0][0] == 1.0);
     802                    status &= (fabs(distort->x->coeff[i][j][0][0]) < FLT_EPSILON);
    797803                }
    798804            }
     
    805811            if (i + j > order) {
    806812                // high-order cross terms must be masked (eg, x^3 y^2)
     813                status &= distort->y->mask[i][j][0][0];
     814            } else {
    807815                status &= !distort->y->mask[i][j][0][0];
    808             } else {
    809                 if (i + j != 1) {
     816                if ((j == 1) && (i + j == 1)) {
     817                    // linear, diagonal terms must be 1.0
     818                    status &= (fabs(distort->y->coeff[i][j][0][0]) > FLT_EPSILON);
     819                } else {
    810820                    // non-linear and off-diagonal terms must be 0 (eg, x^2, x y)
    811                     status &= (distort->y->coeff[i][j][0][0] == 0.0);
    812                 } else {
    813                     // linear, diagonal terms must be 1.0
    814                     status &= (distort->y->coeff[i][j][0][0] == 1.0);
     821                    status &= (fabs(distort->y->coeff[i][j][0][0]) < FLT_EPSILON);
    815822                }
    816823            }
Note: See TracChangeset for help on using the changeset viewer.