CMTStation.h

Go to the documentation of this file.
00001 #ifndef CMTSTATION_H
00002 #define CMTSTATION_H
00003 
00004 #include "CGeneralData.h"
00005 #include "CMTTensor.h"
00006 #include "CMagneticTF.h"
00007 #include "types.h"
00008 #include <string>
00009 #include <boost/function.hpp>
00010 
00011 
00012 //! The class CMTStation is used to store the transfer functions and related information for a MT-site
00013 class CMTStation: public CGeneralData{
00014 public:
00015         enum tmtdataformat {unknown, mtt, j, edi, pek};
00016 private:
00017         //! Station Latitude
00018         double latitude;
00019         //! Station Lonigude
00020         double longitude;
00021         //! Station elevation
00022         double elevation;
00023         //! Name, does not have to be filename for j and edi data
00024         std::string name;
00025         //! Azimuth from magnetic north if station was rotated
00026         double azimuth;
00027         // The MTTensor data for each frequency
00028         std::vector<CMTTensor> MTData;
00029         // The Local induction vectors for each frequency
00030         std::vector<CMagneticTF> TFData;
00031         void DoRotate(const int i, const double angle);
00032         //! Perform some initial Setup
00033         void InitialSetup();
00034         //! the format the data was stored in the original file
00035         tmtdataformat dataformat;
00036         //! Write data to file in goettingen .mtt format
00037         void WriteMtt(const std::string filename);
00038         //! Read data from edi file (not all features supported)
00039         void ReadEdi(const std::string filename);
00040         //! Read data from j file
00041         void ReadJ(const std::string filename);
00042         //! Read data from goettingen .mtt file
00043         void ReadMtt(const std::string filename);
00044         //! Read output of Pek's 1D anisotropy code
00045         void ReadPek1D(const std::string filename);
00046         // helper function for WriteAsJ
00047         void WriteJBlock(boost::function<std::complex<double> (const CMTTensor*)> Comp, 
00048         boost::function<double (const CMTTensor*)> Err, std::ofstream &outfile, const double convfactor);
00049 protected:
00050         //! Update all derived quantities
00051          void Update(); 
00052     //! Assign() assigns zero to all derived quantities, this makes the calculation
00053     // more easy
00054     void Assign(const int nfreq);
00055  public:   
00056     // Assign zero to everything, convenient for synthetic data that is not read in from file
00057     void AssignAll(const int nfreq);
00058     //! Given a rotation angle in radian this method rotates the impedance tensor
00059     //! and updates all derived quantities
00060     void Rotate(const double rotangle);
00061     //! Rotate to zero rotation angle
00062     void Rotate(void);
00063     //! return the available frequencies in a single vector
00064     trealdata GetFrequencies() const;
00065     //! Set the frequencies of the tensor elements, invalidates the previously stored impedance data, mainly for creating synthetic data  
00066     void SetFrequencies(const trealdata &freqs);
00067     //! access funtion for Latitude
00068     double GetLatitude()const{return latitude;}
00069     void SetLatitude(double lat){latitude = lat;}
00070         double GetLongitude()const{return longitude;}
00071         void SetLongitude(double lon){longitude = lon;}
00072         double GetElevation()const{return elevation;}
00073         std::string GetName(){return name;}
00074         double GetAzimuth()const{return azimuth;};
00075         //! direct acces to a tensor at a given index
00076         const CMTTensor &at(const unsigned int i) const{return MTData.at(i);}
00077         //! Get the full vector of Tensor elements read only
00078         const std::vector<CMTTensor> &GetMTData() const{return MTData;}
00079         //! Get the full vector of Tensor elements for reading and writing
00080         std::vector<CMTTensor> &SetMTData() {return MTData;}
00081         //! for parallel runs we need to make a copy of the object and its derived classes
00082         virtual CMTStation *clone() const{return new CMTStation(*this);}
00083         CMTStation();
00084         CMTStation(const CMTStation &old);
00085         CMTStation(const int size);
00086         CMTStation(const std::string filename);
00087         virtual ~CMTStation();
00088         //! read in data from file, determines format by ending
00089         virtual void GetData(const std::string filename);
00090         virtual void GetData(){};
00091     //Write data to file, same as WriteBack
00092     virtual void WriteData(const std::string filename);
00093     friend class C1DMTSynthData;
00094     //! Write data in goettingen .mtt format
00095         void WriteAsMtt(const std::string filename);
00096         //! Write data as edi (no functionality yet)
00097         void WriteAsEdi(const std::string filename);
00098         //! Write data to j-file
00099         void WriteAsJ(const std::string filename);
00100         //! Write data back in original format, with filename given by station name
00101         void WriteBack();
00102         CMTStation& operator= (const CMTStation& source);
00103 };
00104 
00105 #endif // CMTSTATION_H

Generated on Thu Nov 22 13:58:25 2007 for GPLIB++ by  doxygen 1.5.1