IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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

finished psastroModel for boresite, created gpcModel for rough theoretical model, added useModel and fixChips options

File:
1 edited

Legend:

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

    r15887 r15891  
    1212    }
    1313
     14    pmFPAfile *output = psMetadataLookupPtr (&status, config->files, "PSASTRO.OUT.MODEL");
     15    if (!status) psAbort ("Can't find output pmFPAfile PSASTRO.OUT.MODEL");
     16
    1417    // physical pixel scale in microns per pixel
    1518    char *refChip = psMetadataLookupStr (&status, recipe, "PSASTRO.MODEL.REF.CHIP");
     
    1922    }
    2023
    21     /* model analysis steps:
    22 
    23     1) determine POS_ZERO:
    24     * choose a reference chip
    25     * what is posangle of chip
    26     * posangle = FPA.POSANGLE - POS_ZERO
    27     * POS_ZERO = FPA.POSANGLE - posangle
    28 
    29     ** average over input images
    30 
    31     2) determine boresite model
    32 
    33     * find CRPIX1,2 for a series of images
    34     * fit ellipse
    35 
    36     */
    37 
    38     /***** find the POSANGLE offset *****/
     24    /* model analysis:
     25     *
     26     * determine POS_ZERO via comparison of measured and reported posangles
     27     * POS_ZERO = FPA.POSANGLE - posangle
     28     *
     29     * determine boresite model:
     30     * X = Xo + R_X cos(FPA.POSANGLE - T_0) cos(P_0) + R_Y sin(FPA.POSANGLE - T_0) sin(P_0)
     31     * Y = Yo + R_Y sin(FPA.POSANGLE - T_0) cos(P_0) - R_X cos(FPA.POSANGLE - T_0) sin(P_0)
     32     * position of reported boresite in reference chip pixels
     33     * Xo, Yo : true coordinate of boresite (rotator center) in reference chip pixels
     34     * R_X, R_Y : amplitude of boresite offset
     35     * T_0 : reference angle for rotator
     36     * P_0 : orientation of boresite ellipse
     37     */
    3938
    4039    // select the input pmFPAfile pointers
     
    4443    psArray *files = psListToArray (item->data.list);
    4544
    46     // temp data vectors
     45    // data storage vectors for measurements
    4746    psVector *posZero  = psVectorAlloc (files->n, PS_TYPE_F32);
    4847    psVector *Po       = psVectorAlloc (files->n, PS_TYPE_F32);
    49     psVector *Lo       = psVectorAlloc (files->n, PS_TYPE_F32);
    50     psVector *Mo       = psVectorAlloc (files->n, PS_TYPE_F32);
     48    psVector *Xo       = psVectorAlloc (files->n, PS_TYPE_F32);
     49    psVector *Yo       = psVectorAlloc (files->n, PS_TYPE_F32);
    5150
     51    // counter for accepted measured values
    5252    int n = 0;
    5353
    54     // convert the headers for the input file into fpa astrometry terms
     54    // Re-select the output fpa.  The output fpa needs to have valid astrometry for the
     55    // refChip.  output->fpa is a copy of the pointer to one of the input->fpa, but the choice
     56    // is arbitrary.  select a new one that has an existing ref chip
     57    psFree (output->fpa);
     58    output->fpa = NULL;
     59
     60    // extract the relevant measured and reported values from the reference chip
    5561    for (int i = 0; i < files->n; i++) {
    5662        psMetadataItem *file = files->data[i];
    5763        pmFPAfile *input = file->data.V;
    5864
     65        // reported rotator position angle (this should perhaps be ROT, not POS)
    5966        double POSANGLE = psMetadataLookupF64 (&status, input->fpa->concepts, "FPA.POSANGLE");
    6067        if (!status) psAbort ("missing FPA.POSANGLE");
    6168
    62         // get chip from name
     69        // get reference chip from name
    6370        pmChip *chip = pmConceptsChipFromName (input->fpa, refChip);
    6471        if (!chip) psAbort ("invalid chip name for reference");
    6572
     73        fprintf (stderr, "input %d : %zx : %zx : %zx\n", i, (size_t) input, (size_t) chip, (size_t) chip->toFPA);
    6674        if (!chip->toFPA) continue;
     75
     76        if (!output->fpa) {
     77            // this one matches
     78            output->fpa = psMemIncrRefCounter(input->fpa);
     79        }
    6780
    6881        // we have two measurements of the posangle (may be parity flipped to different quadrants)
     
    7285        while (posZero->data.F32[n] <   0.0) posZero->data.F32[n] += 360.0;
    7386
    74         Po->data.F32[n] = POSANGLE * PM_RAD_DEG;
    75         Lo->data.F32[n] = chip->toFPA->x->coeff[0][0];
    76         Mo->data.F32[n] = chip->toFPA->y->coeff[0][0];
    77         fprintf (stderr, "%d : %f %f : %f = %f - %f\n", i, Lo->data.F32[n], Mo->data.F32[n], posZero->data.F32[n], POSANGLE, posangle);
     87        Po->data.F32[n] = POSANGLE * PM_RAD_DEG; // reported position angle
     88        Xo->data.F32[n] = chip->fromFPA->x->coeff[0][0]; // reported boresite x position in ref chip coordinates
     89        Yo->data.F32[n] = chip->fromFPA->y->coeff[0][0]; // reported boresite y position in ref chip coordinates
     90        fprintf (stderr, "%d : %f %f : %f = %f - %f\n", i, Xo->data.F32[n], Yo->data.F32[n], posZero->data.F32[n], POSANGLE, posangle);
    7891        n ++;
    7992    }
    8093     
    81     Lo->n = n;
    82     Mo->n = n;
     94    Xo->n = n;
     95    Yo->n = n;
    8396    Po->n = n;
    8497    posZero->n = n;
     
    88101
    89102    fprintf (stderr, "pos zero %f +/- %f\n", stats->sampleMedian, stats->sampleStdev);
     103    psMetadataAddF32 (output->fpa->concepts, PS_LIST_TAIL, "FPA.POS_ZERO", PS_META_REPLACE, "offset between obs and meas posangle", stats->sampleMedian);
    90104
    91     psastroModelFitBoresite (Lo, Mo, Po);
     105    psVector *params = psastroModelFitBoresite (Xo, Yo, Po);
     106    if (params->n != 6) psAbort ("error");
     107
     108    psMetadataAddF32 (output->fpa->concepts, PS_LIST_TAIL, "FPA.BORE.X0", PS_META_REPLACE, "boresite parameter", params->data.F32[PAR_X0]);
     109    psMetadataAddF32 (output->fpa->concepts, PS_LIST_TAIL, "FPA.BORE.Y0", PS_META_REPLACE, "boresite parameter", params->data.F32[PAR_Y0]);
     110    psMetadataAddF32 (output->fpa->concepts, PS_LIST_TAIL, "FPA.BORE.RX", PS_META_REPLACE, "boresite parameter", params->data.F32[PAR_RX]);
     111    psMetadataAddF32 (output->fpa->concepts, PS_LIST_TAIL, "FPA.BORE.RY", PS_META_REPLACE, "boresite parameter", params->data.F32[PAR_RY]);
     112    psMetadataAddF32 (output->fpa->concepts, PS_LIST_TAIL, "FPA.BORE.T0", PS_META_REPLACE, "boresite parameter", params->data.F32[PAR_T0]);
     113    psMetadataAddF32 (output->fpa->concepts, PS_LIST_TAIL, "FPA.BORE.P0", PS_META_REPLACE, "boresite parameter", params->data.F32[PAR_P0]);
     114    psMetadataAddStr (output->fpa->concepts, PS_LIST_TAIL, "FPA.REF.CHIP", PS_META_REPLACE, "boresite parameter", refChip);
    92115
    93116    return true;
Note: See TracChangeset for help on using the changeset viewer.