Changeset 29813
- Timestamp:
- Nov 23, 2010, 4:57:00 PM (15 years ago)
- Location:
- branches/czw_branch/20100817
- Files:
-
- 4 edited
-
ppImage/src/ppImageDetrendReadout.c (modified) (4 diffs)
-
psModules/src/detrend/pmBias.c (modified) (3 diffs)
-
psModules/src/detrend/pmBias.h (modified) (1 diff)
-
psModules/src/detrend/pmNonLinear.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/20100817/ppImage/src/ppImageDetrendReadout.c
r29486 r29813 51 51 } 52 52 53 // Subtract the overscan 54 if (options->doOverscan) { 55 if (!pmOverscanSubtract (input, options->overscan)) { 56 psError(PS_ERR_UNKNOWN, false, "Unable to subtract overscan."); 57 psFree(detview); 58 return false; 59 } 60 } 61 53 62 // Non-linearity correction 54 63 if (options->doNonLin) { … … 59 68 return(false); 60 69 } 61 /* ppImageDetrendNonLinear(detrend->input, input, options); */70 /* ppImageDetrendNonLinear(detrend->input, input, options); */ 62 71 } 63 72 … … 80 89 } 81 90 82 // Bias , dark and overscan subtraction are allmerged.83 if (options->doBias || options->doOverscan) {84 if (!pmBiasSubtract(input, options->overscan,bias, oldDark, view)) {91 // Bias and temperature-independent-dark subtraction are merged. 92 if (options->doBias) { 93 if (!pmBiasSubtract(input, bias, oldDark, view)) { 85 94 psError(PS_ERR_UNKNOWN, false, "Unable to subtract bias."); 86 95 psFree(detview); … … 88 97 } 89 98 } 90 99 91 100 // Weight on the basis of pixel value needs to be done after the overscan has been subtracted 92 101 if (options->doVarianceBuild) { -
branches/czw_branch/20100817/psModules/src/detrend/pmBias.c
r28405 r29813 163 163 } 164 164 165 bool pmBiasSubtract(pmReadout *in, pmOverscanOptions *overscanOpts,165 bool pmBiasSubtract(pmReadout *in, 166 166 pmReadout *bias, pmReadout *dark, const pmFPAview *view) 167 167 { … … 184 184 185 185 pmHDU *hdu = pmHDUFromReadout(in); // HDU of interest 186 187 if (!pmOverscanSubtract (in, overscanOpts)) {188 return false;189 }190 186 191 187 // Bias frame subtraction … … 247 243 psString timeString = psTimeToISO(time); // String with time 248 244 psFree(time); 249 psStringPrepend(&timeString, " Overscan/bias/dark processing completed at ");245 psStringPrepend(&timeString, "Bias/dark processing completed at "); 250 246 psMetadataAddStr(hdu->header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, 251 247 timeString, ""); -
branches/czw_branch/20100817/psModules/src/detrend/pmBias.h
r19432 r29813 21 21 /// bias (if non-NULL) and dark (if non-NULL) scaled by the CELL.DARKTIME concept. 22 22 bool pmBiasSubtract(pmReadout *in, ///< Input readout, to be overscan/bias/dark corrected 23 pmOverscanOptions *overscanOpts, ///< Options for overscan subtraction, or NULL24 23 pmReadout *bias, ///< Bias to subtract, or NULL 25 24 pmReadout *dark, ///< Dark to scale and subtract, or NULL -
branches/czw_branch/20100817/psModules/src/detrend/pmNonLinear.c
r29678 r29813 10 10 #include "pmNonLinear.h" 11 11 12 psF32 pmNonLinearityMeasureNoisy(psF32 flux, psVector *correction_fluxes, psVector *correction_factors); 12 13 pmReadout *pmNonLinearityPolynomial(pmReadout *inputReadout, const psPolynomial1D *input1DPoly) 13 14 { … … 201 202 int seq = -1; 202 203 if ((dir == 0) && (pos < image->numCols/2)) { 203 seq = pos - 1;204 seq = pos ; 204 205 if (seq < 0) continue; 205 206 fluxVector = x_lo_flux->data[seq]; … … 207 208 } 208 209 if ((dir == 0) && (pos > image->numCols/2)) { 209 seq = pos - 1+ numBorder - image->numCols;210 seq = pos + numBorder - image->numCols; 210 211 if (seq >= image->numCols) continue; 211 212 fluxVector = x_hi_flux->data[seq]; … … 213 214 } 214 215 if ((dir == 1) && (pos < image->numRows/2)) { 215 seq = pos - 1;216 seq = pos; 216 217 if (seq < 0) continue; 217 218 fluxVector = y_lo_flux->data[seq]; … … 219 220 } 220 221 if ((dir == 1) && (pos > image->numRows/2)) { 221 seq = pos - 1+ numBorder - image->numRows;222 seq = pos + numBorder - image->numRows; 222 223 if (seq >= image->numRows) continue; 223 224 fluxVector = y_hi_flux->data[seq]; … … 244 245 } 245 246 if (row_correction_fluxes == NULL) { 247 row_correction_factors = default_row_correction_factors; 246 248 row_correction_fluxes = default_row_correction_fluxes; 247 249 } … … 258 260 } 259 261 if (col_correction_fluxes == NULL) { 260 col_correction_fluxes = default_col_correction_fluxes; 262 col_correction_factors = default_col_correction_factors; 263 col_correction_fluxes = default_col_correction_fluxes; 261 264 } 262 265 … … 264 267 psF32 factor_row = pmNonLinearityMeasure(image->data.F32[i][j], row_correction_fluxes,row_correction_factors); 265 268 psF32 factor_col = pmNonLinearityMeasure(image->data.F32[i][j], col_correction_fluxes,col_correction_factors); 266 267 if (((i <= 9)&&(j <= 9))||((i == 9)&&(j == 5))) { // Print out if we're looking at a test case. 268 psTrace("psModules.camera",6,"Linearity: %d %d %s %f %f %f %d %d\n",i,j, 269 #if (0) 270 if (((i == 200)&&(j == 200))||((i == 9)&&(j == 5))) { // Print out if we're looking at a test case. 271 psF32 factor_row = pmNonLinearityMeasureNoisy(image->data.F32[i][j], row_correction_fluxes,row_correction_factors); 272 psF32 factor_col = pmNonLinearityMeasureNoisy(image->data.F32[i][j], col_correction_fluxes,col_correction_factors); 273 274 psTrace("psModules.nonlin",6,"Linearity: %d %d %s %f %f %f %d %d\n",i,j, 269 275 psMetadataLookupStr(NULL,inputReadout->parent->concepts,"CELL.NAME"), 270 276 image->data.F32[i][j],factor_row,factor_col,numBorder,numSamples); 271 psTrace("psModules. camera",6,"Linearity: R: %d %d %d C: %d %d %d\n",277 psTrace("psModules.nonlin",6,"Linearity: R: %d %d %d C: %d %d %d\n", 272 278 i,(i < numBorder),(image->numRows - i), 273 279 j,(j < numBorder),(image->numCols - j)); 274 280 275 # if (0) 276 psTrace("psModules.camera",6,"Linearity: V: "); 281 psTrace("psModules.nonlin",6,"Linearity: V: "); 277 282 for (int k = 0; k < numSamples; k++) { 278 psTrace("psModules.camera",6,"(%f %f) ", 279 col_correction_fluxes->data.F32[k],col_correction_factors->data.F32[k]); 283 psTrace("psModules.nonlin",6,"(%f %f) (%f %f) DDDD> (%f %f) (%f %f)", 284 col_correction_fluxes->data.F32[k],col_correction_factors->data.F32[k], 285 row_correction_fluxes->data.F32[k],row_correction_factors->data.F32[k], 286 default_col_correction_fluxes->data.F32[k],default_col_correction_factors->data.F32[k], 287 default_row_correction_fluxes->data.F32[k],default_row_correction_factors->data.F32[k]); 280 288 } 281 psTrace("psModules.camera",6,"\n"); 289 psTrace("psModules.nonlin",6,"\n"); 290 } // End Test case 291 #endif 292 // Apply correction to image data 293 #if (0) 294 if (((i == 200)&&(j == 200))||((i == 9)&&(j == 5))) { // Print out if we're looking at a test case. 295 psTrace("psModules.nonlin",4,"Applied Linearity Correction: %s %d %d : %f %f -> %f\n", 296 psMetadataLookupStr(NULL,inputReadout->parent->concepts,"CELL.NAME"), 297 i,j,image->data.F32[i][j],(factor_row + factor_col) / 2.0, 298 image->data.F32[i][j] + (factor_row + factor_col) / 2.0); 299 } 282 300 # endif 283 } // End Test case 284 285 // Apply correction to image data 286 image->data.F32[i][j] = image->data.F32[i][j] * ( factor_row * factor_col ) ; 301 image->data.F32[i][j] = image->data.F32[i][j] - ( factor_row + factor_col ) / 2.0; 302 287 303 } // End loop over columns 288 304 } // End loop over rows … … 314 330 bin = correction_fluxes->n - 1; 315 331 if (flux < correction_fluxes->data.F32[0]) { 316 return( 1.0);317 } 318 if (flux > correction_fluxes->data.F32[bin]) { 319 return(1.0); 320 } 332 return(0.0); 333 } 334 /* if (flux > correction_fluxes->data.F32[bin]) { */ 335 /* return(0.0); */ 336 /* } */ 321 337 322 338 for (int i = 0; i < correction_fluxes->n - 1; i++) { … … 338 354 /* PS_BIN_INTERPOLATE(result,correction_fluxes,correction_factors,bin,flux); */ 339 355 if (!isfinite(result)) { 340 result = 1.0;341 } 342 if (result <= 0) { 343 result = 1.0; 344 } 356 result = 0.0; 357 } 358 /* if (result <= 0) { */ 359 /* result = 1.0; */ 360 /* } */ 345 361 return(result); 346 362 } 347 348 349 363 364 psF32 pmNonLinearityMeasureNoisy(psF32 flux, psVector *correction_fluxes, psVector *correction_factors) { 365 // psS32 numPixels = 0; 366 psF32 result = 0; 367 psU32 bin = 0; 368 369 bin = correction_fluxes->n - 1; 370 psTrace("psModules.nonlin",6,"NLMN: %f %d %f %f\n",flux,bin,correction_fluxes->data.F32[0],correction_fluxes->data.F32[bin]); 371 if (flux < correction_fluxes->data.F32[0]) { 372 return(0.0); 373 } 374 /* if (flux > correction_fluxes->data.F32[bin]) { */ 375 /* return(0.0); */ 376 /* } */ 377 378 for (int i = 0; i < correction_fluxes->n - 1; i++) { 379 psTrace("psModules.nonlin",6,"NLMN: %f %d %f %f %f %f\n",flux,i,correction_fluxes->data.F32[i],correction_fluxes->data.F32[i], 380 correction_factors->data.F32[i],correction_factors->data.F32[i+1]); 381 if ((flux >= correction_fluxes->data.F32[i])&& 382 (flux < correction_fluxes->data.F32[i+1])) { 383 result = correction_factors->data.F32[i] + 384 (flux - correction_fluxes->data.F32[i]) * 385 ((correction_factors->data.F32[i+1] - correction_factors->data.F32[i]) / 386 (correction_fluxes->data.F32[i+1] - correction_fluxes->data.F32[i])); 387 continue; 388 } 389 } 390 391 /* PS_BIN_FOR_VALUE(bin,correction_fluxes,flux); */ 392 /* if ((bin < 0)||(bin > correction_fluxes->n)) { */ 393 /* return(1.0); */ 394 /* } */ 395 396 /* PS_BIN_INTERPOLATE(result,correction_fluxes,correction_factors,bin,flux); */ 397 if (!isfinite(result)) { 398 result = 0.0; 399 } 400 /* if (result <= 0) { */ 401 /* result = 1.0; */ 402 /* } */ 403 return(result); 404 } 405 406 407
Note:
See TracChangeset
for help on using the changeset viewer.
