Changeset 35530 for trunk/ppStack/src/ppStackPrepare.c
- Timestamp:
- May 7, 2013, 2:32:30 PM (13 years ago)
- File:
-
- 1 edited
-
trunk/ppStack/src/ppStackPrepare.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppStack/src/ppStackPrepare.c
r35529 r35530 355 355 clipFWHMnSig,maxFWHM,threshFWHM,asymmetryFWHM); 356 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 357 else { 358 // Do GMM test with two modes to decide where to put the break. 359 double Punimodal; 360 int m = 2; 361 psVector *modes = psVectorAlloc(num,PS_TYPE_F32); 362 psVector *means = psVectorAlloc(m,PS_TYPE_F32); 363 psVector *S = psVectorAlloc(m,PS_TYPE_F32); 364 psVector *pi = psVectorAlloc(m,PS_TYPE_F32); 365 psImage *P = psImageAlloc(m,num,PS_TYPE_F32); 366 367 if (!psMM1DClass(options->inputSeeing, 368 options->inputSeeing->n, 369 modes,means, 370 S,pi,P, 371 2, 372 &Punimodal)) { 373 // Handle error here 374 psFree(modes); 375 psFree(means); 376 psFree(S); 377 psFree(pi); 378 psFree(P); 379 return(false); 380 } 381 // fprintf(stderr,"means: %g %g\n",means->data.F32[0],means->data.F32[1]); 382 // fprintf(stderr,"sigma: %g %g \n",S->data.F32[0],S->data.F32[1]); 383 // fprintf(stderr,"pi: %g %g\n",pi->data.F32[0],pi->data.F32[1]); 384 385 // Use Gaussian mixture model analysis of the FWHM distribution to decide an optional FWHM limit 386 if ((Punimodal > 0.5)|| // This distribution is best represented by a single mode 387 (num <= 4)) { // Or we have a small number of inputs, making this statistic poor. 388 limit = maxFWHM; 389 } 390 else { // This is a bimodal distribution 391 if ((fabs(pi->data.F32[0] - pi->data.F32[1]) < asymmetryFWHM)|| // However, both modes are equally populated 392 (pi->data.F32[1] > pi->data.F32[0])) { // Or the larger FWHM mode is more populated 393 limit = means->data.F32[1] + clipFWHMnSig * S->data.F32[1]; 394 } 395 else { // The smaller FWHM mode is more populated 396 limit = means->data.F32[0] + clipFWHMnSig * S->data.F32[0]; 397 } 398 } 399 if (limit > maxFWHM) { limit = maxFWHM; } // We should not be larger than our max 400 if (limit < threshFWHM) { limit = threshFWHM; } // Nor smaller than our min 401 psLogMsg("ppStack",PS_LOG_INFO, 402 "PSF FWHM distribution: limit: %f (%f %f %f) (%f %f %f) %f", 403 limit,means->data.F32[0],S->data.F32[0],pi->data.F32[0], 404 means->data.F32[1],S->data.F32[1],pi->data.F32[1], 405 Punimodal); 406 psFree(means); 373 407 psFree(modes); 374 psFree(means);375 408 psFree(S); 376 409 psFree(pi); 377 410 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); 406 psFree(modes); 407 psFree(S); 408 psFree(pi); 409 psFree(P); 410 } // End mixture model case 411 411 } // End mixture model case 412 } 412 413 // Perform rejection using the limit set 413 414 for (int i = 0; i < num; i++) {
Note:
See TracChangeset
for help on using the changeset viewer.
