64 "usage: mseedtest [-v] [-raw] [-reader] [-skip] [-stream] [-silent]" "\n" 65 " [-nfinconsist] [-dumpsamples] [-modifiers m]" "\n" 67 " file [file...]" "\n" 68 " or: mseedtest --help|-h" "\n" 74 "-v verbose mode" "\n" 75 "-raw Use raw reading functions from mseedstruct." "\n" 76 " This option uses an algorithm coded on mseedtest.cc\n" 77 " Tested conditions may be different from the conditions\n" 78 " tested in the actual reader functions in the library.\n" 79 " Being able to read a file with this option does not\n" 80 " necessarily mean, that the reader will decode the file\n" 81 " without complaining.\n" 82 "-reader use reading functions from mseedread" "\n" 83 "-skip skip data samples" "\n" 84 "-stream read data through stream" "\n" 85 "-generic use generic frame dump during raw test" "\n" 86 "-nfinconsist make inconsistencies non fatal errors" "\n" 87 "-dumpsamples dump sample values in reader mode" "\n" 88 "-modifiers m format modifiers" "\n" 89 "-silent be silent in stream mode; just output by imseedstream\n" 90 " is produced; this is useful to dump ASCII log entries\n" 91 "-logdump dump ASCII log entries\n" 92 " This is identical to\n" 93 " -stream -modifiers dumpascii -silent -skip\n" 97 using namespace tfxx::cmdline;
98 static Declare options[]=
107 {
"reader",arg_no,
"-"},
111 {
"stream",arg_no,
"-"},
113 {
"generic",arg_no,
"-"},
115 {
"nfinconsist",arg_no,
"-"},
117 {
"dumpsamples",arg_no,
"-"},
119 {
"modifiers",arg_yes,
""},
121 {
"silent",arg_no,
"-"},
123 {
"logdump",arg_no,
"-"},
130 cerr << usage_text << endl;
135 Commandline cmdline(iargc, argv, options);
138 if (cmdline.optset(0))
140 cerr << usage_text << endl;
141 cerr << help_text << endl;
165 bool verbosemode=cmdline.optset(1);
166 bool rawmode=cmdline.optset(2);
167 bool readermode=cmdline.optset(3);
168 bool skipmode=cmdline.optset(4);
169 bool streammode=cmdline.optset(5);
170 bool genericframedump=cmdline.optset(6);
175 bool dumpsamples=cmdline.optset(8);
176 std::string modifiers=cmdline.string_arg(9);
177 bool silent=cmdline.optset(10);
179 if (cmdline.optset(11))
181 modifiers=
"dumpascii";
190 cout <<
"in verbose mode" << endl;
193 { cout <<
"inconsistencies are made non fatal" << endl; }
195 while (cmdline.extra())
197 std::cout << std::endl;
198 std::string filename=cmdline.next();
199 std::cout <<
"file: " << filename << std::endl;
200 std::cout <<
"using standard input block size of " 209 cout <<
"raw mode" << endl;
210 cout <<
"========" << endl;
212 std::ifstream ifs(filename.c_str());
220 cout << endl <<
"BLOCK #" << iblock << endl
221 <<
"===========" << endl;
227 "ERROR (reading MiniSEED record): " 228 "cannot identify CPU type");
230 if (doswap) { cout <<
"swap bytes, when reading header" << endl; }
231 else { cout <<
"do not swap bytes, when reading header" << endl; }
233 if ((controlheader.type ==
'D')
234 || (controlheader.type ==
'R')
235 || (controlheader.type ==
'Q')
236 || (controlheader.type ==
'M'))
239 dataheader(block.block(),doswap);
240 if (dataheader.fblock > block.bytesize())
243 cout <<
"Could not find first Blockette!" << endl;
244 cout <<
"Trying different byte order..." << endl;
249 "ERROR (reading MiniSEED record): " 250 "cannot find first blockette");
251 cout <<
"Apparently we are reading raw data written by an " 252 <<
"EarthDataLogger (EDL) :-)" << endl;
253 if (doswap) { cout <<
"Hence"; }
254 else { cout <<
"Hence do not"; }
255 cout <<
" swap bytes, when reading header!" << endl;
259 cout <<
"RECORD #" << irecord << endl;
260 cout <<
"===========" << endl;
262 int nblockettes(dataheader.numblock);
263 unsigned int blocketteadr(dataheader.fblock);
265 bool foundBlockette1000=
false;
266 bool foundBlockette1001=
false;
269 for (
int i=0; i<nblockettes; i++)
272 bh(block.block(blocketteadr), doswap);
273 cout <<
"Blockette #" << i<< endl;
277 bck(block.block(blocketteadr), doswap);
280 foundBlockette1000=
true;
282 else if (bh.type == 1001)
285 bck(block.block(blocketteadr), doswap);
288 foundBlockette1001=
true;
294 blocketteadr=bh.next;
297 if (foundBlockette1000)
303 if (!dodataswap) { cout <<
"do not "; }
304 cout <<
"swap bytes, when reading data" << endl;
308 unsigned int isamples=0;
311 cout <<
"total number of possible frames in record: " 313 if (foundBlockette1001)
332 cout <<
"number of frames specified in Blockette 1001: " 333 << blockette1001.
ifcount() << endl;
336 unsigned int pframe=dataheader.dbeg;
337 for (
unsigned int i=0; int(i)<
nframes; ++i)
339 if (pframe >= block.bytesize())
344 cout << endl <<
"BLOCK #" << iblock << endl
345 <<
"===========" << endl;
347 if (isamples < dataheader.nsamp)
348 { cout <<
"decode"; }
349 else { cout <<
"ignore"; }
350 cout <<
" frame #" << i+1 <<
"/" <<
nframes;
352 std::ostream::fmtflags flags=cout.flags();
353 cout.setf(std::ios_base::hex, std::ios_base::basefield);
360 if (isamples < dataheader.nsamp)
366 if (genericframedump)
376 while (frame.valid())
386 if (genericframedump)
396 while (frame.valid())
408 cout <<
"This is an ascii record" << endl;
409 unsigned int totalreclen=blockette1000.
reclenbytes();
410 cout <<
"Provides " << totalreclen
411 <<
" bytes of data in total" << endl;
412 unsigned int bytecount=dataheader.dbeg;
413 unsigned int pframe=dataheader.dbeg;
415 while (bytecount < totalreclen)
417 if (pframe >= block.bytesize())
422 cout << endl <<
"BLOCK #" << iblock << endl
423 <<
"===========" << endl;
425 while (pframe < block.bytesize())
427 char c=block[pframe];
434 cout << endl <<
">>";
444 cout <<
"Not steim1, steim2, or ascii format!" << std::endl;
449 cout <<
"No Blockette 1000 available!" << std::endl;
454 std::string seqnum(controlheader.seqno, 6);
455 cout <<
"seqno: #" << seqnum <<
"#" 456 << controlheader.type
458 << controlheader.cont
471 cout <<
"reader mode" << endl;
472 cout <<
"===========" << endl;
474 std::ifstream ifs(filename.c_str());
481 cout <<
"RECORD #" << irecord << endl;
482 cout <<
"===========" << endl;
485 if (verbosemode) { cout <<
"read record by skipping samples" << endl; }
486 record.skipdata(ifs);
490 if (verbosemode) { cout <<
"read record header and samples" << endl; }
497 cout <<
" last sample of previous record: " 498 << record.xm1() << endl << endl;
504 if (record.hasblockette1001())
511 cout <<
"data:" << endl;
513 cout <<
" number of samples in data: " 514 <<
data.size() << endl;
515 cout <<
" last sample of previous record: " 516 << record.xm1() << endl;
517 cout <<
" first sample: " 519 cout <<
" last sample: " 523 cout <<
"BEGIN OF DUMP: data values" << endl;
524 for (
int i=
data.f(); i<=
data.l(); ++i)
526 cout <<
data(i) << endl;
528 cout <<
"END OF DUMP: data values" << endl;
533 libtime::TRelativeTime
dt 534 =libtime::double2time(record.dt());
535 libtime::TRelativeTime length=
dt*(record.nsamples()-1);
536 libtime::TAbsoluteTime date=record.date();
537 libtime::TAbsoluteTime next=(date+
dt+length);
538 cout <<
" sampling interval: " 539 <<
dt.timestring() << endl;
540 cout <<
" length of record: " 541 << length.timestring() << endl;
542 cout <<
" start of this record: " 543 << date.timestring() << endl;
544 cout <<
" expected start of next record: " 545 << next.timestring() << endl;
550 cout <<
"record is invalid!" << endl;
560 cout <<
"stream mode" << endl;
561 cout <<
"===========" << endl;
562 cout <<
"format modifiers: " << modifiers << endl;
565 cout <<
"silent mode: only imseedstream produces output" << endl;
568 std::ifstream ifs(filename.c_str());
572 while (ifs.good() && is.good() && (!is.last()))
575 if (skipmode) { is.skipseries(); }
576 else { is >> series; }
581 cout <<
"TRACE #" << itrace << endl;
582 cout <<
"=========" << endl;
584 if (is.last() && (!silent))
585 { cout <<
"(is the last trace in the file)" << endl; }
589 if (!silent) { cout << wid2line.line() << endl; }
595 cout <<
"data samples were skipped" << endl;
599 cout <<
"series contains " << series.size()
600 <<
" samples" << endl;
601 cout <<
"first (" << series.f() <<
") sample: " 602 << series(series.f()) << endl;
603 cout <<
"last (" << series.l() <<
") sample: " 604 << series(series.l()) << endl;
611 cout << infoline.line() << endl;;
#define DATRW_assert(C, M)
Check an assertion and report by throwing an exception.
static const int blocksize
size of frame in bytes
Ecpu_type cpu()
check for my CPU model
const char *const nframes
keywords for consistency checks
libtime::TRelativeTime dt()
return sampling interval of HPMO data acquisition (i.e. 5 sec)
Ecpu_type
Define different CPU type that are recognized.
class to read mini-SEED data
const char *const data
keywords for consistency checks
bool needswap(const unsigned char &bytesex)
check bytesex
unsigned int ifcount() const
aff::Series< Tvalue > Tseries
type of container for sample data
#define MSEEDTEST_VERSION
bool inconsistencies_are_not_fatal
make inconsistencies non fatal
void dump(const ControlHeader &s, std::ostream &os)
aff::Series< int > Tiseries
unsigned char format
Encoding Format.
static const int standard_block_size
standard block size for mini-SEED files (in SeisComP)
unsigned char bytesex
Word order.
unsigned int reclenbytes() const