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,6 +726,7 @@ class ApplicationWindow(QtWidgets.QMainWindow):
726 726
         # Add some extra info 
727 727
         INFO = {}
728 728
         INFO["pulseType"] = self.RAWDataProc.pulseType
729
+        INFO["prePulseDelay"] = self.RAWDataProc.prePulseDelay
729 730
         INFO["interpulseDelay"] = self.RAWDataProc.interpulseDelay
730 731
         INFO["transFreq"] = self.RAWDataProc.transFreq
731 732
         INFO["pulseLength"] = self.RAWDataProc.pulseLength
@@ -791,6 +792,7 @@ class ApplicationWindow(QtWidgets.QMainWindow):
791 792
         self.RAWDataProc.deadTime = self.RAWDataProc.DATADICT["INFO"]["deadTime"] 
792 793
         self.RAWDataProc.transFreq = self.RAWDataProc.DATADICT["INFO"]["transFreq"]
793 794
         self.RAWDataProc.nDAQVersion = self.RAWDataProc.DATADICT["INFO"]["nDAQVersion"]
795
+        #self.RAWDataProc.prePulseDelay = self.RAWDataProc.DATADICT["INFO"]["prePulseDelay"]
794 796
         self.RAWDataProc.dt = 1./self.RAWDataProc.samp 
795 797
 
796 798
         self.dataChan = self.RAWDataProc.DATADICT[ self.RAWDataProc.DATADICT["PULSES"][0] ]["chan"]
@@ -851,15 +853,17 @@ class ApplicationWindow(QtWidgets.QMainWindow):
851 853
         self.ui.lcdTotalDeadTime.setEnabled(1)
852 854
         
853 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 857
         self.ui.headerFileTextBrowser.clear( ) 
857 858
         self.ui.headerFileTextBrowser.append( self.RAWDataProc.DATADICT["INFO"]["headerstr"] )
858 859
         
859 860
         if u"Pulse 1" in self.RAWDataProc.DATADICT.keys():
860 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 864
         if u"Pulse 2" in self.RAWDataProc.DATADICT.keys():
862 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 868
         # Update info from the header into the GUI
865 869
         self.ui.pulseTypeTextBrowser.clear()
@@ -1009,6 +1013,7 @@ class ApplicationWindow(QtWidgets.QMainWindow):
1009 1013
         self.ui.lcdTotalDeadTime.setEnabled(1)
1010 1014
 
1011 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 1018
         #self.ui.lcdNumberFID1Length.display(0)
1014 1019
         #self.ui.lcdNumberFID2Length.display(0)

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

@@ -1039,6 +1039,7 @@ class GMRDataProcessor(SNMRDataProcessor):
1039 1039
                                        (float)(self.DATADICT["nPulseMoments"] * len(self.DATADICT[pulse]["chan"])))
1040 1040
                     self.progressTrigger.emit(percent)
1041 1041
                 ichan += 1
1042
+            self.DATADICT[pulse]["TIMES"] = self.DATADICT[pulse]["TIMES"][clip::]
1042 1043
 
1043 1044
         self.DATADICT["CA"] = CA
1044 1045
         self.DATADICT["IP"] = IP
@@ -1067,10 +1068,11 @@ class GMRDataProcessor(SNMRDataProcessor):
1067 1068
             axes = canvas.fig.axes
1068 1069
             mmaxr = 0.
1069 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 1077
             QQ = np.average(self.DATADICT[pulse]["Q"], axis=1 )
1076 1078
  
@@ -1257,10 +1259,11 @@ class GMRDataProcessor(SNMRDataProcessor):
1257 1259
                 if self.GATED[chan]["isum"][it] < 8:
1258 1260
                     XS[ii, it] = self.sigma[pulse][chan]
1259 1261
                 else:
1260
-                                
1261 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 1267
                     elif it == 1:                
1265 1268
                         X = self.bootstrap_resample( np.concatenate( (self.GATED[chan]["NR"][:,it-1], self.GATED[chan]["NR"][:,it], \
1266 1269
                             self.GATED[chan]["NR"][:,it+1], self.GATED[chan]["NR"][:,it+2] ) ), n=nt )
@@ -1282,7 +1285,8 @@ class GMRDataProcessor(SNMRDataProcessor):
1282 1285
         
1283 1286
         canvas.reAxH2(  len(self.DATADICT[ self.DATADICT["PULSES"][0] ]["chan"] ), False, False)
1284 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 1291
         # Calculate maximum for plotting...TODO move into loop above
1288 1292
         vmax1 = 0
@@ -1308,14 +1312,14 @@ class GMRDataProcessor(SNMRDataProcessor):
1308 1312
                 ax2 = axes[2*ichan+1] 
1309 1313
                 
1310 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 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 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 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 1323
                     XS = self.bootstrap_sigma(pulse, chan)
1320 1324
                     #im2 = ax2.pcolormesh(self.GATED[chan]["GTT"], self.GATED[chan]["QQ"], self.GATED[chan]["NR"], cmap=cmap, vmin=-vmax2, vmax=vmax2)
1321 1325
                     # bootstrap resample
@@ -1358,7 +1362,6 @@ class GMRDataProcessor(SNMRDataProcessor):
1358 1362
                 if phase != 2:
1359 1363
                     im2.set_edgecolor('face')
1360 1364
 
1361
-
1362 1365
                 plt.setp(ax1.get_xticklabels(), visible=False)
1363 1366
         
1364 1367
                 ax1.set_ylim( np.min(self.GATED[chan]["QQ"]), np.max(self.GATED[chan]["QQ"]) )
@@ -1379,15 +1382,15 @@ class GMRDataProcessor(SNMRDataProcessor):
1379 1382
                 #formatter = matplotlib.ticker.LogFormatter(10, labelOnlyBase=False)
1380 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 1388
                 ax1.yaxis.set_major_formatter(formatter) #matplotlib.ticker.FormatStrFormatter('%d.1'))
1383 1389
                 ax2.yaxis.set_major_formatter(formatter) #matplotlib.ticker.FormatStrFormatter('%d.1'))
1384 1390
 
1385 1391
                 ax1.xaxis.set_major_formatter(formatter) #matplotlib.ticker.FormatStrFormatter('%d.1'))
1386 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 1394
                 if ichan == 0:
1392 1395
                     ax1.set_ylabel(r"$q$ ( $\mathrm{A}\cdot\mathrm{s}$)", fontsize=8)
1393 1396
                     if phase == 2:
@@ -1410,8 +1413,8 @@ class GMRDataProcessor(SNMRDataProcessor):
1410 1413
         cb1 = canvas.fig.colorbar(im1, ax=axes[0::2], format='%1.0e', orientation='horizontal', shrink=.35, aspect=30)
1411 1414
         cb1.ax.tick_params(axis='both', which='major', labelsize=8)
1412 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 1419
         if phase != 2:
1417 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,6 +128,33 @@ def RotateAmplitude(X, Y, zeta, df, t):
128 128
     return np.abs(V) * np.exp( 1j * ( np.angle(V) - zeta - 2.*np.pi*df*t ) )
129 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 158
 def gateIntegrate(T2D, T2T, gpd, sigma, stackEfficiency=2.):
132 159
     """ Gate integrate the signal to gpd, gates per decade
133 160
         T2D = the time series to gate integrate, complex 

Loading…
Cancel
Save