IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.