Browse Source

Edits to fix plotting when numerous cycles are present (interleaves) in GMR speak. Prior plotting assumed monotonically decreasing pulse moments, which is not always the case

tags/1.6.1
Trevor Irons 4 years ago
parent
commit
de0e5e7cc4
3 changed files with 54 additions and 21 deletions
  1. 8
    2
      akvo/gui/akvoGUI.py
  2. 45
    18
      akvo/tressel/mrsurvey.py
  3. 1
    1
      setup.py

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

662
                 #    print ("stack q", self.RAWDataProc.DATADICT[pulse]["Q"][ipm,istack-1])
662
                 #    print ("stack q", self.RAWDataProc.DATADICT[pulse]["Q"][ipm,istack-1])
663
                 qq.append(np.mean(    self.RAWDataProc.DATADICT[pulse]["Q"][ipm,:]) )
663
                 qq.append(np.mean(    self.RAWDataProc.DATADICT[pulse]["Q"][ipm,:]) )
664
                 qv.append(np.std(     self.RAWDataProc.DATADICT[pulse]["Q"][ipm,:]/self.RAWDataProc.pulseLength[ip] ))
664
                 qv.append(np.std(     self.RAWDataProc.DATADICT[pulse]["Q"][ipm,:]/self.RAWDataProc.pulseLength[ip] ))
665
+            qq = np.array(qq)
666
+            qv = np.array(qv)
667
+            iQ = np.argsort(np.array(qq))
668
+            qq = np.array(qq)[iQ]
669
+            print("qq", qq, iQ)
670
+            qv = np.array(qv)[iQ]
665
             INFO["Pulses"][pulse] = {}
671
             INFO["Pulses"][pulse] = {}
666
             INFO["Pulses"][pulse]["units"] = "A"
672
             INFO["Pulses"][pulse]["units"] = "A"
667
-            INFO["Pulses"][pulse]["current"] = VectorXr(np.array(qq)/self.RAWDataProc.pulseLength[ip])
668
-            INFO["Pulses"][pulse]["variance"] = VectorXr(np.array(qv))
673
+            INFO["Pulses"][pulse]["current"] = VectorXr(qq/self.RAWDataProc.pulseLength[ip])
674
+            INFO["Pulses"][pulse]["variance"] = VectorXr(qv)
669
             ip += 1
675
             ip += 1
670
 
676
 
671
         # Data
677
         # Data

+ 45
- 18
akvo/tressel/mrsurvey.py View File

1004
                 NR[pulse][chan] = np.zeros( (self.DATADICT["nPulseMoments"],  len(self.DATADICT[pulse]["TIMES"])-clip )  )
1004
                 NR[pulse][chan] = np.zeros( (self.DATADICT["nPulseMoments"],  len(self.DATADICT[pulse]["TIMES"])-clip )  )
1005
                 RE[pulse][chan] = np.zeros( (self.DATADICT["nPulseMoments"],  len(self.DATADICT[pulse]["TIMES"])-clip )  )
1005
                 RE[pulse][chan] = np.zeros( (self.DATADICT["nPulseMoments"],  len(self.DATADICT[pulse]["TIMES"])-clip )  )
1006
                 IM[pulse][chan] = np.zeros( (self.DATADICT["nPulseMoments"],  len(self.DATADICT[pulse]["TIMES"])-clip )  )
1006
                 IM[pulse][chan] = np.zeros( (self.DATADICT["nPulseMoments"],  len(self.DATADICT[pulse]["TIMES"])-clip )  )
1007
+        
1008
+                #QQ = np.average(self.DATADICT[pulse]["Q"], axis=1 )
1009
+                #for ipm in np.argsort(QQ):
1007
                 for ipm in range(0, self.DATADICT["nPulseMoments"]):
1010
                 for ipm in range(0, self.DATADICT["nPulseMoments"]):
1008
                     #t = self.DATADICT[pulse]["TIMES"] - self.DATADICT[pulse]["PULSE_TIMES"][-1]
1011
                     #t = self.DATADICT[pulse]["TIMES"] - self.DATADICT[pulse]["PULSE_TIMES"][-1]
1009
                     xn = self.DATADICT["stack"][pulse][chan][ipm,:]
1012
                     xn = self.DATADICT["stack"][pulse][chan][ipm,:]
1040
                     self.progressTrigger.emit(percent)
1043
                     self.progressTrigger.emit(percent)
1041
                 ichan += 1
1044
                 ichan += 1
1042
             self.DATADICT[pulse]["TIMES"] = self.DATADICT[pulse]["TIMES"][clip::]
1045
             self.DATADICT[pulse]["TIMES"] = self.DATADICT[pulse]["TIMES"][clip::]
1043
-
1046
+            
1044
         self.DATADICT["CA"] = CA
1047
         self.DATADICT["CA"] = CA
1045
         self.DATADICT["IP"] = IP
1048
         self.DATADICT["IP"] = IP
1046
         self.DATADICT["NR"] = NR
1049
         self.DATADICT["NR"] = NR
1075
             time_sp =  1e3 * (self.DATADICT[pulse]["TIMES"] - self.DATADICT[pulse]["PULSE_TIMES"][-1] )
1078
             time_sp =  1e3 * (self.DATADICT[pulse]["TIMES"] - self.DATADICT[pulse]["PULSE_TIMES"][-1] )
1076
                 
1079
                 
1077
             QQ = np.average(self.DATADICT[pulse]["Q"], axis=1 )
1080
             QQ = np.average(self.DATADICT[pulse]["Q"], axis=1 )
1078
- 
1081
+            iQ = np.argsort(QQ)
1082
+
1079
             for chan in self.DATADICT[pulse]["chan"]: 
1083
             for chan in self.DATADICT[pulse]["chan"]: 
1080
                 ax1 = axes[2*ichan  ]
1084
                 ax1 = axes[2*ichan  ]
1081
                 ax2 = axes[2*ichan+1] # TODO fix hard coded number
1085
                 ax2 = axes[2*ichan+1] # TODO fix hard coded number
1082
-                if phase == 0: # Re Im  
1083
-                    im1 = ax1.pcolormesh( time_sp, QQ, self.DATADICT["RE"][pulse][chan], cmap=dcmap, rasterized=True,\
1086
+                if phase == 0: # Re Im 
1087
+                    print("plot dog", np.shape(QQ), np.shape(self.DATADICT["RE"][pulse][chan]))
1088
+                    print("QQ", QQ) 
1089
+                    im1 = ax1.pcolormesh( time_sp, QQ[iQ], self.DATADICT["RE"][pulse][chan][iQ], cmap=dcmap, \
1084
                          vmin=-self.DATADICT["REmax"][pulse] , vmax=self.DATADICT["REmax"][pulse] )
1090
                          vmin=-self.DATADICT["REmax"][pulse] , vmax=self.DATADICT["REmax"][pulse] )
1085
-                    im2 = ax2.pcolormesh( time_sp, QQ, self.DATADICT["IM"][pulse][chan], cmap=dcmap, rasterized=True,\
1091
+                    im2 = ax2.pcolormesh( time_sp, QQ[iQ], self.DATADICT["IM"][pulse][chan][iQ], cmap=dcmap, \
1086
                          vmin=-self.DATADICT["IMmax"][pulse], vmax=self.DATADICT["IMmax"][pulse]  )
1092
                          vmin=-self.DATADICT["IMmax"][pulse], vmax=self.DATADICT["IMmax"][pulse]  )
1093
+                    #im1 = ax1.matshow( self.DATADICT["RE"][pulse][chan][iQ], cmap=dcmap, aspect='auto', \
1094
+                    #     vmin=-self.DATADICT["REmax"][pulse] , vmax=self.DATADICT["REmax"][pulse] )
1095
+                    #im2 = ax2.matshow( self.DATADICT["IM"][pulse][chan][iQ], cmap=dcmap, aspect='auto', \
1096
+                    #     vmin=-self.DATADICT["REmax"][pulse] , vmax=self.DATADICT["REmax"][pulse] )
1087
                 if phase == 1: # Amp phase
1097
                 if phase == 1: # Amp phase
1088
-                    im1 = ax1.pcolormesh( time_sp, QQ, self.DATADICT["CA"][pulse][chan], cmap=dcmap, rasterized=True,
1098
+                    im1 = ax1.pcolormesh( time_sp, QQ[iQ], self.DATADICT["CA"][pulse][chan][iQ], cmap=dcmap, \
1089
                          vmin=-self.DATADICT["CAmax"][pulse] , vmax=self.DATADICT["CAmax"][pulse]  )
1099
                          vmin=-self.DATADICT["CAmax"][pulse] , vmax=self.DATADICT["CAmax"][pulse]  )
1090
                     #im2 = ax2.pcolormesh( time_sp, QQ, self.DATADICT["IP"][pulse][chan], cmap=cmocean.cm.balance, rasterized=True,\
1100
                     #im2 = ax2.pcolormesh( time_sp, QQ, self.DATADICT["IP"][pulse][chan], cmap=cmocean.cm.balance, rasterized=True,\
1091
-                    im2 = ax2.pcolormesh( time_sp, QQ, self.DATADICT["IP"][pulse][chan], cmap=cmocean.cm.delta, rasterized=True,\
1101
+                    im2 = ax2.pcolormesh( time_sp, QQ[iQ], self.DATADICT["IP"][pulse][chan][iQ], cmap=cmocean.cm.delta, \
1092
                          vmin=-np.pi, vmax=np.pi)
1102
                          vmin=-np.pi, vmax=np.pi)
1093
                 if phase == 2: # CA NR
1103
                 if phase == 2: # CA NR
1094
-                    im1 = ax1.pcolormesh( time_sp, QQ, self.DATADICT["CA"][pulse][chan], cmap=dcmap, rasterized=True,\
1104
+                    im1 = ax1.pcolormesh( time_sp, QQ[iQ], self.DATADICT["CA"][pulse][chan][iQ], cmap=dcmap, \
1095
                          vmin=-self.DATADICT["CAmax"][pulse] , vmax=self.DATADICT["CAmax"][pulse] )
1105
                          vmin=-self.DATADICT["CAmax"][pulse] , vmax=self.DATADICT["CAmax"][pulse] )
1096
-                    im2 = ax2.pcolormesh( time_sp, QQ, self.DATADICT["NR"][pulse][chan], cmap=dcmap, rasterized=True,\
1106
+                    im2 = ax2.pcolormesh( time_sp, QQ[iQ], self.DATADICT["NR"][pulse][chan][iQ], cmap=dcmap, \
1097
                          vmin=-self.DATADICT["NRmax"][pulse] , vmax=self.DATADICT["NRmax"][pulse] )
1107
                          vmin=-self.DATADICT["NRmax"][pulse] , vmax=self.DATADICT["NRmax"][pulse] )
1098
 #                     cb2 = canvas.fig.colorbar(im2, ax=ax2, format='%1.0e')
1108
 #                     cb2 = canvas.fig.colorbar(im2, ax=ax2, format='%1.0e')
1099
 #                     cb2.set_label("Noise residual (nV)", fontsize=8)
1109
 #                     cb2.set_label("Noise residual (nV)", fontsize=8)
1154
         tick_locator2 = MaxNLocator(nbins=3)
1164
         tick_locator2 = MaxNLocator(nbins=3)
1155
         cb2 = canvas.fig.colorbar(im2, ax=axes[1::2], format='%1.0e', orientation='horizontal', shrink=.35, aspect=30, pad=.2)
1165
         cb2 = canvas.fig.colorbar(im2, ax=axes[1::2], format='%1.0e', orientation='horizontal', shrink=.35, aspect=30, pad=.2)
1156
         cb2.ax.tick_params(axis='both', which='major', labelsize=8)
1166
         cb2.ax.tick_params(axis='both', which='major', labelsize=8)
1157
-        cb2.set_label("$\mathcal{V}_N$ (nV)", fontsize=8)
1167
+        if phase == 1: # Amp phase
1168
+            cb2.set_label(r"$\angle \mathcal{V}_N$", fontsize=8)
1169
+        else:
1170
+            cb2.set_label("$\mathcal{V}_N$ (nV)", fontsize=8)
1158
 
1171
 
1159
 
1172
 
1160
         cb2.locator = tick_locator2
1173
         cb2.locator = tick_locator2
1176
         
1189
         
1177
         for pulse in self.DATADICT["PULSES"]:
1190
         for pulse in self.DATADICT["PULSES"]:
1178
             QQ = np.average(self.DATADICT[pulse]["Q"], axis=1 )
1191
             QQ = np.average(self.DATADICT[pulse]["Q"], axis=1 )
1192
+            iQ = np.argsort(QQ)
1179
             ichan = 0
1193
             ichan = 0
1180
             for chan in self.DATADICT[pulse]["chan"]:
1194
             for chan in self.DATADICT[pulse]["chan"]:
1181
                 self.GATED[chan] = {}
1195
                 self.GATED[chan] = {}
1182
                 for ipm in range(0, self.DATADICT["nPulseMoments"]):
1196
                 for ipm in range(0, self.DATADICT["nPulseMoments"]):
1183
-
1184
-                    # Time since pulse rather than since record starts...
1197
+                #for ipm in iQ: 
1198
+                    # Time since pulse end rather than since record starts...
1185
                     #if clip > 0:
1199
                     #if clip > 0:
1186
                     #    time_sp =  1e3 * (self.DATADICT[pulse]["TIMES"][clip:] - self.DATADICT[pulse]["PULSE_TIMES"][-1] )
1200
                     #    time_sp =  1e3 * (self.DATADICT[pulse]["TIMES"][clip:] - self.DATADICT[pulse]["PULSE_TIMES"][-1] )
1187
                     #else:
1201
                     #else:
1190
                     #GT, GD, GTT, sig_stack, isum      = rotate.gateIntegrate( self.DATADICT["CA"][pulse][chan][ipm,:], time_sp, gpd, self.sigma[pulse][chan], 1.5 )
1204
                     #GT, GD, GTT, sig_stack, isum      = rotate.gateIntegrate( self.DATADICT["CA"][pulse][chan][ipm,:], time_sp, gpd, self.sigma[pulse][chan], 1.5 )
1191
                     #GT2, GP, GTT, sig_stack_err, isum = rotate.gateIntegrate( self.DATADICT["NR"][pulse][chan][ipm,:], time_sp, gpd, self.sigma[pulse][chan], 1.5 ) 
1205
                     #GT2, GP, GTT, sig_stack_err, isum = rotate.gateIntegrate( self.DATADICT["NR"][pulse][chan][ipm,:], time_sp, gpd, self.sigma[pulse][chan], 1.5 ) 
1192
                     
1206
                     
1193
-                    GT, GCA, GTT, sig_stack, isum  = rotate.gateIntegrate( self.DATADICT["CA"][pulse][chan][ipm], time_sp, gpd, self.sigma[pulse][chan], 1.5 )
1194
-                    GT, GNR, GTT, sig_stack, isum  = rotate.gateIntegrate( self.DATADICT["NR"][pulse][chan][ipm], time_sp, gpd, self.sigma[pulse][chan], 1.5 )
1195
-                    GT, GRE, GTT, sig_stack, isum  = rotate.gateIntegrate( self.DATADICT["RE"][pulse][chan][ipm], time_sp, gpd, self.sigma[pulse][chan], 1.5 )
1196
-                    GT, GIM, GTT, sig_stack, isum  = rotate.gateIntegrate( self.DATADICT["IM"][pulse][chan][ipm], time_sp, gpd, self.sigma[pulse][chan], 1.5 )
1197
-                    GT, GIP, GTT, sig_stack, isum  = rotate.gateIntegrate( self.DATADICT["IP"][pulse][chan][ipm], time_sp, gpd, self.sigma[pulse][chan], 1.5 )
1207
+                    GT, GCA, GTT, sig_stack, isum  = rotate.gateIntegrate( self.DATADICT["CA"][pulse][chan][ipm], time_sp, gpd, self.sigma[pulse][chan], 2 )
1208
+                    GT, GNR, GTT, sig_stack, isum  = rotate.gateIntegrate( self.DATADICT["NR"][pulse][chan][ipm], time_sp, gpd, self.sigma[pulse][chan], 2 )
1209
+                    GT, GRE, GTT, sig_stack, isum  = rotate.gateIntegrate( self.DATADICT["RE"][pulse][chan][ipm], time_sp, gpd, self.sigma[pulse][chan], 2 )
1210
+                    GT, GIM, GTT, sig_stack, isum  = rotate.gateIntegrate( self.DATADICT["IM"][pulse][chan][ipm], time_sp, gpd, self.sigma[pulse][chan], 2 )
1211
+                    GT, GIP, GTT, sig_stack, isum  = rotate.gateIntegrate( self.DATADICT["IP"][pulse][chan][ipm], time_sp, gpd, self.sigma[pulse][chan], 2 )
1198
                     
1212
                     
1213
+                    #if ipm == iQ[0]:
1199
                     if ipm == 0:
1214
                     if ipm == 0:
1200
                     #    self.GATED[chan]["DATA"]  = np.zeros( ( self.DATADICT["nPulseMoments"], len(GT)) )
1215
                     #    self.GATED[chan]["DATA"]  = np.zeros( ( self.DATADICT["nPulseMoments"], len(GT)) )
1201
                     #    self.GATED[chan]["ERR"]   = np.zeros( ( self.DATADICT["nPulseMoments"], len(GT)) )
1216
                     #    self.GATED[chan]["ERR"]   = np.zeros( ( self.DATADICT["nPulseMoments"], len(GT)) )
1213
                     #self.GATED[chan]["SIGMA"][ipm] =  sig_stack #_err # GP.real
1228
                     #self.GATED[chan]["SIGMA"][ipm] =  sig_stack #_err # GP.real
1214
                     #self.GATED[chan]["ERR"][ipm] =  GP.real
1229
                     #self.GATED[chan]["ERR"][ipm] =  GP.real
1215
                     
1230
                     
1231
+                    #self.GATED[chan]["CA"][iQ[ipm]] = GCA.real[clip:]
1232
+                    #self.GATED[chan]["NR"][iQ[ipm]] = GNR.real[clip:]
1233
+                    #self.GATED[chan]["RE"][iQ[ipm]] = GRE.real[clip:]
1234
+                    #self.GATED[chan]["IM"][iQ[ipm]] = GIM.real[clip:]
1235
+                    #self.GATED[chan]["IP"][iQ[ipm]] = GIP.real[clip:]
1216
                     self.GATED[chan]["CA"][ipm] = GCA.real[clip:]
1236
                     self.GATED[chan]["CA"][ipm] = GCA.real[clip:]
1217
                     self.GATED[chan]["NR"][ipm] = GNR.real[clip:]
1237
                     self.GATED[chan]["NR"][ipm] = GNR.real[clip:]
1218
                     self.GATED[chan]["RE"][ipm] = GRE.real[clip:]
1238
                     self.GATED[chan]["RE"][ipm] = GRE.real[clip:]
1223
                                        (float)(self.DATADICT["nPulseMoments"] * len(self.DATADICT[pulse]["chan"])))
1243
                                        (float)(self.DATADICT["nPulseMoments"] * len(self.DATADICT[pulse]["chan"])))
1224
                     self.progressTrigger.emit(percent)
1244
                     self.progressTrigger.emit(percent)
1225
 
1245
 
1246
+                self.GATED[chan]["CA"] = self.GATED[chan]["CA"][iQ,:]
1247
+                self.GATED[chan]["NR"] = self.GATED[chan]["NR"][iQ,:]
1248
+                self.GATED[chan]["RE"] = self.GATED[chan]["RE"][iQ,:]
1249
+                self.GATED[chan]["IM"] = self.GATED[chan]["IM"][iQ,:]
1250
+                self.GATED[chan]["IP"] = self.GATED[chan]["IP"][iQ,:]
1226
                 self.GATED[chan]["GTT"] = GTT[clip:]
1251
                 self.GATED[chan]["GTT"] = GTT[clip:]
1227
                 self.GATED[chan]["GT"] = GT[clip:]
1252
                 self.GATED[chan]["GT"] = GT[clip:]
1228
-                self.GATED[chan]["QQ"] = QQ
1253
+                self.GATED[chan]["QQ"] = QQ[iQ]
1229
                 ichan += 1
1254
                 ichan += 1
1230
         self.doneTrigger.emit() 
1255
         self.doneTrigger.emit() 
1231
 
1256
 
1314
                 if phase == 0:
1339
                 if phase == 0:
1315
                     im1 = ax1.pcolormesh(self.GATED[chan]["GTT"], self.GATED[chan]["QQ"], self.GATED[chan]["RE"], cmap=dcmap, vmin=-vmax1, vmax=vmax1)
1340
                     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)
1341
                     im2 = ax2.pcolormesh(self.GATED[chan]["GTT"], self.GATED[chan]["QQ"], self.GATED[chan]["IM"], cmap=dcmap, vmin=-vmax2, vmax=vmax2)
1342
+                    #im1 = ax1.matshow(self.GATED[chan]["RE"], cmap=dcmap, vmin=-vmax1, vmax=vmax1, aspect='auto')
1343
+                    #im2 = ax2.matshow(self.GATED[chan]["IM"], cmap=dcmap, vmin=-vmax2, vmax=vmax2, aspect='auto')
1317
                 elif phase == 1:
1344
                 elif phase == 1:
1318
                     im1 = ax1.pcolormesh(self.GATED[chan]["GTT"], self.GATED[chan]["QQ"], self.GATED[chan]["CA"], cmap=dcmap, vmin=-vmax1, vmax=vmax1)
1345
                     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)
1346
                     im2 = ax2.pcolormesh(self.GATED[chan]["GTT"], self.GATED[chan]["QQ"], self.GATED[chan]["IP"], cmap=cmocean.cm.delta, vmin=-vmax2, vmax=vmax2)

+ 1
- 1
setup.py View File

21
     long_description = fh.read()
21
     long_description = fh.read()
22
 
22
 
23
 setup(name='Akvo',
23
 setup(name='Akvo',
24
-      version='1.2.7',
24
+      version='1.2.8',
25
       description='Surface nuclear magnetic resonance workbench',
25
       description='Surface nuclear magnetic resonance workbench',
26
       long_description=long_description,
26
       long_description=long_description,
27
       long_description_content_type='text/markdown',
27
       long_description_content_type='text/markdown',

Loading…
Cancel
Save