IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 7715


Ignore:
Timestamp:
Jun 27, 2006, 6:03:35 PM (20 years ago)
Author:
Paul Price
Message:

Renaming pmReadoutSet{Mask,Weight} as pmReadoutGenerate{Mask,Weight}; adding pmReadoutSet{Mask,Weight}. These changes are in order to generate 'throwaway' masks and weights, in the case where we're using pmReadoutReadNext (which doesn't use the HDU).

Location:
trunk/psModules/src/camera
Files:
3 edited

Legend:

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

    r7432 r7715  
    9090//////////////////////////////////////////////////////////////////////////////////////////////////////////////
    9191
    92 bool pmReadoutSetMask(pmReadout *readout // Readout for which to set mask
     92bool pmReadoutSetMask(pmReadout *readout// Readout for which to set mask
    9393                     )
    9494{
    9595    PS_ASSERT_PTR_NON_NULL(readout, false);
     96    PS_ASSERT_IMAGE_NON_NULL(readout->image, false);
    9697
    9798    pmCell *cell = readout->parent;     // The parent cell
     
    111112    psTrace(__func__, 5, "Saturation: %f, bad: %f\n", saturation, bad);
    112113
    113     // Create the mask image if required
    114     if (!readout->mask) {
    115         psRegion *trimsec = psMetadataLookupPtr(&mdok, cell->concepts, "CELL.TRIMSEC"); // Trim section
    116         if (!mdok || psRegionIsNaN(*trimsec)) {
    117             psError(PS_ERR_IO, true, "CELL.TRIMSEC is not set --- unable to set mask.\n");
    118             return false;
    119         }
    120 
    121         pmHDU *hdu = pmHDUFromCell(cell);   // The HDU containing the cell's pixels
    122         PS_ASSERT_PTR_NON_NULL(hdu, false);
    123         if (!hdu->images && !pmHDUGenerateForCell(cell)) {
    124             psError(PS_ERR_UNKNOWN, false, "Unable to generate HDU for cell.\n");
    125             return false;
    126         }
    127 
    128         createParentMasks(hdu);
    129 
    130         // Need to identify which readout we're working with....
    131         long index = identifyReadout(hdu, readout); // Index of the readout
    132         if (index == -1) {
    133             psError(PS_ERR_UNKNOWN, true, "Unable to identify readout image in HDU.\n");
    134             return false;
    135         }
    136 
    137         psImage *mask = psImageSubset(hdu->masks->data[index], *trimsec); // The mask pixels
    138         if (!mask) {
    139             psString trimsecString = psRegionToString(*trimsec);
    140             psError(PS_ERR_UNKNOWN, false, "Unable to set mask from HDU with trimsec: %s.\n", trimsecString);
    141             psFree(trimsecString);
    142             return NULL;
    143         }
    144         psImageInit(mask, 0);
    145         readout->mask = mask;
    146     }
    147114
    148115    // Set up the mask
    149116    psImage *image = readout->image;    // The image pixels
     117    if (!readout->mask) {
     118        // Generate a (throwaway) mask image, if required
     119        readout->mask = psImageAlloc(image->numCols, image->numRows, PS_TYPE_U8);
     120    }
    150121    psImage *mask = readout->mask;      // The mask pixels
    151122    for (long i = 0; i < image->numRows; i++) {
     
    163134}
    164135
     136bool pmReadoutGenerateMask(pmReadout *readout // Readout for which to generate mask
     137                          )
     138{
     139    PS_ASSERT_PTR_NON_NULL(readout, false);
     140
     141    pmCell *cell = readout->parent;     // The parent cell
     142    bool mdok = true;                   // Status of MD lookup
     143
     144    // Create the mask image if required
     145    if (!readout->mask) {
     146        psRegion *trimsec = psMetadataLookupPtr(&mdok, cell->concepts, "CELL.TRIMSEC"); // Trim section
     147        if (!mdok || psRegionIsNaN(*trimsec)) {
     148            psError(PS_ERR_IO, true, "CELL.TRIMSEC is not set --- unable to set mask.\n");
     149            return false;
     150        }
     151
     152        pmHDU *hdu = pmHDUFromCell(cell);   // The HDU containing the cell's pixels
     153        PS_ASSERT_PTR_NON_NULL(hdu, false);
     154        if (!hdu->images && !pmHDUGenerateForCell(cell)) {
     155            psError(PS_ERR_UNKNOWN, false, "Unable to generate HDU for cell.\n");
     156            return false;
     157        }
     158
     159        createParentMasks(hdu);
     160
     161        // Need to identify which readout we're working with....
     162        long index = identifyReadout(hdu, readout); // Index of the readout
     163        if (index == -1) {
     164            psError(PS_ERR_UNKNOWN, true, "Unable to identify readout image in HDU.\n");
     165            return false;
     166        }
     167
     168        psImage *mask = psImageSubset(hdu->masks->data[index], *trimsec); // The mask pixels
     169        if (!mask) {
     170            psString trimsecString = psRegionToString(*trimsec);
     171            psError(PS_ERR_UNKNOWN, false, "Unable to set mask from HDU with trimsec: %s.\n", trimsecString);
     172            psFree(trimsecString);
     173            return false;
     174        }
     175        psImageInit(mask, 0);
     176        readout->mask = mask;
     177    }
     178
     179    return pmReadoutSetMask(readout);
     180}
     181
    165182bool pmReadoutSetWeight(pmReadout *readout // Readout for which to set weight
    166183                       )
     
    182199        return false;
    183200    }
     201
     202    // Set weight image to the variance in ADU = f/g + rn^2
     203    psImage *image = readout->image;    // The image pixels
     204    readout->weight = (psImage*)psBinaryOp(readout->weight, image, "/", psScalarAlloc(gain, PS_TYPE_F32));
     205    readout->weight = (psImage*)psBinaryOp(readout->weight, readout->weight, "+",
     206                                           psScalarAlloc(readnoise*readnoise/gain/gain, PS_TYPE_F32));
     207
     208    return true;
     209}
     210
     211bool pmReadoutGenerateWeight(pmReadout *readout // Readout for which to generate weight
     212                            )
     213{
     214    PS_ASSERT_PTR_NON_NULL(readout, false);
     215
     216    pmCell *cell = readout->parent;     // The parent cell
     217    bool mdok = true;                   // Status of MD lookup
    184218
    185219    // Create the weight image if required
     
    213247                    trimsecString);
    214248            psFree(trimsecString);
    215             return NULL;
     249            return false;
    216250        }
    217251        psImageInit(weight, 0);
     
    219253    }
    220254
    221     // Set weight image to the variance in ADU = f/g + rn^2
    222     psImage *image = readout->image;    // The image pixels
    223     psBinaryOp(readout->weight, image, "/", psScalarAlloc(gain, PS_TYPE_F32));
    224     psBinaryOp(readout->weight, readout->weight, "+",
    225                psScalarAlloc(readnoise*readnoise/gain/gain, PS_TYPE_F32));
    226 
    227     return true;
    228 }
    229 
    230 bool pmCellSetMaskWeight(pmCell *cell // Cell for which to set weights
    231                         )
     255    return pmReadoutSetWeight(readout);
     256}
     257
     258bool pmCellGenerateMaskWeight(pmCell *cell // Cell for which to set weights
     259                             )
    232260{
    233261    PS_ASSERT_PTR_NON_NULL(cell, false);
     
    237265    for (int i = 0; i < readouts->n; i++) {
    238266        pmReadout *readout = readouts->data[i]; // The readout
    239         success |= pmReadoutSetMask(readout);
    240         success |= pmReadoutSetWeight(readout);
     267        success |= pmReadoutGenerateMask(readout);
     268        success |= pmReadoutGenerateWeight(readout);
    241269    }
    242270
     
    244272}
    245273
    246 bool pmReadoutSetMaskWeight(pmReadout *readout // Readout for which to set mask and weights
    247                            )
     274bool pmReadoutGenerateMaskWeight(pmReadout *readout // Readout for which to set mask and weights
     275                                )
    248276{
    249277    PS_ASSERT_PTR_NON_NULL(readout, false);
     
    251279    bool success;
    252280
    253     success |= pmReadoutSetMask(readout);
    254     success |= pmReadoutSetWeight(readout);
     281    success |= pmReadoutGenerateMask(readout);
     282    success |= pmReadoutGenerateWeight(readout);
    255283
    256284    return success;
  • trunk/psModules/src/camera/pmFPAMaskWeight.h

    r7309 r7715  
    2121} pmMaskValue;
    2222
     23// These functions set an extant mask/weight (or create a throwaway one).
     24// The throwaway case is intended for when the user is iterating using pmReadoutReadNext, in which case
     25// the HDU can't be generated
    2326bool pmReadoutSetMask(pmReadout *readout // Readout for which to set mask
    2427                     );
    2528bool pmReadoutSetWeight(pmReadout *readout // Readout for which to set weight
    2629                       );
    27 bool pmCellSetMaskWeight(pmCell *cell // Cell for which to set weights
    28                         );
    29 bool pmReadoutSetMaskWeight(pmReadout *readout // Readout for which to set weights
    30                            );
     30
     31// These functions generate a mask/weight suitable for output (complete with HDU entry) and then set them.
     32bool pmReadoutGenerateMask(pmReadout *readout // Readout for which to generate mask
     33                          );
     34bool pmReadoutGenerateWeight(pmReadout *readout // Readout for which to generate weight
     35                            );
     36
     37// These functions are conveniences for pmReadoutGenerateMask and pmReadoutGenerateWeight.
     38bool pmCellGenerateMaskWeight(pmCell *cell // Cell for which to generate mask and weights
     39                             );
     40bool pmReadoutGenerateMaskWeight(pmReadout *readout // Readout for which to generate mask and weights
     41                                );
    3142
    3243
  • trunk/psModules/src/camera/pmFPARead.c

    r7604 r7715  
    159159//
    160160// Note that this doesn't put pixels in the HDU.  It is therefore NOT COMPATIBLE with pmCellWrite,
    161 // pmChipWrite, and pmFPAWrite.  Use pmReadoutWriteNext to write the data that's read by this function.
     161// pmChipWrite, and pmFPAWrite (or any function that uses or creates an HDU for that matter).
     162// Use pmReadoutWriteNext to write the data that's read by this function.
    162163bool pmReadoutReadNext(pmReadout *readout, // Readout into which to read
    163164                       psFits *fits,    // FITS file from which to read
Note: See TracChangeset for help on using the changeset viewer.