IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 1, 2009, 11:55:34 AM (17 years ago)
Author:
eugene
Message:

re-factored ppSubReadout into a sequence of logical steps; defined convolved images as their own pmFPAfiles; switched to new psphot functions (psphotReadoutFindPSF and psphotReadoutMinimal); simplified mask and psphot visualization handling

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppSub/src/ppSubBackground.c

    r21183 r21257  
    1 #ifdef HAVE_CONFIG_H
    2 #include <config.h>
    3 #endif
    4 
    5 #include <stdio.h>
    6 #include <pslib.h>
    7 #include <psmodules.h>
    8 #include <psphot.h>
    91#include "ppSub.h"
    102
    11 // Copied from ppImageSubtractBackground()
    12 bool ppSubBackground(pmReadout *ro, pmConfig *config, const pmFPAview *view)
     3// Based on ppImageSubtractBackground()
     4bool ppSubBackground(pmConfig *config, const pmFPAview *view)
    135{
    146    psAssert(config, "Need configuration");
    157    psAssert(view, "Need view to chip");
    168
    17     // The background model file may be defined, though the model hasn't been built
    18     // If so, we will build it below.
    19     bool status;                        // Status of lookup
    20     pmFPAfile *modelFile = psMetadataLookupPtr(&status, config->files, "PSPHOT.BACKMDL"); // Background model
    21     if (!status) {
    22         psError(PS_ERR_UNEXPECTED_NULL, true, "PSPHOT.BACKMDL file is not defined");
    23         return false;
    24     }
     9    bool status; // Status of metadata lookups
    2510
    2611    psMetadata *ppSubRecipe = psMetadataLookupPtr(NULL, config->recipes, PPSUB_RECIPE);
    2712    psAssert(ppSubRecipe, "Need PPSUB recipe");
     13
    2814    psMetadata *psphotRecipe = psMetadataLookupPtr(NULL, config->recipes, PSPHOT_RECIPE);
    29     psAssert(psphotRecipe, "Need PSPHOT recipe");
     15    psAssert(psphotRecipe, "Need PSPHOT recipe for binning");
    3016
    31     psString maskBadStr = psMetadataLookupStr(NULL, ppSubRecipe, "MASK.BAD"); // Name of bits to mask for bad
    32     psImageMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels
     17    psImageMaskType maskBad = pmConfigMaskGet("BLANK", config);
    3318
    34     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    35     psMetadataAddImageMask(psphotRecipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "user-defined mask", maskBad);
     19    // select the output readout
     20    pmReadout *outRO = pmFPAfileThisReadout(config->files, view, "PPSUB.OUTPUT");
    3621
    37     psImage *image = ro->image, *mask = ro->mask; // Image and mask of interest
     22    // select the model readout, if it exist already; if not, generate it
     23    pmReadout *modelRO = pmFPAfileThisReadout(config->files, view, "PSPHOT.BACKMDL");
    3824
    39     pmReadout *modelRO = pmFPAviewThisReadout(view, modelFile->fpa); // Background model
     25    // if necessary, generate the background model
    4026    if (!modelRO) {
    4127        // Create the background model
     
    4430            return false;
    4531        }
    46         modelRO = (modelFile->mode == PM_FPA_MODE_INTERNAL) ? modelFile->readout :
    47                    pmFPAviewThisReadout(view, modelFile->fpa);
     32        // select the model readout (should now exist)
     33        modelRO = pmFPAfileThisReadout(config->files, view, "PSPHOT.BACKMDL");
    4834        if (!modelRO) {
    4935            psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find background model");
     
    5440                                                  "PSPHOT.BACKGROUND.BINNING"); // Binning for model
    5541    psImage *modelImage = modelRO->image; // Background model
     42
     43    psImage *image = outRO->image; // Image of interest
     44    psImage *mask = outRO->mask; // Mask of interest
    5645
    5746    // Do the background subtraction
Note: See TracChangeset for help on using the changeset viewer.