IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 3, 2010, 8:50:52 AM (16 years ago)
Author:
eugene
Message:

updates from trunk

Location:
branches/simtest_nebulous_branches
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/simtest_nebulous_branches

  • branches/simtest_nebulous_branches/psphot

  • branches/simtest_nebulous_branches/psphot/src

    • Property svn:ignore
      •  

        old new  
        1818psphotVersionDefinitions.h
        1919psphotMomentsStudy
         20psphotPetrosianStudy
         21psphotForced
         22psphotMakePSF
         23psphotStack
  • branches/simtest_nebulous_branches/psphot/src/psphotOutput.c

    r21366 r27840  
    3131    }
    3232    return background;
     33}
     34
     35// dump source stats for psf stars
     36bool psphotDumpStats (psArray *sources, char *stage) {
     37
     38    char filename[64];
     39    snprintf (filename, 64, "psf.%s.dat", stage);
     40    FILE *f = fopen (filename, "w");
     41    for (int i = 0; i < sources->n; i++) {
     42        pmSource *source = sources->data[i];
     43        if (!(source->mode & PM_SOURCE_MODE_PSFSTAR)) continue;
     44
     45        pmModel *model = source->modelPSF;
     46        if (!model) continue;
     47
     48        // int xc = source->peak->x - source->pixels->col0;
     49        // int yc = source->peak->y - source->pixels->row0;
     50        // float mcore = source->modelFlux ? source->modelFlux->data.F32[yc][xc] : NAN;
     51        // float mpeak = model ? model->params->data.F32[PM_PAR_I0] : NAN;
     52        // bool subtracted = source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED;
     53        // fprintf (stderr, "%d %d : %d : %f %f : %f %f\n", source->peak->x, source->peak->y, subtracted, source->peak->flux, source->pixels->data.F32[yc][xc], mcore, mpeak);
     54
     55        fprintf (f, "%6.1f %6.1f : %6.1f %6.1f : %8.3f %8.3f %8.3f : %f : %f %f %f : %f\n",
     56                 source->peak->xf, source->peak->yf,
     57                 model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS],
     58                 source->psfMag, source->apMag, source->errMag,
     59                 model->params->data.F32[PM_PAR_I0],
     60                 model->params->data.F32[PM_PAR_SXX], model->params->data.F32[PM_PAR_SXY], model->params->data.F32[PM_PAR_SYY],
     61                 model->params->data.F32[PM_PAR_7]);
     62    }
     63    fclose (f);
     64    return true;
    3365}
    3466
     
    94126}
    95127
    96 bool psphotAddPhotcode (psMetadata *recipe, pmConfig *config, const pmFPAview *view, const char *filerule) {
    97 
    98     bool status;
    99 
    100     pmFPAfile *input = psMetadataLookupPtr (&status, config->files, filerule);
    101     PS_ASSERT (status, false);
    102 
    103     // determine PHOTCODE from fpa & view, overwrite in recipe
    104     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);
    105154    PS_ASSERT (photcode, false);
    106155
    107     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);
    108157    psLogMsg ("psphot", 3, "PHOTCODE is %s", photcode);
    109158
     
    112161}
    113162
    114 bool psphotSetHeaderNstars (psMetadata *recipe, psArray *sources) {
     163bool psphotSetHeaderNstars (psMetadata *header, psArray *sources) {
    115164
    116165    int nSrc = 0;
     
    141190    }
    142191
    143     psMetadataAddS32 (recipe, PS_LIST_TAIL, "NSTARS",   PS_META_REPLACE, "Number of sources", nSrc);
    144     psMetadataAddS32 (recipe, PS_LIST_TAIL, "NDET_EXT", PS_META_REPLACE, "Number of extended sources", nEXT);
    145     psMetadataAddS32 (recipe, PS_LIST_TAIL, "NDET_CR",  PS_META_REPLACE, "Number of cosmic rays", nCR);
    146     return true;
    147 }
    148 
    149 // these values are saved in an output header stub - they are added to either the
    150 // PHU header (CMP) or the MEF table header (CMF)
    151 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;
    152204
    153205    psMetadata *header = psMetadataAlloc ();
    154206
    155207    // write necessary information to output header
    156     psMetadataItemSupplement (header, recipe, "ZERO_PT");
    157     psMetadataItemSupplement (header, recipe, "PHOTCODE");
    158 
    159     psMetadataItemSupplement (header, recipe, "APMIFIT");
    160     psMetadataItemSupplement (header, recipe, "DAPMIFIT");
    161     psMetadataItemSupplement (header, recipe, "NAPMIFIT");
    162     psMetadataItemSupplement (header, recipe, "SKYBIAS");
    163     psMetadataItemSupplement (header, recipe, "SKYSAT");
     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");
    164214
    165215    // PSF model parameters (shape values for image center)
    166     psMetadataItemSupplement (header, recipe, "NPSFSTAR");
    167     psMetadataItemSupplement (header, recipe, "APLOSS");
    168 
    169     psMetadataItemSupplement (header, recipe, "FWHM_MAJ");
    170     psMetadataItemSupplement (header, recipe, "FW_MJ_SG");
    171     psMetadataItemSupplement (header, recipe, "FW_MJ_LQ");
    172     psMetadataItemSupplement (header, recipe, "FW_MJ_UQ");
    173 
    174     psMetadataItemSupplement (header, recipe, "FWHM_MIN");
    175     psMetadataItemSupplement (header, recipe, "FW_MN_SG");
    176     psMetadataItemSupplement (header, recipe, "FW_MN_LQ");
    177     psMetadataItemSupplement (header, recipe, "FW_MN_UQ");
    178 
    179     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");
    180230
    181231    // Image Quality measurements
    182     psMetadataItemSupplement (header, recipe, "IQ_NSTAR");
    183 
    184     psMetadataItemSupplement (header, recipe, "IQ_FW1");
    185     psMetadataItemSupplement (header, recipe, "IQ_FW1_E");
    186     psMetadataItemSupplement (header, recipe, "IQ_FW2");
    187     psMetadataItemSupplement (header, recipe, "IQ_FW2_E");
    188 
    189     psMetadataItemSupplement (header, recipe, "IQ_M2");
    190     psMetadataItemSupplement (header, recipe, "IQ_M2_ER");
    191     psMetadataItemSupplement (header, recipe, "IQ_M2_LQ");
    192     psMetadataItemSupplement (header, recipe, "IQ_M2_UQ");
    193 
    194     psMetadataItemSupplement (header, recipe, "IQ_M2C");
    195     psMetadataItemSupplement (header, recipe, "IQ_M2C_E");
    196     psMetadataItemSupplement (header, recipe, "IQ_M2C_L");
    197     psMetadataItemSupplement (header, recipe, "IQ_M2C_U");
    198 
    199     psMetadataItemSupplement (header, recipe, "IQ_M2S");
    200     psMetadataItemSupplement (header, recipe, "IQ_M2S_E");
    201     psMetadataItemSupplement (header, recipe, "IQ_M2S_L");
    202     psMetadataItemSupplement (header, recipe, "IQ_M2S_U");
    203 
    204     psMetadataItemSupplement (header, recipe, "IQ_M3");
    205     psMetadataItemSupplement (header, recipe, "IQ_M3_ER");
    206     psMetadataItemSupplement (header, recipe, "IQ_M3_LQ");
    207     psMetadataItemSupplement (header, recipe, "IQ_M3_UQ");
    208 
    209     psMetadataItemSupplement (header, recipe, "IQ_M4");
    210     psMetadataItemSupplement (header, recipe, "IQ_M4_ER");
    211     psMetadataItemSupplement (header, recipe, "IQ_M4_LQ");
    212     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");
    213263
    214264    // XXX these need to be defined from elsewhere
    215265    psMetadataAdd (header, PS_LIST_TAIL, "FSATUR",   PS_DATA_F32 | PS_META_REPLACE, "SATURATION MAG",      0.0);
    216266    psMetadataAdd (header, PS_LIST_TAIL, "FLIMIT",   PS_DATA_F32 | PS_META_REPLACE, "COMPLETENESS MAG",    0.0);
    217     psMetadataItemSupplement (header, recipe, "NSTARS");
    218 
    219     psMetadataItemSupplement (header, recipe, "NDET_EXT");
    220     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");
    221271
    222272    // sky background model statistics
    223     psMetadataItemSupplement (header, recipe, "MSKY_MN");
    224     psMetadataItemSupplement (header, recipe, "MSKY_SIG");
    225     psMetadataItemSupplement (header, recipe, "MSKY_MIN");
    226     psMetadataItemSupplement (header, recipe, "MSKY_MAX");
    227     psMetadataItemSupplement (header, recipe, "MSKY_NX");
    228     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");
    229279
    230280    psMetadataAddF32 (header, PS_LIST_TAIL, "DT_PHOT", PS_META_REPLACE, "elapsed psphot time", psTimerMark ("psphotReadout"));
    231 
    232     // XXX : don't require any of these about values to exist
    233     psErrorClear ();
    234281
    235282    return header;
     
    256303        psImageKeepCircle (source->maskObj, x, y, radius, "OR", markVal);
    257304        pmModelSub (source->pixels, source->maskObj, source->modelPSF, PM_MODEL_OP_FULL, maskVal);
    258         psImageKeepCircle (source->maskObj, x, y, radius, "AND", PS_NOT_IMAGE_MASK(markVal));
     305        psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(markVal));
    259306    }
    260307
Note: See TracChangeset for help on using the changeset viewer.