IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 11225


Ignore:
Timestamp:
Jan 21, 2007, 3:09:29 PM (19 years ago)
Author:
magnier
Message:

use the existing weight image, if available; added a note

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/camera/pmFPAMaskWeight.c

    r11157 r11225  
    142142}
    143143
     144// XXX this function creates the mask pixels, or uses the existing mask
     145// pixels.  currently, it will set mask bits if (value <= BAD) or (value >= SATURATION)
     146// should we optionally ignore these tests?
    144147bool pmReadoutGenerateMask(pmReadout *readout)
    145148{
     
    230233}
    231234
     235// this function creates the weight pixels, or uses the existing weight pixels.  it will set
     236// the noise pixel values only if the weight image is not supplied
    232237bool pmReadoutGenerateWeight(pmReadout *readout, bool poisson)
    233238{
     
    238243
    239244    // Create the weight image if required
    240     if (!readout->weight) {
    241         psRegion *trimsec = psMetadataLookupPtr(&mdok, cell->concepts, "CELL.TRIMSEC"); // Trim section
    242         if (!mdok || psRegionIsNaN(*trimsec)) {
    243             psError(PS_ERR_IO, true, "CELL.TRIMSEC is not set --- unable to set weight.\n");
    244             return false;
    245         }
    246 
    247         pmHDU *hdu = pmHDUFromCell(cell);   // The HDU containing the cell's pixels
    248         PS_ASSERT_PTR_NON_NULL(hdu, false);
    249         if (!hdu->images && !pmHDUGenerateForCell(cell)) {
    250             psError(PS_ERR_UNKNOWN, false, "Unable to generate HDU for cell.\n");
    251             return false;
    252         }
    253 
    254         createParentWeights(hdu);
    255 
    256         // Need to identify which readout we're working with....
    257         long index = identifyReadout(hdu, readout); // Index of the readout
    258         if (index == -1) {
    259             psError(PS_ERR_UNKNOWN, true, "Unable to identify readout image in HDU.\n");
    260             return false;
    261         }
    262 
    263         psImage *weight = psImageSubset(hdu->weights->data[index], *trimsec); // The weight pixels
    264         if (!weight) {
    265             psString trimsecString = psRegionToString(*trimsec);
    266             psError(PS_ERR_UNKNOWN, false, "Unable to set weight from HDU with trimsec: %s.\n",
    267                     trimsecString);
    268             psFree(trimsecString);
    269             return false;
    270         }
    271         psImageInit(weight, 0);
    272         readout->weight = weight;
    273     }
     245    if (readout->weight)
     246        return true;
     247
     248    psRegion *trimsec = psMetadataLookupPtr(&mdok, cell->concepts, "CELL.TRIMSEC"); // Trim section
     249    if (!mdok || psRegionIsNaN(*trimsec)) {
     250        psError(PS_ERR_IO, true, "CELL.TRIMSEC is not set --- unable to set weight.\n");
     251        return false;
     252    }
     253
     254    pmHDU *hdu = pmHDUFromCell(cell);   // The HDU containing the cell's pixels
     255    PS_ASSERT_PTR_NON_NULL(hdu, false);
     256    if (!hdu->images && !pmHDUGenerateForCell(cell)) {
     257        psError(PS_ERR_UNKNOWN, false, "Unable to generate HDU for cell.\n");
     258        return false;
     259    }
     260
     261    createParentWeights(hdu);
     262
     263    // Need to identify which readout we're working with....
     264    long index = identifyReadout(hdu, readout); // Index of the readout
     265    if (index == -1) {
     266        psError(PS_ERR_UNKNOWN, true, "Unable to identify readout image in HDU.\n");
     267        return false;
     268    }
     269
     270    psImage *weight = psImageSubset(hdu->weights->data[index], *trimsec); // The weight pixels
     271    if (!weight) {
     272        psString trimsecString = psRegionToString(*trimsec);
     273        psError(PS_ERR_UNKNOWN, false, "Unable to set weight from HDU with trimsec: %s.\n",
     274                trimsecString);
     275        psFree(trimsecString);
     276        return false;
     277    }
     278    psImageInit(weight, 0);
     279    readout->weight = weight;
    274280
    275281    return pmReadoutSetWeight(readout, poisson);
Note: See TracChangeset for help on using the changeset viewer.