14 TimeSeriesData::TimeSeriesData()
18 TimeSeriesData::~TimeSeriesData()
22 void TimeSeriesData::GetData(std::string filename)
26 ending = GetFileExtension(filename);
28 if (ending ==
".ts3" || ending ==
".TS3" || ending ==
".ts4" || ending
29 ==
".TS4" || ending ==
".ts5" || ending ==
".TS5")
31 Data = boost::shared_ptr<TimeSeries>(
new MtuFormat);
35 else if (ending ==
".asc")
41 else if (ending ==
".csv")
43 Data = boost::shared_ptr<TimeSeries>(
new CsvFormat);
47 else if (ending ==
".lem")
56 "Unknown data format or file does not exist : " + filename);
59 unsigned int dotpos = name.find(
'.', 0);
60 if (dotpos != string::npos)
62 Data->GetData(filename);
69 this->name = source.name;
70 this->datatype = source.datatype;
72 this->Data = source.Data;
77 void TimeSeriesData::WriteAsMtu(std::string filename_base)
81 switch (
int(Data->GetSamplerate()))
84 Data->WriteData(filename_base +
".ts3");
87 Data->WriteData(filename_base +
".ts4");
90 Data->WriteData(filename_base +
".ts5");
94 "Unknown samplerate ! Cannot write file. Value is: "
95 + stringify(Data->GetSamplerate()));
105 void TimeSeriesData::WriteAsBirrp(std::string filename_base)
108 if (datatype ==
birrp)
109 Data->WriteData(filename_base +
".asc");
114 BirrpData.
WriteData(filename_base +
".asc");
118 void TimeSeriesData::WriteAsLemi(std::string filename_base)
120 if (datatype ==
lemi)
121 Data->WriteData(filename_base +
".lem");
126 LemiData.
WriteData(filename_base +
".lem");
130 void TimeSeriesData::WriteAsCsv(std::string filename_base)
135 void TimeSeriesData::WriteBack(std::string filename_base)
140 WriteAsLemi(filename_base);
143 WriteAsBirrp(filename_base);
146 WriteAsMtu(filename_base);
149 WriteAsCsv(filename_base);
152 throw FatalException(
"Cannot write back data ! Unknown datatype !");
TimeSeriesData stores a pointer to the different components of magnetotelluric data and provides func...
The basic exception class for all errors that arise in gplib.