IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 19516


Ignore:
Timestamp:
Sep 11, 2008, 3:10:04 PM (18 years ago)
Author:
eugene
Message:

various fixes to the model

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psastro/src/psastroModelAnalysis.c

    r19386 r19516  
    11# include "psastroStandAlone.h"
     2# define NONLIN_TOL 0.001
    23
    34bool psastroModelAnalysis (pmConfig *config) {
     
    1213    }
    1314
    14     pmFPAfile *output = psMetadataLookupPtr (&status, config->files, "PSASTRO.OUT.MODEL");
    15     if (!status) psAbort ("Can't find output pmFPAfile PSASTRO.OUT.MODEL");
    16 
    17     char *outroot = psMetadataLookupStr (&status, config->arguments, "OUTPUT");
    18     if (!status || !outroot) psAbort ("Can't find outroot on config->arguments");
    19 
    20     // physical pixel scale in microns per pixel
     15    // reference chip for boresite parameters
    2116    char *refChip = psMetadataLookupStr (&status, recipe, "PSASTRO.MODEL.REF.CHIP");
    2217    if (!refChip) {
     
    2419        return false;
    2520    }
     21
     22    pmFPAfile *output = psMetadataLookupPtr (&status, config->files, "PSASTRO.OUT.MODEL");
     23    if (!status) psAbort ("Can't find output pmFPAfile PSASTRO.OUT.MODEL");
     24
     25    // measure the boresite position from a rotation sequence?
     26    bool fitBoresite = psMetadataLookupBool (&status, recipe, "PSASTRO.MODEL.FIT.BORESITE");
     27    if (!fitBoresite) {
     28        psMetadataAddF32 (output->fpa->concepts, PS_LIST_TAIL, "FPA.BORE.X0", PS_META_REPLACE, "boresite parameter", 0.0);
     29        psMetadataAddF32 (output->fpa->concepts, PS_LIST_TAIL, "FPA.BORE.Y0", PS_META_REPLACE, "boresite parameter", 0.0);
     30        psMetadataAddF32 (output->fpa->concepts, PS_LIST_TAIL, "FPA.BORE.RX", PS_META_REPLACE, "boresite parameter", 0.0);
     31        psMetadataAddF32 (output->fpa->concepts, PS_LIST_TAIL, "FPA.BORE.RY", PS_META_REPLACE, "boresite parameter", 0.0);
     32        psMetadataAddF32 (output->fpa->concepts, PS_LIST_TAIL, "FPA.BORE.T0", PS_META_REPLACE, "boresite parameter", 0.0);
     33        psMetadataAddF32 (output->fpa->concepts, PS_LIST_TAIL, "FPA.BORE.P0", PS_META_REPLACE, "boresite parameter", 0.0);
     34        psMetadataAddStr (output->fpa->concepts, PS_LIST_TAIL, "FPA.REF.CHIP", PS_META_REPLACE, "boresite parameter", refChip);
     35        return true;
     36    }
     37
     38    char *outroot = psMetadataLookupStr (&status, config->arguments, "OUTPUT");
     39    if (!status || !outroot) psAbort ("Can't find outroot on config->arguments");
    2640
    2741    /* model analysis:
     
    3852     * T_0 : reference angle for rotator
    3953     * P_0 : orientation of boresite ellipse
     54     *
    4055     */
    4156
     
    7691        pmFPAfile *input = file->data.V;
    7792
    78         // reported rotator position angle (this should perhaps be ROT, not POS)
     93        // reported rotator position angle
    7994        double POSANGLE = psMetadataLookupF64 (&status, input->fpa->concepts, "FPA.POSANGLE");
    8095        if (!status) psAbort ("missing FPA.POSANGLE");
     
    8499        if (!chip) psAbort ("invalid chip name for reference");
    85100
    86         // fprintf (stderr, "input %d : %zx : %zx : %zx\n", i, (size_t) input, (size_t) chip, (size_t) chip->toFPA);
    87101        if (!chip->toFPA) continue;
    88102
     
    96110        // all posZero values should be clustered in some region, but we need to flip over the 0,360 boundary correctly.
    97111        // push all to one side or the other
    98         float posangle = PM_DEG_RAD * atan2 (chip->toFPA->y->coeff[1][0], chip->toFPA->x->coeff[1][0]);
    99         posZero->data.F32[n] = POSANGLE - posangle;
     112        float chipAngle = PM_DEG_RAD * atan2 (chip->toFPA->y->coeff[1][0], chip->toFPA->x->coeff[1][0]);
     113        float fpaAngle = PM_DEG_RAD * atan2 (input->fpa->toTPA->y->coeff[1][0], input->fpa->toTPA->x->coeff[1][0]);
     114
     115        posZero->data.F32[n] = POSANGLE - chipAngle - fpaAngle;
    100116        if (n == 0) {
    101117            posBoundary = posZero->data.F32[n] + 180.0;
     
    106122
    107123        Po->data.F32[n] = POSANGLE * PM_RAD_DEG; // reported position angle
    108         Xo->data.F32[n] = chip->fromFPA->x->coeff[0][0]; // reported boresite x position in ref chip coordinates
    109         Yo->data.F32[n] = chip->fromFPA->y->coeff[0][0]; // reported boresite y position in ref chip coordinates
    110         fprintf (outfile, "%d : %f %f : %f = %f - %f\n", i, Xo->data.F32[n], Yo->data.F32[n], posZero->data.F32[n], POSANGLE, posangle);
     124        float xc = chip->fromFPA->x->coeff[0][0]; // reported boresite x position in ref chip coordinates
     125        float yc = chip->fromFPA->y->coeff[0][0]; // reported boresite y position in ref chip coordinates
     126        // XXX this can also be derived from toFPA via GetCenter....
     127       
     128        psPlane *PT = psPlaneTransformGetCenter (chip->toFPA, NONLIN_TOL);
     129        Xo->data.F32[n] = PT->x; // reported boresite x position in ref chip coordinates
     130        Yo->data.F32[n] = PT->y; // reported boresite y position in ref chip coordinates
     131        psFree (PT);
     132
     133        fprintf (outfile, "%d : %f %f : %f = %f - %f - %f | %f %f\n", i, Xo->data.F32[n], Yo->data.F32[n], posZero->data.F32[n], POSANGLE, chipAngle, fpaAngle, xc, yc);
    111134        n ++;
    112135    }
Note: See TracChangeset for help on using the changeset viewer.