IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 17, 2011, 1:09:10 PM (15 years ago)
Author:
eugene
Message:

correctly handle the second pass in the detection image: the code was creating duplicate detections in 2 ways: 1) the source subtraction before the second pass was only being applied to the SRC, not the DET image, thus all 1st pass detections were also found as 2nd pass detections; 2) the DBL star fitting function was causing trouble, with the two positions merging to a single object -- this was considered a success, but left behind flux in the subtracted image (and garbage detections in general); Ive turned off the DBL fitting for now as I am not convinced that code is ready

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20111110/psphot/src/psphotStackReadout.c

    r32686 r32689  
    11# include "psphotInternal.h"
    2 bool psphotDumpTest (pmConfig *config, const pmFPAview *view, const char *filerule);
    32
    43// we have 3 possible real filesets:
     
    8382    }
    8483
    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 
    8984    // generate a background model (median, smoothed image)
    9085    if (!psphotModelBackground (config, view, STACK_DET)) {
     
    9287    }
    9388    if (!psphotSubtractBackground (config, view, STACK_DET)) {
     89        return psphotReadoutCleanup (config, view, STACK_SRC);
     90    }
     91    if (!psphotSubtractBackground (config, view, STACK_SRC)) {
    9492        return psphotReadoutCleanup (config, view, STACK_SRC);
    9593    }
     
    133131        return psphotReadoutCleanup (config, view, STACK_SRC);
    134132    }
    135     psphotDumpTest (config, view, STACK_SRC);
     133    // psphotDumpTest (config, view, STACK_SRC);
    136134    psMemDump("sourcestats");
    137135
     
    170168
    171169    // 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);
    174170    psphotFitSourcesLinear (config, view, STACK_SRC, false);
    175171    psphotStackVisualFilerule(config, view, STACK_SRC);
    176     psphotDumpTest (config, view, STACK_SRC);
    177172
    178173    // measure the radial profiles to the sky
     
    206201    // NOTE: this block performs the 2nd pass low-significance PSF detection stage
    207202    {
    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        }
    218214
    219215        // add noise for subtracted objects
     
    231227        // (this operation just ensures the metadata container has a view on SRC as well
    232228        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)) {
    241234                psError (PSPHOT_ERR_UNKNOWN, false, "failure in peak analysis");
    242235                return psphotReadoutCleanup (config, view, STACK_SRC);
     
    244237        }
    245238
    246         // replace all sources in DET
    247         psphotReplaceAllSources (config, view, STACK_DET, true); // ignore subtraction state for sources
    248 
    249239        // define new sources based on only the new peaks & measure moments
    250240        // NOTE: new sources are saved on detections->newSources
    251241        psphotSourceStats (config, view, STACK_SRC, false); // pass 2 (detections->newSources)
    252         psphotDumpTest (config, view, STACK_SRC);
    253242
    254243        // set source type
     
    271260        // XXX check on free of sources...
    272261        psphotMergeSources (config, view, STACK_SRC); // (detections->newSources + detections->allSources -> detections->allSources)
    273         psphotDumpTest (config, view, STACK_SRC);
    274262    }
    275263
     
    285273
    286274    psphotStackObjectsSelectForAnalysis (config, view, STACK_SRC, objects);
    287     psphotDumpTest (config, view, STACK_SRC);
    288275
    289276    // NOTE: apply to ALL sources
     
    324311
    325312    int nRadialEntries = psphotStackMatchPSFsEntries(config, view, STACK_OUT);
    326 
    327     psphotDumpTest (config, view, STACK_SRC);
    328313
    329314    for (int entry = 1; entry < nRadialEntries; entry++) {
Note: See TracChangeset for help on using the changeset viewer.