Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JP-3770: emicorr memory and run time improvement #8849

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions changes/8849.refpix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Removed the interleve array and do interleving of noise and subtraction in-place to avoid creating 2 arrays of equal dimensions to data
16 changes: 7 additions & 9 deletions jwst/emicorr/emicorr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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] -= 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:
Expand Down
4 changes: 2 additions & 2 deletions jwst/emicorr/tests/test_emicorr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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'
Expand Down
Loading