IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 34201


Ignore:
Timestamp:
Jul 24, 2012, 3:42:45 PM (14 years ago)
Author:
bills
Message:

The cosmic ray code was going a bit mental when presented with
really large footprints. Change the code to search a configurable
window rather than the entire image.
Also disable psphotMaskCosmicRayFootprintCheck. The assertion
no longer triggers and it also uses up lots of time for large footprints

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/psphotSourceSize.c

    r32633 r34201  
    1818    float sizeLimitCR;
    1919    float magLimitCR;
     20    int maxWindowCR;
    2021} psphotSourceSizeOptions;
    2122
     
    2627bool psphotSourceClassRegion (psRegion *region, pmPSFClump *psfClump, psArray *sources, psMetadata *recipe, pmPSF *psf, psphotSourceSizeOptions *options);
    2728bool psphotSourceSelectCR (pmReadout *readout, psArray *sources, psphotSourceSizeOptions *options);
    28 bool psphotMaskCosmicRay (pmReadout *readout, pmSource *source, psImageMaskType maskVal);
     29bool psphotMaskCosmicRay (pmReadout *readout, pmSource *source, psImageMaskType maskVal, int maxWindowCR);
    2930bool psphotMaskCosmicRayFootprintCheck (psArray *sources);
    3031int  psphotMaskCosmicRayConnected (int xPeak, int yPeak, psImage *mymask, psImage *myvar, psImage *edges, int binning, float sigma_thresh);
     
    139140    if (!status) {
    140141        psError(PS_ERR_BAD_PARAMETER_VALUE, true, "PSPHOT.CRMASK.APPLY is not defined.");
     142        return false;
     143    }
     144    options.maxWindowCR =  psMetadataLookupS32 (&status, recipe, "PSPHOT.CR.MAX.WINDOW");
     145    if (!status) {
     146        psError(PS_ERR_BAD_PARAMETER_VALUE, true, "PSPHOT.CR.MAX.WINDOW is not defined.");
    141147        return false;
    142148    }
     
    637643        psTrace("psphot", 6, "mask cosmic ray at %f, %f\n", source->peak->xf, source->peak->yf);
    638644        if (options->applyCRmask) {
    639             psphotMaskCosmicRay(readout, source, options->crMask);
     645            psphotMaskCosmicRay(readout, source, options->crMask, options->maxWindowCR);
    640646        } else {
    641647            source->mode |= PM_SOURCE_MODE_CR_LIMIT;
     
    677683// does no repair or recovery of the CR pixels, it only masks them out.  My test code can be
    678684// found at /data/ipp031.0/watersc1/psphot.20091209/algo_check.c
    679 bool psphotMaskCosmicRay (pmReadout *readout, pmSource *source, psImageMaskType maskVal) {
     685bool psphotMaskCosmicRay (pmReadout *readout, pmSource *source, psImageMaskType maskVal, int maxWindowCR) {
    680686
    681687    // Get the actual images and information about the peak.
     
    689695    int ys = footprint->bbox.y0;
    690696    int ye = footprint->bbox.y1 + 1;
     697
     698    // We occasionally get very large footprints. When the footprint bounding box is large this function will
     699    // do an incredible amount of work for no benefit.
     700    // Limit the size of the area we examine.
     701    if (xe - xs > maxWindowCR) {
     702        xs = peak->x - maxWindowCR / 2;
     703        xe = xs + maxWindowCR;
     704    }
     705    if (ye - ys > maxWindowCR) {
     706        ys = peak->y - maxWindowCR / 2;
     707        ye = ys + maxWindowCR;
     708    }
    691709
    692710    LIMIT_XRANGE(xs, mask);
     
    731749    for (int i = 0; i < footprint->spans->n; i++) {
    732750        pmSpan *sp = footprint->spans->data[i];
    733         for (int j = sp->x0; j <= sp->x1; j++) {
    734             int y = sp->y - ys;
    735             int x = j - xs;
     751        int y = sp->y - ys;
     752        if (y < 0 || y >= mymask->numRows) {
     753            // can we break if y >= numRows?
     754            continue;
     755        }
     756        for (int x = PS_MAX(sp->x0 - xs, 0); x <= PS_MIN(sp->x1 - xs, mymask->numCols-1); x++) {
    736757            mymask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= 0x01;
    737758        }
     
    873894
    874895bool psphotMaskCosmicRayFootprintCheck (psArray *sources) {
    875 
     896#ifdef CHECK_FOOTPRINTS
     897    // This gets really expensive for complex images
    876898    for (int i = 0; i < sources->n; i++) {
    877899        pmSource *source = sources->data[i];
     
    884906        }
    885907    }
     908#endif
    886909    return true;
    887910}
Note: See TracChangeset for help on using the changeset viewer.