CMTStation Class Reference

The class CMTStation is used to store the transfer functions and related information for a MT-site. More...

#include <CMTStation.h>

Inheritance diagram for CMTStation:

Inheritance graph
[legend]
Collaboration diagram for CMTStation:

Collaboration graph
[legend]
List of all members.

Public Types

enum  tmtdataformat {
  unknown, mtt, j, edi,
  pek
}

Public Member Functions

void AssignAll (const int nfreq)
void Rotate (const double rotangle)
void Rotate (void)
 Rotate to zero rotation angle.
trealdata GetFrequencies () const
 return the available frequencies in a single vector
void SetFrequencies (const trealdata &freqs)
 Set the frequencies of the tensor elements, invalidates the previously stored impedance data, mainly for creating synthetic data.
double GetLatitude () const
 access funtion for Latitude
void SetLatitude (double lat)
double GetLongitude () const
void SetLongitude (double lon)
double GetElevation () const
std::string GetName ()
double GetAzimuth () const
const CMTTensorat (const unsigned int i) const
 direct acces to a tensor at a given index
const std::vector< CMTTensor > & GetMTData () const
 Get the full vector of Tensor elements read only.
std::vector< CMTTensor > & SetMTData ()
 Get the full vector of Tensor elements for reading and writing.
virtual CMTStationclone () const
 for parallel runs we need to make a copy of the object and its derived classes
 CMTStation ()
 CMTStation (const CMTStation &old)
 CMTStation (const int size)
 CMTStation (const std::string filename)
virtual ~CMTStation ()
virtual void GetData (const std::string filename)
 read in data from file, determines format by ending
virtual void GetData ()
virtual void WriteData (const std::string filename)
void WriteAsMtt (const std::string filename)
 Write data in goettingen .mtt format.
void WriteAsEdi (const std::string filename)
 Write data as edi (no functionality yet).
void WriteAsJ (const std::string filename)
 Write data to j-file.
void WriteBack ()
 Write data back in original format, with filename given by station name.
CMTStationoperator= (const CMTStation &source)

Protected Member Functions

void Update ()
 Update all derived quantities.
void Assign (const int nfreq)
 Assign() assigns zero to all derived quantities, this makes the calculation.

Friends

class C1DMTSynthData

Detailed Description

The class CMTStation is used to store the transfer functions and related information for a MT-site.

Definition at line 13 of file CMTStation.h.


Member Enumeration Documentation

enum CMTStation::tmtdataformat

Enumerator:
unknown 
mtt 
j 
edi 
pek 

Definition at line 15 of file CMTStation.h.

00015 {unknown, mtt, j, edi, pek};


Constructor & Destructor Documentation

CMTStation::CMTStation (  ) 

Definition at line 37 of file CMTStation.cpp.

Referenced by clone().

00038 {
00039         InitialSetup();
00040 }

CMTStation::CMTStation ( const CMTStation old  ) 

Definition at line 614 of file CMTStation.cpp.

References Update().

00614                                            :
00615         MTData(old.MTData),
00616         TFData(old.TFData),
00617         latitude(old.latitude),
00618         longitude(old.longitude),
00619         elevation(old.elevation),
00620         azimuth(old.azimuth),
00621         name(old.name),
00622         dataformat(old.dataformat)
00623 {
00624         Update();
00625 }

Here is the call graph for this function:

CMTStation::CMTStation ( const int  size  ) 

Definition at line 51 of file CMTStation.cpp.

References Assign().

00051                                     :
00052 MTData(size)
00053 {
00054         InitialSetup();
00055         Assign(size);
00056 }

Here is the call graph for this function:

CMTStation::CMTStation ( const std::string  filename  ) 

Definition at line 45 of file CMTStation.cpp.

References GetData().

00046 {
00047         InitialSetup();
00048         GetData(filename);
00049 }

Here is the call graph for this function:

CMTStation::~CMTStation (  )  [virtual]

Definition at line 42 of file CMTStation.cpp.

00043 {}


Member Function Documentation

void CMTStation::Update (  )  [protected]

Update all derived quantities.

The Update() method first updates all components individually and then recalculates all derived quantities that depend on more than one component

Definition at line 71 of file CMTStation.cpp.

Referenced by CMTStation(), C1DMTSynthData::GetData(), C1DAnisoMTSynthData::GetData(), operator=(), Rotate(), and WriteAsMtt().

00072 {
00073         
00074 }

void CMTStation::Assign ( const int  nfreq  )  [protected]

Assign() assigns zero to all derived quantities, this makes the calculation.

Definition at line 61 of file CMTStation.cpp.

References MTData.

Referenced by AssignAll(), CMTStation(), C1DMTSynthData::GetData(), and C1DAnisoMTSynthData::GetData().

00062 {
00063         MTData.assign(nfreq,CMTTensor());
00064         TFData.assign(nfreq,CMagneticTF());
00065 }

void CMTStation::AssignAll ( const int  nfreq  ) 

Definition at line 57 of file CMTStation.cpp.

References Assign().

Referenced by main().

00058 {
00059         Assign(nfreq);
00060 }

Here is the call graph for this function:

void CMTStation::Rotate ( const double  rotangle  ) 

Given a rotation angle in radian this method rotates the impedance tensor and updates all derived quantities

Definition at line 98 of file CMTStation.cpp.

References MTData, and Update().

00099 {
00100     for (unsigned int i = 0; i < MTData.size() ; ++i)
00101     {
00102            DoRotate(i,rotangle);
00103     }
00104     Update();
00105 }

Here is the call graph for this function:

void CMTStation::Rotate ( void   ) 

Rotate to zero rotation angle.

Rotate(void) rotates the impedance tensor by the negative of the angle given in the rotangles field

Definition at line 109 of file CMTStation.cpp.

References at(), MTData, CMTTensor::rotangle, and Update().

Referenced by GetData().

00110 {
00111     for (unsigned int i = 0; i < MTData.size() ; ++i)
00112     {
00113                 DoRotate(i,-MTData.at(i).rotangle);
00114     }
00115     Update();
00116 }

Here is the call graph for this function:

trealdata CMTStation::GetFrequencies (  )  const

return the available frequencies in a single vector

Return a vector containing the available frequencies; This should be rewritten to be more efficient

Definition at line 119 of file CMTStation.cpp.

References CMTTensor::GetFrequency(), and MTData.

Referenced by C1DMTSynthData::GetData(), C1DAnisoMTSynthData::GetData(), main(), PTensor1DMTObjective::SafeParallel(), and C1DMTObjective::SafeParallel().

00120 {
00121         trealdata temp(MTData.size());
00122         transform(MTData.begin(),MTData.end(),temp.begin(),mem_fun_ref(&CMTTensor::GetFrequency));
00123         return temp;
00124 }

Here is the call graph for this function:

void CMTStation::SetFrequencies ( const trealdata &  freqs  ) 

Set the frequencies of the tensor elements, invalidates the previously stored impedance data, mainly for creating synthetic data.

Definition at line 126 of file CMTStation.cpp.

References at(), CMTTensor::frequency, and MTData.

Referenced by main(), PTensor1DMTObjective::SafeParallel(), and C1DMTObjective::SafeParallel().

00127 {
00128         //assert(MTData.size() == freqs.size());
00129         const unsigned int nfreqs = freqs.size();
00130         if (MTData.size() != nfreqs) //this invalidates the data stored there before
00131         {
00132                 MTData.resize(nfreqs);
00133                 TFData.resize(nfreqs);
00134         }
00135         for (unsigned int i = 0; i < nfreqs; ++i)
00136                 MTData.at(i).frequency = freqs.at(i);
00137         assert(MTData.size() == TFData.size());
00138         
00139         
00140 }

Here is the call graph for this function:

double CMTStation::GetLatitude (  )  const [inline]

access funtion for Latitude

Definition at line 68 of file CMTStation.h.

Referenced by PrintComponent().

00068 {return latitude;}

void CMTStation::SetLatitude ( double  lat  )  [inline]

Definition at line 69 of file CMTStation.h.

Referenced by CMTStationList::GetData().

00069 {latitude = lat;}

double CMTStation::GetLongitude (  )  const [inline]

Definition at line 70 of file CMTStation.h.

Referenced by PrintComponent().

00070 {return longitude;}

void CMTStation::SetLongitude ( double  lon  )  [inline]

Definition at line 71 of file CMTStation.h.

Referenced by CMTStationList::GetData().

00071 {longitude = lon;}

double CMTStation::GetElevation (  )  const [inline]

Definition at line 72 of file CMTStation.h.

00072 {return elevation;}

std::string CMTStation::GetName (  )  [inline]

Definition at line 73 of file CMTStation.h.

Referenced by main(), HasSameName::operator()(), and PrintComponent().

00073 {return name;}

double CMTStation::GetAzimuth (  )  const [inline]

Definition at line 74 of file CMTStation.h.

00074 {return azimuth;};

const CMTTensor& CMTStation::at ( const unsigned int  i  )  const [inline]

direct acces to a tensor at a given index

Definition at line 76 of file CMTStation.h.

Referenced by C1DMTSynthData::GetData(), main(), PTensorMTStation::operator=(), Rotate(), PTensor1DMTObjective::SafeParallel(), SetFrequencies(), and WriteAsJ().

00076 {return MTData.at(i);}

const std::vector<CMTTensor>& CMTStation::GetMTData (  )  const [inline]

Get the full vector of Tensor elements read only.

Definition at line 78 of file CMTStation.h.

Referenced by main(), PTensorMTStation::operator=(), PrintComponent(), C1DMTObjective::SafeParallel(), and WriteParameterToFile().

00078 {return MTData;}

std::vector<CMTTensor>& CMTStation::SetMTData (  )  [inline]

Get the full vector of Tensor elements for reading and writing.

Definition at line 80 of file CMTStation.h.

Referenced by main().

00080 {return MTData;}

virtual CMTStation* CMTStation::clone (  )  const [inline, virtual]

for parallel runs we need to make a copy of the object and its derived classes

Reimplemented in C1DAnisoMTSynthData, and C1DMTSynthData.

Definition at line 82 of file CMTStation.h.

References CMTStation().

00082 {return new CMTStation(*this);}

Here is the call graph for this function:

void CMTStation::GetData ( const std::string  filename  )  [virtual]

read in data from file, determines format by ending

Implements CGeneralData.

Definition at line 419 of file CMTStation.cpp.

References edi, j, MTData, mtt, pek, Rotate(), and unknown.

Referenced by CMTStationList::GetData(), init(), and main().

00420 {
00421         if (!boost::filesystem::exists(filename))
00422                 throw CFatalException("File does not exist : "+filename);
00423         string ending;
00424         unsigned int dotpos = filename.find('.',0);
00425         if (dotpos != string::npos)
00426                 ending = filename.substr(dotpos);
00427         else
00428         {
00429                 cerr << "File has no extension ! " << filename << endl;
00430                 dataformat = unknown;
00431                 throw CFatalException("File has no extension ! " + filename);
00432         }
00433         if ( ending == ".mtt")
00434                                         {
00435                                                 ReadMtt(filename);
00436                                                 dataformat = mtt;
00437                                         }
00438                                         else
00439                                                 if      (ending == ".dat" || ending == ".j")
00440                                                 {
00441                                                         ReadJ(filename);
00442                                                         dataformat = j;
00443                                                 }
00444                                                 else
00445                                                         if      (filename.substr(filename.size()-4) == ".edi")
00446                                                         {
00447                                                                 ReadEdi(filename);
00448                                                                 dataformat = edi;
00449                                                         }
00450                                                         else
00451                                                                 if (ending == ".pek")
00452                                                                 {
00453                                                                         ReadPek1D(filename);
00454                                                                         dataformat = pek;
00455                                                                 }
00456                                                                 else
00457                                                                 {
00458                                                                         dataformat = unknown;
00459                                                                         throw CFatalException("File not recognised: "+filename); 
00460                                                                 }
00461         assert(MTData.size() == TFData.size());
00462         Rotate(); //rotate data to 0 degree 
00463                 
00464 }

Here is the call graph for this function:

virtual void CMTStation::GetData (  )  [inline, virtual]

Declaration for GetData() without any parameter. This function is intended for use with objects that read in data that is generated within the program.

Implements CGeneralData.

Reimplemented in C1DAnisoMTSynthData, and C1DMTSynthData.

Definition at line 90 of file CMTStation.h.

Referenced by CMTStation().

00090 {};

void CMTStation::WriteData ( const std::string  filename  )  [virtual]

The abstract declaration for a method that writes the data to a file. Therefore no version without a filename is present

Implements CGeneralData.

Definition at line 466 of file CMTStation.cpp.

References EDIParser::name, and WriteBack().

Referenced by main().

00467 {
00468         name = filename;
00469         WriteBack();
00470 }

Here is the call graph for this function:

void CMTStation::WriteAsMtt ( const std::string  filename  ) 

Write data in goettingen .mtt format.

Definition at line 491 of file CMTStation.cpp.

References Update().

Referenced by main(), WriteBack(), PTensor1DMTObjective::WriteData(), Iso1DMTObjective::WriteData(), and Aniso1DMTObjective::WriteData().

00492 {
00493         Update();
00494     WriteMtt((filename+".mtt").c_str());
00495 }

Here is the call graph for this function:

void CMTStation::WriteAsEdi ( const std::string  filename  ) 

Write data as edi (no functionality yet).

Definition at line 497 of file CMTStation.cpp.

Referenced by WriteBack().

00498 {
00499         throw CFatalException("WriteAsEdi not implemented yet !");
00500 }

void CMTStation::WriteAsJ ( const std::string  filename  ) 

Write data to j-file.

Definition at line 520 of file CMTStation.cpp.

References at(), EDIParser::azimuth, EDIParser::elevation, CMTTensor::frequency, CMTTensor::GetdZxx(), CMTTensor::GetdZxy(), CMTTensor::GetdZyx(), CMTTensor::GetdZyy(), CMTTensor::GetZxx(), CMTTensor::GetZxy(), CMTTensor::GetZyx(), CMTTensor::GetZyy(), EDIParser::latitude, EDIParser::longitude, MTData, and EDIParser::name.

Referenced by main(), and WriteBack().

00521 {
00522         ofstream outfile;
00523         outfile.open((filename+".j").c_str());
00524         int actfreqs = 0;
00525         const double convfactor = 4. * acos(-1.)*1e-4;
00526         
00527         outfile << "# J-File Produced by CJData.cpp" << endl;
00528         outfile << ">LATITUDE  = " << latitude  << endl; 
00529         outfile << ">LONGITUDE = " << longitude << endl; 
00530         outfile << ">ELEVATION = " << elevation << endl;
00531         outfile << ">AZIMUTH   = " << azimuth << endl;
00532         outfile << name << endl;
00533         for (unsigned int i = 0; i < MTData.size(); ++i)
00534                 if (MTData.at(i).frequency != 0)
00535                         actfreqs++;
00536         outfile << "ZXX S.I." << endl;
00537         outfile << actfreqs << endl;
00538         //WriteJBlock(DataXX,outfile,convfactor);
00539         WriteJBlock(&CMTTensor::GetZxx,&CMTTensor::GetdZxx,outfile,convfactor);
00540         outfile << "ZXY S.I." << endl;
00541         outfile << actfreqs << endl;
00542         WriteJBlock(&CMTTensor::GetZxy,&CMTTensor::GetdZxy,outfile,convfactor);
00543         
00544         outfile << "ZYX S.I." << endl;
00545         outfile << actfreqs << endl;
00546         WriteJBlock(&CMTTensor::GetZyx,&CMTTensor::GetdZyx,outfile,convfactor);
00547         
00548         outfile << "ZYY S.I." << endl;
00549         outfile << actfreqs << endl;
00550         WriteJBlock(&CMTTensor::GetZyy,&CMTTensor::GetdZyy,outfile,convfactor);
00551         
00552 /*      if (norm(DataZY.Z.at(0)) !=0)
00553         {
00554                 outfile << "TZX " << endl;
00555                 outfile << actfreqs << endl;
00556                 WriteJBlock(DataZX,outfile,1.);
00557         }
00558         
00559         if (norm(DataZY.Z.at(0)) !=0)
00560         {
00561                 outfile << "TZY " << endl;
00562                 outfile << actfreqs << endl;
00563                 WriteJBlock(DataZY,outfile,1.);
00564         }*/
00565         outfile.close();
00566 }

Here is the call graph for this function:

void CMTStation::WriteBack (  ) 

Write data back in original format, with filename given by station name.

Definition at line 472 of file CMTStation.cpp.

References edi, j, mtt, EDIParser::name, WriteAsEdi(), WriteAsJ(), and WriteAsMtt().

Referenced by WriteData().

00473 {
00474         switch (dataformat)
00475         {
00476                 case mtt:
00477                         WriteAsMtt(name.c_str());
00478                         break;
00479                 case j:
00480                         WriteAsJ(name.c_str());
00481                         break;
00482                 case edi:
00483                         WriteAsEdi(name.c_str());
00484                         break;
00485                 default:
00486                         throw CFatalException("Unknown File Format for Writing ! This should not happen");
00487         }
00488         
00489 }

Here is the call graph for this function:

CMTStation & CMTStation::operator= ( const CMTStation source  ) 

Definition at line 626 of file CMTStation.cpp.

References azimuth, EDIParser::azimuth, dataformat, elevation, EDIParser::elevation, latitude, EDIParser::latitude, longitude, EDIParser::longitude, MTData, name, EDIParser::name, TFData, and Update().

00627 {
00628         if (this == &source) return *this;
00629         
00630         copy(source.MTData.begin(),source.MTData.end(),back_inserter(this->MTData));
00631         copy(source.TFData.begin(),source.TFData.end(),back_inserter(this->TFData));
00632 
00633         
00634         this->latitude = source.latitude;
00635         this->longitude = source.longitude;
00636         this->elevation = source.elevation;
00637         this->azimuth = source.azimuth;
00638         this->name = source.name;
00639         this->dataformat = source.dataformat;
00640         this->Update();
00641         return *this;
00642 }

Here is the call graph for this function:


Friends And Related Function Documentation

friend class C1DMTSynthData [friend]

Definition at line 93 of file CMTStation.h.


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