Changeset 10574
- Timestamp:
- Dec 8, 2006, 10:46:16 AM (20 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/detrend/pmBias.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/detrend/pmBias.c
r10541 r10574 110 110 111 111 // Produce an overscan vector from an array of pixels 112 static psVector *overscanVector(pmOverscanOptions *overscanOpts, // Overscan options 112 static psVector *overscanVector(float *chi2, // chi^2 from fit 113 pmOverscanOptions *overscanOpts, // Overscan options 113 114 const psArray *pixels, // Array of vectors containing the pixel values 114 115 psStats *myStats // Statistic to use in reducing the overscan … … 145 146 146 147 // Fit the overscan, if required 148 psVector *fitted; // Fitted overscan values 147 149 switch (overscanOpts->fitType) { 148 150 case PM_FIT_NONE: 149 151 // No fitting --- that's easy. 152 fitted = psMemIncrRefCounter(reduced); 150 153 break; 151 154 case PM_FIT_POLY_ORD: … … 159 162 } 160 163 psVectorFitPolynomial1D(overscanOpts->poly, mask, 1, reduced, NULL, ordinate); 161 psFree(reduced); 162 reduced = psPolynomial1DEvalVector(overscanOpts->poly, ordinate); 164 fitted = psPolynomial1DEvalVector(overscanOpts->poly, ordinate); 163 165 break; 164 166 case PM_FIT_POLY_CHEBY: … … 172 174 } 173 175 psVectorFitPolynomial1D(overscanOpts->poly, mask, 1, reduced, NULL, ordinate); 174 psFree(reduced); 175 reduced = psPolynomial1DEvalVector(overscanOpts->poly, ordinate); 176 fitted = psPolynomial1DEvalVector(overscanOpts->poly, ordinate); 176 177 break; 177 178 case PM_FIT_SPLINE: … … 179 180 // input spline 180 181 overscanOpts->spline = psVectorFitSpline1D(reduced, ordinate); 181 psFree(reduced); 182 reduced = psSpline1DEvalVector(overscanOpts->spline, ordinate); 182 fitted = psSpline1DEvalVector(overscanOpts->spline, ordinate); 183 183 break; 184 184 default: … … 188 188 } 189 189 190 if (chi2) { 191 *chi2 = 0.0; // chi^2 (sort of) 192 for (int i = 0; i < reduced->n; i++) { 193 *chi2 += PS_SQR(fitted->data.F32[i] - reduced->data.F32[i]); 194 } 195 } 196 197 psFree(reduced); 190 198 psFree(ordinate); 191 199 psFree(mask); 192 200 193 return reduced;201 return fitted; 194 202 } 195 203 … … 273 281 // We do the regular overscan subtraction 274 282 bool readRows = psMetadataLookupBool(NULL, in->parent->concepts, "CELL.READDIR");// Read direction 283 float chi2 = NAN; // chi^2 from fit 275 284 276 285 if (readRows) { … … 301 310 302 311 // Reduce the overscans 303 psVector *reduced = overscanVector( overscanOpts, pixels, stats);312 psVector *reduced = overscanVector(&chi2, overscanOpts, pixels, stats); 304 313 psFree(pixels); 305 314 if (! reduced) { … … 344 353 345 354 // Reduce the overscans 346 psVector *reduced = overscanVector( overscanOpts, pixels, stats);355 psVector *reduced = overscanVector(&chi2, overscanOpts, pixels, stats); 347 356 psFree(pixels); 348 357 if (! reduced) { … … 364 373 case PM_FIT_POLY_CHEBY: { 365 374 psString comment = NULL; // Comment to add 366 psStringAppend(&comment, "Overscan fit : ");375 psStringAppend(&comment, "Overscan fit (chi^2: %.2f):", chi2); 367 376 psPolynomial1D *poly = overscanOpts->poly; // The polynomial 368 377 for (int i = 0; i < poly->nX; i++) { … … 376 385 psSpline1D *spline = overscanOpts->spline; // The spline 377 386 for (int i = 0; i < spline->n; i++) { 378 psStringAppend(&comment, "Overscan fit %d: ", i);387 psStringAppend(&comment, "Overscan fit (chi^2: %.2f) %d :", chi2, i); 379 388 psPolynomial1D *poly = spline->spline[i]; // i-th polynomial 380 389 for (int j = 0; j < poly->nX; j++) {
Note:
See TracChangeset
for help on using the changeset viewer.
