IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 30811


Ignore:
Timestamp:
Mar 6, 2011, 12:39:13 PM (15 years ago)
Author:
eugene
Message:

update output headers to include more info on the input images (airmasses, exptimes, zpts)

Location:
branches/eam_branches/ipp-20110213/ppStack/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110213/ppStack/src/ppStackConvolve.c

    r30806 r30811  
    323323
    324324        // UPDATE CELL.SATURATION here
    325         UPDATE_CONCEPT(outFPA,  "FPA.EXPOSURE",  options->sumExposure);
    326         UPDATE_CONCEPT(outCell, "CELL.EXPOSURE", options->sumExposure);
    327         UPDATE_CONCEPT(outCell, "CELL.DARKTIME", NAN);
     325        UPDATE_CONCEPT(outFPA,  "FPA.EXPOSURE",    options->sumExposure);
     326        UPDATE_CONCEPT(outCell, "CELL.EXPOSURE",   options->sumExposure);
     327        UPDATE_CONCEPT(outCell, "CELL.DARKTIME",   NAN);
    328328        UPDATE_CONCEPT(outCell, "CELL.SATURATION", satBest);
    329         UPDATE_CONCEPT(outFPA,  "FPA.ZP",        options->zp);
    330 
    331         UPDATE_CONCEPT(unconvFPA,  "FPA.EXPOSURE",  options->sumExposure);
    332         UPDATE_CONCEPT(unconvCell, "CELL.EXPOSURE", options->sumExposure);
    333         UPDATE_CONCEPT(unconvCell, "CELL.DARKTIME", NAN);
     329        UPDATE_CONCEPT(outFPA,  "FPA.ZP",          options->zp);
     330        UPDATE_CONCEPT(outFPA,  "FPA.AIRMASS",     options->airmass);
     331
     332        UPDATE_CONCEPT(unconvFPA,  "FPA.EXPOSURE",    options->sumExposure);
     333        UPDATE_CONCEPT(unconvCell, "CELL.EXPOSURE",   options->sumExposure);
     334        UPDATE_CONCEPT(unconvCell, "CELL.DARKTIME",   NAN);
    334335        UPDATE_CONCEPT(unconvCell, "CELL.SATURATION", satBest);
    335         UPDATE_CONCEPT(unconvFPA,  "FPA.ZP",        options->zp);
     336        UPDATE_CONCEPT(unconvFPA,  "FPA.ZP",          options->zp);
     337        UPDATE_CONCEPT(unconvFPA,  "FPA.AIRMASS",     options->airmass);
    336338
    337339        psLogMsg("ppStack", PS_LOG_INFO, "stack adjust metadata values : zp %f, exptime %f, sat %f", options->zp, options->sumExposure, satBest);
  • branches/eam_branches/ipp-20110213/ppStack/src/ppStackOptions.h

    r30620 r30811  
    2222    float sumExposure;                  // Sum of exposure times
    2323    float zp;                           // Zero point for output
     24    float zpErr;                        // Zero point error for output
     25    float airmass;                      // airmass for output image
     26    float airmassSlope;                 // airmass slope used for zp analysis
    2427    psVector *inputMask;                // Mask for inputs
    2528    psArray *sourceLists;               // Individual lists of sources for matching
    2629    psVector *norm;                     // Normalisation for each image
     30    psVector *zpInput;                  // reported zero point of input exposure
     31    psVector *expTimeInput;             // exposure time of input exposure
     32    psVector *airmassInput;             // airmass of input exposure
    2733    psArray *sources;                   // Matched sources
    2834    // Convolve
  • branches/eam_branches/ipp-20110213/ppStack/src/ppStackSources.c

    r30802 r30811  
    115115    float fracMatch = psMetadataLookupF32(NULL, recipe, "ZP.MATCH"); // Fraction of images to match for star
    116116
    117     psMetadata *airmassZP = psMetadataLookupMetadata(NULL, recipe, "ZP.AIRMASS"); // Airmass terms
     117    bool mdok = false;
     118    float airmassTarget = psMetadataLookupF32(&mdok, recipe, "ZP.AIRMASS.TARGET"); // output airmass value
     119    if (!mdok) {
     120        airmassTarget = 1.0;
     121    }
     122
     123    psMetadata *airmassZP = psMetadataLookupMetadata(NULL, recipe, "ZP.AIRMASS"); // Airmass terms (slopes) by filter
    118124    if (!airmassZP) {
    119125        psError(PPSTACK_ERR_CONFIG, false, "Unable to find ZP.AIRMASS in recipe.");
     
    128134    int num = options->num;             // Number of inputs
    129135    psAssert(num == sourceLists->n, "Wrong number of source lists: %ld\n", sourceLists->n);
     136
     137    // vectors to store these inputs so they may be recorded in the output headers
     138    options->zpInput      = psVectorAlloc(num, PS_TYPE_F32);
     139    options->expTimeInput = psVectorAlloc(num, PS_TYPE_F32);
     140    options->airmassInput = psVectorAlloc(num, PS_TYPE_F32);
    130141
    131142    psVector *zp = psVectorAlloc(num, PS_TYPE_F32); // Relative zero points for each image
     
    167178        const char *expFilter = psMetadataLookupStr(NULL, file->fpa->concepts, "FPA.FILTER"); // Filter name
    168179        zpExp->data.F32[i] = psMetadataLookupF32(NULL, file->fpa->concepts, "FPA.ZP"); // Exposure zero point
     180        // XXX need to get the zero point error values and propagate to get the FPA.ZP.ERR value
     181
     182        options->zpInput->data.F32[i] = zpExp->data.F32[i]; // NOTE zpExp may be re-assigned below using relative photometry
     183        options->expTimeInput->data.F32[i] = exptime;
     184        options->airmassInput->data.F32[i] = airmass;
     185
    169186        psLogMsg("ppStack", PS_LOG_INFO,
    170187                 "Image %d: %.2f sec exposure in %s at airmass %.2f with zero point %.2f",
     
    185202        if (!filter) {
    186203            filter = expFilter;
    187             bool mdok;
    188204            airmassTerm = psMetadataLookupF32(&mdok, airmassZP, filter);
    189205            if (!mdok || !isfinite(airmassTerm)) {
     
    277293
    278294        // For any star, the observed instrumental magnitude on an image and the apparent magnitude are related by:
    279         // M_app = m_inst + zp + c1 * airmass + 2.5log(t) + transparency
     295        // M_app = m_inst + zp + c1 * airmass + 2.5log(t) - transparency
     296        // NOTE the sign of 'transparency'  this must agree with the definition in pmSourceMatch.c. see, eg, line 457 where
     297        // transparency = m_inst + zp + c1 * airmass + 2.5log(t) - M_app
    280298
    281299        // we want to adjust the input images to be in a consistent flux system so that the
     
    288306        // m_inst_o : instrumental mags on re-normalized image (out)
    289307
    290         // m_inst_o + zp_o + c1 * airmass_o + 2.5log(t_o) + trans_o = m_inst_i + zp_i + c1 * airmass_i + 2.5log(t_i) + trans_i
    291 
    292         // m_inst_o = m_inst_i + (zp_i - zp_o) + c1 * (airmass_i - airmass_o) + 2.5log(t_i) - 2.5log(t_o) + trans_i - trans_o
     308        // m_inst_o + zp_o + c1 * airmass_o + 2.5log(t_o) - trans_o = m_inst_i + zp_i + c1 * airmass_i + 2.5log(t_i) - trans_i
     309
     310        // m_inst_o = m_inst_i + (zp_i - zp_o) + c1 * (airmass_i - airmass_o) + 2.5log(t_i) - 2.5log(t_o) - trans_i + trans_o
    293311
    294312        // zp_i, airmass_i, t_i, trans_i : reported or measured for input image
     
    305323        // NOTE: in case (b), the current code is equating the TARGET zp with the NOMINAL zp, which is wrong.
    306324
    307         // m_inst_o - m_inst_i = zp[i] - zpTarget - c1 * airmassTarget - 2.5log(sumExpTime) + trans_i
     325        // m_inst_o - m_inst_i = zp[i] - zpTarget - c1 * airmassTarget - 2.5log(sumExpTime) - trans_i
    308326
    309327        if (options->matchZPs) {
     
    314332                }
    315333                psArray *sources = sourceLists->data[i]; // Sources of interest
    316                 float magCorr = zp->data.F32[i] - trans->data.F32[i] - 2.5*log10(options->sumExposure);
     334                float magCorr = zp->data.F32[i] - trans->data.F32[i] - 2.5*log10(options->sumExposure) - airmassTerm * airmassTarget;
    317335                if (zpExpNum == numGoodImages) { // case (a)
    318336                    // Using measured zero points, so attempt to set target zero point
     
    341359            // Producing image with target zero point
    342360            options->zp = zpTarget;
     361            options->airmass = airmassTarget;
     362            options->airmassSlope = airmassTerm;
    343363        } else {
    344364            options->zp = NAN;
  • branches/eam_branches/ipp-20110213/ppStack/src/ppStackUpdateHeader.c

    r30808 r30811  
    7070    psMetadataAddStr(hdu->header, PS_LIST_TAIL, "TESS_ID", PS_META_REPLACE, "type of stack", tessID);
    7171
    72     // add data about the inputs
     72    psMetadataAddF32(hdu->header, PS_LIST_TAIL, "AIRM_SLP", PS_META_REPLACE, "airmass slope", options->airmassSlope);
     73   
     74
     75    // write the following fields to the output headers:
     76    // INP_NNNN : input file names
     77    // SCL_NNNN : scale factor for each input file
     78    // ZPT_NNNN : zero point of input file
     79    // EXT_NNNN : exptime of input file
     80    // AIR_NNNN : airmass of input file
     81
     82    // use separate loops so they are blocked together in the headers (more readable)
     83
     84    // save the input filenames
    7385    for (int i = 0; i < options->num; i++) {
    7486        char field[64];
     
    7890        psMetadataAddStr(hdu->header, PS_LIST_TAIL, field, PS_META_REPLACE, "input image name", basename);
    7991        psFree(basename);
    80 
    81         float inScale = pow(10.0, -0.4*options->norm->data.F32[i]);
    82         snprintf (field, 64, "SCL_%04d", i);
    83         psMetadataAddF32(hdu->header, PS_LIST_TAIL, field, PS_META_REPLACE, "input image scale factor", inScale);
    8492    }   
    8593
     94    // save the input normalizations
     95    for (int i = 0; i < options->num; i++) {
     96        char field[64];
     97
     98        float value = options->norm ? pow(10.0, -0.4*options->norm->data.F32[i]) : NAN;
     99        snprintf (field, 64, "SCL_%04d", i);
     100        psMetadataAddF32(hdu->header, PS_LIST_TAIL, field, PS_META_REPLACE, "input image scale factor", value);
     101    }   
     102    // save the input exptimes
     103    for (int i = 0; i < options->num; i++) {
     104        char field[64];
     105
     106        float value = options->zpInput ? options->zpInput->data.F32[i] : NAN;
     107        snprintf (field, 64, "ZPT_%04d", i);
     108        psMetadataAddF32(hdu->header, PS_LIST_TAIL, field, PS_META_REPLACE, "input image zero point", value);
     109    }   
     110    // save the input normalizations
     111    for (int i = 0; i < options->num; i++) {
     112        char field[64];
     113
     114        float value = options->expTimeInput ? options->expTimeInput->data.F32[i] : NAN;
     115        snprintf (field, 64, "EXP_%04d", i);
     116        psMetadataAddF32(hdu->header, PS_LIST_TAIL, field, PS_META_REPLACE, "input image exptime", value);
     117    }   
     118    // save the input normalizations
     119    for (int i = 0; i < options->num; i++) {
     120        char field[64];
     121
     122        float value = options->airmassInput ? options->airmassInput->data.F32[i] : NAN;
     123        snprintf (field, 64, "AIR_%04d", i);
     124        psMetadataAddF32(hdu->header, PS_LIST_TAIL, field, PS_META_REPLACE, "input image airmass", value);
     125    }   
    86126    return true;
    87127}
Note: See TracChangeset for help on using the changeset viewer.