From faee8663f117ee4f5275eef05869a2ee8601679e Mon Sep 17 00:00:00 2001 From: mlibralato <78165985+mlibralato@users.noreply.github.com> Date: Thu, 30 Nov 2023 15:16:33 -0500 Subject: [PATCH] JP-3455: Updated MIRI imager photom step (#8096) Co-authored-by: Howard Bushouse --- CHANGES.rst | 5 +++++ jwst/photom/miri_imager.py | 35 ++++++++++++++++++++++++++++++++ jwst/photom/photom.py | 28 ++++++++++++++++++++++++- jwst/photom/tests/test_photom.py | 18 +++++++++++++--- 4 files changed, 82 insertions(+), 4 deletions(-) create mode 100644 jwst/photom/miri_imager.py diff --git a/CHANGES.rst b/CHANGES.rst index 4596833ef8..67ae78eacb 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -61,6 +61,11 @@ imprint - Updated the logging to report which imprint image is being subtracted from the science image. [#8041] +photom +-------- + +- Added time-dependent correction for MIRI Imager data [#8096, spacetelescope/stdatamodels#235] + pixel_replace ------------- diff --git a/jwst/photom/miri_imager.py b/jwst/photom/miri_imager.py new file mode 100644 index 0000000000..96eec891ad --- /dev/null +++ b/jwst/photom/miri_imager.py @@ -0,0 +1,35 @@ +import logging +import numpy as np + +log = logging.getLogger(__name__) +log.setLevel(logging.DEBUG) + +# Routine to find a time-dependent correction to the PHOTOM value. + +def time_corr_photom(param, t): + """ + Short Summary + -------------- + Time dependent PHOTOM function. + + The model parameters are amplitude, tau, t0. t0 is the reference day + from which the time-dependent parameters were derived. This function will return + a correction to apply to the PHOTOM value at a given MJD. + + Parameters + ---------- + param : numpy array + Set of parameters for the PHOTOM value + t : int + Modified Julian Day (MJD) of the observation + + Returns + ------- + corr: float + The time-dependent correction to the photmjsr term. + """ + + amplitude, tau, t0 = param["amplitude"], param["tau"], param["t0"] + corr = amplitude * np.exp(-(t - t0)/tau) + + return corr diff --git a/jwst/photom/photom.py b/jwst/photom/photom.py index a2c61244d9..d5d695cc7d 100644 --- a/jwst/photom/photom.py +++ b/jwst/photom/photom.py @@ -10,6 +10,7 @@ from .. lib.wcs_utils import get_wavelengths from . import miri_mrs +from . import miri_imager log = logging.getLogger(__name__) log.setLevel(logging.DEBUG) @@ -468,7 +469,32 @@ def calc_miri(self, ftab): row = find_row(ftab.phot_table, fields_to_match) if row is None: return - self.photom_io(ftab.phot_table[row]) + self.photom_io(ftab.phot_table[row]) + + # Check if reference file contains the coefficients for the time-dependent correction of the PHOTOM value + try: + ftab.getarray_noinit("timecoeff") + log.info("Applying the time-dependent correction to the PHOTOM value.") + + mid_time = self.input.meta.exposure.mid_time + photom_corr = miri_imager.time_corr_photom(ftab.timecoeff[row], mid_time) + + data = np.array( + [(self.filter, self.subarray, ftab.phot_table[row]['photmjsr']+photom_corr, ftab.phot_table[row]['uncertainty'])], + dtype=[ + ("filter", "O"), + ("subarray", "O"), + ("photmjsr", "