2 #include <boost/filesystem/operations.hpp>
3 #include <boost/filesystem/path.hpp>
4 #include <boost/filesystem/convenience.hpp>
5 #include <boost/algorithm/string.hpp>
6 #include <boost/version.hpp>
12 namespace fs = boost::filesystem;
14 using namespace gplib;
16 int main(
int argc,
char* argv[])
21 "$Id: chooserecfunc.cpp 1870 2011-04-01 11:55:47Z mmoorkamp $";
23 cout <<
"Program " << version << endl;
25 <<
" Display all the receiver functions in a directory and select good and bad ones "
27 cout <<
" Receiver functions are identified by file ending '.rec' " << endl;
29 <<
" Type 'g' for good or 'b' for bad after receiver function is displayed "
33 fs::path full_path(fs::initial_path());
35 if (!fs::exists(full_path))
37 std::cout <<
"\nNot found: " << full_path << std::endl;
41 cout <<
"Enter station identifier: ";
43 if (GraceOpen(2048) == -1)
45 fprintf(stderr,
"Can't run Grace. \n");
48 fs::directory_iterator end_iter;
50 for (fs::directory_iterator dir_itr(full_path); dir_itr != end_iter; ++dir_itr)
52 if (extension(*dir_itr) ==
".rec" && boost::algorithm::contains(
53 dir_itr->path().filename().string(), statid))
55 std::string currentname(dir_itr->path().filename().string());
57 const double dt = RecData.
GetDt();
58 for (
size_t i = 0; i < RecData.
GetData().size() && GraceIsOpen(); i++)
60 if (finite(RecData.
GetData().at(i)))
63 GracePrintf(
"g0.s0 point %f, %f", i * dt,
69 GracePrintf(
"g0.s0 point %f, %f", i * dt, 10000.0);
72 double ymax = *max_element(RecData.
GetData().begin(),
74 double ymin = *min_element(RecData.
GetData().begin(),
76 GracePrintf(
"world xmax %f", RecData.
GetData().size() * dt);
77 GracePrintf(
"world ymax %f", ymax);
78 GracePrintf(
"world ymin %f", ymin);
79 GracePrintf(
"xaxis tick major %f", RecData.
GetData().size() * dt
81 GracePrintf(
"xaxis tick minor %f", RecData.
GetData().size() * dt
83 GracePrintf(
"yaxis tick major %f", ymax / 5);
84 GracePrintf(
"yaxis tick minor %f", ymax / 10);
85 GraceCommand((
"title \" " + currentname +
" \" ").c_str());
86 GracePrintf(
"redraw");
89 fs::rename(currentname, fs::path(
"bad") / currentname);
90 else if (response ==
"g")
91 fs::rename(currentname, fs::path(
"good") / currentname);
93 cout <<
"Invalid reply, ignoring file !" << endl;
94 GracePrintf(
"KILL g0.s0");
96 std::cout <<
"Data size: " << RecData.
GetData().size() << std::endl;
int ReadData(const std::string &filename, tseismicdataformat format=sac)
Read in data from a file, as we cannot determine the type from the ending we have to provide it...
std::vector< double > & GetData()
Access for data vector, for ease of use and efficiency we return a reference.
int main(int argc, char *argv[])
double GetDt() const
Return dt in s.