Skip to content

Commit e6acae9

Browse files
committed
Merge branch 'main' of https://github.com/spacetelescope/jwst into JP-3931-test-followup
2 parents b0f494d + a4846d5 commit e6acae9

File tree

14 files changed

+34
-33
lines changed

14 files changed

+34
-33
lines changed

changes/9533.background.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Change background alias to "bkg_subtract" to fix conflicting aliases for the step. The new alias is the one currently used for running the step or changing parameters from the stage2 pipelines.

docs/jwst/background_step/description.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Description
22
===========
33

44
:Class: `jwst.background.BackgroundStep`
5-
:Alias: background
5+
:Alias: bkg_subtract
66

77
The background subtraction step performs
88
image-from-image subtraction in order to accomplish subtraction of background

jwst/background/background_step.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
class BackgroundStep(Step):
1717
"""Subtract background exposures from target exposures."""
1818

19-
class_alias = "background"
19+
class_alias = "bkg_subtract"
2020

2121
spec = """
2222
bkg_list = force_list(default=None) # List of background files. Ignored for WFSS or if asn is provided
@@ -80,9 +80,9 @@ def process(self, step_input, input_bkg_list=None):
8080
)
8181
if result is None:
8282
result = input_model.copy()
83-
result.meta.cal_step.back_sub = "SKIPPED"
83+
result.meta.cal_step.bkg_subtract = "SKIPPED"
8484
else:
85-
result.meta.cal_step.back_sub = "COMPLETE"
85+
result.meta.cal_step.bkg_subtract = "COMPLETE"
8686

8787
elif input_model.meta.exposure.type == "NIS_SOSS":
8888
# Fetch the background reference filename
@@ -126,7 +126,7 @@ def process(self, step_input, input_bkg_list=None):
126126
# or report and skip the step
127127
if bkg_list is None or len(bkg_list) == 0:
128128
self.log.warning("* No background list provided * Skipping step.")
129-
result.meta.cal_step.back_sub = "SKIPPED"
129+
result.meta.cal_step.bkg_subtract = "SKIPPED"
130130
return result
131131

132132
# check if input data is NRS_IFU
@@ -154,13 +154,13 @@ def process(self, step_input, input_bkg_list=None):
154154
# Do the background subtraction
155155
if do_sub:
156156
bkg_model, result = background_sub(result, bkg_list, self.sigma, self.maxiters)
157-
result.meta.cal_step.back_sub = "COMPLETE"
157+
result.meta.cal_step.bkg_subtract = "COMPLETE"
158158
if self.save_combined_background:
159159
comb_bkg_path = self.save_model(bkg_model, suffix=self.bkg_suffix, force=True)
160160
self.log.info(f"Combined background written to {comb_bkg_path}.")
161161

162162
else:
163-
result.meta.cal_step.back_sub = "SKIPPED"
163+
result.meta.cal_step.bkg_subtract = "SKIPPED"
164164
self.log.warning("Skipping background subtraction")
165165
self.log.warning(
166166
"GWA_XTIL and GWA_YTIL source values are not the same as bkg values"

jwst/background/tests/test_background.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def test_nirspec_gwa(tmp_cwd, background, science_image):
177177
test = science_image.data - back_image.data
178178
assert_allclose(result.data, test)
179179
assert type(result) is type(science_image)
180-
assert result.meta.cal_step.back_sub == 'COMPLETE'
180+
assert result.meta.cal_step.bkg_subtract == 'COMPLETE'
181181
back_image.close()
182182

183183

@@ -199,7 +199,7 @@ def test_nirspec_gwa_xtilt(tmp_cwd, background, science_image):
199199
result = BackgroundStep.call(science_image, bkg)
200200

201201
assert type(result) is type(science_image)
202-
assert result.meta.cal_step.back_sub == 'SKIPPED'
202+
assert result.meta.cal_step.bkg_subtract == 'SKIPPED'
203203
back_image.close()
204204

205205

@@ -221,7 +221,7 @@ def test_nirspec_gwa_ytilt(tmp_cwd, background, science_image):
221221
result = BackgroundStep.call(science_image, bkg)
222222

223223
assert type(result) is type(science_image)
224-
assert result.meta.cal_step.back_sub == 'SKIPPED'
224+
assert result.meta.cal_step.bkg_subtract == 'SKIPPED'
225225

226226
back_image.close()
227227

@@ -245,7 +245,7 @@ def test_miri_subarray_full_overlap(data_shape, background_shape):
245245

246246
assert_allclose(result.data, image_value - background_value)
247247
assert type(result) is type(image)
248-
assert result.meta.cal_step.back_sub == 'COMPLETE'
248+
assert result.meta.cal_step.bkg_subtract == 'COMPLETE'
249249

250250
image.close()
251251
background.close()
@@ -269,7 +269,7 @@ def test_miri_subarray_partial_overlap(data_shape, background_shape):
269269
assert_allclose(result.data[..., background_shape[-2]:, :], image_value)
270270
assert_allclose(result.data[..., :, background_shape[-1]:], image_value)
271271
assert type(result) is type(image)
272-
assert result.meta.cal_step.back_sub == 'COMPLETE'
272+
assert result.meta.cal_step.bkg_subtract == 'COMPLETE'
273273

274274
image.close()
275275
background.close()
@@ -283,7 +283,7 @@ def test_asn_input(mk_asn):
283283
bgs = datamodels.open(bg_subtracted)
284284

285285
assert_allclose(result.data, bgs.data)
286-
assert result.meta.cal_step.back_sub == 'COMPLETE'
286+
assert result.meta.cal_step.bkg_subtract == 'COMPLETE'
287287

288288
result.close()
289289
bgs.close()
@@ -304,11 +304,11 @@ def test_bg_file_list(mk_asn):
304304
assert_allclose(result1.data, bgs.data)
305305
assert_allclose(result2.data, bgs.data)
306306
assert_allclose(result3.data, bgs.data)
307-
assert result1.meta.cal_step.back_sub == 'COMPLETE'
308-
assert result2.meta.cal_step.back_sub == 'COMPLETE'
309-
assert result3.meta.cal_step.back_sub == 'COMPLETE'
310-
assert result4.meta.cal_step.back_sub == 'SKIPPED'
311-
assert result5.meta.cal_step.back_sub == 'SKIPPED'
307+
assert result1.meta.cal_step.bkg_subtract == 'COMPLETE'
308+
assert result2.meta.cal_step.bkg_subtract == 'COMPLETE'
309+
assert result3.meta.cal_step.bkg_subtract == 'COMPLETE'
310+
assert result4.meta.cal_step.bkg_subtract == 'SKIPPED'
311+
assert result5.meta.cal_step.bkg_subtract == 'SKIPPED'
312312

313313
result1.close()
314314
result2.close()

jwst/background/tests/test_background_wfss.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,5 +458,5 @@ def test_wfss_asn_input(mock_asn_and_data):
458458
assert result.meta.source_catalog == "test_cat.ecsv"
459459
assert result.meta.direct_image == i2dfile.name
460460
assert result.meta.segmentation_map == segmfile.name
461-
assert result.meta.cal_step.back_sub == "COMPLETE"
461+
assert result.meta.cal_step.bkg_subtract == "COMPLETE"
462462

jwst/extract_1d/psf_profile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ def psf_profile(
319319
# Check if we need to add a negative nod pair trace
320320
nod_offset = None
321321
if model_nod_pair:
322-
nod_subtracted = str(input_model.meta.cal_step.back_sub) == "COMPLETE"
322+
nod_subtracted = str(input_model.meta.cal_step.bkg_subtract) == "COMPLETE"
323323
pattype_ok = str(input_model.meta.dither.primary_type) in NOD_PAIR_PATTERN
324324
if not nod_subtracted:
325325
log.info("Input data was not nod-subtracted. A negative trace will not be modeled.")

jwst/extract_1d/tests/test_extract.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,7 +1174,7 @@ def test_define_aperture_optimal_with_nod(
11741174
exptype = "MIR_LRS-FIXEDSLIT"
11751175

11761176
# mock nod subtraction
1177-
mock_miri_lrs_fs.meta.cal_step.back_sub = "COMPLETE"
1177+
mock_miri_lrs_fs.meta.cal_step.bkg_subtract = "COMPLETE"
11781178
mock_miri_lrs_fs.meta.dither.primary_type = "ALONG-SLIT-NOD"
11791179

11801180
# mock a nod position at the opposite end of the array
@@ -1607,7 +1607,7 @@ def test_create_extraction_optimal(monkeypatch, create_extraction_inputs, psf_re
16071607
model = create_extraction_inputs[0]
16081608

16091609
# mock nod subtraction
1610-
model.meta.cal_step.back_sub = "COMPLETE"
1610+
model.meta.cal_step.bkg_subtract = "COMPLETE"
16111611
model.meta.dither.primary_type = "2-POINT-NOD"
16121612

16131613
# mock a nod position at the opposite end of the array

jwst/extract_1d/tests/test_psf_profile.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ def test_psf_profile_model_nod(monkeypatch, mock_miri_lrs_fs, psf_reference_file
248248
_, _, wl_array = model.meta.wcs(xidx, yidx)
249249

250250
# mock nod subtraction
251-
model.meta.cal_step.back_sub = "COMPLETE"
251+
model.meta.cal_step.bkg_subtract = "COMPLETE"
252252
model.meta.dither.primary_type = "2-POINT-NOD"
253253

254254
# mock a nod position at the opposite end of the array
@@ -316,7 +316,7 @@ def test_psf_profile_model_nod_wrong_pattern(mock_miri_lrs_fs, psf_reference_fil
316316
model = mock_miri_lrs_fs
317317
data_shape = model.data.shape
318318
trace = np.full(data_shape[0], (data_shape[1] - 1) / 2.0)
319-
model.meta.cal_step.back_sub = "COMPLETE"
319+
model.meta.cal_step.bkg_subtract = "COMPLETE"
320320

321321
yidx, xidx = np.mgrid[: data_shape[0], : data_shape[1]]
322322
_, _, wl_array = model.meta.wcs(xidx, yidx)
@@ -335,7 +335,7 @@ def test_psf_profile_model_nod_bad_position(mock_miri_lrs_fs, psf_reference_file
335335
model = mock_miri_lrs_fs
336336
data_shape = model.data.shape
337337
trace = np.full(data_shape[0], (data_shape[1] - 1) / 2.0)
338-
model.meta.cal_step.back_sub = "COMPLETE"
338+
model.meta.cal_step.bkg_subtract = "COMPLETE"
339339
model.meta.dither.primary_type = "2-POINT-NOD"
340340

341341
yidx, xidx = np.mgrid[: data_shape[0], : data_shape[1]]
@@ -394,7 +394,7 @@ def test_psf_profile_optimize_with_nod(
394394
data_shape = model.data.shape
395395

396396
# mock nod subtraction
397-
model.meta.cal_step.back_sub = "COMPLETE"
397+
model.meta.cal_step.bkg_subtract = "COMPLETE"
398398
model.meta.dither.primary_type = "2-POINT-NOD"
399399

400400
# trace at pixel 9.5

jwst/lib/suffix.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
"extract2dstep",
9696
"guider_cds",
9797
"gain_scale",
98-
"background",
98+
"bkg_subtract",
9999
"resetstep",
100100
"imprintstep",
101101
"extract1dstep",

jwst/master_background/master_background_mos_step.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def process(self, data):
131131
# If some type of background processing had already been done. Abort.
132132
# UNLESS forcing is enacted.
133133
if not self.force_subtract and "COMPLETE" in [
134-
data_model.meta.cal_step.back_sub,
134+
data_model.meta.cal_step.bkg_subtract,
135135
data_model.meta.cal_step.master_background,
136136
]:
137137
self.log.info("Background subtraction has already occurred. Skipping.")

0 commit comments

Comments
 (0)