sucomanager.h 4.74 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*! \file sucomanager.h
 * \brief manage coordinate scaling (prototypes)
 * 
 * ----------------------------------------------------------------------------
 * 
 * $Id$
 * \author Thomas Forbriger
 * \date 06/12/2010
 * 
 * manage coordinate scaling (prototypes)
 * 
 * Copyright (c) 2010 by Thomas Forbriger (BFO Schiltach) 
 *
 * ----
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version. 
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 * ----
 *
 * 
 * REVISIONS and CHANGES 
 *  - 06/12/2010   V1.0   Thomas Forbriger
 * 
 * ============================================================================
 */

// include guard
#ifndef DATRW_SUCOMANAGER_H_VERSION

#define DATRW_SUCOMANAGER_H_VERSION \
  "DATRW_SUCOMANAGER_H   V1.0   "
#define DATRW_SUCOMANAGER_H_CVSID \
  "$Id$"

thomas.forbriger's avatar
thomas.forbriger committed
45
46
#include<datrwxx/suheaderstruct.h>

47
48
49
50
namespace datrw {

  namespace su {

51
52
53
54
55
56
    /*! \brief scaled coordinate.
     *
     * This struct holds one coordinate together with a scale value.
     * It provides functions to support appropriate scaling and to explore
     * dynamic range.
     */
thomas.forbriger's avatar
thomas.forbriger committed
57
    struct ScalCoo {
58
59
60
61
      //! constructor
      ScalCoo(const bool& debug=false)
        : scale(1), coo(0), Mdebug(debug) 
      { }
62

63
      /*! \brief lower limit of values
64
65
66
67
68
69
70
71
72
73
       *
       * Coordinate values smaller than this will be regarded as zero.
       * They cannot be represented, since the scaling limits the exponential
       * factor to the range 1.e-4 to 1.e+4. It is unsafe to handle these
       * values with the standard scaling algorithm, since this requires to
       * take the logarithm of the coordinate value, which will approach
       * infinity for coordinates approaching zero.
       */
      static double effectivezero;

74
      /*! \brief maximum number of significant digits to be used
75
76
77
78
79
80
81
       *
       * Floating point number representation and conversion easily leads to
       * cases where 0.01 becomes 0.00999999977648 which is not intended.
       * In such cases we will round to the nearest value.
       */
      static int maxnsigdigits;

thomas.forbriger's avatar
thomas.forbriger committed
82
      //! set from header fields
83
      void set(const short& s, const int& c);
thomas.forbriger's avatar
thomas.forbriger committed
84
85
86
87
88
89
      //! set from coordinate value in meters
      void set(const double& v);
      //! return decimal power of scaling factor
      int power() const;
      //! scale to given scaling factor as defined by decimal power
      void scaletopower(const int& p);
90
      //! smallest possible power larger or equal desired
91
      int smallestpower(const int& desired=-2);
92
93
      //! return coordinate value
      double value() const;
94
95
      //! adjust scale to optimal representation of significant digits
      void adjustscale();
thomas.forbriger's avatar
thomas.forbriger committed
96
97
98
99
100

      //! scale like scalco
      short scale;
      //! coordinate
      int coo;
101
102
      //! debug mode
      bool Mdebug;
103
    }; // struct ScalCoo
thomas.forbriger's avatar
thomas.forbriger committed
104
105
106

    /*----------------------------------------------------------------------*/

107
108
109
110
111
112
113
114
    /*! \brief full set of coordinates.
     *
     * This struct holds a full set of coordinates for a SEG-Y trace header.
     * It provides functions to read the values from a given trace header and
     * to set values in a trace header. Further it provides a function to
     * chose equal scaling values for horizontal coordinates on one hand and
     * vertical coordinates on the other hand.
     */
115
    struct Coordinates {
116
117
118
119
120
      //! constructor
      Coordinates(const bool& debug=false)
        : sx(debug), sy(debug), gx(debug), gy(debug),
        sdepth(debug), gelev(debug), Mdebug(debug)
      { }
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
      //! read values from SU header
      void getvaluesfrom(const TraceHeaderStruct& h);
      //! set values in SU header
      void setvaluesin(TraceHeaderStruct& h);
      //! equalize scaling
      void equalizescaling();

      //! source x coordinate
      ScalCoo sx;
      //! source y coordinate
      ScalCoo sy;
      //! receiver x coordinate
      ScalCoo gx;
      //! receiver y coordinate
      ScalCoo gy;
      //! source z coordinate
      ScalCoo sdepth;
      //! source y coordinate
      ScalCoo gelev;
140
141
      //! debug mode
      bool Mdebug;
142
143
    }; // struct Coordinates

144
145
146
147
148
149
150
  } // namespace su

} // namespace datrw

#endif // DATRW_SUCOMANAGER_H_VERSION (includeguard)

/* ----- END OF sucomanager.h ----- */