CMTStationList Class Reference

CMTStationList holds a number of MTSites, usually associated with a single project, line, etc. More...

#include <CMTStationList.h>

Collaboration diagram for CMTStationList:

Collaboration graph
[legend]
List of all members.

Public Member Functions

tStationListGetList ()
 Access to the complete vector of Stations.
void GetData (const std::string filename)
 Read a list of filenames and the associated data in those files to fill the list.
void WriteList (const std::string filename="station.list")
 Write the names of the sites in the current list to a file.
void WriteAllData ()
 Write the data of each station to an individual file.
const std::vector< tindexvector > & GetComFreqIndices ()
 Get a vector that for each site contains the indices to the common frequencies.
const trealdata & GetCommonFrequencies ()
 Get a vector with frequencies that are common to all sites.
CMTStationat (int loc)
 Get a reference to a site at a given index.
 CMTStationList ()
virtual ~CMTStationList ()

Detailed Description

CMTStationList holds a number of MTSites, usually associated with a single project, line, etc.

Definition at line 11 of file CMTStationList.h.


Constructor & Destructor Documentation

CMTStationList::CMTStationList (  ) 

Definition at line 15 of file CMTStationList.cpp.

00016 {}

CMTStationList::~CMTStationList (  )  [virtual]

Definition at line 17 of file CMTStationList.cpp.

00018 {}


Member Function Documentation

tStationList& CMTStationList::GetList (  )  [inline]

Access to the complete vector of Stations.

Definition at line 23 of file CMTStationList.h.

Referenced by main(), and PrintComponent().

00023 {return StationData;}

void CMTStationList::GetData ( const std::string  filename  ) 

Read a list of filenames and the associated data in those files to fill the list.

Definition at line 20 of file CMTStationList.cpp.

References CMTStation::GetData(), StationParser::HasLatLong, StationParser::Latitudes, StationParser::Longitudes, CMTStation::SetLatitude(), CMTStation::SetLongitude(), StationParser::stationfile(), and StationParser::Stationnames.

Referenced by main(), and PromptAndReadStationFile().

00021 {
00022         ifstream infile(filename.c_str());
00023         
00024 
00025         if (infile)
00026         {
00027                 StationLexer lexer(infile);
00028                 StationParser parser(lexer);
00029                 parser.stationfile();
00030                 for (unsigned int i = 0; i < parser.Stationnames.size(); ++i)
00031                 {
00032                         cout << "Working on file " << parser.Stationnames.at(i) << endl;
00033                         try
00034                         {
00035                           CMTStation CurrentStation;
00036                            CurrentStation.GetData(parser.Stationnames.at(i)); 
00037                                 if (parser.HasLatLong.at(i))
00038                                 {
00039                                         CurrentStation.SetLongitude(parser.Longitudes.at(i));
00040                                         CurrentStation.SetLatitude(parser.Latitudes.at(i));
00041                                 }
00042                                 StationData.push_back(CurrentStation);
00043                         }
00044                         catch(ANTLRException& e)
00045                         {
00046                                 cerr << "File " << parser.Stationnames.at(i) << " not found !" << endl;
00047                         }
00048                 }
00049         }
00050         else
00051         {
00052                 throw CFatalException("File not found: " +filename);
00053         }
00054         FindCommon();
00055 }

Here is the call graph for this function:

void CMTStationList::WriteList ( const std::string  filename = "station.list"  ) 

Write the names of the sites in the current list to a file.

Definition at line 62 of file CMTStationList.cpp.

Referenced by main().

00063 {
00064         ofstream outfile(filename.c_str());
00065         for (vector<CMTStation>::iterator CurrentStation = StationData.begin(); CurrentStation != StationData.end(); CurrentStation++)
00066         {
00067                 outfile << CurrentStation->GetName();
00068                 outfile <<  setfill(' ') << setw(15) <<resetiosflags(ios::fixed);       
00069                 outfile << CurrentStation->GetLongitude() << " ";
00070                 outfile <<  setfill(' ') << setw(15) <<resetiosflags(ios::fixed);
00071                 outfile << CurrentStation->GetLatitude();
00072                 outfile << endl;                
00073         }
00074 }

void CMTStationList::WriteAllData (  ) 

Write the data of each station to an individual file.

Definition at line 76 of file CMTStationList.cpp.

00077 {
00078         for (std::vector<CMTStation>::iterator CurrentStation = StationData.begin(); CurrentStation != StationData.end(); CurrentStation++)
00079                 CurrentStation->WriteBack();
00080 }

const std::vector<tindexvector>& CMTStationList::GetComFreqIndices (  )  [inline]

Get a vector that for each site contains the indices to the common frequencies.

Definition at line 31 of file CMTStationList.h.

Referenced by main(), and PrintComponent().

00031 {return cfindices;}

const trealdata& CMTStationList::GetCommonFrequencies (  )  [inline]

Get a vector with frequencies that are common to all sites.

Definition at line 33 of file CMTStationList.h.

Referenced by main(), and PromptAndReadFreqIndex().

00033 {return commonfrequencies;}

CMTStation & CMTStationList::at ( int  loc  ) 

Get a reference to a site at a given index.

Definition at line 57 of file CMTStationList.cpp.

Referenced by main(), and PrintComponent().

00058 {       
00059         return (StationData.at(loc));
00060 }


The documentation for this class was generated from the following files:
Generated on Thu Nov 22 14:07:52 2007 for GPLIB++ by  doxygen 1.5.1