- Timestamp:
- Jan 20, 2010, 12:59:49 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/psphot.stack.20100120/src/psphotSourceStats.c
r26596 r26643 3 3 bool psphotSetMomentsWindow (psMetadata *recipe, psMetadata *analysis, psArray *sources); 4 4 5 psArray *psphotSourceStats (pmConfig *config, pmReadout *readout, pmDetections *detections, bool setWindow) {5 bool psphotSourceStatsReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, bool setWindow) { 6 6 7 7 bool status = false; … … 10 10 psTimerStart ("psphot.stats"); 11 11 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 12 22 // select the appropriate recipe information 13 23 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE); 14 assert (recipe);24 psAssert (recipe, "missing recipe?"); 15 25 16 26 // determine the number of allowed threads … … 21 31 22 32 // 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... 26 37 OUTER = PS_MAX(OUTER, 20.0); // XXX Guarantee that we can encompass the max moments radius 27 38 28 39 char *breakPt = psMetadataLookupStr (&status, recipe, "BREAK_POINT"); 29 if (!status) return NULL;40 if (!status) return false; 30 41 31 42 psArray *peaks = detections->peaks; 32 43 if (!peaks) { 33 44 psError(PS_ERR_UNEXPECTED_NULL, false, "No peaks found!"); 34 return NULL;45 return false; 35 46 } 36 47 … … 64 75 psLogMsg ("psphot", PS_LOG_INFO, "break point PEAKS, skipping MOMENTS\n"); 65 76 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; 67 85 } 68 86 … … 70 88 if (!psphotSetMomentsWindow(recipe, readout->analysis, sources)) { 71 89 psError(PS_ERR_UNEXPECTED_NULL, false, "Failed to determine Moments Window!"); 72 return NULL; 90 psFree(sources); 91 return false; 73 92 } 74 93 } … … 103 122 psError(PS_ERR_UNKNOWN, false, "Unable to launch thread job PSPHOT_SOURCE_STATS"); 104 123 psFree (job); 105 return NULL; 124 psFree(sources); 125 return false; 106 126 } 107 127 psFree(job); … … 111 131 if (!psThreadPoolWait (false)) { 112 132 psError(PS_ERR_UNKNOWN, false, "Failure in thread job PSPHOT_SOURCE_STATS"); 113 return NULL; 133 psFree(sources); 134 return false; 114 135 } 115 136 … … 138 159 psphotVisualShowMoments (sources); 139 160 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; 141 169 } 142 170 171 // XXX fix the return status of this function... 143 172 bool psphotSourceStatsUpdate (psArray *sources, pmConfig *config, pmReadout *readout) { 144 173 … … 451 480 return true; 452 481 } 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 488 bool 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.
