Browse Source

v1.2.7

tags/1.6.1
Trevor Irons 5 years ago
parent
commit
d02c8fc0d0
3 changed files with 55 additions and 20 deletions
  1. 6
    1
      akvo/gui/akvoGUI.py
  2. 22
    19
      akvo/tressel/mrsurvey.py
  3. 27
    0
      akvo/tressel/rotate.py

+ 6
- 1
akvo/gui/akvoGUI.py View File

726
         # Add some extra info 
726
         # Add some extra info 
727
         INFO = {}
727
         INFO = {}
728
         INFO["pulseType"] = self.RAWDataProc.pulseType
728
         INFO["pulseType"] = self.RAWDataProc.pulseType
729
+        INFO["prePulseDelay"] = self.RAWDataProc.prePulseDelay
729
         INFO["interpulseDelay"] = self.RAWDataProc.interpulseDelay
730
         INFO["interpulseDelay"] = self.RAWDataProc.interpulseDelay
730
         INFO["transFreq"] = self.RAWDataProc.transFreq
731
         INFO["transFreq"] = self.RAWDataProc.transFreq
731
         INFO["pulseLength"] = self.RAWDataProc.pulseLength
732
         INFO["pulseLength"] = self.RAWDataProc.pulseLength
791
         self.RAWDataProc.deadTime = self.RAWDataProc.DATADICT["INFO"]["deadTime"] 
792
         self.RAWDataProc.deadTime = self.RAWDataProc.DATADICT["INFO"]["deadTime"] 
792
         self.RAWDataProc.transFreq = self.RAWDataProc.DATADICT["INFO"]["transFreq"]
793
         self.RAWDataProc.transFreq = self.RAWDataProc.DATADICT["INFO"]["transFreq"]
793
         self.RAWDataProc.nDAQVersion = self.RAWDataProc.DATADICT["INFO"]["nDAQVersion"]
794
         self.RAWDataProc.nDAQVersion = self.RAWDataProc.DATADICT["INFO"]["nDAQVersion"]
795
+        #self.RAWDataProc.prePulseDelay = self.RAWDataProc.DATADICT["INFO"]["prePulseDelay"]
794
         self.RAWDataProc.dt = 1./self.RAWDataProc.samp 
796
         self.RAWDataProc.dt = 1./self.RAWDataProc.samp 
795
 
797
 
796
         self.dataChan = self.RAWDataProc.DATADICT[ self.RAWDataProc.DATADICT["PULSES"][0] ]["chan"]
798
         self.dataChan = self.RAWDataProc.DATADICT[ self.RAWDataProc.DATADICT["PULSES"][0] ]["chan"]
851
         self.ui.lcdTotalDeadTime.setEnabled(1)
853
         self.ui.lcdTotalDeadTime.setEnabled(1)
852
         
854
         
853
         #self.ui.lcdTotalDeadTime.display( 1e3*self.RAWDataProc.DATADICT["INFO"]["deadTime"] )
855
         #self.ui.lcdTotalDeadTime.display( 1e3*self.RAWDataProc.DATADICT["INFO"]["deadTime"] )
854
-        self.ui.lcdTotalDeadTime.display( 1e3 * (self.RAWDataProc.DATADICT["Pulse 1"]["TIMES"][0]-self.RAWDataProc.DATADICT["Pulse 1"]["PULSE_TIMES"][-1]) )
855
 
856
 
856
         self.ui.headerFileTextBrowser.clear( ) 
857
         self.ui.headerFileTextBrowser.clear( ) 
857
         self.ui.headerFileTextBrowser.append( self.RAWDataProc.DATADICT["INFO"]["headerstr"] )
858
         self.ui.headerFileTextBrowser.append( self.RAWDataProc.DATADICT["INFO"]["headerstr"] )
858
         
859
         
859
         if u"Pulse 1" in self.RAWDataProc.DATADICT.keys():
860
         if u"Pulse 1" in self.RAWDataProc.DATADICT.keys():
860
             self.ui.lcdNumberFID1Length.display(self.RAWDataProc.DATADICT["Pulse 1"]["TIMES"][-1]- self.RAWDataProc.DATADICT["Pulse 1"]["TIMES"][0])
861
             self.ui.lcdNumberFID1Length.display(self.RAWDataProc.DATADICT["Pulse 1"]["TIMES"][-1]- self.RAWDataProc.DATADICT["Pulse 1"]["TIMES"][0])
862
+            self.ui.lcdTotalDeadTime.display( round(1e3*(self.RAWDataProc.DATADICT["Pulse 1"]["TIMES"][0]-self.RAWDataProc.DATADICT["Pulse 1"]["PULSE_TIMES"][-1]), 3) )
863
+            print("CALC DEAD",    (1e3*(self.RAWDataProc.prePulseDelay))) # -  (self.RAWDataProc.DATADICT["Pulse 1"]["TIMES"][0]-self.RAWDataProc.DATADICT["Pulse 1"]["PULSE_TIMES"][-1])), 3) )
861
         if u"Pulse 2" in self.RAWDataProc.DATADICT.keys():
864
         if u"Pulse 2" in self.RAWDataProc.DATADICT.keys():
862
             self.ui.lcdNumberFID1Length.display(self.RAWDataProc.DATADICT["Pulse 2"]["TIMES"][-1]- self.RAWDataProc.DATADICT["Pulse 2"]["TIMES"][0])
865
             self.ui.lcdNumberFID1Length.display(self.RAWDataProc.DATADICT["Pulse 2"]["TIMES"][-1]- self.RAWDataProc.DATADICT["Pulse 2"]["TIMES"][0])
866
+            self.ui.lcdTotalDeadTime.display( 1e3 * (self.RAWDataProc.DATADICT["Pulse 2"]["TIMES"][0]-self.RAWDataProc.DATADICT["Pulse 2"]["PULSE_TIMES"][-1]) )
863
  
867
  
864
         # Update info from the header into the GUI
868
         # Update info from the header into the GUI
865
         self.ui.pulseTypeTextBrowser.clear()
869
         self.ui.pulseTypeTextBrowser.clear()
1009
         self.ui.lcdTotalDeadTime.setEnabled(1)
1013
         self.ui.lcdTotalDeadTime.setEnabled(1)
1010
 
1014
 
1011
         self.ui.lcdTotalDeadTime.display( self.ui.DeadTimeSpinBox.value( ) )
1015
         self.ui.lcdTotalDeadTime.display( self.ui.DeadTimeSpinBox.value( ) )
1016
+        #self.ui.lcdTotalDeadTime.display( round(1e3*(self.RAWDataProc.DATADICT["Pulse 1"]["TIMES"][0]-self.RAWDataProc.DATADICT["Pulse 1"]["PULSE_TIMES"][-1]), 3) )
1012
         
1017
         
1013
         #self.ui.lcdNumberFID1Length.display(0)
1018
         #self.ui.lcdNumberFID1Length.display(0)
1014
         #self.ui.lcdNumberFID2Length.display(0)
1019
         #self.ui.lcdNumberFID2Length.display(0)

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

1039
                                        (float)(self.DATADICT["nPulseMoments"] * len(self.DATADICT[pulse]["chan"])))
1039
                                        (float)(self.DATADICT["nPulseMoments"] * len(self.DATADICT[pulse]["chan"])))
1040
                     self.progressTrigger.emit(percent)
1040
                     self.progressTrigger.emit(percent)
1041
                 ichan += 1
1041
                 ichan += 1
1042
+            self.DATADICT[pulse]["TIMES"] = self.DATADICT[pulse]["TIMES"][clip::]
1042
 
1043
 
1043
         self.DATADICT["CA"] = CA
1044
         self.DATADICT["CA"] = CA
1044
         self.DATADICT["IP"] = IP
1045
         self.DATADICT["IP"] = IP
1067
             axes = canvas.fig.axes
1068
             axes = canvas.fig.axes
1068
             mmaxr = 0.
1069
             mmaxr = 0.
1069
             mmaxi = 0.
1070
             mmaxi = 0.
1070
-            if clip > 0:
1071
-                time_sp =  1e3 * (self.DATADICT[pulse]["TIMES"][clip-1::] - self.DATADICT[pulse]["PULSE_TIMES"][-1] )
1072
-            else:
1073
-                time_sp =  1e3 * (self.DATADICT[pulse]["TIMES"] - self.DATADICT[pulse]["PULSE_TIMES"][-1] )
1071
+            #if clip > 0:
1072
+            #    time_sp =  1e3 * (self.DATADICT[pulse]["TIMES"][clip-1::] - self.DATADICT[pulse]["PULSE_TIMES"][-1] )
1073
+            #else:
1074
+            #    time_sp =  1e3 * (self.DATADICT[pulse]["TIMES"] - self.DATADICT[pulse]["PULSE_TIMES"][-1] )
1075
+            time_sp =  1e3 * (self.DATADICT[pulse]["TIMES"] - self.DATADICT[pulse]["PULSE_TIMES"][-1] )
1074
                 
1076
                 
1075
             QQ = np.average(self.DATADICT[pulse]["Q"], axis=1 )
1077
             QQ = np.average(self.DATADICT[pulse]["Q"], axis=1 )
1076
  
1078
  
1257
                 if self.GATED[chan]["isum"][it] < 8:
1259
                 if self.GATED[chan]["isum"][it] < 8:
1258
                     XS[ii, it] = self.sigma[pulse][chan]
1260
                     XS[ii, it] = self.sigma[pulse][chan]
1259
                 else:
1261
                 else:
1260
-                                
1261
                     if it == 0:                
1262
                     if it == 0:                
1262
-                        X = self.bootstrap_resample( np.concatenate( (self.GATED[chan]["NR"][:,it], self.GATED[chan]["NR"][:,it+1], \
1263
-                            self.GATED[chan]["NR"][:,it+2], self.GATED[chan]["NR"][:,it+3] ) ), n=nt )
1263
+                        X = self.bootstrap_resample( np.concatenate( (self.GATED[chan]["NR"][:,it],   \
1264
+                                                                      self.GATED[chan]["NR"][:,it+1], \
1265
+                                                                      self.GATED[chan]["NR"][:,it+2], \
1266
+                                                                      self.GATED[chan]["NR"][:,it+3] ) ), n=nt )
1264
                     elif it == 1:                
1267
                     elif it == 1:                
1265
                         X = self.bootstrap_resample( np.concatenate( (self.GATED[chan]["NR"][:,it-1], self.GATED[chan]["NR"][:,it], \
1268
                         X = self.bootstrap_resample( np.concatenate( (self.GATED[chan]["NR"][:,it-1], self.GATED[chan]["NR"][:,it], \
1266
                             self.GATED[chan]["NR"][:,it+1], self.GATED[chan]["NR"][:,it+2] ) ), n=nt )
1269
                             self.GATED[chan]["NR"][:,it+1], self.GATED[chan]["NR"][:,it+2] ) ), n=nt )
1282
         
1285
         
1283
         canvas.reAxH2(  len(self.DATADICT[ self.DATADICT["PULSES"][0] ]["chan"] ), False, False)
1286
         canvas.reAxH2(  len(self.DATADICT[ self.DATADICT["PULSES"][0] ]["chan"] ), False, False)
1284
         axes = canvas.fig.axes
1287
         axes = canvas.fig.axes
1285
-        cmap = cmocean.cm.balance_r 
1288
+        #cmap = cmocean.cm.balance_r 
1289
+        dcmap = cmocean.cm.curl_r  #"seismic_r" #cmocean.cm.balance_r #"RdBu" #YlGn" # "coolwarm_r"  # diverging 
1286
     
1290
     
1287
         # Calculate maximum for plotting...TODO move into loop above
1291
         # Calculate maximum for plotting...TODO move into loop above
1288
         vmax1 = 0
1292
         vmax1 = 0
1308
                 ax2 = axes[2*ichan+1] 
1312
                 ax2 = axes[2*ichan+1] 
1309
                 
1313
                 
1310
                 if phase == 0:
1314
                 if phase == 0:
1311
-                    im1 = ax1.pcolormesh(self.GATED[chan]["GTT"], self.GATED[chan]["QQ"], self.GATED[chan]["RE"], cmap=cmap, vmin=-vmax1, vmax=vmax1)
1312
-                    im2 = ax2.pcolormesh(self.GATED[chan]["GTT"], self.GATED[chan]["QQ"], self.GATED[chan]["IM"], cmap=cmap, vmin=-vmax2, vmax=vmax2)
1315
+                    im1 = ax1.pcolormesh(self.GATED[chan]["GTT"], self.GATED[chan]["QQ"], self.GATED[chan]["RE"], cmap=dcmap, vmin=-vmax1, vmax=vmax1)
1316
+                    im2 = ax2.pcolormesh(self.GATED[chan]["GTT"], self.GATED[chan]["QQ"], self.GATED[chan]["IM"], cmap=dcmap, vmin=-vmax2, vmax=vmax2)
1313
                 elif phase == 1:
1317
                 elif phase == 1:
1314
-                    im1 = ax1.pcolormesh(self.GATED[chan]["GTT"], self.GATED[chan]["QQ"], self.GATED[chan]["CA"], cmap=cmap, vmin=-vmax1, vmax=vmax1)
1315
-                    im2 = ax2.pcolormesh(self.GATED[chan]["GTT"], self.GATED[chan]["QQ"], self.GATED[chan]["IP"], cmap=cmocean.cm.balance, vmin=-vmax2, vmax=vmax2)
1318
+                    im1 = ax1.pcolormesh(self.GATED[chan]["GTT"], self.GATED[chan]["QQ"], self.GATED[chan]["CA"], cmap=dcmap, vmin=-vmax1, vmax=vmax1)
1319
+                    im2 = ax2.pcolormesh(self.GATED[chan]["GTT"], self.GATED[chan]["QQ"], self.GATED[chan]["IP"], cmap=cmocean.cm.delta, vmin=-vmax2, vmax=vmax2)
1316
                     #im2 = ax2.pcolormesh(self.GATED[chan]["GTT"], self.GATED[chan]["QQ"], self.GATED[chan]["IP"], cmap=cmocean.cm.phase, vmin=-vmax2, vmax=vmax2)
1320
                     #im2 = ax2.pcolormesh(self.GATED[chan]["GTT"], self.GATED[chan]["QQ"], self.GATED[chan]["IP"], cmap=cmocean.cm.phase, vmin=-vmax2, vmax=vmax2)
1317
                 elif phase == 2:
1321
                 elif phase == 2:
1318
-                    im1 = ax1.pcolormesh(self.GATED[chan]["GTT"], self.GATED[chan]["QQ"], self.GATED[chan]["CA"], cmap=cmap, vmin=-vmax1, vmax=vmax1)
1322
+                    im1 = ax1.pcolormesh(self.GATED[chan]["GTT"], self.GATED[chan]["QQ"], self.GATED[chan]["CA"], cmap=dcmap, vmin=-vmax1, vmax=vmax1)
1319
                     XS = self.bootstrap_sigma(pulse, chan)
1323
                     XS = self.bootstrap_sigma(pulse, chan)
1320
                     #im2 = ax2.pcolormesh(self.GATED[chan]["GTT"], self.GATED[chan]["QQ"], self.GATED[chan]["NR"], cmap=cmap, vmin=-vmax2, vmax=vmax2)
1324
                     #im2 = ax2.pcolormesh(self.GATED[chan]["GTT"], self.GATED[chan]["QQ"], self.GATED[chan]["NR"], cmap=cmap, vmin=-vmax2, vmax=vmax2)
1321
                     # bootstrap resample
1325
                     # bootstrap resample
1358
                 if phase != 2:
1362
                 if phase != 2:
1359
                     im2.set_edgecolor('face')
1363
                     im2.set_edgecolor('face')
1360
 
1364
 
1361
-
1362
                 plt.setp(ax1.get_xticklabels(), visible=False)
1365
                 plt.setp(ax1.get_xticklabels(), visible=False)
1363
         
1366
         
1364
                 ax1.set_ylim( np.min(self.GATED[chan]["QQ"]), np.max(self.GATED[chan]["QQ"]) )
1367
                 ax1.set_ylim( np.min(self.GATED[chan]["QQ"]), np.max(self.GATED[chan]["QQ"]) )
1379
                 #formatter = matplotlib.ticker.LogFormatter(10, labelOnlyBase=False)
1382
                 #formatter = matplotlib.ticker.LogFormatter(10, labelOnlyBase=False)
1380
                 formatter = matplotlib.ticker.FuncFormatter(lambda x, pos: str((round(x,1)))) 
1383
                 formatter = matplotlib.ticker.FuncFormatter(lambda x, pos: str((round(x,1)))) 
1381
                 
1384
                 
1385
+                ax1.set_xscale('log')
1386
+                ax2.set_xscale('log')
1387
+                
1382
                 ax1.yaxis.set_major_formatter(formatter) #matplotlib.ticker.FormatStrFormatter('%d.1'))
1388
                 ax1.yaxis.set_major_formatter(formatter) #matplotlib.ticker.FormatStrFormatter('%d.1'))
1383
                 ax2.yaxis.set_major_formatter(formatter) #matplotlib.ticker.FormatStrFormatter('%d.1'))
1389
                 ax2.yaxis.set_major_formatter(formatter) #matplotlib.ticker.FormatStrFormatter('%d.1'))
1384
 
1390
 
1385
                 ax1.xaxis.set_major_formatter(formatter) #matplotlib.ticker.FormatStrFormatter('%d.1'))
1391
                 ax1.xaxis.set_major_formatter(formatter) #matplotlib.ticker.FormatStrFormatter('%d.1'))
1386
                 ax2.xaxis.set_major_formatter(formatter) #matplotlib.ticker.FormatStrFormatter('%d.1'))
1392
                 ax2.xaxis.set_major_formatter(formatter) #matplotlib.ticker.FormatStrFormatter('%d.1'))
1387
                 
1393
                 
1388
-                ax1.set_xscale('log')
1389
-                ax2.set_xscale('log')
1390
-                
1391
                 if ichan == 0:
1394
                 if ichan == 0:
1392
                     ax1.set_ylabel(r"$q$ ( $\mathrm{A}\cdot\mathrm{s}$)", fontsize=8)
1395
                     ax1.set_ylabel(r"$q$ ( $\mathrm{A}\cdot\mathrm{s}$)", fontsize=8)
1393
                     if phase == 2:
1396
                     if phase == 2:
1410
         cb1 = canvas.fig.colorbar(im1, ax=axes[0::2], format='%1.0e', orientation='horizontal', shrink=.35, aspect=30)
1413
         cb1 = canvas.fig.colorbar(im1, ax=axes[0::2], format='%1.0e', orientation='horizontal', shrink=.35, aspect=30)
1411
         cb1.ax.tick_params(axis='both', which='major', labelsize=8)
1414
         cb1.ax.tick_params(axis='both', which='major', labelsize=8)
1412
         cb1.set_label("$\mathcal{V}_N$ (nV)", fontsize=8)
1415
         cb1.set_label("$\mathcal{V}_N$ (nV)", fontsize=8)
1413
-        cb1.locator = tick_locator
1414
-        cb1.update_ticks()
1416
+        #cb1.locator = tick_locator
1417
+        #cb1.update_ticks()
1415
 
1418
 
1416
         if phase != 2:
1419
         if phase != 2:
1417
             cb2 = canvas.fig.colorbar(im2, ax=axes[1::2], format='%1.0e', orientation='horizontal', shrink=.35, aspect=30, pad=.2)
1420
             cb2 = canvas.fig.colorbar(im2, ax=axes[1::2], format='%1.0e', orientation='horizontal', shrink=.35, aspect=30, pad=.2)

+ 27
- 0
akvo/tressel/rotate.py View File

128
     return np.abs(V) * np.exp( 1j * ( np.angle(V) - zeta - 2.*np.pi*df*t ) )
128
     return np.abs(V) * np.exp( 1j * ( np.angle(V) - zeta - 2.*np.pi*df*t ) )
129
     #return np.abs(V) * np.exp( 1j * ( np.angle(V) - zeta - df*t ) )
129
     #return np.abs(V) * np.exp( 1j * ( np.angle(V) - zeta - df*t ) )
130
 
130
 
131
+def bootstrapWindows(N, nboot, isum, adapt=False):
132
+    """ Bootstraps noise as a function of gate width
133
+        N = input noise signal 
134
+        nboot = number of boostrap windows to perform 
135
+        isum = length of windows (L_i)
136
+        adapt = reduce nboot as window size increases
137
+    """
138
+    nc = np.shape(N)[0]
139
+    Means = {}
140
+
141
+    if adapt:
142
+        Means = -9999*np.ones((len(isum), nboot//isum[0])) # dummy value
143
+        for ii, nwin in enumerate(isum):  
144
+            for iboot in range(nboot//isum[ii]):
145
+                cs = np.random.randint(0,nc-nwin)
146
+                Means[ii,iboot] = np.mean( N[cs:cs+nwin] )
147
+        Means = np.ma.masked_less(Means, -9995)
148
+
149
+    else:
150
+        Means = np.zeros((len(isum), nboot))
151
+        for ii, nwin in enumerate(isum):  
152
+            for iboot in range(nboot):
153
+                cs = np.random.randint(0,nc-nwin)
154
+                Means[ii,iboot] = np.mean( N[cs:cs+nwin] )
155
+
156
+    return Means, np.array(isum)
157
+
131
 def gateIntegrate(T2D, T2T, gpd, sigma, stackEfficiency=2.):
158
 def gateIntegrate(T2D, T2T, gpd, sigma, stackEfficiency=2.):
132
     """ Gate integrate the signal to gpd, gates per decade
159
     """ Gate integrate the signal to gpd, gates per decade
133
         T2D = the time series to gate integrate, complex 
160
         T2D = the time series to gate integrate, complex 

Loading…
Cancel
Save