#include <CMTStation.h>
Inheritance diagram for CMTStation:


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 CMTTensor & | at (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 CMTStation * | clone () 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. | |
| CMTStation & | operator= (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 |
Definition at line 13 of file CMTStation.h.
| CMTStation::CMTStation | ( | ) |
| 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().
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] |
| 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().
| 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().
| void CMTStation::SetLatitude | ( | double | lat | ) | [inline] |
| double CMTStation::GetLongitude | ( | ) | const [inline] |
| void CMTStation::SetLongitude | ( | double | lon | ) | [inline] |
| double CMTStation::GetElevation | ( | ) | const [inline] |
| std::string CMTStation::GetName | ( | ) | [inline] |
Definition at line 73 of file CMTStation.h.
Referenced by main(), HasSameName::operator()(), and PrintComponent().
| double CMTStation::GetAzimuth | ( | ) | const [inline] |
| 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().
| 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().
| 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().
| 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().
| 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:

friend class C1DMTSynthData [friend] |
Definition at line 93 of file CMTStation.h.
1.5.1