Changeset 30868
- Timestamp:
- Mar 10, 2011, 5:28:23 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20110213/psphot/src/psphotModelBackground.c
r30785 r30868 67 67 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); 68 68 69 float dXsample = psMetadataLookupF32(&status, recipe, "BACKGROUND.XSAMPLE"); 70 if (!status) dXsample = 1.0; 71 float dYsample = psMetadataLookupF32(&status, recipe, "BACKGROUND.YSAMPLE"); 72 if (!status) dYsample = 1.0; 73 69 74 // subtract this amount extra from the sky 70 75 float SKY_BIAS = psMetadataLookupF32 (&status, recipe, "SKY_BIAS"); … … 84 89 PS_STAT_ROBUST_QUARTILE | 85 90 PS_STAT_CLIPPED_MEAN | 86 PS_STAT_FITTED_MEAN | 87 PS_STAT_FITTED_MEAN_V2 | 88 PS_STAT_FITTED_MEAN_V3 | 89 PS_STAT_FITTED_MEAN_V4))) { 91 PS_STAT_FITTED_MEAN))) { 90 92 statsOptionLocation = PS_STAT_FITTED_MEAN; 91 93 } … … 95 97 statsOptionWidth = PS_STAT_SAMPLE_STDEV; 96 98 } else if (statsOptionLocation & (PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_QUARTILE)) { 97 #if 1 98 statsOptionWidth = PS_STAT_ROBUST_STDEV; // not set; => NaN 99 #else 100 statsOptionWidth = PS_STAT_FITTED_STDEV; 101 #endif 99 statsOptionWidth = PS_STAT_ROBUST_STDEV; 102 100 } else if (statsOptionLocation & PS_STAT_FITTED_MEAN) { 103 101 statsOptionWidth = PS_STAT_FITTED_STDEV; 104 102 } else if (statsOptionLocation & PS_STAT_CLIPPED_MEAN) { 105 103 statsOptionWidth = PS_STAT_CLIPPED_STDEV; 106 } else if (statsOptionLocation & PS_STAT_FITTED_MEAN_V2) {107 statsOptionWidth = PS_STAT_FITTED_STDEV_V2;108 } else if (statsOptionLocation & PS_STAT_FITTED_MEAN_V3) {109 statsOptionWidth = PS_STAT_FITTED_STDEV_V3;110 } else if (statsOptionLocation & PS_STAT_FITTED_MEAN_V4) {111 statsOptionWidth = PS_STAT_FITTED_STDEV_V4;112 104 } else { 113 105 psAbort("Unable to estimate variance of selected statsOptionLocations 0x%x", statsOptionLocation); … … 138 130 stats->clipSigma = psMetadataLookupF32 (&status, recipe, "SKY_CLIP_SIGMA"); 139 131 if (!status) { 140 if ( (stats->options & PS_STAT_FITTED_MEAN) || (stats->options & PS_STAT_FITTED_MEAN_V2)) {132 if (stats->options & PS_STAT_FITTED_MEAN) { 141 133 stats->clipSigma = 1.0; 142 134 } else { … … 160 152 int nFailures = 0; 161 153 psImageBackgroundInit(); 154 155 // we have Nx * Ny model points, but we can use a window which is larger (or smaller) than 156 // 1 superpixel. If we have a window of size dXsample * dYsample, then the regions run from: 157 // (ix + 0.5) - dX to (ix + 0.5) + dX 162 158 163 159 // measure clipped median for subimages … … 168 164 169 165 // convert the ruff grid cell to the equivalent fine grid cell 170 // XXX we need to watch out for row0,col0171 ruffRegion = psRegionSet (ix, ix + 1, iy, iy + 1);166 ruffRegion = psRegionSet (ix + 0.5 - 0.5*dXsample, ix + 0.5 + 0.5*dXsample, 167 iy + 0.5 - 0.5*dYsample, iy + 0.5 + 0.5*dYsample); 172 168 fineRegion = psImageBinningSetFineRegion (binning, ruffRegion); 173 169 fineRegion = psRegionForImage (image, fineRegion); … … 205 201 206 202 if (gotX && gotY) { 207 (void) psTraceSetLevel ("psLib.math.vectorFittedStats _v4", 6);203 (void) psTraceSetLevel ("psLib.math.vectorFittedStats", 6); 208 204 (void) psTraceSetLevel ("psLib.math.vectorRobustStats", 6); 209 205 } else { 210 (void) psTraceSetLevel ("psLib.math.vectorFittedStats _v4", 0);206 (void) psTraceSetLevel ("psLib.math.vectorFittedStats", 0); 211 207 (void) psTraceSetLevel ("psLib.math.vectorRobustStats", 0); 212 208 } … … 270 266 for (int iy = 0; iy < model->numRows; iy++) { 271 267 for (int ix = 0; ix < model->numCols; ix++) { 272 if ( !isnan(modelData[iy][ix])) {268 if (isfinite(modelData[iy][ix])) { 273 269 Value += modelData[iy][ix]; 274 270 ValueStdev += modelStdevData[iy][ix]; … … 286 282 if (jx < 0) continue; 287 283 if (jx >= model->numCols) continue; 284 if (!isfinite(modelData[jy][jx])) continue; 288 285 value += modelData[jy][jx]; 289 286 count += 1.0; 290 287 } 291 288 } 292 if (count > 0) modelData[iy][ix] = value / count; 289 if (count > 0) { 290 psLogMsg ("psphot", PS_LOG_DETAIL, "patching background %d, %d: %f (%d pts)\n", ix, iy, (value / count), (int) count); 291 modelData[iy][ix] = value / count; 292 } 293 293 } 294 294 }
Note:
See TracChangeset
for help on using the changeset viewer.
