IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 15896


Ignore:
Timestamp:
Dec 22, 2007, 7:52:57 AM (18 years ago)
Author:
eugene
Message:

apply toTPA to toFPA when writing out single chip version

File:
1 edited

Legend:

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

    r15254 r15896  
    77 *  @author EAM, IfA
    88 *
    9  *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2007-10-09 19:27:04 $
     9 *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2007-12-22 17:52:57 $
    1111 *
    1212 *  Copyright 2006 Institute for Astronomy, University of Hawaii
     
    5656bool pmAstromWriteWCS (psMetadata *header, const pmFPA *fpa, const pmChip *chip, double tol)
    5757{
    58     // XXX require chip->toFPA->x->nX == chip->toFPA->x->nY
    59     // XXX require chip->toFPA->y->nX == chip->toFPA->y->nY
    60     // XXX require chip->toFPA->x->nX == chip->toFPA->y->nX
    61     // XXX require chip->toFPA->nX == 1,2,3
    62 
    63     // technically, we can have a plate scale here (fpa->toTPA:dx,dy != 1)
    64     if (!psPlaneTransformIsDiagonal (fpa->toTPA))
    65         psAbort("invalid TPA transformation");
    66 
    6758    pmAstromWCS *wcs = pmAstromWCSfromFPA(fpa, chip, tol);
     59    if (!wcs) return false;
     60
    6861    pmAstromWCStoHeader (header, wcs);
    6962
     
    118111{
    119112    pmAstromWCS *wcs = pmAstromWCSBilevelChipFromFPA (chip, tol);
    120 
    121113    pmAstromWCStoHeader (header, wcs);
    122114
     
    337329    char *type;
    338330
     331    if (!wcs) return false;
     332
    339333    type = psProjectTypeToString (wcs->toSky->type, "RA--");
    340334    psMetadataAddStr (header, PS_LIST_TAIL, "CTYPE1", PS_META_REPLACE, "", type);
     
    385379    }
    386380
    387     return (true);
     381    return true;
    388382}
    389383
     
    550544pmAstromWCS *pmAstromWCSfromFPA (const pmFPA *fpa, const pmChip *chip, double tol)
    551545{
    552 
    553     // technically, we can have a plate scale here (fpa->toTPA:dx,dy != 1)
    554     // XXX not really: toTPA needs to have unity scale for distortion fitting function
    555     if (!psPlaneTransformIsDiagonal (fpa->toTPA))
    556         psAbort("invalid TPA transformation");
    557 
    558546    // XXX require chip->toFPA->x->nX == chip->toFPA->x->nY
    559547    // XXX require chip->toFPA->y->nX == chip->toFPA->y->nY
     
    561549    // XXX require chip->toFPA->nX == 1,2,3
    562550
    563     pmAstromWCS *wcs = pmAstromWCSAlloc(chip->toFPA->x->nX, chip->toFPA->x->nY);
     551    // technically, we can have a plate scale here (fpa->toTPA:dx,dy != 1)
     552    // XXX not really: toTPA needs to have unity scale for distortion fitting function
     553    // if (!psPlaneTransformIsDiagonal (fpa->toTPA))
     554    // psAbort("invalid TPA transformation");
     555
     556    // create a temporary transform which combines toTPA and toFPA.  allow toTPA to have 0th
     557    // and 1st order terms
     558   
     559    // XXX require fpa->toTPA->x->nX == fpa->toTPA->x->nY
     560    // XXX require fpa->toTPA->y->nX == fpa->toTPA->y->nY
     561    // XXX require fpa->toTPA->x->nX == fpa->toTPA->y->nX
     562    // XXX require fpa->toTPA->x->coeffMask[1][1]
     563    // XXX require fpa->toTPA->y->coeffMask[1][1]
     564    // XXX require fpa->toTPA->nX == 1
     565
     566    psPlaneTransform *toTPA = psPlaneTransformAlloc(chip->toFPA->x->nX, chip->toFPA->x->nY);
     567
     568    for (int i = 0; i <= toTPA->x->nX; i++) {
     569        for (int j = 0; j <= toTPA->x->nY; j++) {
     570            double f1 = chip->toFPA->x->coeffMask[i][j] ? 0.0 : fpa->toTPA->x->coeff[1][0]*chip->toFPA->x->coeff[i][j];
     571            double f2 = chip->toFPA->y->coeffMask[i][j] ? 0.0 : fpa->toTPA->x->coeff[0][1]*chip->toFPA->y->coeff[i][j];
     572            toTPA->x->coeff[i][j] = f1 + f2;
     573
     574            double g1 = chip->toFPA->x->coeffMask[i][j] ? 0.0 : fpa->toTPA->y->coeff[1][0]*chip->toFPA->x->coeff[i][j];
     575            double g2 = chip->toFPA->y->coeffMask[i][j] ? 0.0 : fpa->toTPA->y->coeff[0][1]*chip->toFPA->y->coeff[i][j];
     576            toTPA->y->coeff[i][j] = g1 + g2;
     577        }
     578    }
     579    toTPA->x->coeff[0][0] += fpa->toTPA->x->coeff[0][0];
     580    toTPA->y->coeff[0][0] += fpa->toTPA->y->coeff[0][0];
     581
     582    pmAstromWCS *wcs = pmAstromWCSAlloc(toTPA->x->nX, toTPA->x->nY);
    564583
    565584    // convert projection from FPA to SKY into wcs projection (degrees to radians)
     
    569588
    570589    // given transformation, solve for coordinates which yields output coordinates of 0,0
    571     psPlane *center = psPlaneTransformGetCenter (chip->toFPA, tol);
     590    psPlane *center = psPlaneTransformGetCenter (toTPA, tol);
    572591
    573592    // create wcs transform from toFPA, resulting transformation has units of microns/pixel
    574593    // adjust wcs transform to use center as reference coordinate
    575     psPlaneTransformSetCenter (wcs->trans, chip->toFPA, center->x, center->y);
     594    psPlaneTransformSetCenter (wcs->trans, toTPA, center->x, center->y);
    576595
    577596    // calculated center is crpix1,2
     
    595614    wcs->cdelt1 = hypot (wcs->trans->x->coeff[1][0], wcs->trans->x->coeff[0][1]);
    596615    wcs->cdelt2 = hypot (wcs->trans->y->coeff[1][0], wcs->trans->y->coeff[0][1]);
     616
     617    psFree (toTPA);
    597618
    598619    return wcs;
Note: See TracChangeset for help on using the changeset viewer.