Commit 9ad0f297 authored by thomas.forbriger's avatar thomas.forbriger
Browse files

[FEATURE] (foutra): provide output format selector

This is a legacy commit from before 2015-03-01.
It may be incomplete as well as inconsistent.
See COPYING.legacy and README.history for details.

Output in any format supported by libdatrwxx is provided
parent d3daab93
......@@ -48,6 +48,7 @@
* and segment (analysis) series
* - 10/01/2011 V1.8b corrected Fourier transformation formula in
* doxygen documentation
* - 03/12/2014 V1.9 provide output file format selector
*
* \note 08/01/2010:
* Scaling for foutra power spectrum was tested against theory.
......@@ -65,7 +66,7 @@
* ============================================================================
*/
#define FOUTRA_VERSION \
"FOUTRA V1.8 Fourier transforms"
"FOUTRA V1.9 Fourier transforms"
#define FOUTRA_CVSID \
"$Id$"
......@@ -89,8 +90,8 @@
#include <tfxx/xcmdline.h>
#include <tfxx/misc.h>
#include <tfxx/handle.h>
#include <sffostream.h>
#include <datrwxx/readany.h>
#include <datrwxx/writeany.h>
#include <fourier/fftwaff.h>
#include <sstream>
......@@ -100,7 +101,7 @@ using std::endl;
struct Options {
bool verbose, overwrite, debug, asciiout, logascii;
std::string inputformat, asciibase;
std::string inputformat, asciibase, outputformat;
bool amplitudespectrum, powerspectrum, boxcartaper;
bool avgconstbw, avgrelbw, avgasciionly;
bool demean, detrend, scalerbw, adjustdivisor;
......@@ -134,7 +135,7 @@ int main(int iargc, char* argv[])
char usage_text[]=
{
FOUTRA_VERSION "\n"
"usage: foutra [-v] [-o] [-type type] [-D] [-ASCII[=base]]" "\n"
"usage: foutra [-v] [-o] [-type type] [-Type type] [-D] [-ASCII[=base]]\n"
" [-amplitude] [-power] [-logascii[=n]]" "\n"
" [-boxcar] [-avg[=n]] [-rbw[=n]] [-avgascii]" "\n"
" [-demean[=n]] [-dtrend[=n]] [-scalerbw[=n]]" "\n"
......@@ -165,7 +166,7 @@ int main(int iargc, char* argv[])
"-amplitude calculate amplitude spectrum" "\n"
"-power calculate power spectrum" "\n"
"-type type select input file type" "\n"
"-type type select input file type" "\n"
"-Type type select output file type" "\n"
"-avg[=n] smooth power spectrum by averaging over n samples" "\n"
"-rbw[=n] smooth power spectrum by averaging over n decades" "\n"
"-demean[=n] remove average (determined from n samples)" "\n"
......@@ -285,6 +286,8 @@ int main(int iargc, char* argv[])
{"nsegments",arg_yes,"1"},
// 21: extended help
{"xhelp",arg_no,"-"},
// 22: input format
{"Type",arg_yes,"sff"},
{NULL}
};
......@@ -308,7 +311,7 @@ int main(int iargc, char* argv[])
{
cerr << usage_text << endl;
cerr << help_text << endl;
datrw::supported_input_data_types(cerr);
datrw::supported_data_types(cerr);
if (cmdline.optset(21)) { datrw::online_help(cerr); }
exit(0);
}
......@@ -344,6 +347,7 @@ int main(int iargc, char* argv[])
opt.padzeroes=cmdline.optset(19);
opt.padfactor=cmdline.int_arg(19);
opt.nsegments=cmdline.int_arg(20);
opt.outputformat=cmdline.string_arg(22);
TFXX_assert((opt.divisor > 0), "illegal value for argument divisor");
TFXX_assert((opt.nsegments > 0), "illegal value for argument nsegments");
......@@ -520,7 +524,7 @@ int main(int iargc, char* argv[])
TFXX_assert((!file.good()),"ERROR: output file exists!");
}
std::ofstream ofs(outfile.c_str());
sff::SFFostream<Tseries> os(ofs, opt.debug);
datrw::oanystream os(ofs, opt.outputformat);
// prepare file FREE block
sff::FREE filefree;
......@@ -911,7 +915,6 @@ int main(int iargc, char* argv[])
wid2.dt=df;
wid2.nsamples=series.size();
os << series;
os << wid2;
TFXX_debug(opt.debug, "main", " series and WID are written");
if (is.hasinfo()) { sff::INFO info; is >> info; os << info; }
......@@ -924,6 +927,7 @@ int main(int iargc, char* argv[])
tracefree.append(processfree);
os << tracefree;
}
os << series;
// write ASCII output if requested
if (opt.asciiout)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment