Skip to content

Commit

Permalink
addressing rebase bugs and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
penaguerrero committed Nov 27, 2024
1 parent 9f57dbf commit 53cdadd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
1 change: 1 addition & 0 deletions changes/8847.master_background.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Include resample, pixel_replace and extract_1d into MOS background pipeline
19 changes: 7 additions & 12 deletions jwst/master_background/master_background_mos_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ def process(self, data):
user_background = datamodels.open(self.user_background)
master_background, mb_multislit, bkg_x1d_spectra = self._calc_master_background(
data_model, user_background)
# data, user_background=None, sigma_clip=3, median_kernel=1)
elif self.use_correction_pars:
self.log.info('Using pre-calculated correction parameters.')
master_background = self.correction_pars['masterbkg_1d']
Expand Down Expand Up @@ -181,8 +180,7 @@ def set_pars_from_parent(self):
if not self.parent:
return

steps = ['barshadow', 'flat_field', 'pathloss', 'photom',
'pixel_replace', 'resample_spec', 'extract_1d']
steps = ['barshadow', 'flat_field', 'pathloss', 'photom']
pars_to_ignore = {
'barshadow': ['source_type'],
'flat_field': ['save_interpolated_flat'],
Expand All @@ -191,12 +189,9 @@ def set_pars_from_parent(self):
}

for step in steps:
if step in pars_to_ignore:
pars = getattr(self.parent, step).get_pars()
for par in pars_to_ignore[step] + GLOBAL_PARS_TO_IGNORE:
del pars[par]
else:
pars = getattr(self, step).get_pars()
pars = getattr(self.parent, step).get_pars()
for par in pars_to_ignore[step] + GLOBAL_PARS_TO_IGNORE:
del pars[par]
getattr(self, step).update_pars(pars)

def _extend_bg_slits(self, pre_calibrated):
Expand Down Expand Up @@ -298,9 +293,9 @@ def _calc_master_background(
self.log.info('Creating MOS master background from background slitlets')
bkg_model = self._extend_bg_slits(pre_calibrated)
if bkg_model is not None:
bkg_model = self.pixel_replace(bkg_model)
bkg_model = self.resample_spec(bkg_model)
bkg_x1d_spectra = self.extract_1d(bkg_model)
bkg_model = self.pixel_replace.run(bkg_model)
bkg_model = self.resample_spec.run(bkg_model)
bkg_x1d_spectra = self.extract_1d.run(bkg_model)
master_background = nirspec_utils.create_background_from_multispec(
bkg_x1d_spectra, sigma_clip=sigma_clip, median_kernel=median_kernel)
else:
Expand Down

0 comments on commit 53cdadd

Please sign in to comment.