IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 7, 2010, 5:07:54 PM (17 years ago)
Author:
eugene
Message:

upgrade psphot functions to work in the stack context (see doc/stack.txt)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20091201/psphot/src/psphotSubtractBackground.c

    r26523 r26542  
    44// generate the median in NxN boxes, clipping heavily
    55// linear interpolation to generate full-scale model
    6 bool psphotSubtractBackground (pmConfig *config, const pmFPAview *view, const char *filename)
     6bool psphotSubtractBackgroundReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index)
    77{
    88    bool status = true;
     
    1313
    1414    // find the currently selected readout
    15     pmFPAfile *file = psMetadataLookupPtr (&status, config->files, filename);
     15    pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest
     16
    1617    pmFPA *inFPA = file->fpa;
    1718    pmReadout *readout = pmFPAviewThisReadout (view, inFPA);
     
    1920    psImage *mask  = readout->mask;
    2021
    21     // find the currently selected readout
    22     pmReadout *model = pmFPAfileThisReadout (config->files, view, "PSPHOT.BACKMDL");
     22    // find the currently selected readout (XXX note that the model is saved on PSPHOT.BACKMDL regardless of 'filename'
     23    pmFPAfile *modelFile = pmFPAfileSelectSingle(config->files, "PSPHOT.BACKMDL", index); // File of interest
     24    assert (modelFile);
     25    pmReadout *model = pmFPAviewThisReadout (view, modelFile->fpa);
    2326    assert (model);
    2427
     
    3538
    3639    // select background pixels, from output background file, or create
     40    // XXX for now, we will only allow a single background image to be generated
    3741    file = psMetadataLookupPtr (&status, config->files, "PSPHOT.BACKGND");
    3842    if (file) {
     
    6670
    6771    // back-sub image pixels, from output background file (don't create if not requested)
     72    // XXX for now, we will only allow a single background-subtracted image to be generated
    6873    file = psMetadataLookupPtr (&status, config->files, "PSPHOT.BACKSUB");
    6974    if (file) {
     
    113118}
    114119
    115 // XXX supply filename or keep PSPHOT.INPUT fixed?
    116 bool psphotStackSubtractBackground (pmConfig *config, const pmFPAview *view)
     120bool psphotSubtractBackground (pmConfig *config, const pmFPAview *view)
    117121{
    118     bool status = true;
     122    bool status = false;
    119123
    120     int num = psMetadataAddS32 (&status, config->arguments, "INPUTS.NUM");
    121     psAbort (!status, "programming error: must define INPUTS.NUM");
     124    int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
     125    psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
    122126
    123127    // loop over the available readouts
    124128    for (int i = 0; i < num; i++) {
    125 
    126         pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PSPHOT.INPUT", i); // File of interest
    127 
    128         // find the currently selected readout
    129         pmReadout  *readout = pmFPAviewThisReadout (view, file->fpa);
    130         PS_ASSERT_PTR_NON_NULL (readout, false);
    131 
    132         psImageBinning *binning = psphotBackgroundBinning(readout->image, config); // Image binning parameters
    133         pmReadout *model = pmFPAGenerateReadout(config, view, "PSPHOT.BACKMDL", inFPA, binning); // this needs to be a MULTI like PSPHOT.INPUT
    134         pmReadout *modelStdev = pmFPAGenerateReadout(config, view, "PSPHOT.BACKMDL.STDEV", inFPA, binning); // this needs to be a MULTI like PSPHOT.INPUT
    135 
    136         // XXX save results on model->analysis or readout->analysis??
    137         // XXX need to create a worker function from the function above...
    138         if (!backgroundModel(model->image, modelStdev->image, model->analysis, readout, binning, config)) {
    139             psError(PS_ERR_UNKNOWN, false, "Unable to generate background model");
     129        if (!psphotSubtractBackgroundReadout (config, view, "PSPHOT.INPUT", i)) {
     130            psError (PSPHOT_ERR_CONFIG, false, "failed to subtract background for PSPHOT.INPUT entry %d", i);
    140131            return false;
    141132        }
    142         // display the backsub and backgnd images
    143         psphotVisualShowBackground (config, view, readout);
    144 
    145         npass ++;
    146133    }
    147134    return true;
Note: See TracChangeset for help on using the changeset viewer.