Changeset 20596
- Timestamp:
- Nov 8, 2008, 2:30:32 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/concepts/pmConceptsAverage.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/concepts/pmConceptsAverage.c
r20576 r20596 102 102 } 103 103 104 float averageWithDropouts (psList *sources, char *name) { 105 106 bool status; 107 108 float sum = 0; 109 int nCells = 0; // Number of cells; 110 psListIterator *sourcesIter = psListIteratorAlloc(sources, PS_LIST_HEAD, false); // Iterator for sources 111 pmCell *cell = NULL; // Source cell from iteration 112 while ((cell = psListGetAndIncrement(sourcesIter))) { 113 if (!cell) { 114 continue; 115 } 116 117 float value = psMetadataLookupF32(&status, cell->concepts, name); 118 if (!status) continue; 119 if (!isfinite(value)) continue; 120 121 sum += value; 122 nCells++; 123 } 124 psFree (sourcesIter); 125 126 float average = sum / nCells; 127 return average; 128 } 104 129 105 130 // Set a variety of concepts in a cell by averaging over several … … 111 136 PS_ASSERT_INT_POSITIVE(sources->n, false); 112 137 113 float gain = 0.0; // Gain114 float readnoise = 0.0; // Read noise115 138 float saturation = INFINITY; // Saturation level 116 139 float bad = -INFINITY; // Bad level 117 float exposure = 0.0; // Exposure time118 float darktime = 0.0; // Dark time119 140 double time = 0.0; // Time of observation 120 141 psTimeType timeSys = 0; // Time system … … 124 145 int xParity = 0, yParity = 0; // Parity 125 146 147 float gain = averageWithDropouts (sources, "CELL.GAIN"); 148 float readnoise = averageWithDropouts (sources, "CELL.READNOISE"); 149 float exposure = averageWithDropouts (sources, "CELL.EXPOSURE"); 150 float darktime = averageWithDropouts (sources, "CELL.DARKTIME"); 151 152 // other concepts are a bit more "special" 126 153 int nCells = 0; // Number of cells; 127 154 psListIterator *sourcesIter = psListIteratorAlloc(sources, PS_LIST_HEAD, false); // Iterator for sources … … 133 160 134 161 nCells++; 135 gain += psMetadataLookupF32(NULL, cell->concepts, "CELL.GAIN");136 readnoise += psMetadataLookupF32(NULL, cell->concepts, "CELL.READNOISE");137 exposure += psMetadataLookupF32(NULL, cell->concepts, "CELL.EXPOSURE");138 darktime += psMetadataLookupF32(NULL, cell->concepts, "CELL.DARKTIME");139 162 psTime *cellTime = psMetadataLookupPtr(NULL, cell->concepts, "CELL.TIME"); 140 163 time += psTimeToMJD(cellTime); … … 200 223 psFree(sourcesIter); 201 224 202 gain /= (float)nCells; 203 readnoise /= (float)nCells; 204 exposure /= (float)nCells; 205 darktime /= (float)nCells; 206 time /= (double)nCells; 225 time /= nCells; 207 226 208 227 MD_UPDATE(target->concepts, "CELL.GAIN", F32, gain);
Note:
See TracChangeset
for help on using the changeset viewer.
