- Timestamp:
- Jan 26, 2010, 5:10:34 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/psphot.stack.20100120/src/psphotFindDetections.c
r26643 r26688 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) 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 3 27 // 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) {28 bool psphotFindDetectionsReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe) { 5 29 6 30 bool status; … … 11 35 // find the currently selected readout 12 36 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest 13 psAssert ( readout, "missing file?");37 psAssert (file, "missing file?"); 14 38 15 39 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); 16 40 psAssert (readout, "missing readout?"); 17 18 // select the appropriate recipe information19 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE);20 psAssert (recipe, "missing recipe?");21 41 22 42 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) … … 27 47 const bool useFootprints = psMetadataLookupBool(NULL, recipe, "USE_FOOTPRINTS"); 28 48 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 30 51 if (!detections) { 52 // create the container 31 53 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 32 61 pass = 1; 33 62 NSIGMA_PEAK = psMetadataLookupF32 (&status, recipe, "PEAKS_NSIGMA_LIMIT"); PS_ASSERT (status, NULL); 34 63 NMAX = psMetadataLookupS32 (&status, recipe, "PEAKS_NMAX"); PS_ASSERT (status, NULL); 35 64 } else { 65 psMemIncrRefCounter(detections); // so we can free the detections below 36 66 pass = 2; 37 67 NSIGMA_PEAK = psMetadataLookupF32 (&status, recipe, "PEAKS_NSIGMA_LIMIT_2"); PS_ASSERT (status, NULL); … … 41 71 float threshold = PS_SQR(NSIGMA_PEAK); 42 72 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 45 79 assert (detections->oldPeaks == NULL); 46 80 detections->oldPeaks = detections->peaks; … … 68 102 psFree (detections); 69 103 psError (PSPHOT_ERR_CONFIG, false, "failed on peak search"); 70 return NULL;104 return false; 71 105 } 72 106 … … 82 116 psphotVisualShowFootprints (detections); 83 117 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); 89 119 90 120 return true; … … 94 124 // otherwise it only contains the new peaks. 95 125 96 // for now, let's store the detections on the readout->analysis for each readout97 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 readouts105 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.
