Changeset 7849 for trunk/psModules/src/camera/pmFPAMosaic.c
- Timestamp:
- Jul 7, 2006, 7:21:12 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/camera/pmFPAMosaic.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/camera/pmFPAMosaic.c
r7755 r7849 4 4 #include "pmFPA.h" 5 5 #include "pmHDU.h" 6 #include "pmConceptsAverage.h" 6 7 #include "pmHDUUtils.h" 7 8 #include "pmFPAMosaic.h" … … 27 28 if ((value) > (max)) { \ 28 29 (max) = (value); \ 29 }30 31 // Update a metadata entry directly32 #define MD_UPDATE(MD, NAME, TYPE, VALUE) \33 { \34 psMetadataItem *item = psMetadataLookup(MD, NAME); \35 item->data.TYPE = VALUE; \36 30 } 37 31 … … 529 523 530 524 return mosaic; 531 }532 533 534 // Set the concepts in the new cell, based on the values in the old one535 static bool cellConcepts(pmCell *target,// Target cell536 psList *sources, // Source cells537 int xBin, int yBin, // Binning538 psRegion *trimsec // The trim section539 )540 {541 assert(target);542 assert(sources);543 assert(xBin > 0 && yBin > 0);544 assert(trimsec);545 546 bool success = true; // Result of setting everything547 float gain = 0.0; // Gain548 float readnoise = 0.0; // Read noise549 float saturation = INFINITY; // Saturation level550 float bad = -INFINITY; // Bad level551 float exposure = 0.0; // Exposure time552 float darktime = 0.0; // Dark time553 double time = 0.0; // Time of observation554 psTimeType timeSys = 0; // Time system555 int readdir = 0; // Cell read direction556 557 int nCells = 0; // Number of cells;558 psListIterator *sourcesIter = psListIteratorAlloc(sources, PS_LIST_HEAD, false); // Iterator for sources559 pmCell *cell = NULL; // Source cell from iteration560 while ((cell = psListGetAndIncrement(sourcesIter))) {561 if (!cell) {562 continue;563 }564 565 nCells++;566 gain += psMetadataLookupF32(NULL, cell->concepts, "CELL.GAIN");567 readnoise += psMetadataLookupF32(NULL, cell->concepts, "CELL.READNOISE");568 exposure += psMetadataLookupF32(NULL, cell->concepts, "CELL.EXPOSURE");569 darktime += psMetadataLookupF32(NULL, cell->concepts, "CELL.DARKTIME");570 psTime *cellTime = psMetadataLookupPtr(NULL, cell->concepts, "CELL.TIME");571 time += psTimeToMJD(cellTime);572 if (nCells == 1) {573 timeSys = psMetadataLookupS32(NULL, cell->concepts, "CELL.TIMESYS");574 readdir = psMetadataLookupS32(NULL, cell->concepts, "CELL.READDIR");575 } else {576 if (timeSys != psMetadataLookupS32(NULL, cell->concepts, "CELL.TIMESYS")) {577 psLogMsg(__func__, PS_LOG_ERROR, "Differing time systems in use: %d vs %d\n", timeSys,578 psMetadataLookupS32(NULL, cell->concepts, "CELL.TIMESYS"));579 success = false;580 }581 if (readdir != psMetadataLookupS32(NULL, cell->concepts, "CELL.READDIR")) {582 psLogMsg(__func__, PS_LOG_ERROR, "Differing cell read directions in use: %d vs %d\n", readdir,583 psMetadataLookupS32(NULL, cell->concepts, "CELL.READDIR"));584 success = false;585 }586 }587 588 float cellSaturation = psMetadataLookupF32(NULL, cell->concepts, "CELL.SATURATION");589 if (cellSaturation < saturation) {590 saturation = cellSaturation;591 }592 float cellBad = psMetadataLookupF32(NULL, cell->concepts, "CELL.BAD");593 if (cellBad > bad) {594 bad = cellBad;595 }596 }597 psFree(sourcesIter);598 599 gain /= (float)nCells;600 readnoise /= (float)nCells;601 exposure /= (float)nCells;602 darktime /= (float)nCells;603 time /= (double)nCells;604 605 MD_UPDATE(target->concepts, "CELL.GAIN", F32, gain);606 MD_UPDATE(target->concepts, "CELL.READNOISE", F32, readnoise);607 MD_UPDATE(target->concepts, "CELL.SATURATION", F32, saturation);608 MD_UPDATE(target->concepts, "CELL.BAD", F32, bad);609 MD_UPDATE(target->concepts, "CELL.EXPOSURE", F32, exposure);610 MD_UPDATE(target->concepts, "CELL.DARKTIME", F32, darktime);611 MD_UPDATE(target->concepts, "CELL.TIMESYS", S32, timeSys);612 MD_UPDATE(target->concepts, "CELL.X0", S32, 0);613 MD_UPDATE(target->concepts, "CELL.Y0", S32, 0);614 MD_UPDATE(target->concepts, "CELL.XPARITY", S32, 1);615 MD_UPDATE(target->concepts, "CELL.YPARITY", S32, 1);616 MD_UPDATE(target->concepts, "CELL.XBIN", S32, xBin);617 MD_UPDATE(target->concepts, "CELL.YBIN", S32, yBin);618 MD_UPDATE(target->concepts, "CELL.READDIR", S32, readdir);619 620 // CELL.TIME needs special care621 {622 psMetadataItem *timeItem = psMetadataLookup(target->concepts, "CELL.TIME");623 psFree(timeItem->data.V);624 timeItem->data.V = psTimeFromMJD(time);625 }626 627 // CELL.TRIMSEC needs special care628 {629 psMetadataItem *trimsecItem = psMetadataLookup(target->concepts, "CELL.TRIMSEC");630 psFree(trimsecItem->data.V);631 trimsecItem->data.V = psMemIncrRefCounter(trimsec);632 }633 634 return success;635 525 } 636 526 … … 1105 995 // Set the concepts for the target cell 1106 996 psList *sourceCells = psArrayToList(source->cells); // List of cells 1107 cellConcepts(targetCell, sourceCells, xBin, yBin, chipRegion);997 pmConceptsAverageCells(targetCell, sourceCells, xBin, yBin, chipRegion, NULL); 1108 998 psFree(sourceCells); 1109 999 psFree(chipRegion); … … 1211 1101 } 1212 1102 } 1213 cellConcepts(targetCell, sourceCells, xBin, yBin, fpaRegion);1103 pmConceptsAverageCells(targetCell, sourceCells, xBin, yBin, fpaRegion, NULL); 1214 1104 psFree(sourceCells); 1215 1105 psFree(fpaRegion);
Note:
See TracChangeset
for help on using the changeset viewer.
