IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 27034


Ignore:
Timestamp:
Feb 22, 2010, 4:21:34 PM (16 years ago)
Author:
Paul Price
Message:

Was setting FPA.ZP from the wrong place.

File:
1 edited

Legend:

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

    r26966 r27034  
    6262    psVector *dMag = NULL;
    6363
     64    float fpaZP = 0.0;                  // Average zero point
     65    int numZP = 0.0;                    // Number of measurements
     66
    6467    // this loop selects the matched stars for all chips
    6568    // XXX optionally measure zero point for entire exposure in a single statistic
     
    8689                    psFree (dMag);
    8790                    dMag = NULL;
     91
     92                    float zp = psMetadataLookupF32(NULL, header, "ZPT_OBS");
     93                    if (isfinite(zp)) {
     94                        fpaZP += zp;
     95                        numZP++;
     96                    }
     97
     98
    8899                }
    89100            }
     
    92103
    93104    if (byExposure) {
    94         psMetadata *header = psMetadataLookupMetadata (&status, fpa->analysis, "PSASTRO.HEADER");
    95         if (!header) {
    96             header = psMetadataAlloc ();
    97             psMetadataAddMetadata (fpa->analysis, PS_LIST_TAIL, "PSASTRO.HEADER",  PS_META_REPLACE, "psastro header stats", header);
    98             psFree (header);
    99         }
    100         psastroZeroPointAnalysis (header, dMag, zeropt, recipe);
    101         psFree (dMag);
    102         dMag = NULL;
    103 
    104         float zptObs = psMetadataLookupF32 (&status, header, "ZPT_OBS");
    105         float zptRef = psMetadataLookupF32 (&status, header, "ZPT_REF");
    106         float zptErr = psMetadataLookupF32 (&status, header, "ZPT_ERR");
    107         float zptOff = psMetadataLookupF32 (&status, header, "ZPT_OFF");
    108 
    109         // copy the zero point metadata from the fpa header to the chip headers
    110         for (int i = 0; i < fpa->chips->n; i++) {
    111             pmChip *chip = fpa->chips->data[i];
    112             if (!chip) continue;
    113             if (!chip->process) continue;
    114             if (!chip->file_exists) continue;
    115 
    116             for (int j = 0; j < chip->cells->n; j++) {
    117                 pmCell *cell = chip->cells->data[j];
    118                 if (!cell) continue;
    119                 if (!cell->process) continue;
    120                 if (!cell->file_exists) continue;
    121 
    122                 for (int k = 0; k < cell->readouts->n; k++) {
    123                     pmReadout *readout = cell->readouts->data[k];
    124                     if (!readout) continue;
    125                     if (!readout->data_exists) continue;
    126 
    127                     // calculate dMag for the matched stars just for this readout (well, chip)
    128                     psMetadata *header = psMetadataLookupMetadata (&status, readout->analysis, "PSASTRO.HEADER");
    129 
    130                     psMetadataAddF32 (header, PS_LIST_TAIL, "ZPT_OBS", PS_META_REPLACE, "measured zero point",  zptObs);
    131                     psMetadataAddF32 (header, PS_LIST_TAIL, "ZPT_REF", PS_META_REPLACE, "reference zero point", zptRef);
    132                     psMetadataAddF32 (header, PS_LIST_TAIL, "ZPT_ERR", PS_META_REPLACE, "error on zero point",  zptErr);
    133                     psMetadataAddF32 (header, PS_LIST_TAIL, "ZPT_OFF", PS_META_REPLACE, "zero point offset",    zptOff);
    134                 }
    135             }
    136         }
    137     }
     105        psMetadata *header = psMetadataLookupMetadata (&status, fpa->analysis, "PSASTRO.HEADER");
     106        if (!header) {
     107            header = psMetadataAlloc ();
     108            psMetadataAddMetadata (fpa->analysis, PS_LIST_TAIL, "PSASTRO.HEADER",  PS_META_REPLACE, "psastro header stats", header);
     109            psFree (header);
     110        }
     111        psastroZeroPointAnalysis (header, dMag, zeropt, recipe);
     112        psFree (dMag);
     113        dMag = NULL;
     114
     115        float zptObs = psMetadataLookupF32 (&status, header, "ZPT_OBS");
     116        float zptRef = psMetadataLookupF32 (&status, header, "ZPT_REF");
     117        float zptErr = psMetadataLookupF32 (&status, header, "ZPT_ERR");
     118        float zptOff = psMetadataLookupF32 (&status, header, "ZPT_OFF");
     119
     120        fpaZP = zptObs;
     121        numZP = 1;
     122
     123        // copy the zero point metadata from the fpa header to the chip headers
     124        for (int i = 0; i < fpa->chips->n; i++) {
     125            pmChip *chip = fpa->chips->data[i];
     126            if (!chip) continue;
     127            if (!chip->process) continue;
     128            if (!chip->file_exists) continue;
     129
     130            for (int j = 0; j < chip->cells->n; j++) {
     131                pmCell *cell = chip->cells->data[j];
     132                if (!cell) continue;
     133                if (!cell->process) continue;
     134                if (!cell->file_exists) continue;
     135
     136                for (int k = 0; k < cell->readouts->n; k++) {
     137                    pmReadout *readout = cell->readouts->data[k];
     138                    if (!readout) continue;
     139                    if (!readout->data_exists) continue;
     140
     141                    // calculate dMag for the matched stars just for this readout (well, chip)
     142                    psMetadata *header = psMetadataLookupMetadata (&status, readout->analysis, "PSASTRO.HEADER");
     143
     144                    psMetadataAddF32 (header, PS_LIST_TAIL, "ZPT_OBS", PS_META_REPLACE, "measured zero point",  zptObs);
     145                    psMetadataAddF32 (header, PS_LIST_TAIL, "ZPT_REF", PS_META_REPLACE, "reference zero point", zptRef);
     146                    psMetadataAddF32 (header, PS_LIST_TAIL, "ZPT_ERR", PS_META_REPLACE, "error on zero point",  zptErr);
     147                    psMetadataAddF32 (header, PS_LIST_TAIL, "ZPT_OFF", PS_META_REPLACE, "zero point offset",    zptOff);
     148                }
     149            }
     150        }
     151    }
     152
    138153
    139154    psMetadataItem *item = psMetadataLookup(fpa->concepts, "FPA.ZP");
    140     item->data.F32 = zeropt;
     155    item->data.F32 = fpaZP / (float)numZP;
    141156
    142157    psFree (view);
Note: See TracChangeset for help on using the changeset viewer.