From 56f63701557a50f50a5bfa174c5643edac6e1f2e Mon Sep 17 00:00:00 2001 From: Maria Pena-Guerrero Date: Tue, 1 Oct 2024 18:44:11 -0400 Subject: [PATCH 1/8] improving runtime and memory usage --- jwst/emicorr/emicorr.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/jwst/emicorr/emicorr.py b/jwst/emicorr/emicorr.py index 3c714a1e7d..6ce99ba878 100644 --- a/jwst/emicorr/emicorr.py +++ b/jwst/emicorr/emicorr.py @@ -438,25 +438,23 @@ def apply_emicorr(output_model, emicorr_model, # This is the phase matched noise model to subtract from each pixel of the input image dd_noise = lut[(phaseall * period_in_pixels).astype(int)] - # Interleave (straight copy) into 4 amps - noise = np.zeros((nints, ngroups, ny, nx)) # same size as input data - noise_x = np.arange(nx4) * 4 - for k in range(4): - noise[:, :, :, noise_x + k] = dd_noise - # Safety catch; anywhere the noise value is not finite, set it to zero - noise[~np.isfinite(noise)] = 0.0 + dd_noise[~np.isfinite(dd_noise)] = 0.0 # Subtract EMI noise from the input data log.info('Subtracting EMI noise from data') - output_model.data = output_model.data - noise + + # Interleave (straight copy) into 4 amps + noise_x = np.arange(nx4) * 4 + for k in range(4): + output_model.data[..., noise_x + k] = output_model.data[..., noise_x + k] - dd_noise # clean up del data del dd_all del times_this_int del phaseall - del noise + del dd_noise if save_intermediate_results and save_onthefly_reffile is not None: if 'FAST' in readpatt: From ea96ff081de4985aa52657d93bed976957aa15b2 Mon Sep 17 00:00:00 2001 From: Maria Pena-Guerrero Date: Tue, 1 Oct 2024 18:48:10 -0400 Subject: [PATCH 2/8] changes entry --- changes/8849 | 1 + 1 file changed, 1 insertion(+) create mode 100644 changes/8849 diff --git a/changes/8849 b/changes/8849 new file mode 100644 index 0000000000..891f3cdffd --- /dev/null +++ b/changes/8849 @@ -0,0 +1 @@ +Improving runtime and memory usage From 466033e515ba60154bd0b842612539af0473a3d3 Mon Sep 17 00:00:00 2001 From: Maria Pena-Guerrero Date: Wed, 2 Oct 2024 09:54:09 -0400 Subject: [PATCH 3/8] adding changes --- changes/8847.refpix.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changes/8847.refpix.rst diff --git a/changes/8847.refpix.rst b/changes/8847.refpix.rst new file mode 100644 index 0000000000..44b6fe0d39 --- /dev/null +++ b/changes/8847.refpix.rst @@ -0,0 +1 @@ +Include resample and extract_1d into MOS background pipeline From 32e96b13b4d0b9034ad1dcd850e4efdd81601aee Mon Sep 17 00:00:00 2001 From: Maria Pena-Guerrero Date: Wed, 2 Oct 2024 09:57:44 -0400 Subject: [PATCH 4/8] adding changes --- changes/8849.refpix.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changes/8849.refpix.rst diff --git a/changes/8849.refpix.rst b/changes/8849.refpix.rst new file mode 100644 index 0000000000..891f3cdffd --- /dev/null +++ b/changes/8849.refpix.rst @@ -0,0 +1 @@ +Improving runtime and memory usage From 8e5016f3411f6bdb8acd93c2f37502f920b033bc Mon Sep 17 00:00:00 2001 From: Maria Pena-Guerrero Date: Wed, 2 Oct 2024 10:05:56 -0400 Subject: [PATCH 5/8] removing error --- changes/8849 | 1 - 1 file changed, 1 deletion(-) delete mode 100644 changes/8849 diff --git a/changes/8849 b/changes/8849 deleted file mode 100644 index 891f3cdffd..0000000000 --- a/changes/8849 +++ /dev/null @@ -1 +0,0 @@ -Improving runtime and memory usage From b76e87795fd44d3ab83cf43895bab51efeb86249 Mon Sep 17 00:00:00 2001 From: Maria Date: Wed, 2 Oct 2024 10:14:40 -0400 Subject: [PATCH 6/8] Delete changes/8847.refpix.rst this was a mistake from a different PR --- changes/8847.refpix.rst | 1 - 1 file changed, 1 deletion(-) delete mode 100644 changes/8847.refpix.rst diff --git a/changes/8847.refpix.rst b/changes/8847.refpix.rst deleted file mode 100644 index 44b6fe0d39..0000000000 --- a/changes/8847.refpix.rst +++ /dev/null @@ -1 +0,0 @@ -Include resample and extract_1d into MOS background pipeline From 4bf36c49daad7a7887e03134516a17b2cdc15d7b Mon Sep 17 00:00:00 2001 From: Maria Pena-Guerrero Date: Thu, 3 Oct 2024 09:45:35 -0400 Subject: [PATCH 7/8] addressing comments --- jwst/emicorr/emicorr.py | 2 +- jwst/emicorr/tests/test_emicorr.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/jwst/emicorr/emicorr.py b/jwst/emicorr/emicorr.py index 6ce99ba878..6386b8e76c 100644 --- a/jwst/emicorr/emicorr.py +++ b/jwst/emicorr/emicorr.py @@ -447,7 +447,7 @@ def apply_emicorr(output_model, emicorr_model, # Interleave (straight copy) into 4 amps noise_x = np.arange(nx4) * 4 for k in range(4): - output_model.data[..., noise_x + k] = output_model.data[..., noise_x + k] - dd_noise + output_model.data[..., noise_x + k] -= dd_noise # clean up del data diff --git a/jwst/emicorr/tests/test_emicorr.py b/jwst/emicorr/tests/test_emicorr.py index 412e6033e6..1dcfb19cd3 100644 --- a/jwst/emicorr/tests/test_emicorr.py +++ b/jwst/emicorr/tests/test_emicorr.py @@ -7,7 +7,7 @@ import numpy as np from jwst.emicorr import emicorr, emicorr_step -from stdatamodels.jwst.datamodels import Level1bModel, EmiModel +from stdatamodels.jwst.datamodels import RampModel, EmiModel subarray_example_case = { @@ -33,7 +33,7 @@ def mk_data_mdl(data, subarray, readpatt, detector): # create input_model - input_model = Level1bModel(data=data) + input_model = RampModel(data=data) input_model.meta.instrument.name = 'MIRI' input_model.meta.instrument.detector = detector input_model.meta.exposure.type = 'MIR_4QPM' From 2976d4b958fae999209e7d023296f708038c9270 Mon Sep 17 00:00:00 2001 From: Maria Pena-Guerrero Date: Fri, 4 Oct 2024 19:43:20 -0400 Subject: [PATCH 8/8] adding more detail to Changes file --- changes/8849.refpix.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changes/8849.refpix.rst b/changes/8849.refpix.rst index 891f3cdffd..2901259a74 100644 --- a/changes/8849.refpix.rst +++ b/changes/8849.refpix.rst @@ -1 +1 @@ -Improving runtime and memory usage +Removed the interleve array and do interleving of noise and subtraction in-place to avoid creating 2 arrays of equal dimensions to data