IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 18430


Ignore:
Timestamp:
Jul 6, 2008, 6:23:02 PM (18 years ago)
Author:
eugene
Message:

set mask bits based on recipe and input mask image headers

Location:
branches/eam_branch_20080706
Files:
1 added
9 edited

Legend:

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

    r16249 r18430  
    6262                    continue;
    6363                }
     64
     65                // XXX set the options->*Mask values here (after the mask images have been loaded
     66                // and before any of the value are used)
     67                ppImageSetMaskBits (config, options);
    6468
    6569                // perform the detrend analysis
  • branches/eam_branch_20080706/ppImage/src/ppImageMetadataStats.c

    r16249 r18430  
    1414    }
    1515
     16    // XXX should this be just options->maskValue?? I think so...
    1617    psMaskType maskVal = options->satMask | options->badMask | options->maskValue;
    1718
  • branches/eam_branch_20080706/ppImage/src/ppImageMosaic.c

    r13901 r18430  
    3434    // XXX mosaic the chip, making a deep copy.  this has the side effect of making the
    3535    // output image products pure trimmed images, but also increases the memory footprint.
     36    // XXX I think we should be using options->maskValue
    3637    status = pmChipMosaic(outChip, inChip, true, options->blankMask);
    3738    return status;
  • branches/eam_branch_20080706/ppImage/src/ppImageOptions.c

    r17688 r18430  
    191191
    192192    // Mask recipe options
     193    // XXX we cannot set these values here; wait until just before ppImageDetrend
    193194    options->doMask = psMetadataLookupBool(NULL, recipe, "MASK");
     195
     196# if (0)   
    194197    const char *masks = psMetadataLookupStr(&status, recipe, "MASK.VALUE");
    195198    if (status) {
     
    201204    options->blankMask = pmConfigMask("BLANK", config);
    202205    // XXX should it be an error for these to not exist?
     206# endif
    203207
    204208    options->doBias = psMetadataLookupBool(NULL, recipe, "BIAS");
  • branches/eam_branch_20080706/ppImage/src/ppImageParseCamera.c

    r18422 r18430  
    2020    }
    2121
    22     // if MASK or WEIGHT was supplied on command line, bind files to 'input'
     22    // if MASK or WEIGHT was supplied on command line, bind files to 'input'.
    2323    // the mask and weight will be mosaicked with the image
    2424    pmFPAfile *inputMask = pmFPAfileBindFromArgs(&status, input, config, "PPIMAGE.INPUT.MASK", "PPIMAGE.INPUT.MASK");
     
    2727        return NULL;
    2828    }
    29     if (inputMask && inputMask->type != PM_FPA_FILE_MASK) {
     29    if (inputMask) {
     30      if (inputMask->type != PM_FPA_FILE_MASK) {
    3031        psError(PS_ERR_IO, true, "PPIMAGE.INPUT.MASK is not of type MASK");
    3132        return NULL;
     33      }
     34      // XXX need to load the mask bit names from one of the headers
     35      // this grabs the first available hdu : no guarantee that it will be valid, though
     36      pmHDU *hdu = pmHDUGetFirst (inputMask->fpa);
     37      if (!hdu) {
     38        psError(PS_ERR_IO, true, "no valid HDU for PPIMAGE.INPUT.MASK");
     39        return NULL;
     40      }
     41      if (!pmConfigMaskReadHeader (config, hdu->header)) {
     42        psError(PS_ERR_IO, false, "error in mask bits");
     43        return NULL;
     44      }
    3245    }
    3346
     
    6679    }
    6780    if (options->doMask) {
     81
    6882        if (!ppImageDefineFile (config, input->fpa, "PPIMAGE.MASK", "MASK", PM_FPA_FILE_MASK, PM_DETREND_TYPE_MASK)) {
    6983            psError (PS_ERR_IO, false, "Can't find a mask image source");
     
    7185            return NULL;
    7286        }
    73         // Need to read the names of bit masks from the mask header and set them in the recipe
     87        // XXX have ppImageDefineFile return the pmFPAfile?
     88        pmFPAfile *mask = psMetadataLookupPtr(&status, config->files, "PPIMAGE.MASK");
     89        psAssert (mask, "mask not defined?  not possible!");
     90
     91        // Need to read the names of bit masks from the mask header and set them in the
     92        // recipe.  If we are loading this from the detrend db, this action will happen
     93        // when the file is resolved.
     94        if (!mask->detrend) {
     95            // XXX need to load the mask bit names from one of the headers
     96            // this grabs the first available hdu : no guarantee that it will be valid, though
     97            pmHDU *hdu = pmHDUGetFirst (mask->fpa);
     98            if (!hdu) {
     99                psError(PS_ERR_IO, true, "no valid HDU for PPIMAGE.INPUT.MASK");
     100                return NULL;
     101            }
     102            // XXX is this consistent with the pmConfigMaskReadHeader call above?
     103            if (!pmConfigMaskReadHeader (config, hdu->header)) {
     104                psError(PS_ERR_IO, false, "error in mask bits");
     105                return NULL;
     106            }
     107        }
    74108    }
    75109    if (options->doShutter) {
  • branches/eam_branch_20080706/ppImage/src/ppImagePixelStats.c

    r14000 r18430  
    1010    bool mdok;              // Status of MD lookup
    1111
     12    // XXX should this be just options->maskValue?? I think so...
    1213    psMaskType maskVal = options->satMask | options->badMask | options->maskValue;
    1314
  • branches/eam_branch_20080706/ppImage/src/ppImageReplaceBackground.c

    r18255 r18430  
    4141
    4242    // define the mask value to be used in ppImage
     43    // XXX should this be just options->maskValue?? I think so...  (but it should certainly include flat!)
    4344    psMaskType maskVal  = options->satMask | options->badMask | options->flatMask | options->blankMask;
    4445
  • branches/eam_branch_20080706/psModules/src/camera/pmFPAfileIO.c

    r18330 r18430  
    792792          }
    793793
     794          // XXX if we have a mask file, then we need to read the mask bit names
     795          // defined for this file
     796          if (file->type == PM_FPA_FILE_MASK) {
     797            if (!pmConfigMaskReadHeader (config, phu)) {
     798                psError(PS_ERR_IO, false, "error in mask bits");
     799                return false;
     800            }
     801          }
     802
    794803          // determine the current format from the header
    795804          // determine camera if not specified already
  • branches/eam_branch_20080706/psModules/src/config/pmConfigMask.c

    r18425 r18430  
    4040}
    4141
    42 // replace the named masks in the recipe with values in the header
     42// replace the named masks in the recipe with values in the header:
     43// replace only the names in the header in the recipe
    4344void pmConfigMasksReadHeader (pmConfig *config, psMetadata *header) {
    4445
     
    4950    }
    5051
    51     int nMask = 0;
     52    int nMask = psMetadataLookupS32 (&status, header, "MSKNUM");
     53    if (!status) {
     54        psError(PS_ERR_UNKNOWN, true, "Unable to find MSKNUM in header.");
     55        return false;
     56    }
    5257
    53     psMetadataIterator *iter = psMetadataIteratorAlloc(recipe, PS_LIST_HEAD, NULL); // Iterator
     58    for (int i = 0; i < nMask; i++) {
    5459
    55     psMetadataItem *item;               // Item from iteration
    56     while ((item = psMetadataGetAndIncrement(iter))) {
     60        snprintf (namekey,  64, "MSKNAM%02d", i);
     61        snprintf (valuekey, 64, "MSKVAL%02d", i);
    5762
    58         if (item->type != PS_DATA_U8) {
    59             psWarning("mask recipe entry %s is not a bit value\n", item->name);
    60             continue;
     63        char *name = psMetadataLookupStr (&status, header, namekey);
     64        psU8 bit = psMetadataLookupU8 (&status, header, valuekey);
     65
     66        // XXX validate that bit is a 2^n value?
     67
     68        psMetadataItem *item = psMetadataLookup (header, name);
     69        if (!item) {
     70          psWarning("mask recipe entry %s not in recipe\n", name);
     71          psMetadataAddU8 (recipe, PS_LIST_TAIL, name, 0, "Bitmask bit value", bit);
     72        } else {
     73          item->data.U8 = bit;
    6174        }
    62 
    63         snprintf (namekey,  64, "MSKNAM%02d", nMask);
    64         snprintf (valuekey, 64, "MSKVAL%02d", nMask);
    65 
    66         psMetadataAddStr (header, PS_LIST_TAIL, namekey, 0, "Bitmask bit name", item->name);
    67         psMetadataAddU8 (header, PS_LIST_TAIL, valuekey, 0, "Bitmask bit value", item->data.U8);
    68         nMask ++;
    6975    }
    7076   
    71     psMetadataAddU8 (header, PS_LIST_TAIL, "MSKNUM", 0, "Bitmask bit count", nMask);
    7277    return true;
    7378}
     
    102107    }
    103108   
    104     psMetadataAddU8 (header, PS_LIST_TAIL, "MSKNUM", 0, "Bitmask bit count", nMask);
     109    psMetadataAddS32 (header, PS_LIST_TAIL, "MSKNUM", 0, "Bitmask bit count", nMask);
    105110    return true;
    106111}
Note: See TracChangeset for help on using the changeset viewer.