IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 26, 2012, 11:25:02 AM (14 years ago)
Author:
eugene
Message:

fix numerical round-off errors and aperture bias in ppSimInsertStars

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppSim/src/ppSimInsertStars.c

    r32350 r34083  
    66    PTR = NULL;
    77
    8 float imageSum (psImage *image);
     8double imageSum (psImage *image);
    99
    1010bool ppSimInsertStars (pmReadout *readout, psImage *expCorr, psArray *stars, pmConfig *config) {
     
    7979    FILE *outfile = fopen (outname, "w");
    8080
     81    float radius = -1.0;
     82
    8183    // add sources to the readout image & variance
    8284    psTrace("ppSim", 1, "Inserting %ld stars...\n", stars->n);
     
    110112        pmModelSetFlux (model, flux);
    111113
    112         float radius = model->modelRadius (model->params, nSigmaLim * roughNoise);
    113         radius = PS_MAX (radius, 1.0);
    114         radius = 20.0;
     114        // we must set the radius on the first object, and leave it there for everyone else
     115        // (inserting flux with a variable radius introduces a flux-dependent bias)
     116        if (radius < 0) {
     117          radius = model->modelRadius (model->params, nSigmaLim * roughNoise);
     118          radius = PS_MAX (radius,  1.0);
     119          radius = PS_MIN (radius, 50.0);
     120        }
    115121
    116122        // construct a source, with model flux pixels set, based on the model
     
    136142            readout->image->data.F32[(int)(yCell)][(int)(xCell)] += flux;
    137143        } else {
    138             // insert the source flux in the image
    139             float sum1 = imageSum(source->pixels);
     144            // insert the source flux in the image and measure inserted flux
     145            // this is a difference of 2 large numbers : must use 'double' or we get floating
     146            // point errors and trends on a scale of ~0.005 mags at > -10 mags instrumental
     147            double sum1 = imageSum(source->pixels);
    140148            pmSourceAddWithOffset (source, PM_MODEL_OP_FULL, 0xff, dX, dY);
    141             float sum2 = imageSum(source->pixels);
     149            double sum2 = imageSum(source->pixels);
    142150            starFlux = sum2 - sum1;
    143151           
     
    154162            RESET(source->blends);
    155163        }
    156         fprintf (outfile, "%8.3f %8.3f %10.2f  %2d  %7.3f %5.3f  %5.3f %5.3f %5.3f %5.3f  :  %f %f\n", star->x, star->y, starFlux, 0, source->psfMag, source->psfMagErr, axes.major, axes.minor, axes.theta, par8, model->params->data.F32[PM_PAR_I0], radius);
     164        fprintf (outfile, "%8.3f %8.3f %10.5f  %2d  %7.3f %5.3f  %5.3f %5.3f %5.3f %5.3f  :  %f %f\n", star->x, star->y, starFlux, 0, source->psfMag, source->psfMagErr, axes.major, axes.minor, axes.theta, par8, model->params->data.F32[PM_PAR_I0], radius);
    157165
    158166        // add the sources to the source array
Note: See TracChangeset for help on using the changeset viewer.