diff --git a/CHANGES.rst b/CHANGES.rst index db515eadf3..664e5f7826 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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] diff --git a/jwst/pipeline/calwebb_spec2.py b/jwst/pipeline/calwebb_spec2.py index 7a5f0b3ca3..36e2993113 100644 --- a/jwst/pipeline/calwebb_spec2.py +++ b/jwst/pipeline/calwebb_spec2.py @@ -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