DATRW++ library: seismic data I/O with multiple formats
readhpmo.h
Go to the documentation of this file.
1 /*! \file readhpmo.h
2  * \brief read data from Walter Grossmann file format (prototypes)
3  *
4  * ----------------------------------------------------------------------------
5  *
6  * \author Thomas Forbriger
7  * \date 31/03/2004
8  *
9  * read data from Walter Grossmann file format (prototypes)
10  *
11  * ----
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25  * ----
26  *
27  * Copyright (c) 2004 by Thomas Forbriger (BFO Schiltach)
28  *
29  * REVISIONS and CHANGES
30  * - 31/03/2004 V1.0 Thomas Forbriger
31  *
32  * ============================================================================
33  */
34 
35 // include guard
36 #ifndef DATRW_READHPMO_H_VERSION
37 
38 #define DATRW_READHPMO_H_VERSION \
39  "DATRW_READHPMO_H V1.0 "
40 
41 #include<iostream>
42 #include<string>
43 #include<vector>
44 #include<libtime++.h>
45 #include<sffxx.h>
46 #include<datrwxx/datread.h>
47 #include<datrwxx/hpmodata.h>
48 
49 namespace datrw {
50 
51  /*! \brief All classes and functions to extract data from HPMO files
52  *
53  * \defgroup group_hpmo Reading module for: HPMO data
54  */
55 
56  /*! \brief All classes and functions to extract data from HPMO files
57  *
58  * \ingroup group_hpmo
59  */
60  namespace hpmo {
61 
62  /*! \brief within the inner reading functions, we use vector to hold
63  * minute blocks
64  *
65  * \ingroup group_hpmo
66  */
67  typedef std::vector<MinuteBlock> Tvecofblocks;
68 
69 /*----------------------------------------------------------------------*/
70 
71  /*! \brief this excpetion will be thrown by the Header reading function,
72  * in case it does not find something that look like a header (i.e. a line
73  * with more or less than 44 characters)
74  *
75  * \ingroup group_hpmo
76  */
78  public:
79  NoHeaderException(): Exception("no header found!") { }
80  }; // class NoHeaderException
81 
82 /*----------------------------------------------------------------------*/
83 
84  /*! \brief Read, hold and handle one minute block header line
85  *
86  * \ingroup group_hpmo
87  */
88  class Header {
89  public:
90  Header(): Merrorflag(16) { }
91  Header(std::istream& is, const bool& verbose=false)
92  { this->readheader(is, verbose); }
93  void readheader(std::istream& is, const bool& verbose=false);
94  libtime::TAbsoluteTime time() const { return(Mtime); }
95  int errorflag() const { return(Merrorflag); }
96  std::string errorstring() const;
97  std::string headerline() const { return (Mline); }
98  void dump(std::ostream& os) const;
99  private:
100  libtime::TAbsoluteTime Mtime;
102  std::string Mline;
103  }; // class Header
104 
105 /*----------------------------------------------------------------------*/
106 
107  /*! \brief read one minute block of samples
108  * \ingroup group_hpmo
109  */
110  SampleBlock readdata(std::istream& is, const bool& verbose=false);
111 
112  //! dump one block of samples
113  void dump(std::ostream& os, const SampleBlock& data);
114 
115 /*----------------------------------------------------------------------*/
116 
117  /*! \brief dump one MinueBlock
118  * \ingroup group_hpmo
119  */
120  void dump(std::ostream& os, const MinuteBlock& block);
121 
122 /*----------------------------------------------------------------------*/
123 
124  //! read a full data file
125  Tvecofblocks readfile(std::istream& is, const bool& verbose=false);
126 
127 /*----------------------------------------------------------------------*/
128 /* some general functions */
129 
130  //! return sampling interval of HPMO data acquisition (i.e. 5 sec)
131  libtime::TRelativeTime dt();
132 
133  //! return time offset for channel \p ichannel (due to multiplexer)
134  libtime::TRelativeTime toffset(const int& ichannel);
135 
136  //! check if channel number is valid
137  void check_channel_no(const int& ichannel);
138 
139  //! return meaning of quality flag
140  std::string quality(const int& flag);
141 
142  //! prepare a report on unusual quality reports
143  sff::FREE qualityreports(const MinuteBlock* blocks, const int& nblocks);
144 
145 /*----------------------------------------------------------------------*/
146 
147  //! read header from C++ stream
148  inline std::istream& operator >> (std::istream& is, Header& hd)
149  { hd.readheader(is); return(is); }
150 
151  //! read a sample block from C++ stream
152  inline std::istream& operator >> (std::istream& is, SampleBlock& data)
153  { data=readdata(is); return(is); }
154 
155  //! read a full minute block from C++ stream
156  std::istream& operator >> (std::istream& is, MinuteBlock& block);
157 
158 /*----------------------------------------------------------------------*/
159 
160  //! dump values of a sample block
161  inline std::ostream& operator << (std::ostream& os,
162  const SampleBlock& data)
163  { dump(os, data); return(os); }
164 
165  //! dump header values
166  inline std::ostream& operator << (std::ostream& os, const Header& hd)
167  { hd.dump(os); return(os); }
168 
169  //! dump a minute block
170  inline std::ostream& operator << (std::ostream& os,
171  const MinuteBlock& block)
172  { dump(os, block); return(os); }
173 
174  } // namespace hpmo
175 
176 } // namespace datrw
177 
178 #endif // DATRW_READHPMO_H_VERSION (includeguard)
179 
180 /* ----- END OF readhpmo.h ----- */
sff::FREE qualityreports(const MinuteBlock *blocks, const int &nblocks)
prepare a report on unusual quality reports
Definition: readhpmo.cc:125
libtime::TAbsoluteTime time() const
Definition: readhpmo.h:94
std::vector< MinuteBlock > Tvecofblocks
within the inner reading functions, we use vector to hold minute blocks
Definition: readhpmo.h:67
int errorflag() const
Definition: readhpmo.h:95
libtime::TRelativeTime dt()
return sampling interval of HPMO data acquisition (i.e. 5 sec)
Definition: readhpmo.cc:83
void dump(std::ostream &os) const
Definition: readhpmo.cc:73
Read, hold and handle one minute block header line.
Definition: readhpmo.h:88
Base class for exceptions.
Definition: exception.h:62
std::string errorstring() const
hold one minute block
Definition: hpmodata.h:67
std::string headerline() const
Definition: readhpmo.h:97
const char *const data
keywords for consistency checks
this excpetion will be thrown by the Header reading function, in case it does not find something that...
Definition: readhpmo.h:77
std::string Mline
Definition: readhpmo.h:102
void readheader(std::istream &is, const bool &verbose=false)
Definition: readhpmo.cc:47
libtime::TRelativeTime toffset(const int &ichannel)
return time offset for channel ichannel (due to multiplexer)
Definition: readhpmo.cc:90
Root namespace of library.
Definition: aalibdatrwxx.cc:16
std::ostream & operator<<(std::ostream &os, const SampleBlock &data)
dump values of a sample block
Definition: readhpmo.h:161
hold samples of one minute-block
Definition: hpmodata.h:58
libtime::TAbsoluteTime Mtime
Definition: readhpmo.h:100
Tvecofblocks readfile(std::istream &is, const bool &verbose)
read a full data file
Definition: readhpmo.cc:216
std::string quality(const int &flag)
return meaning of quality flag
Definition: readhpmo.cc:109
void dump(std::ostream &os, const SampleBlock &block)
dump one block of samples
Definition: readhpmo.cc:161
void check_channel_no(const int &ichannel)
check if channel number is valid
Definition: readhpmo.cc:101
Header(std::istream &is, const bool &verbose=false)
Definition: readhpmo.h:91
std::istream & operator>>(std::istream &is, MinuteBlock &block)
read a full minute block from C++ stream
Definition: readhpmo.cc:205
SampleBlock readdata(std::istream &is, const bool &verbose)
read one minute block of samples
Definition: readhpmo.cc:145