Browse Source

Fix indexing bug in second to last segment with harmoinc modelling of multiple segments

tags/1.6.1
Trevor Irons 5 years ago
parent
commit
24087b34ba
1 changed files with 28 additions and 21 deletions
  1. 28
    21
      akvo/tressel/mrsurvey.py

+ 28
- 21
akvo/tressel/mrsurvey.py View File

570
 
570
 
571
         for pulse in self.DATADICT["PULSES"]:
571
         for pulse in self.DATADICT["PULSES"]:
572
             self.DATADICT[pulse]["TIMES"] =  self.DATADICT[pulse]["TIMES"]
572
             self.DATADICT[pulse]["TIMES"] =  self.DATADICT[pulse]["TIMES"]
573
-
573
+            Nseg = int( np.floor(len( self.DATADICT[pulse]["TIMES"] ) / f0ns) )
574
             for ipm in range(self.DATADICT["nPulseMoments"]):
574
             for ipm in range(self.DATADICT["nPulseMoments"]):
575
                 for istack in self.DATADICT["stacks"]:
575
                 for istack in self.DATADICT["stacks"]:
576
                     canvas.ax1.clear()
576
                     canvas.ax1.clear()
584
                         if nF == 1:
584
                         if nF == 1:
585
                             #self.DATADICT[pulse][ichan][ipm][istack] = harmonic.minHarmonic( f0, self.DATADICT[pulse][ichan][ipm][istack], self.samp, nK, self.DATADICT[pulse]["TIMES"] ) 
585
                             #self.DATADICT[pulse][ichan][ipm][istack] = harmonic.minHarmonic( f0, self.DATADICT[pulse][ichan][ipm][istack], self.samp, nK, self.DATADICT[pulse]["TIMES"] ) 
586
                             for iseg in range(f0ns):
586
                             for iseg in range(f0ns):
587
-                                if iseg < f0ns-2:
588
-                                    Nseg = int( np.floor(len( self.DATADICT[pulse]["TIMES"] ) / f0ns) )
589
-                                else:
590
-                                    Nseg = int( np.ceil(len( self.DATADICT[pulse]["TIMES"] ) / f0ns) )
591
-                                self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg:(iseg+1)*Nseg] = harmonic.minHarmonic( self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg:(iseg+1)*Nseg], \
587
+                                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], \
592
                                             self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg:(iseg+1)*Nseg], \
589
                                             self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg:(iseg+1)*Nseg], \
593
                                             f0, f0K1, f0KN, f0Ks ) 
590
                                             f0, f0K1, f0KN, f0Ks ) 
591
+                                else:
592
+                                    self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg::] = harmonic.minHarmonic( self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg::], \
593
+                                            self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg::], \
594
+                                            f0, f0K1, f0KN, f0Ks ) 
594
 
595
 
595
                             #self.DATADICT[pulse][ichan][ipm][istack] = harmonic.minHarmonic( self.DATADICT[pulse][ichan][ipm][istack], self.samp,  self.DATADICT[pulse]["TIMES"], \
596
                             #self.DATADICT[pulse][ichan][ipm][istack] = harmonic.minHarmonic( self.DATADICT[pulse][ichan][ipm][istack], self.samp,  self.DATADICT[pulse]["TIMES"], \
596
                             #    f0, f0K1, f0KN, f0Ks ) 
597
                             #    f0, f0K1, f0KN, f0Ks ) 
600
                             #    f0-1e-2, f0K1, f0KN, f0Ks,  \
601
                             #    f0-1e-2, f0K1, f0KN, f0Ks,  \
601
                             #    f1+1e-2, f1K1, f1KN, f1Ks ) 
602
                             #    f1+1e-2, f1K1, f1KN, f1Ks ) 
602
                             for iseg in range(f0ns):
603
                             for iseg in range(f0ns):
603
-                                if iseg < f0ns-2:
604
-                                    Nseg = int( np.floor(len( self.DATADICT[pulse]["TIMES"] ) / f0ns) )
605
-                                else:
606
-                                    Nseg = int( np.ceil(len( self.DATADICT[pulse]["TIMES"] ) / f0ns) )
607
-                                self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg:(iseg+1)*Nseg] = harmonic.minHarmonic2( self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg:(iseg+1)*Nseg],\
604
+                                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],\
608
                                      self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg:(iseg+1)*Nseg], \
606
                                      self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg:(iseg+1)*Nseg], \
609
                                      f0-1e-2, f0K1, f0KN, f0Ks,  \
607
                                      f0-1e-2, f0K1, f0KN, f0Ks,  \
610
                                      f1+1e-2, f1K1, f1KN, f1Ks ) 
608
                                      f1+1e-2, f1K1, f1KN, f1Ks ) 
609
+                                else:
610
+                                    self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg::] = harmonic.minHarmonic2( self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg::],\
611
+                                     self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg::], \
612
+                                     f0-1e-2, f0K1, f0KN, f0Ks,  \
613
+                                     f1+1e-2, f1K1, f1KN, f1Ks ) 
611
                         # plot
614
                         # plot
612
                         if plot:
615
                         if plot:
613
                             canvas.ax1.plot( self.DATADICT[pulse]["TIMES"], 1e9*self.DATADICT[pulse][ichan][ipm][istack], \
616
                             canvas.ax1.plot( self.DATADICT[pulse]["TIMES"], 1e9*self.DATADICT[pulse][ichan][ipm][istack], \
624
                             #self.DATADICT[pulse][ichan][ipm][istack] = harmonic.minHarmonic( self.DATADICT[pulse][ichan][ipm][istack], self.samp,  self.DATADICT[pulse]["TIMES"], \
627
                             #self.DATADICT[pulse][ichan][ipm][istack] = harmonic.minHarmonic( self.DATADICT[pulse][ichan][ipm][istack], self.samp,  self.DATADICT[pulse]["TIMES"], \
625
                             #    f0, f0K1, f0KN, f0Ks ) 
628
                             #    f0, f0K1, f0KN, f0Ks ) 
626
                             for iseg in range(f0ns):
629
                             for iseg in range(f0ns):
627
-                                if iseg < f0ns-2:
628
-                                    Nseg = int( np.floor(len( self.DATADICT[pulse]["TIMES"] ) / f0ns) )
629
-                                else:
630
-                                    Nseg = int( np.ceil(len( self.DATADICT[pulse]["TIMES"] ) / f0ns) )
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], 
630
+                                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], 
632
                                             self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg:(iseg+1)*Nseg], \
632
                                             self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg:(iseg+1)*Nseg], \
633
                                             f0, f0K1, f0KN, f0Ks ) 
633
                                             f0, f0K1, f0KN, f0Ks ) 
634
+                                else:
635
+                                    self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg::] = harmonic.minHarmonic( self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg::], 
636
+                                            self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg::], \
637
+                                            f0, f0K1, f0KN, f0Ks ) 
638
+
634
                         elif nF == 2:
639
                         elif nF == 2:
635
                             #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"] ) 
640
                             #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"] ) 
636
                             #self.DATADICT[pulse][ichan][ipm][istack] = harmonic.harmonicEuler( f0, self.DATADICT[pulse][ichan][ipm][istack], self.samp, 20, self.DATADICT[pulse]["TIMES"] ) 
641
                             #self.DATADICT[pulse][ichan][ipm][istack] = harmonic.harmonicEuler( f0, self.DATADICT[pulse][ichan][ipm][istack], self.samp, 20, self.DATADICT[pulse]["TIMES"] ) 
638
                             #    f0-1e-2, f0K1, f0KN, f0Ks,  \
643
                             #    f0-1e-2, f0K1, f0KN, f0Ks,  \
639
                             #    f1+1e-2, f1K1, f1KN, f1Ks ) 
644
                             #    f1+1e-2, f1K1, f1KN, f1Ks ) 
640
                             for iseg in range(f0ns):
645
                             for iseg in range(f0ns):
641
-                                if iseg < f0ns-2:
642
-                                    Nseg = int( np.floor(len( self.DATADICT[pulse]["TIMES"] ) / f0ns) )
643
-                                else:
644
-                                    Nseg = int( np.ceil(len( self.DATADICT[pulse]["TIMES"] ) / f0ns) )
645
-                                self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg:(iseg+1)*Nseg] = harmonic.minHarmonic2( self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg:(iseg+1)*Nseg],\
646
+                                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],\
646
                                      self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg:(iseg+1)*Nseg], \
648
                                      self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg:(iseg+1)*Nseg], \
647
                                      f0-1e-2, f0K1, f0KN, f0Ks,  \
649
                                      f0-1e-2, f0K1, f0KN, f0Ks,  \
648
                                      f1+1e-2, f1K1, f1KN, f1Ks ) 
650
                                      f1+1e-2, f1K1, f1KN, f1Ks ) 
651
+                                else:
652
+                                    self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg::] = harmonic.minHarmonic2( self.DATADICT[pulse][ichan][ipm][istack][iseg*Nseg::],\
653
+                                     self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg::], \
654
+                                     f0-1e-2, f0K1, f0KN, f0Ks,  \
655
+                                     f1+1e-2, f1K1, f1KN, f1Ks ) 
649
                
656
                
650
                         # plot
657
                         # plot
651
                         if plot:
658
                         if plot:

Loading…
Cancel
Save