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

Wrap "process_slit" in try/except for "extract_2d.nirspec.nrs_extract2d" #8964

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
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/8964.extract_2d.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Wrap process_slit in try/except during extract_2d.nirspec.nrs_extract2d.
11 changes: 10 additions & 1 deletion jwst/extract_2d/nirspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,16 @@ def nrs_extract2d(input_model, slit_name=None):

# Loop over all slit instances that are present
for slit in open_slits:
new_model, xlo, xhi, ylo, yhi = process_slit(input_model, slit, exp_type)
try:
new_model, xlo, xhi, ylo, yhi = process_slit(
input_model, slit, exp_type
)
except ValueError:
log.warning(
'process_slit failed for slit/subarray {0}, '.format(slit.name)
+ 'probably because the cutout has no valid pixels'
Comment on lines +91 to +92
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be a little simpler formatted as an f-string:

Suggested change
'process_slit failed for slit/subarray {0}, '.format(slit.name)
+ 'probably because the cutout has no valid pixels'
f'process_slit failed for slit {slit.name}, '
f'probably because the cutout has no valid pixels'

)
continue

slits.append(new_model)
orig_s_region = new_model.meta.wcsinfo.s_region.strip()
Expand Down