UNIVERS  15.3
UNIVERS base processing software API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
polycor_math_old.hpp
1 /* polycor_math.hpp */
2 /* $Id: polycor_math.hpp 21283 2011-11-29 07:50:53Z urij $ */
3 #ifndef __polycor_math_old_hpp
4 #define __polycor_math_old_hpp
5 
6 #include <s2proc/udb_seis.hpp>
7 #include <s2proc/wave_field.hpp>
8 #include <s2proc/PolyMatrix_old.hpp>
9 
10 #include <math.h>
11 
12 namespace polycor_old
13 {
14 
15 
16 namespace Polycor
17 {
18 
19  struct CCF_sample
20  {
21  std::pair<int, int> m_TRS1; // id of the first trace
22  std::pair<int, int> m_TRS2; // id of the second trace
23 
24  int m_CCF_RANGE; // Correlation function range 0-> ACF
25  // 1-> neighbour shot points
26  // 2-> cross 1 shot point
27  char m_COMP; // component of traces
28 
29  int m_summed_count;
30  Trace m_CCF_TRACE; // body of CCF1
31 
32  };
33 
34  struct CCF2_shift
35  {
36  std::pair<int, int> NSP_PAIR1; // id of the first trace in first CCF1
37  std::pair<int, int> NSP_PAIR2; // id of the second trace in first CCF1
38 
39  float SHIFT; // shift betwen pair of CCF1 in ms
40  float MAX_VAL; // Value of CCF2 in SHIFT point
41  Trace m_CCF2; // body of CCF2
42  };
43 
44  typedef std::vector<Polycor::CCF_sample> CCF_Ar;
45  typedef std::vector<Polycor::CCF2_shift> SHIFT_Ar;
46 
47  typedef std::vector<std::vector<double> > Coeff_Matrix;
48 
49  struct AmplBadness
50  {
51  AmplBadness(const std::vector<double> &shifts) :
52  m_d(0.0),
53  m_mean(0.0)
54  {
55  if (shifts.size() < 1)
56  {
57  m_d = 0.0;
58  m_mean = 0.0;
59  return;
60  }
61 
62  // mean value
63  m_mean = 0.;
64  for (size_t i=0; i<shifts.size(); i++)
65  {
66  m_mean += shifts[i]* shifts[i];
67  }
68  m_mean /= shifts.size();
69 
70  //summ of quadratic derivations
71  m_d = 0;
72  for (size_t i=0; i<shifts.size(); ++i)
73  {
74  m_d += (shifts[i]*shifts[i] - m_mean) * (shifts[i]*shifts[i] - m_mean);
75  }
76  m_d /= shifts.size();
77  }
78 
79  double operator()() const {return m_d;}
80 
81  double operator()(const double& t) const
82  {
83  return fabs(t*t - m_mean);
84  }
85 
86  double m_d;
87 
88  double m_mean;
89  };
90 
91 
93  typedef std::vector<std::pair<std::pair<int, int >, double> > StaticRow;
94 
96  bool WfCorrelator(WaveField &wf1, WaveField &wf2, WaveField &ccf_wf, float start_time, float time_width, float ccf_length, bool norma);
97 
99  bool TransformCCF(const WaveField &wf, TrHeader *headers, Polycor::CCF_Ar &CcfAr);
100 
103  bool summ_CCF1_rows(CCF_Ar &Base_row, CCF_Ar &add_row, CCF2_shift &CCF2, const float &intersect_ratio, const float *l_range, const float &max_shift);
104 
106  bool get_CCF_max(const Trace &trs, float &time, float &max_value);
107 
108 
110  bool get_CCF2_wave(const SHIFT_Ar &TMP_CCF2_ROW, Trace &ccf2_trs);
111 
112 
114  bool compose_summ_row(CCF_Ar &first_row, const CCF_Ar &second_row, float &time_shift, CCF_Ar &summ_row);
115 
117 
118  bool form_Matrix(SHIFT_Ar &cur_shift_ar,
119  std::vector<std::pair<int ,int> > &X_i,
120  Coeff_Matrix &coef_mat,
121  std::vector<double> &result);
122 
123  bool gauss_Prepare(Coeff_Matrix &coef_mat, std::vector<double> &result);
124 
125 
126 };
127 
128 bool Comparator(const Polycor::CCF2_shift &ccf_sh1, const Polycor::CCF2_shift &ccf_sh2);
129 
130 //===================================================================================================
131 //=========================* Class for RP based matrix construction *================================
132 //===================================================================================================
133 
134 class PolyMatrixRP : public PolyMatrix
135 {
136 public:
137 
138  PolyMatrixRP(std::vector<Polycor::CCF_Ar> &CCF1_base);
139  virtual ~PolyMatrixRP();
140 
141  bool SetMatrixElement(size_t i, size_t j, double& val);
142  bool SetVectorElement(size_t i, double& val);
143 
144  bool IsReady();
145  size_t GetPointsCount(std::vector<int> &ID_num);
146 
147 protected:
148 
149  bool set_ID_Row();
150  std::set<int> m_RP_set;
151  std::vector<Polycor::CCF_Ar>* m_CCF1_base;
152 
153 private:
154  bool m_ready;
155 
156 };
157 
158 
159 
160 //===================================================================================================
161 //=========================* Class for SP based matrix construction *================================
162 //===================================================================================================
163 
164 class PolyMatrixSP : public PolyMatrix
165 {
166 public:
167 
168  PolyMatrixSP(std::vector<Polycor::SHIFT_Ar> &CCF2_base);
169  virtual ~PolyMatrixSP();
170 
171  bool SetMatrixElement(size_t i, size_t j, double& val);
172  bool SetVectorElement(size_t i, double& val);
173 
174  bool IsReady();
175  size_t GetPointsCount(std::vector<int> &ID_num);
176 
177 protected:
178 
179  bool set_ID_Row();
180  std::set<int> m_SP_set;
181  std::vector<Polycor::SHIFT_Ar>* m_CCF2_base;
182 
183 private:
184  bool m_ready;
185 
186 };
187 
188 };
189 
190 #endif /* polycor_math_old.hpp */
Definition: polycor_math_old.hpp:164
Definition: polycor_math_old.hpp:134
Definition: trace_file.h:15
Definition: polycor_math_old.hpp:19
Definition: wave_field.hpp:13
Definition: PolyMatrix_old.hpp:22
Definition: trace.hpp:14
Definition: polycor_math_old.hpp:49
Definition: polycor_math_old.hpp:34