Skip to content

Commit 47b063e

Browse files
committed
Rename mrs_time_correction parameter; apply option to all modes
1 parent c686da4 commit 47b063e

File tree

3 files changed

+40
-12
lines changed

3 files changed

+40
-12
lines changed

jwst/photom/photom.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def __init__(
100100
model,
101101
inverse=False,
102102
source_type=None,
103-
mrs_time_correction=False,
103+
apply_time_correction=True,
104104
correction_pars=None,
105105
):
106106
"""
@@ -114,8 +114,8 @@ def __init__(
114114
Invert the math operations used to apply the corrections.
115115
source_type : str or None
116116
Force processing using the specified source type.
117-
mrs_time_correction : bool
118-
Switch to apply/not apply the MRS time correction.
117+
apply_time_correction : bool
118+
Switch to apply/not apply a time correction, if available.
119119
correction_pars : dict
120120
Correction meta-data from a previous run.
121121
"""
@@ -158,7 +158,7 @@ def __init__(
158158
self.integ_row = -1
159159
self.inverse = inverse
160160
self.source_type = None
161-
self.mrs_time_correction = mrs_time_correction
161+
self.apply_time_correction = apply_time_correction
162162

163163
# For MultiSlitModels, only set a generic source_type value for the
164164
# entire datamodel if the user has set the source_type parameter.
@@ -545,9 +545,9 @@ def calc_miri(self, ftab):
545545
"Skipping MRS MIRI time correction. "
546546
"Extensions not found in the reference file."
547547
)
548-
self.mrs_time_correction = False
548+
self.apply_time_correction = False
549549

550-
if self.mrs_time_correction:
550+
if self.apply_time_correction:
551551
log.info("Applying MRS IFU time dependent correction.")
552552
mid_time = self.input.meta.exposure.mid_time
553553
correction = time_dependence.miri_mrs_time_correction(
@@ -743,7 +743,8 @@ def photom_io(self, tabdata, order=None, time_correction=None):
743743
Multiplicative correction for time dependence, defined as the
744744
fractional amount of light recorded now divided by the light
745745
recorded on the zero-day MJD (t0). The scalar conversion factor
746-
will be divided by the correction value if provided.
746+
will be divided by the correction value if provided, and if
747+
``self.apply_time_correction`` is True.
747748
"""
748749
# First get the scalar conversion factor.
749750
# For most modes, the scalar conversion factor in the photom reference
@@ -796,7 +797,7 @@ def photom_io(self, tabdata, order=None, time_correction=None):
796797
unit_is_surface_brightness = False
797798

798799
# Apply the time-dependence correction
799-
if time_correction is not None and time_correction != 1.0:
800+
if self.apply_time_correction and time_correction is not None and time_correction != 1.0:
800801
log.info(f"Multiplicative time dependence correction is {time_correction:.6g}")
801802
conversion /= time_correction
802803

jwst/photom/photom_step.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ class PhotomStep(Step):
1414

1515
spec = """
1616
inverse = boolean(default=False) # Invert the operation
17-
source_type = string(default=None) # Process as specified source type.
18-
mrs_time_correction = boolean(default=True) # Apply the MIRI MRS time dependent correction
17+
source_type = string(default=None) # Process as specified source type
18+
time_correction = boolean(default=True) # Apply time dependent corrections if available
1919
""" # noqa: E501
2020

2121
reference_file_types = ["photom", "area"]
@@ -89,7 +89,7 @@ def process(self, input_data):
8989
input_model,
9090
self.inverse,
9191
self.source_type,
92-
self.mrs_time_correction,
92+
self.time_correction,
9393
correction_pars,
9494
)
9595
result = phot.apply_photom(phot_filename, area_filename)

jwst/photom/tests/test_photom.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1649,7 +1649,7 @@ def test_miri_mrs_time_cor():
16491649
input_model.meta.wcs.bounding_box = ((-0.5, shape[-1] - 0.5), (-0.5, shape[-2] - 0.5))
16501650

16511651
save_input = input_model.copy()
1652-
ds = photom.DataSet(input_model, mrs_time_correction=True)
1652+
ds = photom.DataSet(input_model, apply_time_correction=True)
16531653
value = 1.436
16541654
pixel_area = 0.0436
16551655
photmjsr = 17.3
@@ -1732,6 +1732,33 @@ def test_miri_image():
17321732
assert_allclose(ratio, compare, rtol=1.0e-7)
17331733

17341734

1735+
def test_miri_image_no_time_corr():
1736+
"""Test the calc_miri method of the DataSet class, image data."""
1737+
input_model = create_input("MIRI", "MIRIMAGE", "MIR_IMAGE", filter_used="F1800W")
1738+
save_input = input_model.copy()
1739+
ds = photom.DataSet(input_model, apply_time_correction=False)
1740+
ftab = create_photom_miri_image()
1741+
ds.calc_miri(ftab)
1742+
1743+
input_data = save_input.data
1744+
output = ds.input.data # ds.input is the output
1745+
rownum = find_row_in_ftab(save_input, ftab, ["filter"], slitname=None, order=None)
1746+
photmjsr = ftab.phot_table["photmjsr"][rownum]
1747+
1748+
shape = input_data.shape
1749+
ix = shape[1] // 2
1750+
iy = shape[0] // 2
1751+
1752+
# Time correction is not applied, so comparison value is just
1753+
# the conversion factor, even though timecoeff extensions
1754+
# are present.
1755+
compare = photmjsr
1756+
1757+
# Compare the values at the center pixel.
1758+
ratio = output[iy, ix] / input_data[iy, ix]
1759+
assert_allclose(ratio, compare, rtol=1.0e-7)
1760+
1761+
17351762
def test_nircam_image():
17361763
"""Test the calc_nircam method of the DataSet class, image data."""
17371764
input_model = create_input("NIRCAM", "NRCA3", "NRC_IMAGE", filter_used="F150W", pupil="CLEAR")

0 commit comments

Comments
 (0)