spacetelescope / jwst

Python library for science observations from the James Webb Space Telescope
https://jwst-pipeline.readthedocs.io/en/latest/
Other
571 stars 167 forks source link

Jump detection modifies input data by gain multiplier #6944

Closed JarronL closed 2 years ago

JarronL commented 2 years ago

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.

stscieisenhamer commented 2 years ago

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

stscieisenhamer commented 2 years ago

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__)"
jdavies-st commented 2 years ago

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 ! 👋

stscieisenhamer commented 2 years ago

@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())
JarronL commented 2 years ago

Thanks. I am currently on 1.6.3.dev5+g565f37e4