Browse Source

Improved speed of 1 frequency harmonic noise removal.

tags/1.6.1
T-bone 5 years ago
parent
commit
a868a12f8e
3 changed files with 34 additions and 1210 deletions
  1. 13
    13
      akvo/gui/main.ui
  2. 0
    1187
      akvo/gui/mainui.py
  3. 21
    10
      akvo/tressel/harmonic.py

+ 13
- 13
akvo/gui/main.ui View File

49
         <rect>
49
         <rect>
50
          <x>0</x>
50
          <x>0</x>
51
          <y>0</y>
51
          <y>0</y>
52
-         <width>537</width>
53
-         <height>882</height>
52
+         <width>548</width>
53
+         <height>813</height>
54
         </rect>
54
         </rect>
55
        </property>
55
        </property>
56
        <property name="sizePolicy">
56
        <property name="sizePolicy">
99
            <enum>Qt::LeftToRight</enum>
99
            <enum>Qt::LeftToRight</enum>
100
           </property>
100
           </property>
101
           <property name="currentIndex">
101
           <property name="currentIndex">
102
-           <number>0</number>
102
+           <number>1</number>
103
           </property>
103
           </property>
104
           <property name="elideMode">
104
           <property name="elideMode">
105
            <enum>Qt::ElideLeft</enum>
105
            <enum>Qt::ElideLeft</enum>
2225
               <rect>
2225
               <rect>
2226
                <x>0</x>
2226
                <x>0</x>
2227
                <y>0</y>
2227
                <y>0</y>
2228
-               <width>96</width>
2229
-               <height>26</height>
2228
+               <width>98</width>
2229
+               <height>28</height>
2230
               </rect>
2230
               </rect>
2231
              </property>
2231
              </property>
2232
              <attribute name="label">
2232
              <attribute name="label">
2238
               <rect>
2238
               <rect>
2239
                <x>0</x>
2239
                <x>0</x>
2240
                <y>0</y>
2240
                <y>0</y>
2241
-               <width>411</width>
2242
-               <height>77</height>
2241
+               <width>98</width>
2242
+               <height>28</height>
2243
               </rect>
2243
               </rect>
2244
              </property>
2244
              </property>
2245
              <attribute name="label">
2245
              <attribute name="label">
2302
              <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
2302
              <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
2303
 &lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
2303
 &lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
2304
 p, li { white-space: pre-wrap; }
2304
 p, li { white-space: pre-wrap; }
2305
-&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Noto Sans'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
2306
-&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:9pt;&quot;&gt;All processing steps are recorded here for your records&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
2305
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
2306
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;All processing steps are recorded here for your records&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
2307
             </property>
2307
             </property>
2308
            </widget>
2308
            </widget>
2309
            <widget class="QLabel" name="label_74">
2309
            <widget class="QLabel" name="label_74">
2439
              <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
2439
              <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
2440
 &lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
2440
 &lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
2441
 p, li { white-space: pre-wrap; }
2441
 p, li { white-space: pre-wrap; }
2442
-&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Noto Sans'; font-size:8pt; font-weight:400; font-style:italic;&quot;&gt;
2442
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:8pt; font-weight:400; font-style:italic;&quot;&gt;
2443
 &lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'DejaVu Serif'; font-size:9pt;&quot;&gt;Load supported RAW Dataset header from file menu&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
2443
 &lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'DejaVu Serif'; font-size:9pt;&quot;&gt;Load supported RAW Dataset header from file menu&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
2444
             </property>
2444
             </property>
2445
            </widget>
2445
            </widget>
2564
                 <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
2564
                 <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
2565
 &lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
2565
 &lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
2566
 p, li { white-space: pre-wrap; }
2566
 p, li { white-space: pre-wrap; }
2567
-&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Noto Sans'; font-size:10pt; font-weight:400; font-style:italic;&quot;&gt;
2568
-&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'DejaVu Serif';&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
2567
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:italic;&quot;&gt;
2568
+&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'DejaVu Serif'; font-size:10pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
2569
                </property>
2569
                </property>
2570
               </widget>
2570
               </widget>
2571
              </item>
2571
              </item>
2995
      <x>0</x>
2995
      <x>0</x>
2996
      <y>0</y>
2996
      <y>0</y>
2997
      <width>1142</width>
2997
      <width>1142</width>
2998
-     <height>30</height>
2998
+     <height>20</height>
2999
     </rect>
2999
     </rect>
3000
    </property>
3000
    </property>
3001
    <widget class="QMenu" name="menuOpen_GMR_RAW_Header">
3001
    <widget class="QMenu" name="menuOpen_GMR_RAW_Header">

+ 0
- 1187
akvo/gui/mainui.py
File diff suppressed because it is too large
View File


+ 21
- 10
akvo/tressel/harmonic.py View File

106
         nK = number of harmonics to calculate 
106
         nK = number of harmonics to calculate 
107
         t = time samples 
107
         t = time samples 
108
     """
108
     """
109
-    print("building Euler matrix ")
110
-    A = np.zeros( (len(t),  nK), dtype=np.complex64)
111
-    for irow, tt in enumerate(t): 
112
-        A[irow,:] = np.exp(1j* np.arange(1,nK+1) * 2*np.pi* (f0/fs) * irow)
109
+    
110
+    #print("building Euler matrix ")
111
+    #A = np.zeros( (len(t),  nK), dtype=np.complex64)
112
+    #for irow, tt in enumerate(t): 
113
+    #    A[irow,:] = np.exp(1j* np.arange(1,nK+1) * 2*np.pi* (f0/fs) * irow)
114
+    
115
+    #AA = np.zeros( (len(t),  nK), dtype=np.complex64)
116
+    A = np.exp(1j* np.tile( np.arange(1,nK+1),(len(t), 1)) * 2*np.pi* (f0/fs) * np.tile(np.arange(len(t)),(nK,1)).T  )
117
+    #AA =  np.tile(np.arange(len(t)), (nK,1)).T 
118
+
119
+    #plt.matshow( np.imag(A), aspect='auto' )
120
+    #plt.matshow( np.real(AA), aspect='auto' )
121
+    #plt.show()
122
+    #exit()
123
+    #print ("A norm", np.linalg.norm(A - AA))
113
 
124
 
114
     v = np.linalg.lstsq(A, sN, rcond=None) # rcond=None) #, rcond=1e-8)
125
     v = np.linalg.lstsq(A, sN, rcond=None) # rcond=None) #, rcond=1e-8)
115
     alpha = np.real(v[0]) #[0::2]
126
     alpha = np.real(v[0]) #[0::2]
175
     f02 = guessf0(sN, fs)
186
     f02 = guessf0(sN, fs)
176
     print("minHarmonic", f0, fs, nK, " guess=", f02)
187
     print("minHarmonic", f0, fs, nK, " guess=", f02)
177
     # CG, BFGS, Newton-CG, L-BFGS-B, TNC, SLSQP, dogleg, trust-ncg, trust-krylov, trust-exact and trust-constr
188
     # CG, BFGS, Newton-CG, L-BFGS-B, TNC, SLSQP, dogleg, trust-ncg, trust-krylov, trust-exact and trust-constr
178
-    res = minimize( harmonicNorm, np.array((f0)), args=(sN, fs, nK, t)) #, method='CG', jac=jacEuler) #, hess=None, bounds=None )
189
+    res = minimize(harmonicNorm, np.array((f0)), args=(sN, fs, nK, t)) #, method='CG', jac=jacEuler) #, hess=None, bounds=None )
179
     print(res)
190
     print(res)
180
     return harmonicEuler(res.x[0], sN, fs, nK, t)
191
     return harmonicEuler(res.x[0], sN, fs, nK, t)
181
 
192
 
183
     #f02 = guessf0(sN, fs)
194
     #f02 = guessf0(sN, fs)
184
     #print("minHarmonic2", f0, fs, nK, " guess=", f02)
195
     #print("minHarmonic2", f0, fs, nK, " guess=", f02)
185
     #methods with bounds, L-BFGS-B, TNC, SLSQP
196
     #methods with bounds, L-BFGS-B, TNC, SLSQP
186
-    res = minimize( harmonic2Norm, np.array((f1,f2)), args=(sN, fs, nK, t)) #, bounds=((f1-1.,f1+1.0),(f2-1.0,f2+1.0)), method='TNC' )
197
+    res = minimize( harmonic2Norm, np.array((f1,f2)), args=(sN, fs, nK, t), jac='2-point') #, bounds=((f1-1.,f1+1.0),(f2-1.0,f2+1.0)), method='TNC' )
187
     print(res)
198
     print(res)
188
     return harmonicEuler2(res.x[0], res.x[1], sN, fs, nK, t) 
199
     return harmonicEuler2(res.x[0], res.x[1], sN, fs, nK, t) 
189
 
200
 
202
     import matplotlib.pyplot as plt 
213
     import matplotlib.pyplot as plt 
203
 
214
 
204
     f0 = 60      # Hz
215
     f0 = 60      # Hz
205
-    f1 = 62      # Hz
216
+    f1 = 61      # Hz
206
     delta  = np.random.rand() 
217
     delta  = np.random.rand() 
207
     delta2 =  np.random.rand() 
218
     delta2 =  np.random.rand() 
208
     print("delta", delta)
219
     print("delta", delta)
211
     phi =  np.random.rand() 
222
     phi =  np.random.rand() 
212
     phi2 = np.random.rand() 
223
     phi2 = np.random.rand() 
213
     A =  1.0
224
     A =  1.0
214
-    A2 = 0.25 
225
+    A2 = 0.0 
215
     A3 = 1.0 
226
     A3 = 1.0 
216
     nK = 35
227
     nK = 35
217
     T2 = .200
228
     T2 = .200
229
 
240
 
230
     # single freq
241
     # single freq
231
     #h = harmonicEuler( f0, sN, fs, nK, t) 
242
     #h = harmonicEuler( f0, sN, fs, nK, t) 
232
-    #h = minHarmonic( f0, sN, fs, nK, t) 
243
+    h = minHarmonic( f0, sN, fs, nK, t) 
233
     
244
     
234
     # two freqs 
245
     # two freqs 
235
-    h = minHarmonic2( f0, f1, sN, fs, nK, t) 
246
+    #h = minHarmonic2( f0, f1, sN, fs, nK, t) 
236
     #h = harmonic2( f0, f1, sN, fs, nK, t) 
247
     #h = harmonic2( f0, f1, sN, fs, nK, t) 
237
     #h = harmonicEuler2( f0, f1, sN, fs, nK, t) 
248
     #h = harmonicEuler2( f0, f1, sN, fs, nK, t) 
238
 
249
 

Loading…
Cancel
Save