poppy
poppy copied to clipboard
re-importing modules breaks fresnel propagation
@mperrin, I found the bit of code that was breaking coronagraph sims during benchmarking.
This is an edge case, but running the following snippet to reload modules after importing causes optics to not be applied while calc_psf is called. The propagation occurs and wavefronts are multiplied by optics, but without rescaling the wavefront pixelscale, so the optic arrays are interpolated to zero size and no flux is observed at the output of the system.
Since the lens power is not applied, this can also change the number of FFTs performed, invalidating benchmark numbers.
This can be diagnosed from the debug statements, where there are no "DEBUG:------ Optic: " statements. Otherwise the failure is silent.
import importlib
importlib.reload(poppy.fresnel)
importlib.reload(poppy.optics)
importlib.reload(poppy)
Under the new GPU selection paradigm, #250, this hack to set the _USE_CUDA etc.. keywords aren't needed to switch acceleration modes so this shouldn't be problem in practice but is being documented here in case it comes up again.
Nice debugging to track down where that glitch was coming from. Not so surprising- reloading modules is pretty brittle and unreliable. I’m sure this is related to some calls to isinstance
which don’t work as expected after reloading.
Do we think there is actually any change needed for this, or is it just a matter of 'don't use the reload function, it's not reliable'?
The latter is probably OK for now, do we need to include it in a troubleshooting doc or do we feel this issue is this sufficient documentation?