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-3827: Remove unused error from ramp data #9109

Merged
merged 3 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/9109.datamodels.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Removed the unused error array from 4D ramp models.
1 change: 1 addition & 0 deletions changes/9109.pipeline.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Removed references to the unused error array in 4D ramp models in all detector1 pipeline steps.
2 changes: 0 additions & 2 deletions docs/jwst/dark_current/description.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ subtracted from the corresponding first few integrations of the science exposure
The data in the last integration of the dark reference file is applied to all
remaining science integrations.

The ERR arrays of the science data are currently not modified by this step.

The DQ flags from the dark reference file are propagated into the science
exposure PIXELDQ array using a bitwise OR operation.

Expand Down
2 changes: 0 additions & 2 deletions docs/jwst/linearity/description.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ Special Handling
applied to that group. Any groups for that pixel that are not flagged as
saturated will be corrected.

The ERR array of the input science exposure is not modified.

The flags from the linearity reference file DQ array are propagated into the
PIXELDQ array of the science exposure using a bitwise OR operation.

Expand Down
2 changes: 1 addition & 1 deletion docs/jwst/pipeline/calwebb_detector1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ input will be in the form of a `~jwst.datamodels.Level1bModel`, which only
contains the 4D array of detector pixel values, along with some optional
extensions. When such a file is loaded into the pipeline, it is immediately
converted into a `~jwst.datamodels.RampModel`, and has all additional data arrays
for errors and Data Quality flags created and initialized to zero.
for Data Quality flags created and initialized to zero.

The input can also contain a 3D cube of NIRCam "Frame 0" data, where
each image plane in the 3D cube is the initial frame for each integration in
Expand Down
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
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)