Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mask outliers in BKG extensions in drizzle_from_visit #220

Merged
merged 3 commits into from
Apr 27, 2024
Merged

Conversation

gbrammer
Copy link
Owner

Add a global variable BKG_CLIP used in grizli.utils.drizzle_from_visit to mask outlier pixels in the BKG extension of grizli-processed JWST exposures. There are a few examples where there are excessively negative pixels in the BKG maps that then show up as stripes of bad pixels in the combined mosaic.

The three elements of the BKG_CLIP array are interpreted as

BKG_CLIP = [scale, percentile_lo, percentile_hi]

# Clip percentiles
bkg_lo, bkg_hi = np.nanpercentile(flt['BKG'].data[valid], BKG_CLIP[1:3])

# make sure lower (upper) limit is negative (positive)
clip_lo = -np.abs(bkg_lo)
clip_hi = np.abs(bkg_hi)

_badpix = flt['BKG'].data < BKG_CLIP[0]*bkg_lo
_badpix |= flt['BKG'].data > BKG_CLIP[0]*bkg_hi

where the _badpix mask is added to the DQ mask for that exposure.

To turn off the masking, set grizli.utils.BKG_CLIP = None (it's not currently implemented as a keyword argument on grizli.utils.drizzle_from_visit ).

@gbrammer gbrammer changed the title Add option mask outliers in BKG extensions in drizzle_from_visit Mask outliers in BKG extensions in drizzle_from_visit Apr 27, 2024
@gbrammer gbrammer merged commit f4d761f into master Apr 27, 2024
9 checks passed
@gbrammer gbrammer deleted the fix-bad-bkg branch April 27, 2024 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant