Преглед на файлове

Improving the speed of plotting of subsequent graphs by not doing a hard clear at each call to plot.

tags/1.6.1
Trevor Irons преди 5 години
родител
ревизия
3f9d8d98f5
променени са 3 файла, в които са добавени 120 реда и са изтрити 75 реда
  1. 9
    3
      akvo/gui/mydynamicmplcanvas.py
  2. 26
    4
      akvo/tressel/harmonic.py
  3. 85
    68
      akvo/tressel/mrsurvey.py

+ 9
- 3
akvo/gui/mydynamicmplcanvas.py Целия файл

@@ -17,7 +17,7 @@ class MyMplCanvas(FigureCanvas):
17 17
     """Ultimately, this is a QWidget (as well as a FigureCanvasAgg, etc.)."""
18 18
     def __init__(self, parent=None, width=3, height=4, dpi=100):
19 19
         
20
-        self.fig = Figure(figsize=(width, height), dpi=dpi, facecolor='darkgrey') # this fucking works...why?
20
+        self.fig = Figure(figsize=(width, height), dpi=dpi, facecolor='darkgrey') 
21 21
         #self.fig.patch.set_facecolor('blue')
22 22
         FigureCanvas.__init__(self, self.fig)
23 23
 
@@ -198,11 +198,17 @@ class MyDynamicMplCanvas(MyMplCanvas):
198 198
         self.ax1.tick_params(axis='both', which='major', labelsize=8)
199 199
         self.ax2.tick_params(axis='both', which='major', labelsize=8)
200 200
 
201
-        self.ax1.ticklabel_format(style='sci', scilimits=(0,0), axis='y')  
202
-        self.ax2.ticklabel_format(style='sci', scilimits=(0,0), axis='y')  
201
+        self.ax1.ticklabel_format(style='scientific', scilimits=(0,0), axis='y')  
202
+        self.ax2.ticklabel_format(style='scientific', scilimits=(0,0), axis='y')  
203 203
 
204 204
         self.ax1.yaxis.get_offset_text().set_size(8) 
205 205
         self.ax2.yaxis.get_offset_text().set_size(8) 
206
+    
207
+    def softClear(self):
208
+        for ax in self.fig.get_axes():
209
+            for artist in ax.lines + ax.collections:
210
+                artist.remove()
211
+            ax.set_prop_cycle(None)
206 212
 
207 213
     def reAx3(self, shx=True, shy=True):
208 214
 

+ 26
- 4
akvo/tressel/harmonic.py Целия файл

@@ -38,11 +38,28 @@ def harmonicNorm (f0, sN, fs, t, k1, kN, ks):
38 38
     return np.linalg.norm( harmonicEuler(sN, fs, t, f0, k1, kN, ks)[ii] ) 
39 39
 
40 40
 def minHarmonic(sN, fs, t, f0, k1, kN, ks):
41
+    
41 42
     # CG, BFGS, Newton-CG, L-BFGS-B, TNC, SLSQP, dogleg, trust-ncg, trust-krylov, trust-exact and trust-constr
42
-    res = minimize(harmonicNorm, np.array((f0)), args=(sN, fs, t, k1, kN, ks), jac='2-point', method='BFGS') # hess=None, bounds=None )
43
+    #res = minimize(harmonicNorm, np.array((f0)), args=(sN, fs, t, k1, kN, ks), jac='2-point', method='BFGS') # hess=None, bounds=None )
44
+    
45
+    #############
46
+    # Reduced N #
47
+    #############
48
+    #print("min 10")
49
+    #res = minimize(harmonicNorm, np.array((f0)), args=(sN, fs, t, k1, 10, ks), jac='2-point', method='BFGS') # hess=None, bounds=None )
50
+    
51
+    ########## 
52
+    # Bounds #
53
+    ##########
54
+    print("bounded search for f0", f0)
55
+    bnds = ( (f0-0.125, f0+0.125), )
56
+    #print("len f0", len( [f0,] ))
57
+    #print("len bnds", len(bnds) )
58
+    res = minimize(harmonicNorm, (f0,), args=(sN, fs, t, k1, kN, ks), jac='2-point', method='L-BFGS-B', bounds=bnds ) # hess=None, bounds=None )
59
+    
43 60
     #print(res)
44 61
     #print ( "guess", guessf0(  harmonicEuler(sN, fs, t, res.x[0], k1, kN, ks), fs  ) )
45
-    return harmonicEuler(sN, fs, t, res.x[0], k1, kN, ks)#[0]
62
+    return harmonicEuler(sN, fs, t, res.x[0], k1, kN, ks), res.x[0]#[0]
46 63
 
47 64
 def harmonicEuler2 ( sN, fs, t, f0, f0k1, f0kN, f0ks, f1, f1k1, f1kN, f1ks ): 
48 65
     """
@@ -91,11 +108,16 @@ def harmonic2Norm (f0, sN, fs, t, f0k1, f0kN, f0ks, f1k1, f1kN, f1ks):
91 108
     return np.linalg.norm( harmonicEuler2(sN, fs, t, f0[0], f0k1, f0kN, f0ks, f0[1], f1k1, f1kN, f1ks)[ii] ) 
92 109
 
93 110
 def minHarmonic2(sN, fs, t, f0, f0k1, f0kN, f0ks, f1, f1k1, f1kN, f1ks):
111
+    
94 112
     # CG, BFGS, Newton-CG, L-BFGS-B, TNC, SLSQP, dogleg, trust-ncg, trust-krylov, trust-exact and trust-constr
95
-    res = minimize(harmonic2Norm, np.array((f0, f1)), args=(sN, fs, t, f0k1, f0kN, f0ks, f1k1,f1kN, f1ks), jac='2-point', method='BFGS') # hess=None, bounds=None )
113
+    #res = minimize(harmonic2Norm, np.array((f0, f1)), args=(sN, fs, t, f0k1, f0kN, f0ks, f1k1,f1kN, f1ks), jac='2-point', method='BFGS') # hess=None, bounds=None )
114
+    
115
+    print("search 10")
116
+    res = minimize(harmonic2Norm, np.array((f0, f1)), args=(sN, fs, t, f0k1, 10, f0ks, f1k1, 10, f1ks), jac='2-point', method='BFGS') # hess=None, bounds=None )
117
+    
96 118
     #print(res)
97 119
     #print ( "guess", guessf0(harmonicEuler2(sN, fs, t, res.x[0], f0k1, f0kN, f0ks, res.x[1], f1k1, f1kN, f1ks), fs)  )
98
-    return harmonicEuler2(sN, fs, t, res.x[0], f0k1, f0kN, f0ks, res.x[1], f1k1, f1kN, f1ks)#[0]
120
+    return harmonicEuler2(sN, fs, t, res.x[0], f0k1, f0kN, f0ks, res.x[1], f1k1, f1kN, f1ks), res.x[0], res.x[1]#[0]
99 121
 
100 122
 def guessf0( sN, fs ):
101 123
     S = np.fft.fft(sN)

+ 85
- 68
akvo/tressel/mrsurvey.py Целия файл

@@ -194,7 +194,7 @@ class GMRDataProcessor(SNMRDataProcessor):
194 194
         self.RotatedAmplitude = False
195 195
 #        self.DATA                   = np.zeros(1) # Numpy array to hold all data, dimensions resized based on experiment
196 196
 #        self.PULSES                 = np.zeros(1) # Numpy array to hold all data, dimensions resized based on experiment
197
-
197
+ 
198 198
     def Print(self):
199 199
         print ("pulse type", self.pulseType)
200 200
         print ("maxBusV", self.maxBusV)
@@ -560,39 +560,66 @@ class GMRDataProcessor(SNMRDataProcessor):
560 560
         #plot = True
561 561
         if plot:
562 562
             canvas.reAx2()
563
-            canvas.ax1.tick_params(axis='both', which='major', labelsize=8)
564
-            canvas.ax1.ticklabel_format(style='sci', scilimits=(0,0), axis='y')  
565
-            canvas.ax2.tick_params(axis='both', which='major', labelsize=8)
566
-            canvas.ax2.ticklabel_format(style='sci', scilimits=(0,0), axis='y')  
563
+            #canvas.ax1.tick_params(axis='both', which='major', labelsize=8)
564
+            #canvas.ax1.ticklabel_format(style='sci', axis='y') #, scilimits=(0,0))
565
+            #canvas.ax2.tick_params(axis='both', which='major', labelsize=8)
566
+            #canvas.ax2.ticklabel_format(style='sci', axis='y') #, scilimits=(0,0)) 
567
+            canvas.ax1.set_ylabel(r"signal [nV]", fontsize=8)
568
+            canvas.ax2.set_xlabel(r"time [s]", fontsize=8)
569
+            canvas.ax2.set_ylabel(r"signal [nV]", fontsize=8)
570
+            #canvas.ax1.tick_params(axis='both', which='major', labelsize=8)
571
+            #canvas.ax2.tick_params(axis='both', which='major', labelsize=8)
567 572
 
568 573
         # Data
569 574
         iFID = 0
570 575
 
576
+        # stores previous f0 as starting point in non-linear search 
577
+        f0p = {} 
578
+        f1p = {} 
579
+        for pulse in self.DATADICT["PULSES"]:
580
+            for rchan in self.DATADICT[pulse]["rchan"]:
581
+                f0p[rchan] = f0
582
+                f1p[rchan] = f1+1e-1 
583
+            for chan in self.DATADICT[pulse]["chan"]:
584
+                f0p[chan] = f0
585
+                f1p[chan] = f1+1e-1
586
+
571 587
         for pulse in self.DATADICT["PULSES"]:
572 588
             self.DATADICT[pulse]["TIMES"] =  self.DATADICT[pulse]["TIMES"]
573 589
             Nseg = int( np.floor(len( self.DATADICT[pulse]["TIMES"] ) / f0ns) )
574
-            for ipm in range(self.DATADICT["nPulseMoments"]):
575
-                for istack in self.DATADICT["stacks"]:
576
-                    canvas.ax1.clear()
577
-                    canvas.ax2.clear()
578
-                    #for ichan in np.append(self.DATADICT[pulse]["chan"], self.DATADICT[pulse]["rchan"]):
590
+            for istack in self.DATADICT["stacks"]:
591
+                for ipm in range(self.DATADICT["nPulseMoments"]):
592
+                    if plot:
593
+                        #canvas.ax1.clear()
594
+                        #canvas.ax2.clear()
595
+                        #for artist in canvas.ax1.lines + canvas.ax1.collections:
596
+                        #    artist.remove()
597
+                        #canvas.ax1.set_prop_cycle(None)
598
+                        #for artist in canvas.ax2.lines + canvas.ax2.collections:
599
+                        #    artist.remove()
600
+                        #canvas.ax2.set_prop_cycle(None)
601
+                        canvas.softClear()
602
+                        for ichan in self.DATADICT[pulse]["rchan"]:
603
+                            canvas.ax1.plot( self.DATADICT[pulse]["TIMES"], 1e9*self.DATADICT[pulse][ichan][ipm][istack], alpha=.5) 
604
+                            #, label = "orig " +  pulse + " ipm=" + str(ipm) + " istack=" + str(istack) + " rchan="  + str(ichan))
605
+                            
606
+                        for ichan in self.DATADICT[pulse]["chan"]:
607
+                            canvas.ax2.plot( self.DATADICT[pulse]["TIMES"], 1e9*self.DATADICT[pulse][ichan][ipm][istack], alpha=.5) 
608
+                            #, label = "orig " +  pulse + " ipm=" + str(ipm) + " istack=" + str(istack) + " chan="  + str(ichan))
609
+                        canvas.ax1.set_prop_cycle(None)
610
+                        canvas.ax2.set_prop_cycle(None)
579 611
                     for ichan in self.DATADICT[pulse]["rchan"]:
580
-                        if plot:
581
-                            canvas.ax1.plot( self.DATADICT[pulse]["TIMES"], 1e9*self.DATADICT[pulse][ichan][ipm][istack], \
582
-                                label = "orig " +  pulse + " ipm=" + str(ipm) + " istack=" + str(istack) + " rchan="  + str(ichan))
583
-
584 612
                         if nF == 1:
585 613
                             #self.DATADICT[pulse][ichan][ipm][istack] = harmonic.minHarmonic( f0, self.DATADICT[pulse][ichan][ipm][istack], self.samp, nK, self.DATADICT[pulse]["TIMES"] ) 
586 614
                             for iseg in range(f0ns):
587 615
                                 if iseg < f0ns-1:
588
-                                    self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg:(iseg+1)*Nseg] = harmonic.minHarmonic( self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg:(iseg+1)*Nseg], \
616
+                                    self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg:(iseg+1)*Nseg], f0p[ichan] = harmonic.minHarmonic( self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg:(iseg+1)*Nseg], \
589 617
                                             self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg:(iseg+1)*Nseg], \
590
-                                            f0, f0K1, f0KN, f0Ks ) 
618
+                                            f0p[ichan], f0K1, f0KN, f0Ks ) 
591 619
                                 else:
592
-                                    self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg::] = harmonic.minHarmonic( self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg::], \
620
+                                    self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg::], f0p[ichan] = harmonic.minHarmonic( self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg::], \
593 621
                                             self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg::], \
594
-                                            f0, f0K1, f0KN, f0Ks ) 
595
-
622
+                                            f0p[ichan], f0K1, f0KN, f0Ks ) 
596 623
                             #self.DATADICT[pulse][ichan][ipm][istack] = harmonic.minHarmonic( self.DATADICT[pulse][ichan][ipm][istack], self.samp,  self.DATADICT[pulse]["TIMES"], \
597 624
                             #    f0, f0K1, f0KN, f0Ks ) 
598 625
                         elif nF == 2:
@@ -602,15 +629,15 @@ class GMRDataProcessor(SNMRDataProcessor):
602 629
                             #    f1+1e-2, f1K1, f1KN, f1Ks ) 
603 630
                             for iseg in range(f0ns):
604 631
                                 if iseg < f0ns-1:
605
-                                    self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg:(iseg+1)*Nseg] = harmonic.minHarmonic2( self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg:(iseg+1)*Nseg],\
632
+                                    self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg:(iseg+1)*Nseg], f0p[ichan], f1p[ichan] = harmonic.minHarmonic2( self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg:(iseg+1)*Nseg],\
606 633
                                      self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg:(iseg+1)*Nseg], \
607
-                                     f0-1e-2, f0K1, f0KN, f0Ks,  \
608
-                                     f1+1e-2, f1K1, f1KN, f1Ks ) 
634
+                                     f0p[ichan], f0K1, f0KN, f0Ks,  \
635
+                                     f1p[ichan], f1K1, f1KN, f1Ks ) 
609 636
                                 else:
610
-                                    self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg::] = harmonic.minHarmonic2( self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg::],\
637
+                                    self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg::], f0p[ichan], f1p[ichan] = harmonic.minHarmonic2( self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg::],\
611 638
                                      self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg::], \
612
-                                     f0-1e-2, f0K1, f0KN, f0Ks,  \
613
-                                     f1+1e-2, f1K1, f1KN, f1Ks ) 
639
+                                     f0p[ichan], f0K1, f0KN, f0Ks,  \
640
+                                     f1p[ichan], f1K1, f1KN, f1Ks ) 
614 641
                         # plot
615 642
                         if plot:
616 643
                             canvas.ax1.plot( self.DATADICT[pulse]["TIMES"], 1e9*self.DATADICT[pulse][ichan][ipm][istack], \
@@ -618,23 +645,19 @@ class GMRDataProcessor(SNMRDataProcessor):
618 645
 
619 646
                     for ichan in self.DATADICT[pulse]["chan"]:
620 647
                         
621
-                        if plot:
622
-                            canvas.ax2.plot( self.DATADICT[pulse]["TIMES"], 1e9*self.DATADICT[pulse][ichan][ipm][istack], \
623
-                                label = "orig " +  pulse + " ipm=" + str(ipm) + " istack=" + str(istack) + " chan="  + str(ichan))
624
-                        
625 648
                         if nF == 1:
626 649
                             #self.DATADICT[pulse][ichan][ipm][istack] = harmonic.minHarmonic( f0, self.DATADICT[pulse][ichan][ipm][istack], self.samp, nK, self.DATADICT[pulse]["TIMES"] ) 
627 650
                             #self.DATADICT[pulse][ichan][ipm][istack] = harmonic.minHarmonic( self.DATADICT[pulse][ichan][ipm][istack], self.samp,  self.DATADICT[pulse]["TIMES"], \
628 651
                             #    f0, f0K1, f0KN, f0Ks ) 
629 652
                             for iseg in range(f0ns):
630 653
                                 if iseg < f0ns-1:
631
-                                    self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg:(iseg+1)*Nseg] = harmonic.minHarmonic( self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg:(iseg+1)*Nseg], 
654
+                                    self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg:(iseg+1)*Nseg], f0p[ichan] = harmonic.minHarmonic( self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg:(iseg+1)*Nseg], 
632 655
                                             self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg:(iseg+1)*Nseg], \
633
-                                            f0, f0K1, f0KN, f0Ks ) 
656
+                                            f0p[ichan], f0K1, f0KN, f0Ks ) 
634 657
                                 else:
635
-                                    self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg::] = harmonic.minHarmonic( self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg::], 
658
+                                    self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg::], f0p[ichan] = harmonic.minHarmonic( self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg::], 
636 659
                                             self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg::], \
637
-                                            f0, f0K1, f0KN, f0Ks ) 
660
+                                            f0p[ichan], f0K1, f0KN, f0Ks )
638 661
 
639 662
                         elif nF == 2:
640 663
                             #self.DATADICT[pulse][ichan][ipm][istack] = harmonic.minHarmonic2( f0-1e-2, f1+1e-2, self.DATADICT[pulse][ichan][ipm][istack], self.samp, nK, self.DATADICT[pulse]["TIMES"] ) 
@@ -644,33 +667,31 @@ class GMRDataProcessor(SNMRDataProcessor):
644 667
                             #    f1+1e-2, f1K1, f1KN, f1Ks ) 
645 668
                             for iseg in range(f0ns):
646 669
                                 if iseg < f0ns-1:
647
-                                    self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg:(iseg+1)*Nseg] = harmonic.minHarmonic2( self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg:(iseg+1)*Nseg],\
670
+                                    self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg:(iseg+1)*Nseg], f0p[ichan], f1p[ichan] = harmonic.minHarmonic2( self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg:(iseg+1)*Nseg],\
648 671
                                      self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg:(iseg+1)*Nseg], \
649
-                                     f0-1e-2, f0K1, f0KN, f0Ks,  \
650
-                                     f1+1e-2, f1K1, f1KN, f1Ks ) 
672
+                                     f0p[ichan], f0K1, f0KN, f0Ks,  \
673
+                                     f1p[ichan], f1K1, f1KN, f1Ks ) 
651 674
                                 else:
652
-                                    self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg::] = harmonic.minHarmonic2( self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg::],\
675
+                                    self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg::], f0p[ichan], f1p[ichan] = harmonic.minHarmonic2( self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg::],\
653 676
                                      self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg::], \
654
-                                     f0-1e-2, f0K1, f0KN, f0Ks,  \
655
-                                     f1+1e-2, f1K1, f1KN, f1Ks ) 
677
+                                     f0p[ichan], f0K1, f0KN, f0Ks,  \
678
+                                     f1p[ichan], f1K1, f1KN, f1Ks ) 
656 679
                
657 680
                         # plot
658 681
                         if plot:
659 682
                             canvas.ax2.plot( self.DATADICT[pulse]["TIMES"], 1e9*self.DATADICT[pulse][ichan][ipm][istack], \
660
-                                label = "data " + pulse + " ipm=" + str(ipm) + " istack=" + str(istack) + " chan="  + str(ichan))
683
+                                label = pulse + " ipm=" + str(ipm) + " istack=" + str(istack) + " chan="  + str(ichan))
661 684
 
662 685
                     if plot:
663
-                        canvas.ax1.set_xlabel(r"time [s]", fontsize=8)
664
-                        canvas.ax1.set_ylabel(r"signal [nV]", fontsize=8)
665
-                        canvas.ax2.set_xlabel(r"time [s]", fontsize=8)
666
-                        canvas.ax2.set_ylabel(r"signal [nV]", fontsize=8)
667
-                        canvas.ax1.legend(prop={'size':6})
668
-                        canvas.ax2.legend(prop={'size':6})
686
+                        canvas.ax1.legend(prop={'size':6}, loc='upper right')
687
+                        canvas.ax2.legend(prop={'size':6}, loc='upper right')
669 688
                         canvas.draw() 
670 689
                     
671
-                percent = (int)(1e2*((float)(iFID*self.DATADICT["nPulseMoments"]+(ipm))/(len(self.DATADICT["PULSES"])*self.nPulseMoments)))
690
+                #percent = (int)(1e2*((float)(iFID*self.DATADICT["nPulseMoments"]+(ipm))/(len(self.DATADICT["PULSES"])*self.nPulseMoments)))
691
+                percent = (int)(1e2*((ipm+istack*self.nPulseMoments)/(self.nPulseMoments*len(self.DATADICT["stacks"])))) 
672 692
                 self.progressTrigger.emit(percent)  
673 693
             iFID += 1
694
+
674 695
         self.doneTrigger.emit() 
675 696
         self.updateProcTrigger.emit()  
676 697
 
@@ -1990,15 +2011,20 @@ class GMRDataProcessor(SNMRDataProcessor):
1990 2011
         canvas.draw() 
1991 2012
         return [bord, self.fe] 
1992 2013
 
1993
-    def downsample(self, truncate, dec, plot, canvas):
1994
-        """ Downsamples and truncates the raw signal. 
2014
+    def downsample(self, truncate, dec, plot=False, canvas=None):
2015
+        """ Downsamples and truncates the raw signal.
2016
+            Args 
2017
+                truncate (float) : the length of the signal to truncate to  
2018
+                dec (int) : the decimation factor, 1 results in no downsampling
2019
+                plot (bool) : perform plots
2020
+                canvas : MPL axis for plotting  
1995 2021
         """
1996
-        canvas.reAx2()
1997
-
1998
-        canvas.ax1.tick_params(axis='both', which='major', labelsize=8)
1999
-        canvas.ax1.ticklabel_format(style='sci', scilimits=(0,0), axis='y')  
2000
-        canvas.ax2.tick_params(axis='both', which='major', labelsize=8)
2001
-        canvas.ax2.ticklabel_format(style='sci', scilimits=(0,0), axis='y')  
2022
+        
2023
+        if plot:
2024
+            canvas.reAx2()
2025
+            canvas.ax1.set_ylabel(r"signal [nV]", fontsize=8)
2026
+            canvas.ax2.set_xlabel(r"time [s]", fontsize=8)
2027
+            canvas.ax2.set_ylabel(r"signal [nV]", fontsize=8)
2002 2028
 
2003 2029
         self.samp /= dec
2004 2030
         self.dt   = 1./self.samp       
@@ -2009,8 +2035,8 @@ class GMRDataProcessor(SNMRDataProcessor):
2009 2035
         for pulse in self.DATADICT["PULSES"]:
2010 2036
             for ipm in range(self.DATADICT["nPulseMoments"]):
2011 2037
                 for istack in self.DATADICT["stacks"]:
2012
-                    canvas.ax1.clear()
2013
-                    canvas.ax2.clear()
2038
+                    if plot:
2039
+                        canvas.softClear()
2014 2040
                     for ichan in np.append(self.DATADICT[pulse]["chan"], self.DATADICT[pulse]["rchan"]):
2015 2041
                         # trim off indices that don't divide evenly
2016 2042
                         ndi = np.shape(self.DATADICT[pulse][ichan][ipm][istack])[0]%dec
@@ -2025,7 +2051,6 @@ class GMRDataProcessor(SNMRDataProcessor):
2025 2051
                         if truncate:
2026 2052
                             self.DATADICT[pulse][ichan][ipm][istack] = self.DATADICT[pulse][ichan][ipm][istack][0:itrunc]
2027 2053
                             RSTIMES = RSTIMES[0:itrunc]
2028
-
2029 2054
                     if plot:
2030 2055
                         for ichan in self.DATADICT[pulse]["chan"]:
2031 2056
                             canvas.ax2.plot( RSTIMES, 1e9*self.DATADICT[pulse][ichan][ipm][istack], \
@@ -2033,16 +2058,8 @@ class GMRDataProcessor(SNMRDataProcessor):
2033 2058
                         for ichan in self.DATADICT[pulse]["rchan"]:
2034 2059
                             canvas.ax1.plot( RSTIMES, 1e9*self.DATADICT[pulse][ichan][ipm][istack], \
2035 2060
                                 label = pulse + " ipm=" + str(ipm) + " istack=" + str(istack) + " ichan="  + str(ichan))
2036
-                    
2037
-                        canvas.ax1.set_xlabel(r"time [s]", fontsize=8)
2038
-                        canvas.ax1.set_ylabel(r"signal [nV]", fontsize=8)
2039
-                        canvas.ax2.set_xlabel(r"time [s]", fontsize=8)
2040
-                        canvas.ax2.set_ylabel(r"signal [nV]", fontsize=8)
2041
-                    
2042
-                        canvas.ax1.legend(prop={'size':6})
2043
-                        canvas.ax2.legend(prop={'size':6})
2044
-                        canvas.ax1.ticklabel_format(style='sci', scilimits=(0,0), axis='y') 
2045
-                        canvas.ax2.ticklabel_format(style='sci', scilimits=(0,0), axis='y') 
2061
+                        canvas.ax1.legend(prop={'size':6}, loc='upper right')
2062
+                        canvas.ax2.legend(prop={'size':6}, loc='upper right')
2046 2063
                         canvas.draw() 
2047 2064
                 percent = (int)(1e2*((float)(iFID*self.DATADICT["nPulseMoments"]+(ipm))/( len(self.DATADICT["PULSES"])*self.nPulseMoments)))
2048 2065
                 self.progressTrigger.emit(percent)

Loading…
Отказ
Запис