IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 20, 2010, 12:59:49 PM (17 years ago)
Author:
eugene
Message:

updating code so more functions can handle the multi-input concept

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/psphot.stack.20100120/src/psphotSourceStats.c

    r26596 r26643  
    33bool psphotSetMomentsWindow (psMetadata *recipe, psMetadata *analysis, psArray *sources);
    44
    5 psArray *psphotSourceStats (pmConfig *config, pmReadout *readout, pmDetections *detections, bool setWindow) {
     5bool psphotSourceStatsReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, bool setWindow) {
    66
    77    bool status = false;
     
    1010    psTimerStart ("psphot.stats");
    1111
     12    // find the currently selected readout
     13    pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest
     14    psAssert (readout, "missing file?");
     15
     16    pmReadout *readout = pmFPAviewThisReadout(view, file->fpa);
     17    psAssert (readout, "missing readout?");
     18
     19    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
     20    psAssert (detections, "missing detections?");
     21
    1222    // select the appropriate recipe information
    1323    psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE);
    14     assert (recipe);
     24    psAssert (recipe, "missing recipe?");
    1525
    1626    // determine the number of allowed threads
     
    2131
    2232    // determine properties (sky, moments) of initial sources
    23     float OUTER    = psMetadataLookupF32 (&status, recipe, "SKY_OUTER_RADIUS");
    24     if (!status) return NULL;
    25 
     33    float OUTER = psMetadataLookupF32 (&status, recipe, "SKY_OUTER_RADIUS");
     34    psAssert (status, "missing SKY_OUTER_RADIUS in recipe?");
     35
     36    // XXX this seems like an arbitrary number...
    2637    OUTER = PS_MAX(OUTER, 20.0); // XXX Guarantee that we can encompass the max moments radius
    2738
    2839    char *breakPt  = psMetadataLookupStr (&status, recipe, "BREAK_POINT");
    29     if (!status) return NULL;
     40    if (!status) return false;
    3041
    3142    psArray *peaks = detections->peaks;
    3243    if (!peaks) {
    3344        psError(PS_ERR_UNEXPECTED_NULL, false, "No peaks found!");
    34         return NULL;
     45        return false;
    3546    }
    3647
     
    6475        psLogMsg ("psphot", PS_LOG_INFO, "break point PEAKS, skipping MOMENTS\n");
    6576        psphotVisualShowMoments (sources);
    66         return sources;
     77        // save sources on the readout->analysis
     78        if (!psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY, "psphot sources", sources)) {
     79            psError (PSPHOT_ERR_UNKNOWN, false, "problem saving sources on readout");
     80            psFree(sources);
     81            return false;
     82        }
     83        psFree(sources);
     84        return true;
    6785    }
    6886
     
    7088        if (!psphotSetMomentsWindow(recipe, readout->analysis, sources)) {
    7189            psError(PS_ERR_UNEXPECTED_NULL, false, "Failed to determine Moments Window!");
    72             return NULL;
     90            psFree(sources);
     91            return false;
    7392        }
    7493    }
     
    103122                psError(PS_ERR_UNKNOWN, false, "Unable to launch thread job PSPHOT_SOURCE_STATS");
    104123                psFree (job);
    105                 return NULL;
     124                psFree(sources);
     125                return false;
    106126            }
    107127            psFree(job);
     
    111131        if (!psThreadPoolWait (false)) {
    112132            psError(PS_ERR_UNKNOWN, false, "Failure in thread job PSPHOT_SOURCE_STATS");
    113             return NULL;
     133            psFree(sources);
     134            return false;
    114135        }
    115136
     
    138159    psphotVisualShowMoments (sources);
    139160
    140     return (sources);
     161    // save sources on the readout->analysis
     162    if (!psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY, "psphot sources", sources)) {
     163        psError (PSPHOT_ERR_UNKNOWN, false, "problem saving sources on readout");
     164        psFree(sources);
     165        return false;
     166    }
     167    psFree(sources);
     168    return true;
    141169}
    142170
     171// XXX fix the return status of this function...
    143172bool psphotSourceStatsUpdate (psArray *sources, pmConfig *config, pmReadout *readout) {
    144173
     
    451480    return true;
    452481}
     482
     483
     484// if we use the footprints, the output peaks list contains both old and new peaks,
     485// otherwise it only contains the new peaks.
     486
     487// for now, let's store the detections on the readout->analysis for each readout
     488bool psphotSourceStats (pmConfig *config, const pmFPAview *view, bool setWindow)
     489{
     490    bool status = true;
     491
     492    int num = psMetadataAddS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
     493    psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     494
     495    // loop over the available readouts
     496    for (int i = 0; i < num; i++) {
     497        if (!psphotFindDetectionsReadout (config, view, "PSPHOT.INPUT", i, setWindow)) {
     498            psError (PSPHOT_ERR_CONFIG, false, "failed to find initial detections for PSPHOT.INPUT entry %d", i);
     499            return false;
     500        }
     501    }
     502    return true;
     503}
Note: See TracChangeset for help on using the changeset viewer.