27 #ifndef wfp_fraunhoferPropagator_hpp
28 #define wfp_fraunhoferPropagator_hpp
30 #include "../math/constants.hpp"
34 #include "../math/fft/fft.hpp"
55 template<
typename _wavefrontT>
68 typedef typename wavefrontT::Scalar::value_type
realT;
167 template<
typename wavefrontT>
170 m_wavefrontSizePixels = 0;
176 template<
typename wavefrontT>
181 template<
typename wavefrontT>
186 template<
typename wavefrontT>
192 template<
typename wavefrontT>
198 if(m_wavefrontSizePixels > 0) makeShiftPhase();
202 template<
typename wavefrontT>
205 complexPupil *= m_centerFocal;
208 template<
typename wavefrontT>
211 complexPupil *= m_centerPupil;
214 template<
typename wavefrontT>
221 setWavefrontSizePixels(complexPupil.rows());
224 if(doCenter) shiftPupil(complexPupil);
227 m_fft_fwd( complexFocal.data(), complexPupil.data() );
230 template<
typename wavefrontT>
237 setWavefrontSizePixels(complexPupil.rows());
240 m_fft_back( complexPupil.data(), complexFocal.data() );
243 if(doCenter) unshiftPupil(complexPupil);
246 template<
typename wavefrontT>
250 if(wfsPix == m_centerFocal.rows())
return;
252 m_wavefrontSizePixels = wfsPix;
254 m_xcen = 0.5*(wfsPix - 1.0);
255 m_ycen = 0.5*(wfsPix - 1.0);
259 m_fft_fwd.plan(wfsPix, wfsPix);
261 m_fft_back.plan(wfsPix, wfsPix, MXFFT_BACKWARD);
264 template<
typename wavefrontT>
267 constexpr
realT pi = math::pi<realT>();
270 realT norm = 1./(m_wavefrontSizePixels*sqrt(2));
274 m_centerFocal.resize(m_wavefrontSizePixels, m_wavefrontSizePixels);
275 m_centerPupil.resize(m_wavefrontSizePixels, m_wavefrontSizePixels);
278 realT arg = -2.0*
pi*0.5*(m_wavefrontSizePixels-m_wholePixel)/(m_wavefrontSizePixels-1);
280 for(
int ii=0; ii < m_wavefrontSizePixels; ++ii)
282 for(
int jj=0; jj < m_wavefrontSizePixels; ++jj)
284 m_centerFocal(ii,jj) = cnorm*exp(
complexT(0.,arg*((ii-m_xcen)+(jj-m_ycen))));
285 m_centerPupil(ii,jj) = cnorm*exp(
complexT(0., 0.5*
pi - arg*((ii-m_xcen)+(jj-m_ycen))));
Class to perform Fraunhofer propagation between pupil and focal planes.
realT m_xcen
x-coordinate of focal plane center, in pixels
void unshiftPupil(wavefrontT &complexPupil)
Apply the shift to a pupil wavefront which will restore it to a centered pupil image,...
wavefrontT::Scalar::value_type realT
The real data type.
fraunhoferPropagator()
Constructor.
wavefrontT m_centerPupil
Phase screen for un-tilting the pupil plane after propagating from a centered focal plane.
void makeShiftPhase()
Calculate the complex tilt arrays for centering and normalizing the wavefronts.
math::fft::fftT< complexT, complexT, 2, 0 > m_fft_fwd
FFT object for forward FFTs.
int wholePixel()
Get the value of the wholePixel parameter.
void setWavefrontSizePixels(int wfsPix)
Set the size of the wavefront, in pixels.
realT m_ycen
x-coordinate of focal plane center, in pixels
void wholePixel(realT wp)
Set the value of the wholePixel parameter.
realT m_wholePixel
Determines how the image is centered.
~fraunhoferPropagator()
Destructor.
int m_wavefrontSizePixels
The size of the wavefront in pixels.
wavefrontT m_centerFocal
Phase screen for tilting the pupil plane so that the focal plane image is centered.
math::fft::fftT< complexT, complexT, 2, 0 > m_fft_back
FFT object for backward FFTs.
void shiftPupil(wavefrontT &complexPupil)
Apply the shift to a pupil wavefront which will center the resultant focal plane image,...
wavefrontT::Scalar complexT
The complex data type.
void propagatePupilToFocal(wavefrontT &complexFocal, wavefrontT &complexPupil, bool doCenter=true)
Propagate the wavefront from the pupil plane to the focal plane.
void initialize()
Initialize members.
_wavefrontT wavefrontT
The wavefront data type.
void propagateFocalToPupil(wavefrontT &complexPupil, wavefrontT &complexFocal, bool doCenter=true)
Propagate the wavefront from Focal plane to Pupil plane.
constexpr T pi()
Get the value of pi.
Declares and defines a class for managing images.
Utilities for modeling image formation.