Changeset 28013 for trunk/psphot/src/psphotMergeSources.c
- Timestamp:
- May 18, 2010, 4:11:53 PM (16 years ago)
- Location:
- trunk/psphot
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
src/psphotMergeSources.c (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot
-
Property svn:mergeinfo
set to
/branches/eam_branches/psphot.20100506 merged eligible
-
Property svn:mergeinfo
set to
-
trunk/psphot/src/psphotMergeSources.c
r27657 r28013 6 6 7 7 // for now, let's store the detections on the readout->analysis for each readout 8 bool psphotMergeSources (pmConfig *config, const pmFPAview *view )8 bool psphotMergeSources (pmConfig *config, const pmFPAview *view, const char *filerule) 9 9 { 10 10 bool status = true; … … 15 15 // loop over the available readouts 16 16 for (int i = 0; i < num; i++) { 17 if (!psphotMergeSourcesReadout (config, view, "PSPHOT.INPUT", i)) {18 psError (PSPHOT_ERR_CONFIG, false, "failed to merge sources for PSPHOT.INPUT entry %d", i);17 if (!psphotMergeSourcesReadout (config, view, filerule, i)) { 18 psError (PSPHOT_ERR_CONFIG, false, "failed to merge sources for %s entry %d", filerule, i); 19 19 return false; 20 20 } … … 24 24 25 25 // add newly selected sources to the existing list of sources 26 bool psphotMergeSourcesReadout (pmConfig *config, const pmFPAview *view, const char *file name, int index) {26 bool psphotMergeSourcesReadout (pmConfig *config, const pmFPAview *view, const char *filerule, int index) { 27 27 28 28 bool status; 29 29 30 30 // find the currently selected readout 31 pmFPAfile *file = pmFPAfileSelectSingle(config->files, file name, index); // File of interest31 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filerule, index); // File of interest 32 32 psAssert (file, "missing file?"); 33 33 … … 71 71 // only expect a single entry for PSPHOT.INPUT.CMF and PSPHOT.SOURCES.TEXT, so we can only 72 72 // associate input sources with a single entry for PSPHOT.INPUT 73 bool psphotLoadExtSources (pmConfig *config, const pmFPAview *view ) {73 bool psphotLoadExtSources (pmConfig *config, const pmFPAview *view, const char *filerule) { 74 74 75 75 bool status; … … 79 79 80 80 // find the currently selected readout 81 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PSPHOT.INPUT", index); // File of interest81 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filerule, index); // File of interest 82 82 psAssert (file, "missing file?"); 83 83 … … 130 130 // load data from input TXT file: 131 131 { 132 pmChip *chipTXT = pmFPAfileThisChip (config->files, view, "PSPHOT.INPUT");132 pmChip *chipTXT = pmFPAfileThisChip (config->files, view, filerule); 133 133 if (!chipTXT) goto finish; 134 134 … … 167 167 168 168 // extract the input sources corresponding to this readout 169 // XXX this function needs to be updated to work with the new context of ps hot inputs169 // XXX this function needs to be updated to work with the new context of psphot inputs 170 170 psArray *psphotLoadPSFSources (pmConfig *config, const pmFPAview *view) { 171 171 … … 197 197 // psphotDetectionsFromSources to psphotSourceStats and are now stored on 198 198 // detections->newSources. 199 bool psphotRepairLoadedSources (pmConfig *config, const pmFPAview *view ) {200 201 // find the currently selected readout 202 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PSPHOT.INPUT", 0); // File of interest199 bool psphotRepairLoadedSources (pmConfig *config, const pmFPAview *view, const char *filerule) { 200 201 // find the currently selected readout 202 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filerule, 0); // File of interest 203 203 psAssert (file, "missing file?"); 204 204 … … 227 227 // generate the detection structure for the supplied array of sources 228 228 // XXX this currently assumes there is a single input file 229 bool psphotDetectionsFromSources (pmConfig *config, const pmFPAview *view, psArray *sources) {230 231 // find the currently selected readout 232 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PSPHOT.INPUT", 0); // File of interest229 bool psphotDetectionsFromSources (pmConfig *config, const pmFPAview *view, const char *filerule, psArray *sources) { 230 231 // find the currently selected readout 232 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filerule, 0); // File of interest 233 233 psAssert (file, "missing file?"); 234 234 … … 335 335 } 336 336 337 bool psphotCheckExtSources (pmConfig *config, const pmFPAview *view ) {337 bool psphotCheckExtSources (pmConfig *config, const pmFPAview *view, const char *filerule) { 338 338 339 339 bool status; … … 343 343 344 344 // find the currently selected readout 345 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PSPHOT.INPUT", 0); // File of interest345 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filerule, 0); // File of interest 346 346 psAssert (file, "missing file?"); 347 347 … … 373 373 374 374 // find the detections (by peak and/or footprint) in the image. 375 if (!psphotFindDetections (config, view, true)) {375 if (!psphotFindDetections (config, view, filerule, true)) { 376 376 psError(PSPHOT_ERR_CONFIG, false, "unable to find detections in this image"); 377 return psphotReadoutCleanup (config, view );377 return psphotReadoutCleanup (config, view, filerule); 378 378 } 379 379 380 380 // construct sources and measure basic stats 381 psphotSourceStats (config, view, true);381 psphotSourceStats (config, view, filerule, true); 382 382 383 383 // find blended neighbors of very saturated stars 384 psphotDeblendSatstars (config, view );384 psphotDeblendSatstars (config, view, filerule); 385 385 386 386 // mark blended peaks PS_SOURCE_BLEND 387 if (!psphotBasicDeblend (config, view )) {387 if (!psphotBasicDeblend (config, view, filerule)) { 388 388 psLogMsg ("psphot", 3, "failed on deblend analysis"); 389 return psphotReadoutCleanup (config, view );389 return psphotReadoutCleanup (config, view, filerule); 390 390 } 391 391 392 392 // classify sources based on moments, brightness 393 if (!psphotRoughClass (config, view )) {393 if (!psphotRoughClass (config, view, filerule)) { 394 394 psLogMsg ("psphot", 3, "failed to find a valid PSF clump for image"); 395 return psphotReadoutCleanup (config, view); 396 } 397 } 398 399 return true; 400 } 395 return psphotReadoutCleanup (config, view, filerule); 396 } 397 } 398 399 return true; 400 } 401 402 // copy the detections from one pmFPAfile to another 403 bool psphotCopySources (pmConfig *config, const pmFPAview *view, const char *ruleOut, const char *ruleSrc) 404 { 405 bool status = true; 406 407 int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM"); 408 psAssert (status, "programming error: must define PSPHOT.INPUT.NUM"); 409 410 // skip the chisq image because it is a duplicate of the detection version 411 int chisqNum = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.CHISQ.NUM"); 412 if (!status) chisqNum = -1; 413 414 // loop over the available readouts 415 for (int i = 0; i < num; i++) { 416 if (i == chisqNum) continue; // skip chisq image 417 if (!psphotCopySourcesReadout (config, view, ruleOut, ruleSrc, i)) { 418 psError (PSPHOT_ERR_CONFIG, false, "failed to copy sources from %s to %s entry %d", ruleSrc, ruleOut, i); 419 return false; 420 } 421 } 422 return true; 423 } 424 425 // add newly selected sources to the existing list of sources 426 bool psphotCopySourcesReadout (pmConfig *config, const pmFPAview *view, const char *ruleOut, const char *ruleSrc, int index) { 427 428 bool status; 429 430 // find the currently selected readout 431 pmFPAfile *fileSrc = pmFPAfileSelectSingle(config->files, ruleSrc, index); // File of interest 432 psAssert (fileSrc, "missing file?"); 433 434 pmReadout *readoutSrc = pmFPAviewThisReadout(view, fileSrc->fpa); 435 psAssert (readoutSrc, "missing readout?"); 436 437 pmDetections *detections = psMetadataLookupPtr (&status, readoutSrc->analysis, "PSPHOT.DETECTIONS"); 438 psAssert (detections, "missing detections?"); 439 440 // find the currently selected readout 441 pmFPAfile *fileOut = pmFPAfileSelectSingle(config->files, ruleOut, index); // File of interest 442 psAssert (fileOut, "missing file?"); 443 444 pmReadout *readoutOut = pmFPAviewThisReadout(view, fileOut->fpa); 445 psAssert (readoutOut, "missing readout?"); 446 447 // save detections on the readout->analysis 448 // XXX this replaced any existing entry; allow this operation to merge? 449 if (!psMetadataAddPtr (readoutOut->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_META_REPLACE | PS_DATA_UNKNOWN, "psphot detections", detections)) { 450 psError (PSPHOT_ERR_CONFIG, false, "problem saving detections on readout"); 451 return false; 452 } 453 454 return true; 455 } 456
Note:
See TracChangeset
for help on using the changeset viewer.
