IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 35394


Ignore:
Timestamp:
Apr 11, 2013, 3:21:06 PM (13 years ago)
Author:
watersc1
Message:

Update to FWHM rejection. I've not fully tested this yet, although it does seem to work as intended in the initial tests.

Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippconfig/gpc1/ppStack.config

    r35337 r35394  
    11PSF.MODEL       STR     PS_MODEL_PS1_V1 # Model for PSF generation
     2BACKGROUND.MODEL BOOL   F
    23
    34ZP.AIRMASS      METADATA                # Airmass terms by filter
     
    3031    OUTPUT.LOGFLUX          BOOL  FALSE
    3132    OUTPUT.REPLICATE        BOOL  TRUE
    32     PSF.INPUT.MAX           F32   7.5
     33    PSF.INPUT.MAX           F32   10.0
    3334    PSF.INPUT.CLIP.NSIGMA   F32   1.5
     35    PSF.INPUT.THRESH        F32   5.0
     36    PSF.INPUT.ASYMMETRY     F32   0.2
    3437END
    3538
  • trunk/ippconfig/recipes/ppStack.config

    r35337 r35394  
    9292PSF.INPUT.MAX           F32  NAN
    9393PSF.INPUT.CLIP.NSIGMA   F32  NAN
     94PSF.INPUT.THRESH        F32  NAN
     95PSF.INPUT.ASYMMETRY     F32  NAN
    9496
    9597TEMP.IMAGE      STR     conv.im.fits    # Suffix for temporary convolved images
  • trunk/ppStack/src/ppStackPrepare.c

    r34800 r35394  
    253253    float maxFWHM = psMetadataLookupF32(&mdok, recipe, "PSF.INPUT.MAX"); // max allowed input fwhm
    254254    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
    256257    psString log = psStringCopy("Input seeing FWHMs:\n"); // Log message
    257258    bool havePSFs = false;                                // Do we have any PSFs?
     
    286287            options->inputSeeing->data.F32[i] = sumFWHM / (float)numFWHM;
    287288        }
    288 
     289#ifdef OLD_REJECTION
    289290        // reject any input images which exceed the specified max FWHM
    290291        if (isfinite(maxFWHM) && (options->inputSeeing->data.F32[i] > maxFWHM)) {
     
    292293            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);
    293294        }
    294 
     295#endif
    295296        psStringAppend(&log, "Input %d: %f\n", i, options->inputSeeing->data.F32[i]);
    296297    }
     
    300301    psFree(log);
    301302
     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
    302368    // We should have the ability to filter the input list based on the seeing:
    303369    // * reject above some max value and/or min value
     
    323389        }
    324390    }
    325 
     391#endif
    326392    // Generate target PSF
    327393    if (options->convolve) {
  • trunk/psLib/src/math/Makefile.am

    r16793 r35394  
    1616        psMinimizePowell.c \
    1717        psMinimizePolyFit.c \
     18        psMixtureModels.c \
    1819        psPolynomial.c \
    1920        psPolynomialMetadata.c \
     
    4546        psMinimizePowell.h \
    4647        psMinimizePolyFit.h \
     48        psMixtureModels.h \
    4749        psPolynomial.h \
    4850        psPolynomialMetadata.h \
  • trunk/psLib/src/pslib_strict.h

    r32251 r35394  
    7676#include "psMinimizePowell.h"
    7777#include "psMinimizePolyFit.h"
     78#include "psMixtureModels.h"
    7879#include "psMutex.h"
    7980#include "psRandom.h"
Note: See TracChangeset for help on using the changeset viewer.