34 #define SACTEST_VERSION \ 35 "SACTEST V1.0 test SAC reading functions" 40 #include <tfxx/commandline.h> 41 #include <tfxx/error.h> 42 #include <datrwxx/sacread.h> 53 int main(
int iargc,
char* argv[])
60 "usage: sactest file [-h] [-d]" "\n" 61 " or: sactest --help|-h" "\n" 67 "file name of SAC file to read" "\n" 69 "-h read and dump header only" "\n" 70 "-d read samples (implies -h)" "\n" 75 using namespace tfxx::cmdline;
76 static Declare options[]=
92 cerr << usage_text << endl;
97 Commandline cmdline(iargc, argv, options);
100 if (cmdline.optset(0))
102 cerr << usage_text << endl;
103 cerr << help_text << endl;
112 TFXX_assert(cmdline.extra(),
"missing SAC file name");
113 std::string filename=cmdline.next();
117 cout <<
"file to process: " << filename << endl;
123 cout <<
"dump header" << endl;
124 cout <<
"-----------" << endl;
126 std::ifstream ifs(filename.c_str());
128 cout <<
" sampling interval: " << hd.delta <<
" s" << endl;
129 cout <<
" initial value: " << hd.b << endl;
130 cout <<
" final value: " << hd.e << endl;
131 cout <<
" station latitude: " << hd.stla <<
" °N" << endl;
132 cout <<
" station longitude: " << hd.stlo <<
" °E" << endl;
133 cout <<
" station elevation: " << hd.stel <<
" m" << endl;
134 cout <<
" station depth: " << hd.stdp <<
" m" << endl;
135 cout <<
" component azimuth: " << hd.cmpaz <<
" °" << endl;
136 cout <<
" component inclination: " << hd.cmpinc <<
" °" << endl;
137 cout <<
" zero time of file, year: " << hd.nzyear << endl;
138 cout <<
" zero time of file, doy: " << hd.nzjday << endl;
139 cout <<
" zero time of file, hour: " << hd.nzhour << endl;
140 cout <<
" zero time of file, minute: " << hd.nzmin << endl;
141 cout <<
" zero time of file, second: " << hd.nzsec << endl;
142 cout <<
" zero time of file, millisecond: " << hd.nzmsec << endl;
143 cout <<
" number of samples: " << hd.npts << endl;
144 cout <<
" station name: " << std::string(hd.kstnm,8) << endl;
145 cout <<
" component name: " << std::string(hd.kcmpnm,8) << endl;
146 cout <<
" network name: " << std::string(hd.knetwk,8) << endl;
147 cout <<
" man-made event name: " << std::string(hd.khole,8) << endl;
148 cout <<
" type of file: " << hd.iftype << endl;
149 cout <<
" even sampling flag: " << hd.leven << endl;
157 { cout <<
"input stream is good after reading samples" << endl; }
159 { cout <<
"input stream is NOT good after reading samples!" << endl; }
162 cout <<
"read " << series.size() <<
" samples" << endl;
163 int ifi=10 > series.last() ? series.last() : 10;
164 int il=series.last()-10;
165 il=series.first() > il ? series.first() : il;
166 for (
int i=series.f(); i<=ifi; ++i)
167 { cout << i <<
" " << series(i) << endl; }
168 cout <<
"." << endl <<
"." << endl <<
"." << endl;
169 for (
int i=il; i<=series.last(); ++i)
170 { cout << i <<
" " << series(i) << endl; }
SACheader read_sac_header(std::istream &is)
read SAC header from stream
int main(int iargc, char *argv[])
A copy of bytesex.h from libtfxx (prototypes)
aff::Series< Tvalue > Tseries
float Tvalue
binary SAC sample type