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,7 +570,7 @@ class GMRDataProcessor(SNMRDataProcessor):
570 570
 
571 571
         for pulse in self.DATADICT["PULSES"]:
572 572
             self.DATADICT[pulse]["TIMES"] =  self.DATADICT[pulse]["TIMES"]
573
-
573
+            Nseg = int( np.floor(len( self.DATADICT[pulse]["TIMES"] ) / f0ns) )
574 574
             for ipm in range(self.DATADICT["nPulseMoments"]):
575 575
                 for istack in self.DATADICT["stacks"]:
576 576
                     canvas.ax1.clear()
@@ -584,13 +584,14 @@ class GMRDataProcessor(SNMRDataProcessor):
584 584
                         if nF == 1:
585 585
                             #self.DATADICT[pulse][ichan][ipm][istack] = harmonic.minHarmonic( f0, self.DATADICT[pulse][ichan][ipm][istack], self.samp, nK, self.DATADICT[pulse]["TIMES"] ) 
586 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 589
                                             self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg:(iseg+1)*Nseg], \
593 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 596
                             #self.DATADICT[pulse][ichan][ipm][istack] = harmonic.minHarmonic( self.DATADICT[pulse][ichan][ipm][istack], self.samp,  self.DATADICT[pulse]["TIMES"], \
596 597
                             #    f0, f0K1, f0KN, f0Ks ) 
@@ -600,14 +601,16 @@ class GMRDataProcessor(SNMRDataProcessor):
600 601
                             #    f0-1e-2, f0K1, f0KN, f0Ks,  \
601 602
                             #    f1+1e-2, f1K1, f1KN, f1Ks ) 
602 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 606
                                      self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg:(iseg+1)*Nseg], \
609 607
                                      f0-1e-2, f0K1, f0KN, f0Ks,  \
610 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 614
                         # plot
612 615
                         if plot:
613 616
                             canvas.ax1.plot( self.DATADICT[pulse]["TIMES"], 1e9*self.DATADICT[pulse][ichan][ipm][istack], \
@@ -624,13 +627,15 @@ class GMRDataProcessor(SNMRDataProcessor):
624 627
                             #self.DATADICT[pulse][ichan][ipm][istack] = harmonic.minHarmonic( self.DATADICT[pulse][ichan][ipm][istack], self.samp,  self.DATADICT[pulse]["TIMES"], \
625 628
                             #    f0, f0K1, f0KN, f0Ks ) 
626 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 632
                                             self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg:(iseg+1)*Nseg], \
633 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 639
                         elif nF == 2:
635 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 641
                             #self.DATADICT[pulse][ichan][ipm][istack] = harmonic.harmonicEuler( f0, self.DATADICT[pulse][ichan][ipm][istack], self.samp, 20, self.DATADICT[pulse]["TIMES"] ) 
@@ -638,14 +643,16 @@ class GMRDataProcessor(SNMRDataProcessor):
638 643
                             #    f0-1e-2, f0K1, f0KN, f0Ks,  \
639 644
                             #    f1+1e-2, f1K1, f1KN, f1Ks ) 
640 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 648
                                      self.samp,  self.DATADICT[pulse]["TIMES"][iseg*Nseg:(iseg+1)*Nseg], \
647 649
                                      f0-1e-2, f0K1, f0KN, f0Ks,  \
648 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 657
                         # plot
651 658
                         if plot:

Loading…
Cancel
Save