GalSim-developers / GalSim

The modular galaxy image simulation toolkit. Documentation:
http://galsim-developers.github.io/GalSim/
Other
228 stars 107 forks source link

Fix a bug where errors could happen in chromatic drawing when realized flux is 0. #1317

Open rmjarvis opened 4 weeks ago

rmjarvis commented 4 weeks ago

@sidneymau reported a bug where very low flux objects being drawn with chromatic photon shooting could error rather than just not draw anything.

The bug stemmed from having both 0 photons and each photon having a flux of 0 (the g parameter returned by calculate_nphotons). This is overkill and confused one of the calculations in the chromatic draw function. In case there are other bits of code that similarly assume the raw flux is sensible even if nphotons=0, I changed the calculate_nphotons function to return g=1 when iN=0.