IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 31, 2012, 11:50:18 AM (14 years ago)
Author:
eugene
Message:

merge changes from trunk

Location:
branches/eam_branches/ipp-20120627/psphot
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20120627/psphot

  • branches/eam_branches/ipp-20120627/psphot/src

  • branches/eam_branches/ipp-20120627/psphot/src/psphotSourceSize.c

    r34179 r34247  
    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    }
     
    647653        psTrace("psphot", 6, "mask cosmic ray at %f, %f\n", source->peak->xf, source->peak->yf);
    648654        if (options->applyCRmask) {
    649             psphotMaskCosmicRay(readout, source, options->crMask);
     655            psphotMaskCosmicRay(readout, source, options->crMask, options->maxWindowCR);
    650656        } else {
    651657            source->mode |= PM_SOURCE_MODE_CR_LIMIT;
     
    687693// does no repair or recovery of the CR pixels, it only masks them out.  My test code can be
    688694// found at /data/ipp031.0/watersc1/psphot.20091209/algo_check.c
    689 bool psphotMaskCosmicRay (pmReadout *readout, pmSource *source, psImageMaskType maskVal) {
     695bool psphotMaskCosmicRay (pmReadout *readout, pmSource *source, psImageMaskType maskVal, int maxWindowCR) {
    690696
    691697    // Get the actual images and information about the peak.
     
    699705    int ys = footprint->bbox.y0;
    700706    int ye = footprint->bbox.y1 + 1;
     707
     708    // We occasionally get very large footprints. When the footprint bounding box is large this function will
     709    // do an incredible amount of work for no benefit.
     710    // Limit the size of the area we examine.
     711    if (xe - xs > maxWindowCR) {
     712        xs = peak->x - maxWindowCR / 2;
     713        xe = xs + maxWindowCR;
     714    }
     715    if (ye - ys > maxWindowCR) {
     716        ys = peak->y - maxWindowCR / 2;
     717        ye = ys + maxWindowCR;
     718    }
    701719
    702720    LIMIT_XRANGE(xs, mask);
     
    741759    for (int i = 0; i < footprint->spans->n; i++) {
    742760        pmSpan *sp = footprint->spans->data[i];
    743         for (int j = sp->x0; j <= sp->x1; j++) {
    744             int y = sp->y - ys;
    745             int x = j - xs;
     761        int y = sp->y - ys;
     762        if (y < 0 || y >= mymask->numRows) {
     763            // can we break if y >= numRows?
     764            continue;
     765        }
     766        for (int x = PS_MAX(sp->x0 - xs, 0); x <= PS_MIN(sp->x1 - xs, mymask->numCols-1); x++) {
    746767            mymask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= 0x01;
    747768        }
     
    883904
    884905bool psphotMaskCosmicRayFootprintCheck (psArray *sources) {
    885 
     906#ifdef CHECK_FOOTPRINTS
     907    // This gets really expensive for complex images
    886908    for (int i = 0; i < sources->n; i++) {
    887909        pmSource *source = sources->data[i];
     
    894916        }
    895917    }
     918#endif
    896919    return true;
    897920}
Note: See TracChangeset for help on using the changeset viewer.