UNIVERS  15.3
UNIVERS base processing software API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
corr_wave_detector.hpp
1 /* corr_wave_detector.hpp */
2 /* $Id: corr_wave_detector.hpp 21741 2012-08-10 12:34:54Z hoot $ */
3 #ifndef __corr_wave_detector_hpp
4 #define __corr_wave_detector_hpp
5 
6 #include <s2proc/wave_field.hpp>
7 #include <s2proc/u_abs_hod.hpp>
8 #include <mth/medmean.hpp>
9 #include <math.h>
10 
11 #include "abstract_wave_detector.hpp"
12 
14 {
15 public:
16 
18 
19  CorrWaveDetector(size_t sb_size, size_t sb_step, size_t start_smpl, size_t end_smpl);
20 
21 
22  const WaveField& getWavefield() const;
23  void setWavefield(const WaveField& wf);
24 
25  virtual ~CorrWaveDetector();
26 
27  //static size_t op_num;
28 
29 protected:
30 
31  virtual bool calc(Trace &tr) const;
32 
33  bool getCorrVal(size_t start_smpl, size_t length, int win_number, float &corr_val) const;
34 
35 
36  size_t m_sb_size;
37  size_t m_sb_step;
38  size_t m_start_smpl;
39  size_t m_end_smpl;
40  const WaveField *m_wf;
41 
42 private:
43  mutable std::map<int, std::map<std::pair<int, int>, float > > m_corr_map;
44  // outer key int -> number of window
45  // inner key pair -> pair of traces
46  // inner float -> correlation value
47 };
48 
49 
50 
51 
52 struct badness
53 {
54  badness(const std::vector<float> &v)
55  {
56  mean=0;
57  for(size_t i=0; i<v.size(); i++)
58  mean+=v[i];
59  mean/=v.size();
60 
61  float D=0;
62  for(size_t i=0; i<v.size(); i++)
63  D+=(v[i]-mean)*(v[i]-mean);
64  D/=v.size();
65 
66  d=sqrt(D);
67  }
68 
69  // The badness of whole vector is sum of variances against mean
70  float operator()() const
71  {
72  return d;
73  }
74  // The badness of any given variable against vector is variance
75  // of variable against mean of vector.
76 
77  float operator()(const float &v) const
78  {
79  return fabs(v-mean);
80  }
81 
82  float mean, d;
83 
84 };
85 
86 
87 
88 
89 
90 
91 
92 
93 #endif /* corr_wave_detector.hpp */
Definition: corr_wave_detector.hpp:52
Definition: corr_wave_detector.hpp:13
Definition: abstract_wave_detector.hpp:7
Definition: wave_field.hpp:13
Definition: trace.hpp:14