Repository navigation
fix: SimulatorImaging draws Poisson noise only when used and clips round-off negatives - #688
Merged
Merged
Conversation
…687) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SimulatorImaging.via_image_fromalways drew Poisson noise and only then checkedadd_poisson_noise_to_data. With Poisson noise switched off, round-off negatives from PSF convolution (around 1e-17 of the peak) still reachednp.random.poisson, which raisedValueError: lam < 0. That killed 4 of 100 Euclid sersic resimulations. Closes #687.add_poisson_noise_to_dataorinclude_poisson_noise_in_noise_mapis set. This is a Python-level check on the simulator's flags, so JAX tracing is unaffected.poisson_noise_via_data_eps_fromclips round-off negatives to zero before drawing, on both the NumPy and JAX paths. On NumPy, an image that is genuinely negative (minimum below-1e-10times its maximum) raises a clearDatasetException.API Changes
Behaviour changes only, no signature changes:
np.randomstate.DatasetException(NumPy) instead of NumPy'sValueError. Under JAX it is clipped to zero.See full details below.
Test Plan
test_autoarray/dataset/imaging/test_simulator.pyandtest_autoarray/dataset/test_preprocess.py; 4 of them fail on main.test_autoarray: 2408 passed.jax.jit).pyauto-heart smoke(all workspaces, worktree source): 154 passed, 0 failed. autocti and autocti_test could not build their environment on the laptop (no GSL headers for arcticpy). Covered instead by the full PyAutoCTI unit suite against this branch's autoarray: 279 passed. CTI simulators subclassSimulatorImagingbut override everyvia_*path and use only the Gaussian-noise helpers.Heart RED override (development only)
Heart was RED when the task started and is RED at ship. The human authorized the override in-session on 2026-11-10: "Do a, override is fine well fix red separate".
/prmwith every required check green. No release is authorized.Full API Changes (for automation & release notes)
Changed Behaviour
SimulatorImaging.via_image_from: Poisson noise is drawn only whenadd_poisson_noise_to_dataorinclude_poisson_noise_in_noise_mapis true. With both off, the global NumPy RNG is not touched.preprocess.poisson_noise_via_data_eps_from/data_eps_with_poisson_noise_added: negative counts are clipped to 0 before drawing. NumPy path: raisesexc.DatasetExceptionwhenmin < -1e-10 * |max|. JAX path: clips only.Known edge
-1e-19pixel and Poisson on still raises. It raised before too, as aValueError.Follow-up after release: remove the pipeline-side workaround in euclid_strong_lens_modeling_pipeline (PR #87).
Generated by the PyAutoLabs agent workflow.
🤖 Generated with Claude Code