IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 13593


Ignore:
Timestamp:
Jun 1, 2007, 6:16:29 PM (19 years ago)
Author:
Paul Price
Message:

Updating high-level programs to use symbolic names for mask values in the recipes.

Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppImage/src/ppImageDetrendReadout.c

    r13506 r13593  
    1818    // Masking on the basis of pixel value needs to be done before anything else, so the values are pristine.
    1919    if (options->doMask || options->doShutter || options->doFlat || options->doPhotom) {
    20         pmReadoutGenerateMask(input);
     20        pmReadoutGenerateMask(input, options->satMask, options->badMask);
    2121    }
    2222    // apply the externally supplied mask to the input->mask pixels
     
    6868    if (options->doFlat) {
    6969        pmReadout *flat = pmFPAfileThisReadout(config->files, detview, "PPIMAGE.FLAT");
    70         if (!pmFlatField(input, flat)) {
     70        if (!pmFlatField(input, flat, options->flatMask)) {
    7171            return false;
    7272        }
  • trunk/ppImage/src/ppImageOptions.c

    r10214 r13593  
    2424    // default flags for various activities
    2525    options->doMask     = false;        // Mask bad pixels
    26     options->maskValue  = 0xff;         // Default mask value
     26    options->maskValue  = 0x00;         // Default mask value
     27    options->satMask    = 0x00;         // Saturated pixels
     28    options->badMask    = 0x00;         // Bad pixels
     29    options->flatMask   = 0x00;         // Bad flat pixels
    2730
    2831    options->doNonLin   = false;        // Non-linearity correction
     
    163166    // Mask recipe options
    164167    options->doMask = psMetadataLookupBool(NULL, recipe, "MASK");
    165     psMaskType maskValue = psMetadataLookupU8(&status, recipe, "MASK.VALUE");
     168    const char *masks = psMetadataLookupStr(&status, recipe, "MASK.VALUE");
    166169    if (status) {
    167         options->maskValue = maskValue;
    168     }
     170        options->maskValue = pmConfigMask(masks, config);
     171    }
     172    options->satMask = pmConfigMask("SAT", config);
     173    options->badMask = pmConfigMask("BAD", config);
     174    options->flatMask = pmConfigMask("FLAT", config);
     175
    169176
    170177    options->doBias = psMetadataLookupBool(NULL, recipe, "BIAS");
  • trunk/ppImage/src/ppImageOptions.h

    r9857 r13593  
    66    bool doMask;                        // Mask bad pixels
    77    psMaskType maskValue;               // apply this bit-mask to choose masked bits
     8    psMaskType satMask;                 // Mask value to give saturated pixels
     9    psMaskType badMask;                 // Mask value to give bad pixels
     10    psMaskType flatMask;                // Mask value to give bad flat pixels
    811
    912    bool doBias;                        // Bias subtraction
  • trunk/ppMerge/src/ppMergeCombine.c

    r12991 r13593  
    165165                        // If the mask value is set, we want to generate a mask
    166166                        if (options->combine->maskVal) {
    167                             pmReadoutSetMask(stack->data[i]);
     167                            pmReadoutSetMask(stack->data[i], options->satMask, options->badMask);
    168168                        }
    169169
  • trunk/ppMerge/src/ppMergeOptions.c

    r13246 r13593  
    5959    options->combine->maskVal = 0xff;
    6060    options->combine->weights = false;
     61    options->satMask = 0x00;
     62    options->badMask = 0x00;
    6163
    6264    return options;
     
    141143    OPTION_PARSE(options->combine->fracLow,  recipe, "FRACLOW",        F32);
    142144    OPTION_PARSE(options->combine->nKeep,    recipe, "NKEEP",          S32);
    143     OPTION_PARSE(options->combine->maskVal,  recipe, "MASKVAL",        S32);
    144145    OPTION_PARSE(options->combine->weights,  recipe, "WEIGHTS",        Bool);
    145146    OPTION_PARSE(options->fringeNum,         recipe, "FRINGE.NUM",     S32);
     
    153154    OPTION_PARSE(options->maskBad,           recipe, "MASK.BAD",       F32);
    154155
     156    const char *masks = psMetadataLookupStr(NULL, recipe, "MASKVAL");
     157    options->combine->maskVal = pmConfigMask(masks, config);
     158
    155159    options->combine->combine = parseStat(recipe, "COMBINE");
    156160    options->mean             = parseStat(recipe, "MEAN");
     
    238242    }
    239243
    240 
    241244#if 0
    242245    // Or you can set them individually
     
    249252    OPTION_PARSE(options->onOff, config->arguments, "-onoff", S32);
    250253
     254    // Masking options
     255    options->satMask = pmConfigMask("SAT", config);
     256    options->badMask = pmConfigMask("BAD", config);
     257
    251258    return options;
    252259}
  • trunk/ppMerge/src/ppMergeOptions.h

    r9996 r13593  
    3939    ppOnOff onOff;                      // On/off pairs?
    4040    pmCombineParams *combine;           // Combination parameters
     41    psMaskType satMask;                 // Mask value for saturated pixels
     42    psMaskType badMask;                 // Mask value for bad (low) pixels
    4143} ppMergeOptions;
    4244
  • trunk/ppStack/src/ppStackArguments.c

    r13557 r13593  
    6464}
    6565
     66// Get a mask value from the command-line or recipe, and add it to the arguments
     67#define VALUE_ARG_RECIPE_MASK(ARGNAME, RECIPENAME) { \
     68    bool mdok; \
     69    const char *name = psMetadataLookupStr(&mdok, arguments, ARGNAME); \
     70    if (!mdok || !name || strlen(name) == 0) { \
     71        name = psMetadataLookupStr(NULL, recipe, RECIPENAME); \
     72        if (!name) { \
     73            psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unable to find %s in recipe %s", \
     74                RECIPENAME, PPSTACK_RECIPE); \
     75            goto ERROR; \
     76        } \
     77    } \
     78    psMaskType value = pmConfigMask(name, config); \
     79    psMetadataAddU8(config->arguments, PS_LIST_TAIL, RECIPENAME, 0, NULL, value); \
     80}
     81
    6682// Get a string value from the command-line and add it to the target
    6783static bool valueArgStr(pmConfig *config,      // Configuration
     
    119135    VALUE_ARG_RECIPE_FLOAT("-convolve-rej", "CONVOLVE.REJ", F32);
    120136    VALUE_ARG_RECIPE_FLOAT("-extent",       "EXTENT",       F32);
    121     VALUE_ARG_RECIPE_INT("-mask-bad",       "MASK.BAD",     U8, 0);
    122     VALUE_ARG_RECIPE_INT("-mask-blank",     "MASK.BLANK",   U8, 0);
     137    VALUE_ARG_RECIPE_MASK("-mask-bad",      "MASK.BAD");
     138    VALUE_ARG_RECIPE_MASK("-mask-blank",    "MASK.BLANK");
    123139
    124140    psTrace("ppStack", 1, "Done reading command-line arguments\n");
  • trunk/ppSub/src/ppSubArguments.c

    r13509 r13593  
    5757    } \
    5858    psMetadataAdd##TYPE(config->arguments, PS_LIST_TAIL, RECIPENAME, 0, NULL, value); \
     59}
     60
     61// Get a mask value from the command-line or recipe, and add it to the arguments
     62#define VALUE_ARG_RECIPE_MASK(ARGNAME, RECIPENAME) { \
     63    bool mdok; \
     64    const char *name = psMetadataLookupStr(&mdok, arguments, ARGNAME); \
     65    if (!mdok || !name || strlen(name) == 0) { \
     66        name = psMetadataLookupStr(NULL, recipe, RECIPENAME); \
     67        if (!name) { \
     68            psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unable to find %s in recipe %s", \
     69                RECIPENAME, PPSUB_RECIPE); \
     70            goto ERROR; \
     71        } \
     72    } \
     73    psMaskType value = pmConfigMask(name, config); \
     74    psMetadataAddU8(config->arguments, PS_LIST_TAIL, RECIPENAME, 0, NULL, value); \
    5975}
    6076
     
    200216    VALUE_ARG_RECIPE_INT("-iter",        "ITER",            S32, 0);
    201217    VALUE_ARG_RECIPE_FLOAT("-rej",       "REJ",             F32);
    202     VALUE_ARG_RECIPE_INT("-mask-bad",    "MASK.BAD",        U8, 0);
    203     VALUE_ARG_RECIPE_INT("-mask-blank",  "MASK.BLANK",      U8, 0);
     218    VALUE_ARG_RECIPE_MASK("-mask-bad",   "MASK.BAD");
     219    VALUE_ARG_RECIPE_MASK("-mask-blank", "MASK.BLANK");
    204220
    205221    vectorArgRecipe(config, arguments, "-isis-widths", recipe, "ISIS.WIDTHS", config->arguments, PS_TYPE_F32);
  • trunk/ppSub/src/ppSubReadout.c

    r13508 r13593  
    4242    psMaskType maskBlank = psMetadataLookupU8(NULL, config->arguments, "MASK.BLANK"); // Mask for blank reg.
    4343
    44     if (!inRO->mask && !pmReadoutGenerateMask(inRO)) {
     44    psMaskType maskSat = pmConfigMask("SAT", config); // Mask for saturated pixels
     45    psMaskType maskLow = pmConfigMask("BAD", config); // Mask for bad (low) pixels
     46
     47    if (!inRO->mask && !pmReadoutGenerateMask(inRO, maskSat, maskLow)) {
    4548        psError(PS_ERR_UNKNOWN, false, "Unable to generate mask for input image");
    4649        return false;
     
    5053        return false;
    5154    }
    52     if (!refRO->mask && !pmReadoutGenerateMask(refRO)) {
     55    if (!refRO->mask && !pmReadoutGenerateMask(refRO, maskSat, maskLow)) {
    5356        psError(PS_ERR_UNKNOWN, false, "Unable to generate mask for reference image");
    5457        return false;
  • trunk/psphot/src/psphot.h

    r13411 r13593  
    5757int             pmSourceSortByY (const void **a, const void **b);
    5858bool            psphotGrowthCurve (pmReadout *readout, pmPSF *psf, bool ignore);
    59 bool            psphotMaskReadout (pmReadout *readout, psMetadata *recipe);
     59bool            psphotMaskReadout (pmReadout *readout, psMetadata *recipe, pmConfig *config);
    6060void            psphotSourceFreePixels (psArray *sources);
    6161
  • trunk/psphot/src/psphotMaskReadout.c

    r12792 r13593  
    11# include "psphotInternal.h"
    22
    3 bool psphotMaskReadout (pmReadout *readout, psMetadata *recipe) {
    4    
     3bool psphotMaskReadout (pmReadout *readout, psMetadata *recipe, pmConfig *config) {
     4
    55    bool status;
    66
     
    1919
    2020    // psImageKeepRegion assumes the region refers to the parent coordinates
    21     psImageKeepRegion (readout->mask, keep, "OR", PM_MASK_BAD);
     21    psImageKeepRegion (readout->mask, keep, "OR", pmConfigMask("BAD", config));
    2222
    2323    return true;
  • trunk/psphot/src/psphotReadout.c

    r13411 r13593  
    2424
    2525    // generate mask & weight images if they don't already exit
    26     if ((!readout->mask && !pmReadoutGenerateMask(readout)) ||
     26    if ((!readout->mask && !pmReadoutGenerateMask(readout, pmConfigMask("SAT", config),
     27                                                  pmConfigMask("BAD", config))) ||
    2728        (!readout->weight && !pmReadoutGenerateWeight(readout, true))) {
    2829        psError (PSPHOT_ERR_CONFIG, false, "trouble creating mask and/or weight");
     
    3738
    3839    // I have a valid mask, now mask in the analysis region of interest
    39     psphotMaskReadout (readout, recipe);
     40    psphotMaskReadout (readout, recipe, config);
    4041
    4142    // run a single-model test if desired
  • trunk/pswarp/src/pswarpArguments.c

    r13104 r13593  
    102102
    103103        // Get mask parameters
    104         psMaskType maskIn = psMetadataLookupU8(&status, recipe, "MASK.IN"); // Mask for input data
    105         if (!status) {
     104        psMaskType maskIn, maskPoor, maskBad; // Mask values for input, "poor" and "bad" pixels
     105
     106        psString maskNames = psMetadataLookupStr(&status, recipe, "MASK.IN");
     107         if (!status) {
    106108            maskIn = 0x00;
    107109            psWarning("MASK.IN is not set in the %s recipe --- defaulting to %x.", PSWARP_RECIPE, maskIn);
    108110        }
    109         psMaskType maskPoor = psMetadataLookupU8(&status, recipe, "MASK.POOR"); // Mask for "poor" warped data
     111        maskIn = pmConfigMask(maskNames, config); // Mask for input data
     112
     113        maskNames = psMetadataLookupStr(&status, recipe, "MASK.POOR");
    110114        if (!status) {
    111115            maskPoor = 0x00;
    112116            psWarning("MASK.POOR is not set in the %s recipe --- defaulting to %x.", PSWARP_RECIPE, maskPoor);
    113117        }
    114         psMaskType maskBad = psMetadataLookupU8(&status, recipe, "MASK.IN"); // Mask for bad warped data
     118        maskPoor = pmConfigMask(maskNames, config); // Mask for "poor" warped data
     119
     120        maskNames = psMetadataLookupStr(&status, recipe, "MASK.BAD");
    115121        if (!status) {
    116122            maskBad = 0x00;
    117123            psWarning("MASK.BAD is not set in the %s recipe --- defaulting to %x.", PSWARP_RECIPE, maskBad);
    118124        }
     125        maskBad = pmConfigMask(maskNames, config); // Mask for bad warped data
     126
    119127        float poorFrac = psMetadataLookupF32(&status, recipe, "POOR.FRAC"); // Frac of bad flux for a "poor"
    120128        if (!status) {
Note: See TracChangeset for help on using the changeset viewer.