IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 33917 for trunk


Ignore:
Timestamp:
May 25, 2012, 11:14:13 AM (14 years ago)
Author:
bills
Message:

Several changes to psphotStackReadout.

  • Model the convolved inputs backgrounds separately to work around the different background levels in the current convolved and unconvolved stacks.
  • Don't subtract the backgroud twice if PSPHOT.STACK.USE.RAW
  • if FOOTPRINT_USE_UNSUBTRACTED psphotFindDetections returns with the noise already subtracted so don't repeat
  • rename objectsRadial to objectsOut to emphasize that while they are used for radial apertures they also carry all of the source data to the outputs
  • if RADIAL_APERTURES is false skip the loop since psphotRadialApertures is a no-op in that case
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/psphotStackReadout.c

    r32996 r33917  
    8989        return psphotReadoutCleanup (config, view, STACK_SRC);
    9090    }
    91     if (!psphotSubtractBackground (config, view, STACK_SRC)) {
    92         return psphotReadoutCleanup (config, view, STACK_SRC);
     91    if (strcmp(STACK_SRC, STACK_DET)) {
     92#define MODEL_BACKGROUND_SRC 1
     93#ifdef MODEL_BACKGROUND_SRC
     94        // work around the fact that the background levels on the convolved
     95        // and unconvolved stacks can be different
     96        if (!psphotModelBackground (config, view, STACK_SRC)) {
     97            return psphotReadoutCleanup (config, view, STACK_SRC);
     98        }
     99#endif
     100        if (!psphotSubtractBackground (config, view, STACK_SRC)) {
     101            return psphotReadoutCleanup (config, view, STACK_SRC);
     102        }
    93103    }
    94104    if (!strcasecmp (breakPt, "BACKMDL")) {
     
    190200    psphotReplaceAllSources (config, view, STACK_SRC, false); // pass 1 (detections->allSources)
    191201
     202
    192203    // if we only do one pass, skip to extended source analysis
    193204    if (!strcasecmp (breakPt, "PASS1")) goto pass1finish;
     
    211222            //  subtract all sources from DET (this will subtract using the psf model for SRC, which
    212223            //  will somewhat oversubtract the sources -- this is OK
    213             psphotRemoveAllSources (config, view, STACK_DET, false); // ignore subtraction state for sources
     224            psphotRemoveAllSources (config, view, STACK_DET, false); // do not ignore subtraction state for sources
    214225        }
    215226
     
    223234        // remove noise for subtracted objects (ie, return to normal noise level)
    224235        // NOTE: this needs to operate only on the OLD sources
    225         psphotSubNoise (config, view, STACK_DET); // pass 1 (detections->allSources)
     236        // NOTE: if fooprintsUseUnsubtracted, the noise has already been removed by psphotFindDetections
     237        bool footprintsUseUnsubtracted = psMetadataLookupBool(NULL, recipe, "FOOTPRINT_USE_UNSUBTRACTED");
     238        if (!footprintsUseUnsubtracted) {
     239            psphotSubNoise (config, view, STACK_DET); // pass 1 (detections->allSources)
     240        }
    226241
    227242        // if DET and SRC are different images, copy the detections from DET to SRC
     
    303318
    304319    // create source children for the OUT filerule (for radial aperture photometry)
    305     psArray *objectsRadial = psphotSourceChildrenByObject (config, view, STACK_OUT, objects);
    306     if (!objectsRadial) {
     320    // (These are not just for radial aperture photomoetry. If they aren't defined we
     321    // get no sources output
     322    psArray *objectsOut = psphotSourceChildrenByObject (config, view, STACK_OUT, objects);
     323    if (!objectsOut) {
    307324        psFree(objects);
    308325        psError (PSPHOT_ERR_UNKNOWN, false, "failure in peak analysis");
     
    310327    }
    311328
    312     // measure circular, radial apertures (objects sorted by S/N)
    313     // this forces photometry on the undetected sources from other images
    314     psphotRadialApertures (config, view, STACK_SRC, 0); // XXX entry 0 == unmatched?
    315     psMemDump("extmeas");
    316 
    317     int nRadialEntries = psphotStackMatchPSFsEntries(config, view, STACK_OUT);
    318 
    319     for (int entry = 1; entry < nRadialEntries; entry++) {
    320         // NOTE: entry 0 is the unmatched image set
    321 
    322         // re-measure the PSF for the smoothed image (using entries in 'allSources')
    323         psphotChoosePSF (config, view, STACK_OUT, false);
    324 
    325         // this is necessary to update the models based on the new PSF
    326         psphotResetModels (config, view, STACK_OUT);
    327 
    328         // this is necessary to get the right normalization for the new models
    329         psphotFitSourcesLinear (config, view, STACK_OUT, false);
    330 
    331         // measure circular, radial apertures (objects sorted by S/N)
    332         // entry 0 == unmatched? pass entry + 1?
    333         psphotRadialApertures (config, view, STACK_OUT, entry);
    334 
    335         // replace the flux in the image so it is returned to its original state
    336         psphotReplaceAllSources (config, view, STACK_OUT, false);
    337 
    338         // smooth to the next FWHM, or set 'smoothAgain' to false if no more
    339         psphotStackMatchPSFsNext(config, view, STACK_OUT, entry);
    340         psMemDump("matched");
     329
     330    bool radial_apertures = psMetadataLookupBool(NULL, recipe, "RADIAL_APERTURES");
     331    if (radial_apertures) {
     332        // measure circular, radial apertures (objects sorted by S/N)
     333        // this forces photometry on the undetected sources from other images
     334        psphotRadialApertures (config, view, STACK_SRC, 0); // XXX entry 0 == unmatched?
     335        psMemDump("extmeas");
     336
     337        int nRadialEntries = psphotStackMatchPSFsEntries(config, view, STACK_OUT);
     338
     339        for (int entry = 1; entry < nRadialEntries; entry++) {
     340            // NOTE: entry 0 is the unmatched image set
     341
     342            // re-measure the PSF for the smoothed image (using entries in 'allSources')
     343            psphotChoosePSF (config, view, STACK_OUT, false);
     344
     345            // this is necessary to update the models based on the new PSF
     346            psphotResetModels (config, view, STACK_OUT);
     347
     348            // this is necessary to get the right normalization for the new models
     349            psphotFitSourcesLinear (config, view, STACK_OUT, false);
     350
     351            // measure circular, radial apertures (objects sorted by S/N)
     352            // entry 0 == unmatched? pass entry + 1?
     353            psphotRadialApertures (config, view, STACK_OUT, entry);
     354
     355            // replace the flux in the image so it is returned to its original state
     356            psphotReplaceAllSources (config, view, STACK_OUT, false);
     357
     358            // smooth to the next FWHM, or set 'smoothAgain' to false if no more
     359            psphotStackMatchPSFsNext(config, view, STACK_OUT, entry);
     360            psMemDump("matched");
     361        }
    341362    }
    342363
     
    344365    if (!psphotApResid (config, view, STACK_SRC)) {
    345366        psFree (objects);
     367        psFree (objectsOut);
    346368        psLogMsg ("psphot", 3, "failed on psphotApResid");
    347369        return psphotReadoutCleanup (config, view, STACK_SRC);
     
    375397
    376398    psFree (objects);
    377     psFree (objectsRadial);
     399    psFree (objectsOut);
    378400
    379401    // create the exported-metadata and free local data
Note: See TracChangeset for help on using the changeset viewer.