[Feature] Faster hologram reconstruction
Added
ReconstructionPlan, which precomputes once which part of a hologram’s spectrum ends up in the output window, and then reconstructs each hologram with a real-to-complex FFT, transforming only the needed columns of the spectrum and gathering the window directly, without full-sizeroll,fftshiftor scaling passes. Build it withfrom_params()and reuse it for a whole stack. Reconstructing the wave and the brightfield image of a 4096x4096 hologram at 1024x1024 takes about a sixth of the time it did.
reconstruct_frame(),reconstruct_bf()andHologramFFTare now thin wrappers around the plan, with the same signatures; results agree with the previous implementation up to floating point rounding.reconstruct_bf()gained theprecisionparameter. The index arrays of the plan are cached per geometry and array module, on the GPU for cupy, so calling the wrappers once per frame does not transfer anything per call. Anout_shapelarger than the hologram, or aslice_fftthat is not the centered slice ofget_slice_fft(), now raiseValueErrorinstead of producing wrapped-around results.The
precisionparameter now selects the computation dtype explicitly:Truetransforms the hologram in float64 (complex128 results),Falsein float32 (complex64 results). Previously, float32 holograms were transformed in float32 regardless, andprecision=Falsestill returned complex128.numpy >= 2.0 is now required.