42 #define DATRW_IASCIISTREAM_CC_VERSION \ 43 "DATRW_IASCIISTREAM_CC V1.3" 47 #include<aff/subarray.h> 50 #include<datrwxx/asciiheaderkeys.h> 56 const std::ios_base::openmode
62 const std::string& modifier,
64 Tbase(is, true, true, true, debug), Mmodifier(modifier)
95 libtime::TAbsoluteTime
174 this->
Mcurrentinfo.cs=::sff::coosysID(value.c_str()[0]);
189 this->
Mcurrentsrce.cs=::sff::coosysID(value.c_str()[0]);
197 std::istringstream iss(value);
262 "keyword is missing in header line\n" <<
270 std::cerr <<
"Illegal keyword: " << key << std::endl;
275 "iasciistream: header key not recognized\n" 319 const unsigned int& n,
320 const std::string& firstline,
321 typename aff::Series<T>& series,
324 typedef typename aff::Series<T> Tmyseries;
325 std::string line=firstline;
330 typedef typename std::vector<Tmyseries> Tvecofrecorddata;
331 Tvecofrecorddata vecofrecorddata;
334 const unsigned int bufsize=5000;
335 Tmyseries buffer(0,bufsize-1);
338 while ((!(line.substr(0,1)==
"#")) && is.good())
342 vecofrecorddata.push_back(buffer.copyout());
346 std::istringstream iss(line);
348 std::getline(is, line);
354 vecofrecorddata.push_back(aff::subarray(buffer)(0,i-1));
357 typename Tvecofrecorddata::const_iterator I(vecofrecorddata.begin());
360 while (I != vecofrecorddata.end())
375 while ((!(line.substr(0,1)==
"#")) && is.good() && (i<n))
377 std::istringstream iss(line);
378 iss >> series(series.f()+i);
379 std::getline(is, line);
384 "readsamples (ASCII): " 385 "found less samples than expected\n" 386 "expected: " << n <<
" " <<
413 const unsigned int& n,
414 const std::string& firstline,
415 typename aff::Series<T>& series,
416 const std::string& datatype,
441 std::cerr <<
"unrecognized data type: " << datatype << std::endl;
544 const char*
const key,
545 const char*
const message)
548 std::string keyval=key;
550 os << std::left << std::setfill(
'.')
551 << keyval <<
" " << message << std::endl;
562 const char*
const key,
563 const char*
const message)
566 std::string keyval=key;
568 os << std::left << std::setfill(
'.')
569 << keyval <<
" " << message << std::endl;
582 "ASCII reading functions" << std::endl <<
583 "-----------------------" << std::endl <<
587 "This module reads seismic time series data in the raw\n" 588 "single column ASCII format. No header values are required\n" 589 "but all SFF header data can be provided. Header data not\n" 590 "present in the file can be set through format modifiers.\n" 591 "Header data neither given in the file nor in the format are\n" 592 "set to default values. The number of samples is determined from\n" 593 "actual numer of samples present in the file. If a number of samples\n" 594 "is defined in the header it is used as a maximum number of samples\n" 595 "to be read until the next trace begins.\n" 596 "Each line with a hash (#) in the first column is treated\n" 597 "as a header line. Each line with a double hash (##) in the\n" 598 "first two columns is treated as a free format comment. All\n" 599 "other lines are treated as ASCII data.\n" 602 "Parameter values for header fields can be set in lines which\n" 603 "have a single hash (#) in the first column. The hash is expected\n" 604 "to be followed by a key ID, which can be either one of the\n" 605 "modifier keys listed below or can be \"" <<
ascii::keydata <<
"\".\n" 606 "The key has to be separated from the value by a single colon (:).\n" 607 "If you feel unsure, simply write a data file using the ASCII\n" 608 "output functions and have a look at the result.\n" 611 "The data type can be selected by the key \"" 613 os <<
" "; os.width(7);
616 os <<
" "; os.width(7);
619 os <<
" "; os.width(7);
622 "If no type is specified, the default will be " 626 "The ascii input stream can be controlled by format modifiers:\n";
628 "(WID2) set number of samples");
630 "(WID2) set sampling interval (seconds)");
632 "(WID2) set time of first sample; YYYY/MM/DD/hh/mm/ss.ssssss");
634 "(WID2) set channel ID");
636 "(WID2) set station ID");
638 "(WID2) set auxiliary ID");
640 "(WID2) set instrument type ID");
642 "(WID2) set calib value");
644 "(WID2) set calper value");
646 "(WID2) set hang value");
648 "(WID2) set vang value");
650 "(SRCE) set date and time of source; YYYY/MM/DD/hh/mm/ss.ssssss");
652 "(SRCE) set type of source");
654 "(SRCE) set x coordinate of source");
656 "(SRCE) set y coordinate of source");
658 "(SRCE) set z coordinate of source");
660 "(SRCE) set coordinate system of source");
662 "(INFO) set number of stacks");
664 "(INFO) set x coordinate of receiver");
666 "(INFO) set y coordinate of receiver");
668 "(INFO) set z coordinate of receiver");
670 "(INFO) set coordinate system of receiver");
671 os <<
"Further modifiers:\n";
673 "make errors non-fatal is possible (only a warning will be issued)");
const char *const keyinstype
key for WID2 line header field
virtual Tiseries iseries()
const char *const keySRCEtype
key for SRCE line header field
const char *const keydouble
key for DATA type header field
const char *const keySRCEY
key for SRCE line header field
const char *const keynonfatal
format modifier key
Cout convert(const typename Cin::Tcoc &data)
function template to convert a whole series
void setinfo(const sff::INFO &info)
aff::Series< float > Tfseries
virtual Tdseries dseries()
const char *const keyRECVY
key for INFO line header field
std::string Mmodifier
format modifier
void explainmodifier(std::ostream &os, const char *const key, const char *const message)
const char *const keydt
key for WID2 line header field
static const std::ios_base::openmode openmode
handle data types and data type conversion (prototypes)
const char *const keyRECVCS
key for INFO line header field
const char *const keyhang
key for WID2 line header field
void setsrce(const sff::SRCE &srce)
aff::Series< double > Tdseries
iasciistream(std::istream &is, const std::string &modifier="", const bool &debug=false)
const char *const keyint
key for DATA type header field
const int nsamples
number of samples per minute block and channel
void setwid2(const sff::WID2 &wid2)
#define DATRW_IASCIISTREAM_CC_VERSION
const char *const keycalib
key for WID2 line header field
const char *const keyauxid
key for WID2 line header field
const char *const keychannel
key for WID2 line header field
std::string trimws(std::string s)
remove leading and trailing whitespace
Root namespace of library.
const char *const keydate
key for WID2 line header field
utilities used by more than one type of data reader (prototypes)
const char *const keynstacks
key for INFO line header field
void explainmodifierflag(std::ostream &os, const char *const key, const char *const message)
const char *const keySRCEdate
key for SRCE line header field
#define DATRW_abort(M)
Abort and give a message.
const char *const keyRECVX
key for INFO line header field
void settracefree(const sff::FREE &free)
static void help(std::ostream &os=std::cout)
aff::Series< int > Tiseries
std::string clipstring(std::string &s, const std::string &delim)
strip substringStrips off first substring up to given delimiter. The string is passed as a reference ...
const char *const keycalper
key for WID2 line header field
#define DATRW_nonfatal_assert(F, C, M)
Macro to distinguish between fatal and non fatal assertions.
virtual void skipseries()
const char *const keynsamples
key for WID2 line header field
const char *const keySRCEX
key for SRCE line header field
std::string readany(std::istream &is, const unsigned int &n, const std::string &firstline, typename aff::Series< T > &series, const std::string &datatype, const bool &nonfatal)
const char *const keyRECVZ
key for INFO line header field
const char *const keySRCECS
key for SRCE line header field
virtual Tfseries fseries()
const char *const keyfloat
key for DATA type header field
std::string readsamples(std::istream &is, const unsigned int &n, const std::string &firstline, typename aff::Series< T > &series, const bool &nonfatal)
const char *const keyvang
key for WID2 line header field
const char *const keystation
key for WID2 line header field
#define DATRW_report_assert(C, M)
Check an assertion and report only.
const char *const keydata
key for DATA type header field
const char *const keySRCEZ
key for SRCE line header field
interface to write ASCII data (prototypes)
const char *const nonfatal
keywords for format modifiers