GalSim-developers / GalSim

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

Fix some problems when using photon_ops with fft drawing. #1193

Closed rmjarvis closed 1 year ago

rmjarvis commented 1 year ago

@g-braeunlich discovered that using photon_ops with method='fft' doesn't quite work as intended.

First, if you don't explicitly give a sensor object, then it bails out telling you that this isn't allowed. Second, there is no way to limit the number of photons used as we do when photon shooting very bright objects, so the memory explodes if you try to do this for very bright objects (as we want to do in imSim).

So this fixes some of the sanity checks to work correctly when the user is applying photon ops on an fft image. And it implements the maxN parameter for this use case, following the same pattern as we do in drawPhot.

g-braeunlich commented 1 year ago

I also just got an AssertionError on assert photon_array.hasAllocatedPupil(). I think somewhere in the FFT pipeline, there also should be a call to samplePupil. Or I missed another piece of config maybe.

rmjarvis commented 1 year ago

I think somewhere in the FFT pipeline, there also should be a call to samplePupil. Or I missed another piece of config maybe.

No, that would be an imsim error, not a galsim one. Your photon op requires that the pupil positions be set, so you need to include a SamplePupil operator before the diffraction one. GalSim would have no possible way of knowing what kind of pupil to sample from on its own.