poppy icon indicating copy to clipboard operation
poppy copied to clipboard

re-importing modules breaks fresnel propagation

Open douglase opened this issue 6 years ago • 3 comments

@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.

douglase avatar Jun 03 '18 17:06 douglase

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.

mperrin avatar Jun 03 '18 18:06 mperrin

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'?

mperrin avatar Jul 09 '18 17:07 mperrin

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?

douglase avatar Jul 09 '18 17:07 douglase