- Timestamp:
- Feb 5, 2010, 3:11:11 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20091201/psphot/src/psphotMergeSources.c
r26788 r26793 15 15 // loop over the available readouts 16 16 for (int i = 0; i < num; i++) { 17 if (!psphotMergeSourcesReadout (config, view, "PSPHOT.INPUT", i)) {17 if (!psphotMergeSourcesReadout (config, view, "PSPHOT.INPUT", i)) { 18 18 psError (PSPHOT_ERR_CONFIG, false, "failed to merge sources for PSPHOT.INPUT entry %d", i); 19 return false;20 }19 return false; 20 } 21 21 } 22 22 return true; … … 43 43 // XXX TEST: 44 44 if (detections->allSources) { 45 psphotMaskCosmicRayFootprintCheck(detections->allSources);45 psphotMaskCosmicRayFootprintCheck(detections->allSources); 46 46 } 47 47 if (detections->newSources) { 48 psphotMaskCosmicRayFootprintCheck(detections->newSources);48 psphotMaskCosmicRayFootprintCheck(detections->newSources); 49 49 } 50 50 51 51 if (!detections->allSources) { 52 detections->allSources = psArrayAllocEmpty(newSources->n);52 detections->allSources = psArrayAllocEmpty(newSources->n); 53 53 } 54 54 psArray *allSources = detections->allSources; … … 87 87 psAssert (detections, "missing detections?"); 88 88 89 // XXX allSources o fnewSources?89 // XXX allSources or newSources? 90 90 psArray *sources = detections->allSources; 91 91 psAssert (sources, "missing sources?"); … … 96 96 if (!readoutCMF) goto loadTXT; 97 97 98 extCMF = psMetadataLookupPtr (NULL, readoutCMF->analysis, "PSPHOT.DETECTIONS");99 if (extCMF) {100 for (int i = 0; i < extCMF->allSources->n; i++) {101 pmSource *source = extCMF->allSources->data[i];102 source->mode |= PM_SOURCE_MODE_EXTERNAL;98 extCMF = psMetadataLookupPtr (NULL, readoutCMF->analysis, "PSPHOT.DETECTIONS"); 99 if (extCMF) { 100 for (int i = 0; i < extCMF->allSources->n; i++) { 101 pmSource *source = extCMF->allSources->data[i]; 102 source->mode |= PM_SOURCE_MODE_EXTERNAL; 103 103 104 104 // the supplied peak flux needs to be re-normalized … … 106 106 source->peak->value = 1.0; 107 107 108 // drop the loaded source modelPSF109 psFree (source->modelPSF);110 source->modelPSF = NULL;111 112 psArrayAdd (detections->allSources, 100, source);113 }114 }108 // drop the loaded source modelPSF 109 psFree (source->modelPSF); 110 source->modelPSF = NULL; 111 112 psArrayAdd (detections->allSources, 100, source); 113 } 114 } 115 115 } 116 116 … … 128 128 source->mode |= PM_SOURCE_MODE_EXTERNAL; 129 129 130 // drop the loaded source modelPSF131 psFree (source->modelPSF);132 source->modelPSF = NULL;133 134 psArrayAdd (detections->allSources, 100, source);135 }136 }130 // drop the loaded source modelPSF 131 psFree (source->modelPSF); 132 source->modelPSF = NULL; 133 134 psArrayAdd (detections->allSources, 100, source); 135 } 136 } 137 137 } 138 138 … … 168 168 if (!detections) { 169 169 psLogMsg ("psphot", 3, "no psf sources for this readout"); 170 return NULL;170 return NULL; 171 171 } 172 172 … … 174 174 if (!sources) { 175 175 psLogMsg ("psphot", 3, "no psf sources for this readout"); 176 return NULL;176 return NULL; 177 177 } 178 178 … … 212 212 213 213 // generate the detection structure for the supplied array of sources 214 // XXX this currently assumes there is a single input file 214 // XXX this currently assumes there is a single input file 215 215 bool psphotDetectionsFromSources (pmConfig *config, const pmFPAview *view, psArray *sources) { 216 216 … … 274 274 // save detections on the readout->analysis 275 275 if (!psMetadataAddPtr (readout->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_META_REPLACE | PS_DATA_UNKNOWN, "psphot detectinos", detections)) { 276 psError (PSPHOT_ERR_CONFIG, false, "problem saving detections on readout");277 return false;276 psError (PSPHOT_ERR_CONFIG, false, "problem saving detections on readout"); 277 return false; 278 278 } 279 279 psFree (detections); … … 343 343 344 344 if (sources->n) { 345 // the user wants to make the psf from these stars; define them as psf stars:346 for (int i = 0; i < sources->n; i++) {347 pmSource *source = sources->data[i];348 source->mode |= PM_SOURCE_MODE_PSFSTAR;349 }350 // force psphotChoosePSF to use all loaded sources351 psMetadataAddS32 (recipe, PS_LIST_TAIL, "PSF_MAX_NSTARS", PS_META_REPLACE, "max number of sources for PSF model", sources->n);352 353 // measure stats of externally specified sources354 if (!psphotSourceStatsUpdate (sources, config, readout)) {355 psError(PSPHOT_ERR_CONFIG, false, "failure to measure stats of existing sources");356 return false;357 }345 // the user wants to make the psf from these stars; define them as psf stars: 346 for (int i = 0; i < sources->n; i++) { 347 pmSource *source = sources->data[i]; 348 source->mode |= PM_SOURCE_MODE_PSFSTAR; 349 } 350 // force psphotChoosePSF to use all loaded sources 351 psMetadataAddS32 (recipe, PS_LIST_TAIL, "PSF_MAX_NSTARS", PS_META_REPLACE, "max number of sources for PSF model", sources->n); 352 353 // measure stats of externally specified sources 354 if (!psphotSourceStatsUpdate (sources, config, readout)) { 355 psError(PSPHOT_ERR_CONFIG, false, "failure to measure stats of existing sources"); 356 return false; 357 } 358 358 } else { 359 359 360 // find the detections (by peak and/or footprint) in the image.361 if (!psphotFindDetections (config, view, true)) {362 psError(PSPHOT_ERR_CONFIG, false, "unable to find detections in this image");363 return psphotReadoutCleanup (config, view);364 }365 366 // construct sources and measure basic stats367 psphotSourceStats (config, view, true);368 369 // find blended neighbors of very saturated stars370 psphotDeblendSatstars (config, view);371 372 // mark blended peaks PS_SOURCE_BLEND373 if (!psphotBasicDeblend (config, view)) {374 psLogMsg ("psphot", 3, "failed on deblend analysis");375 return psphotReadoutCleanup (config, view);376 }377 378 // classify sources based on moments, brightness379 if (!psphotRoughClass (config, view)) {380 psLogMsg ("psphot", 3, "failed to find a valid PSF clump for image");381 return psphotReadoutCleanup (config, view);382 }383 } 384 385 return true; 386 } 360 // find the detections (by peak and/or footprint) in the image. 361 if (!psphotFindDetections (config, view, true)) { 362 psError(PSPHOT_ERR_CONFIG, false, "unable to find detections in this image"); 363 return psphotReadoutCleanup (config, view); 364 } 365 366 // construct sources and measure basic stats 367 psphotSourceStats (config, view, true); 368 369 // find blended neighbors of very saturated stars 370 psphotDeblendSatstars (config, view); 371 372 // mark blended peaks PS_SOURCE_BLEND 373 if (!psphotBasicDeblend (config, view)) { 374 psLogMsg ("psphot", 3, "failed on deblend analysis"); 375 return psphotReadoutCleanup (config, view); 376 } 377 378 // classify sources based on moments, brightness 379 if (!psphotRoughClass (config, view)) { 380 psLogMsg ("psphot", 3, "failed to find a valid PSF clump for image"); 381 return psphotReadoutCleanup (config, view); 382 } 383 } 384 385 return true; 386 }
Note:
See TracChangeset
for help on using the changeset viewer.
