Changeset 30036 for trunk/psModules/src/concepts/pmConceptsAverage.c
- Timestamp:
- Dec 14, 2010, 4:00:32 PM (15 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/concepts/pmConceptsAverage.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/concepts/pmConceptsAverage.c
r29603 r30036 136 136 return average; 137 137 } 138 float medianWithDropouts (psList *sources, char *name) { 139 140 bool status; 141 142 psListIterator *sourcesIter = psListIteratorAlloc(sources, PS_LIST_HEAD, false); // Iterator for sources 143 pmCell *cell = NULL; // Source cell from iteration 144 145 psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEDIAN); 146 psVector *values = psVectorAlloc(sources->n, PS_TYPE_F32); 147 int nvalues = 0; 148 while ((cell = psListGetAndIncrement(sourcesIter))) { 149 if (!cell) { 150 continue; 151 } 152 153 float value = psMetadataLookupF32(&status, cell->concepts, name); 154 if (!status) continue; 155 if (!isfinite(value)) continue; 156 157 values->data.F32[nvalues++] = value; 158 } 159 psFree (sourcesIter); 160 if (!nvalues) { 161 psWarning("no valid values found for %s\n", name); 162 psFree(values); 163 psFree(stats); 164 return INFINITY; 165 } 166 if (!(values = psVectorRealloc(values, nvalues))) { 167 psWarning("failed to reallocate values vector for %s\n", name); 168 psFree(stats); 169 return INFINITY; 170 } 171 if (!psVectorStats(stats, values, NULL, NULL, 0)) { 172 psWarning("psVectorStats failed for %s\n", name); 173 psFree(values); 174 psFree(stats); 175 return INFINITY; 176 } 177 178 psF32 median = psStatsGetValue(stats, PS_STAT_SAMPLE_MEDIAN); 179 180 psFree(values); 181 psFree(stats); 182 183 return median; 184 } 138 185 139 186 // Set a variety of concepts in a cell by averaging over several … … 145 192 PS_ASSERT_INT_POSITIVE(sources->n, false); 146 193 147 float saturation = INFINITY; // Saturation level148 194 float bad = -INFINITY; // Bad level 149 195 double time = 0.0; // Time of observation … … 158 204 float exposure = averageWithDropouts (sources, "CELL.EXPOSURE"); 159 205 float darktime = averageWithDropouts (sources, "CELL.DARKTIME"); 206 float saturation = medianWithDropouts(sources, "CELL.SATURATION"); 160 207 161 208 // other concepts are a bit more "special" … … 221 268 } 222 269 223 float cellSaturation = psMetadataLookupF32(NULL, cell->concepts, "CELL.SATURATION");224 if (cellSaturation > 10000) {225 // do not allow invalid values to polute this calculation226 // XXX really need to do this on the basis of the fraction of the cell that contributes..227 // if a cell is completely masked, it should not be included.228 if (cellSaturation < saturation) {229 saturation = cellSaturation;230 }231 }232 270 float cellBad = psMetadataLookupF32(NULL, cell->concepts, "CELL.BAD"); 233 271 if (cellBad > bad) {
Note:
See TracChangeset
for help on using the changeset viewer.
