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 @@
Improving runtime and memory usage
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a little more detail here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing!

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] = output_model.data[..., noise_x + k] - dd_noise
melanieclarke marked this conversation as resolved.
Show resolved Hide resolved

# 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
Loading