jwst icon indicating copy to clipboard operation
jwst copied to clipboard

Jump detection modifies input data by gain multiplier

Open JarronL opened this issue 2 years ago • 5 comments

When running the jump detection step, the data in the input object is multiplied by the gain at some point during the algorithm. However, the input data is never returned to its original value. This is problematic, because a user may want to test multiple jump detection parameters (e.g., rejection thresholds) using the same input.

For instance:

jump_step = JumpStep()
jump_step.rejection_threshold = 4
jump = jump_step.run(dark)

For a particular use case of a 320x320 subarray, I was only flagging about 300 pixels.

However, the array dark.data has now been multiplied by the detector gain. So, if I try to run again with a high rejection threshold:

jump_step = JumpStep()
jump_step.rejection_threshold = 5
jump = jump_step.run(dark)

the algorithm flags almost 10 times as many jumps.

Please ensure that original input data does not get modified.

JarronL avatar Jul 26 '22 22:07 JarronL

Thank you for the report. This is definitely not desirable behavior and will be looked into.

stscieisenhamer avatar Jul 27 '22 01:07 stscieisenhamer

For completeness, what platform is this on and version of the JWST package is in use? The version can be retrieved using the following command:

python -c "import jwst; print(jwst.__version__)"

stscieisenhamer avatar Jul 27 '22 01:07 stscieisenhamer

Yeah, there's no copy made at any point of the input data before the input data is modified in stcal.jump.jump.detect_jumps. Just lots of shallow pointers. Hi @stscieisenhamer ! 👋

jdavies-st avatar Jul 27 '22 09:07 jdavies-st

@jdavies-st 👋 will be expecting PR shortly. 😄

@JarronL In the meantime, the workaround is to make a copy of the datamodel before passing in to the step. Datamodels have a copy method so you can do:

jump = jump_step.run(dark.copy())

stscieisenhamer avatar Jul 27 '22 12:07 stscieisenhamer

Thanks. I am currently on 1.6.3.dev5+g565f37e4

JarronL avatar Jul 27 '22 19:07 JarronL