IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 6825


Ignore:
Timestamp:
Apr 10, 2006, 10:21:36 AM (20 years ago)
Author:
magnier
Message:

adding chisq-flux trend corrections; adding option to use non-poisson errors for fits

Location:
branches/rel10_ifa/psModules/src/objects
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/rel10_ifa/psModules/src/objects/pmModel.h

    r6751 r6825  
    66 *  @author EAM, IfA
    77 *
    8  *  @version $Revision: 1.1.2.3 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2006-04-01 02:47:20 $
     8 *  @version $Revision: 1.1.2.4 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2006-04-10 20:21:36 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4242    psVector *dparams;   ///< Parameter errors.
    4343    float chisq;   ///< Fit chi-squared.
     44    float chisqNorm;   ///< re-normalized fit chi-squared.
    4445    int nDOF;    ///< number of degrees of freedom
    4546    int nIter;    ///< number of iterations to reach min
  • branches/rel10_ifa/psModules/src/objects/pmPSF.c

    r6556 r6825  
    66 *  @author EAM, IfA
    77 *
    8  *  @version $Revision: 1.4.4.2 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2006-03-09 03:14:23 $
     8 *  @version $Revision: 1.4.4.3 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2006-04-10 20:21:36 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    9797    pmPSF_MaskApTrend (psf, PM_PSF_SKYBIAS);
    9898
     99    if (PM_PSF_POISSON_WEIGHTS) {
     100        psf->ChiTrend = psPolynomial1DAlloc (PS_POLYNOMIAL_ORD, 1);
     101    } else {
     102        psf->ChiTrend = psPolynomial1DAlloc (PS_POLYNOMIAL_ORD, 2);
     103    }
     104
    99105    // don't define a growth curve : user needs to choose radius bins
    100106    psf->growth = NULL;
  • branches/rel10_ifa/psModules/src/objects/pmPSF.h

    r6556 r6825  
    66 *  @author EAM, IfA
    77 *
    8  *  @version $Revision: 1.1.22.2 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2006-03-09 03:14:23 $
     8 *  @version $Revision: 1.1.22.3 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2006-04-10 20:21:36 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    1515# ifndef PM_PSF_H
    1616# define PM_PSF_H
     17
     18# define PM_PSF_POISSON_WEIGHTS 1
    1719
    1820/** pmPSF data structure
     
    3234    pmModelType type;   ///< PSF Model in use
    3335    psArray *params;   ///< Model parameters (psPolynomial2D)
     36    psPolynomial1D *ChiTrend;  ///< Chisq vs flux fit (correction for systematic errors)
    3437    psPolynomial4D *ApTrend;  ///< ApResid vs (x,y,rflux) (rflux = ten(0.4*mInst)
    3538    pmGrowthCurve *growth;  ///< apMag vs Radius
    36     float ApResid;   ///< ???
    37     float dApResid;   ///< ???
    38     float skyBias;   ///< ???
    39     float skySat;   ///< ???
    40     float chisq;   ///< PSF goodness statistic
     39    float ApResid;   ///< apMag - psfMag (for PSF stars)
     40    float dApResid;   ///< scatter of ApResid
     41    float skyBias;   ///< implied residual sky offset from ApResid fit
     42    float skySat;   ///< roll-over of ApResid fit
     43    float chisq;   ///< PSF goodness statistic (unused??)
    4144    int nPSFstars;   ///< number of stars used to measure PSF
    4245    int nApResid;   ///< number of stars used to measure ApResid
  • branches/rel10_ifa/psModules/src/objects/pmPSFtry.c

    r6556 r6825  
    55 *  @author EAM, IfA
    66 *
    7  *  @version $Revision: 1.4.4.2 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2006-03-09 03:14:23 $
     7 *  @version $Revision: 1.4.4.3 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2006-04-10 20:21:36 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    184184    psTrace ("psphot.psftry", 3, "keeping %d of %d PSF candidates (PSF)\n", Npsf, sources->n);
    185185
    186     // make this optional
    187     // DumpModelFits (psfTry->modelPSF, "modelsPSF.dat");
     186    // measure the chi-square trend as a function of flux (PAR[1])
     187    // this should be linear for Poisson errors and quadratic for constant sky errors
     188    psVector *flux  = psVectorAlloc (psfTry->sources->n, PS_TYPE_F64);
     189    psVector *chisq = psVectorAlloc (psfTry->sources->n, PS_TYPE_F64);
     190    psVector *mask  = psVectorAlloc (psfTry->sources->n, PS_TYPE_MASK);
     191
     192    // write sources with models first
     193    for (int i = 0; i < psfTry->sources->n; i++) {
     194        pmModel *model = psfTry->modelPSF->data[i];
     195        if (model == NULL) {
     196            flux->data.F64[i] = 0.0;
     197            chisq->data.F64[i] = 0.0;
     198            mask->data.U8[i] = 1;
     199        } else {
     200            flux->data.F64[i] = model->params->data.F32[1];
     201            chisq->data.F64[i] = model[0].chisq/model[0].nDOF;
     202            mask->data.U8[i] = 0;
     203        }
     204    }
     205    // use 3hi/3lo sigma clipping on the r2rflux vs metric fit
     206    psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_STDEV);
     207    stats->clipSigma = 3.0;
     208    stats->clipIter = 3;
     209    // linear clipped fit of ApResid to r2rflux
     210    psVectorClipFitPolynomial1D (psfTry->psf->ChiTrend, stats, mask, 1, chisq, NULL, flux);
     211    for (int i = 0; i < psfTry->psf->ChiTrend->nX + 1; i++) {
     212        psLogMsg ("pmPSFtry", 4, "chisq vs flux fit term %d: %f +/- %f\n", i, psfTry->psf->ChiTrend->coeff[i]*pow(10000, i), psfTry->psf->ChiTrend->coeffErr[i]);
     213    }
     214    psLogMsg ("pmPSFtry", 4, "chisq vs flux fit: %f +/- %f\n", stats->sampleMedian, stats->sampleStdev);
     215    psFree (stats);
     216    psFree (flux);
     217    psFree (chisq);
    188218
    189219    // XXX this function wants aperture radius for pmSourcePhotometry
  • branches/rel10_ifa/psModules/src/objects/pmSourceFitModel.c

    r6820 r6825  
    66 *  @author GLG, MHPCC
    77 *
    8  *  @version $Revision: 1.1.2.4 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2006-04-09 18:45:42 $
     8 *  @version $Revision: 1.1.2.5 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2006-04-10 20:21:36 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    9696            y->data.F32[nPix] = source->pixels->data.F32[i][j];
    9797            // psMinimizeLMChi2 takes wt = 1/dY^2
    98             if (POISSON_WEIGHT) {
     98            if (PM_PSF_POISSON_WEIGHTS) {
    9999                yErr->data.F32[nPix] = 1.0 / source->weight->data.F32[i][j];
    100100            } else {
  • branches/rel10_ifa/psModules/src/objects/pmSourceFitSet.c

    r6751 r6825  
    33 *  @author EAM, IfA
    44 *
    5  *  @version $Revision: 1.1.2.3 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2006-04-01 02:47:20 $
     5 *  @version $Revision: 1.1.2.4 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2006-04-10 20:21:36 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    182182    psS32 nPix = source->pixels->numRows * source->pixels->numCols;
    183183
     184    // local sky variance
     185    psF32 dSky = source->moments->dSky;
     186
    184187    // construct the coordinate and value entries
    185188    psArray *x = psArrayAlloc(nPix);
     
    206209            y->data.F32[nPix] = source->pixels->data.F32[i][j];
    207210            // psMinimizeLMChi2 takes wt = 1/dY^2
    208             yErr->data.F32[nPix] = 1.0 / source->weight->data.F32[i][j];
     211            if (PM_PSF_POISSON_WEIGHTS) {
     212                yErr->data.F32[nPix] = 1.0 / source->weight->data.F32[i][j];
     213            } else {
     214                yErr->data.F32[nPix] = 1.0 / dSky;
     215            }
    209216            nPix++;
    210217        }
Note: See TracChangeset for help on using the changeset viewer.