DATRW++ library: seismic data I/O with multiple formats
mseed.h
Go to the documentation of this file.
1 /*! \file mseed.h
2  * \brief provide mini-SEED data (prototypes)
3  *
4  * ----------------------------------------------------------------------------
5  *
6  * \author Thomas Forbriger
7  * \date 15/07/2004
8  *
9  * provide mini-SEED data (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  * - 15/07/2004 V1.0 Thomas Forbriger (thof)
31  * - 23/11/2010 V1.1 introduced static members
32  * - 13/09/2011 V1.2 support format modifiers for ASCII dump
33  * - 08/05/2014 V1.3 Add field for timing tolerance value
34  * - 22/07/2014 V1.4 thof: support new format modifier: estimateNframes
35  * - 05/07/2016 V1.5 thof: provide consistency check control flags
36  * - 12/07/2016 V1.6 thof: provide usec consistency check
37  * - 18/11/2016 V1.7 use debug flag in base class
38  *
39  * ============================================================================
40  */
41 
42 // include guard
43 #ifndef DATRW_MSEED_H_VERSION
44 
45 #define DATRW_MSEED_H_VERSION \
46  "DATRW_MSEED_H V1.7"
47 
48 #include<datrwxx/datread.h>
49 
50 namespace datrw {
51 
52  namespace mseed {
53 
54  extern const bool isbinary;
55  extern const char* const streamID;
56 
57  } // namespace mseed
58 
59  namespace mseed {
60 
61  /*! Container for flags to control consistency checks
62  *
63  * \ingroup group_mseed
64  */
66  ConsistencyCheckControl(const bool& fatal, const bool& check):
67  docheck(fatal), fatal(check) { }
68  /*! \brief Activation of check.
69  *
70  * If true, the respective check shall be applied.
71  */
72  bool docheck;
73  /*! \brief Consequences of check.
74  *
75  * If true, an exception is thrown, if the respective check fails.
76  */
77  bool fatal;
78  }; // struct ConsistencyCheckControl
79 
80  /*----------------------------------------------------------------------*/
81 
82  /*! Container for flags to control consistency checks
83  * \ingroup group_mseed
84  */
86  ConsistencyChecks(const bool& fatal, const bool& check):
87  nframes(fatal, check),
88  nsamples(fatal, check),
89  data(fatal, check),
90  usec(fatal, check) { }
91  /*! \brief Check for consistent number of frames.
92  *
93  * Number of frames to be expected is provided in the header in
94  * \ref page_mseed_blockette1001
95  * This value will be compared against the number of frames actually
96  * used to store data.
97  */
99  /*! \brief Check for consistent number of samples.
100  *
101  * Number of samples to be expected is provided in the header in
102  * \ref page_mseed_FixedSectionDataHeader
103  * This value will be compared against the number of samples actually
104  * provided in the logical record.
105  */
107  /*! \brief Check for consistent data values.
108  *
109  * Page 142 of "SEED Reference Manual, Standard for the Exchange of
110  * Earthquake Data, SEED Format Version 2.4, August, 2012":
111  *
112  * > The reverse integrating constant also provides for a quick data
113  * > integrity check when compared with the last computed
114  * > sample. A discrepancy indicates that the contents of the data are
115  * > garbled.
116  *
117  * The sample value of the last sample in the record is compared against
118  * the value of the reverse integration constant as provided in the
119  * first data frame of the record.
120  */
122  /*! \brief Check for usec field being in specified range.
123  *
124  * On page 124 of "SEED Reference Manual, Standard for the Exchange of
125  * Earthquake Data, SEED Format Version 2.4, August, 2012" with
126  * respect to [1001] Data Extension Blockette (8 bytes):
127  *
128  * > field 4: BYTE: µsec has the data start time down to the
129  * > microsecond. The SEED format handles down to 100µsecs. This
130  * > field is an offset from that value. The recommended value is
131  * > from -50 to +49µsecs. At the users option, this value may be
132  * > from 0 to +99µsecs.
133  */
135  }; // struct ConsistencyChecks
136 
137  /*----------------------------------------------------------------------*/
138 
139  /*! structure to hold one MiniSEEDRecord in SFF format
140  *
141  * \ingroup group_mseed
142  */
143  struct Record {
144  ::sff::WID2 wid2;
145  ::sff::FREE free;
147  int xm1;
148  bool valid;
149  void read(std::istream& is,
150  const bool& dumpascii=false,
151  const bool& estimateNframes=false,
152  const ConsistencyChecks& checks=ConsistencyChecks(true, true));
153  }; // struct Record
154 
155  } // namespace mseed
156 
157  /*----------------------------------------------------------------------*/
158 
159  /*! \brief class to read mini-SEED data
160  *
161  * \ingroup group_mseed
162  */
163  class imseedstream: public idatstream {
164  public:
165  typedef idatstream Tbase;
166  imseedstream(std::istream& is,
167  const std::string& modifier="",
168  const bool& debug=false);
169  virtual ~imseedstream() { }
170  virtual Tdseries dseries();
171  virtual Tfseries fseries();
172  virtual Tiseries iseries();
173  virtual void skipseries();
174  static void help(std::ostream& os=std::cout);
175  static const std::ios_base::openmode openmode;
176  private:
177  //! read file
178  Tiseries read(const bool& skipdata=false);
179  //! data read ahead
181  std::string Mmodifier; //!< format modifier
182  bool Mdumpascii; //!< dump ASCII data if true
183  double Mttolerance; //!< timing tolerance in microseconds
184  bool MestimateNframes; //!< estimate frame count
185  //! flags controlling consistency checks
187  }; // class imseedstream
188 
189 } // namespace datrw
190 
191 #endif // DATRW_MSEED_H_VERSION (includeguard)
192 
193 /* ----- END OF mseed.h ----- */
virtual Tdseries dseries()
bool Mdumpascii
dump ASCII data if true
Definition: mseed.h:182
bool fatal
Consequences of check.
Definition: mseed.h:77
ConsistencyCheckControl nsamples
Check for consistent number of samples.
Definition: mseed.h:106
ConsistencyCheckControl data
Check for consistent data values.
Definition: mseed.h:121
datrw::mseed::Record Mrecord
data read ahead
Definition: mseed.h:180
aff::Series< float > Tfseries
Definition: types.h:46
static const std::ios_base::openmode openmode
Definition: mseed.h:175
idatstream Tbase
Definition: mseed.h:165
datrw::mseed::ConsistencyChecks Mchecks
Definition: mseed.h:186
virtual Tiseries iseries()
void read(std::istream &is, const bool &dumpascii=false, const bool &estimateNframes=false, const ConsistencyChecks &checks=ConsistencyChecks(true, true))
read and decode a record to SFF
imseedstream(std::istream &is, const std::string &modifier="", const bool &debug=false)
Definition: imseedstream.cc:90
ConsistencyCheckControl(const bool &fatal, const bool &check)
Definition: mseed.h:66
class to read mini-SEED data
Definition: mseed.h:163
aff::Series< double > Tdseries
Definition: types.h:45
virtual void skipseries()
ConsistencyCheckControl usec
Check for usec field being in specified range.
Definition: mseed.h:134
Tiseries read(const bool &skipdata=false)
read file
Tiseries data
Definition: mseed.h:146
const char *const dumpascii
keywords for format modifiers
bool debug()
indicate debug mode
Definition: datread.h:116
::sff::WID2 wid2
Definition: mseed.h:144
Root namespace of library.
Definition: aalibdatrwxx.cc:16
static void help(std::ostream &os=std::cout)
bool MestimateNframes
estimate frame count flags controlling consistency checks
Definition: mseed.h:184
bool docheck
Activation of check.
Definition: mseed.h:72
::sff::FREE free
Definition: mseed.h:145
double Mttolerance
timing tolerance in microseconds
Definition: mseed.h:183
aff::Series< int > Tiseries
Definition: types.h:47
ConsistencyChecks(const bool &fatal, const bool &check)
Definition: mseed.h:86
const char *const streamID
Format properties.
Definition: imseedstream.cc:68
virtual ~imseedstream()
Definition: mseed.h:169
std::string Mmodifier
format modifier
Definition: mseed.h:181
const char *const estimateNframes
keywords for format modifiers
ConsistencyCheckControl nframes
Check for consistent number of frames.
Definition: mseed.h:98
const bool isbinary
Format properties.
Definition: imseedstream.cc:67
virtual Tfseries fseries()