11 using namespace gplib;
13 string version =
"$Id: mtupspec.cpp 1857 2010-11-03 14:55:32Z mmoorkamp $";
25 const int seglength,
const string name)
27 vector<complex<double> > Spectrum(seglength / 2 + 1);
30 ofstream outfile(name.c_str());
31 for (
unsigned int i = 1; i < Spectrum.size(); ++i)
32 outfile << i * samplerate / seglength <<
" " << abs(Spectrum.at(i))
36 int main(
int argc,
char *argv[])
41 size_t seglength = 2400;
43 <<
"This is mtupspec: Calculate power spectra from Phoenix time series"
46 <<
" Usage mtupspec filename if no filename given, the program will ask for one"
48 cout <<
" Output will be 4 ascii file with ending _specex, _specey etc."
50 cout <<
" This is Version: " <<
version << endl << endl;
59 infilename = AskFilename(
"Infilename: ");
63 cout <<
"Length for each segment: ";
68 std::cerr <<
"Segment must be longer than 2 !";
74 std::cerr <<
"Segment must shorter than the time series !";
82 seglength, (infilename +
"_specex"));
84 seglength, (infilename +
"_specey"));
86 seglength, (infilename +
"_spechx"));
88 seglength, (infilename +
"_spechy"));
90 seglength, (infilename +
"_spechz"));
std::vector< double > & GetData()
Access for data vector, for ease of use and efficiency we return a reference.
TimeSeries & GetData()
return a reference to the actual object stored in the pointer
TimeSeriesComponent & GetEx()
double GetSamplerate()
The samplerate is stored in each component, we just return the samplerate of Hx assuming they are all...
TimeSeriesComponent & GetHy()
TimeSeriesData stores a pointer to the different components of magnetotelluric data and provides func...
void CalcPSpecAndWrite(ttsdata Data, const double samplerate, const int seglength, const string name)
Calculate the power spectrum and write it to an ascii file.
This functor returns the weighting factor for the Hanning window, given the relative position (0...
TimeSeriesComponent & GetEy()
TimeSeriesComponent & GetHz()
TimeSeriesComponent & GetHx()
Access function for Hx, returns reference for efficiency.