@@ -257,11 +257,18 @@ def clean_showers(input_model, allregions, shower_plane=3, shower_x_stddev=18.0,
257
257
shower_high_reject : float, optional
258
258
High percentile of pixels to reject
259
259
260
+ save_shower_model : bool
261
+ If set, a shower model is created and returned along with the cleaned input_model
262
+ array. If not, the `shower_model` returned is None
263
+
260
264
Returns
261
265
-------
262
266
output : `~jwst.datamodels.IFUImageModel`
263
267
Straylight-subtracted science data.
264
268
269
+ output_shower_model : `~jwst.datamodel.JwstDataModel` or None
270
+ A datamodel containing the shower model, if `save_shower_model`
271
+ is True.
265
272
"""
266
273
267
274
log .info ("Applying correction for residual cosmic ray showers." )
@@ -299,7 +306,7 @@ def clean_showers(input_model, allregions, shower_plane=3, shower_x_stddev=18.0,
299
306
input_model .data = input_model .data - shower_model
300
307
301
308
if save_shower_model :
302
- output_shower_model = _make_intermediate_model (input_model , shower_model )
309
+ output_shower_model = _make_straylight_model (input_model , shower_model )
303
310
else :
304
311
output_shower_model = None
305
312
@@ -309,33 +316,25 @@ def clean_showers(input_model, allregions, shower_plane=3, shower_x_stddev=18.0,
309
316
return input_model , output_shower_model
310
317
311
318
312
- def _make_intermediate_model (input_model , intermediate_data ):
319
+ def _make_straylight_model (input_model , shower_data ):
313
320
"""
314
- Make a data model to contain intermediate outputs.
315
-
316
- The output model type depends on the shape of the input
317
- intermediate data.
321
+ Make a data model to contain an optional output shower model.
318
322
319
323
Parameters
320
324
----------
321
325
input_model : `~jwst.datamodel.JwstDataModel`
322
326
The input data.
323
- intermediate_data : array-like
324
- The intermediate data to save.
327
+ shower_data : numpy array
328
+ The intermediate shower model data to save.
325
329
326
330
Returns
327
331
-------
328
332
intermediate_model : ~jwst.datamodel.JwstDataModel`
329
- A model containing only the intermediate data and top-level
333
+ A model containing only the shower model data and top-level
330
334
metadata matching the input.
331
335
"""
332
- if intermediate_data .ndim == 4 :
333
- intermediate_model = datamodels .RampModel (data = intermediate_data )
334
- elif intermediate_data .ndim == 3 :
335
- intermediate_model = datamodels .CubeModel (data = intermediate_data )
336
- else :
337
- intermediate_model = datamodels .ImageModel (data = intermediate_data )
336
+ shower_model = datamodels .ImageModel (data = shower_data )
338
337
339
338
# Copy metadata from input model
340
- intermediate_model .update (input_model )
341
- return intermediate_model
339
+ shower_model .update (input_model , only = "PRIMARY" )
340
+ return shower_model
0 commit comments