LSSTDESC / descwl-shear-sims

simple simulations for testing weak lensing shear measurement
BSD 3-Clause "New" or "Revised" License
10 stars 9 forks source link

Divide by zero warning if`noisefact=0` on `make_sim` #134

Closed slosar closed 3 years ago

slosar commented 3 years ago

One gets this:


/opt/conda/lib/python3.8/site-packages/descwl_shear_sims/sim/sim.py:264: RuntimeWarning: divide by zero encountered in double_scalars
  weight.array[:, :] = 1.0/noise**2```
One if statement can probably fix it.
esheldon commented 3 years ago

are you trying to make a zero noise image?

beckermr commented 3 years ago

Yeah just make the noise tiny.

esheldon commented 3 years ago

I'll add the check to the code

esheldon commented 3 years ago

Hmm, I'm not sure how this would work. All the weights would be infinity

I think I agree with matt, just send a very small noise

slosar commented 3 years ago

I think if someone sets noise=0, then they are intentionally making a noiseless image and so you set weights to unity. All I want is something like

weights = np.ones((N,M)) / (noise**2 if noise>0 else 1.0)

Doesn't sounds even worth this discussion... :)

esheldon commented 3 years ago

For your use case I see that it might not be worth discussion; but for metadetect this would result in failure, so we want to do something sensible.

I think we may just internally convert noise <= 0 to something tiny like 1.0e-10