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
             #self.ui.logTextBrowser.append( yaml.dump(self.YamlNode)) #, default_flow_style=False)  )
768
             #self.ui.logTextBrowser.append( yaml.dump(self.YamlNode)) #, default_flow_style=False)  )
769
         #except KeyError:
769
         #except KeyError:
770
         #    pass
770
         #    pass
771
-       
772
         # Remove "Saved" and "Loaded" from processing flow 
771
         # Remove "Saved" and "Loaded" from processing flow 
773
         #if "Loaded" not in self.YamlNode.Processing.keys():
772
         #if "Loaded" not in self.YamlNode.Processing.keys():
774
         #    self.YamlNode.Processing["Loaded"] = []
773
         #    self.YamlNode.Processing["Loaded"] = []
783
         self.ui.lcdNumberNQ.setEnabled(True)
782
         self.ui.lcdNumberNQ.setEnabled(True)
784
 
783
 
785
         self.ui.headerFileBox.setEnabled(True)
784
         self.ui.headerFileBox.setEnabled(True)
786
-        self.ui.headerFileBox.setChecked( False )
785
+        self.ui.headerFileBox.setChecked( True )
786
+        self.headerBoxShrink() 
787
         #self.ui.headerBox2.setVisible(True) 
787
         #self.ui.headerBox2.setVisible(True) 
788
-        self.ui.inputRAWParametersBox.setEnabled(True)
788
+        self.ui.inputRAWParametersBox.setEnabled(False)
789
         self.ui.loadDataPushButton.setEnabled(True)
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
         self.ui.plotImportCheckBox.setEnabled(True)
792
         self.ui.plotImportCheckBox.setEnabled(True)
793
         self.ui.plotImportCheckBox.setChecked(True)
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
         # Update info from the header into the GUI
807
         # Update info from the header into the GUI
796
         self.ui.pulseTypeTextBrowser.clear()
808
         self.ui.pulseTypeTextBrowser.clear()
798
         self.ui.lcdNumberNuTx.display(self.RAWDataProc.transFreq)
810
         self.ui.lcdNumberNuTx.display(self.RAWDataProc.transFreq)
799
         self.ui.lcdNumberTauPulse1.display(1e3*self.RAWDataProc.pulseLength[0])
811
         self.ui.lcdNumberTauPulse1.display(1e3*self.RAWDataProc.pulseLength[0])
800
         self.ui.lcdNumberTuneuF.display(self.RAWDataProc.TuneCapacitance)
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
         self.ui.lcdNumberNQ.display(self.RAWDataProc.nPulseMoments)
815
         self.ui.lcdNumberNQ.display(self.RAWDataProc.nPulseMoments)
803
         self.ui.DeadTimeSpinBox.setValue(1e3*self.RAWDataProc.deadTime)
816
         self.ui.DeadTimeSpinBox.setValue(1e3*self.RAWDataProc.deadTime)
804
         self.ui.CentralVSpinBox.setValue( self.RAWDataProc.transFreq )
817
         self.ui.CentralVSpinBox.setValue( self.RAWDataProc.transFreq )
948
         self.ui.logTextBrowser.append( yaml.dump(self.YamlNode)) #, default_flow_style=False)  )
961
         self.ui.logTextBrowser.append( yaml.dump(self.YamlNode)) #, default_flow_style=False)  )
949
 
962
 
950
     def disable(self):
963
     def disable(self):
964
+        self.ui.inputRAWParametersBox.setEnabled(False)
951
         self.ui.BandPassBox.setEnabled(False)
965
         self.ui.BandPassBox.setEnabled(False)
952
         self.ui.downSampleGroupBox.setEnabled(False)
966
         self.ui.downSampleGroupBox.setEnabled(False)
953
         self.ui.windowFilterGroupBox.setEnabled(False)
967
         self.ui.windowFilterGroupBox.setEnabled(False)
991
         
1005
         
992
         # FD Adaptive filtering 
1006
         # FD Adaptive filtering 
993
         self.ui.adaptFDBox.setEnabled(True)
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
         # sum group box
1014
         # sum group box
997
         try:
1015
         try:
1067
     def harmonicModel(self):
1085
     def harmonicModel(self):
1068
         self.lock("harmonic noise modelling")
1086
         self.lock("harmonic noise modelling")
1069
         thread.start_new_thread(self.RAWDataProc.harmonicModel, \
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
     def FDSmartStack(self):
1097
     def FDSmartStack(self):
1074
 
1098
 
1171
         
1195
         
1172
         thread.start_new_thread(self.RAWDataProc.downsample, \
1196
         thread.start_new_thread(self.RAWDataProc.downsample, \
1173
                 (self.ui.truncateSpinBox.value(), \
1197
                 (self.ui.truncateSpinBox.value(), \
1174
-                self.ui.downSampleSpinBox.value(),
1198
+                self.ui.downSampleSpinBox.value(), \
1199
+                self.ui.dsPlot.isChecked(), \
1175
                 self.ui.mplwidget))
1200
                 self.ui.mplwidget))
1176
 
1201
 
1177
     def quadDet(self):
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
         t = time samples 
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
     v = np.linalg.lstsq(A, sN, rcond=None) 
20
     v = np.linalg.lstsq(A, sN, rcond=None) 
21
     alpha = np.real(v[0]) 
21
     alpha = np.real(v[0]) 
26
 
26
 
27
     h = np.zeros(len(t))
27
     h = np.zeros(len(t))
28
     for ik in range(nK):
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
     return sN-h
31
     return sN-h
32
     
32
     
75
         nK = number of harmonics to calculate 
75
         nK = number of harmonics to calculate 
76
         t = time samples 
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
     A = np.concatenate( (A1, A2), axis=1 )
80
     A = np.concatenate( (A1, A2), axis=1 )
81
 
81
 
82
 
82
 
88
 
88
 
89
     h = np.zeros(len(t))
89
     h = np.zeros(len(t))
90
     for ik in range(nK):
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
     return sN-h
94
     return sN-h
95
 
95
 
103
     f02 = guessf0(sN, fs)
103
     f02 = guessf0(sN, fs)
104
     print("minHarmonic", f0, fs, nK, " guess=", f02)
104
     print("minHarmonic", f0, fs, nK, " guess=", f02)
105
     # CG, BFGS, Newton-CG, L-BFGS-B, TNC, SLSQP, dogleg, trust-ncg, trust-krylov, trust-exact and trust-constr
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
     print(res)
107
     print(res)
108
     return harmonicEuler(res.x[0], sN, fs, nK, t)#[0]
108
     return harmonicEuler(res.x[0], sN, fs, nK, t)#[0]
109
 
109
 
141
     phi2 = 2.*np.pi*np.random.rand() - np.pi
141
     phi2 = 2.*np.pi*np.random.rand() - np.pi
142
     print("phi", phi, phi2)
142
     print("phi", phi, phi2)
143
     A =  1.0
143
     A =  1.0
144
-    A2 = 1.0 
144
+    A2 = 0.0 
145
     A3 = 1.0 
145
     A3 = 1.0 
146
     nK = 10
146
     nK = 10
147
     T2 = .200
147
     T2 = .200
159
 
159
 
160
     # single freq
160
     # single freq
161
     #h = harmonicEuler( f0, sN, fs, nK, t) 
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
     # two freqs 
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
     #h = harmonicEuler2( f0, f1, sN, fs, nK, t) 
166
     #h = harmonicEuler2( f0, f1, sN, fs, nK, t) 
167
 
167
 
168
     plt.figure()
168
     plt.figure()

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

517
         canvas.draw()
517
         canvas.draw()
518
         self.doneTrigger.emit() 
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
         if plot:
523
         if plot:
524
             canvas.reAx2()
524
             canvas.reAx2()
525
             canvas.ax1.tick_params(axis='both', which='major', labelsize=8)
525
             canvas.ax1.tick_params(axis='both', which='major', labelsize=8)
542
                             canvas.ax1.plot( self.DATADICT[pulse]["TIMES"], 1e9*self.DATADICT[pulse][ichan][ipm][istack], \
542
                             canvas.ax1.plot( self.DATADICT[pulse]["TIMES"], 1e9*self.DATADICT[pulse][ichan][ipm][istack], \
543
                                 label = "orig " +  pulse + " ipm=" + str(ipm) + " istack=" + str(istack) + " rchan="  + str(ichan))
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
                         #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"] ) 
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
                         # plot
548
                         # plot
556
                             canvas.ax2.plot( self.DATADICT[pulse]["TIMES"], 1e9*self.DATADICT[pulse][ichan][ipm][istack], \
556
                             canvas.ax2.plot( self.DATADICT[pulse]["TIMES"], 1e9*self.DATADICT[pulse][ichan][ipm][istack], \
557
                                 label = "orig " +  pulse + " ipm=" + str(ipm) + " istack=" + str(istack) + " chan="  + str(ichan))
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
                         #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"] ) 
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
                         #self.DATADICT[pulse][ichan][ipm][istack] = harmonic.harmonicEuler( f0, self.DATADICT[pulse][ichan][ipm][istack], self.samp, 20, self.DATADICT[pulse]["TIMES"] ) 
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
            
1896
            
1897
         return [bord, self.fe] 
1897
         return [bord, self.fe] 
1898
 
1898
 
1899
-    def downsample(self, truncate, dec, canvas):
1899
+    def downsample(self, truncate, dec, plot, canvas):
1900
         """ Downsamples and truncates the raw signal. 
1900
         """ Downsamples and truncates the raw signal. 
1901
         """
1901
         """
1902
         canvas.reAx2()
1902
         canvas.reAx2()
1932
                             self.DATADICT[pulse][ichan][ipm][istack] = self.DATADICT[pulse][ichan][ipm][istack][0:itrunc]
1932
                             self.DATADICT[pulse][ichan][ipm][istack] = self.DATADICT[pulse][ichan][ipm][istack][0:itrunc]
1933
                             RSTIMES = RSTIMES[0:itrunc]
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
                 percent = (int)(1e2*((float)(iFID*self.DATADICT["nPulseMoments"]+(ipm))/( len(self.DATADICT["PULSES"])*self.nPulseMoments)))
1953
                 percent = (int)(1e2*((float)(iFID*self.DATADICT["nPulseMoments"]+(ipm))/( len(self.DATADICT["PULSES"])*self.nPulseMoments)))
1954
                 self.progressTrigger.emit(percent)
1954
                 self.progressTrigger.emit(percent)
1955
             iFID += 1  
1955
             iFID += 1  

Loading…
Cancel
Save