IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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;
Note: See TracChangeset for help on using the changeset viewer.