DATRW++ library: seismic data I/O with multiple formats
ithiesdl1stream.cc
Go to the documentation of this file.
1 /*! \file ithiesdl1stream.cc
2  * \brief ThiesDL1 input stream (implementation)
3  *
4  * ----------------------------------------------------------------------------
5  *
6  * \author Thomas Forbriger
7  * \date 13/09/2011
8  *
9  * ThiesDL1 input stream (implementation)
10  *
11  * Copyright (c) 2011 by Thomas Forbriger (BFO Schiltach)
12  *
13  * ----
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 2 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program; if not, write to the Free Software
26  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27  * ----
28  *
29  * REVISIONS and CHANGES
30  * - 13/09/2011 V1.0 Thomas Forbriger
31  * - 18/11/2016 V1.1 use debug flag in base class
32  *
33  * ============================================================================
34  */
35 #define DATRW_ITHIESDL1STREAM_CC_VERSION \
36  "DATRW_ITHIESDL1STREAM_CC V1.1"
37 
38 #include <datrwxx/thiesdl1.h>
39 #include <datrwxx/formatmodifier.h>
40 
41 namespace datrw {
42 
43  const std::ios_base::openmode
44  ithiesdl1stream::openmode=std::ios_base::in;
45 
46  /*----------------------------------------------------------------------*/
47 
49  const std::string& modifier,
50  const bool& debug):
51  Tbase(is, true, true, true, debug), Mmodifier(modifier)
52  {
54  this->setfilefree(this->Mheader.lines);
55  datrw::Subformat subformat(Mmodifier);
56  this->Mfile.tolerateredundant(subformat.isset("tr"));
57  this->Mfile.toleratewrongtime(subformat.isset("twt"));
58  subformat.notchecked(std::cerr);
59  } // ithiesdl1stream::ithiesdl1stream
60 
61  /*----------------------------------------------------------------------*/
62 
64  {
65  this->newtrace();
66  this->setwid2(this->Mheader.wid2line());
67  } // void ithiesdl1stream::settraceheader()
68 
69  /*----------------------------------------------------------------------*/
70 
72  {
73  this->Mfile.read(Mis, this->Mheader);
74  this->settracefree(this->Mfile.tracefree());
75  }
76 
77  /*----------------------------------------------------------------------*/
78 
80  {
81  this->settraceheader();
82  this->readsamples();
83  this->setlast();
84  return(this->Mfile.dseries());
85  } // Tdseries ithiesdl1stream::dseries()
86 
87  /*----------------------------------------------------------------------*/
88 
90  {
91  this->settraceheader();
92  this->readsamples();
93  this->setlast();
94  return(this->Mfile.fseries());
95  } // Tfseries ithiesdl1stream::fseries()
96 
97  /*----------------------------------------------------------------------*/
98 
100  {
101  this->settraceheader();
102  this->readsamples();
103  this->setlast();
104  return(this->Mfile.iseries());
105  } // Tfseries ithiesdl1stream::iseries()
106 
107  /*----------------------------------------------------------------------*/
108 
110  {
111  this->settraceheader();
112  this->setlast();
113  } // void ithiesdl1stream::skipseries()
114 
115  /*----------------------------------------------------------------------*/
116 
117  void ithiesdl1stream::help(std::ostream& os)
118  {
119  os <<
120  std::endl <<
121  "Thies DL1 reading functions" << std::endl <<
122  "---------------------------" << std::endl <<
123  DATRW_ITHIESDL1STREAM_CC_VERSION << std::endl <<
124  std::endl;
125  os <<
126  "This file format is used to store data of the Thies DL1/N pluviometer\n"
127  "at BFO. The files are produced by program DL1logger, which accomplishes\n"
128  "data acquisition by controlling the Thies DL1/N data logger and reading\n"
129  "the data from the logger.\n"
130  "See also:\n"
131  "http://www.rz.uni-karlsruhe.de/~bi77/public/paperware/linked/technotes/DL1recording.pdf\n"
132  << std::endl;
133  os <<
134  "The Thies DL1 input stream can be controlled by format modifiers:\n"
135  "tr input stream tolerates redundant samples\n"
136  "twt input stream tolerates samples not fitting in expected time window\n"
137  << std::endl;
138  } // void ithiesdl1stream::help(std::ostream& os)
139 
140 } // namespace datrw
141 
142 /* ----- END OF ithiesdl1stream.cc ----- */
FileHeader readheader(std::istream &is)
Read and parse a file header.
provide format modifiers (prototypes)
aff::Series< float > Tfseries
Definition: types.h:46
Tdseries dseries() const
return data block of values
void setfilefree(const sff::FREE &free)
Definition: datread.cc:97
thiesdl1::FileHeader Mheader
Definition: thiesdl1.h:81
::sff::FREE tracefree() const
return FREE lines produced while reading the data
Definition: thiesdl1file.h:148
void toleratewrongtime(const bool flag=true)
set tolerance for wrong time
Definition: thiesdl1file.h:170
void tolerateredundant(const bool flag=true)
set tolerance for redundant samples
Definition: thiesdl1file.h:167
thiesdl1::File Mfile
Definition: thiesdl1.h:82
std::string Mmodifier
Definition: thiesdl1.h:80
aff::Series< double > Tdseries
Definition: types.h:45
virtual Tfseries fseries()
std::istream & Mis
Definition: datread.h:126
::sff::FREE lines
A collection of header lines with hash sign stripped off.
Definition: thiesdl1file.h:92
void setwid2(const sff::WID2 &wid2)
Definition: datread.cc:113
Tiseries iseries() const
return data block of counts
static void help(std::ostream &os=std::cout)
virtual Tiseries iseries()
Root namespace of library.
Definition: aalibdatrwxx.cc:16
void read(std::istream &is, const FileHeader &header)
actually read file
module to read ThiesDL1 data files (prototypes)
void settracefree(const sff::FREE &free)
Definition: datread.cc:105
aff::Series< int > Tiseries
Definition: types.h:47
Tfseries fseries() const
return data block of values
Class to handle format modifiersThis class is used to parse a format modifier string. Detailed instructions will be given upon request. For some hints have a look at tests/libdatrwxxtests.c.
virtual Tdseries dseries()
bool isset(const std::string &k) const
check if user provided this key
void notchecked(std::ostream &os) const
output all modifier which have not been checked yet
static const std::ios_base::openmode openmode
Definition: thiesdl1.h:76
::sff::WID2 wid2line() const
return WID2 header
#define DATRW_ITHIESDL1STREAM_CC_VERSION
ithiesdl1stream(std::istream &is, const std::string &modifier="", const bool &debug=false)