IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 5, 2010, 1:38:43 PM (16 years ago)
Author:
eugene
Message:

updates to psphot APIs to enable stack photometry

Location:
branches/eam_branches/20091201/psphot
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20091201/psphot

  • branches/eam_branches/20091201/psphot/src/psphotReplaceUnfit.c

    r25755 r26788  
    2222}
    2323
    24 bool psphotReplaceAllSources (psArray *sources, psMetadata *recipe) {
     24// for now, let's store the detections on the readout->analysis for each readout
     25bool psphotReplaceAllSources (pmConfig *config, const pmFPAview *view)
     26{
     27    bool status = true;
     28
     29    // select the appropriate recipe information
     30    psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE);
     31    psAssert (recipe, "missing recipe?");
     32
     33    int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
     34    psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     35
     36    // loop over the available readouts
     37    for (int i = 0; i < num; i++) {
     38        if (!psphotReplaceAllSourcesReadout (config, view, "PSPHOT.INPUT", i, recipe)) {
     39            psError (PSPHOT_ERR_CONFIG, false, "failed to replace all sources for PSPHOT.INPUT entry %d", i);
     40            return false;
     41        }
     42    }
     43    return true;
     44}
     45
     46bool psphotReplaceAllSourcesReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe) {
    2547
    2648    bool status;
     
    2951    psTimerStart ("psphot.replace");
    3052
     53    // find the currently selected readout
     54    pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest
     55    psAssert (file, "missing file?");
     56
     57    pmReadout *readout = pmFPAviewThisReadout(view, file->fpa);
     58    psAssert (readout, "missing readout?");
     59
     60    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
     61    psAssert (detections, "missing detections?");
     62
     63    psArray *sources = detections->allSources;
     64    psAssert (sources, "missing sources?");
     65
    3166    // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    3267    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
    33     assert (maskVal);
     68    psAssert (maskVal, "missing mask value?");
    3469
    3570    for (int i = 0; i < sources->n; i++) {
     
    67102    return true;
    68103}
    69 
    70 # if (0)
    71 // add source, if the source has been subtracted; do not modify state
    72 bool psphotAddWithTest (pmSource *source, bool useState, psImageMaskType maskVal) {
    73 
    74     // what is current state? (true : add; false : sub)
    75     bool state = !(source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED);
    76     if (state && useState) return true;
    77 
    78     pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal);
    79     return true;
    80 }
    81 
    82 // sub source, if the source has been added; do not modify state
    83 bool psphotSubWithTest (pmSource *source, bool useState, psImageMaskType maskVal) {
    84 
    85     // what is current state? (true : sub; false : add)
    86     bool state = (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED);
    87     if (state && useState) return true;
    88 
    89     pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);
    90     return true;
    91 }
    92 
    93 // add or sub source to match recorded state: supply current state as true (add) or false (sub)
    94 bool psphotSetState (pmSource *source, bool curState, psImageMaskType maskVal) {
    95 
    96     // what is desired state? (true : add; false : sub)
    97     bool newState = !(source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED);
    98     if (curState == newState) return true;
    99 
    100     if (curState && !newState) {
    101         pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);
    102     }
    103     if (newState && !curState) {
    104         pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal);
    105     }
    106     return true;
    107 }
    108 # endif
Note: See TracChangeset for help on using the changeset viewer.