IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 13, 2008, 11:20:36 AM (18 years ago)
Author:
Paul Price
Message:

Allowing CELL.READNOISE to be specified in ADU instead of electrons. This requires updating the parsed value with the gain when it's available. Added a check at the principal (only?) place this value is used (pmReadoutSetWeight) so that errors can be trapped.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/concepts/pmConceptsUpdate.c

    r13034 r20095  
    2525        // Check for cell concepts updates
    2626
    27         bool xStatus, yStatus; // Status of MD lookups
    28         psImageBinning *binning = psImageBinningAlloc();
    29         binning->nXbin = psMetadataLookupS32(&xStatus, cell->concepts, "CELL.XBIN");
    30         binning->nYbin = psMetadataLookupS32(&yStatus, cell->concepts, "CELL.YBIN");
    31         if (!xStatus || !yStatus) {
    32             // XXX should this be an error condition?
    33             psFree (binning);
    34             return true;
    35         }
    36         if (!binning->nXbin || !binning->nXbin) {
    37             // XXX should this be an error condition?
    38             psFree (binning);
    39             return true;
    40         }
     27        // CELL.READNOISE needs to be updated if specified in ADU
     28        if (psMetadataLookup(cell->concepts, "CELL.READNOISE.UPDATE")) {
     29            float gain = psMetadataLookupF32(NULL, cell->concepts, "CELL.GAIN"); // Gain for cell
     30            if (isfinite(gain)) {
     31                psMetadataItem *rn = psMetadataLookup(cell->concepts, "CELL.READNOISE"); // Read noise
     32                psAssert(rn && rn->type == PS_TYPE_F32, "Should be of the correct type");
     33                rn->data.F32 *= gain;
     34                psMetadataRemoveKey(cell->concepts, "CELL.READNOISE.UPDATE");
     35            }
     36        }
     37
     38        bool xStatus, yStatus; // Status of MD lookups
     39        psImageBinning *binning = psImageBinningAlloc();
     40        binning->nXbin = psMetadataLookupS32(&xStatus, cell->concepts, "CELL.XBIN");
     41        binning->nYbin = psMetadataLookupS32(&yStatus, cell->concepts, "CELL.YBIN");
     42        if (!xStatus || !yStatus) {
     43            // XXX should this be an error condition?
     44            psFree (binning);
     45            return true;
     46        }
     47        if (!binning->nXbin || !binning->nXbin) {
     48            // XXX should this be an error condition?
     49            psFree (binning);
     50            return true;
     51        }
    4152
    4253        // CELL.TRIMSEC needs to be updated for the binning
    4354        if (psMetadataLookup(cell->concepts, "CELL.TRIMSEC.UPDATE")) {
    44             psRegion *trimsec = psMetadataLookupPtr(NULL, cell->concepts, "CELL.TRIMSEC"); // Trim section
    45             *trimsec = psImageBinningSetRuffRegion (binning, *trimsec);
    46             // force integer pixels : truncate x0, roundup x1:
    47             trimsec->x0 = (int)trimsec->x0;
    48             if (trimsec->x1 > (int)trimsec->x1) {
    49                 trimsec->x1 = (int)trimsec->x1 + 1;
    50             } else {
    51                 trimsec->x1 = (int)trimsec->x1;
    52             }           
    53             trimsec->y0 = (int)trimsec->y0;
    54             if (trimsec->y1 > (int)trimsec->y1) {
    55                 trimsec->y1 = (int)trimsec->y1 + 1;
    56             } else {
    57                 trimsec->y1 = (int)trimsec->y1;
    58             }           
    59             psMetadataRemoveKey(cell->concepts, "CELL.TRIMSEC.UPDATE");
     55            psRegion *trimsec = psMetadataLookupPtr(NULL, cell->concepts, "CELL.TRIMSEC"); // Trim section
     56            *trimsec = psImageBinningSetRuffRegion (binning, *trimsec);
     57            // force integer pixels : truncate x0, roundup x1:
     58            trimsec->x0 = (int)trimsec->x0;
     59            if (trimsec->x1 > (int)trimsec->x1) {
     60                trimsec->x1 = (int)trimsec->x1 + 1;
     61            } else {
     62                trimsec->x1 = (int)trimsec->x1;
     63            }
     64            trimsec->y0 = (int)trimsec->y0;
     65            if (trimsec->y1 > (int)trimsec->y1) {
     66                trimsec->y1 = (int)trimsec->y1 + 1;
     67            } else {
     68                trimsec->y1 = (int)trimsec->y1;
     69            }
     70            psMetadataRemoveKey(cell->concepts, "CELL.TRIMSEC.UPDATE");
    6071        }
    6172
    6273        // CELL.BIASSEC needs to be updated for the binning
    6374        if (psMetadataLookup(cell->concepts, "CELL.BIASSEC.UPDATE")) {
    64             psList *biassecs = psMetadataLookupPtr(NULL, cell->concepts, "CELL.BIASSEC"); // Bias sections
    65             psListIterator *biassecsIter = psListIteratorAlloc(biassecs, PS_LIST_HEAD, true); // Iterator
    66             psRegion *biassec; // Bias region, from iteration
    67             while ((biassec = psListGetAndIncrement(biassecsIter))) {
    68                 *biassec = psImageBinningSetRuffRegion (binning, *biassec);
    69                 // force integer pixels : truncate x0, roundup x1:
    70                 biassec->x0 = (int)biassec->x0;
    71                 if (biassec->x1 > (int)biassec->x1) {
    72                     biassec->x1 = (int)biassec->x1 + 1;
    73                 } else {
    74                     biassec->x1 = (int)biassec->x1;
    75                 }               
    76                 biassec->y0 = (int)biassec->y0;
    77                 if (biassec->y1 > (int)biassec->y1) {
    78                     biassec->y1 = (int)biassec->y1 + 1;
    79                 } else {
    80                     biassec->y1 = (int)biassec->y1;
    81                 }               
    82             }
    83             psFree(biassecsIter);
    84             psMetadataRemoveKey(cell->concepts, "CELL.BIASSEC.UPDATE");
     75            psList *biassecs = psMetadataLookupPtr(NULL, cell->concepts, "CELL.BIASSEC"); // Bias sections
     76            psListIterator *biassecsIter = psListIteratorAlloc(biassecs, PS_LIST_HEAD, true); // Iterator
     77            psRegion *biassec; // Bias region, from iteration
     78            while ((biassec = psListGetAndIncrement(biassecsIter))) {
     79                *biassec = psImageBinningSetRuffRegion (binning, *biassec);
     80                // force integer pixels : truncate x0, roundup x1:
     81                biassec->x0 = (int)biassec->x0;
     82                if (biassec->x1 > (int)biassec->x1) {
     83                    biassec->x1 = (int)biassec->x1 + 1;
     84                } else {
     85                    biassec->x1 = (int)biassec->x1;
     86                }
     87                biassec->y0 = (int)biassec->y0;
     88                if (biassec->y1 > (int)biassec->y1) {
     89                    biassec->y1 = (int)biassec->y1 + 1;
     90                } else {
     91                    biassec->y1 = (int)biassec->y1;
     92                }
     93            }
     94            psFree(biassecsIter);
     95            psMetadataRemoveKey(cell->concepts, "CELL.BIASSEC.UPDATE");
    8596        }
    86         psFree (binning);
     97        psFree (binning);
    8798    }
    8899
Note: See TracChangeset for help on using the changeset viewer.