GPLIB++
sac2asc.cpp
Go to the documentation of this file.
1 #include "SeismicDataComp.h"
2 #include "FatalException.h"
3 #include <iostream>
4 #include <string>
5 #include "Util.h"
6 
7 using namespace std;
8 using namespace gplib;
9 
10 string version = "$Id: sac2asc.cpp 1816 2009-09-07 11:28:35Z mmoorkamp $";
11 
12 int main(int argc, char *argv[])
13  {
14  cout << " This is sac2asc: Convert sac to plain ascii format" << endl; // write some info
15  cout << " Reads in a file in SAC format and writes it as an ascii file"
16  << endl;
17  cout
18  << " Most header values are ignored, only npts, dt and b are written to the output file"
19  << endl;
20  cout << " This is Version: " << version << endl << endl;
21 
22  SeismicDataComp Input;
23  string outfilename, infilename;
24  try
25  {
26  if (argc > 1)
27  infilename = argv[1];
28  else
29  {
30  infilename = AskFilename("Input file: ");
31  }
32  outfilename = infilename + ".asc";
33 
34  Input.ReadData(infilename);
35  Input.WriteAsAscii(outfilename);
36  } catch (FatalException &e)
37  {
38  cerr << e.what() << endl; // if something fails print error
39  return -1; // and stop execution
40  }
41 
42  }
int ReadData(const std::string &filename, tseismicdataformat format=sac)
Read in data from a file, as we cannot determine the type from the ending we have to provide it...
int main(int argc, char *argv[])
Definition: sac2asc.cpp:12
string version
Definition: sac2asc.cpp:10
int WriteAsAscii(const std::string &filename) const
Write the data in plain ascii format.
The basic exception class for all errors that arise in gplib.