IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 11, 2008, 8:35:04 AM (18 years ago)
Author:
eugene
Message:

total overhaul of mask handling

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20080706/ppImage/src/ppImageSetMaskBits.c

    r18430 r18472  
    77bool ppImageSetMaskBits (pmConfig *config, ppImageOptions *options) {
    88
    9     // Mask recipe options
    10     const char *masks = psMetadataLookupStr(&status, recipe, "MASK.VALUE");
    11     if (status) {
    12         options->maskValue = pmConfigMask(masks, config);
     9    if (!pmConfigMaskSetBits (&options->maskValue, &options->markValue, config)) {
     10        psError (PS_ERR_UNKNOWN, true, "Unable to define the mask bit values");
     11        return false;
    1312    }
    1413
    15     darkMask           = pmConfigMask("DARK",     config);
    16     options->flatMask  = pmConfigMask("FLAT",     config);
    17     options->blankMask = pmConfigMask("BLANK",    config);
    18     detectorMask       = pmConfigMask("DETECTOR", config);
     14    // at this point we know we have valid values for required entries SAT, BAD, FLAT, BLANK:
    1915
    20     options->satMask   = pmConfigMask("SAT",      config);
    21     options->badMask   = pmConfigMask("BAD",      config);
     16    // mask for non-linear flat corrections
     17    options->flatMask = pmConfigMaskGet("FLAT", config);
     18    psAssert (options->flatMask, "flat mask not set");
    2219
    23     rangeMask          = pmConfigMask("RANGE",    config);
     20    // mask for non-existent data  (default to DETECTOR if not defined)
     21    options->blankMask = pmConfigMaskGet("BLANK", config);
     22    psAssert (options->blankMask, "blank mask not set");
    2423
    25     crMask             = pmConfigMask("CR",       config);
    26     ghostMask          = pmConfigMask("GHOST",    config);
     24    // mask for saturated data  (default to RANGE if not defined)
     25    options->satMask = pmConfigMaskGet("SAT", config);
     26    psAssert (options->satMask, "sat mask not set");
     27   
     28    // mask for below-range data  (default to RANGE if not defined)
     29    options->badMask = pmConfigMaskGet("BAD", config);
     30    psAssert (options->badMask, "bad mask not set");
    2731
    28     // XXX it should be an error for these to not exist
    29     if (!options->flatMask) {
    30       psWarning ("FLAT MASK is not set");
     32    // save MASK and MARK on the PSPHOT recipe
     33    psMetadata *recipe = psMetadataLookupPtr (NULL, config->recipes, PSPHOT_RECIPE);
     34    if (!recipe) {
     35        psError(PSPHOT_ERR_CONFIG, false, "missing recipe %s", PSPHOT_RECIPE);
     36        return false;
    3137    }
    32     if (!options->flatMask) {
    33       psWarning ("FLAT MASK is not set");
    34     }
     38
     39    // set maskValue and markValue in the psphot recipe
     40    psMetadataAddU8 (recipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "user-defined mask", options->maskValue);
     41    psMetadataAddU8 (recipe, PS_LIST_TAIL, "MARK.PSPHOT", PS_META_REPLACE, "user-defined mask", options->markValue);
    3542
    3643    return true;
Note: See TracChangeset for help on using the changeset viewer.