Commit ea04ffcb authored by thomas.forbriger's avatar thomas.forbriger
Browse files

croposp [WP]: add consistency check

This commit had to be rebased and appears out of chronological order.
parent 671419e6
......@@ -20,6 +20,7 @@
#include <iostream>
#include <tfxx/commandline.h>
#include <tfxx/error.h>
#include <tsioxx/cmdlinefiles.h>
#include <tsxx/tscollection.h>
......@@ -28,8 +29,9 @@ using std::cerr;
using std::endl;
struct Options {
bool verbose;
bool verbose, trim;
std::string inputformat;
double datetolerance;
}; // struct Options
int main(int iargc, char* argv[])
......@@ -46,9 +48,14 @@ int main(int iargc, char* argv[])
// define full help text
char help_text[]=
{
"-verbose verbose\n"
"-itype f input file format\n"
"-verbose be verbose\n"
"-itype f set default input file format (this value can\n"
" be overwritten by the format key at a file name)\n"
"-trim trim time series to identical begin and length\n"
"-datetolerance t set tolerance as a fraction of sampling interval\n"
" when comparing time series header date values\n"
"\n"
"keys to be appended to file names if required:\n"
"t:sel trace selection\n"
"f:format file format\n"
};
......@@ -63,6 +70,10 @@ int main(int iargc, char* argv[])
{"verbose",arg_no,"-"},
// 2: default input file format
{"itype",arg_yes,"sff"},
// 3: trim time series
{"trim",arg_no,"-"},
// 4: default input file format
{"datetolerance",arg_yes,"0."},
{NULL}
};
......@@ -94,6 +105,8 @@ int main(int iargc, char* argv[])
Options opt;
opt.verbose=cmdline.optset(1);
opt.inputformat=cmdline.string_arg(2);
opt.trim=cmdline.optset(3);
opt.datetolerance=cmdline.double_arg(4);
// extract commandline arguments
TFXX_assert(cmdline.extra(), "missing input file");
......@@ -120,7 +133,7 @@ int main(int iargc, char* argv[])
// collect traces
typedef ts::TimeSeriesCollection<double> TCollection;
TCollection list_of_series;
TCollection collection_of_series;
typedef ts::sff::DFile::Tfile Tfile;
typedef Tfile::Ttracevector Ttracevector;
ts::sff::TDFileList::const_iterator i_file=input_file_list.begin();
......@@ -129,7 +142,7 @@ int main(int iargc, char* argv[])
Ttracevector::const_iterator i_trace=i_file->data.begin();
while (i_trace != i_file->data.end())
{
list_of_series.push_back(*i_trace);
collection_of_series.push_back(*i_trace);
++i_trace;
}
++i_file;
......@@ -139,8 +152,8 @@ int main(int iargc, char* argv[])
if (opt.verbose)
{
cout << "Time series to be analyzed:" << endl;
TCollection::const_iterator i_series=list_of_series.begin();
while (i_series != list_of_series.end())
TCollection::const_iterator i_series=collection_of_series.begin();
while (i_series != collection_of_series.end())
{
cout << " "
<< i_series->header.station << " "
......@@ -154,6 +167,18 @@ int main(int iargc, char* argv[])
}
}
// trim time series
if (opt.trim)
{
TFXX_abort("trim is not yet implemented");
}
// check consistency
::sff::WID2compare comparer(::sff::Fdt | ::sff::Fnsamples | ::sff::Fdate);
comparer.setdatetolerance(opt.datetolerance);
TFXX_assert(collection_of_series.are_consistent(comparer),
"time series are inconsistent");
} // main()
/* ----- END OF croposp.cc ----- */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment