34 #define SEIFETEST_VERSION \ 35 "SEIFETEST V1.0 test seife format I/O functions" 40 #include <tfxx/commandline.h> 41 #include <datrwxx/seifeio.h> 64 int main(
int iargc,
char* argv[])
71 "usage: seifetest [-pl file] [-read file] [-DEBUG] [-stream file]" "\n" 72 " [-cmmntlim] [-verbose] [-countonly] [-nprint n]\n" 73 " [-sine file] [-freq f] [-nsamples n] [-moretraces]\n" 75 " or: seifetest --help|-h" "\n" 76 " or: seifetest --xhelp" "\n" 83 "-pl file read parameter line from file" "\n" 84 "-read file read seife data file" "\n" 85 "-stream file read seife data file through stream interface" "\n" 86 "-DEBUG produce debug output" "\n" 87 "-xhelp print complete online help available" "\n" 88 "-cmmntlim test automatic limiting of comment lines" "\n" 89 "-verbose be verbose" "\n" 90 "-countonly just count traces in stream mode (test skiptrace)" "\n" 91 "-nprint n print n samples in stream mode when verbose" "\n" 92 "-sine file write sine wave to file" "\n" 93 "-freq f produce sine wave with frequency f" "\n" 94 "-nsamples n write n samples for sine wave" "\n" 95 "-moretraces try to write more than one trace" "\n" 96 "-modifiers s pass string as format modifiers to the I/O stream" "\n" 100 using namespace tfxx::cmdline;
101 static Declare options[]=
106 {
"verbose",arg_no,
"-"},
110 {
"DEBUG",arg_no,
"-"},
112 {
"read",arg_yes,
"-"},
114 {
"xhelp",arg_no,
"-"},
116 {
"cmmntlim",arg_no,
"-"},
118 {
"stream",arg_yes,
"-"},
120 {
"countonly",arg_no,
"-"},
122 {
"nprint",arg_yes,
"10"},
124 {
"nsamples",arg_yes,
"1000"},
126 {
"frequency",arg_yes,
"25."},
128 {
"sine",arg_yes,
"-"},
130 {
"moretraces",arg_no,
"-"},
132 {
"modifiers",arg_yes,
""},
139 cerr << usage_text << endl;
144 Commandline cmdline(iargc, argv, options);
147 if (cmdline.optset(0) || cmdline.optset(5))
149 cerr << usage_text << endl;
150 cerr << help_text << endl;
151 if (cmdline.optset(5))
154 cerr <<
"help functions:" << endl;
167 opt.
debug=cmdline.optset(3);
174 opt.
nprint=cmdline.int_arg(9);
192 cout <<
"read parameter line is:" << endl;
193 cout << line << endl;
195 cout <<
"reproduced as:" << endl;
196 cout << paraline.
line() << endl;
197 cout <<
"123456789012345678901234567890123456789012345678901234567890" <<
199 cout <<
"0 1 2 3 4 5 6" <<
211 ::sff::FREE free=header.comments();
213 datrw::util::readasciidouble<datrw::Tdseries>(ifs, parameters.
nsamples(),
215 cout <<
"the file is reproduced as:" << std::endl;
217 header.set(parameters);
228 cout <<
"test automatic limiting of comment lines" << endl;
229 ::sff::FREE comments;
230 std::ostringstream oss;
231 for (
unsigned int i=0; i<60; ++i)
233 if (oss.str().length()>60) { oss.str(
""); }
235 comments.append(oss.str());
237 cout <<
"FREE block prepared is:" << endl;
238 comments.write(cout);
240 header.
set(comments);
241 cout <<
"seife header produced from this:" << endl;
256 cout <<
"file FREE block:" << endl;
257 is.free().write(std::cout);
261 cout <<
"file has FREE block" << endl;
266 cout <<
"file has no FREE block" << endl;
272 cout <<
"file SRCE line:" << endl;
273 cout << is.srce().line() << endl;;
277 cout <<
"file has SRCE line" << endl;
282 cout <<
"file has no SRCE line" << endl;
298 cout <<
"trace FREE block:" << endl;
299 is.free().write(std::cout);
303 cout <<
"trace has FREE block" << endl;
308 cout <<
"trace has no FREE block" << endl;
314 cout <<
"trace INFO line:" << endl;
315 cout << is.info().line() << endl;;
319 cout <<
"trace has INFO line" << endl;
324 cout <<
"trace has no INFO line" << endl;
326 std::cout << is.wid2().line() << std::endl;
330 opt.
nprint < int(fseries.size()/2) ?
331 opt.
nprint : fseries.size()/2;
332 for (
int i=0; i<npr; ++i)
333 { std::cout << i <<
" " << fseries(i) << std::endl; }
334 std::cout <<
" ... " << std::endl;
335 for (
int i=fseries.size()-npr; i<int(fseries.size()); ++i)
336 { std::cout << i <<
" " << fseries(i) << std::endl; }
344 cout <<
"write sine wave to file " << opt.
sinefilename << endl;
348 cout <<
"file data is stored in ";
350 switch (os.seriestype()) {
355 cout <<
"single precision floating point";
358 cout <<
"double precision floating point";
361 cout <<
"any desired";
364 TFXX_abort(
"output stream uses unknown variable type!");
366 cout <<
" variable type" << endl;
368 cout <<
"file FREE data can ";
369 if (!os.handlesfilefree()) { cout <<
"NOT "; }
370 cout <<
"be handled" << endl;
372 cout <<
"SRCE data can ";
373 if (!os.handlessrce()) { cout <<
"NOT "; }
374 cout <<
"be handled" << endl;
378 for (
int itrace=0; itrace<ntraces; ++itrace)
380 cout <<
"write trace #" << itrace+1 << endl;
381 aff::Series<double> sine(opt.
nsamples);
382 const double dt=2.e-3*(itrace+4);
383 for (
int isample=0; isample<opt.
nsamples; ++isample)
385 sine(sine.f()+isample)=(itrace+2)*sin(2.*3.141592653589793115998
389 cout <<
"trace FREE data can ";
390 if (!os.handlestracefree()) { cout <<
"NOT "; }
391 cout <<
"be handled" << endl;
393 cout <<
"INFO data can ";
394 if (!os.handlesinfo()) { cout <<
"NOT "; }
395 cout <<
"be handled" << endl;
401 wid2.nsamples=sine.size();
402 wid2.date=libtime::now();
404 if (os.handlestracefree()) { os << free; }
seife format header parameter line
int main(int iargc, char *argv[])
unsigned int nsamples() const
return number of samples
seife reading and writing module (prototypes)
const char *const seife_standard_format
static const std::ios_base::openmode openmode
aff::Series< float > Tfseries
libtime::TRelativeTime dt()
return sampling interval of HPMO data acquisition (i.e. 5 sec)
aff::Series< double > Tdseries
void online_help(const std::string &format, std::ostream &os, const bool &modifierhelp)
utilities used by more than one type of data reader (prototypes)
void write_series(std::ostream &os, const Tseries::Tcoc &s)
write samples to file
std::string format() const
return Fortran data format
void supported_data_types(std::ostream &os)
#define SEIFETEST_VERSION
std::string streamreadfile
class to write seife data
std::string parameterlinefile
std::string line() const
create line for output from values