Changeset 26894 for trunk/psphot/src/psphotModelBackground.c
- Timestamp:
- Feb 10, 2010, 7:36:29 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/psphotModelBackground.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphotModelBackground.c
r26452 r26894 30 30 31 31 // Generate the background model 32 static bool backgroundModel(psImage *model, // Model image 33 psImage *modelStdev, // Model stdev image 34 psMetadata *analysis, // Analysis metadata for outputs 35 pmReadout *readout, // Readout for which to generate a background model 36 psImageBinning *binning, // Binning parameters 37 const pmConfig *config // Configuration 38 ) 32 // generate the median in NxN boxes, clipping heavily 33 // linear interpolation to generate full-scale model 34 // 35 // NOTE that the 'analysis' metedata pass in here is used to store the binning information. 36 // This may be the analysis for this readout, but it may be the analysis for the pmFPAfile 37 // corresponding to the model. Other information about the background model is saved on the 38 // readout->analysis 39 static bool psphotModelBackgroundReadout(psImage *model, // Model image 40 psImage *modelStdev, // Model stdev image 41 psMetadata *analysis, // Analysis metadata for outputs 42 pmReadout *readout, // Readout for which to generate a background model 43 psImageBinning *binning, // Binning parameters 44 const pmConfig *config // Configuration 45 ) 39 46 { 40 47 psTimerStart ("psphot.background"); … … 138 145 139 146 // we save the binning structure for use in psphotMagnitudes 140 psMetadataAddPtr(analysis, PS_LIST_TAIL, "PSPHOT.BACKGROUND.BINNING", 141 PS_DATA_UNKNOWN | PS_META_REPLACE, "Background binning", binning); 147 psMetadataAddPtr(analysis, PS_LIST_TAIL, "PSPHOT.BACKGROUND.BINNING", PS_DATA_UNKNOWN | PS_META_REPLACE, "Background binning", binning); 142 148 143 149 psF32 **modelData = model->data.F32; … … 304 310 psLogMsg ("psphot", PS_LOG_INFO, "built background image: %f sec\n", psTimerMark ("psphot.background")); 305 311 306 psMetadataAddF32(re cipe, PS_LIST_TAIL, "SKY_MEAN", PS_META_REPLACE, "sky mean", Value);307 psMetadataAddF32(re cipe, PS_LIST_TAIL, "SKY_STDEV", PS_META_REPLACE, "sky stdev", ValueStdev);312 psMetadataAddF32(readout->analysis, PS_LIST_TAIL, "SKY_MEAN", PS_META_REPLACE, "sky mean", Value); 313 psMetadataAddF32(readout->analysis, PS_LIST_TAIL, "SKY_STDEV", PS_META_REPLACE, "sky stdev", ValueStdev); 308 314 psLogMsg ("psphot", PS_LOG_INFO, "image sky : mean %f stdev %f", Value, ValueStdev); 309 315 … … 314 320 PS_STAT_MAX); 315 321 psImageStats (statsBck, model, NULL, 0); 316 psMetadataAddF32 (recipe, PS_LIST_TAIL, "MSKY_MN", 317 PS_META_REPLACE, "sky model mean", statsBck->sampleMean); 318 psMetadataAddF32 (recipe, PS_LIST_TAIL, "MSKY_SIG", 319 PS_META_REPLACE, "sky model stdev", statsBck->sampleStdev); 320 psMetadataAddF32 (recipe, PS_LIST_TAIL, "MSKY_MAX", 321 PS_META_REPLACE, "sky model maximum value", statsBck->max); 322 psMetadataAddF32 (recipe, PS_LIST_TAIL, "MSKY_MIN", 323 PS_META_REPLACE, "sky model minimum value", statsBck->min); 324 psMetadataAddS32 (recipe, PS_LIST_TAIL, "MSKY_NX", 325 PS_META_REPLACE, "sky model size (x)", model->numCols); 326 psMetadataAddS32 (recipe, PS_LIST_TAIL, "MSKY_NY", 327 PS_META_REPLACE, "sky model size (y)", model->numRows); 322 psMetadataAddF32 (readout->analysis, PS_LIST_TAIL, "MSKY_MN", PS_META_REPLACE, "sky model mean", statsBck->sampleMean); 323 psMetadataAddF32 (readout->analysis, PS_LIST_TAIL, "MSKY_SIG", PS_META_REPLACE, "sky model stdev", statsBck->sampleStdev); 324 psMetadataAddF32 (readout->analysis, PS_LIST_TAIL, "MSKY_MAX", PS_META_REPLACE, "sky model maximum value", statsBck->max); 325 psMetadataAddF32 (readout->analysis, PS_LIST_TAIL, "MSKY_MIN", PS_META_REPLACE, "sky model minimum value", statsBck->min); 326 psMetadataAddS32 (readout->analysis, PS_LIST_TAIL, "MSKY_NX", PS_META_REPLACE, "sky model size (x)", model->numCols); 327 psMetadataAddS32 (readout->analysis, PS_LIST_TAIL, "MSKY_NY", PS_META_REPLACE, "sky model size (y)", model->numRows); 328 328 psLogMsg ("psphot", PS_LOG_INFO, "background sky : min %f mean %f max %f stdev %f", 329 329 statsBck->min, statsBck->sampleMean, statsBck->max, statsBck->sampleStdev); … … 338 338 } 339 339 340 341 342 psImage *psphotBackgroundModel(pmReadout *ro, const pmConfig *config) 340 // generate a background model for a single readout. do not save an associated pmFPAfile for possible output 341 psImage *psphotModelBackgroundReadoutNoFile(pmReadout *readout, const pmConfig *config) 343 342 { 344 PM_ASSERT_READOUT_NON_NULL(r o, NULL);345 PM_ASSERT_READOUT_IMAGE(r o, NULL);343 PM_ASSERT_READOUT_NON_NULL(readout, NULL); 344 PM_ASSERT_READOUT_IMAGE(readout, NULL); 346 345 PS_ASSERT_PTR_NON_NULL(config, NULL); 347 346 348 psImageBinning *binning = psphotBackgroundBinning(r o->image, config); // Image binning parameters347 psImageBinning *binning = psphotBackgroundBinning(readout->image, config); // Image binning parameters 349 348 psImage *model = psImageAlloc(binning->nXruff, binning->nYruff, PS_TYPE_F32); // Background model 350 349 psImage *modelStdev = psImageAlloc(binning->nXruff, binning->nYruff, PS_TYPE_F32); // Standard deviation 351 350 352 if (! backgroundModel(model, modelStdev, ro->analysis, ro, binning, config)) {351 if (!psphotModelBackgroundReadout(model, modelStdev, readout->analysis, readout, binning, config)) { 353 352 psFree(model); 354 353 psFree(modelStdev); … … 356 355 return NULL; 357 356 } 358 359 357 psFree(modelStdev); 360 361 358 return model; 362 359 } 363 360 364 365 // generate the median in NxN boxes, clipping heavily 366 // linear interpolation to generate full-scale model 367 bool psphotModelBackground (pmConfig *config, const pmFPAview *view, const char *filename) 361 // generate a background model for readout number index; save an associated pmFPAfile for possible output 362 bool psphotModelBackgroundReadoutFileIndex (pmConfig *config, const pmFPAview *view, const char *filename, int index) 368 363 { 369 bool status = true;370 371 364 // find the currently selected readout 372 pmFPAfile *file = psMetadataLookupPtr (&status, config->files, filename); 365 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest 366 psAssert (file, "missing file?"); 367 373 368 pmFPA *inFPA = file->fpa; 374 369 pmReadout *readout = pmFPAviewThisReadout(view, inFPA); 370 psAssert (readout, "missing readout?"); 375 371 376 372 psImageBinning *binning = psphotBackgroundBinning(readout->image, config); // Image binning parameters … … 378 374 pmReadout *modelStdev = pmFPAGenerateReadout(config, view, "PSPHOT.BACKMDL.STDEV", inFPA, binning); 379 375 380 if (! backgroundModel(model->image, modelStdev->image, model->analysis, readout, binning, config)) {376 if (!psphotModelBackgroundReadout(model->image, modelStdev->image, model->analysis, readout, binning, config)) { 381 377 psError(PS_ERR_UNKNOWN, false, "Unable to generate background model"); 382 378 return false; … … 386 382 return true; 387 383 } 384 385 // XXX supply filename or keep PSPHOT.INPUT fixed? 386 bool psphotModelBackground (pmConfig *config, const pmFPAview *view) 387 { 388 bool status = false; 389 390 int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM"); 391 psAssert (status, "programming error: must define PSPHOT.INPUT.NUM"); 392 393 // loop over the available readouts 394 for (int i = 0; i < num; i++) { 395 if (!psphotModelBackgroundReadoutFileIndex(config, view, "PSPHOT.INPUT", i)) { 396 psError (PSPHOT_ERR_CONFIG, false, "failed to model background for PSPHOT.INPUT entry %d", i); 397 return false; 398 } 399 } 400 return true; 401 }
Note:
See TracChangeset
for help on using the changeset viewer.
