Browse Source

Improvements to reload of dmp files

tags/1.6.1
Trevor Irons 5 years ago
parent
commit
390218d321
4 changed files with 626 additions and 553 deletions
  1. 34
    9
      akvo/gui/akvoGUI.py
  2. 560
    512
      akvo/gui/main.ui
  3. 10
    10
      akvo/tressel/harmonic.py
  4. 22
    22
      akvo/tressel/mrsurvey.py

+ 34
- 9
akvo/gui/akvoGUI.py View File

@@ -768,7 +768,6 @@ class ApplicationWindow(QtWidgets.QMainWindow):
768 768
             #self.ui.logTextBrowser.append( yaml.dump(self.YamlNode)) #, default_flow_style=False)  )
769 769
         #except KeyError:
770 770
         #    pass
771
-       
772 771
         # Remove "Saved" and "Loaded" from processing flow 
773 772
         #if "Loaded" not in self.YamlNode.Processing.keys():
774 773
         #    self.YamlNode.Processing["Loaded"] = []
@@ -783,14 +782,27 @@ class ApplicationWindow(QtWidgets.QMainWindow):
783 782
         self.ui.lcdNumberNQ.setEnabled(True)
784 783
 
785 784
         self.ui.headerFileBox.setEnabled(True)
786
-        self.ui.headerFileBox.setChecked( False )
785
+        self.ui.headerFileBox.setChecked( True )
786
+        self.headerBoxShrink() 
787 787
         #self.ui.headerBox2.setVisible(True) 
788
-        self.ui.inputRAWParametersBox.setEnabled(True)
788
+        self.ui.inputRAWParametersBox.setEnabled(False)
789 789
         self.ui.loadDataPushButton.setEnabled(True)
790 790
         
791
-        # make plots as you import the dataset
791
+        # make plots as you import the datasetmost
792 792
         self.ui.plotImportCheckBox.setEnabled(True)
793 793
         self.ui.plotImportCheckBox.setChecked(True)
794
+
795
+        # enable the LCDs
796
+        self.ui.lcdNumberFID1Length.setEnabled(1)
797
+        self.ui.lcdNumberFID2Length.setEnabled(1)
798
+        self.ui.lcdNumberResampFreq.setEnabled(1)
799
+        self.ui.lcdTotalDeadTime.setEnabled(1)
800
+        
801
+        self.ui.lcdTotalDeadTime.display( 1e3*self.RAWDataProc.DATADICT["INFO"]["deadTime"] )
802
+        self.ui.headerFileTextBrowser.clear( ) 
803
+        self.ui.headerFileTextBrowser.append( self.RAWDataProc.DATADICT["INFO"]["headerstr"] )
804
+            
805
+        self.ui.lcdNumberFID1Length.display(self.RAWDataProc.DATADICT["Pulse 1"]["TIMES"][-1]- self.RAWDataProc.DATADICT["Pulse 1"]["TIMES"][0])
794 806
  
795 807
         # Update info from the header into the GUI
796 808
         self.ui.pulseTypeTextBrowser.clear()
@@ -798,7 +810,8 @@ class ApplicationWindow(QtWidgets.QMainWindow):
798 810
         self.ui.lcdNumberNuTx.display(self.RAWDataProc.transFreq)
799 811
         self.ui.lcdNumberTauPulse1.display(1e3*self.RAWDataProc.pulseLength[0])
800 812
         self.ui.lcdNumberTuneuF.display(self.RAWDataProc.TuneCapacitance)
801
-        self.ui.lcdNumberSampFreq.display(self.RAWDataProc.samp)
813
+        self.ui.lcdNumberResampFreq.display(self.RAWDataProc.samp)
814
+        self.ui.lcdNumberSampFreq.display(50000) # TODO, if non GMR is supported, query
802 815
         self.ui.lcdNumberNQ.display(self.RAWDataProc.nPulseMoments)
803 816
         self.ui.DeadTimeSpinBox.setValue(1e3*self.RAWDataProc.deadTime)
804 817
         self.ui.CentralVSpinBox.setValue( self.RAWDataProc.transFreq )
@@ -948,6 +961,7 @@ class ApplicationWindow(QtWidgets.QMainWindow):
948 961
         self.ui.logTextBrowser.append( yaml.dump(self.YamlNode)) #, default_flow_style=False)  )
949 962
 
950 963
     def disable(self):
964
+        self.ui.inputRAWParametersBox.setEnabled(False)
951 965
         self.ui.BandPassBox.setEnabled(False)
952 966
         self.ui.downSampleGroupBox.setEnabled(False)
953 967
         self.ui.windowFilterGroupBox.setEnabled(False)
@@ -991,7 +1005,11 @@ class ApplicationWindow(QtWidgets.QMainWindow):
991 1005
         
992 1006
         # FD Adaptive filtering 
993 1007
         self.ui.adaptFDBox.setEnabled(True)
994
-        self.ui.adaptFDBox.setChecked(True)
1008
+        self.ui.adaptFDBox.setChecked(False)
1009
+        
1010
+        # Harmonic
1011
+        self.ui.harmonicBox.setEnabled(True)
1012
+        self.ui.harmonicBox.setChecked(True)
995 1013
 
996 1014
         # sum group box
997 1015
         try:
@@ -1067,8 +1085,14 @@ class ApplicationWindow(QtWidgets.QMainWindow):
1067 1085
     def harmonicModel(self):
1068 1086
         self.lock("harmonic noise modelling")
1069 1087
         thread.start_new_thread(self.RAWDataProc.harmonicModel, \
1070
-                (self.ui.f0Spin.value(), \
1071
-                self.ui.mplwidget))
1088
+                ( \
1089
+                 self.ui.NHarmonicsFreqsSpin.value(), \
1090
+                 self.ui.NKHarmonicsSpin.value(), \
1091
+                 self.ui.f0Spin.value(), \
1092
+                 self.ui.f1Spin.value(), \
1093
+                 self.ui.plotHarmonic.isChecked(), \
1094
+                 self.ui.mplwidget) \
1095
+        )
1072 1096
 
1073 1097
     def FDSmartStack(self):
1074 1098
 
@@ -1171,7 +1195,8 @@ class ApplicationWindow(QtWidgets.QMainWindow):
1171 1195
         
1172 1196
         thread.start_new_thread(self.RAWDataProc.downsample, \
1173 1197
                 (self.ui.truncateSpinBox.value(), \
1174
-                self.ui.downSampleSpinBox.value(),
1198
+                self.ui.downSampleSpinBox.value(), \
1199
+                self.ui.dsPlot.isChecked(), \
1175 1200
                 self.ui.mplwidget))
1176 1201
 
1177 1202
     def quadDet(self):

+ 560
- 512
akvo/gui/main.ui
File diff suppressed because it is too large
View File


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

@@ -15,7 +15,7 @@ def harmonicEuler ( f0, sN, fs, nK, t ):
15 15
         t = time samples 
16 16
     """
17 17
     
18
-    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  )
18
+    A = np.exp(1j* np.tile( np.arange(1,nK+1),(len(t), 1)) * 2*np.pi* (f0/fs) * np.tile( np.arange(1, len(t)+1, 1),(nK,1)).T  )
19 19
 
20 20
     v = np.linalg.lstsq(A, sN, rcond=None) 
21 21
     alpha = np.real(v[0]) 
@@ -26,7 +26,7 @@ def harmonicEuler ( f0, sN, fs, nK, t ):
26 26
 
27 27
     h = np.zeros(len(t))
28 28
     for ik in range(nK):
29
-        h +=  2*amp[ik] * np.cos( 2.*np.pi*(ik+1) * (f0/fs) * np.arange(0, len(t), 1 )  + phase[ik] )
29
+        h +=  2*amp[ik] * np.cos( 2.*np.pi*(ik+1) * (f0/fs) * np.arange(1, len(t)+1, 1 )  + phase[ik] )
30 30
     
31 31
     return sN-h
32 32
     
@@ -75,8 +75,8 @@ def harmonicEuler2 ( f0, f1, sN, fs, nK, t ):
75 75
         nK = number of harmonics to calculate 
76 76
         t = time samples 
77 77
     """
78
-    A1 = 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  )
79
-    A2 = np.exp(1j* np.tile( np.arange(1,nK+1),(len(t), 1)) * 2*np.pi* (f1/fs) * np.tile(np.arange(len(t)),(nK,1)).T  )
78
+    A1 = np.exp(1j* np.tile( np.arange(1,nK+1),(len(t), 1)) * 2*np.pi* (f0/fs) * np.tile(np.arange(1, len(t)+1, 1),(nK,1)).T  )
79
+    A2 = np.exp(1j* np.tile( np.arange(1,nK+1),(len(t), 1)) * 2*np.pi* (f1/fs) * np.tile(np.arange(1, len(t)+1, 1),(nK,1)).T  )
80 80
     A = np.concatenate( (A1, A2), axis=1 )
81 81
 
82 82
 
@@ -88,8 +88,8 @@ def harmonicEuler2 ( f0, f1, sN, fs, nK, t ):
88 88
 
89 89
     h = np.zeros(len(t))
90 90
     for ik in range(nK):
91
-        h +=  2*amp[ik]  * np.cos( 2.*np.pi*(ik+1) * (f0/fs) * np.arange(0, len(t), 1 )  + phase[ik] ) + \
92
-              2*amp1[ik] * np.cos( 2.*np.pi*(ik+1) * (f1/fs) * np.arange(0, len(t), 1 )  + phase1[ik] )
91
+        h +=  2*amp[ik]  * np.cos( 2.*np.pi*(ik+1) * (f0/fs) * np.arange(1, len(t)+1, 1 )  + phase[ik] ) + \
92
+              2*amp1[ik] * np.cos( 2.*np.pi*(ik+1) * (f1/fs) * np.arange(1, len(t)+1, 1 )  + phase1[ik] )
93 93
 
94 94
     return sN-h
95 95
 
@@ -103,7 +103,7 @@ def minHarmonic(f0, sN, fs, nK, t):
103 103
     f02 = guessf0(sN, fs)
104 104
     print("minHarmonic", f0, fs, nK, " guess=", f02)
105 105
     # CG, BFGS, Newton-CG, L-BFGS-B, TNC, SLSQP, dogleg, trust-ncg, trust-krylov, trust-exact and trust-constr
106
-    res = minimize(harmonicNorm, np.array((f02)), args=(sN, fs, nK, t), jac='2-point', method='BFGS') #, jac=jacEuler) #, hess=None, bounds=None )
106
+    res = minimize(harmonicNorm, np.array((f0)), args=(sN, fs, nK, t), jac='2-point', method='BFGS') #, jac=jacEuler) #, hess=None, bounds=None )
107 107
     print(res)
108 108
     return harmonicEuler(res.x[0], sN, fs, nK, t)#[0]
109 109
 
@@ -141,7 +141,7 @@ if __name__ == "__main__":
141 141
     phi2 = 2.*np.pi*np.random.rand() - np.pi
142 142
     print("phi", phi, phi2)
143 143
     A =  1.0
144
-    A2 = 1.0 
144
+    A2 = 0.0 
145 145
     A3 = 1.0 
146 146
     nK = 10
147 147
     T2 = .200
@@ -159,10 +159,10 @@ if __name__ == "__main__":
159 159
 
160 160
     # single freq
161 161
     #h = harmonicEuler( f0, sN, fs, nK, t) 
162
-    #h = minHarmonic( f0, sN, fs, nK, t) 
162
+    h = minHarmonic( f0, sN, fs, nK, t) 
163 163
     
164 164
     # two freqs 
165
-    h = minHarmonic2( f0+1e-2, f1-1e-2, sN, fs, nK, t) 
165
+    #h = minHarmonic2( f0+1e-2, f1-1e-2, sN, fs, nK, t) 
166 166
     #h = harmonicEuler2( f0, f1, sN, fs, nK, t) 
167 167
 
168 168
     plt.figure()

+ 22
- 22
akvo/tressel/mrsurvey.py View File

@@ -517,9 +517,9 @@ class GMRDataProcessor(SNMRDataProcessor):
517 517
         canvas.draw()
518 518
         self.doneTrigger.emit() 
519 519
 
520
-    def harmonicModel(self, f0, canvas):
521
-        print("harmonic modelling...", f0)
522
-        plot = True
520
+    def harmonicModel(self, nF, nK, f0, f1, plot, canvas):
521
+        #print("harmonic modelling...", f0)
522
+        #plot = True
523 523
         if plot:
524 524
             canvas.reAx2()
525 525
             canvas.ax1.tick_params(axis='both', which='major', labelsize=8)
@@ -542,7 +542,7 @@ class GMRDataProcessor(SNMRDataProcessor):
542 542
                             canvas.ax1.plot( self.DATADICT[pulse]["TIMES"], 1e9*self.DATADICT[pulse][ichan][ipm][istack], \
543 543
                                 label = "orig " +  pulse + " ipm=" + str(ipm) + " istack=" + str(istack) + " rchan="  + str(ichan))
544 544
 
545
-                        self.DATADICT[pulse][ichan][ipm][istack] = harmonic.minHarmonic( f0, self.DATADICT[pulse][ichan][ipm][istack], self.samp, 20, self.DATADICT[pulse]["TIMES"] ) 
545
+                        self.DATADICT[pulse][ichan][ipm][istack] = harmonic.minHarmonic( f0, self.DATADICT[pulse][ichan][ipm][istack], self.samp, 45, self.DATADICT[pulse]["TIMES"] ) 
546 546
                         #self.DATADICT[pulse][ichan][ipm][istack] = harmonic.minHarmonic2( f0-1e-2, f0+1e-2, self.DATADICT[pulse][ichan][ipm][istack], self.samp, 30, self.DATADICT[pulse]["TIMES"] ) 
547 547
 
548 548
                         # plot
@@ -556,7 +556,7 @@ class GMRDataProcessor(SNMRDataProcessor):
556 556
                             canvas.ax2.plot( self.DATADICT[pulse]["TIMES"], 1e9*self.DATADICT[pulse][ichan][ipm][istack], \
557 557
                                 label = "orig " +  pulse + " ipm=" + str(ipm) + " istack=" + str(istack) + " chan="  + str(ichan))
558 558
                         
559
-                        self.DATADICT[pulse][ichan][ipm][istack] = harmonic.minHarmonic( f0, self.DATADICT[pulse][ichan][ipm][istack], self.samp, 20, self.DATADICT[pulse]["TIMES"] ) 
559
+                        self.DATADICT[pulse][ichan][ipm][istack] = harmonic.minHarmonic( f0, self.DATADICT[pulse][ichan][ipm][istack], self.samp, 45, self.DATADICT[pulse]["TIMES"] ) 
560 560
                         #self.DATADICT[pulse][ichan][ipm][istack] = harmonic.minHarmonic2( f0-1e-2, f0+1e-2, self.DATADICT[pulse][ichan][ipm][istack], self.samp, 30, self.DATADICT[pulse]["TIMES"] ) 
561 561
                         #self.DATADICT[pulse][ichan][ipm][istack] = harmonic.harmonicEuler( f0, self.DATADICT[pulse][ichan][ipm][istack], self.samp, 20, self.DATADICT[pulse]["TIMES"] ) 
562 562
                
@@ -1896,7 +1896,7 @@ class GMRDataProcessor(SNMRDataProcessor):
1896 1896
            
1897 1897
         return [bord, self.fe] 
1898 1898
 
1899
-    def downsample(self, truncate, dec, canvas):
1899
+    def downsample(self, truncate, dec, plot, canvas):
1900 1900
         """ Downsamples and truncates the raw signal. 
1901 1901
         """
1902 1902
         canvas.reAx2()
@@ -1932,24 +1932,24 @@ class GMRDataProcessor(SNMRDataProcessor):
1932 1932
                             self.DATADICT[pulse][ichan][ipm][istack] = self.DATADICT[pulse][ichan][ipm][istack][0:itrunc]
1933 1933
                             RSTIMES = RSTIMES[0:itrunc]
1934 1934
 
1935
-
1936
-                    for ichan in self.DATADICT[pulse]["chan"]:
1937
-                        canvas.ax2.plot( RSTIMES, 1e9*self.DATADICT[pulse][ichan][ipm][istack], \
1938
-                            label = pulse + " ipm=" + str(ipm) + " istack=" + str(istack) + " ichan="  + str(ichan))
1939
-                    for ichan in self.DATADICT[pulse]["rchan"]:
1940
-                        canvas.ax1.plot( RSTIMES, 1e9*self.DATADICT[pulse][ichan][ipm][istack], \
1941
-                            label = pulse + " ipm=" + str(ipm) + " istack=" + str(istack) + " ichan="  + str(ichan))
1935
+                    if plot:
1936
+                        for ichan in self.DATADICT[pulse]["chan"]:
1937
+                            canvas.ax2.plot( RSTIMES, 1e9*self.DATADICT[pulse][ichan][ipm][istack], \
1938
+                                label = pulse + " ipm=" + str(ipm) + " istack=" + str(istack) + " ichan="  + str(ichan))
1939
+                        for ichan in self.DATADICT[pulse]["rchan"]:
1940
+                            canvas.ax1.plot( RSTIMES, 1e9*self.DATADICT[pulse][ichan][ipm][istack], \
1941
+                                label = pulse + " ipm=" + str(ipm) + " istack=" + str(istack) + " ichan="  + str(ichan))
1942 1942
                     
1943
-                    canvas.ax1.set_xlabel(r"time [s]", fontsize=8)
1944
-                    canvas.ax1.set_ylabel(r"signal [nV]", fontsize=8)
1945
-                    canvas.ax2.set_xlabel(r"time [s]", fontsize=8)
1946
-                    canvas.ax2.set_ylabel(r"signal [nV]", fontsize=8)
1943
+                        canvas.ax1.set_xlabel(r"time [s]", fontsize=8)
1944
+                        canvas.ax1.set_ylabel(r"signal [nV]", fontsize=8)
1945
+                        canvas.ax2.set_xlabel(r"time [s]", fontsize=8)
1946
+                        canvas.ax2.set_ylabel(r"signal [nV]", fontsize=8)
1947 1947
                     
1948
-                    canvas.ax1.legend(prop={'size':6})
1949
-                    canvas.ax2.legend(prop={'size':6})
1950
-                    canvas.ax1.ticklabel_format(style='sci', scilimits=(0,0), axis='y') 
1951
-                    canvas.ax2.ticklabel_format(style='sci', scilimits=(0,0), axis='y') 
1952
-                    canvas.draw() 
1948
+                        canvas.ax1.legend(prop={'size':6})
1949
+                        canvas.ax2.legend(prop={'size':6})
1950
+                        canvas.ax1.ticklabel_format(style='sci', scilimits=(0,0), axis='y') 
1951
+                        canvas.ax2.ticklabel_format(style='sci', scilimits=(0,0), axis='y') 
1952
+                        canvas.draw() 
1953 1953
                 percent = (int)(1e2*((float)(iFID*self.DATADICT["nPulseMoments"]+(ipm))/( len(self.DATADICT["PULSES"])*self.nPulseMoments)))
1954 1954
                 self.progressTrigger.emit(percent)
1955 1955
             iFID += 1  

Loading…
Cancel
Save