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-3667: Add safeguards for NSClean on background/imprint members #8809

Merged
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
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ pipeline
in memory or on disk. [#8683]

- Updated ``calwebb_spec2`` to run ``nsclean`` on NIRSpec imprint and background
association members. [#8786]
association members. [#8786, #8809]

- Updated `calwebb_spec3` to not save the `pixel_replacement` output by default.[#8765]

Expand Down
29 changes: 20 additions & 9 deletions jwst/pipeline/calwebb_spec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,15 +270,26 @@
calibrated = self.nsclean(calibrated)

# Apply nsclean to NIRSpec imprint and background members
for i, imprint_file in enumerate(members_by_type['imprint']):
self.nsclean.output_file = os.path.basename(imprint_file)
imprint_nsclean = self.nsclean(imprint_file)
members_by_type['imprint'][i] = imprint_nsclean

for i, bkg_file in enumerate(members_by_type['background']):
self.nsclean.output_file = os.path.basename(bkg_file)
bkg_nsclean = self.nsclean(bkg_file)
members_by_type['background'][i] = bkg_nsclean
if not self.nsclean.skip:
save_results = self.nsclean.save_results

Check warning on line 274 in jwst/pipeline/calwebb_spec2.py

View check run for this annotation

Codecov / codecov/patch

jwst/pipeline/calwebb_spec2.py#L274

Added line #L274 was not covered by tests

for i, imprint_file in enumerate(members_by_type['imprint']):
if save_results:
if isinstance(imprint_file, datamodels.JwstDataModel):
self.nsclean.output_file = imprint_file.meta.filename

Check warning on line 279 in jwst/pipeline/calwebb_spec2.py

View check run for this annotation

Codecov / codecov/patch

jwst/pipeline/calwebb_spec2.py#L276-L279

Added lines #L276 - L279 were not covered by tests
else:
self.nsclean.output_file = os.path.basename(imprint_file)
imprint_nsclean = self.nsclean(imprint_file)
members_by_type['imprint'][i] = imprint_nsclean

Check warning on line 283 in jwst/pipeline/calwebb_spec2.py

View check run for this annotation

Codecov / codecov/patch

jwst/pipeline/calwebb_spec2.py#L281-L283

Added lines #L281 - L283 were not covered by tests

for i, bkg_file in enumerate(members_by_type['background']):
if save_results:
if isinstance(bkg_file, datamodels.JwstDataModel):
self.nsclean.output_file = bkg_file.meta.filename

Check warning on line 288 in jwst/pipeline/calwebb_spec2.py

View check run for this annotation

Codecov / codecov/patch

jwst/pipeline/calwebb_spec2.py#L285-L288

Added lines #L285 - L288 were not covered by tests
else:
self.nsclean.output_file = os.path.basename(bkg_file)
bkg_nsclean = self.nsclean(bkg_file)
members_by_type['background'][i] = bkg_nsclean

Check warning on line 292 in jwst/pipeline/calwebb_spec2.py

View check run for this annotation

Codecov / codecov/patch

jwst/pipeline/calwebb_spec2.py#L290-L292

Added lines #L290 - L292 were not covered by tests

# Leakcal subtraction (imprint) occurs before background subtraction on a per-exposure basis.
# If there is only one `imprint` member, this imprint exposure is subtracted from all the
Expand Down
Loading