Skip to content

Commit

Permalink
JP-3667: Add safeguards for NSClean on background/imprint members (sp…
Browse files Browse the repository at this point in the history
  • Loading branch information
melanieclarke authored Sep 20, 2024
2 parents 9fdf2c1 + dc2ce65 commit 6244cd3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
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 @@ def process_exposure_product(
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

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
else:
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']):
if save_results:
if isinstance(bkg_file, datamodels.JwstDataModel):
self.nsclean.output_file = bkg_file.meta.filename
else:
self.nsclean.output_file = os.path.basename(bkg_file)
bkg_nsclean = self.nsclean(bkg_file)
members_by_type['background'][i] = bkg_nsclean

# 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

0 comments on commit 6244cd3

Please sign in to comment.