Skip to content

Commit 5a0f127

Browse files
Apply basic code style changes to lastframe step (#9147)
2 parents 0d24c1e + a4175b4 commit 5a0f127

File tree

5 files changed

+42
-29
lines changed

5 files changed

+42
-29
lines changed

.pre-commit-config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ repos:
6161
jwst/imprint/.* |
6262
jwst/ipc/.* |
6363
jwst/jump/.* |
64-
jwst/lastframe/.* |
6564
jwst/lib/.* |
6665
jwst/linearity/.* |
6766
jwst/master_background/.* |

.ruff.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ exclude = [
5252
"jwst/imprint/**.py",
5353
"jwst/ipc/**.py",
5454
"jwst/jump/**.py",
55-
"jwst/lastframe/**.py",
55+
# "jwst/lastframe/**.py",
5656
"jwst/lib/**.py",
5757
"jwst/linearity/**.py",
5858
"jwst/master_background/**.py",
@@ -182,7 +182,7 @@ ignore-fully-untyped = true # Turn of annotation checking for fully untyped cod
182182
"jwst/imprint/**.py" = ["D", "N", "A", "ARG", "B", "C4", "ICN", "INP", "ISC", "LOG", "NPY", "PGH", "PTH", "S", "SLF", "SLOT", "T20", "TRY", "UP", "YTT", "E501"]
183183
"jwst/ipc/**.py" = ["D", "N", "A", "ARG", "B", "C4", "ICN", "INP", "ISC", "LOG", "NPY", "PGH", "PTH", "S", "SLF", "SLOT", "T20", "TRY", "UP", "YTT", "E501"]
184184
"jwst/jump/**.py" = ["D", "N", "A", "ARG", "B", "C4", "ICN", "INP", "ISC", "LOG", "NPY", "PGH", "PTH", "S", "SLF", "SLOT", "T20", "TRY", "UP", "YTT", "E501"]
185-
"jwst/lastframe/**.py" = ["D", "N", "A", "ARG", "B", "C4", "ICN", "INP", "ISC", "LOG", "NPY", "PGH", "PTH", "S", "SLF", "SLOT", "T20", "TRY", "UP", "YTT", "E501"]
185+
#"jwst/lastframe/**.py" = ["D", "N", "A", "ARG", "B", "C4", "ICN", "INP", "ISC", "LOG", "NPY", "PGH"#, "PTH", "S", "SLF", "SLOT", "T20", "TRY", "UP", "YTT", "E501"]
186186
"jwst/lib/**.py" = ["D", "N", "A", "ARG", "B", "C4", "ICN", "INP", "ISC", "LOG", "NPY", "PGH", "PTH", "S", "SLF", "SLOT", "T20", "TRY", "UP", "YTT", "E501"]
187187
"jwst/linearity/**.py" = ["D", "N", "A", "ARG", "B", "C4", "ICN", "INP", "ISC", "LOG", "NPY", "PGH", "PTH", "S", "SLF", "SLOT", "T20", "TRY", "UP", "YTT", "E501"]
188188
"jwst/master_background/**.py" = ["D", "N", "A", "ARG", "B", "C4", "ICN", "INP", "ISC", "LOG", "NPY", "PGH", "PTH", "S", "SLF", "SLOT", "T20", "TRY", "UP", "YTT", "E501"]

jwst/lastframe/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""Set data quality flag of last group in MIRI data."""
2+
13
from .lastframe_step import LastFrameStep
24

3-
__all__ = ['LastFrameStep']
5+
__all__ = ["LastFrameStep"]

jwst/lastframe/lastframe_step.py

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,40 @@
77

88
class LastFrameStep(Step):
99
"""
10-
LastFrameStep: This is a MIRI specific task. If the number of groups
11-
is greater than 2, the GROUP data quality flags for the final group will
12-
be set to DO_NOT_USE.
10+
Set data quality flags for the last group in MIRI ramps.
11+
12+
A MIRI specific task. If the number of groups > 2, the GROUP
13+
data quality flag for the final group will be set to DO_NOT_USE.
1314
"""
1415

1516
class_alias = "lastframe"
1617

1718
spec = """
18-
""" # noqa: E501
19+
""" # noqa: E501
1920

2021
def process(self, step_input):
21-
22+
"""
23+
For MIRI data with more than 2 groups, set final group dq to DO_NOT_USE.
24+
25+
Parameters
26+
----------
27+
step_input : DataModel
28+
Input datamodel to be corrected
29+
30+
Returns
31+
-------
32+
output_model : DataModel
33+
Lastframe corrected datamodel
34+
"""
2235
# Open the input data model
2336
with datamodels.RampModel(step_input) as input_model:
24-
2537
# check the data is MIRI data
2638
detector = input_model.meta.instrument.detector
2739

28-
if detector[:3] != 'MIR':
29-
self.log.warning('Last Frame Correction is only for MIRI data')
30-
self.log.warning('Last frame step will be skipped')
31-
input_model.meta.cal_step.lastframe = 'SKIPPED'
40+
if detector[:3] != "MIR":
41+
self.log.warning("Last Frame Correction is only for MIRI data")
42+
self.log.warning("Last frame step will be skipped")
43+
input_model.meta.cal_step.lastframe = "SKIPPED"
3244
return input_model
3345

3446
# Work on a copy

jwst/lastframe/lastframe_sub.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,36 +12,36 @@
1212

1313
def do_correction(output):
1414
"""
15-
Short Summary
16-
-------------
17-
The sole correction is to reset to DO_NOT_USE the GROUP data quality flags
18-
for the final group, if the number of groups is greater than 2.
15+
Set data quality flag of the final group in an integration to DO_NOT_USE.
16+
17+
This correction only works on MIRI data. If the number of groups
18+
is greater than 2, then GROUP dq flag of final group is set to
19+
DO_NOT_USE.
1920
2021
Parameters
2122
----------
22-
output: data model object
23-
science data to be corrected
23+
output : DataModel
24+
Science data to be corrected
2425
2526
Returns
2627
-------
27-
output: data model object
28-
lastframe-corrected science data
29-
28+
output : DataModel
29+
Lastframe-corrected science data
3030
"""
31-
3231
# Save some data params for easy use later
3332
sci_ngroups = output.data.shape[1]
3433

3534
# Update the step status, and if ngroups > 2, set all of the GROUPDQ in
3635
# the final group to 'DO_NOT_USE'
3736
if sci_ngroups > 2:
38-
output.groupdq[:, -1, :, :] = \
39-
np.bitwise_or(output.groupdq[:, -1, :, :], dqflags.group['DO_NOT_USE'])
37+
output.groupdq[:, -1, :, :] = np.bitwise_or(
38+
output.groupdq[:, -1, :, :], dqflags.group["DO_NOT_USE"]
39+
)
4040
log.debug("LastFrame Sub: resetting GROUPDQ in last frame to DO_NOT_USE")
41-
output.meta.cal_step.lastframe = 'COMPLETE'
42-
else: # too few groups
41+
output.meta.cal_step.lastframe = "COMPLETE"
42+
else: # too few groups
4343
log.warning("Too few groups to apply correction")
4444
log.warning("Step will be skipped")
45-
output.meta.cal_step.lastframe = 'SKIPPED'
45+
output.meta.cal_step.lastframe = "SKIPPED"
4646

4747
return output

0 commit comments

Comments
 (0)