From 92077f39ce1815055b2cc6fa8f44b02a0f7b30cd Mon Sep 17 00:00:00 2001 From: Howard Bushouse Date: Thu, 10 Sep 2020 09:39:35 -0400 Subject: [PATCH 1/3] JP-1681: Fix empty int_times table in rateints products --- jwst/ramp_fitting/ramp_fit.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jwst/ramp_fitting/ramp_fit.py b/jwst/ramp_fitting/ramp_fit.py index 2ae936c6c6..a1aca071d5 100755 --- a/jwst/ramp_fitting/ramp_fit.py +++ b/jwst/ramp_fitting/ramp_fit.py @@ -223,6 +223,7 @@ def ols_ramp_fit_multi(input_model, buffsize, save_opt, readnoise_2d, gain_2d, int_model.var_poisson = int_var_poisson int_model.var_rnoise = int_var_rnoise int_model.err = int_err + int_model.int_times = int_times # Populate the optional output model if save_opt: @@ -292,6 +293,7 @@ def ols_ramp_fit_multi(input_model, buffsize, save_opt, readnoise_2d, gain_2d, int_model, opt_model, out_model = create_output_models(input_model, number_of_integrations, save_opt, total_cols, total_rows, actual_segments, actual_CRs) + int_model.int_times = int_times # iterate over the number of slices and place the results into the output models for resultslice in real_results: @@ -1039,7 +1041,6 @@ def ols_ramp_fit(data, err, groupdq, inpixeldq, buffsize, save_opt, readnoise_2d del pixeldq # Output integration-specific results to separate file - int_times = None int_model = utils.output_integ(slope_int, dq_int, effintim, var_p3, var_r3, var_both3, int_times) if opt_res is not None: From 48ff6da28d2cf6f0d0c78f7f75b61cb64354ef62 Mon Sep 17 00:00:00 2001 From: Howard Bushouse Date: Thu, 10 Sep 2020 20:53:06 -0400 Subject: [PATCH 2/3] Add unit test and add change log entry --- CHANGES.rst | 4 ++++ jwst/ramp_fitting/tests/test_ramp_fit.py | 19 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index c55d24748b..c82ecd532f 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -53,6 +53,10 @@ pipeline - Include the per-slit failure traceback in any RuntimeError raised in Spec2Pipeline. [#5315] +ramp_fitting +------------ + +- Reinstate copying of INT_TIMES table to output rateints product for TSO exposures. [#5321] tso_photometry -------------- diff --git a/jwst/ramp_fitting/tests/test_ramp_fit.py b/jwst/ramp_fitting/tests/test_ramp_fit.py index e5643ddfe1..5da236c3d2 100644 --- a/jwst/ramp_fitting/tests/test_ramp_fit.py +++ b/jwst/ramp_fitting/tests/test_ramp_fit.py @@ -12,6 +12,22 @@ # expected to fail. Needs fixing, but the fix is not clear # to me. [KDG - 19 Dec 2018] +def test_int_times(): + # Test whether int_times table gets copied to output when it should + nints = 5 + model1, gdq, rnModel, pixdq, err, gain = setup_inputs(ngroups=3, nints=nints, nrows=2, ncols=2) + + # Set TSOVISIT false, in which case the int_times table should come back with zero length + model1.meta.visit.tsovisit = False + slopes, int_model, dum1, dum2 = ramp_fit(model1, 512, False, rnModel, gain, 'OLS', 'optimal', 'none') + assert(len(int_model.int_times) == 0) + + # Set TSOVISIT true, in which case the int_times table should come back with length nints + model1.meta.visit.tsovisit = True + slopes, int_model, dum1, dum2 = ramp_fit(model1, 512, False, rnModel, gain, 'OLS', 'optimal', 'none') + assert(len(int_model.int_times) == nints) + + def test_one_group_small_buffer_fit_ols(): model1, gdq, rnModel, pixdq, err, gain = setup_inputs(ngroups=1,gain=1,readnoise=10) model1.data[0, 0, 50, 50] = 10.0 @@ -668,7 +684,8 @@ def setup_inputs(ngroups=10, readnoise=10, nints=1, pixdq = np.zeros(shape=(nrows, ncols), dtype= np.float64) read_noise = np.full((nrows, ncols), readnoise, dtype=np.float64) gdq = np.zeros(shape=(nints, ngroups, nrows, ncols), dtype=np.int32) - model1 = RampModel(data=data, err=err, pixeldq=pixdq, groupdq=gdq, times=times) + int_times = np.zeros((nints,7)) + model1 = RampModel(data=data, err=err, pixeldq=pixdq, groupdq=gdq, int_times=int_times) model1.meta.instrument.name='MIRI' model1.meta.instrument.detector='MIRIMAGE' model1.meta.instrument.filter='F480M' From c97e6adfc677cd32a076ba8b9a6e825c65cdeee9 Mon Sep 17 00:00:00 2001 From: Howard Bushouse Date: Thu, 10 Sep 2020 22:39:36 -0400 Subject: [PATCH 3/3] pep8 fixes --- jwst/ramp_fitting/tests/test_ramp_fit.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/jwst/ramp_fitting/tests/test_ramp_fit.py b/jwst/ramp_fitting/tests/test_ramp_fit.py index 5da236c3d2..7b5b3a69ba 100644 --- a/jwst/ramp_fitting/tests/test_ramp_fit.py +++ b/jwst/ramp_fitting/tests/test_ramp_fit.py @@ -26,7 +26,7 @@ def test_int_times(): model1.meta.visit.tsovisit = True slopes, int_model, dum1, dum2 = ramp_fit(model1, 512, False, rnModel, gain, 'OLS', 'optimal', 'none') assert(len(int_model.int_times) == nints) - + def test_one_group_small_buffer_fit_ols(): model1, gdq, rnModel, pixdq, err, gain = setup_inputs(ngroups=1,gain=1,readnoise=10) @@ -677,7 +677,6 @@ def setup_small_cube(ngroups=10, nints=1, nrows=2, ncols=2, deltatime=10., def setup_inputs(ngroups=10, readnoise=10, nints=1, nrows=103, ncols=102, nframes=1, grouptime=1.0,gain=1, deltatime=1): - times = np.array(list(range(ngroups)),dtype=np.float64) * deltatime gain = np.ones(shape=(nrows, ncols), dtype=np.float64) * gain err = np.ones(shape=(nints, ngroups, nrows, ncols), dtype=np.float64) data = np.zeros(shape=(nints, ngroups, nrows, ncols), dtype=np.uint32)