8#ifndef turbSequence_hpp
9#define turbSequence_hpp
22#include "wavefront.hpp"
31template <
typename _realT>
35 typedef Eigen::Array<realT, Eigen::Dynamic, Eigen::Dynamic> imageT;
37 std::vector<std::string> _phaseFnames;
38 std::vector<std::string> _ampFnames;
49 int _currFrameNo{ 0 };
52 realT _F0Photons{ 2e11 };
62 improc::eigenCube<realT> _currPhase;
63 improc::eigenCube<realT> _currAmp;
65 bool _phaseOnly{
false };
112 void wfPS( realT ps )
123 void F0Photons( realT f0 )
134 void starMag( realT sm )
148 _pixVal = sqrt( _F0Photons ) * pow( 10., -0.2 * _starMag ) * _wfPS;
159 int turbFnames( std::string dir,
int max = 0 );
161 void openPhaseFrame(
int fn );
163 void nextPhase( wavefront<realT> &wf );
165 void nextWF( wavefront<realT> &wf );
168template <
typename realT>
169int turbSequence<realT>::turbFnames( std::string dir,
int max )
174 if( _phaseFnames.size() == 0 )
180 if( _ampFnames.size() == 0 )
182 std::cerr <<
"turbSequence: no turbulent amplitude files found.\n";
189 const size_t maxFiles =
static_cast<size_t>( max );
191 if( _phaseFnames.size() > maxFiles )
192 _phaseFnames.erase( _phaseFnames.begin() + maxFiles, _phaseFnames.end() );
194 if( _phaseOnly ==
false && _ampFnames.size() > maxFiles )
195 _ampFnames.erase( _ampFnames.begin() + maxFiles, _ampFnames.end() );
198 _files = _phaseFnames.size();
202 _size = _currPhase.rows();
203 _nPerCube = _currPhase.planes();
205 _frames = _nPerCube * _phaseFnames.size();
210template <
typename realT>
211void turbSequence<realT>::openPhaseFrame(
int fn )
213 fits::fitsFile<float> ff;
215 std::cout << _phaseFnames[fn] <<
"\n";
217 ff.read( _currPhase, _phaseFnames[fn] );
220 if( _phaseOnly ==
false )
222 ff.read( _currAmp, _ampFnames[fn] );
230template <
typename realT>
234 int Npix = _pupil->sum();
236 if( _currFrameNo > _nPerCube - 1 )
238 openPhaseFrame( _currFileNo + 1 );
241 wf.phase.resize( _pupil->rows(), _pupil->cols() );
244 wf.phase = _currPhase.image( _currFrameNo )
245 .block( 0.5 * ( _currPhase.rows() - _pupil->rows() ),
246 0.5 * ( _currPhase.cols() - _pupil->cols() ),
250 wf.phase = ( wf.phase - ( wf.phase * ( *_pupil ) ).sum() / Npix ) * ( *_pupil );
254 wf.amplitude = ( *_pupil ) * _pixVal;
259template <
typename realT>
263 int Npix = _pupil->sum();
265 if( _currFrameNo > _nPerCube - 1 )
267 openPhaseFrame( _currFileNo + 1 );
269 wf.phase.resize( _pupil->rows(), _pupil->cols() );
271 wf.phase = _currPhase.image( _currFrameNo )
272 .block( 0.5 * ( _currPhase.rows() - _pupil->rows() ),
273 0.5 * ( _currPhase.cols() - _pupil->cols() ),
277 wf.phase = ( wf.phase - ( wf.phase * ( *_pupil ) ).sum() / Npix ) * ( *_pupil );
281 wf.amplitude = _pixVal * ( *_pupil );
285 wf.amplitude.resize( _pupil->rows(), _pupil->cols() );
287 wf.amplitude = _currAmp.image( _currFrameNo )
288 .block( 0.5 * ( _currAmp.rows() - _pupil->rows() ),
289 0.5 * ( _currAmp.cols() - _pupil->cols() ),
293 wf.amplitude *= _pixVal * ( *_pupil );
An image cube with an Eigen API.
Declarations of utilities for working with files.
Declares and defines a class to work with a FITS file.
#define mxError(esrc, ecode, expl)
This reports an mxlib specific error.
error_t getFileNames(std::vector< std::string > &fileNames, const std::string &directory, const std::string &prefix, const std::string &substr, const std::string &extension)
Get a list of file names from the specified directory, specifying a prefix, a substring to match,...
#define MXE_FILENOTFOUND
The file was not found.
Old version. Deprecated. Declares and defines the mxlib error reporting system.
Structure containing the phase and amplitude of a wavefront.