- Timestamp:
- Feb 5, 2010, 1:38:43 PM (16 years ago)
- Location:
- branches/eam_branches/20091201/psphot
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
src/psphotFindDetections.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20091201/psphot
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/eam_branches/psphot.stack.20100120 merged eligible /branches/eam_branches/20091113/psphot 26119-26255
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/eam_branches/20091201/psphot/src/psphotFindDetections.c
r26634 r26788 1 1 # include "psphotInternal.h" 2 2 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) 6 bool psphotFindDetections (pmConfig *config, const pmFPAview *view, bool firstPass) 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 = psMetadataLookupS32 (&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, firstPass)) { 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 3 27 // smooth the image, search for peaks, optionally define footprints based on the peaks 4 pmDetections *psphotFindDetections (pmDetections *detections, pmReadout *readout, psMetadata *recipe) {28 bool psphotFindDetectionsReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe, bool firstPass) { 5 29 6 30 bool status; … … 9 33 int NMAX = 0; 10 34 35 // find the currently selected readout 36 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest 37 psAssert (file, "missing file?"); 38 39 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); 40 psAssert (readout, "missing readout?"); 41 11 42 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 12 43 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels 13 assert (maskVal);44 psAssert (maskVal, "missing mask value?"); 14 45 15 46 // Use the new pmFootprints approach? 16 47 const bool useFootprints = psMetadataLookupBool(NULL, recipe, "USE_FOOTPRINTS"); 17 48 18 // 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 19 51 if (!detections) { 52 // create the container 20 53 detections = pmDetectionsAlloc(); 54 55 // save detections on the readout->analysis 56 if (!psMetadataAddPtr (readout->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_META_REPLACE | PS_DATA_UNKNOWN, "psphot detections", detections)) { 57 psError (PSPHOT_ERR_CONFIG, false, "problem saving detections on readout"); 58 return false; 59 } 60 } else { 61 psMemIncrRefCounter(detections); // so we can free the detections below 62 } 63 64 if (firstPass) { 21 65 pass = 1; 22 66 NSIGMA_PEAK = psMetadataLookupF32 (&status, recipe, "PEAKS_NSIGMA_LIMIT"); PS_ASSERT (status, NULL); … … 30 74 float threshold = PS_SQR(NSIGMA_PEAK); 31 75 32 // move the old peaks array (if it exists) to oldPeaks 33 // XXX generically, we should be able to call this function an arbitrary number of times 76 // move the old peaks array (if it exists) to oldPeaks XXX generically, we should be able 77 // to call this function an arbitrary number of times the old peaks are saved so they can 78 // be freed later -- the have to be freed after psphotFindFootprints is called below, since 79 // they are also owned by the oldFootprints, which are in turn merged into the new 80 // footprints. (what about the source->peak entry?) 81 34 82 assert (detections->oldPeaks == NULL); 35 83 detections->oldPeaks = detections->peaks; … … 51 99 // detect the peaks in the significance image 52 100 detections->peaks = psphotFindPeaks (significance, readout, recipe, threshold, NMAX); 53 psMetadataAddF32 (re cipe, PS_LIST_TAIL, "PEAK_THRESHOLD", PS_META_REPLACE, "Peak Detection Threshold", threshold);101 psMetadataAddF32 (readout->analysis, PS_LIST_TAIL, "PEAK_THRESHOLD", PS_META_REPLACE, "Peak Detection Threshold", threshold); 54 102 if (!detections->peaks) { 55 103 // we only get a NULL peaks array due to a programming or config error. … … 57 105 psFree (detections); 58 106 psError (PSPHOT_ERR_CONFIG, false, "failed on peak search"); 59 return NULL;107 return false; 60 108 } 61 109 … … 71 119 psphotVisualShowFootprints (detections); 72 120 73 return detections; 121 psFree (detections); 122 123 return true; 74 124 } 75 125 76 126 // if we use the footprints, the output peaks list contains both old and new peaks, 77 127 // otherwise it only contains the new peaks. 78 79 # if 080 // XXX where do we place the N sets of detections?81 bool psphotFindDetections (pmConfig *config, const pmFPAview *view)82 {83 bool status = true;84 85 int num = psMetadataAddS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");86 psAbort (!status, "programming error: must define PSPHOT.INPUT.NUM");87 88 // loop over the available readouts89 for (int i = 0; i < num; i++) {90 if (!psphotFindDetectionsReadout (config, view, "PSPHOT.INPUT", i)) {91 psError (PSPHOT_ERR_CONFIG, false, "failed to subtract background for PSPHOT.INPUT entry %d", i);92 return false;93 }94 }95 return true;96 }97 # endif
Note:
See TracChangeset
for help on using the changeset viewer.
