Skip to content

Fix missing noise in simple_sim_2 and add output validation#9

Open
OfficialAbhinavSingh wants to merge 1 commit into
mwt5345:mainfrom
OfficialAbhinavSingh:feature/output-validation-and-failure-tolerance
Open

Fix missing noise in simple_sim_2 and add output validation#9
OfficialAbhinavSingh wants to merge 1 commit into
mwt5345:mainfrom
OfficialAbhinavSingh:feature/output-validation-and-failure-tolerance

Conversation

@OfficialAbhinavSingh

Copy link
Copy Markdown

Summary

  • simple_sim_2 computed self.poisson = sim.noise_for_model(...) but then set self.image_real = self.image_model + self.image_model — doubling the noiseless model instead of adding the computed noise. This silently produced noiseless images for every pipeline using simple_sim_2 (Model_II/III/IV, the Euclid/HST-resolution sims). Fixed to self.image_model + self.poisson.
  • Added deeplense/validation.py with validate_image(), raising on NaN/Inf/empty/constant-image outputs. Wired into both simple_sim and simple_sim_2, replacing a NaN check in simple_sim that had been written and then commented out (lens.py:270 prior to this PR).
  • Wrapped the Model_I/Model_II/Model_III batch loops (sim_axion.py, sim_cdm.py, sim_no_sub.py, 9 scripts total) in try/except so a single failed draw is logged and skipped instead of crashing the entire multi-thousand-iteration SLURM job.

Test plan

  • Installed the exact pinned stack from the README (lenstronomy==1.9.2, pyHalo from source, colossus) in a clean venv.
  • Ran simple_sim() and simple_sim_2() end-to-end; confirmed no NaNs and correct shapes.
  • Confirmed the noise fix: image_real now matches image_model + poisson (previously matched image_model * 2, i.e. no noise applied).
  • Unit-tested validate_image() against NaN, Inf, empty, and constant-image inputs — all correctly raise; a normal random image passes.
  • Simulated a mid-batch validation failure and confirmed the wrapped loop logs and continues instead of crashing.
  • py_compile on all 9 modified batch scripts.

DeepLens.simple_sim_2 computed Poisson noise but never added it to the
returned image (self.image_real = self.image_model + self.image_model,
doubling the noiseless model instead of using self.poisson). This
silently produced noiseless training/validation images for every
Model_II/III/IV run using the Euclid/HST-resolution pipeline.

Also add deeplense/validation.py to catch NaN/Inf/empty/constant
images from failed lens configurations, wired into both simple_sim and
simple_sim_2 (replacing a NaN check that had been written and then
commented out). Wrap the Model_I-III batch simulation loops so a
single failed draw is logged and skipped instead of crashing the
entire (multi-thousand-iteration) SLURM job.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant