Skip to content

Commit c42f027

Browse files
committed
allow IFUImageModel
1 parent b86cd74 commit c42f027

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

jwst/pixel_replace/pixel_replace.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ def __init__(self, input_model, **pars):
5555
try:
5656
self.algorithm = self.algorithm_dict[self.pars['algorithm']]
5757

58-
except:
59-
log.critical(f"Algorithm name provided does not match an"
60-
f"implemented algorithm!")
58+
except KeyError:
59+
log.critical(f"Algorithm name {self.pars['algorithm']} provided does "
60+
f"not match an implemented algorithm!")
6161
raise Exception
6262

6363
def replace(self):
@@ -67,10 +67,10 @@ def replace(self):
6767
to each 2D spectrum in input.
6868
"""
6969
# ImageModel inputs (MIR_LRS-FIXEDSLIT)
70-
if isinstance(self.input, datamodels.ImageModel):
70+
if isinstance(self.input, (datamodels.ImageModel, datamodels.IFUImageModel)):
7171
self.output = self.algorithm(self.input)
7272
n_replaced = np.sum(self.output.dq & self.REPLACED)
73-
log.info(f"Input ImageModel had {n_replaced} pixels replaced.")
73+
log.info(f"Input model had {n_replaced} pixels replaced.")
7474

7575
# MultiSlitModel inputs (WFSS, NRS_FIXEDSLIT, ?)
7676
elif isinstance(self.input, datamodels.MultiSlitModel):
@@ -86,7 +86,7 @@ def replace(self):
8686

8787
else:
8888
# This should never happen, as these would be caught in the step code.
89-
log.critical(f"How did we get here?")
89+
log.critical("How did we get here?")
9090
raise Exception
9191

9292
def fit_profile(self, model):
@@ -124,8 +124,8 @@ def fit_profile(self, model):
124124
# Truncate array to region where good pixels exist
125125
good_pixels = np.where(~model.dq & 1)
126126
if np.any(0 in np.shape(good_pixels)):
127-
log.warning(f"No good pixels in at least one dimension of "
128-
f"data array - skipping pixel replacement.")
127+
log.warning("No good pixels in at least one dimension of "
128+
"data array - skipping pixel replacement.")
129129
return model
130130
x_range = [np.min(good_pixels[0]), np.max(good_pixels[0]) + 1]
131131
y_range = [np.min(good_pixels[1]), np.max(good_pixels[1]) + 1]

jwst/pixel_replace/pixel_replace_step.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ def process(self, input):
5959
# MIRI_LRS-FIXEDSLIT comes in ImageModel - any others?
6060
elif isinstance(input_model, datamodels.ImageModel):
6161
self.log.debug(f'Input ImageModel is of exptype: {input_model.meta.exposure.type}')
62+
elif isinstance(input_model, datamodels.IFUImageModel):
63+
self.log.debug(f'Input is an IFUImageModel.')
6264
'''
6365
elif isinstance(input_model, datamodels.CubeModel):
6466
# It's a 3-D multi-integration model

0 commit comments

Comments
 (0)