Changeset 34353 for trunk/psphot
- Timestamp:
- Aug 24, 2012, 12:37:46 PM (14 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/psphotEfficiency.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphotEfficiency.c
r34319 r34353 57 57 psFree(stats); 58 58 59 #ifndef USE_SINGLE_POINT_FOR_MODEL 59 60 // Need to normalise out difference between Gaussian and real PSF 61 int sizeX = ro->variance->numCols / 16; 62 int sizeY = ro->variance->numRows / 16; 63 int numPoints = 0; 64 float sum = 0; 65 for (int y = sizeY * 0.5 ; y < ro->variance->numRows; y += sizeY) { 66 for (int x = sizeX * 0.5 ; x < ro->variance->numCols; x += sizeX) { 67 pmModel *normModel = pmModelFromPSFforXY(psf, (float) x, (float) y, 1.0); // model for normalization 68 69 if (!normModel || (normModel->flags & MODEL_MASK)) { 70 psFree(normModel); 71 continue; 72 } 73 float flux = normModel->modelFlux(normModel->params); // Total flux for peak of 1.0 74 psFree(normModel); 75 if (!isfinite(flux)) { 76 continue; 77 } 78 numPoints++; 79 sum += flux; 80 } 81 } 82 if (!isfinite(sum) || numPoints == 0) { 83 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to generate PSF model for any of %d points.", sizeX * sizeY); 84 return false; 85 } 86 *norm = sum / numPoints; 87 #else 88 // This can fail for readout that has few good pixels. It's better to sample many points. 60 89 pmModel *normModel = pmModelFromPSFforXY(psf, 0.5 * ro->variance->numCols, 61 0.5 * ro->variance->numRows, 1.0); // Model for normalisation 90 0.5 * ro->variance->numRows, 1.0); // Model for normalisation 91 psFree(normModel); 62 92 if (!normModel || (normModel->flags & MODEL_MASK)) { 63 93 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to generate PSF model."); … … 67 97 *norm = normModel->modelFlux(normModel->params); // Total flux for peak of 1.0 68 98 psFree(normModel); 99 #endif 69 100 70 101 // The signal-to-noise of the smoothed image is: S/N ~ I_smooth / sqrt(variance * factor) … … 188 219 if (!psphotEfficiencyReadout (config, view, filerule, i, recipe)) { 189 220 psError (PSPHOT_ERR_CONFIG, false, "failed to measure detection efficiency for %s entry %d", filerule, i); 190 return false; 221 psErrorStackPrint(stderr, " "); 222 psErrorClear(); 223 // send message to log as well 224 psLogMsg ("psphot", PS_LOG_WARN, "failed to measure detection efficiency for %s entry %d", filerule, i); 191 225 } 192 226 } … … 376 410 float mag = magLim + magOffsets->data.F32[i]; // Magnitude for bin 377 411 float peak = powf(10.0, -0.4 * mag) / norm; // Peak flux 412 #ifndef USE_SINGLE_POINT_FOR_MODEL 413 int sizeX = numCols / 16; 414 int sizeY = numRows / 16; 415 int numPoints = 0; 416 float sum = 0; 417 for (int y = sizeY * 0.5 ; y < numRows; y += sizeY) { 418 for (int x = sizeX * 0.5 ; x < numCols; x += sizeX) { 419 // Need to normalise out difference between Gaussian and real PSF 420 pmModel *model = pmModelFromPSFforXY(psf, (float) x, (float) y, peak); 421 422 if (!model || (model->flags & MODEL_MASK)) { 423 psFree(model); 424 continue; 425 } 426 float sourceRadius = PS_MAX(radius, model->modelRadius(model->params, minFlux)); // Radius for source 427 psFree(model); 428 if (!isfinite(sourceRadius)) { 429 continue; 430 } 431 numPoints++; 432 sum += sourceRadius; 433 } 434 } 435 if (!isfinite(sum) || numPoints == 0) { 436 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to generate PSF model for any of %d points.", sizeX * sizeY); 437 return false; 438 } 439 float sourceRadius = sum / numPoints; 440 #else 441 // This old way can fail for heavily masked images 378 442 pmModel *model = pmModelFromPSFforXY(psf, numCols / 2.0, numRows / 2.0, peak); // Model for source 379 443 if (!model || (model->flags & MODEL_MASK)) { … … 384 448 float sourceRadius = PS_MAX(radius, model->modelRadius(model->params, minFlux)); // Radius for source 385 449 psFree(model); 450 #endif 386 451 387 452 psArray *sources = psArrayAllocEmpty(numSources); // Sources in this bin
Note:
See TracChangeset
for help on using the changeset viewer.
