Changeset 27271
- Timestamp:
- Mar 12, 2010, 9:39:20 AM (16 years ago)
- Location:
- branches/eam_branches/20100225/psphot/src
- Files:
-
- 2 edited
-
psphot.h (modified) (2 diffs)
-
psphotEfficiency.c (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20100225/psphot/src/psphot.h
r26894 r27271 92 92 93 93 bool psphotFitSourcesLinear (pmConfig *config, const pmFPAview *view, bool final); 94 bool psphotFitSourcesLinearReadout (p mConfig *config, const pmFPAview *view, const char *filename, int index, bool final);94 bool psphotFitSourcesLinearReadout (psMetadata *recipe, pmReadout *readout, psArray *sources, pmPSF *psf, bool final); 95 95 96 96 bool psphotSourceSize (pmConfig *config, const pmFPAview *view, bool getPSFsize); … … 119 119 120 120 bool psphotMagnitudes (pmConfig *config, const pmFPAview *view); 121 bool psphotMagnitudesReadout(pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe);121 bool psphotMagnitudesReadout(pmConfig *config, psMetadata *recipe, const pmFPAview *view, pmReadout *readout, psArray *sources, pmPSF *psf); 122 122 bool psphotMagnitudes_Threaded (psThreadJob *job); 123 123 -
branches/eam_branches/20100225/psphot/src/psphotEfficiency.c
r26894 r27271 4 4 PM_MODEL_STATUS_BADARGS | PM_MODEL_STATUS_LIMITS) // Mask to apply to models 5 5 6 //#define TESTING 7 8 9 # if 0 6 # define TESTING 0 10 7 11 8 // Calculate the limiting magnitude for an image … … 19 16 float *covarFactor,// Covariance factor 20 17 const pmReadout *ro, // Readout of interest 21 const pmPSF *psf,// Point-spread function18 pmPSF *psf, // Point-spread function 22 19 float thresh, // Threshold for source identification 23 20 float smoothSigma, // Gaussian smoothing sigma … … 152 149 } 153 150 154 # endif155 156 151 bool psphotEfficiency (pmConfig *config, const pmFPAview *view) 157 152 { … … 178 173 bool psphotEfficiencyReadout(pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe) 179 174 { 180 # if 0181 175 bool status = true; 182 176 … … 206 200 207 201 // Collect recipe information 208 float fwhmMajor = psMetadataLookupF32(NULL, recipe, "FWHM_MAJ"); // PSF size in x 209 float fwhmMinor = psMetadataLookupF32(NULL, recipe, "FWHM_MIN"); // PSF size in y 202 float smoothNsigma = psMetadataLookupF32(&status, recipe, "PEAKS_SMOOTH_NSIGMA"); // Smoothing limit 203 psAssert (status && isfinite(smoothNsigma), "Unable to find PEAKS_SMOOTH_NSIGMA in recipe (or invalid value)"); 204 205 float thresh = psMetadataLookupF32(&status, recipe, "PEAKS_NSIGMA_LIMIT_2"); 206 psAssert (status && isfinite(thresh), "Unable to find PEAKS_NSIGMA_LIMIT_2 in recipe (or invalid value)"); 207 208 psVector *magOffsets = psMetadataLookupVector(&status, recipe, "EFF.MAG"); // Magnitude offsets 209 psAssert (status, "Unable to find EFF.MAG F32 vector in recipe"); 210 psAssert (magOffsets->type.type == PS_TYPE_F32, "Unable to find EFF.MAG F32 vector in recipe"); 211 212 int numSources = psMetadataLookupS32(&status, recipe, "EFF.NUM"); // Number of sources for each bin 213 psAssert (status && (numSources > 0), "Unable to find EFF.NUM in recipe (or invalid value)"); 214 215 float minGauss = psMetadataLookupF32(&status, recipe, "PEAKS_MIN_GAUSS"); // Minimum valid fraction of kernel 216 psAssert (status && isfinite(minGauss), "PEAKS_MIN_GAUSS is not set in recipe (or invalid)"); 217 218 // find the PSF size information (why is this not part of the psf structure?) 219 float fwhmMajor = psMetadataLookupF32(NULL, readout->analysis, "FWHM_MAJ"); // PSF size in x 220 float fwhmMinor = psMetadataLookupF32(NULL, readout->analysis, "FWHM_MIN"); // PSF size in y 210 221 if (!isfinite(fwhmMajor) || !isfinite(fwhmMinor) || fwhmMajor == 0.0 || fwhmMinor == 0.0) { 211 psError(PSPHOT_ERR_CONFIG, false, "Unable to find FWHM_MAJ and FWHM_MIN in recipe"); 212 return false; 213 } 214 float smoothNsigma = psMetadataLookupF32(NULL, recipe, "PEAKS_SMOOTH_NSIGMA"); // Smoothing limit 215 if (!isfinite(smoothNsigma)) { 216 psError(PSPHOT_ERR_CONFIG, false, "Unable to find PEAKS_SMOOTH_NSIGMA in recipe"); 217 return false; 218 } 219 float thresh = psMetadataLookupF32(NULL, recipe, "PEAKS_NSIGMA_LIMIT_2"); 220 if (!isfinite(thresh)) { 221 psError(PSPHOT_ERR_CONFIG, false, "Unable to find PEAKS_NSIGMA_LIMIT_2 in recipe"); 222 return false; 223 } 224 psVector *magOffsets = psMetadataLookupVector(NULL, recipe, "EFF.MAG"); // Magnitude offsets 225 if (!magOffsets || magOffsets->type.type != PS_TYPE_F32) { 226 psError(PSPHOT_ERR_CONFIG, false, "Unable to find EFF.MAG F32 vector in recipe"); 227 return NULL; 228 } 229 int numSources = psMetadataLookupS32(NULL, recipe, "EFF.NUM"); // Number of sources for each bin 230 if (numSources == 0) { 231 psError(PSPHOT_ERR_CONFIG, false, "Unable to find EFF.NUM in recipe"); 232 return NULL; 233 } 234 float minGauss = psMetadataLookupF32(NULL, recipe, "PEAKS_MIN_GAUSS"); // Minimum valid fraction of kernel 235 if (!isfinite(minGauss)) { 236 psWarning("PEAKS_MIN_GAUSS is not set in recipe; using default value"); 237 minGauss = 0.5; 222 psError(PSPHOT_ERR_CONFIG, false, "Unable to find FWHM_MAJ and FWHM_MIN in readout->analysis"); 223 return false; 238 224 } 239 225 … … 246 232 // remove all sources, adding noise for subtracted sources 247 233 psphotRemoveAllSources(realSources, recipe); 248 // psphotAddNoise(readout, realSources, recipe); 249 250 251 #if defined(TESTING) && 0 234 235 #if TESTING 252 236 { 253 237 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); … … 278 262 } 279 263 280 #if defTESTING264 #if TESTING 281 265 psphotSaveImage(NULL, readout->image, "orig_image.fits"); 282 266 psphotSaveImage(NULL, readout->variance, "orig_variance.fits"); … … 293 277 } 294 278 295 #if defTESTING279 #if TESTING 296 280 psphotSaveImage(NULL, readout->image, "fake_image.fits"); 297 281 psphotSaveImage(NULL, readout->variance, "fake_variance.fits"); … … 408 392 psFree(significance); 409 393 410 if (!psphotFitSourcesLinear (readout, fakeSourcesAll, recipe, psf, true)) {394 if (!psphotFitSourcesLinearReadout(recipe, readout, fakeSourcesAll, psf, true)) { 411 395 psError(PS_ERR_UNKNOWN, false, "Unable to perform linear fit on fake sources."); 412 396 psFree(fakeSources); … … 415 399 } 416 400 417 // Disable aperture corrections ; casting away const!401 // Disable aperture corrections (save current value) 418 402 pmTrend2D *apTrend = psf->ApTrend; // Aperture trend 419 ((pmPSF*)psf)->ApTrend = NULL;420 421 if (!psphotMagnitudes (config, readout, view, fakeSourcesAll, psf)) {403 psf->ApTrend = NULL; 404 405 if (!psphotMagnitudesReadout(config, recipe, view, readout, fakeSourcesAll, psf)) { 422 406 psError(PS_ERR_UNKNOWN, false, "Unable to measure magnitudes of fake sources."); 423 407 psFree(fakeSources); 424 408 psFree(count); 425 ((pmPSF*)psf)->ApTrend = apTrend; // Casting away const!409 psf->ApTrend = apTrend; // Casting away const! 426 410 return false; 427 411 } 428 412 psFree(fakeSourcesAll); 429 413 430 // Re -enable aperture corrections; casting away const!431 ((pmPSF*)psf)->ApTrend = apTrend;414 // Replace aperture corrections 415 psf->ApTrend = apTrend; 432 416 433 417 psVector *magDiffMean = psVectorAlloc(numBins, PS_TYPE_F32); // Mean difference in magnitude for each bin … … 443 427 psVectorInit(magMask, 0); 444 428 445 #if defTESTING429 #if TESTING 446 430 psString name = NULL; 447 431 psStringAppend(&name, "fake_%d.dat", i); … … 459 443 } 460 444 461 #if defTESTING445 #if TESTING 462 446 fprintf(file, "%f %f %f %f %f %f %f\n", source->peak->xf, source->peak->yf, 463 447 source->modelPSF->params->data.F32[PM_PAR_XPOS], … … 495 479 } 496 480 497 #if defTESTING481 #if TESTING 498 482 fclose(file); 499 483 #endif … … 520 504 psLogMsg("psphot", PS_LOG_INFO, "Detection efficiency: %lf sec\n", psTimerClear("psphot.fake")); 521 505 522 # endif523 524 506 return true; 525 507 }
Note:
See TracChangeset
for help on using the changeset viewer.
