37 #define WRITETEST_VERSION \ 38 "WRITETEST V1.0 test writing a file" 42 #include <tfxx/commandline.h> 66 int main(
int iargc,
char* argv[])
73 "usage: writetest [-v] [-D] [-sff n] [-gse n] [-any n]" "\n" 74 " [-t type] [-A amp] [-o] [-digits v]" "\n" 75 " or: writetest --help|-h" "\n" 76 " or: writetest --xhelp" "\n" 84 "-D enter debug mode" "\n" 85 "-sff n write to SFF file \"n\"" "\n" 86 "-gse n write to GSE file \"n\"" "\n" 87 "-any n write to file \"n\"" "\n" 89 "options to define \"any\" test:" "\n" 90 "-t type select output format type for any" "\n" 91 "-A amp select signal amplitude" "\n" 92 "-o overwrite existing output file" "\n" 93 "-digits v test digits functions" "\n" 97 using namespace tfxx::cmdline;
98 static Declare options[]=
119 {
"digits",arg_yes,
"1."},
121 {
"xhelp",arg_no,
"-"},
128 cerr << usage_text << endl;
133 Commandline cmdline(iargc, argv, options);
136 if (cmdline.optset(0) || cmdline.optset(10))
138 cerr << usage_text << endl;
139 cerr << help_text << endl;
141 if (cmdline.optset(10))
174 opt.
debug=cmdline.optset(2);
181 opt.
format=cmdline.string_arg(6);
192 { cout <<
"SFF test: write to file " << opt.
sfffilename << endl; }
196 free.append(
"my file comment");
208 tracefree.append(
"linear integer trace");
210 for (
int i=s.f(); i<=s.l(); ++i)
222 tracefree.append(
"double sine trace");
223 for (
int i=s.f(); i<=s.l(); ++i)
225 s(i)=5.e4*sin(2*3.14159265358979311599*i/(s.size()-1));
236 tracefree.append(
"float cosine trace");
237 for (
int i=s.f(); i<=s.l(); ++i)
239 s(i)=6.e-12*cos(2*3.14159265358979311599*i/(s.size()-1));
255 { cout <<
"GSE test: write to file " << opt.
gsefilename << endl; }
259 free.append(
"my file comment");
271 tracefree.append(
"linear integer trace");
273 for (
int i=s.f(); i<=s.l(); ++i)
285 tracefree.append(
"double sine trace");
286 for (
int i=s.f(); i<=s.l(); ++i)
288 s(i)=30.*sin(2*3.14159265358979311599*i/(s.size()-1));
299 tracefree.append(
"float cosine trace");
300 for (
int i=s.f(); i<=s.l(); ++i)
302 s(i)=6.*cos(2*3.14159265358979311599*i/(s.size()-1));
319 cout <<
"ANY test: write to file " << opt.
anyfilename << endl;
320 cout <<
"using " << opt.
format << endl;
326 free.append(
"my file comment");
336 tracefree.append(
"double sine trace");
337 for (
int i=s.f(); i<=s.l(); ++i)
339 s(i)=opt.
amplitude*sin(2*3.14159265358979311599*i/(s.size()-1));
344 tracefree.append(
"smaller sampling interval");
358 cout <<
"number of siginificant digits " 361 cout <<
"number of trailing digits " void abort_if_exists(const std::string &filename)
aff::Series< float > Tfseries
read sff data (prototypes)
aff::Series< double > Tdseries
void online_help(const std::string &format, std::ostream &os, const bool &modifierhelp)
int main(int iargc, char *argv[])
utilities used by more than one type of data reader (prototypes)
common interface for all data types (prototypes)
void supported_data_types(std::ostream &os)
int ntrailingdigits(double v, const bool &debug)
return number of trailing digits (after decimal point)
int nsignificantdigits(double v, const bool &debug)
return number of significant digits
aff::Series< int > Tiseries
Class to write any type of data file.
#define WRITETEST_VERSION