DATRW++ library: seismic data I/O with multiple formats
suformat.h
Go to the documentation of this file.
1 /*! \file suformat.h
2  * \brief subformat keys and properties (prototypes)
3  *
4  * ----------------------------------------------------------------------------
5  *
6  * \author Thomas Forbriger
7  * \date 21/11/2011
8  *
9  * subformat keys and properties (prototypes)
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  *
30  * REVISIONS and CHANGES
31  * - 21/11/2011 V1.0 Thomas Forbriger
32  * - 21/01/2012 V1.1 added option structs and strict modifier
33  * - 22/01/2012 V1.2 bestrict control parameter must be bundled with
34  * spatial sampling parameters
35  * - 24/01/2012 V1.3 provide functions to evaluate output modifiers
36  *
37  * ============================================================================
38  */
39 
40 // include guard
41 #ifndef DATRW_SUFORMAT_H_VERSION
42 
43 #define DATRW_SUFORMAT_H_VERSION \
44  "DATRW_SUFORMAT_H V1.3"
45 
46 #include <string>
47 
48 namespace datrw {
49 
50  namespace su {
51 
52  /*! \brief subformat definitions
53  * \ingroup group_su
54  */
55  namespace subformat {
56 
57  /*! \brief key for subformat modifiers
58  * \ingroup group_su
59  */
60  namespace key {
61 
62  //! strictly interpret header as defined in SeismicUnix source
63  extern const char* const strict;
64 
65  //! understand data file as seismic data file in any case
66  extern const char* const forceseismic;
67 
68  //! understand data file as ultrasonic data file in any case
69  extern const char* const forceultrasonic;
70 
71  //! maximum number of significant digits to be used
72  extern const char* const coodigits;
73 
74  //! set desired scalco value
75  extern const char* const scalco;
76 
77  } // namespace key
78 
79  /*----------------------------------------------------------------------*/
80 
81  /*! \brief default values for subformat modifiers
82  * \ingroup group_su
83  */
84  namespace def {
85 
86  //! default maximum number of significant digits to be used
87  extern const unsigned int coodigits;
88 
89  //! default scalco value
90  extern const short scalco;
91 
92  /*----------------------------------------------------------------------*/
93  // not adjustable values
94 
95  /*! Values smaller than this (coordinates) are understood as being
96  * zero
97  */
98  extern const double thresholdzero;
99 
100  /*! Comparison of integer values and floating point values requires a
101  * way to handle round-off. Values which are closer to each other
102  * (relative residual) than the threshold are regarded as being equal.
103  */
104  extern const double thresholdcmp;
105 
106  } // namespace def
107 
108  } // namespace subformat
109 
110  /*======================================================================*/
111 
112  /*! \brief options to be passed between classes definitions
113  * \ingroup group_su
114  */
115  namespace options {
116 
117  /*! \brief options to control the way spatial sampling header variables
118  * are handeled.
119  * \ingroup group_su
120  * \sa datrw::su::ScalCoo, datrw::su::Coordinates
121  */
123  /*! \brief maximum number of significant digits to be used
124  *
125  * Floating point number representation and conversion easily leads to
126  * cases where 0.01 becomes 0.00999999977648 which is not intended.
127  * In such cases we will round to the nearest value.
128  */
129  unsigned int coodigits;
130  //! preferred scalco value
131  short scalco;
132  //! if true: strictly use header definition by SeismicUnix source
133  bool bestrict;
134 
136  coodigits(datrw::su::subformat::def::coodigits),
137  scalco(datrw::su::subformat::def::scalco),
138  bestrict(false)
139  { }
140  }; // struct SpatialSampling
141 
142  /*----------------------------------------------------------------------*/
143 
144  /*! \brief options to control the way temporal sampling header variables
145  * are handeled.
146  * \ingroup group_su
147  * \sa datrw::su::SUheader, \ref sec_su_for_TOAST
148  */
150  //! force ultrasonic headers
152  //! force seismic headers
154 
156  forceultrasonic(false),
157  forceseismic(false) { }
158  bool isconsistent() const;
159  }; // struct TemporalSampling
160 
161  /*----------------------------------------------------------------------*/
162 
163  /*! \brief options to control the way header variables
164  * are handeled.
165  * \ingroup group_su
166  * \sa datrw::su::SUheader
167  */
171  }; // struct SUHeaderControl
172 
173  } // namespace options
174 
175  /*----------------------------------------------------------------------*/
176 
177  /*! \brief evaluate input stream format modifiers
178  * \ingroup group_su
179  */
180  options::SUHeaderControl inputmodifiers(const std::string& mf,
181  const bool& debug=false);
182 
183  /*! \brief evaluate output stream format modifiers
184  * \ingroup group_su
185  */
186  options::SUHeaderControl outputmodifiers(const std::string& mf,
187  const bool& debug=false);
188 
189  /*----------------------------------------------------------------------*/
190 
191  } // namespace su
192 
193 } // namespace datrw
194 
195 #endif // DATRW_SUFORMAT_H_VERSION (includeguard)
196 
197 /* ----- END OF suformat.h ----- */
bool forceultrasonic
force ultrasonic headers
Definition: suformat.h:151
const char *const scalco
set desired scalco value
Definition: suformat.cc:64
TemporalSampling temporalsampling
Definition: suformat.h:170
unsigned int coodigits
maximum number of significant digits to be used
Definition: suformat.h:129
bool bestrict
if true: strictly use header definition by SeismicUnix source
Definition: suformat.h:133
const char *const forceseismic
understand data file as seismic data file in any case
Definition: suformat.cc:61
const double thresholdzero
Definition: suformat.cc:75
short scalco
preferred scalco value
Definition: suformat.h:131
options::SUHeaderControl inputmodifiers(const std::string &modifier, const bool &debug)
evaluate input stream format modifiers
Definition: suformat.cc:94
options to control the way spatial sampling header variables are handeled.
Definition: suformat.h:122
const char *const strict
strictly interpret header as defined in SeismicUnix source
Definition: suformat.cc:65
Root namespace of library.
Definition: aalibdatrwxx.cc:16
const short scalco
default scalco value
Definition: suformat.cc:74
const char *const forceultrasonic
understand data file as ultrasonic data file in any case
Definition: suformat.cc:62
options to control the way temporal sampling header variables are handeled.
Definition: suformat.h:149
const char *const coodigits
maximum number of significant digits to be used
Definition: suformat.cc:63
const unsigned int coodigits
default maximum number of significant digits to be used
Definition: suformat.cc:73
const double thresholdcmp
Definition: suformat.cc:76
options to control the way header variables are handeled.
Definition: suformat.h:168
options::SUHeaderControl outputmodifiers(const std::string &modifier, const bool &debug)
evaluate output stream format modifiers
Definition: suformat.cc:122
bool forceseismic
force seismic headers
Definition: suformat.h:153