IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 23, 2009, 5:48:09 PM (17 years ago)
Author:
Paul Price
Message:

Doing our best to cope when working with skycells on the edge of the FoV --- e.g., the PSF is not necessarily defined in the centre of the image. If the model or moments aren't good, then don't use the source to fit the PSF.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/imcombine/pmPSFEnvelope.c

    r23956 r23960  
    4040#define PSF_STATS PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_STDEV // Statistics options for measuring PSF
    4141#define SOURCE_FIT_ITERATIONS 100       // Number of iterations for source fitting
     42#define MODEL_MASK (PM_MODEL_STATUS_NONCONVERGE | PM_MODEL_STATUS_OFFIMAGE | \
     43                    PM_MODEL_STATUS_BADARGS | PM_MODEL_STATUS_LIMITS) // Mask to apply to models
    4244
    4345
     
    112114    psImageInit(envelope, SKY_VALUE);
    113115    pmReadout *fakeRO = pmReadoutAlloc(NULL); // Fake readout
    114     float maxRadius = 0.0;              // Maximum radius of sources
    115116    psVector *numbers = psVectorAlloc(numFakes, PS_TYPE_S32); // Number of detections for each source
    116117    psVectorInit(numbers, 0);
     
    143144
    144145            double flux = fakeRO->image->data.F32[(int)y][(int)x];
    145             if (flux > 0) {
    146                 // The source is present
    147                 numbers->data.S32[j]++;
     146            if (!isfinite(flux) || flux < 0) {
     147                continue;
    148148            }
    149149            float norm = PEAK_FLUX / flux; // Normalisation for source
     
    156156            psFree(subEnv);
    157157
    158             // Get the radius
    159             pmModel *model = pmModelFromPSFforXY(psf, x, y, PEAK_FLUX); // Model for source
    160             psAssert (model, "failed to generate model: should this be an error or not?");
    161             float srcRadius = model->modelRadius(model->params, PS_SQR(VARIANCE_VAL)); // Radius for source
    162             if (srcRadius > maxRadius) {
    163                 maxRadius = srcRadius;
    164             }
    165             psFree(model);
     158            // If we got this far, the source is decent
     159            numbers->data.S32[j]++;
    166160        }
    167161
     
    182176    psFree(fakeRO);
    183177
    184     if (maxRadius > radius) {
    185         maxRadius = radius;
    186     }
    187 
    188178#ifdef TESTING
    189179    {
     
    261251
    262252    // Reset the sources to point to the new pixels, and measure the moments in preparation for PSF fitting
     253    int numMoments = 0;                 // Number of moments measured
    263254    for (int i = 0; i < numFakes; i++) {
    264255        pmSource *source = fakes->data[i]; // Fake source
     
    275266        source->maskObj = NULL;
    276267
    277         if (!pmSourceDefinePixels(source, readout, x, y, maxRadius)) {
     268        if (!pmSourceDefinePixels(source, readout, x, y, radius)) {
    278269            psError(PS_ERR_UNKNOWN, false, "Unable to define pixels for source.");
    279270            psFree(readout);
     
    282273        }
    283274
    284         if (!pmSourceMoments(source, maxRadius)) {
    285             psError(PS_ERR_UNKNOWN, false, "Unable to measure moments for source.");
    286             psFree(readout);
    287             psFree(fakes);
    288             return NULL;
    289         }
     275        if (!pmSourceMoments(source, radius)) {
     276            // Can't do anything about it; limp along as best we can
     277            psErrorClear();
     278            continue;
     279        }
     280        numMoments++;
     281    }
     282
     283    if (numMoments == 0) {
     284        psError(PS_ERR_UNKNOWN, true, "Unable to measure moments for sources.");
     285        psFree(fakes);
     286        psFree(readout);
     287        return NULL;
    290288    }
    291289
     
    296294    options->poissonErrorsParams = true;
    297295    options->stats = psStatsAlloc(PSF_STATS);
    298     options->radius = maxRadius;
     296    options->radius = radius;
    299297    options->psfTrendMode = PM_TREND_MAP;
    300298    options->psfTrendNx = xOrder;
Note: See TracChangeset for help on using the changeset viewer.