Browse Source

More performance improvements for plotting

tags/1.6.1
Trevor Irons 5 years ago
parent
commit
9297604df7
2 changed files with 89 additions and 126 deletions
  1. 8
    5
      akvo/gui/mydynamicmplcanvas.py
  2. 81
    121
      akvo/tressel/mrsurvey.py

+ 8
- 5
akvo/gui/mydynamicmplcanvas.py View File

235
         except:
235
         except:
236
             pass
236
             pass
237
 
237
 
238
-        self.ax1 = self.fig.add_subplot(211)
238
+        self.ax2 = self.fig.add_subplot(211)
239
         if shx and shy:
239
         if shx and shy:
240
-            self.ax2 = self.fig.add_subplot(212, sharex=self.ax1, sharey=self.ax1)
240
+            self.ax1 = self.fig.add_subplot(212, sharex=self.ax2, sharey=self.ax2)
241
         elif shx:
241
         elif shx:
242
-            self.ax2 = self.fig.add_subplot(212, sharex=self.ax1) 
242
+            self.ax1 = self.fig.add_subplot(212, sharex=self.ax2) 
243
         elif shy:
243
         elif shy:
244
-            self.ax2 = self.fig.add_subplot(212, sharey=self.ax1) 
244
+            self.ax1 = self.fig.add_subplot(212, sharey=self.ax2) 
245
         else:
245
         else:
246
-            self.ax2 = self.fig.add_subplot(212) 
246
+            self.ax1 = self.fig.add_subplot(212) 
247
 
247
 
248
         self.ax3 = self.ax1.twinx()
248
         self.ax3 = self.ax1.twinx()
249
+        self.ax2.yaxis.set_label_position("right")
250
+        self.ax2.yaxis.set_ticks_position("right")
251
+        #self.ax2.yaxis.tick_right()
249
 
252
 
250
         #self.ax1.set_facecolor('red')
253
         #self.ax1.set_facecolor('red')
251
         #self.ax2.set_facecolor('red')
254
         #self.ax2.set_facecolor('red')

+ 81
- 121
akvo/tressel/mrsurvey.py View File

36
 plt.register_cmap(name='magma_r', cmap=cmaps.magma_r)
36
 plt.register_cmap(name='magma_r', cmap=cmaps.magma_r)
37
 
37
 
38
 
38
 
39
-def loadGMRBinaryFID( rawfname, istack, info ):
39
+def xxloadGMRBinaryFID( rawfname, info ):
40
     """ Reads a single binary GMR file and fills into DATADICT
40
     """ Reads a single binary GMR file and fills into DATADICT
41
     """
41
     """
42
 
42
 
556
             plot = should Akvo plot the results 
556
             plot = should Akvo plot the results 
557
             canvas = mpl plotting axis      
557
             canvas = mpl plotting axis      
558
         """
558
         """
559
-        #print("harmonic modelling...", f0)
560
-        #plot = True
561
         if plot:
559
         if plot:
562
             canvas.reAx2()
560
             canvas.reAx2()
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)
561
             canvas.ax1.set_ylabel(r"signal [nV]", fontsize=8)
568
             canvas.ax2.set_xlabel(r"time [s]", fontsize=8)
562
             canvas.ax2.set_xlabel(r"time [s]", fontsize=8)
569
             canvas.ax2.set_ylabel(r"signal [nV]", fontsize=8)
563
             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)
572
 
564
 
573
         # Data
565
         # Data
574
         iFID = 0
566
         iFID = 0
585
                 f1p[chan] = f1+1e-1
577
                 f1p[chan] = f1+1e-1
586
 
578
 
587
         for pulse in self.DATADICT["PULSES"]:
579
         for pulse in self.DATADICT["PULSES"]:
588
-            self.DATADICT[pulse]["TIMES"] =  self.DATADICT[pulse]["TIMES"]
589
             Nseg = int( np.floor(len( self.DATADICT[pulse]["TIMES"] ) / f0ns) )
580
             Nseg = int( np.floor(len( self.DATADICT[pulse]["TIMES"] ) / f0ns) )
590
             for istack in self.DATADICT["stacks"]:
581
             for istack in self.DATADICT["stacks"]:
591
                 for ipm in range(self.DATADICT["nPulseMoments"]):
582
                 for ipm in range(self.DATADICT["nPulseMoments"]):
592
                     if plot:
583
                     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()
584
                         canvas.softClear()
585
+                        mmax = 0
602
                         for ichan in self.DATADICT[pulse]["rchan"]:
586
                         for ichan in self.DATADICT[pulse]["rchan"]:
603
                             canvas.ax1.plot( self.DATADICT[pulse]["TIMES"], 1e9*self.DATADICT[pulse][ichan][ipm][istack], alpha=.5) 
587
                             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
-                            
588
+                            mmax = max( mmax, np.max(1e9*self.DATADICT[pulse][ichan][ipm][istack])) 
606
                         for ichan in self.DATADICT[pulse]["chan"]:
589
                         for ichan in self.DATADICT[pulse]["chan"]:
607
                             canvas.ax2.plot( self.DATADICT[pulse]["TIMES"], 1e9*self.DATADICT[pulse][ichan][ipm][istack], alpha=.5) 
590
                             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))
591
+                            mmax = max( mmax, np.max(1e9*self.DATADICT[pulse][ichan][ipm][istack])) 
609
                         canvas.ax1.set_prop_cycle(None)
592
                         canvas.ax1.set_prop_cycle(None)
610
                         canvas.ax2.set_prop_cycle(None)
593
                         canvas.ax2.set_prop_cycle(None)
594
+                        canvas.ax1.set_ylim(-mmax, mmax) 
611
                     for ichan in self.DATADICT[pulse]["rchan"]:
595
                     for ichan in self.DATADICT[pulse]["rchan"]:
612
                         if nF == 1:
596
                         if nF == 1:
613
-                            #self.DATADICT[pulse][ichan][ipm][istack] = harmonic.minHarmonic( f0, self.DATADICT[pulse][ichan][ipm][istack], self.samp, nK, self.DATADICT[pulse]["TIMES"] ) 
614
                             for iseg in range(f0ns):
597
                             for iseg in range(f0ns):
615
                                 if iseg < f0ns-1:
598
                                 if iseg < f0ns-1:
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], \
599
+                                    self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg:(iseg+1)*Nseg], f0p[ichan] = \
600
+                                        harmonic.minHarmonic( self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg:(iseg+1)*Nseg], \
617
                                             self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg:(iseg+1)*Nseg], \
601
                                             self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg:(iseg+1)*Nseg], \
618
                                             f0p[ichan], f0K1, f0KN, f0Ks ) 
602
                                             f0p[ichan], f0K1, f0KN, f0Ks ) 
619
                                 else:
603
                                 else:
620
-                                    self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg::], f0p[ichan] = harmonic.minHarmonic( self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg::], \
604
+                                    self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg::], f0p[ichan] = \
605
+                                        harmonic.minHarmonic( self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg::], \
621
                                             self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg::], \
606
                                             self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg::], \
622
                                             f0p[ichan], f0K1, f0KN, f0Ks ) 
607
                                             f0p[ichan], f0K1, f0KN, f0Ks ) 
623
-                            #self.DATADICT[pulse][ichan][ipm][istack] = harmonic.minHarmonic( self.DATADICT[pulse][ichan][ipm][istack], self.samp,  self.DATADICT[pulse]["TIMES"], \
624
-                            #    f0, f0K1, f0KN, f0Ks ) 
625
                         elif nF == 2:
608
                         elif nF == 2:
626
-                            #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"] ) 
627
-                            #self.DATADICT[pulse][ichan][ipm][istack] = harmonic.minHarmonic2( self.DATADICT[pulse][ichan][ipm][istack], self.samp,  self.DATADICT[pulse]["TIMES"], \
628
-                            #    f0-1e-2, f0K1, f0KN, f0Ks,  \
629
-                            #    f1+1e-2, f1K1, f1KN, f1Ks ) 
630
                             for iseg in range(f0ns):
609
                             for iseg in range(f0ns):
631
                                 if iseg < f0ns-1:
610
                                 if iseg < f0ns-1:
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],\
611
+                                    self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg:(iseg+1)*Nseg], f0p[ichan], f1p[ichan] = \
612
+                                        harmonic.minHarmonic2( self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg:(iseg+1)*Nseg],\
633
                                      self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg:(iseg+1)*Nseg], \
613
                                      self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg:(iseg+1)*Nseg], \
634
                                      f0p[ichan], f0K1, f0KN, f0Ks,  \
614
                                      f0p[ichan], f0K1, f0KN, f0Ks,  \
635
                                      f1p[ichan], f1K1, f1KN, f1Ks ) 
615
                                      f1p[ichan], f1K1, f1KN, f1Ks ) 
636
                                 else:
616
                                 else:
637
-                                    self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg::], f0p[ichan], f1p[ichan] = harmonic.minHarmonic2( self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg::],\
617
+                                    self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg::], f0p[ichan], f1p[ichan] = \
618
+                                        harmonic.minHarmonic2( self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg::],\
638
                                      self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg::], \
619
                                      self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg::], \
639
                                      f0p[ichan], f0K1, f0KN, f0Ks,  \
620
                                      f0p[ichan], f0K1, f0KN, f0Ks,  \
640
                                      f1p[ichan], f1K1, f1KN, f1Ks ) 
621
                                      f1p[ichan], f1K1, f1KN, f1Ks ) 
646
                     for ichan in self.DATADICT[pulse]["chan"]:
627
                     for ichan in self.DATADICT[pulse]["chan"]:
647
                         
628
                         
648
                         if nF == 1:
629
                         if nF == 1:
649
-                            #self.DATADICT[pulse][ichan][ipm][istack] = harmonic.minHarmonic( f0, self.DATADICT[pulse][ichan][ipm][istack], self.samp, nK, self.DATADICT[pulse]["TIMES"] ) 
650
-                            #self.DATADICT[pulse][ichan][ipm][istack] = harmonic.minHarmonic( self.DATADICT[pulse][ichan][ipm][istack], self.samp,  self.DATADICT[pulse]["TIMES"], \
651
-                            #    f0, f0K1, f0KN, f0Ks ) 
652
                             for iseg in range(f0ns):
630
                             for iseg in range(f0ns):
653
                                 if iseg < f0ns-1:
631
                                 if iseg < f0ns-1:
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
+                                    self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg:(iseg+1)*Nseg], f0p[ichan] = \
633
+                                        harmonic.minHarmonic( self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg:(iseg+1)*Nseg], 
655
                                             self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg:(iseg+1)*Nseg], \
634
                                             self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg:(iseg+1)*Nseg], \
656
                                             f0p[ichan], f0K1, f0KN, f0Ks ) 
635
                                             f0p[ichan], f0K1, f0KN, f0Ks ) 
657
                                 else:
636
                                 else:
658
-                                    self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg::], f0p[ichan] = harmonic.minHarmonic( self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg::], 
637
+                                    self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg::], f0p[ichan] = \
638
+                                        harmonic.minHarmonic( self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg::], 
659
                                             self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg::], \
639
                                             self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg::], \
660
                                             f0p[ichan], f0K1, f0KN, f0Ks )
640
                                             f0p[ichan], f0K1, f0KN, f0Ks )
661
 
641
 
662
                         elif nF == 2:
642
                         elif nF == 2:
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"] ) 
664
-                            #self.DATADICT[pulse][ichan][ipm][istack] = harmonic.harmonicEuler( f0, self.DATADICT[pulse][ichan][ipm][istack], self.samp, 20, self.DATADICT[pulse]["TIMES"] ) 
665
-                            #self.DATADICT[pulse][ichan][ipm][istack] = harmonic.minHarmonic2( self.DATADICT[pulse][ichan][ipm][istack], self.samp,  self.DATADICT[pulse]["TIMES"], \
666
-                            #    f0-1e-2, f0K1, f0KN, f0Ks,  \
667
-                            #    f1+1e-2, f1K1, f1KN, f1Ks ) 
668
                             for iseg in range(f0ns):
643
                             for iseg in range(f0ns):
669
                                 if iseg < f0ns-1:
644
                                 if iseg < f0ns-1:
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],\
645
+                                    self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg:(iseg+1)*Nseg], f0p[ichan], f1p[ichan] = \
646
+                                        harmonic.minHarmonic2( self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg:(iseg+1)*Nseg],\
671
                                      self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg:(iseg+1)*Nseg], \
647
                                      self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg:(iseg+1)*Nseg], \
672
                                      f0p[ichan], f0K1, f0KN, f0Ks,  \
648
                                      f0p[ichan], f0K1, f0KN, f0Ks,  \
673
                                      f1p[ichan], f1K1, f1KN, f1Ks ) 
649
                                      f1p[ichan], f1K1, f1KN, f1Ks ) 
674
                                 else:
650
                                 else:
675
-                                    self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg::], f0p[ichan], f1p[ichan] = harmonic.minHarmonic2( self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg::],\
651
+                                    self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg::], f0p[ichan], f1p[ichan] = \
652
+                                        harmonic.minHarmonic2( self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg::],\
676
                                      self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg::], \
653
                                      self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg::], \
677
                                      f0p[ichan], f0K1, f0KN, f0Ks,  \
654
                                      f0p[ichan], f0K1, f0KN, f0Ks,  \
678
                                      f1p[ichan], f1K1, f1KN, f1Ks ) 
655
                                      f1p[ichan], f1K1, f1KN, f1Ks ) 
686
                         canvas.ax1.legend(prop={'size':6}, loc='upper right')
663
                         canvas.ax1.legend(prop={'size':6}, loc='upper right')
687
                         canvas.ax2.legend(prop={'size':6}, loc='upper right')
664
                         canvas.ax2.legend(prop={'size':6}, loc='upper right')
688
                         canvas.draw() 
665
                         canvas.draw() 
689
-                    
690
-                #percent = (int)(1e2*((float)(iFID*self.DATADICT["nPulseMoments"]+(ipm))/(len(self.DATADICT["PULSES"])*self.nPulseMoments)))
666
+                
691
                 percent = (int)(1e2*((ipm+istack*self.nPulseMoments)/(self.nPulseMoments*len(self.DATADICT["stacks"])))) 
667
                 percent = (int)(1e2*((ipm+istack*self.nPulseMoments)/(self.nPulseMoments*len(self.DATADICT["stacks"])))) 
692
                 self.progressTrigger.emit(percent)  
668
                 self.progressTrigger.emit(percent)  
693
             iFID += 1
669
             iFID += 1
694
 
670
 
695
         self.doneTrigger.emit() 
671
         self.doneTrigger.emit() 
696
         self.updateProcTrigger.emit()  
672
         self.updateProcTrigger.emit()  
697
-
698
-
699
         self.doneTrigger.emit() 
673
         self.doneTrigger.emit() 
700
-        
701
     
674
     
702
     def FDSmartStack(self, outlierTest, MADcutoff, canvas):
675
     def FDSmartStack(self, outlierTest, MADcutoff, canvas):
703
         
676
         
1639
     def adaptiveFilter(self, M, flambda, truncate, mu, PCA, canvas):
1612
     def adaptiveFilter(self, M, flambda, truncate, mu, PCA, canvas):
1640
 
1613
 
1641
         canvas.reAx2(shx=False, shy=False)
1614
         canvas.reAx2(shx=False, shy=False)
1642
-         
1643
-        canvas.ax2.tick_params(axis='both', which='major', labelsize=8)
1644
-        canvas.ax2.ticklabel_format(style='sci', scilimits=(0,0), axis='y')  
1645
-        
1646
-        canvas.ax2.tick_params(axis='both', which='major', labelsize=8)
1647
-        canvas.ax2.ticklabel_format(style='sci', scilimits=(0,0), axis='y')  
1615
+        # ax1 is top plot of filter taps 
1616
+        # ax2 is bottom plot of conditioned signal 
1648
         
1617
         
1649
         if truncate:
1618
         if truncate:
1650
             itrunc =(int) ( round( 1e-3*truncate*self.samp ) )
1619
             itrunc =(int) ( round( 1e-3*truncate*self.samp ) )
1667
         for istack in self.DATADICT["stacks"]:
1636
         for istack in self.DATADICT["stacks"]:
1668
             for ipm in range(self.DATADICT["nPulseMoments"]):
1637
             for ipm in range(self.DATADICT["nPulseMoments"]):
1669
                 for pulse in self.DATADICT["PULSES"]:
1638
                 for pulse in self.DATADICT["PULSES"]:
1670
-                    canvas.ax1.clear()
1671
-                    canvas.ax2.clear()
1639
+                    canvas.softClear()
1640
+                    mmax = 0
1641
+                    for ichan in self.DATADICT[pulse]["chan"]:
1642
+                        canvas.ax2.plot( self.DATADICT[pulse]["TIMES"], 1e9* self.DATADICT[pulse][ichan][ipm][istack], alpha=.5) 
1643
+                        mmax = max(mmax, np.max(1e9*self.DATADICT[pulse][ichan][ipm][istack])) 
1644
+                    canvas.ax2.set_ylim(-mmax, mmax) 
1645
+                    canvas.ax2.set_prop_cycle(None)
1646
+
1672
                     for ichan in self.DATADICT[pulse]["chan"]:
1647
                     for ichan in self.DATADICT[pulse]["chan"]:
1673
                         #H = np.zeros(M)
1648
                         #H = np.zeros(M)
1674
-                        canvas.ax1.plot( self.DATADICT[pulse]["TIMES"], 1e9* self.DATADICT[pulse][ichan][ipm][istack],\
1675
-                            label = "noisy") 
1676
                         RX = []
1649
                         RX = []
1677
                         for irchan in self.DATADICT[pulse]["rchan"]:
1650
                         for irchan in self.DATADICT[pulse]["rchan"]:
1678
                             RX.append(self.DATADICT[pulse][irchan][ipm][istack][::-1])
1651
                             RX.append(self.DATADICT[pulse][irchan][ipm][istack][::-1])
1690
                                                         M, mu, PCA, flambda, H[pulse][ichan])
1663
                                                         M, mu, PCA, flambda, H[pulse][ichan])
1691
                         # replace
1664
                         # replace
1692
                         if truncate:
1665
                         if truncate:
1693
-                            canvas.ax1.plot( self.DATADICT[pulse]["TIMES"][0:itrunc], 1e9* e[::-1][0:itrunc],\
1694
-                            label = pulse + " ipm=" + str(ipm) + " istack=" + str(istack) + " ichan="  + str(ichan))
1666
+                            canvas.ax2.plot( self.DATADICT[pulse]["TIMES"][0:itrunc], 1e9* e[::-1][0:itrunc],\
1667
+                                label = pulse + " ipm=" + str(ipm) + " istack=" + str(istack) + " ichan="  + str(ichan))
1695
                             self.DATADICT[pulse][ichan][ipm][istack] = e[::-1][0:itrunc]
1668
                             self.DATADICT[pulse][ichan][ipm][istack] = e[::-1][0:itrunc]
1696
                         else:
1669
                         else:
1697
-                            canvas.ax1.plot( self.DATADICT[pulse]["TIMES"], 1e9* e[::-1],\
1698
-                            label = pulse + " ipm=" + str(ipm) + " istack=" + str(istack) + " ichan="  + str(ichan))
1670
+                            canvas.ax2.plot( self.DATADICT[pulse]["TIMES"], 1e9* e[::-1],\
1671
+                                label = pulse + " ipm=" + str(ipm) + " istack=" + str(istack) + " ichan="  + str(ichan))
1699
                             self.DATADICT[pulse][ichan][ipm][istack] = e[::-1]
1672
                             self.DATADICT[pulse][ichan][ipm][istack] = e[::-1]
1700
                             
1673
                             
1701
-                        canvas.ax2.plot( H[pulse][ichan] , label="taps") 
1702
-                        canvas.ax1.legend(prop={'size':6})
1703
-                        canvas.ax2.legend(prop={'size':6})
1674
+                        canvas.ax1.plot( H[pulse][ichan] ) # , label="taps") 
1675
+                        canvas.ax2.legend(prop={'size':6}, loc='upper right')
1676
+                        #canvas.ax2.legend(prop={'size':6}, loc='upper right')
1704
 
1677
 
1705
-                        canvas.ax1.set_xlabel(r"time [s]", fontsize=8)
1706
-                        canvas.ax1.set_ylabel(r"signal [nV]", fontsize=8)
1678
+                        canvas.ax2.set_xlabel(r"time [s]", fontsize=8)
1679
+                        canvas.ax2.set_ylabel(r"signal [nV]", fontsize=8)
1707
 
1680
 
1708
-                        canvas.ax2.set_xlabel(r"filter index", fontsize=8)
1709
-                        canvas.ax2.set_ylabel(r"scale factor", fontsize=8)
1681
+                        canvas.ax1.set_xlabel(r"filter index", fontsize=8)
1682
+                        canvas.ax1.set_ylabel(r"scale factor", fontsize=8)
1710
 
1683
 
1711
                     canvas.draw()
1684
                     canvas.draw()
1712
 
1685
 
2169
 
2142
 
2170
         if plot:
2143
         if plot:
2171
             canvas.reAx2()
2144
             canvas.reAx2()
2172
-            canvas.ax1.tick_params(axis='both', which='major', labelsize=8)
2173
-            canvas.ax1.ticklabel_format(style='sci', scilimits=(0,0), axis='y')  
2174
-            canvas.ax2.tick_params(axis='both', which='major', labelsize=8)
2175
-            canvas.ax2.ticklabel_format(style='sci', scilimits=(0,0), axis='y')  
2145
+            canvas.ax1.set_ylabel(r"signal [nV]", fontsize=8)
2146
+            canvas.ax2.set_xlabel(r"time [s]", fontsize=8)
2147
+            canvas.ax2.set_ylabel(r"signal [nV]", fontsize=8)
2176
 
2148
 
2177
         ife = (int)( max(self.fe, self.windead) * self.samp )
2149
         ife = (int)( max(self.fe, self.windead) * self.samp )
2178
         # Data
2150
         # Data
2179
         iFID = 0
2151
         iFID = 0
2180
         for pulse in self.DATADICT["PULSES"]:
2152
         for pulse in self.DATADICT["PULSES"]:
2181
-            self.DATADICT[pulse]["TIMES"] =  self.DATADICT[pulse]["TIMES"][ife:-ife]
2153
+            self.DATADICT[pulse]["TIMES"] = self.DATADICT[pulse]["TIMES"][ife:-ife]
2182
             for ipm in range(self.DATADICT["nPulseMoments"]):
2154
             for ipm in range(self.DATADICT["nPulseMoments"]):
2183
                 for istack in self.DATADICT["stacks"]:
2155
                 for istack in self.DATADICT["stacks"]:
2184
-                    canvas.ax1.clear()
2185
-                    canvas.ax2.clear()
2186
-                    #for ichan in np.append(self.DATADICT[pulse]["chan"], self.DATADICT[pulse]["rchan"]):
2156
+                    if plot:
2157
+                        canvas.softClear()
2158
+                        mmax = 0
2159
+                        for ichan in self.DATADICT[pulse]["rchan"]:
2160
+                            canvas.ax1.plot( self.DATADICT[pulse]["TIMES"], 1e9*self.DATADICT[pulse][ichan][ipm][istack][ife:-ife], alpha=.5)
2161
+                            mmax = max( mmax, np.max(1e9*self.DATADICT[pulse][ichan][ipm][istack][ife:-ife])) 
2162
+                        for ichan in self.DATADICT[pulse]["chan"]:
2163
+                            canvas.ax2.plot( self.DATADICT[pulse]["TIMES"], 1e9*self.DATADICT[pulse][ichan][ipm][istack][ife:-ife], alpha=.5)
2164
+                            mmax = max( mmax, np.max(1e9*self.DATADICT[pulse][ichan][ipm][istack][ife:-ife])) 
2165
+                        canvas.ax2.set_prop_cycle(None)
2166
+                        canvas.ax1.set_prop_cycle(None)
2167
+                        canvas.ax1.set_ylim(-mmax, mmax) 
2168
+
2187
                     for ichan in self.DATADICT[pulse]["rchan"]:
2169
                     for ichan in self.DATADICT[pulse]["rchan"]:
2188
                         # reflect signal back on itself to reduce gibbs effects on early times 
2170
                         # reflect signal back on itself to reduce gibbs effects on early times 
2189
                         #nr = len( self.DATADICT[pulse][ichan][ipm][istack] ) - 1 + ife
2171
                         #nr = len( self.DATADICT[pulse][ichan][ipm][istack] ) - 1 + ife
2217
                                 label = "data " + pulse + " ipm=" + str(ipm) + " istack=" + str(istack) + " chan="  + str(ichan))
2199
                                 label = "data " + pulse + " ipm=" + str(ipm) + " istack=" + str(istack) + " chan="  + str(ichan))
2218
 
2200
 
2219
                     if plot:
2201
                     if plot:
2220
-                        canvas.ax1.set_xlabel(r"time [s]", fontsize=8)
2221
-                        canvas.ax1.set_ylabel(r"signal [nV]", fontsize=8)
2222
-                        canvas.ax2.set_xlabel(r"time [s]", fontsize=8)
2223
-                        canvas.ax2.set_ylabel(r"signal [nV]", fontsize=8)
2224
-                        canvas.ax1.legend(prop={'size':6})
2225
-                        canvas.ax2.legend(prop={'size':6})
2202
+                        canvas.ax1.legend(prop={'size':6}, loc='upper right')
2203
+                        canvas.ax2.legend(prop={'size':6}, loc='upper right')
2226
                         canvas.draw() 
2204
                         canvas.draw() 
2227
                     
2205
                     
2228
                 percent = (int)(1e2*((float)(iFID*self.DATADICT["nPulseMoments"]+(ipm))/(len(self.DATADICT["PULSES"])*self.nPulseMoments)))
2206
                 percent = (int)(1e2*((float)(iFID*self.DATADICT["nPulseMoments"]+(ipm))/(len(self.DATADICT["PULSES"])*self.nPulseMoments)))
2395
         for ch in rchanin:
2373
         for ch in rchanin:
2396
             rchan.append(str(ch)) 
2374
             rchan.append(str(ch)) 
2397
 
2375
 
2398
-        # not in any headers but this has changed, NOT the place to do this. MOVE  
2399
-        #self.prePulseDelay  = 0.01          # delay before pulse
2400
-        self.deadTime       = deadTime       # instrument dead time before measurement
2376
+        self.deadTime = deadTime             # instrument dead time before measurement
2401
         self.samp = 50000.                   # in case this is a reproc, these might have 
2377
         self.samp = 50000.                   # in case this is a reproc, these might have 
2402
         self.dt   = 1./self.samp             # changed
2378
         self.dt   = 1./self.samp             # changed
2403
 
2379
 
2428
         ##############################################
2404
         ##############################################
2429
         # Read in binary (.lvm) data
2405
         # Read in binary (.lvm) data
2430
         iistack = 0
2406
         iistack = 0
2431
-        fnames = []
2432
         for istack in procStacks:
2407
         for istack in procStacks:
2433
             if self.nDAQVersion <= 1.0:
2408
             if self.nDAQVersion <= 1.0:
2434
                 try:
2409
                 try:
2436
                 except:
2411
                 except:
2437
                     self.loadGMRASCIIFID( base + "_" + str(istack) + ".lvm", istack )
2412
                     self.loadGMRASCIIFID( base + "_" + str(istack) + ".lvm", istack )
2438
             elif self.nDAQVersion < 2.3:
2413
             elif self.nDAQVersion < 2.3:
2439
-                #rawfname = base + "_" + str(istack) 
2440
                 self.loadGMRASCIIFID( base + "_" + str(istack), istack )
2414
                 self.loadGMRASCIIFID( base + "_" + str(istack), istack )
2441
             else:
2415
             else:
2442
                 self.loadGMRBinaryFID( base + "_" + str(istack) + ".lvm", istack )
2416
                 self.loadGMRBinaryFID( base + "_" + str(istack) + ".lvm", istack )
2443
-                #fnames.append( base + "_" + str(istack) + ".lvm" )
2444
-                
2445
-            percent = (int) (1e2*((float)((iistack*self.nPulseMoments+ipm+1))  / (len(procStacks)*self.nPulseMoments)))
2446
-            self.progressTrigger.emit(percent) 
2447
-            iistack += 1
2448
 
2417
 
2449
-        # multiprocessing load data
2450
-        #info = {}
2451
-        #info["prePulseDelay"] = self.prePulseDelay
2452
-        #with multiprocessing.Pool() as pool: 
2453
-        #    results = pool.starmap( loadGMRBinaryFID, zip(itertools.repeat(self), fnames, info ) ) # zip(np.tile(vc, (ns, 1)), np.tile(vgc, (ns,1)), itertools.repeat(sys.argv[1]), itertools.repeat(sys.argv[2]), EPS_CMR))
2454
-        # Plotting
2455
-
2456
-        if plot: 
2457
-            iistack = 0
2458
-            for istack in procStacks:
2418
+            if plot: 
2459
                 for ipm in range(self.nPulseMoments):
2419
                 for ipm in range(self.nPulseMoments):
2460
-                    canvas.ax1.clear()
2461
-                    canvas.ax2.clear()
2462
-                    canvas.ax3.clear()
2463
-                    #canvas.fig.patch.set_facecolor('blue')
2464
-                           
2420
+                    canvas.softClear()                           
2421
+
2465
                     for ichan in chan:
2422
                     for ichan in chan:
2466
                         canvas.ax1.plot(self.DATADICT["Pulse 1"]["PULSE_TIMES"], self.DATADICT["Pulse 1"]["CURRENT"][ipm][istack] , color='black')
2423
                         canvas.ax1.plot(self.DATADICT["Pulse 1"]["PULSE_TIMES"], self.DATADICT["Pulse 1"]["CURRENT"][ipm][istack] , color='black')
2467
                         canvas.ax3.plot(self.DATADICT["Pulse 1"]["TIMES"],       self.DATADICT["Pulse 1"][ichan][ipm][istack], label="Pulse 1 FID data ch. "+str(ichan)) #, color='blue')
2424
                         canvas.ax3.plot(self.DATADICT["Pulse 1"]["TIMES"],       self.DATADICT["Pulse 1"][ichan][ipm][istack], label="Pulse 1 FID data ch. "+str(ichan)) #, color='blue')
2469
                     for ichan in rchan:
2426
                     for ichan in rchan:
2470
                         canvas.ax2.plot(self.DATADICT["Pulse 1"]["TIMES"], self.DATADICT["Pulse 1"][ichan][ipm][istack], label="Pulse 1 FID ref ch. "+str(ichan)) #, color='blue')
2427
                         canvas.ax2.plot(self.DATADICT["Pulse 1"]["TIMES"], self.DATADICT["Pulse 1"][ichan][ipm][istack], label="Pulse 1 FID ref ch. "+str(ichan)) #, color='blue')
2471
 
2428
 
2472
-                    canvas.ax3.legend(prop={'size':6})
2473
-                    canvas.ax2.legend(prop={'size':6})
2429
+                    canvas.ax3.legend(prop={'size':6}, loc='upper right')
2430
+                    canvas.ax2.legend(prop={'size':6}, loc='upper right')
2474
                     
2431
                     
2475
                     canvas.ax1.set_title("stack "+str(istack)+" pulse index " + str(ipm), fontsize=8)
2432
                     canvas.ax1.set_title("stack "+str(istack)+" pulse index " + str(ipm), fontsize=8)
2476
-                    canvas.ax1.set_xlabel("time [s]", fontsize=8)
2477
                     canvas.ax1.set_ylabel("Current [A]", fontsize=8) 
2433
                     canvas.ax1.set_ylabel("Current [A]", fontsize=8) 
2478
                     canvas.ax1.ticklabel_format(style='sci', scilimits=(0,0), axis='y') 
2434
                     canvas.ax1.ticklabel_format(style='sci', scilimits=(0,0), axis='y') 
2479
                     
2435
                     
2480
                     canvas.ax2.set_ylabel("RAW signal [V]", fontsize=8)
2436
                     canvas.ax2.set_ylabel("RAW signal [V]", fontsize=8)
2437
+                    canvas.ax3.set_ylabel("RAW signal [V]", fontsize=8)
2481
                     canvas.ax2.tick_params(axis='both', which='major', labelsize=8)
2438
                     canvas.ax2.tick_params(axis='both', which='major', labelsize=8)
2482
                     canvas.ax2.tick_params(axis='both', which='minor', labelsize=6)
2439
                     canvas.ax2.tick_params(axis='both', which='minor', labelsize=6)
2483
                     canvas.ax2.set_xlabel("time [s]", fontsize=8)
2440
                     canvas.ax2.set_xlabel("time [s]", fontsize=8)
2484
-                    canvas.ax2.ticklabel_format(style='sci', scilimits=(0,0), axis='y') 
2485
-                    canvas.ax3.ticklabel_format(style='sci', scilimits=(0,0), axis='y') 
2486
                     canvas.draw()
2441
                     canvas.draw()
2487
 
2442
 
2488
-                percent = (int) (1e2*((float)((iistack*self.nPulseMoments+ipm+1))  / (len(procStacks)*self.nPulseMoments)))
2489
-                self.progressTrigger.emit(percent) 
2490
-                iistack += 1
2443
+            percent = (int) (1e2*((float)((iistack*self.nPulseMoments+ipm+1))  / (len(procStacks)*self.nPulseMoments)))
2444
+            self.progressTrigger.emit(percent) 
2445
+            iistack += 1
2446
+
2447
+#                percent = (int) (1e2*((float)((iistack*self.nPulseMoments+ipm+1))  / (len(procStacks)*self.nPulseMoments)))
2448
+#                self.progressTrigger.emit(percent) 
2449
+#                iistack += 1
2491
 
2450
 
2492
         self.enableDSP()    
2451
         self.enableDSP()    
2493
         self.doneTrigger.emit()
2452
         self.doneTrigger.emit()
2556
         # multiprocessing load data
2515
         # multiprocessing load data
2557
         #info = {}
2516
         #info = {}
2558
         #info["prePulseDelay"] = self.prePulseDelay
2517
         #info["prePulseDelay"] = self.prePulseDelay
2518
+        #info["samp"] = self.samp
2559
         #with multiprocessing.Pool() as pool: 
2519
         #with multiprocessing.Pool() as pool: 
2560
-        #    results = pool.starmap( loadGMRBinaryFID, zip(itertools.repeat(self), fnames, info ) ) # zip(np.tile(vc, (ns, 1)), np.tile(vgc, (ns,1)), itertools.repeat(sys.argv[1]), itertools.repeat(sys.argv[2]), EPS_CMR))
2520
+        #    results = pool.starmap( xxloadGMRBinaryFID, ( fnames, zip(itertools.repeat(info)) ) ) 
2561
         # Plotting
2521
         # Plotting
2562
 
2522
 
2563
         if plot: 
2523
         if plot: 
2576
                     for ichan in rchan:
2536
                     for ichan in rchan:
2577
                         canvas.ax2.plot(self.DATADICT["Pulse 1"]["TIMES"], self.DATADICT["Pulse 1"][ichan][ipm][istack], label="Pulse 1 FID ref ch. "+str(ichan)) #, color='blue')
2537
                         canvas.ax2.plot(self.DATADICT["Pulse 1"]["TIMES"], self.DATADICT["Pulse 1"][ichan][ipm][istack], label="Pulse 1 FID ref ch. "+str(ichan)) #, color='blue')
2578
 
2538
 
2579
-                    canvas.ax3.legend(prop={'size':6})
2580
-                    canvas.ax2.legend(prop={'size':6})
2539
+                    canvas.ax3.legend(prop={'size':6}, loc='upper right')
2540
+                    canvas.ax2.legend(prop={'size':6}, loc='upper right')
2581
                     
2541
                     
2582
                     canvas.ax1.set_title("stack "+str(istack)+" pulse index " + str(ipm), fontsize=8)
2542
                     canvas.ax1.set_title("stack "+str(istack)+" pulse index " + str(ipm), fontsize=8)
2583
                     canvas.ax1.set_xlabel("time [s]", fontsize=8)
2543
                     canvas.ax1.set_xlabel("time [s]", fontsize=8)
2757
                             canvas.ax1.plot(self.DATADICT["Pulse 2"]["TIMES"], self.DATADICT["Pulse 2"][ichan][ipm][istack], label="Pulse 2 FID ref ch. "+str(ichan)) #, color='blue')
2717
                             canvas.ax1.plot(self.DATADICT["Pulse 2"]["TIMES"], self.DATADICT["Pulse 2"][ichan][ipm][istack], label="Pulse 2 FID ref ch. "+str(ichan)) #, color='blue')
2758
                 
2718
                 
2759
                 if plot:
2719
                 if plot:
2760
-                    canvas.ax1.legend(prop={'size':6})
2720
+                    canvas.ax1.legend(prop={'size':6}, loc='upper right')
2761
                     canvas.ax1.set_title("stack "+str(istack)+" pulse index " + str(ipm), fontsize=8)
2721
                     canvas.ax1.set_title("stack "+str(istack)+" pulse index " + str(ipm), fontsize=8)
2762
                     canvas.ax1.set_xlabel("time [s]", fontsize=8)
2722
                     canvas.ax1.set_xlabel("time [s]", fontsize=8)
2763
                     canvas.ax1.set_ylabel("RAW signal [V]", fontsize=8)
2723
                     canvas.ax1.set_ylabel("RAW signal [V]", fontsize=8)

Loading…
Cancel
Save