37 #define DATRW_READTFASCII_CC_VERSION \ 38 "DATRW_READTFASCII_CC V1.0 " 43 #include<datrwxx/readtfascii.h> 57 std::string tmp = line.substr(0,line.rfind(
" "));
58 line = tmp.substr(tmp.rfind(
" ")+1);
62 line = line.substr(line.rfind(
" ")+1);
69 line = line.substr(line.find(
":")+1);
86 while (hot && is.good())
90 if (line ==
"contents of SFF SRCE line:")
95 std::cout <<
"SFF SRCE line detected." << std::endl;
99 fileheader.
srce.type = line;
102 if (line ==
"cartesian")
104 fileheader.
srce.cs = sff::CS_cartesian;
108 fileheader.
srce.cs = sff::CS_spherical;
112 fileheader.
srce.cx = std::atof(line.c_str());
115 fileheader.
srce.cy = std::atof(line.c_str());
118 fileheader.
srce.cz = std::atof(line.c_str());
121 std::istringstream iss(line);
123 int doy, day, month, year, hour, minute, secs, micsecs;
125 iss >> day >> c >> month >> c >> year;
126 iss >> hour >> c >> minute >> c >> secs >> c >> micsecs;
127 fileheader.
srce.date = libtime::TAbsoluteTime(year,
136 "ERROR: inconsistent date values");
139 if (line ==
"contents of SFF FREE block:")
144 std::cout <<
"file FREE block detected." << std::endl;
146 while (getline(is, line))
157 if (line ==
"file header contains no FREE block")
177 if (line ==
"contents of SFF WID2 line:")
182 std::cout <<
"SFF WID2 line detected." << std::endl;
186 std::istringstream iss(line);
188 int doy, day, month, year, hour, minute, secs, micsecs;
190 iss >> day >> c >> month >> c >> year;
191 iss >> hour >> c >> minute >> c >> secs >> c >> micsecs;
192 traceheader.
wid2.date = libtime::TAbsoluteTime(year,
201 "ERROR: inconsistent date values");
204 traceheader.
wid2.station = line;
207 traceheader.
wid2.channel = line;
210 traceheader.
wid2.auxid = line;
213 traceheader.
wid2.instype = line;
216 traceheader.
wid2.nsamples = std::atoi(line.c_str());
219 traceheader.
wid2.dt = std::atof(line.c_str());
222 traceheader.
wid2.calib = std::atof(line.c_str());
225 traceheader.
wid2.calper = std::atof(line.c_str());
228 traceheader.
wid2.hang = std::atof(line.c_str());
231 traceheader.
wid2.vang = std::atof(line.c_str());
234 if (line ==
"contents of SFF INFO line:")
239 std::cout <<
"SFF INFO line detected." << std::endl;
243 if (line ==
"cartesian")
245 traceheader.
info.cs = sff::CS_cartesian;
249 traceheader.
info.cs = sff::CS_spherical;
253 traceheader.
info.cx = std::atof(line.c_str());
256 traceheader.
info.cy = std::atof(line.c_str());
259 traceheader.
info.cz = std::atof(line.c_str());
262 traceheader.
info.nstacks = std::atoi(line.c_str());
265 if (line ==
"contents of SFF FREE block:")
270 std::cout <<
"trace FREE block detected." << std::endl;
272 while (getline(is, line))
275 if (line.empty()) {
break; }
280 if (line ==
"data:") {
break; }
291 os <<
"TFASCII data reading functions" << endl;
292 os <<
"------------------------------" << endl;
294 os <<
"This data reading module implements reading functions" << endl
295 <<
"for the output data of Thomas Forbriger's any2ascii.cc" << endl
296 <<
"program. As the name of this program already says its" << endl
297 <<
"output data are human readable ASCII files."<< endl
298 <<
"If you wish to read an output file of any2ascii.cc just" << endl
299 <<
"remember that files can be read that were generated " << endl
300 <<
"without the [-tcol] option, because the reading module can" << endl
301 <<
"not handle with an additional time column in the input" << endl
304 <<
"IMPORTANT NOTE: The tfascii reading module just relies as" << endl
305 <<
"in many cases on the input following the tfascii" << endl
306 <<
"format. The code does not contain any plausibility" << endl
307 <<
"checks." << endl;
#define DATRW_assert(C, M)
Check an assertion and report by throwing an exception.
FileHeader readfileheader(std::istream &is, const bool &verbose)
read the complete fileheader
const char *const streamname
name of the stream
void extract(std::string &line)
splits a given string after the colon
TraceHeader readtraceheader(std::istream &is, const bool &verbose)
read the complete traceheader
exception class declaration for libdatrwxx (prototypes)
Root namespace of library.
void help(std::ostream &os)
function to print online help
void extractvalue(std::string &line, bool unit)
split given string