IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 10513


Ignore:
Timestamp:
Dec 6, 2006, 2:49:49 PM (20 years ago)
Author:
eugene
Message:

working on non-linear wcs terms

Location:
trunk/psastro/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/psastro/src/psastro.h

    r10438 r10513  
    4343
    4444bool              pmAstromReadWCS (pmFPA *fpa, pmChip *chip, psMetadata *header, double plateScale, bool isMosaic);
    45 bool              pmAstromWriteWCS (psPlaneTransform *toFPA, psProjection *toSky, psMetadata *header, double plateScale);
     45bool              pmAstromWriteWCS (psPlaneTransform *toFPA, psPlaneDistort *toTPA, psProjection *toSky, psMetadata *header, double plateScale);
    4646psPlaneDistort   *psPlaneDistortIdentity ();
     47bool psPlaneDistortIsIdentity (psPlaneDistort *distort);
    4748
    4849psArray          *psastroLoadRefstars (pmConfig *config);
  • trunk/psastro/src/psastroChipAstrom.c

    r10438 r10513  
    5555                    return false;
    5656                }
    57                 pmAstromWriteWCS (chip->toFPA, fpa->toSky, updates, plateScale);
     57                pmAstromWriteWCS (chip->toFPA, fpa->toTangentPlane, fpa->toSky, updates, plateScale);
    5858                psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSASTRO.HEADER",  PS_DATA_METADATA, "psastro header stats", updates);
    5959                psFree (updates);
  • trunk/psastro/src/psastroWCS.c

    r9643 r10513  
    208208// convert toFPA / toSky components to traditional WCS
    209209// plateScale is nominal physical scale on tangent plane (microns / arcsecond)
    210 bool pmAstromWriteWCS (psPlaneTransform *toFPA, psProjection *toSky, psMetadata *header, double plateScale) {
     210// this requires toTP to be the identity transformation
     211bool pmAstromWriteWCS (psPlaneTransform *toFPA, psPlaneDistort *toTPA, psProjection *toSky, psMetadata *header, double plateScale) {
     212
     213    // techinically, we can have a plate scale here (toTPA:dx,dy != 1)
     214    if (!psPlaneDistortIsIdentity (toTPA)) psAbort ("psastro", "invalid TPA transformation");
    211215
    212216    switch (toSky->type) {
     
    232236    }
    233237
    234     // XXX not really right: needs to deal with non-identity toTP coeffs
     238# if (0)
     239    // XXX not really right: needs to deal with non-identity to coeffs
    235240    // XXX actually, totally wrong.  fix the conversions
    236241    // XXX need to handle the plateScale
     242   
     243    // solve for CDELT1,2:
     244    cdelt1 = toSky->Xs*DEG_RAD*toTPA->x->coeff[1][0][0][0];
     245    cdelt2 = toSky->Ys*DEG_RAD*toTPA->y->coeff[0][1][0][0];
     246
     247    // L,M = toFPA(X,Y)
     248    // solve for CRPIX1,2 (Xo,Yo) : L,M(Xo,Yo) = 0,0
     249    // linear solution for Xo,Yo:
     250    R  = (xsum[1][0]*ysum[0][1] - xsum[0][1]*ysum[1][0]);
     251    Xo = det*(ysum[0][0]*xsum[0][1] - xsum[0][0]*ysum[0][1]);
     252    Yo = det*(xsum[0][0]*ysum[1][0] - ysum[0][0]*xsum[1][0]);
     253
     254    if (
     255# endif
     256
    237257    psMetadataAddF32 (header, PS_LIST_TAIL, "CRVAL1",   PS_META_REPLACE, "", toSky->R*DEG_RAD);
    238258    psMetadataAddF32 (header, PS_LIST_TAIL, "CRVAL2",   PS_META_REPLACE, "", toSky->D*DEG_RAD);
     
    362382}
    363383
    364 // XXX for the moment, we mimic the limited Elixir mosastro orders
     384// construct a psPlaneDistort which is the identify transformation
    365385psPlaneDistort *psPlaneDistortIdentity (int order) {
    366386
     
    376396        for (int j = 0; j <= order; j++) {
    377397            if (i + j > order) {
    378                 distort->x->mask [1][1][0][0] = 1;
    379                 distort->y->mask [1][1][0][0] = 1;
     398                distort->x->mask [i][j][0][0] = 1;
     399                distort->y->mask [i][j][0][0] = 1;
    380400            }
    381401        }
     
    386406    return distort;
    387407}
     408
     409// check that the given psPlaneDistort is the identity
     410bool psPlaneDistortIsIdentity (psPlaneDistort *distort) {
     411
     412    int order;
     413    bool status;
     414
     415    // we currently only support up to 3rd order polynomials
     416    if (distort->x->nX < 1) return false;
     417    if (distort->x->nY < 1) return false;
     418    if (distort->y->nX < 1) return false;
     419    if (distort->y->nY < 1) return false;
     420
     421    if (distort->x->nX > 3) return false;
     422    if (distort->x->nY > 3) return false;
     423    if (distort->y->nX > 3) return false;
     424    if (distort->y->nY > 3) return false;
     425   
     426    if (distort->x->nZ > 0) return false;
     427    if (distort->x->nT > 0) return false;
     428    if (distort->y->nZ > 0) return false;
     429    if (distort->y->nT > 0) return false;
     430   
     431    if (distort->x->nX != distort->x->nY) return false;
     432    if (distort->y->nX != distort->y->nY) return false;
     433
     434    status = true;
     435    order = distort->x->nX;
     436    for (int i = 0; i <= order; i++) {
     437        for (int j = 0; j <= order; j++) {
     438            if (i + j > order) {
     439                // high-order cross terms must be masked (eg, x^3 y^2)
     440                status &= !distort->x->mask[i][j][0][0];
     441            } else {
     442                if (i + j != 1) {
     443                    // non-linear and off-diagonal terms must be 0 (eg, x^2, x y)
     444                    status &= (distort->x->coeff[i][j][0][0] == 0.0);
     445                } else {
     446                    // linear, diagonal terms must be 1.0
     447                    status &= (distort->x->coeff[i][j][0][0] == 1.0);
     448                }
     449            }
     450        }
     451    }
     452
     453    order = distort->y->nX;
     454    for (int i = 0; i <= order; i++) {
     455        for (int j = 0; j <= order; j++) {
     456            if (i + j > order) {
     457                // high-order cross terms must be masked (eg, x^3 y^2)
     458                status &= !distort->y->mask[i][j][0][0];
     459            } else {
     460                if (i + j != 1) {
     461                    // non-linear and off-diagonal terms must be 0 (eg, x^2, x y)
     462                    status &= (distort->y->coeff[i][j][0][0] == 0.0);
     463                } else {
     464                    // linear, diagonal terms must be 1.0
     465                    status &= (distort->y->coeff[i][j][0][0] == 1.0);
     466                }
     467            }
     468        }
     469    }
     470    return status;
     471}
Note: See TracChangeset for help on using the changeset viewer.