Changeset 32686
- Timestamp:
- Nov 17, 2011, 6:47:47 AM (15 years ago)
- Location:
- branches/eam_branches/ipp-20111110/psphot/src
- Files:
-
- 2 edited
-
psphotMergeSources.c (modified) (9 diffs)
-
psphotStackReadout.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20111110/psphot/src/psphotMergeSources.c
r31452 r32686 520 520 } 521 521 522 // create source parents children from ruleSrc for ruleOut for orphans 523 bool psphotSourceParent (pmConfig *config, const pmFPAview *view, const char *ruleOut, const char *ruleSrc) 524 { 525 bool status = true; 526 527 int num = psphotFileruleCount(config, ruleSrc); 528 529 // skip the chisq image because it is a duplicate of the detection version 530 int chisqNum = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.CHISQ.NUM"); 531 if (!status) chisqNum = -1; 532 533 // loop over the available readouts 534 for (int i = 0; i < num; i++) { 535 if (i == chisqNum) continue; // skip chisq image 536 if (!psphotSourceParentReadout (config, view, ruleOut, ruleSrc, i)) { 537 psError (PSPHOT_ERR_CONFIG, false, "failed to copy sources from %s to %s entry %d", ruleSrc, ruleOut, i); 538 return false; 539 } 540 } 541 return true; 542 } 543 544 // create source parents from ruleSrc for ruleOut for orphaned children for this readout. XXX currently, this is only 545 // used by psphotStackReadout (sources go on allSources so that psphotChoosePSF can be called 546 // repeatedly) 547 548 // XXX this function will do bad things if called repeatedly. It needs to either (1) delete 549 // the existing DETECTION container on the output images, or (2) intelligently supplement the 550 // existing DETECTION container with only the new detections. 551 bool psphotSourceParentReadout (pmConfig *config, const pmFPAview *view, const char *ruleOut, const char *ruleSrc, int index) { 552 553 bool status; 554 555 // find the currently selected readout 556 pmFPAfile *fileSrc = pmFPAfileSelectSingle(config->files, ruleSrc, index); // File of interest 557 psAssert (fileSrc, "missing file?"); 558 559 pmReadout *readoutSrc = pmFPAviewThisReadout(view, fileSrc->fpa); 560 psAssert (readoutSrc, "missing readout?"); 561 562 pmDetections *detectionsSrc = psMetadataLookupPtr (&status, readoutSrc->analysis, "PSPHOT.DETECTIONS"); 563 psAssert (detectionsSrc, "missing detections?"); 564 565 psArray *sourcesSrc = detectionsSrc->allSources; 566 psAssert (sourcesSrc, "missing sources?"); 567 568 // find the currently selected readout 569 pmFPAfile *fileOut = pmFPAfileSelectSingle(config->files, ruleOut, index); // File of interest 570 psAssert (fileOut, "missing file?"); 571 572 pmReadout *readoutOut = pmFPAviewThisReadout(view, fileOut->fpa); 573 psAssert (readoutOut, "missing readout?"); 574 575 // generate a new detection structure for the output filerule 576 pmDetections *detectionsOut = psMetadataLookupPtr (&status, readoutOut->analysis, "PSPHOT.DETECTIONS"); 577 psAssert (detectionsOut, "missing PSPHOT.DETECTIONS?"); 578 579 // loop over the sources, redefine their pixels to point at the new filerule image, 580 // copy the source data, and add a reference back to the original source 581 582 // copy the sources from sourceSrcs to the new detection structure 583 for (int i = 0; i < sourcesSrc->n; i++) { 584 pmSource *sourceSrc = sourcesSrc->data[i]; 585 if (sourceSrc->parent) continue; // I am not an orphan 586 587 pmSource *sourceOut = pmSourceCopy(sourceSrc); 588 sourceOut->parent = sourceSrc; 589 590 // keep the original source flags 591 sourceOut->seq = sourceSrc->seq; 592 sourceOut->type = sourceSrc->type; 593 sourceOut->mode = sourceSrc->mode; 594 sourceOut->mode2 = sourceSrc->mode2; 595 sourceOut->tmpFlags = sourceSrc->tmpFlags; 596 597 // does this copy all model data? (NO) 598 sourceOut->modelPSF = pmModelCopy(sourceSrc->modelPSF); 599 sourceOut->modelEXT = pmModelCopy(sourceSrc->modelEXT); 600 601 if (sourceSrc->modelFits) { 602 sourceOut->modelFits = psArrayAlloc(sourceSrc->modelFits->n); 603 for (int j = 0; j < sourceSrc->modelFits->n; j++) { 604 sourceOut->modelFits->data[j] = pmModelCopy(sourceSrc->modelFits->data[j]); 605 } 606 } 607 608 // drop the references to the original image pixels: 609 pmSourceFreePixels (sourceOut); 610 611 // XXX do we need to skip the Chisq image sources? 612 613 // allocate image, weight, mask for the new image for each peak 614 if (sourceOut->modelPSF) { 615 pmSourceRedefinePixels (sourceOut, readoutOut, sourceOut->peak->x, sourceOut->peak->y, sourceOut->modelPSF->fitRadius); 616 } 617 618 // child sources have not been subtracted in this image, but this flag may be raised if 619 // they were subtracted in the parent's image 620 sourceOut->tmpFlags &= ~PM_SOURCE_TMPF_SUBTRACTED; 621 622 psArrayAdd (detectionsOut->allSources, 100, sourceOut); 623 psFree (sourceOut); 624 } 625 psLogMsg ("psphot", 3, "%ld known sources supplied", detectionsOut->allSources->n); 626 627 628 return true; 629 } 630 522 631 // create source children from ruleSrc for ruleOut 523 632 bool psphotSourceChildren (pmConfig *config, const pmFPAview *view, const char *ruleOut, const char *ruleSrc) … … 545 654 // used by psphotStackReadout (sources go on allSources so that psphotChoosePSF can be called 546 655 // repeatedly) 656 657 // XXX this function will do bad things if called repeatedly. It needs to either (1) delete 658 // the existing DETECTION container on the output images, or (2) intelligently supplement the 659 // existing DETECTION container with only the new detections. 547 660 bool psphotSourceChildrenReadout (pmConfig *config, const pmFPAview *view, const char *ruleOut, const char *ruleSrc, int index) { 548 661 … … 593 706 594 707 // keep the original source flags 708 sourceOut->seq = sourceSrc->seq; 595 709 sourceOut->type = sourceSrc->type; 596 710 sourceOut->mode = sourceSrc->mode; … … 612 726 pmSourceFreePixels (sourceOut); 613 727 728 // XXX do we need to skip the Chisq image sources? 729 614 730 // allocate image, weight, mask for the new image for each peak 615 731 if (sourceOut->modelPSF) { … … 630 746 } 631 747 632 // create source children associated with 'filerule' from the objectsSrc. XXX currently, this633 // is only used by psphotStackReadout (sources go on allSources so that psphotChoosePSF can be634 // called repeatedly)748 // create source children associated with 'filerule' from the objectsSrc. returns a new object 749 // array containing the child sources. XXX currently, this is only used by psphotStackReadout 750 // (sources go on allSources so that psphotChoosePSF can be called repeatedly) 635 751 psArray *psphotSourceChildrenByObject (pmConfig *config, const pmFPAview *view, const char *filerule, psArray *objectsSrc) { 636 752 … … 652 768 psAssert (readout, "missing readout?"); 653 769 770 // create DETECTIONS containers for each image, in case one lacks it 654 771 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); 655 772 if (!detections) { … … 665 782 psAssert (detections, "missing detections?"); 666 783 } 784 785 // we need to save the new sources on the detection arrays of the appropriate image 667 786 detArrays->data[i] = psMemIncrRefCounter(detections); 668 787 readouts->data[i] = psMemIncrRefCounter(readout); … … 695 814 696 815 pmSource *sourceOut = pmSourceCopy(sourceSrc); 816 sourceOut->parent = sourceSrc; 817 818 // save on the output object array at the same location 697 819 objectOut->sources->data[i] = sourceOut; 698 699 sourceOut->parent = sourceSrc;700 820 701 821 // keep the original source flags and sequence ID (if set) … … 720 840 pmSourceFreePixels (sourceOut); 721 841 722 // set the output reado tu842 // set the output readout 723 843 int index = sourceOut->imageID; 724 844 if (index >= readouts->n) continue; // skip the sources generated by the chisq image -
branches/eam_branches/ipp-20111110/psphot/src/psphotStackReadout.c
r32685 r32686 115 115 } 116 116 117 // if DET and SRC are different images, copy the detections from DET to SRC 117 // If DET and SRC are different images, copy the detections from DET to SRC. This 'copy' 118 // is just a copy of the container pointer; the sources on both DET and SRC are the same 119 // memory objects 118 120 if (strcmp(STACK_SRC, STACK_DET)) { 119 121 if (!psphotCopySources (config, view, STACK_SRC, STACK_DET)) { … … 197 199 // linear fit to include all sources (subtract again) 198 200 // NOTE : apply to ALL sources (extended + psf) 199 // NOTE 2 : this function subtracts the models from the given filerule (SRC) 201 // NOTE 2 : this function subtracts the models from the given filerule (SRC), not DET 200 202 psphotFitSourcesLinear (config, view, STACK_SRC, true); // pass 2 (detections->allSources) 201 203 … … 204 206 // NOTE: this block performs the 2nd pass low-significance PSF detection stage 205 207 { 208 // XXX the steps below to subtract the sources from DET should be skipped if SRC == DET! 209 210 // generate children sources for all sources in the SRC image 211 // XXX (DROP existing detections list) 212 psphotSourceChildren (config, view, STACK_DET, STACK_SRC); 213 206 214 // subtract all sources from DET (this will subtract using the psf model for SRC, which 207 215 // will somewhat oversubtract the sources -- this is OK 216 // *** this fails because the source->pixels are still pointing at SRC, not DET 208 217 psphotRemoveAllSources (config, view, STACK_DET, true); // ignore subtraction state for sources 209 218 … … 222 231 // (this operation just ensures the metadata container has a view on SRC as well 223 232 if (strcmp(STACK_SRC, STACK_DET)) { 224 if (!psphotCopySources (config, view, STACK_SRC, STACK_DET)) { 233 // XXX this operation now needs to create source parents for the new detections 234 // XXX if (!psphotCopySources (config, view, STACK_SRC, STACK_DET)) { 235 // XXX psError (PSPHOT_ERR_UNKNOWN, false, "failure in peak analysis"); 236 // XXX return psphotReadoutCleanup (config, view, STACK_SRC); 237 // XXX } 238 239 // the old detection here are children of SRC; generate parents for the new detections 240 if (!psphotSourceParents (config, view, STACK_SRC, STACK_DET)) { 225 241 psError (PSPHOT_ERR_UNKNOWN, false, "failure in peak analysis"); 226 242 return psphotReadoutCleanup (config, view, STACK_SRC);
Note:
See TracChangeset
for help on using the changeset viewer.
