IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 26, 2010, 5:10:34 PM (16 years ago)
Author:
eugene
Message:

various API fixes for multi-inputs

File:
1 edited

Legend:

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

    r26643 r26688  
    11# include "psphotInternal.h"
    22
     3// we store the detections on the readout->analysis for each readout this function finds new
     4// peaks and new footprints.  any old peaks are saved on oldPeaks.  the resulting footprint set
     5// contains all footprints (old and new)
     6bool psphotFindDetections (pmConfig *config, const pmFPAview *view)
     7{
     8    bool status = true;
     9
     10    // select the appropriate recipe information
     11    psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE);
     12    psAssert (recipe, "missing recipe?");
     13
     14    int num = psMetadataAddS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
     15    psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     16
     17    // loop over the available readouts
     18    for (int i = 0; i < num; i++) {
     19        if (!psphotFindDetectionsReadout (config, view, "PSPHOT.INPUT", i, recipe)) {
     20            psError (PSPHOT_ERR_CONFIG, false, "failed to find initial detections for PSPHOT.INPUT entry %d", i);
     21            return false;
     22        }
     23    }
     24    return true;
     25}
     26
    327// smooth the image, search for peaks, optionally define footprints based on the peaks
    4 bool psphotFindDetections (pmConfig *config, const pmFPAview *view, const char *filename, int index) {
     28bool psphotFindDetectionsReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe) {
    529
    630    bool status;
     
    1135    // find the currently selected readout
    1236    pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest
    13     psAssert (readout, "missing file?");
     37    psAssert (file, "missing file?");
    1438
    1539    pmReadout *readout = pmFPAviewThisReadout(view, file->fpa);
    1640    psAssert (readout, "missing readout?");
    17 
    18     // select the appropriate recipe information
    19     psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE);
    20     psAssert (recipe, "missing recipe?");
    2141
    2242    // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
     
    2747    const bool useFootprints = psMetadataLookupBool(NULL, recipe, "USE_FOOTPRINTS");
    2848
    29     // on first pass, detections have not yet been allocated
     49    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
     50    // on the initial pass, detections have not yet been allocated or saved on readout->analysis
    3051    if (!detections) {
     52        // create the container
    3153        detections = pmDetectionsAlloc();
     54       
     55        // save detections on the readout->analysis
     56        if (!psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_DATA_PTR, "psphot detectinos", detections)) {
     57            psError (PSPHOT_ERR_CONFIG, false, "problem saving detections on readout");
     58            return false;
     59        }
     60
    3261        pass = 1;
    3362        NSIGMA_PEAK = psMetadataLookupF32 (&status, recipe, "PEAKS_NSIGMA_LIMIT"); PS_ASSERT (status, NULL);
    3463        NMAX = psMetadataLookupS32 (&status, recipe, "PEAKS_NMAX"); PS_ASSERT (status, NULL);
    3564    } else {
     65        psMemIncrRefCounter(detections); // so we can free the detections below
    3666        pass = 2;
    3767        NSIGMA_PEAK = psMetadataLookupF32 (&status, recipe, "PEAKS_NSIGMA_LIMIT_2"); PS_ASSERT (status, NULL);
     
    4171    float threshold = PS_SQR(NSIGMA_PEAK);
    4272
    43     // move the old peaks array (if it exists) to oldPeaks
    44     // XXX generically, we should be able to call this function an arbitrary number of times
     73    // move the old peaks array (if it exists) to oldPeaks XXX generically, we should be able
     74    // to call this function an arbitrary number of times the old peaks are saved so they can
     75    // be freed later -- the have to be freed after psphotFindFootprints is called below, since
     76    // they are also owned by the oldFootprints, which are in turn merged into the new
     77    // footprints.  (what about the source->peak entry?)
     78   
    4579    assert (detections->oldPeaks == NULL);
    4680    detections->oldPeaks = detections->peaks;
     
    68102        psFree (detections);
    69103        psError (PSPHOT_ERR_CONFIG, false, "failed on peak search");
    70         return NULL;
     104        return false;
    71105    }
    72106
     
    82116    psphotVisualShowFootprints (detections);
    83117
    84     // save detections on the readout->analysis
    85     if (!psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_DATA_PTR, "psphot detectinos", detections)) {
    86         psError (PSPHOT_ERR_CONFIG, false, "problem saving detections on readout");
    87         return NULL;
    88     }
     118    psFree (detections);
    89119
    90120    return true;
     
    94124// otherwise it only contains the new peaks.
    95125
    96 // for now, let's store the detections on the readout->analysis for each readout
    97 bool psphotFindDetections (pmConfig *config, const pmFPAview *view)
    98 {
    99     bool status = true;
    100 
    101     int num = psMetadataAddS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
    102     psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
    103 
    104     // loop over the available readouts
    105     for (int i = 0; i < num; i++) {
    106         if (!psphotFindDetectionsReadout (config, view, "PSPHOT.INPUT", i)) {
    107             psError (PSPHOT_ERR_CONFIG, false, "failed to find initial detections for PSPHOT.INPUT entry %d", i);
    108             return false;
    109         }
    110     }
    111     return true;
    112 }
Note: See TracChangeset for help on using the changeset viewer.