IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 10, 2010, 7:36:29 PM (16 years ago)
Author:
eugene
Message:

updates from eam_branches/20091201 (substantially changes to the psphotReadout APIs to support future stack photometry; improvements to the CR masking code)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/psphotOutput.c

    r25755 r26894  
    126126}
    127127
    128 bool psphotAddPhotcode (psMetadata *recipe, pmConfig *config, const pmFPAview *view, const char *filerule) {
    129 
    130     bool status;
    131 
    132     pmFPAfile *input = psMetadataLookupPtr (&status, config->files, filerule);
    133     PS_ASSERT (status, false);
    134 
    135     // determine PHOTCODE from fpa & view, overwrite in recipe
    136     char *photcode = pmConceptsPhotcodeForView (input, view);
     128bool psphotAddPhotcode (pmConfig *config, const pmFPAview *view) {
     129
     130    bool status = false;
     131
     132    int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
     133    psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     134
     135    // loop over the available readouts
     136    for (int i = 0; i < num; i++) {
     137        if (!psphotAddPhotcodeReadout (config, view, "PSPHOT.INPUT", i)) {
     138            psError (PSPHOT_ERR_CONFIG, false, "failed to add photcode to PSPHOT.INPUT entry %d", i);
     139            return false;
     140        }
     141    }
     142    return true;
     143}
     144
     145bool psphotAddPhotcodeReadout (pmConfig *config, const pmFPAview *view, const char *filerule, int index) {
     146
     147    pmFPAfile *file = pmFPAfileSelectSingle(config->files, filerule, index); // File of interest
     148    PS_ASSERT (file, false);
     149
     150    pmReadout  *readout = pmFPAviewThisReadout (view, file->fpa);
     151
     152    // determine PHOTCODE from fpa & view, overwrite in readout->analysis
     153    char *photcode = pmConceptsPhotcodeForView (file, view);
    137154    PS_ASSERT (photcode, false);
    138155
    139     psMetadataAddStr (recipe, PS_LIST_TAIL, "PHOTCODE", PS_META_REPLACE, "photcode from FPA concepts", photcode);
     156    psMetadataAddStr (readout->analysis, PS_LIST_TAIL, "PHOTCODE", PS_META_REPLACE, "photcode from FPA concepts", photcode);
    140157    psLogMsg ("psphot", 3, "PHOTCODE is %s", photcode);
    141158
     
    144161}
    145162
    146 bool psphotSetHeaderNstars (psMetadata *recipe, psArray *sources) {
     163bool psphotSetHeaderNstars (psMetadata *header, psArray *sources) {
    147164
    148165    int nSrc = 0;
     
    173190    }
    174191
    175     psMetadataAddS32 (recipe, PS_LIST_TAIL, "NSTARS",   PS_META_REPLACE, "Number of sources", nSrc);
    176     psMetadataAddS32 (recipe, PS_LIST_TAIL, "NDET_EXT", PS_META_REPLACE, "Number of extended sources", nEXT);
    177     psMetadataAddS32 (recipe, PS_LIST_TAIL, "NDET_CR",  PS_META_REPLACE, "Number of cosmic rays", nCR);
    178     return true;
    179 }
    180 
    181 // these values are saved in an output header stub - they are added to either the
    182 // PHU header (CMP) or the MEF table header (CMF)
    183 psMetadata *psphotDefineHeader (psMetadata *recipe) {
     192    psMetadataAddS32 (header, PS_LIST_TAIL, "NSTARS",   PS_META_REPLACE, "Number of sources", nSrc);
     193    psMetadataAddS32 (header, PS_LIST_TAIL, "NDET_EXT", PS_META_REPLACE, "Number of extended sources", nEXT);
     194    psMetadataAddS32 (header, PS_LIST_TAIL, "NDET_CR",  PS_META_REPLACE, "Number of cosmic rays", nCR);
     195    return true;
     196}
     197
     198// these values are saved in an output header stub - they are added to either the PHU header
     199// (CMP) or the MEF table header (CMF).  before the header is created, each readout has these
     200// values stored on readout->analysis
     201psMetadata *psphotDefineHeader (psMetadata *analysis) {
     202
     203    bool status = true;
    184204
    185205    psMetadata *header = psMetadataAlloc ();
    186206
    187207    // write necessary information to output header
    188     psMetadataItemSupplement (header, recipe, "ZERO_PT");
    189     psMetadataItemSupplement (header, recipe, "PHOTCODE");
    190 
    191     psMetadataItemSupplement (header, recipe, "APMIFIT");
    192     psMetadataItemSupplement (header, recipe, "DAPMIFIT");
    193     psMetadataItemSupplement (header, recipe, "NAPMIFIT");
     208    psMetadataItemSupplement (&status, header, analysis, "ZERO_PT");
     209    psMetadataItemSupplement (&status, header, analysis, "PHOTCODE");
     210
     211    psMetadataItemSupplement (&status, header, analysis, "APMIFIT");
     212    psMetadataItemSupplement (&status, header, analysis, "DAPMIFIT");
     213    psMetadataItemSupplement (&status, header, analysis, "NAPMIFIT");
    194214
    195215    // PSF model parameters (shape values for image center)
    196     psMetadataItemSupplement (header, recipe, "NPSFSTAR");
    197     psMetadataItemSupplement (header, recipe, "APLOSS");
    198 
    199     psMetadataItemSupplement (header, recipe, "FWHM_MAJ");
    200     psMetadataItemSupplement (header, recipe, "FW_MJ_SG");
    201     psMetadataItemSupplement (header, recipe, "FW_MJ_LQ");
    202     psMetadataItemSupplement (header, recipe, "FW_MJ_UQ");
    203 
    204     psMetadataItemSupplement (header, recipe, "FWHM_MIN");
    205     psMetadataItemSupplement (header, recipe, "FW_MN_SG");
    206     psMetadataItemSupplement (header, recipe, "FW_MN_LQ");
    207     psMetadataItemSupplement (header, recipe, "FW_MN_UQ");
    208 
    209     psMetadataItemSupplement (header, recipe, "ANGLE");
     216    psMetadataItemSupplement (&status, header, analysis, "NPSFSTAR");
     217    psMetadataItemSupplement (&status, header, analysis, "APLOSS");
     218
     219    psMetadataItemSupplement (&status, header, analysis, "FWHM_MAJ");
     220    psMetadataItemSupplement (&status, header, analysis, "FW_MJ_SG");
     221    psMetadataItemSupplement (&status, header, analysis, "FW_MJ_LQ");
     222    psMetadataItemSupplement (&status, header, analysis, "FW_MJ_UQ");
     223
     224    psMetadataItemSupplement (&status, header, analysis, "FWHM_MIN");
     225    psMetadataItemSupplement (&status, header, analysis, "FW_MN_SG");
     226    psMetadataItemSupplement (&status, header, analysis, "FW_MN_LQ");
     227    psMetadataItemSupplement (&status, header, analysis, "FW_MN_UQ");
     228
     229    psMetadataItemSupplement (&status, header, analysis, "ANGLE");
    210230
    211231    // Image Quality measurements
    212     psMetadataItemSupplement (header, recipe, "IQ_NSTAR");
    213 
    214     psMetadataItemSupplement (header, recipe, "IQ_FW1");
    215     psMetadataItemSupplement (header, recipe, "IQ_FW1_E");
    216     psMetadataItemSupplement (header, recipe, "IQ_FW2");
    217     psMetadataItemSupplement (header, recipe, "IQ_FW2_E");
    218 
    219     psMetadataItemSupplement (header, recipe, "IQ_M2");
    220     psMetadataItemSupplement (header, recipe, "IQ_M2_ER");
    221     psMetadataItemSupplement (header, recipe, "IQ_M2_LQ");
    222     psMetadataItemSupplement (header, recipe, "IQ_M2_UQ");
    223 
    224     psMetadataItemSupplement (header, recipe, "IQ_M2C");
    225     psMetadataItemSupplement (header, recipe, "IQ_M2C_E");
    226     psMetadataItemSupplement (header, recipe, "IQ_M2C_L");
    227     psMetadataItemSupplement (header, recipe, "IQ_M2C_U");
    228 
    229     psMetadataItemSupplement (header, recipe, "IQ_M2S");
    230     psMetadataItemSupplement (header, recipe, "IQ_M2S_E");
    231     psMetadataItemSupplement (header, recipe, "IQ_M2S_L");
    232     psMetadataItemSupplement (header, recipe, "IQ_M2S_U");
    233 
    234     psMetadataItemSupplement (header, recipe, "IQ_M3");
    235     psMetadataItemSupplement (header, recipe, "IQ_M3_ER");
    236     psMetadataItemSupplement (header, recipe, "IQ_M3_LQ");
    237     psMetadataItemSupplement (header, recipe, "IQ_M3_UQ");
    238 
    239     psMetadataItemSupplement (header, recipe, "IQ_M4");
    240     psMetadataItemSupplement (header, recipe, "IQ_M4_ER");
    241     psMetadataItemSupplement (header, recipe, "IQ_M4_LQ");
    242     psMetadataItemSupplement (header, recipe, "IQ_M4_UQ");
     232    psMetadataItemSupplement (&status, header, analysis, "IQ_NSTAR");
     233
     234    psMetadataItemSupplement (&status, header, analysis, "IQ_FW1");
     235    psMetadataItemSupplement (&status, header, analysis, "IQ_FW1_E");
     236    psMetadataItemSupplement (&status, header, analysis, "IQ_FW2");
     237    psMetadataItemSupplement (&status, header, analysis, "IQ_FW2_E");
     238
     239    psMetadataItemSupplement (&status, header, analysis, "IQ_M2");
     240    psMetadataItemSupplement (&status, header, analysis, "IQ_M2_ER");
     241    psMetadataItemSupplement (&status, header, analysis, "IQ_M2_LQ");
     242    psMetadataItemSupplement (&status, header, analysis, "IQ_M2_UQ");
     243
     244    psMetadataItemSupplement (&status, header, analysis, "IQ_M2C");
     245    psMetadataItemSupplement (&status, header, analysis, "IQ_M2C_E");
     246    psMetadataItemSupplement (&status, header, analysis, "IQ_M2C_L");
     247    psMetadataItemSupplement (&status, header, analysis, "IQ_M2C_U");
     248
     249    psMetadataItemSupplement (&status, header, analysis, "IQ_M2S");
     250    psMetadataItemSupplement (&status, header, analysis, "IQ_M2S_E");
     251    psMetadataItemSupplement (&status, header, analysis, "IQ_M2S_L");
     252    psMetadataItemSupplement (&status, header, analysis, "IQ_M2S_U");
     253
     254    psMetadataItemSupplement (&status, header, analysis, "IQ_M3");
     255    psMetadataItemSupplement (&status, header, analysis, "IQ_M3_ER");
     256    psMetadataItemSupplement (&status, header, analysis, "IQ_M3_LQ");
     257    psMetadataItemSupplement (&status, header, analysis, "IQ_M3_UQ");
     258
     259    psMetadataItemSupplement (&status, header, analysis, "IQ_M4");
     260    psMetadataItemSupplement (&status, header, analysis, "IQ_M4_ER");
     261    psMetadataItemSupplement (&status, header, analysis, "IQ_M4_LQ");
     262    psMetadataItemSupplement (&status, header, analysis, "IQ_M4_UQ");
    243263
    244264    // XXX these need to be defined from elsewhere
    245265    psMetadataAdd (header, PS_LIST_TAIL, "FSATUR",   PS_DATA_F32 | PS_META_REPLACE, "SATURATION MAG",      0.0);
    246266    psMetadataAdd (header, PS_LIST_TAIL, "FLIMIT",   PS_DATA_F32 | PS_META_REPLACE, "COMPLETENESS MAG",    0.0);
    247     psMetadataItemSupplement (header, recipe, "NSTARS");
    248 
    249     psMetadataItemSupplement (header, recipe, "NDET_EXT");
    250     psMetadataItemSupplement (header, recipe, "NDET_CR");
     267    psMetadataItemSupplement (&status, header, analysis, "NSTARS");
     268
     269    psMetadataItemSupplement (&status, header, analysis, "NDET_EXT");
     270    psMetadataItemSupplement (&status, header, analysis, "NDET_CR");
    251271
    252272    // sky background model statistics
    253     psMetadataItemSupplement (header, recipe, "MSKY_MN");
    254     psMetadataItemSupplement (header, recipe, "MSKY_SIG");
    255     psMetadataItemSupplement (header, recipe, "MSKY_MIN");
    256     psMetadataItemSupplement (header, recipe, "MSKY_MAX");
    257     psMetadataItemSupplement (header, recipe, "MSKY_NX");
    258     psMetadataItemSupplement (header, recipe, "MSKY_NY");
     273    psMetadataItemSupplement (&status, header, analysis, "MSKY_MN");
     274    psMetadataItemSupplement (&status, header, analysis, "MSKY_SIG");
     275    psMetadataItemSupplement (&status, header, analysis, "MSKY_MIN");
     276    psMetadataItemSupplement (&status, header, analysis, "MSKY_MAX");
     277    psMetadataItemSupplement (&status, header, analysis, "MSKY_NX");
     278    psMetadataItemSupplement (&status, header, analysis, "MSKY_NY");
    259279
    260280    psMetadataAddF32 (header, PS_LIST_TAIL, "DT_PHOT", PS_META_REPLACE, "elapsed psphot time", psTimerMark ("psphotReadout"));
    261 
    262     // XXX : don't require any of these about values to exist
    263     psErrorClear ();
    264281
    265282    return header;
Note: See TracChangeset for help on using the changeset viewer.