67 "usage: asciitest [-v] [-overwrite] [-write name] [-ntraces n]" "\n" 68 " [-nsamples n] [-frequency f] [-DEBUG]\n" 69 " or: asciitest --help|-h" "\n" 78 "-overwrite overwrite existing output file\n" 79 "-write name write test traces to file \"name\"\n" 80 "-ntraces n write \"n\" traces\n" 81 "-nsamples n write \"n\" samples per trace\n" 82 "-frequency f create test signal of frequency \"f\"\n" 84 "File reading can be tested with libdatrwxxtests.cc\n" 88 using namespace tfxx::cmdline;
89 static Declare options[]=
96 {
"write",arg_yes,
"junk"},
98 {
"overwrite",arg_no,
"-"},
100 {
"ntraces",arg_yes,
"1"},
102 {
"nsamples",arg_yes,
"20"},
104 {
"frequency",arg_yes,
"10."},
106 {
"DEBUG",arg_no,
"-"},
113 cerr << usage_text << endl;
118 Commandline cmdline(iargc, argv, options);
121 if (cmdline.optset(0))
123 cerr << usage_text << endl;
124 cerr << help_text << endl;
136 opt.
ntraces=cmdline.int_arg(4);
139 opt.
debug=cmdline.optset(7);
145 cout <<
"test output module\n" 146 <<
"==================\n";
152 cout <<
"file data is stored in ";
154 switch (os.seriestype()) {
159 cout <<
"single precision floating point";
162 cout <<
"double precision floating point";
165 cout <<
"any desired";
168 TFXX_abort(
"output stream uses unknown variable type!");
170 cout <<
" variable type" << endl;
172 cout <<
"file FREE data can ";
173 if (!os.handlesfilefree()) { cout <<
"NOT "; }
174 cout <<
"be handled" << endl;
176 cout <<
"SRCE data can ";
177 if (!os.handlessrce()) { cout <<
"NOT "; }
178 cout <<
"be handled" << endl;
180 ::sff::FREE filefree;
181 filefree.append(
"this is the FREE block for the file header");
183 filefree.append(
"output file name:");
187 srce.date=libtime::now();
188 srce.type=
"test source";
192 srce.cs=::sff::CS_cartesian;
194 if (os.handlesfilefree()) { os << filefree; }
195 if (os.handlessrce()) { os << srce; }
198 for (
int itrace=0; itrace<ntraces; ++itrace)
200 cout <<
"write trace #" << itrace+1 << endl;
202 cout <<
"trace FREE data can ";
203 if (!os.handlestracefree()) { cout <<
"NOT "; }
204 cout <<
"be handled" << endl;
206 cout <<
"INFO data can ";
207 if (!os.handlesinfo()) { cout <<
"NOT "; }
208 cout <<
"be handled" << endl;
218 info.cs=::sff::CS_cartesian;
220 const double dt=2.e-3*(itrace+4);
224 wid2.date=libtime::now();
227 wid2.instype=
"SYNTH";
229 int typeindex=itrace%3;
232 aff::Series<double> sine(opt.
nsamples);
233 for (
int isample=0; isample<opt.
nsamples; ++isample)
235 sine(sine.f()+isample)=(itrace+2)*sin(2.*3.141592653589793115998
238 free.append(
"create double type data");
241 if (os.handlesinfo()) { os << info; }
242 if (os.handlestracefree()) { os << free; }
245 else if (typeindex==1)
247 aff::Series<float> sine(opt.
nsamples);
248 for (
int isample=0; isample<opt.
nsamples; ++isample)
250 sine(sine.f()+isample)=(itrace+2)*sin(2.*3.141592653589793115998
253 free.append(
"create float type data");
256 if (os.handlesinfo()) { os << info; }
257 if (os.handlestracefree()) { os << free; }
262 aff::Series<int> sine(opt.
nsamples);
263 for (
int isample=0; isample<opt.
nsamples; ++isample)
265 sine(isample)=isample%15;
268 free.append(
"create int type data");
270 if (os.handlesinfo()) { os << info; }
271 if (os.handlestracefree()) { os << free; }
void abort_if_exists(const std::string &filename)
libtime::TRelativeTime dt()
return sampling interval of HPMO data acquisition (i.e. 5 sec)
static const std::ios_base::openmode openmode
static void help(std::ostream &os=std::cout)
std::string writefilename
#define ASCIITEST_VERSION
static void help(std::ostream &os=std::cout)
class to write ascii data