8 #ifndef turbSequence_hpp
9 #define turbSequence_hpp
14 #include <Eigen/Dense>
16 #include "../../ioutils/fileUtils.hpp"
17 #include "../../ioutils/fits/fitsFile.hpp"
18 #include "../../improc/eigenCube.hpp"
20 #include "wavefront.hpp"
29 template<
typename _realT>
33 typedef Eigen::Array<realT, Eigen::Dynamic, Eigen::Dynamic> imageT;
35 std::vector<std::string> _phaseFnames;
36 std::vector<std::string> _ampFnames;
50 realT _F0Photons {2e11};
60 improc::eigenCube<realT> _currPhase;
61 improc::eigenCube<realT> _currAmp;
63 bool _phaseOnly {
false};
122 void F0Photons(realT f0)
133 void starMag(realT sm)
148 _pixVal = sqrt(_F0Photons)*pow(10., -0.2*_starMag)*_wfPS;
160 int turbFnames(std::string dir,
int max= 0);
162 void openPhaseFrame(
int fn);
164 void nextPhase(wavefront<realT> &wf);
166 void nextWF(wavefront<realT> & wf);
171 template<
typename realT>
172 int turbSequence<realT>::turbFnames(std::string dir,
int max)
178 if(_phaseFnames.size() == 0)
180 mxError(
"turbSequence", MXE_FILENOTFOUND,
"No turbulent phase files found.");
184 if(_ampFnames.size() == 0)
186 std::cerr <<
"turbSequence: no turbulent amplitude files found.\n";
193 _phaseFnames.erase(_phaseFnames.begin()+max, _phaseFnames.end());
194 if(_phaseOnly ==
false) _ampFnames.erase(_ampFnames.begin()+max, _ampFnames.end());
197 _files = _phaseFnames.size();
201 _size = _currPhase.rows();
202 _nPerCube = _currPhase.planes();
204 _frames = _nPerCube*_phaseFnames.size();
208 template<
typename realT>
209 void turbSequence<realT>::openPhaseFrame(
int fn)
211 fits::fitsFile<float> ff;
213 std::cout << _phaseFnames[fn] <<
"\n";
215 ff.read(_phaseFnames[fn], _currPhase);
218 if(_phaseOnly ==
false)
220 ff.read(_ampFnames[fn], _currAmp);
228 template<
typename realT>
229 void turbSequence<realT>::nextPhase(wavefront<realT> &wf)
232 int Npix = _pupil->sum();
234 if(_currFrameNo > _nPerCube-1)
236 openPhaseFrame(_currFileNo + 1);
239 wf.phase.resize(_pupil->rows(),_pupil->cols());
242 wf.phase = _currPhase.image(_currFrameNo).block( 0.5*( _currPhase.rows()-_pupil->rows()), 0.5*(_currPhase.cols() - _pupil->cols()), _pupil->rows(), _pupil->cols());
245 wf.phase = (wf.phase - (wf.phase* (*_pupil)).sum()/Npix)* (*_pupil);
249 wf.amplitude = (*_pupil)*_pixVal;
254 template<
typename realT>
255 void turbSequence<realT>::nextWF(wavefront<realT> & wf)
258 int Npix = _pupil->sum();
261 if(_currFrameNo > _nPerCube-1)
263 openPhaseFrame(_currFileNo + 1);
265 wf.phase.resize(_pupil->rows(),_pupil->cols());
267 wf.phase = _currPhase.image(_currFrameNo).block( 0.5*( _currPhase.rows()-_pupil->rows()), 0.5*(_currPhase.cols() - _pupil->cols()), _pupil->rows(), _pupil->cols());
269 wf.phase = (wf.phase - (wf.phase* (*_pupil)).sum()/Npix)* (*_pupil);
273 wf.amplitude = _pixVal*(*_pupil);
277 wf.amplitude.resize(_pupil->rows(),_pupil->cols());
279 wf.amplitude = _currAmp.image(_currFrameNo).block( 0.5*( _currAmp.rows()-_pupil->rows()), 0.5*(_currAmp.cols() - _pupil->cols()), _pupil->rows(), _pupil->cols());
281 wf.amplitude *= _pixVal*(*_pupil);
std::vector< std::string > getFileNames(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,...