Changeset 20234
- Timestamp:
- Oct 17, 2008, 12:59:40 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/psphotChoosePSF.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphotChoosePSF.c
r20082 r20234 318 318 bool psphotPSFstats (pmReadout *readout, psMetadata *recipe, pmPSF *psf) { 319 319 320 double FWHM_X, FWHM_Y;321 322 320 psEllipseShape shape; 323 321 psEllipseAxes axes; … … 330 328 PS_ASSERT_PTR_NON_NULL(image, false); 331 329 332 // XXX X A Serious hack: the psf might not be determined in the field center.333 // for the moment, just try a few locations until it is defined!334 335 pmModel *modelPSF = NULL; 336 for ( int ix = -1; ix <= +1; ix ++) {337 for ( int iy = -1; iy <= +1; iy ++) {330 // XXX a minor hack: measure the values for a grid of points across the image, determine mean, UQ, LQ, etc: 331 psVector *fwhmMajor = psVectorAllocEmpty (100, PS_DATA_F32); 332 psVector *fwhmMinor = psVectorAllocEmpty (100, PS_DATA_F32); 333 334 for (float ix = -0.4; ix <= +0.4; ix += 0.1) { 335 for (float iy = -0.4; iy <= +0.4; iy += 0.1) { 338 336 339 337 // use the center of the center pixel of the image 340 float xc = (0.5 + 0.3*ix)*image->numCols + image->col0 + 0.5;341 float yc = (0.5 + 0.3*ix)*image->numRows + image->row0 + 0.5;338 float xc = ix*image->numCols + 0.5*image->numCols + image->col0 + 0.5; 339 float yc = iy*image->numRows + 0.5*image->numRows + image->row0 + 0.5; 342 340 343 341 // create modelPSF from this model 344 modelPSF = pmModelFromPSFforXY (psf, xc, yc, 1.0); 345 if (modelPSF) goto got_model; 342 pmModel *modelPSF = pmModelFromPSFforXY (psf, xc, yc, 1.0); 343 if (!modelPSF) continue; 344 345 // get the model full-width at half-max 346 float FWHM_MAJOR = 2*modelPSF->modelRadius (modelPSF->params, 0.5); 347 348 // XXX make sure this is consistent with the re-definition of PM_PAR_SXX 349 shape.sx = modelPSF->params->data.F32[PM_PAR_SXX]; 350 shape.sy = modelPSF->params->data.F32[PM_PAR_SYY]; 351 shape.sxy = modelPSF->params->data.F32[PM_PAR_SXY]; 352 axes = psEllipseShapeToAxes (shape, 20.0); 353 psFree (modelPSF); 354 355 float FWHM_MINOR = FWHM_MAJOR * (axes.minor / axes.major); 356 if (!isfinite(FWHM_MAJOR) || !isfinite(FWHM_MINOR)) continue; 357 psVectorAppend (fwhmMajor, FWHM_MAJOR); 358 psVectorAppend (fwhmMinor, FWHM_MINOR); 346 359 } 347 360 } 348 psAssert (modelPSF, "Failed to estimate PSF model at image center (psf is invalid everywhere?)"); 349 350 got_model: 351 // get the model full-width at half-max 352 FWHM_X = 2*modelPSF->modelRadius (modelPSF->params, 0.5); 353 354 // XXX make sure this is consistent with the re-definition of PM_PAR_SXX 355 shape.sx = modelPSF->params->data.F32[PM_PAR_SXX]; 356 shape.sy = modelPSF->params->data.F32[PM_PAR_SYY]; 357 shape.sxy = modelPSF->params->data.F32[PM_PAR_SXY]; 358 axes = psEllipseShapeToAxes (shape, 20.0); 359 360 FWHM_Y = FWHM_X * (axes.minor / axes.major); 361 362 psMetadataAddF32 (recipe, PS_LIST_TAIL, "FWHM_X", PS_META_REPLACE, "PSF FWHM Major axis", FWHM_X); 363 psMetadataAddF32 (recipe, PS_LIST_TAIL, "FWHM_Y", PS_META_REPLACE, "PSF FWHM Minor axis", FWHM_Y); 361 362 psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEAN | PS_STAT_SAMPLE_STDEV | PS_STAT_SAMPLE_QUARTILE); 363 psVectorStats (stats, fwhmMajor, NULL, NULL, 0); 364 psMetadataAddF32 (recipe, PS_LIST_TAIL, "FWHM_MAJ", PS_META_REPLACE, "PSF FWHM Major axis (mean)", stats->sampleMean); 365 psMetadataAddF32 (recipe, PS_LIST_TAIL, "FW_MJ_SG", PS_META_REPLACE, "PSF FWHM Major axis (sigma)", stats->sampleStdev); 366 psMetadataAddF32 (recipe, PS_LIST_TAIL, "FW_MJ_LQ", PS_META_REPLACE, "PSF FWHM Major axis (upper quartile)", stats->sampleLQ); 367 psMetadataAddF32 (recipe, PS_LIST_TAIL, "FW_MJ_UQ", PS_META_REPLACE, "PSF FWHM Major axis (lower quartile)", stats->sampleUQ); 368 369 psVectorStats (stats, fwhmMinor, NULL, NULL, 0); 370 psMetadataAddF32 (recipe, PS_LIST_TAIL, "FWHM_MIN", PS_META_REPLACE, "PSF FWHM Minor axis (mean)", stats->sampleMean); 371 psMetadataAddF32 (recipe, PS_LIST_TAIL, "FW_MN_SG", PS_META_REPLACE, "PSF FWHM Minor axis (sigma)", stats->sampleStdev); 372 psMetadataAddF32 (recipe, PS_LIST_TAIL, "FW_MN_LQ", PS_META_REPLACE, "PSF FWHM Minor axis (upper quartile)", stats->sampleLQ); 373 psMetadataAddF32 (recipe, PS_LIST_TAIL, "FW_MN_UQ", PS_META_REPLACE, "PSF FWHM Minor axis (lower quartile)", stats->sampleUQ); 374 364 375 psMetadataAddF32 (recipe, PS_LIST_TAIL, "ANGLE", PS_META_REPLACE, "PSF angle", axes.theta); 365 376 psMetadataAddS32 (recipe, PS_LIST_TAIL, "NPSFSTAR", PS_META_REPLACE, "Number of stars used to make PSF", psf->nPSFstars); 366 377 psMetadataAddBool(recipe, PS_LIST_TAIL, "PSFMODEL", PS_META_REPLACE, "Valid PSF Model?", true); 367 psFree (modelPSF); 368 378 379 psFree (fwhmMajor); 380 psFree (fwhmMinor); 381 psFree (stats); 369 382 return true; 370 383 }
Note:
See TracChangeset
for help on using the changeset viewer.
