37 #define CXXFFTWARTEST_VERSION \ 38 "CXXFFTWARTEST V1.2 test fftw3 array engine" 52 #include <tfxx/commandline.h> 53 #include <tfxx/xcmdline.h> 56 #include <tfxx/error.h> 57 #include <tfxx/misc.h> 60 #include <tfxx/rangestring.h> 61 #include <tfxx/rangelist.h> 64 #include <aff/series.h> 67 #include <datrwxx/readany.h> 68 #include <datrwxx/writeany.h> 71 #include <aff/seriesoperators.h> 73 #include <aff/arrayoperators.h> 125 int main(
int iargc,
char* argv[])
132 "usage: cxxfftwartest input output [-s] [-v] [-o] [-x] [-type f]" "\n" 133 " or: cxxfftwartest --help|-h" "\n" 134 " or: cxxfftwartest --xhelp" "\n" 141 "input input file name\n" 142 "output output file name\n" 145 "-s report container sizes\n" 146 "-o overwrite output file\n" 147 "-x reverse order of DRFFTWAFF and DRFFTWAFFArrayEngine\n" 149 "-type f file format\n" 151 "Fourier coefficients for input time series are obtained from\n" 152 "DRFFTWAFFArrayEngine. Then time series are constructed from these\n" 153 "coefficients by application of DRFFTWAFF. If the -x option is\n" 154 "selected, both transformation tools are exchanged in the\n" 155 "application order.\n" 159 using namespace tfxx::cmdline;
160 static Declare options[]=
165 {
"xhelp",arg_no,
"-"},
171 {
"type",arg_no,
"sff"},
182 cerr << usage_text << endl;
187 Commandline cmdline(iargc, argv, options);
190 if (cmdline.optset(0))
192 cerr << usage_text << endl;
193 cerr << help_text << endl;
194 datrw::supported_data_types(cerr);
199 if (cmdline.optset(1))
201 cerr << usage_text << endl;
203 datrw::online_help(cerr);
222 TFXX_assert(cmdline.extra(),
"missing input file");
223 std::string infilename=cmdline.next();
224 TFXX_assert(cmdline.extra(),
"missing output file");
225 std::string outfilename=cmdline.next();
234 if (opt.
verbose) { cout <<
"open input file " << infilename << endl; }
236 std::ios_base::openmode iopenmode
239 std::ifstream ifs(infilename.c_str(), iopenmode);
254 unsigned int itrace=0;
256 unsigned int nsamples=0;
275 nsamples=nsamples > trace.
series.size() ? nsamples : trace.
series.size();
278 vecoftraces.push_back(trace);
284 unsigned int ntraces=vecoftraces.size();
290 cout <<
"input files are read..." << endl;
295 cout <<
"number of traces: " << ntraces << endl;
296 cout <<
"number of samples in largest trace: " << nsamples << endl;
304 if (opt.
verbose) { cout <<
"create FFT array engine" << endl; }
311 cout <<
"fill FFT array engine with Fourier coefficients" << endl;
318 for (
int i=0; i<engine.
nseries(); ++i)
321 spectrum=fft(vecoftraces[i].series,vecoftraces[i].wid2.dt);
322 engine.
spectrum(i).copyin(spectrum);
325 if (opt.
verbose) { cout <<
"execute FFT array engine" << endl; }
330 cout <<
"read time series samples from FFT array engine" << endl;
332 for (
int i=0; i<engine.
nseries(); ++i)
334 Trace& trace=vecoftraces[i];
342 if (opt.
verbose) { cout <<
"create FFT array engine" << endl; }
345 if (opt.
verbose) { cout <<
"fill FFT array engine" << endl; }
348 for (
int i=0; i<engine.
nseries(); ++i)
350 engine.
series(i).copyin(vecoftraces[i].series);
353 cout <<
"engine series #" << i <<
" has " << engine.
series(i).size()
354 <<
" samples" << endl;
358 if (opt.
verbose) { cout <<
"execute FFT array engine" << endl; }
363 cout <<
"read coefficients and transform to time domain" << endl;
367 for (
int i=0; i<engine.
nseries(); ++i)
369 Trace& trace=vecoftraces[i];
374 spectrum.copyin(coeff);
375 series=fft(spectrum,trace.
wid2.dt);
378 cout <<
"after return from engine for trace #" << i << endl;
379 cout <<
" size of engine spectrum: " << engine.
spectrum(i).size()
381 cout <<
" size of copy of spectrum: " << spectrum.size()
383 cout <<
" returned series size: " << series.size() << endl;
393 if (opt.
verbose) { cout <<
"write transformed traces" << endl; }
396 cout <<
"write file " << outfilename << endl;
402 std::ifstream file(outfilename.c_str(),std::ios_base::in);
403 TFXX_assert((!file.good()),
"ERROR: output file exists!");
407 std::ios_base::openmode oopenmode
409 std::ofstream ofs(outfilename.c_str(), oopenmode);
413 if (os.handlessrce()) { os << srce; }
416 for (
unsigned int j=0; j<vecoftraces.size(); ++j)
420 cout <<
" write trace #" << j+1 << endl;
422 Trace& currenttrace=vecoftraces[j];
424 os << currenttrace.
wid2;
425 if (os.handlesinfo()) { os << currenttrace.
info; }
426 os << currenttrace.
series;
Tsample scale_spectrum(const Tsample &dt) const
Return appropriate scaling factor for sampling interval dt.
engine to transfrom several signals at once (prototypes)
aff::Array< Tcoeff > TAspectrum
unsigned int size() const
std::vector< Trace > Tvecoftraces
aff::Series< Tcoeff > Tspectrum
TAseries series() const
return a reference to the time series arrays
void r2c()
execute r2c plan
Tsample scale_series(const Tsample &dt) const
Return appropriate scaling factor for sampling interval dt.
int main(int iargc, char *argv[])
unsigned int nseries() const
return the number of series in the arrays
aff::Series< Tvalue > Tseries
use fftw together with aff containers (prototypes)
TAspectrum spectrum() const
return a reference to the Fourier coefficient arrays
Engine to transform several signals at once. References to workspace are passed to the contstructor...
void c2r()
execute c2r plan
#define CXXFFTWARTEST_VERSION