Browse Source

Yaml export not uses GJI bootstrap noise estimate

tags/1.6.1
Trevor Irons 5 years ago
parent
commit
d125187d3a
3 changed files with 23 additions and 8 deletions
  1. 2
    2
      akvo/gui/akvoGUI.py
  2. 20
    5
      akvo/tressel/mrsurvey.py
  3. 1
    1
      akvo/tressel/rotate.py

+ 2
- 2
akvo/gui/akvoGUI.py View File

707
                 INFO["Gated"][pulse]["windows"] = VectorXr( self.RAWDataProc.GATEDWINDOW ) 
707
                 INFO["Gated"][pulse]["windows"] = VectorXr( self.RAWDataProc.GATEDWINDOW ) 
708
                 for ichan in self.RAWDataProc.DATADICT[pulse]["chan"]:
708
                 for ichan in self.RAWDataProc.DATADICT[pulse]["chan"]:
709
                     INFO["Gated"][pulse]["Chan. " + str(ichan)] = {} 
709
                     INFO["Gated"][pulse]["Chan. " + str(ichan)] = {} 
710
-                    #INFO["Gated"][pulse]["Chan. " + str(ichan)]["STD"] =  VectorXr( np.std(self.RAWDataProc.GATED[ichan]["NR"], axis=0) )
711
-                    INFO["Gated"][pulse]["Chan. " + str(ichan)]["STD"] = VectorXr( np.average(self.GATED[chan]["BN"], axis=0) )
710
+                    #INFO["Gated"][pulse]["Chan. " + str(ichan)]["STD"] =  VectorXr(   np.std(self.RAWDataProc.GATED[ichan]["NR"], axis=0) )
711
+                    INFO["Gated"][pulse]["Chan. " + str(ichan)]["STD"] = VectorXr( np.average(self.RAWDataProc.GATED[ichan]["BN"], axis=0) )
712
                     for ipm in range(self.RAWDataProc.DATADICT["nPulseMoments"]):     
712
                     for ipm in range(self.RAWDataProc.DATADICT["nPulseMoments"]):     
713
                         INFO["Gated"][pulse]["Chan. " + str(ichan)]["Q-"+str(ipm) + " CA"] = VectorXr(self.RAWDataProc.GATED[ichan]["CA"][ipm])   
713
                         INFO["Gated"][pulse]["Chan. " + str(ichan)]["Q-"+str(ipm) + " CA"] = VectorXr(self.RAWDataProc.GATED[ichan]["CA"][ipm])   
714
                         INFO["Gated"][pulse]["Chan. " + str(ichan)]["Q-"+str(ipm) + " RE"] = VectorXr(self.RAWDataProc.GATED[ichan]["RE"][ipm])   
714
                         INFO["Gated"][pulse]["Chan. " + str(ichan)]["Q-"+str(ipm) + " RE"] = VectorXr(self.RAWDataProc.GATED[ichan]["RE"][ipm])   

+ 20
- 5
akvo/tressel/mrsurvey.py View File

4
 import pylab
4
 import pylab
5
 import sys
5
 import sys
6
 import scipy
6
 import scipy
7
+from scipy import stats
7
 import copy
8
 import copy
8
 import struct
9
 import struct
9
 from scipy.io.matlab import mio
10
 from scipy.io.matlab import mio
1223
 
1224
 
1224
                     #GT, GD, GTT, sig_stack, isum      = rotate.gateIntegrate( self.DATADICT["CA"][pulse][chan][ipm,:], time_sp, gpd, self.sigma[pulse][chan], 1.5 )
1225
                     #GT, GD, GTT, sig_stack, isum      = rotate.gateIntegrate( self.DATADICT["CA"][pulse][chan][ipm,:], time_sp, gpd, self.sigma[pulse][chan], 1.5 )
1225
                     #GT2, GP, GTT, sig_stack_err, isum = rotate.gateIntegrate( self.DATADICT["NR"][pulse][chan][ipm,:], time_sp, gpd, self.sigma[pulse][chan], 1.5 ) 
1226
                     #GT2, GP, GTT, sig_stack_err, isum = rotate.gateIntegrate( self.DATADICT["NR"][pulse][chan][ipm,:], time_sp, gpd, self.sigma[pulse][chan], 1.5 ) 
1226
-                    
1227
+                   
1228
+                    #              err  
1227
                     GT, GCA, GTT, sig_stack, isum  = rotate.gateIntegrate( self.DATADICT["CA"][pulse][chan][ipm], time_sp, gpd, self.sigma[pulse][chan], 2 )
1229
                     GT, GCA, GTT, sig_stack, isum  = rotate.gateIntegrate( self.DATADICT["CA"][pulse][chan][ipm], time_sp, gpd, self.sigma[pulse][chan], 2 )
1228
                     GT, GNR, GTT, sig_stack, isum  = rotate.gateIntegrate( self.DATADICT["NR"][pulse][chan][ipm], time_sp, gpd, self.sigma[pulse][chan], 2 )
1230
                     GT, GNR, GTT, sig_stack, isum  = rotate.gateIntegrate( self.DATADICT["NR"][pulse][chan][ipm], time_sp, gpd, self.sigma[pulse][chan], 2 )
1229
                     GT, GRE, GTT, sig_stack, isum  = rotate.gateIntegrate( self.DATADICT["RE"][pulse][chan][ipm], time_sp, gpd, self.sigma[pulse][chan], 2 )
1231
                     GT, GRE, GTT, sig_stack, isum  = rotate.gateIntegrate( self.DATADICT["RE"][pulse][chan][ipm], time_sp, gpd, self.sigma[pulse][chan], 2 )
1237
                     #    self.GATED[chan]["SIGMA"] = np.zeros( ( self.DATADICT["nPulseMoments"], len(GT)) )
1239
                     #    self.GATED[chan]["SIGMA"] = np.zeros( ( self.DATADICT["nPulseMoments"], len(GT)) )
1238
                         self.GATED[chan]["CA"] = np.zeros( ( self.DATADICT["nPulseMoments"], len(GT)-clip) )
1240
                         self.GATED[chan]["CA"] = np.zeros( ( self.DATADICT["nPulseMoments"], len(GT)-clip) )
1239
                         self.GATED[chan]["NR"] = np.zeros( ( self.DATADICT["nPulseMoments"], len(GT)-clip) )
1241
                         self.GATED[chan]["NR"] = np.zeros( ( self.DATADICT["nPulseMoments"], len(GT)-clip) )
1242
+                        self.GATED[chan]["BN"] = np.zeros( ( self.DATADICT["nPulseMoments"], len(GT)-clip) )
1240
                         self.GATED[chan]["RE"] = np.zeros( ( self.DATADICT["nPulseMoments"], len(GT)-clip) )
1243
                         self.GATED[chan]["RE"] = np.zeros( ( self.DATADICT["nPulseMoments"], len(GT)-clip) )
1241
                         self.GATED[chan]["IM"] = np.zeros( ( self.DATADICT["nPulseMoments"], len(GT)-clip) )
1244
                         self.GATED[chan]["IM"] = np.zeros( ( self.DATADICT["nPulseMoments"], len(GT)-clip) )
1242
                         self.GATED[chan]["IP"] = np.zeros( ( self.DATADICT["nPulseMoments"], len(GT)-clip) )
1245
                         self.GATED[chan]["IP"] = np.zeros( ( self.DATADICT["nPulseMoments"], len(GT)-clip) )
1243
                         self.GATED[chan]["isum"] = isum
1246
                         self.GATED[chan]["isum"] = isum
1247
+                
1248
+                    # Bootstrap noise 
1249
+                    #self.GATED[chan]["isum"]
1250
+                    print("bootstrappin") 
1251
+                    Means = rotate.bootstrapWindows( self.DATADICT["NR"][pulse][chan][ipm], 20000, isum[isum!=1], adapt=True)
1252
+                    # MAD, only for windows > 1 
1253
+                    c = stats.norm.ppf(3./4.)
1254
+                    sig_stack[isum!=1] = np.ma.median(np.ma.abs(Means), axis=1) / c 
1255
+                    self.GATED[chan]["BN"][ipm] = sig_stack[clip:] 
1256
+                    print("end bootstrappin")
1244
 
1257
 
1245
                     #self.GATED[chan]["DATA"][ipm] = GD.real
1258
                     #self.GATED[chan]["DATA"][ipm] = GD.real
1246
                     self.GATEDABSCISSA = GT[clip:]
1259
                     self.GATEDABSCISSA = GT[clip:]
1263
                                        (float)(self.DATADICT["nPulseMoments"] * len(self.DATADICT[pulse]["chan"])))
1276
                                        (float)(self.DATADICT["nPulseMoments"] * len(self.DATADICT[pulse]["chan"])))
1264
                     self.progressTrigger.emit(percent)
1277
                     self.progressTrigger.emit(percent)
1265
 
1278
 
1279
+
1266
                 self.GATED[chan]["CA"] = self.GATED[chan]["CA"][iQ,:]
1280
                 self.GATED[chan]["CA"] = self.GATED[chan]["CA"][iQ,:]
1267
                 self.GATED[chan]["NR"] = self.GATED[chan]["NR"][iQ,:]
1281
                 self.GATED[chan]["NR"] = self.GATED[chan]["NR"][iQ,:]
1268
                 self.GATED[chan]["RE"] = self.GATED[chan]["RE"][iQ,:]
1282
                 self.GATED[chan]["RE"] = self.GATED[chan]["RE"][iQ,:]
1367
                     #im2 = ax2.pcolormesh(self.GATED[chan]["GTT"], self.GATED[chan]["QQ"], self.GATED[chan]["IP"], cmap=cmocean.cm.phase, vmin=-vmax2, vmax=vmax2)
1381
                     #im2 = ax2.pcolormesh(self.GATED[chan]["GTT"], self.GATED[chan]["QQ"], self.GATED[chan]["IP"], cmap=cmocean.cm.phase, vmin=-vmax2, vmax=vmax2)
1368
                 elif phase == 2:
1382
                 elif phase == 2:
1369
                     im1 = ax1.pcolormesh(self.GATED[chan]["GTT"], self.GATED[chan]["QQ"], self.GATED[chan]["CA"], cmap=dcmap, vmin=-vmax1, vmax=vmax1)
1383
                     im1 = ax1.pcolormesh(self.GATED[chan]["GTT"], self.GATED[chan]["QQ"], self.GATED[chan]["CA"], cmap=dcmap, vmin=-vmax1, vmax=vmax1)
1370
-                    XS = self.bootstrap_sigma(pulse, chan)
1384
+                    #XS = self.bootstrap_sigma(pulse, chan)
1371
                     #im2 = ax2.pcolormesh(self.GATED[chan]["GTT"], self.GATED[chan]["QQ"], self.GATED[chan]["NR"], cmap=cmap, vmin=-vmax2, vmax=vmax2)
1385
                     #im2 = ax2.pcolormesh(self.GATED[chan]["GTT"], self.GATED[chan]["QQ"], self.GATED[chan]["NR"], cmap=cmap, vmin=-vmax2, vmax=vmax2)
1372
                     # bootstrap resample
1386
                     # bootstrap resample
1373
 #                     nt = len(self.GATED[chan]["GT"])
1387
 #                     nt = len(self.GATED[chan]["GT"])
1400
                         #else:    
1414
                         #else:    
1401
                         #    ax2.plot( self.GATED[chan]["GT"], XS[ii], '-', linewidth=1, markersize=4, alpha=.5, color='lightgrey'  )
1415
                         #    ax2.plot( self.GATED[chan]["GT"], XS[ii], '-', linewidth=1, markersize=4, alpha=.5, color='lightgrey'  )
1402
                     ax2.plot( self.GATED[chan]["GT"], np.std(self.GATED[chan]["NR"], axis=0), color='darkgrey', linewidth=2, label="gate std" )
1416
                     ax2.plot( self.GATED[chan]["GT"], np.std(self.GATED[chan]["NR"], axis=0), color='darkgrey', linewidth=2, label="gate std" )
1403
-                    ax2.plot( np.tile(self.GATED[chan]["GT"], (5000,1) ), XS, '.', color='lightgrey', linewidth=1, alpha=.5 )
1404
-                    ax2.plot( self.GATED[chan]["GT"], np.average(XS, axis=0), color='black', linewidth=2, label="bootstrap avg." )
1405
-                    ax2.plot( self.GATED[chan]["GT"], np.median(XS, axis=0), color='black', linewidth=2, label="bootstrap med." )
1417
+                    ax2.plot( self.GATED[chan]["GT"], np.average(self.GATED[chan]["BN"], axis=0), color='black', linewidth=2, label="boot average" )
1418
+                    #ax2.plot( np.tile(self.GATED[chan]["GT"], (5000,1) ), XS, '.', color='lightgrey', linewidth=1, alpha=.5 )
1419
+                    #ax2.plot( self.GATED[chan]["GT"], np.average(XS, axis=0), color='black', linewidth=2, label="bootstrap avg." )
1420
+                    #ax2.plot( self.GATED[chan]["GT"], np.median(XS, axis=0), color='black', linewidth=2, label="bootstrap med." )
1406
                     ax2.legend()
1421
                     ax2.legend()
1407
 
1422
 
1408
                 im1.set_edgecolor('face')
1423
                 im1.set_edgecolor('face')

+ 1
- 1
akvo/tressel/rotate.py View File

153
                 cs = np.random.randint(0,nc-nwin)
153
                 cs = np.random.randint(0,nc-nwin)
154
                 Means[ii,iboot] = np.mean( N[cs:cs+nwin] )
154
                 Means[ii,iboot] = np.mean( N[cs:cs+nwin] )
155
 
155
 
156
-    return Means, np.array(isum)
156
+    return Means #, np.array(isum)
157
 
157
 
158
 def gateIntegrate(T2D, T2T, gpd, sigma, stackEfficiency=2.):
158
 def gateIntegrate(T2D, T2T, gpd, sigma, stackEfficiency=2.):
159
     """ Gate integrate the signal to gpd, gates per decade
159
     """ Gate integrate the signal to gpd, gates per decade

Loading…
Cancel
Save