27 #ifndef __idealCoronagraph_hpp__
28 #define __idealCoronagraph_hpp__
35 #include "../wfp/imagingArray.hpp"
37 #include "../ioutils/fits/fitsFile.hpp"
38 #include "../ioutils/fits/fitsUtils.hpp"
39 #include "../improc/imagePads.hpp"
54 template<
typename _realT>
64 typedef imagingArray<std::complex<realT>, fftwAllocator<std::complex<realT> >, 0>
complexFieldT;
67 typedef Eigen::Array< realT, Eigen::Dynamic, Eigen::Dynamic>
imageT;
115 int loadPupil(
const std::string & pupilFile );
147 bool apodize {
false};
152 template<
typename realT>
153 idealCoronagraph<realT>::idealCoronagraph()
158 template<
typename realT>
164 template<
typename realT>
169 m_fi.setWavefrontSizePixels(sz);
170 m_fi.wholePixel(m_wholePixel);
171 m_focalPlane.resize(sz, sz);
175 template<
typename realT>
180 mxError(
"idealCoronagraph", MXE_PARAMNOTSET,
"Must set wavefront size (wfSz) before setting up coronagraph.");
190 template<
typename realT>
198 ff.
read(pupil, pupilFile);
200 return setPupil(pupil);
205 template<
typename realT>
211 mxError(
"idealCoronagraph", MXE_PARAMNOTSET,
"file directory (fileDir) not set.");
215 std::string pupilFile = _fileDir +
"/" + cName +
".fits";
217 return loadPupil(pupilFile);
221 template<
typename realT>
224 if( pupilPlane.rows() != _realPupil.rows() || pupilPlane.cols() != _realPupil.cols())
226 mxError(
"idealCoronagraph", MXE_SIZEERR,
"pupilPlane wavefront size does not match realPupil");
230 Eigen::Map<Eigen::Array<
complexT,-1,-1> > eigWf(pupilPlane.data(), pupilPlane.cols(), pupilPlane.rows());
231 Eigen::Map<Eigen::Array<
realT,-1,-1> > eigPup(_realPupil.data(), _realPupil.cols(), _realPupil.rows());
233 eigWf = (eigWf - ((eigWf*eigPup).sum()/(eigPup*eigPup).sum()))*eigPup;
243 template<
typename realT>
248 propagate(pupilPlane);
250 m_fi.propagatePupilToFocal(m_focalPlane, pupilPlane);
252 int x0 = 0.5*(_wfSz-1) - 0.5*(fpIntensity.rows()-1);
253 int y0 = 0.5*(_wfSz-1) - 0.5*(fpIntensity.cols()-1);
255 extractIntensityImage(fpIntensity,0, fpIntensity.rows(),0,fpIntensity.cols(), m_focalPlane, x0,y0);
260 template<
typename realT>
263 static_cast<void>(pupilPlane);
267 template<
typename realT>
271 propagateNC(pupilPlane);
273 m_fi.propagatePupilToFocal(m_focalPlane, pupilPlane);
275 int x0 = 0.5*(_wfSz-1) - 0.5*(fpIntensity.rows()-1);
276 int y0 = 0.5*(_wfSz-1) - 0.5*(fpIntensity.cols()-1);
278 extractIntensityImage(fpIntensity,0, fpIntensity.rows(),0,fpIntensity.cols(), m_focalPlane, x0,y0);
Class to manage interactions with a FITS file.
int read(dataT *data)
Read the contents of the FITS file into an array.
Declares and defines a class for Fraunhofer propagation of optical wavefronts.
int padImage(imOutT &imOut, imInT &imIn, unsigned int padSz, typename imOutT::Scalar value)
Pad an image with a constant value.
Utilities for modeling image formation.
std::string _fileDir
The directory where coronagraph files are stored.
int _wfSz
The linear size of the wavefront in pixels.
int propagate(complexFieldT &pupilPlane)
Propagate the given pupil-plane wavefront through the coronagraph to the exit pupil plane.
Eigen::Array< realT, Eigen::Dynamic, Eigen::Dynamic > imageT
The image type.
int loadPupil(const std::string &pupilFile)
Load the real pupil mask from a FITS file.
std::complex< realT > complexT
The complex floating point type.
imagingArray< std::complex< realT >, fftwAllocator< std::complex< realT > >, 0 > complexFieldT
The wavefront complex field type.
int loadCoronagraph(const std::string &cName)
Load the components of the coronagraph (just a pupil) based in its base name.
_realT realT
The real floating point type.
realT m_wholePixel
Determines how the image is centered.
int wfSz()
Get the wavefront size in pixels.
int propagateNC(complexFieldT &pupilPlane)
Propagate the given pupil-plane wavefront without the coronagraph.
int setPupil(imageT &pupil)
Set the real pupil mask.
fraunhoferPropagator< complexFieldT > m_fi
Fraunhofer propagator.