IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 4, 2008, 3:10:25 PM (18 years ago)
Author:
eugene
Message:

merge changes from eam_branch_20080229: better flag definitions, cleanup footprint code (move into psphotFindDetections), push mask selection into called functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/psphotMaskReadout.c

    r13900 r16820  
    11# include "psphotInternal.h"
    22
    3 bool psphotMaskReadout (pmReadout *readout, psMetadata *recipe, psMaskType maskVal) {
     3// generate mask and weight if not defined, additional mask for restricted subregion
     4bool psphotSetMaskAndWeight (pmConfig *config, pmReadout *readout, psMetadata *recipe) {
    45
    56    bool status;
     7
     8    // ** Interpret the mask values:
     9
     10    // single-bit named masks
     11    psMaskType maskMark = pmConfigMask("MARK",     config); // Mask value for marking
     12    psMetadataAddU8 (recipe, PS_LIST_TAIL, "MASK.MARK", PS_META_REPLACE, "user-defined mask", maskMark);
     13
     14    psMaskType maskSat  = pmConfigMask("SAT",      config); // Mask value for saturated pixels
     15    psMetadataAddU8 (recipe, PS_LIST_TAIL, "MASK.SAT", PS_META_REPLACE, "user-defined mask", maskSat);
     16
     17    psMaskType maskBad  = pmConfigMask("BAD",      config); // Mask value for bad pixels
     18    psMetadataAddU8 (recipe, PS_LIST_TAIL, "MASK.BAD", PS_META_REPLACE, "user-defined mask", maskBad);
     19
     20    // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
     21    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "PSPHOT"); // Mask value for bad pixels
     22    if (!maskVal) {
     23      const char *maskValStr = psMetadataLookupStr(NULL, recipe, "MASKVAL"); // String with mask names
     24      if (!maskValStr) {
     25        psError(PSPHOT_ERR_CONFIG, false, "Missing recipe item: MASKVAL(STR)");
     26        return false;
     27      }
     28      maskVal = pmConfigMask(maskValStr, config); // Mask values to mask against
     29      psMetadataAddU8 (recipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "user-defined mask", maskVal);
     30      assert (maskVal);
     31    }
     32
     33    // generate mask & weight images if they don't already exit
     34    if (!readout->mask) {
     35        if (!pmReadoutGenerateMask(readout, maskSat, maskBad)) {
     36            psError (PSPHOT_ERR_CONFIG, false, "trouble creating mask");
     37            return false;
     38        }
     39    }
     40    if (!readout->weight) {
     41        if (!pmReadoutGenerateWeight(readout, true)) {
     42            psError (PSPHOT_ERR_CONFIG, false, "trouble creating weight");
     43            return false;
     44        }
     45    }
    646
    747    // mask the excluded outer pixels
     
    1959
    2060    // psImageKeepRegion assumes the region refers to the parent coordinates
    21     psImageKeepRegion (readout->mask, keep, "OR", maskVal);
     61    psImageKeepRegion (readout->mask, keep, "OR", maskBad);
     62
     63    // test output of files at this stage
     64    if (psTraceGetLevel("psphot") >= 5) {
     65        psphotSaveImage (NULL, readout->image,  "image.fits");
     66        psphotSaveImage (NULL, readout->mask,   "mask.fits");
     67        psphotSaveImage (NULL, readout->weight, "weight.fits");
     68    }
    2269
    2370    return true;
Note: See TracChangeset for help on using the changeset viewer.