IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 6586


Ignore:
Timestamp:
Mar 14, 2006, 4:37:16 PM (20 years ago)
Author:
Paul Price
Message:

Adding back in pmCellSetWeights

Location:
branches/rel10_ifa/psModules/src/astrom
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • branches/rel10_ifa/psModules/src/astrom/Makefile.am

    r6575 r6586  
    66        pmFPA.c \
    77        pmFPAConstruct.c \
     8        pmFPAMaskWeight.c \
    89        pmFPARead.c \
    910        pmHDU.c \
     
    2627        pmFPA.h \
    2728        pmFPAConstruct.h \
     29        pmFPAMaskWeight.h \
    2830        pmFPARead.h \
    2931        pmHDU.h \
  • branches/rel10_ifa/psModules/src/astrom/pmFPA.c

    r6552 r6586  
    1212* XXX: Should we implement non-linear cell->chip transforms?
    1313*
    14 *  @version $Revision: 1.1.4.2 $ $Name: not supported by cvs2svn $
    15 *  @date $Date: 2006-03-09 03:08:08 $
     14*  @version $Revision: 1.1.4.3 $ $Name: not supported by cvs2svn $
     15*  @date $Date: 2006-03-15 02:37:16 $
    1616*
    1717*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    601601}
    602602
    603 #if 0
    604 bool pmCellSetWeights(pmCell *cell // Cell for which to set weights
    605                      )
    606 {
    607     float gain = psMetadataLookupF32(NULL, cell->concepts, "CELL.GAIN"); // Cell gain
    608     float readnoise = psMetadataLookupF32(NULL, cell->concepts, "CELL.READNOISE"); // Cell read noise
    609     psRegion *trimsec = psMetadataLookupPtr(NULL, cell->concepts, "CELL.TRIMSEC"); // Trim section
    610     float saturation = psMetadataLookupF32(NULL, cell->concepts, "CELL.SATURATION"); // Saturation level
    611     float bad = psMetadataLookupF32(NULL, cell->concepts, "CELL.BAD"); // Bad level
    612 
    613     pmHDU *hdu = cell->hdu;             // The data unit, containing the weight and mask originals
    614     if (!hdu) {
    615         pmChip *chip = cell->parent;    // The parent chip
    616         if (chip->hdu) {
    617             hdu = chip->hdu;
    618         } else {
    619             pmFPA *fpa = chip->parent;  // The parent FPA
    620             hdu = fpa->hdu;
    621             if (!hdu) {
    622                 psError(PS_ERR_UNKNOWN, true, "Unable to find the HDU in the hierarchy!\n");
    623                 return false;
    624             }
    625         }
    626     }
    627 
    628     psArray *pixels = hdu->images;      // Array of images
    629     psArray *weights = hdu->weights;    // Array of weight images
    630     psArray *masks = hdu->masks;        // Array of mask images
    631     // Generate the weights and masks if required
    632     if (! weights) {
    633         weights = psArrayAlloc(pixels->n);
    634         for (int i = 0; i < pixels->n; i++) {
    635             psImage *image = pixels->data[i];
    636             weights->data[i] = psImageAlloc(image->numCols, image->numRows, PS_TYPE_F32);
    637             psImageInit(weights->data[i], 0.0);
    638         }
    639         hdu->weights = weights;
    640     }
    641     if (! masks) {
    642         masks = psArrayAlloc(pixels->n);
    643         for (int i = 0; i < pixels->n; i++) {
    644             psImage *image = pixels->data[i];
    645             masks->data[i] = psImageAlloc(image->numCols, image->numRows, PS_TYPE_U8);
    646             psImageInit(masks->data[i], 0);
    647         }
    648         hdu->masks = masks;
    649     }
    650 
    651     // Set the pixels
    652     psArray *readouts = cell->readouts; // Array of readouts
    653     for (int i = 0; i < readouts->n; i++) {
    654         pmReadout *readout = readouts->data[i]; // The readout of interest
    655 
    656         if (! readout->weight) {
    657             readout->weight = psMemIncrRefCounter(psImageSubset(weights->data[i], *trimsec));
    658         }
    659         if (! readout->mask) {
    660             readout->mask = psMemIncrRefCounter(psImageSubset(masks->data[i], *trimsec));
    661         }
    662 
    663         // Set up the mask
    664         psImage *image = readout->image;// Pixels
    665         psImage *mask = readout->mask;  // Mask image
    666         for (int i = 0; i < image->numRows; i++) {
    667             for (int j = 0; j < image->numCols; j++) {
    668                 if (image->data.F32[i][j] > saturation) {
    669                     mask->data.U8[i][j] = PM_MASK_SAT;
    670                 }
    671                 if (image->data.F32[i][j] < bad) {
    672                     mask->data.U8[i][j] = PM_MASK_BAD;
    673                 }
    674             }
    675         }
    676 
    677         // Set weight image to the variance = g*f + rn^2
    678         psBinaryOp(readout->weight, image, "/", psScalarAlloc(gain, PS_TYPE_F32));
    679         psBinaryOp(readout->weight, readout->weight, "+",
    680                    psScalarAlloc(readnoise*readnoise/gain/gain, PS_TYPE_F32));
    681     }
    682 
    683     return true;
    684 }
    685 
    686 #endif
     603
Note: See TracChangeset for help on using the changeset viewer.