Changeset 20095 for trunk/psModules/src/concepts/pmConceptsUpdate.c
- Timestamp:
- Oct 13, 2008, 11:20:36 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/concepts/pmConceptsUpdate.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/concepts/pmConceptsUpdate.c
r13034 r20095 25 25 // Check for cell concepts updates 26 26 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 } 41 52 42 53 // CELL.TRIMSEC needs to be updated for the binning 43 54 if (psMetadataLookup(cell->concepts, "CELL.TRIMSEC.UPDATE")) { 44 psRegion *trimsec = psMetadataLookupPtr(NULL, cell->concepts, "CELL.TRIMSEC"); // Trim section45 *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"); 60 71 } 61 72 62 73 // CELL.BIASSEC needs to be updated for the binning 63 74 if (psMetadataLookup(cell->concepts, "CELL.BIASSEC.UPDATE")) { 64 psList *biassecs = psMetadataLookupPtr(NULL, cell->concepts, "CELL.BIASSEC"); // Bias sections65 psListIterator *biassecsIter = psListIteratorAlloc(biassecs, PS_LIST_HEAD, true); // Iterator66 psRegion *biassec; // Bias region, from iteration67 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"); 85 96 } 86 psFree (binning);97 psFree (binning); 87 98 } 88 99
Note:
See TracChangeset
for help on using the changeset viewer.
