27#ifndef __idealCoronagraph_hpp__
28#define __idealCoronagraph_hpp__
57template <
typename _realT>
58struct idealCoronagraph
67 typedef imagingArray<std::complex<realT>, fftwAllocator<std::complex<realT>>, 0>
complexFieldT;
70 typedef Eigen::Array<realT, Eigen::Dynamic, Eigen::Dynamic>
imageT;
118 int loadPupil(
const std::string &pupilFile );
127 const std::string &cName );
158 bool apodize{
false };
162template <
typename realT>
163idealCoronagraph<realT>::idealCoronagraph()
168template <
typename realT>
174template <
typename realT>
179 m_fi.setWavefrontSizePixels( sz );
181 m_focalPlane.resize( sz, sz );
184template <
typename realT>
189 mxError(
"idealCoronagraph",
MXE_PARAMNOTSET,
"Must set wavefront size (wfSz) before setting up coronagraph." );
199template <
typename realT>
207 ff.
read( pupil, pupilFile );
214template <
typename realT>
224 std::string pupilFile =
_fileDir +
"/" + cName +
".fits";
229template <
typename realT>
232 if( pupilPlane.rows() != _realPupil.rows() || pupilPlane.cols() != _realPupil.cols() )
234 mxError(
"idealCoronagraph",
MXE_SIZEERR,
"pupilPlane wavefront size does not match realPupil" );
238 Eigen::Map<Eigen::Array<
complexT, -1, -1>> eigWf( pupilPlane.data(), pupilPlane.cols(), pupilPlane.rows() );
239 Eigen::Map<Eigen::Array<
realT, -1, -1>> eigPup( _realPupil.data(), _realPupil.cols(), _realPupil.rows() );
241 eigWf = ( eigWf - ( ( eigWf * eigPup ).sum() / ( eigPup * eigPup ).sum() ) ) * eigPup;
251template <
typename realT>
256 m_fi.propagatePupilToFocal( m_focalPlane, pupilPlane );
258 int x0 = 0.5 * (
_wfSz - 1 ) - 0.5 * ( fpIntensity.rows() - 1 );
259 int y0 = 0.5 * (
_wfSz - 1 ) - 0.5 * ( fpIntensity.cols() - 1 );
261 extractIntensityImage( fpIntensity, 0, fpIntensity.rows(), 0, fpIntensity.cols(), m_focalPlane, x0, y0 );
266template <
typename realT>
269 static_cast<void>( pupilPlane );
273template <
typename realT>
278 m_fi.propagatePupilToFocal( m_focalPlane, pupilPlane );
280 int x0 = 0.5 * (
_wfSz - 1 ) - 0.5 * ( fpIntensity.rows() - 1 );
281 int y0 = 0.5 * (
_wfSz - 1 ) - 0.5 * ( fpIntensity.cols() - 1 );
283 extractIntensityImage( fpIntensity, 0, fpIntensity.rows(), 0, fpIntensity.cols(), m_focalPlane, x0, y0 );
Class to manage interactions with a FITS file.
error_t read(dataT *data)
Read the contents of the FITS file into an array.
Class to perform Fraunhofer propagation between pupil and focal planes.
Declares and defines a class to work with a FITS file.
Declares and defines utilities to work with FITS files.
Declares and defines a class for Fraunhofer propagation of optical wavefronts.
#define mxError(esrc, ecode, expl)
This reports an mxlib specific error.
int padImage(imOutT &imOut, imInT &imIn, unsigned int padSz, typename imOutT::Scalar value)
Pad an image with a constant value.
#define MXE_SIZEERR
A size was invalid or calculated incorrectly.
#define MXE_PARAMNOTSET
A parameter was not set.
Declares and defines a class for managing images.
Utilities for modeling image formation.
Old version. Deprecated. Declares and defines the mxlib error reporting system.
std::string _fileDir
The directory where coronagraph files are stored.
Eigen::Array< realT, Eigen::Dynamic, Eigen::Dynamic > imageT
The image type.
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.
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.