selectsites.cpp

Go to the documentation of this file.
00001 #include "SeismicStationList.h"
00002 #include <iostream>
00003 #include <string>
00004 #include <fstream>
00005 
00006 using namespace std;
00007 using namespace gplib;
00008 
00009 int main(int argc, char* argv[])
00010   {
00011     SeismicStationList Stations;
00012     string listfilename, outfilename;
00013 
00014     string version = "$Id: selectsites.cpp 1816 2009-09-07 11:28:35Z mmoorkamp $";
00015     cout << endl << endl;
00016     cout << "Program " << version << endl;
00017     cout << " Select sites from a given backazimuth and distance range" << endl;
00018     cout << " Writes out a file with site names for further processing" << endl;
00019     cout << endl << endl;
00020     //we can specify the files on the command line or ask interactively
00021     if (argc > 2)
00022       {
00023         listfilename = argv[1];
00024         outfilename = argv[2];
00025       }
00026     else
00027       {
00028         cout << "List filename: ";
00029         cin >> listfilename;
00030         cout << "Output filename: ";
00031         cin >> outfilename;
00032       }
00033     //read in the data
00034     Stations.ReadList(listfilename);
00035     //specify some reasonable default values
00036     double minbaz = 0;
00037     double maxbaz = 360;
00038     double mingcarc = 30;
00039     double maxgcarc = 130;
00040     //ask backazimuth and distance information
00041     cout << "Minimum  Backazimuth: ";
00042     cin >> minbaz;
00043     cout << " Maximum Backazimuth: ";
00044     cin >> maxbaz;
00045     cout << "Minimum  GcArc: ";
00046     cin >> mingcarc;
00047     cout << " Maximum GcArc: ";
00048     cin >> maxgcarc;
00049     //this file will contain all the filenames
00050     ofstream outlist(outfilename.c_str());
00051     //go through all components in the vector
00052     for (SeismicStationList::tseiscompvector::iterator CurrentStation =
00053         Stations.GetList().begin(); CurrentStation != Stations.GetList().end(); CurrentStation++)
00054       {
00055         //write out the back azimuth and distance to check
00056         cout << "Baz: " << CurrentStation->get()->GetBaz() << " Gcarc: "
00057             << CurrentStation->get()->GetGcarc();
00058         //apply the selection criteria
00059         if (minbaz <= CurrentStation->get()->GetBaz() && maxbaz
00060             >= CurrentStation->get()->GetBaz() && mingcarc
00061             <= CurrentStation->get()->GetGcarc() && maxgcarc
00062             >= CurrentStation->get()->GetGcarc())
00063           {
00064             outlist << CurrentStation->get()->GetName() << endl;
00065             cout << " Selected ! ";
00066           }
00067         cout << endl;
00068       }
00069   }

Generated on Tue May 4 16:52:15 2010 for GPLIB++ by  doxygen 1.5.8