GPLIB++
selectsites.cpp
Go to the documentation of this file.
1 #include "SeismicStationList.h"
2 #include <iostream>
3 #include <string>
4 #include <fstream>
5 
6 using namespace std;
7 using namespace gplib;
8 
9 int main(int argc, char* argv[])
10  {
11  SeismicStationList Stations;
12  string listfilename, outfilename;
13 
14  string version = "$Id: selectsites.cpp 1816 2009-09-07 11:28:35Z mmoorkamp $";
15  cout << endl << endl;
16  cout << "Program " << version << endl;
17  cout << " Select sites from a given backazimuth and distance range" << endl;
18  cout << " Writes out a file with site names for further processing" << endl;
19  cout << endl << endl;
20  //we can specify the files on the command line or ask interactively
21  if (argc > 2)
22  {
23  listfilename = argv[1];
24  outfilename = argv[2];
25  }
26  else
27  {
28  cout << "List filename: ";
29  cin >> listfilename;
30  cout << "Output filename: ";
31  cin >> outfilename;
32  }
33  //read in the data
34  Stations.ReadList(listfilename);
35  //specify some reasonable default values
36  double minbaz = 0;
37  double maxbaz = 360;
38  double mingcarc = 30;
39  double maxgcarc = 130;
40  //ask backazimuth and distance information
41  cout << "Minimum Backazimuth: ";
42  cin >> minbaz;
43  cout << " Maximum Backazimuth: ";
44  cin >> maxbaz;
45  cout << "Minimum GcArc: ";
46  cin >> mingcarc;
47  cout << " Maximum GcArc: ";
48  cin >> maxgcarc;
49  //this file will contain all the filenames
50  ofstream outlist(outfilename.c_str());
51  //go through all components in the vector
52  for (SeismicStationList::tseiscompvector::iterator CurrentStation =
53  Stations.GetList().begin(); CurrentStation != Stations.GetList().end(); CurrentStation++)
54  {
55  //write out the back azimuth and distance to check
56  cout << "Baz: " << CurrentStation->get()->GetBaz() << " Gcarc: "
57  << CurrentStation->get()->GetGcarc();
58  //apply the selection criteria
59  if (minbaz <= CurrentStation->get()->GetBaz() && maxbaz
60  >= CurrentStation->get()->GetBaz() && mingcarc
61  <= CurrentStation->get()->GetGcarc() && maxgcarc
62  >= CurrentStation->get()->GetGcarc())
63  {
64  outlist << CurrentStation->get()->GetName() << endl;
65  cout << " Selected ! ";
66  }
67  cout << endl;
68  }
69  }
tseiscompvector & GetList()
Return the content of the list for manipulation.
Manages a collection of seismic traces, mainly provides functionality to read in data specified in a ...
void ReadList(const std::string filename)
read in a file with names and optionally coordinates
string version
Definition: makeinput.cpp:16
int main(int argc, char *argv[])
Definition: selectsites.cpp:9