IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 17, 2011, 2:17:35 PM (14 years ago)
Author:
eugene
Message:

fix psphotStack 2nd pass (subtract 1st pass sources from the correct image); fix PS color plotting; plug a leak in psphotStack

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/psphot

  • trunk/psphot/src/psphotStackReadout.c

    r32633 r32695  
    8282    }
    8383
    84     // XXX I think this is not defined correctly for an array of images.
    85     // XXX I probably need to subtract the model (same model?) for both RAW and OUT.
    86     // XXX But, probably not a problem in practice since the stacks are constructed with 0.0 mean level.
    87 
    8884    // generate a background model (median, smoothed image)
    8985    if (!psphotModelBackground (config, view, STACK_DET)) {
     
    9187    }
    9288    if (!psphotSubtractBackground (config, view, STACK_DET)) {
     89        return psphotReadoutCleanup (config, view, STACK_SRC);
     90    }
     91    if (!psphotSubtractBackground (config, view, STACK_SRC)) {
    9392        return psphotReadoutCleanup (config, view, STACK_SRC);
    9493    }
     
    114113    }
    115114
    116     // if DET and SRC are different images, copy the detections from DET to SRC
     115    // If DET and SRC are different images, copy the detections from DET to SRC.  This 'copy'
     116    // is just a copy of the container pointer; the sources on both DET and SRC are the same
     117    // memory objects
    117118    if (strcmp(STACK_SRC, STACK_DET)) {
    118119        if (!psphotCopySources (config, view, STACK_SRC, STACK_DET)) {
     
    130131        return psphotReadoutCleanup (config, view, STACK_SRC);
    131132    }
     133    // psphotDumpTest (config, view, STACK_SRC);
    132134    psMemDump("sourcestats");
    133135
     
    166168
    167169    // linear PSF fit to source peaks, subtract the models from the image (in PSF mask)
    168     // XXX why do this as a stack operation?
    169     // psphotFitSourcesLinearStack (config, objects, false);
    170170    psphotFitSourcesLinear (config, view, STACK_SRC, false);
    171171    psphotStackVisualFilerule(config, view, STACK_SRC);
     
    186186    psphotBlendFit (config, view, STACK_SRC); // pass 1 (detections->allSources)
    187187
    188     // replace all sources
    189     psphotReplaceAllSources (config, view, STACK_SRC); // pass 1 (detections->allSources)
     188    // replace all sources (do NOT ignore subtraction state)
     189    psphotReplaceAllSources (config, view, STACK_SRC, false); // pass 1 (detections->allSources)
    190190
    191191    // if we only do one pass, skip to extended source analysis
     
    194194    // linear fit to include all sources (subtract again)
    195195    // NOTE : apply to ALL sources (extended + psf)
     196    // NOTE 2 : this function subtracts the models from the given filerule (SRC), not DET
    196197    psphotFitSourcesLinear (config, view, STACK_SRC, true); // pass 2 (detections->allSources)
    197198
     
    200201    // NOTE: this block performs the 2nd pass low-significance PSF detection stage
    201202    {
     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        }
     214
    202215        // add noise for subtracted objects
    203216        psphotAddNoise (config, view, STACK_DET); // pass 1 (detections->allSources)
     
    212225
    213226        // if DET and SRC are different images, copy the detections from DET to SRC
     227        // (this operation just ensures the metadata container has a view on SRC as well
    214228        if (strcmp(STACK_SRC, STACK_DET)) {
    215             // XXX how does this handle 1st vs 2nd pass sources?
    216             if (!psphotCopySources (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)) {
    217234                psError (PSPHOT_ERR_UNKNOWN, false, "failure in peak analysis");
    218235                return psphotReadoutCleanup (config, view, STACK_SRC);
     
    237254        // replace all sources so fit below applies to all at once
    238255        // NOTE: apply only to OLD sources (which have been subtracted)
    239         psphotReplaceAllSources (config, view, STACK_SRC); // pass 2
     256        psphotReplaceAllSources (config, view, STACK_SRC, false); // pass 2
    240257
    241258        // merge the newly selected sources into the existing list
     
    312329
    313330        // replace the flux in the image so it is returned to its original state
    314         psphotReplaceAllSources (config, view, STACK_OUT);
     331        psphotReplaceAllSources (config, view, STACK_OUT, false);
    315332
    316333        // smooth to the next FWHM, or set 'smoothAgain' to false if no more
Note: See TracChangeset for help on using the changeset viewer.