Skip to content

Commit

Permalink
Merge pull request #212 from TheSkyentist/oneoverf
Browse files Browse the repository at this point in the history
Optional 1/f when setting JWST/HST keywords
  • Loading branch information
gbrammer committed Apr 25, 2024
2 parents 0dd0f2f + 8e0c629 commit 7e06896
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions grizli/jwst_utils.py
Expand Up @@ -923,7 +923,7 @@ def copy_jwst_keywords(header, orig_keys=ORIG_KEYS, verbose=True):
utils.log_comment(utils.LOGFILE, msg, verbose=verbose)


def exposure_oneoverf_correction(file, axis=None, thresholds=[5,4,3], erode_mask=None, dilate_iterations=3, deg_pix=64, make_plot=True, init_model=0, in_place=False, skip_miri=True, verbose=True, **kwargs):
def exposure_oneoverf_correction(file, axis=None, thresholds=[5,4,3], erode_mask=None, dilate_iterations=3, deg_pix=64, make_plot=True, init_model=0, in_place=False, skip_miri=True, force_oneoverf=False, verbose=True, **kwargs):
"""
1/f correction for individual exposure
Expand Down Expand Up @@ -971,6 +971,9 @@ def exposure_oneoverf_correction(file, axis=None, thresholds=[5,4,3], erode_mask
skip_miri : bool
Don't run on MIRI exposures
force_oneoverf : bool
Force the correction even if the `ONEFEXP` keyword is already set
verbose : bool
Print status messages
Expand All @@ -997,6 +1000,14 @@ def exposure_oneoverf_correction(file, axis=None, thresholds=[5,4,3], erode_mask
utils.log_comment(utils.LOGFILE, msg, verbose=verbose)

return None, 0

if ('ONEFEXP' in im[0].header) and im[0].header['ONEFEXP'] and (not force_oneoverf):
im.close()

msg = 'exposure_oneoverf_correction: Skip, already corrected'
utils.log_comment(utils.LOGFILE, msg, verbose=verbose)

return None, 0

if axis is None:
if im[0].header['INSTRUME'] in ('NIRISS', 'NIRSPEC'):
Expand Down Expand Up @@ -1456,7 +1467,7 @@ def initialize_jwst_image(filename, verbose=True, max_dq_bit=14, orig_keys=ORIG_
# 'F480M': [1.879639e-21, 1.453752e-30, 4.8152]}
#

def set_jwst_to_hst_keywords(input, reset=False, verbose=True, orig_keys=ORIG_KEYS):
def set_jwst_to_hst_keywords(input, reset=False, verbose=True, orig_keys=ORIG_KEYS, oneoverf_correction=True):
"""
Make primary header look like an HST instrument
"""
Expand All @@ -1476,7 +1487,7 @@ def set_jwst_to_hst_keywords(input, reset=False, verbose=True, orig_keys=ORIG_KE
'DETECTOR':'IR'}

if 'OTELESCO' not in img[0].header:
_status = initialize_jwst_image(input, verbose=verbose)
_status = initialize_jwst_image(input, oneoverf_correction=oneoverf_correction, verbose=verbose)

# Reopen
if isinstance(input, str):
Expand Down

0 comments on commit 7e06896

Please sign in to comment.