IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 9841


Ignore:
Timestamp:
Nov 3, 2006, 5:12:24 AM (20 years ago)
Author:
magnier
Message:

added metricErr, unused test output code, no skybias in apresid fit (return when we are happy with the apmags and clear on the sky issues)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/objects/pmPSFtry.c

    r9777 r9841  
    55 *  @author EAM, IfA
    66 *
    7  *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2006-10-30 03:03:38 $
     7 *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2006-11-03 15:12:24 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4949    psFree (test->modelPSF);
    5050    psFree (test->metric);
     51    psFree (test->metricErr);
    5152    psFree (test->fitMag);
    5253    psFree (test->mask);
     
    6768    pmPSFtry *test = (pmPSFtry *) psAlloc(sizeof(pmPSFtry));
    6869
    69     test->psf      = pmPSFAlloc (type, poissonErrors, psfTrendMask);
    70     test->sources  = psMemIncrRefCounter(sources);
    71     test->modelEXT = psArrayAlloc (sources->n);
    72     test->modelPSF = psArrayAlloc (sources->n);
    73     test->metric   = psVectorAlloc (sources->n, PS_TYPE_F64);
    74     test->fitMag   = psVectorAlloc (sources->n, PS_TYPE_F64);
    75     test->mask     = psVectorAlloc (sources->n, PS_TYPE_U8);
     70    test->psf       = pmPSFAlloc (type, poissonErrors, psfTrendMask);
     71    test->sources   = psMemIncrRefCounter(sources);
     72    test->modelEXT  = psArrayAlloc (sources->n);
     73    test->modelPSF  = psArrayAlloc (sources->n);
     74    test->metric    = psVectorAlloc (sources->n, PS_TYPE_F64);
     75    test->metricErr = psVectorAlloc (sources->n, PS_TYPE_F64);
     76    test->fitMag    = psVectorAlloc (sources->n, PS_TYPE_F64);
     77    test->mask      = psVectorAlloc (sources->n, PS_TYPE_U8);
    7678
    7779    for (int i = 0; i < test->modelEXT->n; i++) {
     
    8082        test->modelPSF->data[i] = NULL;
    8183        test->metric->data.F64[i] = 0;
     84        test->metricErr->data.F64[i] = 0;
    8285        test->fitMag->data.F64[i] = 0;
    8386    }
     
    175178        psfTry->modelPSF->data[i] = modelPSF;
    176179
     180        // I'm not using the pmSourceMagnitudes API, why?
    177181        // XXX : use a different aperture radius from the fit radius?
    178182        // XXX : use a different estimator for the local sky?
     
    188192
    189193        psfTry->metric->data.F64[i] = obsMag - fitMag;
     194        psfTry->metricErr->data.F64[i] = modelPSF->dparams->data.F32[PM_PAR_I0] / modelPSF->params->data.F32[PM_PAR_I0];
     195
    190196        psfTry->fitMag->data.F64[i] = fitMag;
    191197        Npsf ++;
     
    280286    // linear clipped fit of ApResid to r2rflux
    281287    psPolynomial1D *poly = psPolynomial1DAlloc (PS_POLYNOMIAL_ORD, 1);
    282     poly = psVectorClipFitPolynomial1D (poly, stats, psfTry->mask, PSFTRY_MASK_ALL, psfTry->metric, NULL, r2rflux);
     288
     289    // XXX test to only fit a constant offset (no SKYBIAS)
     290    poly->mask[1] = 1;
     291
     292    poly = psVectorClipFitPolynomial1D (poly, stats, psfTry->mask, PSFTRY_MASK_ALL, psfTry->metric, psfTry->metricErr, r2rflux);
    283293    if (poly == NULL) {
    284294        psError(PS_ERR_UNKNOWN, false, "Failed to fit clipped poly");
     
    286296    }
    287297    psLogMsg ("pmPSFtryMetric", 4, "fit stats: %f +/- %f\n", stats->sampleMedian, stats->sampleStdev);
     298    psLogMsg ("pmPSFtryMetric", 4, "apresid: %f +/- %f\n", poly->coeff[0], poly->coeffErr[0]);
     299
     300    // XXX test dump of fitted model (dump when tracing?)
     301    if (0) {
     302        FILE *f = fopen ("resid.dat", "w");
     303        psVector *apfit = psPolynomial1DEvalVector (poly, r2rflux);
     304        for (int i = 0; i < psfTry->sources->n; i++) {
     305            int keep = (psfTry->mask->data.U8[i] & PSFTRY_MASK_ALL);
     306
     307            pmSource *source = psfTry->sources->data[i];
     308            float x = source->peak->x;
     309            float y = source->peak->y;
     310
     311            fprintf (f, "%d  %d, %f %f %f  %f %f %f  %f\n",
     312                     i, keep, x, y,
     313                     psfTry->fitMag->data.F64[i],
     314                     r2rflux->data.F64[i],
     315                     psfTry->metric->data.F64[i],
     316                     psfTry->metricErr->data.F64[i],
     317                     apfit->data.F64[i]);
     318        }
     319        fclose (f);
     320        psFree (apfit);
     321    }
    288322
    289323    pmPSFMaskApTrend (psfTry->psf->ApTrend, PM_PSF_APTREND_SKYBIAS);
Note: See TracChangeset for help on using the changeset viewer.