Changeset 35529
- Timestamp:
- May 7, 2013, 2:30:23 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
ippconfig/recipes/ppStack.config (modified) (1 diff)
-
ppStack/src/ppStackPrepare.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippconfig/recipes/ppStack.config
r35455 r35529 90 90 91 91 92 PSF.INPUT.MAX F32 NAN 93 PSF.INPUT.CLIP.NSIGMA F32 NAN 94 PSF.INPUT.THRESH F32 NAN 95 PSF.INPUT.ASYMMETRY F32 NAN 92 PSF.INPUT.CLIP.SIMPLE BOOL F # Should we do a simple sigma clip (T, requires CLIP.NSIGMA) or the mixture model (F, requires all parameters) 93 PSF.INPUT.MAX F32 NAN # Set maximum limit on input FWHM (defaults to inf) 94 PSF.INPUT.CLIP.NSIGMA F32 NAN # Set n-sigma cut limit for input rejection 95 PSF.INPUT.THRESH F32 NAN # Set minimum limit below which we do not exclude an input (defaults to 0.0) 96 PSF.INPUT.ASYMMETRY F32 NAN # Set difference in mixture model populations to consider equal. 96 97 97 98 TEMP.IMAGE STR conv.im.fits # Suffix for temporary convolved images -
trunk/ppStack/src/ppStackPrepare.c
r35455 r35529 257 257 258 258 bool mdok = false; 259 bool simpleClip = psMetadataLookupF32(&mdok, recipe, "PSF.INPUT.CLIP.SIMPLE"); 259 260 float maxFWHM = psMetadataLookupF32(&mdok, recipe, "PSF.INPUT.MAX"); // max allowed input fwhm 260 261 float clipFWHMnSig = psMetadataLookupF32(&mdok, recipe, "PSF.INPUT.CLIP.NSIGMA"); // sigma clipping of inputs 261 262 float threshFWHM = psMetadataLookupF32(&mdok, recipe, "PSF.INPUT.THRESH"); // FWHM size that we refuse to clip below 262 263 float asymmetryFWHM = psMetadataLookupF32(&mdok, recipe, "PSF.INPUT.ASYMMETRY"); // max bimodal asymmetry 264 263 265 psString log = psStringCopy("Input seeing FWHMs:\n"); // Log message 264 266 bool havePSFs = false; // Do we have any PSFs? … … 309 311 310 312 #ifdef NEW_REJECTION 311 // Do GMM test with two modes to decide where to put the break. 312 double Punimodal; 313 int m = 2; 314 psVector *modes = psVectorAlloc(num,PS_TYPE_F32); 315 psVector *means = psVectorAlloc(m,PS_TYPE_F32); 316 psVector *S = psVectorAlloc(m,PS_TYPE_F32); 317 psVector *pi = psVectorAlloc(m,PS_TYPE_F32); 318 psImage *P = psImageAlloc(m,num,PS_TYPE_F32); 319 float limit; 320 if (!psMM1DClass(options->inputSeeing, 321 options->inputSeeing->n, 322 modes,means, 323 S,pi,P, 324 2, 325 &Punimodal)) { 326 // Handle error here 313 // Begin new rejection code. 314 float limit = INFINITY; // Default to a big value. 315 if (!isfinite(threshFWHM)) { // If this isn't set, initialize it to zero. No inputs may be clipped if smaller than this 316 threshFWHM = 0.0; 317 } 318 if (!isfinite(maxFWHM)) { // No maxFWHM was set, accept all inputs 319 maxFWHM = INFINITY; 320 } 321 limit = maxFWHM; // Initialize the limit to be the maxFWHM 322 if (limit < threshFWHM) { 323 limit = threshFWHM; 324 } 325 if (!isfinite(clipFWHMnSig)) { // We cannot do a sigma clip with nSig, so use the maxFWHM to set the limit. 326 psLogMsg("ppStack",PS_LOG_INFO, 327 "PSF FWHM distribution: Unable to determine limit based on recipe. Setting to %f. (clipFWHMnSig: %f maxFWHM: %f threshFWHM: %f asymmetryFWHM: %f)", 328 limit, 329 clipFWHMnSig,maxFWHM,threshFWHM,asymmetryFWHM); 330 } 331 if (simpleClip) { // Do a sigma clip like the old rejection code. 332 psStats *fwhmStats = psStatsAlloc(PS_STAT_CLIPPED_MEAN | PS_STAT_CLIPPED_STDEV); 333 psVectorStats (fwhmStats, options->inputSeeing, NULL, options->inputMask, 0xff); 334 psLogMsg("ppStack", PS_LOG_INFO, "Input FWHMs : %f +/- %f", fwhmStats->clippedMean, fwhmStats->clippedStdev); 335 336 options->clippedMean = fwhmStats->clippedMean; 337 options->clippedStdev = fwhmStats->clippedStdev; 338 limit = options->clippedMean + clipFWHMnSig * options->clippedStdev; 339 if (limit < threshFWHM) { 340 limit = threshFWHM; 341 } 342 if (limit > maxFWHM) { 343 limit = maxFWHM; 344 } 345 psLogMsg("ppStack",PS_LOG_INFO, 346 "PSF FWHM distribution: Used simple clip method. Limit set to %f.", 347 limit); 348 psFree(fwhmStats); 349 } 350 else { // Do the mixture model rejection. 351 if(!isfinite(asymmetryFWHM)) { // Or not, because the parameters aren't set. 352 psLogMsg("ppStack",PS_LOG_INFO, 353 "PSF FWHM distribution: Unable to determine limit based on recipe. Setting to %f. (clipFWHMnSig: %f maxFWHM: %f threshFWHM: %f asymmetryFWHM: %f)", 354 limit, 355 clipFWHMnSig,maxFWHM,threshFWHM,asymmetryFWHM); 356 } 357 // Do GMM test with two modes to decide where to put the break. 358 double Punimodal; 359 int m = 2; 360 psVector *modes = psVectorAlloc(num,PS_TYPE_F32); 361 psVector *means = psVectorAlloc(m,PS_TYPE_F32); 362 psVector *S = psVectorAlloc(m,PS_TYPE_F32); 363 psVector *pi = psVectorAlloc(m,PS_TYPE_F32); 364 psImage *P = psImageAlloc(m,num,PS_TYPE_F32); 365 366 if (!psMM1DClass(options->inputSeeing, 367 options->inputSeeing->n, 368 modes,means, 369 S,pi,P, 370 2, 371 &Punimodal)) { 372 // Handle error here 373 psFree(modes); 374 psFree(means); 375 psFree(S); 376 psFree(pi); 377 psFree(P); 378 return(false); 379 } 380 // fprintf(stderr,"means: %g %g\n",means->data.F32[0],means->data.F32[1]); 381 // fprintf(stderr,"sigma: %g %g \n",S->data.F32[0],S->data.F32[1]); 382 // fprintf(stderr,"pi: %g %g\n",pi->data.F32[0],pi->data.F32[1]); 383 384 // Use Gaussian mixture model analysis of the FWHM distribution to decide an optional FWHM limit 385 if ((Punimodal > 0.5)|| // This distribution is best represented by a single mode 386 (num <= 4)) { // Or we have a small number of inputs, making this statistic poor. 387 limit = maxFWHM; 388 } 389 else { // This is a bimodal distribution 390 if ((fabs(pi->data.F32[0] - pi->data.F32[1]) < asymmetryFWHM)|| // However, both modes are equally populated 391 (pi->data.F32[1] > pi->data.F32[0])) { // Or the larger FWHM mode is more populated 392 limit = means->data.F32[1] + clipFWHMnSig * S->data.F32[1]; 393 } 394 else { // The smaller FWHM mode is more populated 395 limit = means->data.F32[0] + clipFWHMnSig * S->data.F32[0]; 396 } 397 } 398 if (limit > maxFWHM) { limit = maxFWHM; } // We should not be larger than our max 399 if (limit < threshFWHM) { limit = threshFWHM; } // Nor smaller than our min 400 psLogMsg("ppStack",PS_LOG_INFO, 401 "PSF FWHM distribution: limit: %f (%f %f %f) (%f %f %f) %f", 402 limit,means->data.F32[0],S->data.F32[0],pi->data.F32[0], 403 means->data.F32[1],S->data.F32[1],pi->data.F32[1], 404 Punimodal); 405 psFree(means); 327 406 psFree(modes); 328 psFree(means);329 407 psFree(S); 330 408 psFree(pi); 331 409 psFree(P); 332 return(false); 333 } 334 // fprintf(stderr,"means: %g %g\n",means->data.F32[0],means->data.F32[1]); 335 // fprintf(stderr,"sigma: %g %g \n",S->data.F32[0],S->data.F32[1]); 336 // fprintf(stderr,"pi: %g %g\n",pi->data.F32[0],pi->data.F32[1]); 337 338 // Use Gaussian mixture model analysis of the FWHM distribution to decide an optional FWHM limit 339 if ((Punimodal > 0.5)|| // This distribution is best represented by a single mode 340 (num <= 4)) { // Or we have a small number of inputs, making this statistic poor. 341 limit = maxFWHM; 342 } 343 else { // This is a bimodal distribution 344 if ((fabs(pi->data.F32[0] - pi->data.F32[1]) < asymmetryFWHM)|| // However, both modes are equally populated 345 (pi->data.F32[1] > pi->data.F32[0])) { // Or the larger FWHM mode is more populated 346 limit = means->data.F32[1] + clipFWHMnSig * S->data.F32[1]; 347 } 348 else { // The smaller FWHM mode is more populated 349 limit = means->data.F32[0] + clipFWHMnSig * S->data.F32[0]; 350 } 351 } 352 if (limit > maxFWHM) { limit = maxFWHM; } // We should not be larger than our max 353 if (limit < threshFWHM) { limit = threshFWHM; } // Nor smaller than our min 354 psLogMsg("ppStack",PS_LOG_INFO, 355 "PSF FWHM distribution: limit: %f (%f %f %f) (%f %f %f) %f", 356 limit,means->data.F32[0],S->data.F32[0],pi->data.F32[0], 357 means->data.F32[1],S->data.F32[1],pi->data.F32[1], 358 Punimodal); 410 } // End mixture model case 411 412 // Perform rejection using the limit set 359 413 for (int i = 0; i < num; i++) { 360 414 if (options->inputSeeing->data.F32[i] > limit) { … … 365 419 } 366 420 } 367 psFree(means);368 psFree(modes);369 psFree(S);370 psFree(pi);371 psFree(P);372 421 // End new rejection code 373 422 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
