瀏覽代碼

Improved speed of 1 frequency harmonic noise removal.

tags/1.6.1
T-bone 5 年之前
父節點
當前提交
a868a12f8e
共有 3 個文件被更改,包括 34 次插入1210 次删除
  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 查看文件

@@ -49,8 +49,8 @@
49 49
         <rect>
50 50
          <x>0</x>
51 51
          <y>0</y>
52
-         <width>537</width>
53
-         <height>882</height>
52
+         <width>548</width>
53
+         <height>813</height>
54 54
         </rect>
55 55
        </property>
56 56
        <property name="sizePolicy">
@@ -99,7 +99,7 @@
99 99
            <enum>Qt::LeftToRight</enum>
100 100
           </property>
101 101
           <property name="currentIndex">
102
-           <number>0</number>
102
+           <number>1</number>
103 103
           </property>
104 104
           <property name="elideMode">
105 105
            <enum>Qt::ElideLeft</enum>
@@ -2225,8 +2225,8 @@ background: dark grey;
2225 2225
               <rect>
2226 2226
                <x>0</x>
2227 2227
                <y>0</y>
2228
-               <width>96</width>
2229
-               <height>26</height>
2228
+               <width>98</width>
2229
+               <height>28</height>
2230 2230
               </rect>
2231 2231
              </property>
2232 2232
              <attribute name="label">
@@ -2238,8 +2238,8 @@ background: dark grey;
2238 2238
               <rect>
2239 2239
                <x>0</x>
2240 2240
                <y>0</y>
2241
-               <width>411</width>
2242
-               <height>77</height>
2241
+               <width>98</width>
2242
+               <height>28</height>
2243 2243
               </rect>
2244 2244
              </property>
2245 2245
              <attribute name="label">
@@ -2302,8 +2302,8 @@ background: red;
2302 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 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 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 2307
             </property>
2308 2308
            </widget>
2309 2309
            <widget class="QLabel" name="label_74">
@@ -2439,7 +2439,7 @@ p, li { white-space: pre-wrap; }
2439 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 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 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 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 2444
             </property>
2445 2445
            </widget>
@@ -2564,8 +2564,8 @@ background: dark grey;
2564 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 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 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 2569
                </property>
2570 2570
               </widget>
2571 2571
              </item>
@@ -2995,7 +2995,7 @@ background: dark grey;
2995 2995
      <x>0</x>
2996 2996
      <y>0</y>
2997 2997
      <width>1142</width>
2998
-     <height>30</height>
2998
+     <height>20</height>
2999 2999
     </rect>
3000 3000
    </property>
3001 3001
    <widget class="QMenu" name="menuOpen_GMR_RAW_Header">

+ 0
- 1187
akvo/gui/mainui.py
文件差異過大導致無法顯示
查看文件


+ 21
- 10
akvo/tressel/harmonic.py 查看文件

@@ -106,10 +106,21 @@ def harmonicEuler ( f0, sN, fs, nK, t ):
106 106
         nK = number of harmonics to calculate 
107 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 125
     v = np.linalg.lstsq(A, sN, rcond=None) # rcond=None) #, rcond=1e-8)
115 126
     alpha = np.real(v[0]) #[0::2]
@@ -175,7 +186,7 @@ def minHarmonic(f0, sN, fs, nK, t):
175 186
     f02 = guessf0(sN, fs)
176 187
     print("minHarmonic", f0, fs, nK, " guess=", f02)
177 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 190
     print(res)
180 191
     return harmonicEuler(res.x[0], sN, fs, nK, t)
181 192
 
@@ -183,7 +194,7 @@ def minHarmonic2(f1, f2, sN, fs, nK, t):
183 194
     #f02 = guessf0(sN, fs)
184 195
     #print("minHarmonic2", f0, fs, nK, " guess=", f02)
185 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 198
     print(res)
188 199
     return harmonicEuler2(res.x[0], res.x[1], sN, fs, nK, t) 
189 200
 
@@ -202,7 +213,7 @@ if __name__ == "__main__":
202 213
     import matplotlib.pyplot as plt 
203 214
 
204 215
     f0 = 60      # Hz
205
-    f1 = 62      # Hz
216
+    f1 = 61      # Hz
206 217
     delta  = np.random.rand() 
207 218
     delta2 =  np.random.rand() 
208 219
     print("delta", delta)
@@ -211,7 +222,7 @@ if __name__ == "__main__":
211 222
     phi =  np.random.rand() 
212 223
     phi2 = np.random.rand() 
213 224
     A =  1.0
214
-    A2 = 0.25 
225
+    A2 = 0.0 
215 226
     A3 = 1.0 
216 227
     nK = 35
217 228
     T2 = .200
@@ -229,10 +240,10 @@ if __name__ == "__main__":
229 240
 
230 241
     # single freq
231 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 245
     # two freqs 
235
-    h = minHarmonic2( f0, f1, sN, fs, nK, t) 
246
+    #h = minHarmonic2( f0, f1, sN, fs, nK, t) 
236 247
     #h = harmonic2( f0, f1, sN, fs, nK, t) 
237 248
     #h = harmonicEuler2( f0, f1, sN, fs, nK, t) 
238 249
 

Loading…
取消
儲存