IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 31, 2012, 11:50:18 AM (14 years ago)
Author:
eugene
Message:

merge changes from trunk

Location:
branches/eam_branches/ipp-20120627/psphot
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20120627/psphot

  • branches/eam_branches/ipp-20120627/psphot/src

  • branches/eam_branches/ipp-20120627/psphot/src/psphotStackReadout.c

    r33958 r34247  
    11# include "psphotInternal.h"
     2
     3static bool psphotStackLoadWCS(pmConfig *config, const pmFPAview *view, const char *filerule);
    24
    35// we have 3 possible real filesets:
     
    6769    char *STACK_SRC = useRaw ? STACK_RAW : STACK_CNV;
    6870    char *STACK_DET = STACK_RAW;
     71
     72    // load WCS
     73    if (!psphotStackLoadWCS(config, view, STACK_SRC)) {
     74        psError (PSPHOT_ERR_CONFIG, false, "trouble loading WCS for %s", STACK_SRC);
     75        return false;
     76    }
    6977
    7078    // set the photcode for each image
     
    179187
    180188    // linear PSF fit to source peaks, subtract the models from the image (in PSF mask)
    181     psphotFitSourcesLinear (config, view, STACK_SRC, false);
     189    psphotFitSourcesLinear (config, view, STACK_SRC, false, false);
    182190    psphotStackVisualFilerule(config, view, STACK_SRC);
    183191
     
    207215    // NOTE : apply to ALL sources (extended + psf)
    208216    // NOTE 2 : this function subtracts the models from the given filerule (SRC), not DET
    209     psphotFitSourcesLinear (config, view, STACK_SRC, true); // pass 2 (detections->allSources)
     217    psphotFitSourcesLinear (config, view, STACK_SRC, true, false); // pass 2 (detections->allSources)
    210218
    211219    // NOTE: possibly re-measure background model here with objects subtracted / or masked
     
    278286    }
    279287
     288    // gcc doesn't like the label to refer to a declaration so we declare this here
     289    bool splitLinearFit;
     290
    280291pass1finish:
     292
     293    splitLinearFit = psMetadataLookupBool(NULL, recipe, "PSPHOT.STACK.SPLIT.LINEAR.FIT");
     294    if (splitLinearFit) {
     295        psLogMsg ("psphot", 3, "splitting fit of detected and matched soures\n");
     296        // Fit the detected sources separately from matched that wea are about to create.
     297        // NOTE: apply to ALL sources but only include sources with postitive flux in the fit
     298        psphotFitSourcesLinear (config, view, STACK_SRC, true, true); // pass 3 (detections->allSources)
     299    }
    281300
    282301    // generate the objects (objects unify the sources from the different images) NOTE: could
     
    286305    psMemDump("matchsources");
    287306
     307    // check the source density. If it too high change the number of radial bins
     308    // in the recipe.
     309    psphotLimitRadialApertures(recipe, objects->n);
     310
    288311    // Construct an initial model for each object, set the radius to fitRadius, set circular
    289312    // fit mask.  NOTE: only applied to sources without guess models
     
    294317    psphotStackObjectsSelectForAnalysis (config, view, STACK_SRC, objects);
    295318
    296     // NOTE: apply to ALL sources
    297     psphotFitSourcesLinear (config, view, STACK_SRC, true); // pass 3 (detections->allSources)
     319    if (splitLinearFit) {
     320        // NOTE: apply to Matched sources. Since the sources that we fit above are subtracted, they will
     321        // not be included in this fit.
     322        psphotFitSourcesLinear (config, view, STACK_SRC, true, false); // pass 4 (detections->allSources)
     323    } else {
     324        // Fit all sources together
     325        psphotFitSourcesLinear (config, view, STACK_SRC, true, false); // pass 3 (detections->allSources)
     326    }
    298327
    299328    // measure the radial profiles to the sky (only measures new objects)
     
    344373            }
    345374        }
    346         psphotRadialApertures (config, view, STACK_CNV, 0); // XXX entry 0 == unmatched?
     375        psphotRadialApertures (config, view, STACK_CNV, 0); // entry 0 == unmatched
    347376        psMemDump("extmeas");
    348377
     378        // mark any inputs that we want to skip the matched apertures for
     379        psphotStackSetInputsToSkip(config, view, STACK_OUT, true);
     380
    349381        int nRadialEntries = psphotStackMatchPSFsEntries(config, view, STACK_OUT);
    350 
    351382        for (int entry = 1; entry < nRadialEntries; entry++) {
    352383            // NOTE: entry 0 is the unmatched image set
     
    359390
    360391            // this is necessary to get the right normalization for the new models
    361             psphotFitSourcesLinear (config, view, STACK_OUT, false);
     392            psphotFitSourcesLinear (config, view, STACK_OUT, false, false);
    362393
    363394            // measure circular, radial apertures (objects sorted by S/N)
    364             // entry 0 == unmatched? pass entry + 1?
    365395            psphotRadialApertures (config, view, STACK_OUT, entry);
    366396
     
    373403        }
    374404    }
     405    psphotStackSetInputsToSkip(config, view, STACK_OUT, false);
    375406
    376407    // measure aperture photometry corrections
     
    413444    // create the exported-metadata and free local data
    414445    return psphotReadoutCleanup (config, view, STACK_SRC);
     446}
     447
     448static bool psphotStackLoadWCS(pmConfig *config, const pmFPAview *view, const char *filerule) {
     449
     450    int num = psphotFileruleCount(config, filerule);
     451
     452    for (int i=0; i<num; i++) {
     453        pmFPAfile *file = pmFPAfileSelectSingle(config->files, filerule, i); // File of interest
     454        psAssert (file, "missing file?");
     455   
     456        pmReadout *readout = pmFPAviewThisReadout(view, file->fpa);
     457        psAssert (readout, "missing readout?");
     458
     459        pmHDU *hdu = pmHDUFromReadout(readout);
     460        psAssert (hdu, "input missing hdu?");
     461
     462        if (!pmAstromReadWCS(file->fpa, readout->parent->parent, hdu->header, 1.0)) {
     463            psError (PSPHOT_ERR_UNKNOWN, false, "failed to read WCS from header for input %d", i);
     464            return false;
     465        }
     466    }
     467    return true;
    415468}
    416469
Note: See TracChangeset for help on using the changeset viewer.