130 "usage: any2ascii [-v] [-hf] [-all] [-type type] [-integer] [-hu]" "\n" 131 " [-precision p] [-tcol] [-namemod m]" "\n" 132 " infile outbase" "\n" 133 " or: any2ascii --help|-h" "\n" 139 "read any input data and convert samples to ASCII" "\n" 141 "Notice: With the introduction of the format 'ascii' in" "\n" 142 " libdatrwxx, this program has become obsolete. Use" "\n" 143 " any2any instead." "\n" 145 "infile name of input file" "\n" 146 "outbase basename for output files" "\n" 149 "-hf write header information to separate file" "\n" 150 "-all extract all traces, not only first" "\n" 151 "-type type input file has data format \"type\" (default: sff)" "\n" 152 "-integer read and write integer data" "\n" 153 "-precision p set output precision for floating point output" "\n" 154 "-hu dump header in human readable form" "\n" 155 "-tcol print time of sample in first column" "\n" 156 "-namemod m modify filename with header fields" "\n" 157 " modifiers \"m\" can be:" "\n" 158 " d: date of first sample" "\n" 159 " t: time of first sample" "\n" 160 " u: time of first sample with parts of seconds" "\n" 161 " s: station name" "\n" 162 " c: channel name" "\n" 163 " a: auxilliary ID" "\n" 164 " i: instrument" "\n" 168 using namespace tfxx::cmdline;
169 static Declare options[]=
174 {
"verbose",arg_no,
"-"},
180 {
"type",arg_yes,
"sff"},
182 {
"integer",arg_no,
"-"},
184 {
"precision",arg_yes,
"7"},
190 {
"namemod",arg_yes,
"-"},
197 "******************************************************************\n" 198 "THIS PROGRAM IS OBSOLETE\n" 199 "any2ascii is no longer maintained and may vanish in the future\n" 200 "consider to use any2any instead\n" 201 "******************************************************************\n";
208 cerr << usage_text << endl;
209 cerr << tfxx::seitosh::repository_reference << endl;
214 Commandline cmdline(iargc, argv, options);
217 if (cmdline.optset(0))
219 cerr << usage_text << endl;
220 cerr << help_text << endl << endl;
221 datrw::supported_data_types(cerr);
222 datrw::online_help(cerr);
223 cerr << endl << tfxx::seitosh::repository_reference << endl;
235 opt.
hrdump=cmdline.optset(7);
240 TFXX_assert(cmdline.extra(),
"ERROR: missing input filename!");
241 std::string infile=cmdline.next();
242 TFXX_assert(cmdline.extra(),
"ERROR: missing output filename!");
243 std::string outfile=cmdline.next();
245 std::ifstream ifs(infile.c_str(),
247 TFXX_assert(ifs.good(),
"ERROR: cannot open input file!");
261 std::map<std::string, int> tracecounter;
271 cout <<
"trace #" << itrace << endl;
276 datrw::Tdseries timeseries;
279 { is >> itimeseries; }
281 { is >> timeseries; }
291 std::string outbase=outfile +
".";
298 libtime::TAbsoluteTime date=header.
wid2.date;
299 std::ostringstream oss;
310 oss << date.day() <<
".";
311 outbase += oss.str();
320 oss << date.minute();
323 oss << date.second() <<
".";
324 outbase += oss.str();
333 oss << date.minute();
336 oss << date.second() <<
".";
339 oss << date.milsec();
342 oss << date.micsec() <<
".";
343 outbase += oss.str();
347 outbase += tfxx::string::trimws(header.
wid2.station) +
".";
351 outbase += tfxx::string::trimws(header.
wid2.channel) +
".";
355 outbase += tfxx::string::trimws(header.
wid2.auxid) +
".";
359 outbase += tfxx::string::trimws(header.
wid2.instype) +
".";
366 std::ostringstream oss;
369 oss << ++tracecounter[outbase] <<
".";
370 outbase += oss.str();
375 cout <<
" basename for output: " << outbase << endl;
378 std::string outputtracename=outbase+std::string(
"asc");
379 std::string outputheadername=outbase+std::string(
"hdr");
384 std::ofstream tos(outputtracename.c_str());
387 std::ofstream hos(outputheadername.c_str());
407 tos <<
"data:" << endl;
412 for (
int isample=itimeseries.first(); isample<=itimeseries.last();
417 tos.setf(std::ios_base::scientific,std::ios_base::floatfield);
419 tos << (isample-itimeseries.f())*header.
wid2.dt <<
" ";
421 tos << itimeseries(isample) << endl;
426 for (
int isample=timeseries.first(); isample<=timeseries.last();
431 tos.setf(std::ios_base::scientific,std::ios_base::floatfield);
433 tos << (isample-timeseries.f())*header.
wid2.dt <<
" ";
435 tos.setf(std::ios_base::scientific,std::ios_base::floatfield);
437 tos << timeseries(isample) << endl;
447 cout <<
"DEBUG: time column" << endl;
void writeheaderhr(std::ostream &os, const Header &header)
#define ANY2ASCII_VERSION
std::string headerfieldselection
void writeheader(std::ostream &os, const Header &header)