|
@@ -4,6 +4,7 @@ import scipy.signal as signal
|
4
|
4
|
import pylab
|
5
|
5
|
import sys
|
6
|
6
|
import scipy
|
|
7
|
+from scipy import stats
|
7
|
8
|
import copy
|
8
|
9
|
import struct
|
9
|
10
|
from scipy.io.matlab import mio
|
|
@@ -1223,7 +1224,8 @@ class GMRDataProcessor(SNMRDataProcessor):
|
1223
|
1224
|
|
1224
|
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
|
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
|
1229
|
GT, GCA, GTT, sig_stack, isum = rotate.gateIntegrate( self.DATADICT["CA"][pulse][chan][ipm], time_sp, gpd, self.sigma[pulse][chan], 2 )
|
1228
|
1230
|
GT, GNR, GTT, sig_stack, isum = rotate.gateIntegrate( self.DATADICT["NR"][pulse][chan][ipm], time_sp, gpd, self.sigma[pulse][chan], 2 )
|
1229
|
1231
|
GT, GRE, GTT, sig_stack, isum = rotate.gateIntegrate( self.DATADICT["RE"][pulse][chan][ipm], time_sp, gpd, self.sigma[pulse][chan], 2 )
|
|
@@ -1237,10 +1239,21 @@ class GMRDataProcessor(SNMRDataProcessor):
|
1237
|
1239
|
# self.GATED[chan]["SIGMA"] = np.zeros( ( self.DATADICT["nPulseMoments"], len(GT)) )
|
1238
|
1240
|
self.GATED[chan]["CA"] = np.zeros( ( self.DATADICT["nPulseMoments"], len(GT)-clip) )
|
1239
|
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
|
1243
|
self.GATED[chan]["RE"] = np.zeros( ( self.DATADICT["nPulseMoments"], len(GT)-clip) )
|
1241
|
1244
|
self.GATED[chan]["IM"] = np.zeros( ( self.DATADICT["nPulseMoments"], len(GT)-clip) )
|
1242
|
1245
|
self.GATED[chan]["IP"] = np.zeros( ( self.DATADICT["nPulseMoments"], len(GT)-clip) )
|
1243
|
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
|
1258
|
#self.GATED[chan]["DATA"][ipm] = GD.real
|
1246
|
1259
|
self.GATEDABSCISSA = GT[clip:]
|
|
@@ -1263,6 +1276,7 @@ class GMRDataProcessor(SNMRDataProcessor):
|
1263
|
1276
|
(float)(self.DATADICT["nPulseMoments"] * len(self.DATADICT[pulse]["chan"])))
|
1264
|
1277
|
self.progressTrigger.emit(percent)
|
1265
|
1278
|
|
|
1279
|
+
|
1266
|
1280
|
self.GATED[chan]["CA"] = self.GATED[chan]["CA"][iQ,:]
|
1267
|
1281
|
self.GATED[chan]["NR"] = self.GATED[chan]["NR"][iQ,:]
|
1268
|
1282
|
self.GATED[chan]["RE"] = self.GATED[chan]["RE"][iQ,:]
|
|
@@ -1367,7 +1381,7 @@ class GMRDataProcessor(SNMRDataProcessor):
|
1367
|
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
|
1382
|
elif phase == 2:
|
1369
|
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
|
1385
|
#im2 = ax2.pcolormesh(self.GATED[chan]["GTT"], self.GATED[chan]["QQ"], self.GATED[chan]["NR"], cmap=cmap, vmin=-vmax2, vmax=vmax2)
|
1372
|
1386
|
# bootstrap resample
|
1373
|
1387
|
# nt = len(self.GATED[chan]["GT"])
|
|
@@ -1400,9 +1414,10 @@ class GMRDataProcessor(SNMRDataProcessor):
|
1400
|
1414
|
#else:
|
1401
|
1415
|
# ax2.plot( self.GATED[chan]["GT"], XS[ii], '-', linewidth=1, markersize=4, alpha=.5, color='lightgrey' )
|
1402
|
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
|
1421
|
ax2.legend()
|
1407
|
1422
|
|
1408
|
1423
|
im1.set_edgecolor('face')
|