Skip to content

Commit a6c0a93

Browse files
committed
updates to only save primary
1 parent 431aac6 commit a6c0a93

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

jwst/straylight/straylight.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,18 @@ def clean_showers(input_model, allregions, shower_plane=3, shower_x_stddev=18.0,
257257
shower_high_reject : float, optional
258258
High percentile of pixels to reject
259259
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+
260264
Returns
261265
-------
262266
output : `~jwst.datamodels.IFUImageModel`
263267
Straylight-subtracted science data.
264268
269+
output_shower_model : `~jwst.datamodel.JwstDataModel` or None
270+
A datamodel containing the shower model, if `save_shower_model`
271+
is True.
265272
"""
266273

267274
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,
299306
input_model.data = input_model.data - shower_model
300307

301308
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)
303310
else:
304311
output_shower_model = None
305312

@@ -309,33 +316,25 @@ def clean_showers(input_model, allregions, shower_plane=3, shower_x_stddev=18.0,
309316
return input_model, output_shower_model
310317

311318

312-
def _make_intermediate_model(input_model, intermediate_data):
319+
def _make_straylight_model(input_model, shower_data):
313320
"""
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.
318322
319323
Parameters
320324
----------
321325
input_model : `~jwst.datamodel.JwstDataModel`
322326
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.
325329
326330
Returns
327331
-------
328332
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
330334
metadata matching the input.
331335
"""
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)
338337

339338
# 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

Comments
 (0)