Changeset 35394 for trunk/ppStack/src/ppStackPrepare.c
- Timestamp:
- Apr 11, 2013, 3:21:06 PM (13 years ago)
- File:
-
- 1 edited
-
trunk/ppStack/src/ppStackPrepare.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppStack/src/ppStackPrepare.c
r34800 r35394 253 253 float maxFWHM = psMetadataLookupF32(&mdok, recipe, "PSF.INPUT.MAX"); // max allowed input fwhm 254 254 float clipFWHMnSig = psMetadataLookupF32(&mdok, recipe, "PSF.INPUT.CLIP.NSIGMA"); // sigma clipping of inputs 255 255 float threshFWHM = psMetadataLookupF32(&mdok, recipe, "PSF.INPUT.THRESH"); // FWHM size that we refuse to clip below 256 float asymmetryFWHM = psMetadataLookupF32(&mdok, recipe, "PSF.INPUT.ASYMMETRY"); // max bimodal asymmetry 256 257 psString log = psStringCopy("Input seeing FWHMs:\n"); // Log message 257 258 bool havePSFs = false; // Do we have any PSFs? … … 286 287 options->inputSeeing->data.F32[i] = sumFWHM / (float)numFWHM; 287 288 } 288 289 #ifdef OLD_REJECTION 289 290 // reject any input images which exceed the specified max FWHM 290 291 if (isfinite(maxFWHM) && (options->inputSeeing->data.F32[i] > maxFWHM)) { … … 292 293 psLogMsg("ppStack", PS_LOG_INFO, "PSF FWHM for image %d is too large (%f vs %f maxFWHM) --- rejected.", i, options->inputSeeing->data.F32[i], maxFWHM); 293 294 } 294 295 #endif 295 296 psStringAppend(&log, "Input %d: %f\n", i, options->inputSeeing->data.F32[i]); 296 297 } … … 300 301 psFree(log); 301 302 303 // Do GMM test with two modes to decide where to put the break. 304 double Punimodal; 305 int m = 2; 306 psVector *modes = psVectorAlloc(num,PS_TYPE_F32); 307 psVector *means = psVectorAlloc(m,PS_TYPE_F32); 308 psVector *S = psVectorAlloc(m,PS_TYPE_F32); 309 psVector *pi = psVectorAlloc(m,PS_TYPE_F32); 310 psImage *P = psImageAlloc(m,num,PS_TYPE_F32); 311 float limit; 312 if (!psMM1DClass(options->inputSeeing, 313 options->inputSeeing->n, 314 modes,means, 315 S,pi,P, 316 2, 317 &Punimodal)) { 318 // Handle error here 319 psFree(modes); 320 psFree(means); 321 psFree(S); 322 psFree(pi); 323 psFree(P); 324 return(false); 325 } 326 fprintf(stderr,"means: %g %g\n",means->data.F32[0],means->data.F32[1]); 327 fprintf(stderr,"sigma: %g %g \n",S->data.F32[0],S->data.F32[1]); 328 329 fprintf(stderr,"pi: %g %g\n",pi->data.F32[0],pi->data.F32[1]); 330 331 // unwrittenGMMfunction(options->inputSeeing, options->inputMask, 0xff, 332 // &Punimodal, 333 // &m1,&s1,&pi1, 334 // &m2,&s2,&pi2); 335 336 // Use Gaussian mixture model analysis of the FWHM distribution to decide an optional FWHM limit 337 if ((Punimodal > 0.5)|| // This distribution is best represented by a single mode 338 (num <= 4)) { // Or we have a small number of inputs, making this statistic poor. 339 limit = maxFWHM; 340 } 341 else { // This is a bimodal distribution 342 if ((fabs(pi->data.F32[0] - pi->data.F32[1]) < asymmetryFWHM)|| // However, both modes are equally populated 343 (pi->data.F32[1] > pi->data.F32[0])) { // Or the larger FWHM mode is more populated 344 limit = means->data.F32[1] + clipFWHMnSig * S->data.F32[1]; 345 } 346 else { // The smaller FWHM mode is more populated 347 limit = means->data.F32[0] + clipFWHMnSig * S->data.F32[0]; 348 } 349 } 350 if (limit > maxFWHM) { limit = maxFWHM; } // We should not be larger than our max 351 if (limit < threshFWHM) { limit = threshFWHM; } // Nor smaller than our min 352 353 for (int i = 0; i < num; i++) { 354 if (options->inputSeeing->data.F32[i] > limit) { 355 options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PPSTACK_MASK_PSF; 356 psLogMsg("ppStack", PS_LOG_INFO, 357 "PSF FWHM for image %d is too large (%f vs %f fwhmlimit) --- rejected", 358 i, options->inputSeeing->data.F32[i],limit); 359 } 360 } 361 psFree(means); 362 psFree(modes); 363 psFree(S); 364 psFree(pi); 365 psFree(P); 366 367 #ifdef OLD_REJECTION 302 368 // We should have the ability to filter the input list based on the seeing: 303 369 // * reject above some max value and/or min value … … 323 389 } 324 390 } 325 391 #endif 326 392 // Generate target PSF 327 393 if (options->convolve) {
Note:
See TracChangeset
for help on using the changeset viewer.
