Skip to content

Commit

Permalink
Remove unused error from ramp data
Browse files Browse the repository at this point in the history
  • Loading branch information
melanieclarke committed Jan 29, 2025
1 parent 4f43822 commit 23bbabf
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 91 deletions.
1 change: 0 additions & 1 deletion jwst/dark_current/dark_current_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,5 +173,4 @@ def dark_output_data_2_ramp_model(out_data, out_model):
out_model.data = out_data.data
out_model.groupdq = out_data.groupdq
out_model.pixeldq = out_data.pixeldq
out_model.err = out_data.err
return out_model
11 changes: 6 additions & 5 deletions jwst/dark_current/tests/test_dark_sub.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,12 @@ def test_2_int(make_rampmodel, make_darkmodel):

# Refac done
def test_frame_avg(make_rampmodel, make_darkmodel):
'''Check that if NFRAMES>1 or GROUPGAP>0, the frame-averaged dark data are
subtracted group-by-group from science data groups and the ERR arrays are not modified'''
"""
Test frame averaging.
Check that if NFRAMES>1 or GROUPGAP>0, the frame-averaged dark data are
subtracted group-by-group from science data groups.
"""

# size of integration
nints = 1
Expand Down Expand Up @@ -393,9 +397,6 @@ def test_frame_avg(make_rampmodel, make_darkmodel):
assert outfile.data[0, 2, 500, 500] == pytest.approx(2.05)
assert outfile.data[0, 3, 500, 500] == pytest.approx(2.65)

# check that the error array is not modified.
np.testing.assert_array_equal(outfile.err[:, :], 0)


# ------------------------------------------------------------------------------
def test_basic_step(make_rampmodel, make_darkmodel):
Expand Down
41 changes: 0 additions & 41 deletions jwst/dq_init/tests/test_dq_init.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import numpy as np
import pytest
import warnings

from stdatamodels.validate import ValidationWarning
from stdatamodels.jwst.datamodels import MaskModel, GuiderRawModel, RampModel, dqflags

from jwst.dq_init import DQInitStep
Expand Down Expand Up @@ -107,45 +105,6 @@ def test_groupdq():
err_msg='groupdq not initialized to zero')


def test_err():
"""Check that a 4-D ERR array is initialized and all values are zero."""

# size of integration
instrument = 'MIRI'
nints = 1
ngroups = 5
xsize = 1032
ysize = 1024
xstart = 1
ystart = 1

# create raw input data for step
dm_ramp = make_rawramp(instrument, nints, ngroups, ysize, xsize, ystart, xstart)

# create a MaskModel for the dq input mask
dq, dq_def = make_maskmodel(ysize, xsize)

# write mask model
ref_data = MaskModel(dq=dq, dq_def=dq_def)
ref_data.meta.instrument.name = instrument
ref_data.meta.subarray.xstart = xstart
ref_data.meta.subarray.xsize = xsize
ref_data.meta.subarray.ystart = ystart
ref_data.meta.subarray.ysize = ysize

# Filter out validation warnings from ref_data
warnings.filterwarnings("ignore", category=ValidationWarning)

# run correction step
outfile = do_dqinit(dm_ramp, ref_data)

# check that ERR array was created and initialized to zero
errarr = outfile.err

assert errarr.ndim == 4 # check that output err array is 4-D
assert np.all(errarr == 0) # check that values are 0


def test_dq_subarray():
"""Test that the pipeline properly extracts the subarray from the reference file."""
# put dq flags in specific pixels and make sure they match in the output subarray file
Expand Down
2 changes: 1 addition & 1 deletion jwst/jump/jump.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def run_detect_jumps(output_model, gain_model, readnoise_model,
readnoise_model)
new_gdq, new_pdq, number_crs, number_extended_events, stddev\
= detect_jumps(frames_per_group, output_model.data, output_model.groupdq,
output_model.pixeldq, output_model.err,
output_model.pixeldq,
gain_2d, readnoise_2d,
rejection_thresh, three_grp_thresh,
four_grp_thresh, max_cores,
Expand Down
30 changes: 0 additions & 30 deletions jwst/linearity/tests/test_linearity.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,36 +291,6 @@ def test_lin_subarray():
assert (outpixdq[76, 104] == 1)


def test_err_array():
"""Test that the error array is not changed by the linearity step"""

# size of integration
ngroups = 10
xsize = 1032
ysize = 1024

# create a JWST datamodel for MIRI data
im = RampModel((1, ngroups, ysize, xsize))
im.data += 1
im.err += 2
# set file header values
im.meta.instrument.detector = 'MIRIMAGE'
im.meta.instrument.name = 'MIRI'
im.meta.observation.date = '2018-01-01'
im.meta.observation.time = '00:00:00'
im.meta.subarray.xstart = 1
im.meta.subarray.xsize = xsize
im.meta.subarray.ystart = 1
im.meta.subarray.ysize = ysize

# run pipeline
outfile = LinearityStep.call(im)

# check output of error array
# test that the science data are not changed
np.testing.assert_allclose(im.err, outfile.err)


def make_rampmodel(nints, ngroups, ysize, xsize):
"""Function to provide ramp model to tests"""

Expand Down
1 change: 0 additions & 1 deletion jwst/ramp_fitting/tests/test_ramp_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -1004,4 +1004,3 @@ def base_print(label, arr):
arr_str = np.array2string(arr, max_line_width=np.nan, separator=", ")
print(label)
print(arr_str)

11 changes: 2 additions & 9 deletions jwst/refpix/irs2_subtract_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def correct_model(output_model, irs2_model, scipix_n_default=16, refpix_r_defaul
else: # don't change orientation
output_model.data = temp_data

# Strip interleaved ref pixels from the PIXELDQ, GROUPDQ, and ERR extensions.
# Strip interleaved ref pixels from the PIXELDQ and GROUPDQ extensions.
if not preserve_refpix:
strip_ref_pixels(output_model, irs2_mask)

Expand Down Expand Up @@ -244,7 +244,7 @@ def make_irs2_mask(nx, ny, scipix_n, refpix_r):


def strip_ref_pixels(output_model, irs2_mask):
"""Copy out the normal pixels from PIXELDQ, GROUPDQ, and ERR arrays.
"""Copy out the normal pixels from PIXELDQ and GROUPDQ arrays.
Parameters
----------
Expand All @@ -267,8 +267,6 @@ def strip_ref_pixels(output_model, irs2_mask):
temp_array = output_model.groupdq
output_model.groupdq = temp_array[..., irs2_mask, :]

temp_array = output_model.err
output_model.err = temp_array[..., irs2_mask, :]
elif detector == "NRS2":
# Reverse the direction of the mask, and select rows.
temp_mask = irs2_mask[::-1]
Expand All @@ -279,8 +277,6 @@ def strip_ref_pixels(output_model, irs2_mask):
temp_array = output_model.groupdq
output_model.groupdq = temp_array[..., temp_mask, :]

temp_array = output_model.err
output_model.err = temp_array[..., temp_mask, :]
else:
# Select columns.
temp_array = output_model.pixeldq
Expand All @@ -289,9 +285,6 @@ def strip_ref_pixels(output_model, irs2_mask):
temp_array = output_model.groupdq
output_model.groupdq = temp_array[..., irs2_mask]

temp_array = output_model.err
output_model.err = temp_array[..., irs2_mask]


def clobber_ref(data, output, odd_even, mask, ref_flags, is_irs2,
scipix_n=16, refpix_r=4):
Expand Down
3 changes: 0 additions & 3 deletions jwst/refpix/tests/test_refpix.py
Original file line number Diff line number Diff line change
Expand Up @@ -987,15 +987,12 @@ def test_preserve_refpix(detector, irs2, preserve):
if not irs2:
# parameter ignored for non-irs2 data
assert out.data.shape == (1, ngroups, ysize, xsize)
assert out.err.shape == (1, ngroups, ysize, xsize)
assert out.pixeldq.shape == (ysize, xsize)
elif preserve:
# output data shape is the same
assert out.data.shape == (1, ngroups, ysize, xsize)
assert out.err.shape == (1, ngroups, ysize, xsize)
assert out.pixeldq.shape == (ysize, xsize)
else:
# output data is trimmed to remove interleaved refpix
assert out.data.shape == (1, ngroups, xsize, xsize)
assert out.err.shape == (1, ngroups, xsize, xsize)
assert out.pixeldq.shape == (xsize, xsize)

0 comments on commit 23bbabf

Please sign in to comment.