Changeset 32689
- Timestamp:
- Nov 17, 2011, 1:09:10 PM (15 years ago)
- Location:
- branches/eam_branches/ipp-20111110/psphot/src
- Files:
-
- 9 edited
-
psphot.h (modified) (1 diff)
-
psphotBlendFit.c (modified) (1 diff)
-
psphotFitSourcesLinear.c (modified) (1 diff)
-
psphotMergeSources.c (modified) (10 diffs)
-
psphotOutput.c (modified) (2 diffs)
-
psphotReadout.c (modified) (5 diffs)
-
psphotReplaceUnfit.c (modified) (4 diffs)
-
psphotSourceFits.c (modified) (1 diff)
-
psphotStackReadout.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20111110/psphot/src/psphot.h
r32685 r32689 455 455 psArray *psphotSourceChildrenByObject (pmConfig *config, const pmFPAview *view, const char *filerule, psArray *objectsSrc); 456 456 457 bool psphotSourceParents (pmConfig *config, const pmFPAview *view, const char *ruleOut, const char *ruleSrc); 458 bool psphotSourceParentsReadout (pmConfig *config, const pmFPAview *view, const char *ruleOut, const char *ruleSrc, int index); 459 460 bool psphotCopyPeaks (pmConfig *config, const pmFPAview *view, const char *ruleOut, const char *ruleSrc); 461 bool psphotCopyPeaksReadout (pmConfig *config, const pmFPAview *view, const char *ruleOut, const char *ruleSrc, int index); 462 457 463 bool psphotSersicModelClassGuessPCM (pmPCMdata *pcm, pmSource *source); 458 464 void psphotSersicModelClassInit (); -
branches/eam_branches/ipp-20111110/psphot/src/psphotBlendFit.c
r32348 r32689 236 236 pmSource *source = sources->data[i]; 237 237 238 # define TEST_X -420.0 239 # define TEST_Y 300.0 238 # if (0) 239 # define TEST_X 34 240 # define TEST_Y 28 240 241 241 242 if ((fabs(source->peak->xf - TEST_X) < 5) && (fabs(source->peak->yf - TEST_Y) < 5)) { 242 fprintf (stderr, "test galaxy\n");243 fprintf (stderr, "test object\n"); 243 244 } 244 245 245 246 # undef TEST_X 246 247 # undef TEST_Y 248 # endif 247 249 248 250 // skip non-astronomical objects (very likely defects) -
branches/eam_branches/ipp-20111110/psphot/src/psphotFitSourcesLinear.c
r32633 r32689 342 342 psLogMsg ("psphot.ensemble", PS_LOG_MINUTIA, "solve matrix: %f sec (%d elements)\n", psTimerMark ("psphot.linear"), sparse->Nelem); 343 343 344 // XXXX **** philosophical question: 345 // we measure bright objects in three passes: 1) linear fit; 2) non-linear fit; 3) linear fit: 346 // should retain the chisq and errors from the intermediate non-linear fit? 347 // the non-linear fit provides better values for the position errors, and for 348 // extended sources, the shape errors 344 // Philosophical question: we measure bright objects in three passes: 1) linear fit; 2) 345 // non-linear fit; 3) linear fit: should we retain the chisq and errors from the 346 // intermediate non-linear fit? the non-linear fit provides better values for the position 347 // errors, and for extended sources, the shape errors 349 348 350 349 // adjust I0 for fitSources and subtract -
branches/eam_branches/ipp-20111110/psphot/src/psphotMergeSources.c
r32686 r32689 520 520 } 521 521 522 // c reate source parents children from ruleSrc for ruleOut for orphans523 bool psphot SourceParent(pmConfig *config, const pmFPAview *view, const char *ruleOut, const char *ruleSrc)522 // copy the newPeaks from the detections of one pmFPAfile to another 523 bool psphotCopyPeaks (pmConfig *config, const pmFPAview *view, const char *ruleOut, const char *ruleSrc) 524 524 { 525 525 bool status = true; … … 534 534 for (int i = 0; i < num; i++) { 535 535 if (i == chisqNum) continue; // skip chisq image 536 if (!psphotSourceParentReadout (config, view, ruleOut, ruleSrc, i)) { 536 if (!psphotCopyPeaksReadout (config, view, ruleOut, ruleSrc, i)) { 537 psError (PSPHOT_ERR_CONFIG, false, "failed to copy peaks from %s to %s entry %d", ruleSrc, ruleOut, i); 538 return false; 539 } 540 } 541 return true; 542 } 543 544 // add newly detected peaks to the existing list of sources 545 bool psphotCopyPeaksReadout (pmConfig *config, const pmFPAview *view, const char *ruleOut, const char *ruleSrc, int index) { 546 547 bool status; 548 549 // find the currently selected readout 550 pmFPAfile *fileSrc = pmFPAfileSelectSingle(config->files, ruleSrc, index); // File of interest 551 psAssert (fileSrc, "missing file?"); 552 553 pmReadout *readoutSrc = pmFPAviewThisReadout(view, fileSrc->fpa); 554 psAssert (readoutSrc, "missing readout?"); 555 556 pmDetections *detections = psMetadataLookupPtr (&status, readoutSrc->analysis, "PSPHOT.DETECTIONS"); 557 psAssert (detections, "missing detections?"); 558 559 // find the currently selected readout 560 pmFPAfile *fileOut = pmFPAfileSelectSingle(config->files, ruleOut, index); // File of interest 561 psAssert (fileOut, "missing file?"); 562 563 pmReadout *readoutOut = pmFPAviewThisReadout(view, fileOut->fpa); 564 psAssert (readoutOut, "missing readout?"); 565 566 // generate a new detection structure for the output filerule 567 pmDetections *detectionsOut = psMetadataLookupPtr (&status, readoutOut->analysis, "PSPHOT.DETECTIONS"); 568 psAssert (detectionsOut, "missing PSPHOT.DETECTIONS?"); 569 570 psAssert (detectionsOut->peaks, "programming error"); 571 psAssert (!detectionsOut->oldPeaks, "programming error"); 572 psAssert (detections->peaks, "programming error"); 573 574 // save the OUT existing peaks on oldPeaks 575 detectionsOut->oldPeaks = detectionsOut->peaks; 576 detectionsOut->peaks = psArrayAllocEmpty(detections->peaks->n); 577 578 for (int i = 0; i < detections->peaks->n; i++) { 579 psAssert (detections->peaks->data[i], "programming error"); 580 pmPeak *peak = pmPeakAlloc (0, 0, 0.0, PM_PEAK_LONE); 581 pmPeakCopy(peak, detections->peaks->data[i]); 582 psArrayAdd (detectionsOut->peaks, 100, peak); 583 psFree (peak); 584 } 585 return true; 586 } 587 588 // create source parents children from ruleSrc for ruleOut for orphans 589 bool psphotSourceParents (pmConfig *config, const pmFPAview *view, const char *ruleOut, const char *ruleSrc) 590 { 591 bool status = true; 592 593 int num = psphotFileruleCount(config, ruleSrc); 594 595 // skip the chisq image because it is a duplicate of the detection version 596 int chisqNum = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.CHISQ.NUM"); 597 if (!status) chisqNum = -1; 598 599 // loop over the available readouts 600 for (int i = 0; i < num; i++) { 601 if (i == chisqNum) continue; // skip chisq image 602 if (!psphotSourceParentsReadout (config, view, ruleOut, ruleSrc, i)) { 537 603 psError (PSPHOT_ERR_CONFIG, false, "failed to copy sources from %s to %s entry %d", ruleSrc, ruleOut, i); 538 604 return false; … … 542 608 } 543 609 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) { 610 // create source parents from ruleSrc for ruleOut for orphaned children for this readout. 611 bool psphotSourceParentsReadout (pmConfig *config, const pmFPAview *view, const char *ruleOut, const char *ruleSrc, int index) { 552 612 553 613 bool status; 614 int nParents = 0; 615 int nNonOrphans = 0; 554 616 555 617 // find the currently selected readout … … 583 645 for (int i = 0; i < sourcesSrc->n; i++) { 584 646 pmSource *sourceSrc = sourcesSrc->data[i]; 585 if (sourceSrc->parent) continue; // I am not an orphan 647 if (sourceSrc->parent) { 648 nNonOrphans ++; 649 continue; // Not an orphan 650 } 586 651 587 652 pmSource *sourceOut = pmSourceCopy(sourceSrc); … … 609 674 pmSourceFreePixels (sourceOut); 610 675 611 // XXX do we need to skip the Chisq image sources?612 613 676 // allocate image, weight, mask for the new image for each peak 614 677 if (sourceOut->modelPSF) { … … 620 683 sourceOut->tmpFlags &= ~PM_SOURCE_TMPF_SUBTRACTED; 621 684 685 nParents ++; 622 686 psArrayAdd (detectionsOut->allSources, 100, sourceOut); 623 687 psFree (sourceOut); 624 688 } 625 psLogMsg ("psphot", 3, "%ld known sources supplied", detectionsOut->allSources->n); 626 689 psLogMsg ("psphot", 3, "%d parents created, %d unorphaned children, %ld input vs %ld output", nParents, nNonOrphans, sourcesSrc->n, detectionsOut->allSources->n); 627 690 628 691 return true; … … 651 714 } 652 715 653 // create source children from ruleSrc for ruleOut for this entry. XXX currently, this is only716 // Create source children from ruleSrc for ruleOut for this entry. Currently, this is only 654 717 // used by psphotStackReadout (sources go on allSources so that psphotChoosePSF can be called 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. 718 // repeatedly). 660 719 bool psphotSourceChildrenReadout (pmConfig *config, const pmFPAview *view, const char *ruleOut, const char *ruleSrc, int index) { 661 720 … … 682 741 psAssert (readoutOut, "missing readout?"); 683 742 684 // generate a new detection structure for the output filerule 685 pmDetections *detectionsOut = psMetadataLookupPtr (&status, readoutOut->analysis, "PSPHOT.DETECTIONS"); 686 if (!detectionsOut) { 687 detectionsOut = pmDetectionsAlloc(); 688 detectionsOut->allSources = psArrayAllocEmpty (100); 689 // save detections on the readout->analysis 690 if (!psMetadataAddPtr (readoutOut->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_META_REPLACE | PS_DATA_UNKNOWN, "psphot detections", detectionsOut)) { 691 psError (PSPHOT_ERR_CONFIG, false, "problem saving detections on readout"); 692 return false; 693 } 694 psFree(detectionsOut); // a copy remains on the analysis metadata 743 // replace any existing DETECTION container on readoutOut->analysis with the new one 744 pmDetections *detectionsOut = pmDetectionsAlloc(); 745 detectionsOut->allSources = psArrayAllocEmpty (100); 746 if (!psMetadataAddPtr (readoutOut->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_META_REPLACE | PS_DATA_UNKNOWN, "psphot detections", detectionsOut)) { 747 psError (PSPHOT_ERR_CONFIG, false, "problem saving detections on readout"); 748 return false; 695 749 } 696 750 … … 729 783 730 784 // allocate image, weight, mask for the new image for each peak 731 if (sourceOut->modelPSF) { 732 pmSourceRedefinePixels (sourceOut, readoutOut, sourceOut->peak->x, sourceOut->peak->y, sourceOut->modelPSF->fitRadius); 733 } 785 pmSourceRedefinePixels (sourceOut, readoutOut, sourceOut->peak->x, sourceOut->peak->y, sourceOut->windowRadius); 734 786 735 787 // child sources have not been subtracted in this image, but this flag may be raised if … … 740 792 psFree (sourceOut); 741 793 } 742 psLogMsg ("psphot", 3, "%ld known sources supplied", detectionsOut->allSources->n); 743 794 psLogMsg ("psphot", 3, "created %ld children", detectionsOut->allSources->n); 795 796 psFree(detectionsOut); // a copy remains on the analysis metadata 744 797 745 798 return true; -
branches/eam_branches/ipp-20111110/psphot/src/psphotOutput.c
r32685 r32689 414 414 char filename[64]; 415 415 416 // XXX uncomment to disreturn true; 416 // XXX dump tests are disabled unless this is commented out: 417 return true; 417 418 418 419 bool status = true; … … 453 454 454 455 // XXX only dump a given region 455 if (peak->xf < 20) continue;456 if (peak->yf < 20) continue;457 if (peak->xf > 40) continue;458 if (peak->yf > 70) continue;456 // if (peak->xf < 20) continue; 457 // if (peak->yf < 20) continue; 458 // if (peak->xf > 40) continue; 459 // if (peak->yf > 70) continue; 459 460 460 461 float Msum = source->moments ? source->moments->Sum : NAN; 461 462 float Mx = source->moments ? source->moments->Mx : NAN; 462 463 float My = source->moments ? source->moments->My : NAN; 463 float Npix = source->moments ? source->moments->nPixels : NAN; 464 fprintf (f, "%f %f : %f %f : %f %f\n", peak->xf, peak->yf, Mx, My, Msum, Npix); 464 // float Npix = source->moments ? source->moments->nPixels : NAN; 465 float Io = source->modelPSF ? source->modelPSF->params->data.F32[PM_PAR_I0] : NAN; 466 fprintf (f, "%d %f %f : %f %f : %f %f\n", source->imageID, peak->xf, peak->yf, Mx, My, Msum, Io); 465 467 } 466 468 } -
branches/eam_branches/ipp-20111110/psphot/src/psphotReadout.c
r32685 r32689 1 1 # include "psphotInternal.h" 2 bool psphotDumpTest (pmConfig *config, const pmFPAview *view, const char *filerule);3 2 4 3 // this should be called by every program that links against libpsphot … … 83 82 return psphotReadoutCleanup (config, view, filerule); 84 83 } 85 psphotDumpTest (config, view, filerule);86 84 87 85 // find blended neighbors of very saturated stars (detections->newSources) … … 139 137 // linear PSF fit to source peaks, subtract the models from the image (in PSF mask) 140 138 psphotFitSourcesLinear (config, view, filerule, false); // pass 1 (detections->allSources) 141 psphotDumpTest (config, view, filerule);142 139 143 140 // measure the radial profiles to the sky … … 188 185 // NOTE: new sources are saved on detections->newSources 189 186 psphotSourceStats (config, view, filerule, false); // pass 2 (detections->newSources) 190 psphotDumpTest (config, view, filerule);191 187 192 188 // set source type … … 209 205 // XXX check on free of sources... 210 206 psphotMergeSources (config, view, filerule); // (detections->newSources + detections->allSources -> detections->allSources) 211 psphotDumpTest (config, view, filerule);212 207 213 208 // NOTE: apply to ALL sources -
branches/eam_branches/ipp-20111110/psphot/src/psphotReplaceUnfit.c
r32685 r32689 1 1 # include "psphotInternal.h" 2 3 static int replace_pass = 0;4 static int remove_pass = 0;5 2 6 3 // replace the flux for sources which failed … … 43 40 } 44 41 } 45 replace_pass ++;46 42 return true; 47 43 } … … 60 56 psAssert (readout, "missing readout?"); 61 57 62 char name[128]; 63 snprintf (name, 128, "testadd.neg.%02d.%02d.fits", replace_pass, index); 64 psphotSaveImage (NULL, readout->image, name); 58 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); 59 psAssert (detections, "missing detections?"); 60 61 psArray *sources = detections->allSources; 62 psAssert (sources, "missing sources?"); 63 64 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 65 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels 66 psAssert (maskVal, "missing mask value?"); 67 68 // bit-mask to mark pixels not used in analysis 69 psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT"); 70 assert (markVal); 71 72 // maskVal is used to test for rejected pixels, and must include markVal 73 maskVal |= markVal; 74 75 for (int i = 0; i < sources->n; i++) { 76 pmSource *source = sources->data[i]; 77 78 if (ignoreState) { 79 // rely on the type of source to decide if we subtract it or not 80 81 // skip non-astronomical objects (very likely defects) 82 if (source->type == PM_SOURCE_TYPE_DEFECT) continue; 83 if (source->type == PM_SOURCE_TYPE_SATURATED) continue; 84 85 // do not include CRs in the full ensemble fit 86 if (source->mode & PM_SOURCE_MODE_CR_LIMIT) continue; 87 88 // do not include MOMENTS_FAILURES in the fit 89 if (source->mode & PM_SOURCE_MODE_MOMENTS_FAILURE) continue; 90 } else { 91 // if we respect the state, do not replace unsubtracted sources 92 if (!(source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED)) continue; 93 } 94 95 pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal); 96 } 97 98 psphotVisualShowImage(readout); 99 psLogMsg ("psphot.replace", PS_LOG_INFO, "replaced models for %ld objects: %f sec\n", sources->n, psTimerMark ("psphot.replace")); 100 return true; 101 } 102 103 // for now, let's store the detections on the readout->analysis for each readout 104 bool psphotRemoveAllSources (pmConfig *config, const pmFPAview *view, const char *filerule, bool ignoreState) 105 { 106 bool status = true; 107 108 // select the appropriate recipe information 109 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE); 110 psAssert (recipe, "missing recipe?"); 111 112 int num = psphotFileruleCount(config, filerule); 113 114 // loop over the available readouts 115 for (int i = 0; i < num; i++) { 116 if (!psphotRemoveAllSourcesReadout (config, view, filerule, i, recipe, ignoreState)) { 117 psError (PSPHOT_ERR_CONFIG, false, "failed to replace all sources for %s entry %d", filerule, i); 118 return false; 119 } 120 } 121 return true; 122 } 123 124 bool psphotRemoveAllSourcesReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe, bool ignoreState) { 125 126 bool status; 127 128 psTimerStart ("psphot.replace"); 129 130 // find the currently selected readout 131 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest 132 psAssert (file, "missing file?"); 133 134 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); 135 psAssert (readout, "missing readout?"); 65 136 66 137 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); … … 98 169 } else { 99 170 // if we respect the state, only remove unsubtracted sources 100 if (!(source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED)) continue; 101 } 102 103 pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal); 104 } 105 106 snprintf (name, 128, "testadd.pos.%02d.%02d.fits", replace_pass, index); 107 psphotSaveImage (NULL, readout->image, name); 108 109 psphotVisualShowImage(readout); 110 psLogMsg ("psphot.replace", PS_LOG_INFO, "replaced models for %ld objects: %f sec\n", sources->n, psTimerMark ("psphot.replace")); 111 return true; 112 } 113 114 // for now, let's store the detections on the readout->analysis for each readout 115 bool psphotRemoveAllSources (pmConfig *config, const pmFPAview *view, const char *filerule, bool ignoreState) 116 { 117 bool status = true; 118 119 // select the appropriate recipe information 120 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE); 121 psAssert (recipe, "missing recipe?"); 122 123 int num = psphotFileruleCount(config, filerule); 124 125 // loop over the available readouts 126 for (int i = 0; i < num; i++) { 127 if (!psphotRemoveAllSourcesReadout (config, view, filerule, i, recipe, ignoreState)) { 128 psError (PSPHOT_ERR_CONFIG, false, "failed to replace all sources for %s entry %d", filerule, i); 129 return false; 130 } 131 } 132 remove_pass ++; 133 return true; 134 } 135 136 bool psphotRemoveAllSourcesReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe, bool ignoreState) { 137 138 bool status; 139 140 psTimerStart ("psphot.replace"); 141 142 // find the currently selected readout 143 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest 144 psAssert (file, "missing file?"); 145 146 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); 147 psAssert (readout, "missing readout?"); 148 149 char name[128]; 150 snprintf (name, 128, "testsub.pos.%02d.%02d.fits", remove_pass, index); 151 psphotSaveImage (NULL, readout->image, name); 152 153 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); 154 psAssert (detections, "missing detections?"); 155 156 psArray *sources = detections->allSources; 157 psAssert (sources, "missing sources?"); 158 159 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 160 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels 161 psAssert (maskVal, "missing mask value?"); 162 163 // bit-mask to mark pixels not used in analysis 164 psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT"); 165 assert (markVal); 166 167 // maskVal is used to test for rejected pixels, and must include markVal 168 maskVal |= markVal; 169 170 for (int i = 0; i < sources->n; i++) { 171 pmSource *source = sources->data[i]; 172 173 // skip non-astronomical objects (very likely defects) 174 if (source->type == PM_SOURCE_TYPE_DEFECT) continue; 175 if (source->type == PM_SOURCE_TYPE_SATURATED) continue; 176 177 // do not include CRs in the full ensemble fit 178 if (source->mode & PM_SOURCE_MODE_CR_LIMIT) continue; 179 180 // do not include MOMENTS_FAILURES in the fit 181 if (source->mode & PM_SOURCE_MODE_MOMENTS_FAILURE) continue; 182 183 // if we respect the state, only remove unsubtracted sources 184 if (!ignoreState && (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED)) continue; 185 171 if ((source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED)) continue; 172 } 173 186 174 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 187 175 } 188 189 snprintf (name, 128, "testsub.neg.%02d.%02d.fits", remove_pass, index);190 psphotSaveImage (NULL, readout->image, name);191 176 192 177 psphotVisualShowImage(readout); -
branches/eam_branches/ipp-20111110/psphot/src/psphotSourceFits.c
r32633 r32689 257 257 okDBL = psphotEvalDBL (tmpSrc, DBL->data[0]); 258 258 okDBL &= psphotEvalDBL (tmpSrc, DBL->data[1]); 259 okDBL = false; // XXX this is failing badly... 259 260 // XXX should I keep / save the flags set in the eval functions? 260 261 -
branches/eam_branches/ipp-20111110/psphot/src/psphotStackReadout.c
r32686 r32689 1 1 # include "psphotInternal.h" 2 bool psphotDumpTest (pmConfig *config, const pmFPAview *view, const char *filerule);3 2 4 3 // we have 3 possible real filesets: … … 83 82 } 84 83 85 // XXX I think this is not defined correctly for an array of images.86 // XXX I probably need to subtract the model (same model?) for both RAW and OUT.87 // XXX But, probably not a problem in practice since the stacks are constructed with 0.0 mean level.88 89 84 // generate a background model (median, smoothed image) 90 85 if (!psphotModelBackground (config, view, STACK_DET)) { … … 92 87 } 93 88 if (!psphotSubtractBackground (config, view, STACK_DET)) { 89 return psphotReadoutCleanup (config, view, STACK_SRC); 90 } 91 if (!psphotSubtractBackground (config, view, STACK_SRC)) { 94 92 return psphotReadoutCleanup (config, view, STACK_SRC); 95 93 } … … 133 131 return psphotReadoutCleanup (config, view, STACK_SRC); 134 132 } 135 psphotDumpTest (config, view, STACK_SRC);133 // psphotDumpTest (config, view, STACK_SRC); 136 134 psMemDump("sourcestats"); 137 135 … … 170 168 171 169 // linear PSF fit to source peaks, subtract the models from the image (in PSF mask) 172 // XXX why do this as a stack operation?173 // psphotFitSourcesLinearStack (config, objects, false);174 170 psphotFitSourcesLinear (config, view, STACK_SRC, false); 175 171 psphotStackVisualFilerule(config, view, STACK_SRC); 176 psphotDumpTest (config, view, STACK_SRC);177 172 178 173 // measure the radial profiles to the sky … … 206 201 // NOTE: this block performs the 2nd pass low-significance PSF detection stage 207 202 { 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 214 // subtract all sources from DET (this will subtract using the psf model for SRC, which 215 // will somewhat oversubtract the sources -- this is OK 216 // *** this fails because the source->pixels are still pointing at SRC, not DET 217 psphotRemoveAllSources (config, view, STACK_DET, true); // ignore subtraction state for sources 203 // if DET and SRC are different images, generate children sources for all sources in 204 // the SRC image. This operation replaces the existing DETECTION container on DET 205 // which is currently a view to the one on SRC). children sources go to 206 // det->allSources 207 if (strcmp(STACK_SRC, STACK_DET)) { 208 psphotSourceChildren (config, view, STACK_DET, STACK_SRC); 209 210 // subtract all sources from DET (this will subtract using the psf model for SRC, which 211 // will somewhat oversubtract the sources -- this is OK 212 psphotRemoveAllSources (config, view, STACK_DET, false); // ignore subtraction state for sources 213 } 218 214 219 215 // add noise for subtracted objects … … 231 227 // (this operation just ensures the metadata container has a view on SRC as well 232 228 if (strcmp(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)) { 229 // replace all sources in DET 230 psphotReplaceAllSources (config, view, STACK_DET, false); // ignore subtraction state for sources 231 232 // copy the newly detected peaks from DET to SRC so SourceStats below can operate on them 233 if (!psphotCopyPeaks (config, view, STACK_SRC, STACK_DET)) { 241 234 psError (PSPHOT_ERR_UNKNOWN, false, "failure in peak analysis"); 242 235 return psphotReadoutCleanup (config, view, STACK_SRC); … … 244 237 } 245 238 246 // replace all sources in DET247 psphotReplaceAllSources (config, view, STACK_DET, true); // ignore subtraction state for sources248 249 239 // define new sources based on only the new peaks & measure moments 250 240 // NOTE: new sources are saved on detections->newSources 251 241 psphotSourceStats (config, view, STACK_SRC, false); // pass 2 (detections->newSources) 252 psphotDumpTest (config, view, STACK_SRC);253 242 254 243 // set source type … … 271 260 // XXX check on free of sources... 272 261 psphotMergeSources (config, view, STACK_SRC); // (detections->newSources + detections->allSources -> detections->allSources) 273 psphotDumpTest (config, view, STACK_SRC);274 262 } 275 263 … … 285 273 286 274 psphotStackObjectsSelectForAnalysis (config, view, STACK_SRC, objects); 287 psphotDumpTest (config, view, STACK_SRC);288 275 289 276 // NOTE: apply to ALL sources … … 324 311 325 312 int nRadialEntries = psphotStackMatchPSFsEntries(config, view, STACK_OUT); 326 327 psphotDumpTest (config, view, STACK_SRC);328 313 329 314 for (int entry = 1; entry < nRadialEntries; entry++) {
Note:
See TracChangeset
for help on using the changeset viewer.
