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

Generated on Tue May 4 16:52:14 2010 for GPLIB++ by  doxygen 1.5.8