Skip to content

Commit 8b9c2e3

Browse files
Backport PR #9584 on branch release/1.19.x (JP-3864: Move to unified bkg reftype for wfss) (#9638)
Co-authored-by: Tyler Pauly <[email protected]>
1 parent 9b71e35 commit 8b9c2e3

File tree

8 files changed

+88
-61
lines changed

8 files changed

+88
-61
lines changed

changes/9584.background.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Change the background reference filetype for WFSS processing from ``wfssbkg`` to ``bkg``.

docs/jwst/background_subtraction/reference_files.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ Reference Files
22
===============
33
The background image subtraction step uses reference files only when
44
processing Wide-Field Slitless Spectroscopy (WFSS) exposures. Two reference
5-
files are used for WFSS mode: WFSSBKG and WAVELENGTHRANGE. The
5+
files are used for WFSS mode: BKG and WAVELENGTHRANGE. The
66
WAVELENGTHRANGE reference file is used in the process of determining the
77
locations of source spectra in the image, and conversely the image areas
88
that contain only background signal.
99

10-
.. include:: ../references_general/wfssbkg_reffile.inc
10+
.. include:: ../references_general/bkg_reffile.inc
1111

1212
.. include:: ../references_general/wavelengthrange_reffile.inc
1313

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
.. _bkg_reffile:
2+
3+
Background reference file
4+
-------------------------
5+
6+
:REFTYPE: BKG
7+
8+
The WFSS background reference file contains a "master" image of the
9+
dispersed background produced by a particular filter+grism combination.
10+
11+
.. include:: ../references_general/bkg_selection.inc
12+
13+
.. include:: ../includes/standard_keywords.inc
14+
15+
Type Specific Keywords for BKG
16+
++++++++++++++++++++++++++++++
17+
In addition to the standard reference file keywords listed above,
18+
the following keywords are *required* in BKG reference files,
19+
because they are used as CRDS selectors.
20+
(see :ref:`bkg_selectors`):
21+
22+
========= ==============================
23+
Keyword Data Model Name
24+
========= ==============================
25+
DETECTOR model.meta.instrument.detector
26+
EXP_TYPE model.meta.exposure.type
27+
FILTER model.meta.instrument.filter
28+
PUPIL model.meta.instrument.pupil
29+
========= ==============================
30+
31+
Reference File Format
32+
+++++++++++++++++++++
33+
BKG reference files are in FITS format. The content of the background references differ
34+
based on exposure type:
35+
36+
:Data model: `~jwst.datamodels.WfssBkgModel`
37+
38+
Wide-field slitless spectroscopy (WFSS) background files contain 3 IMAGE extensions and
39+
1 BINTABLE extension. The FITS primary HDU does not contain a data array.
40+
The characteristics of the FITS extensions are as follows:
41+
42+
======= ======== ===== ============== =========
43+
EXTNAME XTENSION NAXIS Dimensions Data type
44+
======= ======== ===== ============== =========
45+
SCI IMAGE 2 ncols x nrows float
46+
ERR IMAGE 2 ncols x nrows float
47+
DQ IMAGE 2 ncols x nrows integer
48+
DQ_DEF BINTABLE 2 TFIELDS = 4 N/A
49+
======= ======== ===== ============== =========
50+
51+
.. include:: ../includes/dq_def.inc
52+
53+
:Data model: `~jwst.datamodels.SossBkgModel`
54+
55+
Background reference files supporting NIRISS SOSS exposures contain three
56+
image extensions, each with three dimensions. The extensions contain templates
57+
of reference backgrounds. The FITS primary HDU does not contain a data array.
58+
The characteristics of the FITS extensions are as follows:
59+
60+
======= ======== ===== ========================== =========
61+
EXTNAME XTENSION NAXIS Dimensions Data type
62+
======= ======== ===== ========================== =========
63+
SCI IMAGE 3 ncols x nrows x ntemplates float
64+
ERR IMAGE 3 ncols x nrows x ntemplates float
65+
DQ IMAGE 3 ncols x nrows x ntemplates integer
66+
======= ======== ===== ========================== =========

docs/jwst/references_general/wfssbkg_selection.inc renamed to docs/jwst/references_general/bkg_selection.inc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
.. _wfssbkg_selectors:
1+
.. _bkg_selectors:
22

3-
Reference Selection Keywords for WFSSBKG
4-
++++++++++++++++++++++++++++++++++++++++
5-
CRDS selects appropriate WFSSBKG references based on the following keywords.
6-
WFSSBKG is not applicable for instruments not in the table.
3+
Reference Selection Keywords for BKG
4+
++++++++++++++++++++++++++++++++++++
5+
CRDS selects appropriate BKG references based on the following keywords.
6+
BKG is not applicable for instruments not in the table.
77

88
========== ===============================================================
99
Instrument Keywords

docs/jwst/references_general/explain_rmaps.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,14 +167,14 @@ example .imap taken from NIRSPEC::
167167
selector = {
168168
'AREA' : 'jwst_nirspec_area_0010.rmap',
169169
'BARSHADOW' : 'jwst_nirspec_barshadow_0002.rmap',
170+
'BKG' : 'N/A',
170171
'CAMERA' : 'jwst_nirspec_camera_0015.rmap',
171172
...,
172173
'PATHLOSS' : 'jwst_nirspec_pathloss_0003.rmap',
173174
...,
174175
'WAVECORR' : 'jwst_nirspec_wavecorr_0003.rmap',
175176
'WAVELENGTHRANGE' : 'jwst_nirspec_wavelengthrange_0015.rmap',
176177
'WCSREGIONS' : 'N/A',
177-
'WFSSBKG' : 'N/A',
178178
}
179179

180180
A value of N/A indicates that a particular reference type is not yet used by

docs/jwst/references_general/references_general.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ documentation on each reference file.
8080
+ +--------------------------------------------------+
8181
| | :ref:`WAVELENGTHRANGE <wavelengthrange_reffile>` |
8282
+-------------------------------------------------------+--------------------------------------------------+
83-
| :ref:`background <background_subtraction>` | :ref:`WFSSBKG <wfssbkg_reffile>` |
83+
| :ref:`background <background_subtraction>` | :ref:`BKG <bkg_reffile>` |
8484
+ +--------------------------------------------------+
8585
| | :ref:`WAVELENGTHRANGE <wavelengthrange_reffile>` |
8686
+-------------------------------------------------------+--------------------------------------------------+
@@ -312,7 +312,7 @@ documentation on each reference file.
312312
+--------------------------------------------------+-------------------------------------------------------+
313313
| :ref:`WAVECORR <wavecorr_reffile>` | :ref:`wavecorr <wavecorr_step>` |
314314
+--------------------------------------------------+-------------------------------------------------------+
315-
| :ref:`WFSSBKG <wfssbkg_reffile>` | :ref:`background <background_subtraction>` |
315+
| :ref:`BKG <bkg_reffile>` | :ref:`background <background_subtraction>` |
316316
+--------------------------------------------------+-------------------------------------------------------+
317317

318318
Step Parameters Reference Types
@@ -339,7 +339,7 @@ The required Keywords Documenting Contents of Reference Files are:
339339
======== ==================================================================================
340340
Keyword Comment
341341
======== ==================================================================================
342-
REFTYPE `WFSSBKG Required values are listed in the discussion of each pipeline step.`
342+
REFTYPE `BKG Required values are listed in the discussion of each pipeline step.`
343343
DESCRIP `Summary of file content and/or reason for delivery`
344344
AUTHOR `Fred Jones Person(s) who created the file`
345345
USEAFTER `YYYY-MM-DDThh:mm:ss Date and time after the reference files will

docs/jwst/references_general/wfssbkg_reffile.inc

Lines changed: 0 additions & 47 deletions
This file was deleted.

jwst/background/background_step.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class BackgroundStep(Step):
3232
""" # noqa: E501
3333

3434
# These reference files are only used for WFSS/GRISM or SOSS data.
35-
reference_file_types = ["bkg", "wfssbkg", "wavelengthrange"]
35+
reference_file_types = ["bkg", "wavelengthrange"]
3636

3737
# Define a suffix for optional saved output of the combined background
3838
bkg_suffix = "combinedbackground"
@@ -60,9 +60,16 @@ def process(self, step_input, input_bkg_list=None):
6060

6161
if result.meta.exposure.type in ["NIS_WFSS", "NRC_WFSS"]:
6262
# Get the reference file names
63-
bkg_name = self.get_reference_file(result, "wfssbkg")
63+
bkg_name = self.get_reference_file(result, "bkg")
6464
wlrange_name = self.get_reference_file(result, "wavelengthrange")
65-
self.log.info("Using WFSSBKG reference file %s", bkg_name)
65+
66+
if bkg_name == "N/A":
67+
self.log.warning("No BKG reference file found. Skipping background subtraction.")
68+
result.meta.cal_step.bkg_subtract = "SKIPPED"
69+
input_model.close()
70+
return result
71+
72+
self.log.info("Using BKG reference file %s", bkg_name)
6673
self.log.info("Using WavelengthRange reference file %s", wlrange_name)
6774

6875
# Do the background subtraction for WFSS/GRISM data

0 commit comments

Comments
 (0)