IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 21, 2010, 3:01:12 PM (16 years ago)
Author:
eugene
Message:

for psf-matched images: re-determine the psf; re-generate the models with the new psf; re-fit the fluxes; subtract all sources; as radial aperture fluxes are measured only replace the current source of interest; replace all sources before convolving to the next psf

File:
1 edited

Legend:

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

    r30101 r30141  
    1010// SRC (source analysis image) : nominally CNV (optionally RAW)
    1111// OUT (psf-matched images)    : always OUT
     12
     13bool psphotStackVisualFilerule(pmConfig *config, const pmFPAview *view, const char *filerule) {
     14
     15    int num = psphotFileruleCount(config, filerule);
     16
     17    // loop over the available readouts
     18    for (int i = 0; i < num; i++) {
     19
     20        // find the currently selected readout
     21        pmFPAfile *file = pmFPAfileSelectSingle(config->files, filerule, i); // File of interest
     22        psAssert (file, "missing file?");
     23
     24        pmReadout *readout = pmFPAviewThisReadout(view, file->fpa);
     25        psAssert (readout, "missing readout?");
     26
     27        psphotVisualShowImage (readout);
     28        psphotVisualShowResidualImage (readout);
     29    }
     30    return true;
     31}
    1232
    1333bool psphotStackReadout (pmConfig *config, const pmFPAview *view) {
     
    92112    }
    93113
     114    if (!strcasecmp (breakPt, "TEST1")) {
     115        return psphotReadoutCleanup (config, view, STACK_SRC);
     116    }
     117
    94118    // generate the objects (object unify the sources from the different images)
    95119    // XXX this could just match the detections for the chisq image, and not bother measuring the
     
    97121    psArray *objects = psphotMatchSources (config, view, STACK_SRC);
    98122
     123    if (!strcasecmp (breakPt, "TEST2")) {
     124        psFree(objects);
     125        return psphotReadoutCleanup (config, view, STACK_SRC);
     126    }
     127
    99128    // construct sources for the newly-generated sources (from other images)
    100129    if (!psphotSourceStats (config, view, STACK_SRC, false)) { // pass 1
     130        psFree(objects);
    101131        psError(PSPHOT_ERR_UNKNOWN, false, "failure to generate sources");
    102132        return psphotReadoutCleanup (config, view, STACK_SRC);
     
    118148    // only run this on detections from the input images, not chisq image
    119149    if (!psphotRoughClass (config, view, STACK_SRC)) {
     150        psFree(objects);
    120151        psError (PSPHOT_ERR_UNKNOWN, false, "failed to determine rough classifications");
    121152        return psphotReadoutCleanup (config, view, STACK_SRC);
     
    124155    // only run this on detections from the input images, not chisq image
    125156    if (!psphotImageQuality (config, view, STACK_SRC)) { // pass 1
     157        psFree(objects);
    126158        psError (PSPHOT_ERR_UNKNOWN, false, "failed to measure image quality");
    127159        return psphotReadoutCleanup (config, view, STACK_SRC);
    128160    }
    129161    if (!strcasecmp (breakPt, "MOMENTS")) {
     162        psFree(objects);
    130163        return psphotReadoutCleanup (config, view, STACK_SRC);
    131164    }
     
    133166    // use bright stellar objects to measure PSF if we were supplied a PSF for any input file,
    134167    // this step is skipped
    135     if (!psphotChoosePSF (config, view, STACK_SRC)) { // pass 1
     168    if (!psphotChoosePSF (config, view, STACK_SRC, true)) { // pass 1
     169        psFree(objects);
    136170        psLogMsg ("psphot", 3, "failure to construct a psf model");
    137171        return psphotReadoutCleanup (config, view, STACK_SRC);
    138172    }
    139173    if (!strcasecmp (breakPt, "PSFMODEL")) {
     174        psFree(objects);
    140175        return psphotReadoutCleanup (config, view, STACK_SRC);
    141176    }
     
    150185    // linear PSF fit to source peaks, subtract the models from the image (in PSF mask)
    151186    psphotFitSourcesLinearStack (config, objects, FALSE);
     187    psphotStackVisualFilerule(config, view, STACK_SRC);
    152188
    153189    // identify CRs and extended sources
     
    174210    // copy the detections from SRC to OUT (for radial aperture photometry)
    175211    if (!psphotCopySources (config, view, STACK_OUT, STACK_SRC)) {
     212        psFree(objects);
    176213        psError (PSPHOT_ERR_UNKNOWN, false, "failure in peak analysis");
    177214        return psphotReadoutCleanup (config, view, STACK_SRC);
    178215    }
    179     // XXX need to do something to reassign the source pixels here
    180216
    181217    bool smoothAgain = true;
    182218    for (int nMatchedPSF = 0; smoothAgain; nMatchedPSF++) {
     219        psphotRedefinePixels (config, view, STACK_OUT);
     220
     221        psphotChoosePSF (config, view, STACK_OUT, false);
     222
     223        psphotResetModels (config, view, STACK_OUT);
     224
     225        psphotFitSourcesLinear (config, view, STACK_OUT, false);
     226
    183227        // measure circular, radial apertures (objects sorted by S/N)
    184228        psphotRadialAperturesByObject (config, objects, view, STACK_OUT, nMatchedPSF);
     229
     230        psphotReplaceAllSources (config, view, STACK_OUT);
     231
    185232        psphotStackMatchPSFsNext(&smoothAgain, config, view, STACK_OUT, nMatchedPSF);
    186233    }
Note: See TracChangeset for help on using the changeset viewer.