IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 6, 2017, 11:30:10 AM (9 years ago)
Author:
eugene
Message:

merging changes from czw dev branch (compare with r39924)

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/psastro/src/psastroModelAdjust.c

    r21409 r39926  
    2828    }
    2929
     30
     31   
    3032    // if we have not measured the boresite position, no adjustment is needed
    3133    bool fitBoresite = psMetadataLookupBool (&status, recipe, "PSASTRO.MODEL.FIT.BORESITE");
     
    5254        return false;
    5355    }
    54 
     56    float refChipAngleNominal = PS_RAD_DEG*psMetadataLookupF32 (&status, recipe, "PSASTRO.MODEL.REF.CHIP.ANGLE");
     57    if (!refChipName) {
     58        psError(PS_ERR_IO, true, "reference chip is missing from recipe");
     59        return false;
     60    }
     61
     62    int rotatorParity = psMetadataLookupS32(&status, recipe, "PSASTRO.MODEL.ROT.PARITY");
     63    if (!status) psAbort ("Can't find recipe option PSASTRO.MODEL.ROT.PARITY");
     64    psMetadataAddS32 (output->fpa->concepts, PS_LIST_TAIL, "FPA.ROT_PARITY", PS_META_REPLACE, "rotator parity parameter", rotatorParity);
     65   
    5566    // get reference chip from name
    5667    pmChip *refChip = pmConceptsChipFromName (output->fpa, refChipName);
     
    8192        psFree (PT);
    8293    }
    83 
     94   
    8495    // rotate the chip-to-FPA transforms to have 0.0 posangle for refChip;
    8596    // compensate by rotating fpa to TPA transform
    8697
    8798    // get the current posangle of the ref chip
    88     float chipAngle = atan2 (refChip->toFPA->y->coeff[1][0], refChip->toFPA->x->coeff[1][0]);
    89     fprintf (stderr, "chipAngle: %f\n", chipAngle*PS_DEG_RAD);
     99    // this should have a negative sign : chipAngle = -atan2 (dM/dy, dM/dx)
     100    float chipAngle = -atan2 (refChip->toFPA->y->coeff[1][0], refChip->toFPA->x->coeff[1][0]);
     101
     102    // chipAngle should be refChipAngleNominal @ POSANGLE = 0.0
     103    float posAngleOffset = rotatorParity * (chipAngle - refChipAngleNominal);
     104
     105    fprintf (stderr, "chipAngle is: %f, at PA = 0.0, it should be %f, rotating model by %f (parity %d)\n",
     106             chipAngle*PS_DEG_RAD, refChipAngleNominal*PS_DEG_RAD, posAngleOffset*PS_DEG_RAD, rotatorParity);
     107
    90108    // psMetadataAddF32 (output->fpa->concepts, PS_LIST_TAIL, "FPA.POSANGLE", PS_META_REPLACE, "boresite parameter", posangle);
    91109
     
    99117        psRegion *region = pmChipPixels (chip);
    100118
    101         psPlaneTransform *toFPA = psPlaneTransformRotate (NULL, chip->toFPA, chipAngle);
     119        // this should ALSO have a negative sign: this rotates by +posAngleOffset
     120        psPlaneTransform *toFPA = psPlaneTransformRotate (NULL, chip->toFPA, posAngleOffset);
    102121        psFree (chip->toFPA);
    103122        chip->toFPA = toFPA;
    104123
    105124        // invert the new fromFPA transform to get the new toFPA transform
     125        // NOTE: when we call psPlaneTransformInvert here, we do not increase the order as in other places
    106126        psPlaneTransform *fromFPA = psPlaneTransformInvert(NULL, chip->toFPA, *region, 50);
    107127        psFree (chip->fromFPA);
     
    125145
    126146    psFree (output->fpa->fromTPA);
     147    // NOTE: when we call psPlaneTransformInvert here, we do not increase the order as in other places
    127148    output->fpa->fromTPA = psPlaneTransformInvert(NULL, output->fpa->toTPA, *fpaRegion, 50);
    128149
     
    131152
    132153    psMetadata *header = output->fpa->hdu->header;
     154   
    133155    pmAstromWriteBilevelMosaic (header, output->fpa, NONLIN_TOL);
    134156
     
    172194        // invert the new fromFPA transform to get the new toFPA transform
    173195        // the region used here is the region covered by the chip in the FPA
     196        // NOTE: when we call psPlaneTransformInvert here, we do not increase the order as in other places
    174197        psPlaneTransform *fromFPA = psPlaneTransformInvert(NULL, chip->toFPA, *region, 50);
    175198        psFree (chip->fromFPA);
Note: See TracChangeset for help on using the changeset viewer.