MTStation.h

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

Generated on Fri Jul 4 15:30:20 2008 for GPLIB++ by  doxygen 1.5.5