IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 18, 2010, 4:11:53 PM (16 years ago)
Author:
eugene
Message:

merge changes from branches/eam_branches/psphot,psModules.20100506 (finish basic psphotStack)

Location:
trunk/psphot
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot

  • trunk/psphot/src/psphotStackReadout.c

    r27657 r28013  
    11# include "psphotInternal.h"
     2
     3# define STACK_RAW "PSPHOT.STACK.INPUT.RAW"
     4# define STACK_OUT "PSPHOT.STACK.OUTPUT.IMAGE"
    25
    36bool psphotStackReadout (pmConfig *config, const pmFPAview *view) {
     
    1720    PS_ASSERT_PTR_NON_NULL (breakPt, false);
    1821
     22    // we have 3 relevant files: RAW, CNV, OUT
     23
    1924    // set the photcode for each image
    20     if (!psphotAddPhotcode (config, view)) {
     25    if (!psphotAddPhotcode (config, view, STACK_OUT)) {
    2126        psError (PSPHOT_ERR_CONFIG, false, "trouble defining the photcode");
    2227        return false;
     
    2429
    2530    // Generate the mask and weight images
    26     if (!psphotSetMaskAndVariance (config, view)) {
    27         return psphotReadoutCleanup (config, view);
     31    // XXX this should be done before we perform the convolutions
     32    if (!psphotSetMaskAndVariance (config, view, STACK_RAW)) {
     33        return psphotReadoutCleanup (config, view, STACK_OUT);
    2834    }
    2935    if (!strcasecmp (breakPt, "NOTHING")) {
    30         return psphotReadoutCleanup (config, view);
     36        return psphotReadoutCleanup (config, view, STACK_OUT);
    3137    }
    3238
    3339    // generate a background model (median, smoothed image)
    3440    // XXX I think this is not defined correctly for an array of images.
    35     if (!psphotModelBackground (config, view)) {
    36         return psphotReadoutCleanup (config, view);
     41    // XXX probably need to subtract the model (same model?) for both RAW and OUT
     42    if (!psphotModelBackground (config, view, STACK_RAW)) {
     43        return psphotReadoutCleanup (config, view, STACK_OUT);
    3744    }
    38     if (!psphotSubtractBackground (config, view)) {
    39         return psphotReadoutCleanup (config, view);
     45    if (!psphotSubtractBackground (config, view, STACK_RAW)) {
     46        return psphotReadoutCleanup (config, view, STACK_OUT);
    4047    }
    4148    if (!strcasecmp (breakPt, "BACKMDL")) {
    42         return psphotReadoutCleanup (config, view);
     49        return psphotReadoutCleanup (config, view, STACK_OUT);
    4350    }
    4451
     
    4754    if (!psphotLoadPSF (config, view)) {
    4855        psError (PSPHOT_ERR_UNKNOWN, false, "error loading psf model");
    49         return psphotReadoutCleanup (config, view);
     56        return psphotReadoutCleanup (config, view, STACK_OUT);
    5057    }
    5158
    52     if (!psphotStackChisqImage(config, view)) {
     59    if (!psphotStackChisqImage(config, view, STACK_RAW, STACK_OUT)) {
    5360        psError (PSPHOT_ERR_UNKNOWN, false, "failure to generate chisq image");
    54         return psphotReadoutCleanup (config, view);
     61        return psphotReadoutCleanup (config, view, STACK_OUT);
    5562    }
    5663    if (!strcasecmp (breakPt, "CHISQ")) {
    57         return psphotReadoutCleanup (config, view);
     64        return psphotReadoutCleanup (config, view, STACK_OUT);
    5865    }
    5966
    6067    // find the detections (by peak and/or footprint) in the image.
    6168    // This finds the detections on Chisq image as well as the individuals
    62     if (!psphotFindDetections (config, view, true)) { // pass 1
     69    if (!psphotFindDetections (config, view, STACK_RAW, true)) { // pass 1
    6370        // this only happens if we had an error in psphotFindDetections
    6471        psError (PSPHOT_ERR_UNKNOWN, false, "failure in peak analysis");
    65         return psphotReadoutCleanup (config, view);
     72        return psphotReadoutCleanup (config, view, STACK_OUT);
     73    }
     74
     75    // copy the detections from RAW to OUT
     76    if (!psphotCopySources (config, view, STACK_OUT, STACK_RAW)) {
     77        psError (PSPHOT_ERR_UNKNOWN, false, "failure in peak analysis");
     78        return psphotReadoutCleanup (config, view, STACK_OUT);
    6679    }
    6780
    6881    // construct sources and measure basic stats (saved on detections->newSources)
    6982    // only run this on detections from the input images, not chisq image
    70     if (!psphotSourceStats (config, view, true)) { // pass 1
     83    if (!psphotSourceStats (config, view, STACK_OUT, true)) { // pass 1
    7184        psError(PSPHOT_ERR_UNKNOWN, false, "failure to generate sources");
    72         return psphotReadoutCleanup (config, view);
     85        return psphotReadoutCleanup (config, view, STACK_OUT);
    7386    }
    7487
    75     // *** generate the objects (which unify the sources from the different images)
    76     psArray *objects = psphotMatchSources (config, view);
     88    // generate the objects (object unify the sources from the different images)
     89    psArray *objects = psphotMatchSources (config, view, STACK_OUT);
    7790
    7891    // construct sources for the newly-generated sources (from other images)
    79     if (!psphotSourceStats (config, view, false)) { // pass 1
     92    if (!psphotSourceStats (config, view, STACK_OUT, false)) { // pass 1
    8093        psError(PSPHOT_ERR_UNKNOWN, false, "failure to generate sources");
    81         return psphotReadoutCleanup (config, view);
     94        return psphotReadoutCleanup (config, view, STACK_OUT);
    8295    }
    8396
     
    8598    // if (!psphotDeblendSatstars (config, view)) {
    8699    //     psError (PSPHOT_ERR_UNKNOWN, false, "failed on satstar deblend analysis");
    87     //     return psphotReadoutCleanup (config, view);
     100    //     return psphotReadoutCleanup (config, view, STACK_OUT);
    88101    // }
    89102
     
    91104    // if (!psphotBasicDeblend (config, view)) {
    92105    //     psError (PSPHOT_ERR_UNKNOWN, false, "failed on deblend analysis");
    93     //     return psphotReadoutCleanup (config, view);
     106    //     return psphotReadoutCleanup (config, view, STACK_OUT);
    94107    // }
    95108
    96109    // classify sources based on moments, brightness
    97110    // only run this on detections from the input images, not chisq image
    98     if (!psphotRoughClass (config, view)) {
     111    if (!psphotRoughClass (config, view, STACK_OUT)) {
    99112        psError (PSPHOT_ERR_UNKNOWN, false, "failed to determine rough classifications");
    100         return psphotReadoutCleanup (config, view);
     113        return psphotReadoutCleanup (config, view, STACK_OUT);
    101114    }
    102115    // if we were not supplied a PSF model, determine the IQ stats here (detections->newSources)
    103116    // only run this on detections from the input images, not chisq image
    104     if (!psphotImageQuality (config, view)) { // pass 1
     117    if (!psphotImageQuality (config, view, STACK_OUT)) { // pass 1
    105118        psError (PSPHOT_ERR_UNKNOWN, false, "failed to measure image quality");
    106         return psphotReadoutCleanup(config, view);
     119        return psphotReadoutCleanup (config, view, STACK_OUT);
    107120    }
    108121    if (!strcasecmp (breakPt, "MOMENTS")) {
    109         return psphotReadoutCleanup (config, view);
     122        return psphotReadoutCleanup (config, view, STACK_OUT);
    110123    }
    111124
    112125    // use bright stellar objects to measure PSF if we were supplied a PSF for any input file,
    113126    // this step is skipped
    114     if (!psphotChoosePSF (config, view)) { // pass 1
     127    if (!psphotChoosePSF (config, view, STACK_OUT)) { // pass 1
    115128        psLogMsg ("psphot", 3, "failure to construct a psf model");
    116         return psphotReadoutCleanup (config, view);
     129        return psphotReadoutCleanup (config, view, STACK_OUT);
    117130    }
    118131    if (!strcasecmp (breakPt, "PSFMODEL")) {
    119         return psphotReadoutCleanup (config, view);
     132        return psphotReadoutCleanup (config, view, STACK_OUT);
    120133    }
    121134
    122     // include externally-supplied sources
    123     // XXX fix this in the new multi-input context
    124     // psphotLoadExtSources (config, view); // pass 1
    125 
    126135    // construct an initial model for each object, set the radius to fitRadius, set circular fit mask
    127     psphotGuessModels (config, view);
     136    psphotGuessModels (config, view, STACK_OUT);
    128137
    129138    // merge the newly selected sources into the existing list
    130139    // NOTE: merge OLD and NEW
    131     psphotMergeSources (config, view);
     140    psphotMergeSources (config, view, STACK_OUT);
    132141
    133142    // linear PSF fit to source peaks, subtract the models from the image (in PSF mask)
    134143    psphotFitSourcesLinearStack (config, objects, FALSE);
    135     psFree (objects);
    136144
    137145    // identify CRs and extended sources
    138     psphotSourceSize (config, view, TRUE);
     146    psphotSourceSize (config, view, STACK_OUT, TRUE);
    139147
    140148    // measure aperture photometry corrections
    141     if (!psphotApResid (config, view)) {
     149    if (!psphotApResid (config, view, STACK_OUT)) {
     150        psFree (objects);
    142151        psLogMsg ("psphot", 3, "failed on psphotApResid");
    143         return psphotReadoutCleanup (config, view);
     152        return psphotReadoutCleanup (config, view, STACK_OUT);
    144153    }
    145154
     155    psphotStackObjectsUnifyPosition (objects);
     156    psphotRadialAperturesByObject (config, objects, view, STACK_OUT);
     157
     158    psphotExtendedSourceAnalysisByObject (config, objects, view, STACK_OUT); // pass 1 (detections->allSources)
     159    psphotExtendedSourceFits (config, view, STACK_OUT); // pass 1 (detections->allSources)
     160
    146161    // calculate source magnitudes
    147     psphotMagnitudes(config, view);
     162    psphotMagnitudes(config, view, STACK_OUT);
    148163
    149     if (!psphotEfficiency(config, view)) {
     164    if (!psphotEfficiency(config, view, STACK_OUT)) {
    150165        psErrorStackPrint(stderr, "Unable to determine detection efficiencies from fake sources");
    151166        psErrorClear();
     
    156171
    157172    // replace background in residual image
    158     psphotSkyReplace (config, view);
     173    psphotSkyReplace (config, view, STACK_RAW);
    159174
    160175    // drop the references to the image pixels held by each source
    161     psphotSourceFreePixels (config, view);
     176    psphotSourceFreePixels (config, view, STACK_OUT);
    162177
    163178    // remove chisq image from config->file:PSPHOT.INPUT (why?)
    164     psphotStackRemoveChisqFromInputs(config);
     179    psphotStackRemoveChisqFromInputs(config, STACK_RAW);
     180
     181    psFree (objects);
    165182
    166183    // create the exported-metadata and free local data
    167     return psphotReadoutCleanup (config, view);
     184    return psphotReadoutCleanup (config, view, STACK_OUT);
    168185}
    169186
Note: See TracChangeset for help on using the changeset viewer.