Browse Source

Binary file read is restored, working on ASCII

add-license-1
T-bone 7 years ago
parent
commit
fb9f6d9deb
1 changed files with 30 additions and 28 deletions
  1. 30
    28
      akvo/tressel/mrsurvey.py

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

@@ -1758,7 +1758,7 @@ class GMRDataProcessor(SNMRDataProcessor):
1758 1758
         self.doneTrigger.emit() 
1759 1759
         self.updateProcTrigger.emit()  
1760 1760
 
1761
-    def loadGMRBinaryFID( self, rawfname ):
1761
+    def loadGMRBinaryFID( self, rawfname, istack ):
1762 1762
         """ Reads a single binary GMR file and fills into DATADICT
1763 1763
         """
1764 1764
 
@@ -1781,32 +1781,33 @@ class GMRDataProcessor(SNMRDataProcessor):
1781 1781
         
1782 1782
         rawFile = open( rawfname, 'rb')
1783 1783
 
1784
-        buf1 = rawFile.read(4)
1785
-        buf2 = rawFile.read(4)
1784
+        for ipm in range(self.nPulseMoments):
1785
+            buf1 = rawFile.read(4)
1786
+            buf2 = rawFile.read(4)
1786 1787
                 
1787
-        N_chan = struct.unpack('>i', buf1 )[0]
1788
-        N_samp = struct.unpack('>i', buf2 )[0]
1788
+            N_chan = struct.unpack('>i', buf1 )[0]
1789
+            N_samp = struct.unpack('>i', buf2 )[0]
1789 1790
  
1790
-        T = N_samp * self.dt 
1791
-        TIMES = np.arange(0, T, self.dt) - .0002 # small offset in GMR DAQ?
1792
-
1793
-        DATA = np.zeros([N_samp, N_chan+1])
1794
-        for ichan in range(N_chan):
1795
-            DATADUMP = rawFile.read(4*N_samp)
1796
-            for irec in range(N_samp):
1797
-                DATA[irec,ichan] = struct.unpack('>f', DATADUMP[irec*4:irec*4+4])[0]
1791
+            T = N_samp * self.dt 
1792
+            TIMES = np.arange(0, T, self.dt) - .0002 # small offset in GMR DAQ?
1793
+
1794
+            DATA = np.zeros([N_samp, N_chan+1])
1795
+            for ichan in range(N_chan):
1796
+                DATADUMP = rawFile.read(4*N_samp)
1797
+                for irec in range(N_samp):
1798
+                    DATA[irec,ichan] = struct.unpack('>f', DATADUMP[irec*4:irec*4+4])[0]
1798 1799
                            
1799
-        # Save into Data Cube 
1800
-        for ichan in chan:
1801
-            self.DATADICT["Pulse 1"][ichan][ipm][istack] = DATA[:,eval(ichan)+3][nds:nds+nd1] * invGain 
1802
-            self.DATADICT["Pulse 1"]["TIMES"] = TIMES[nds:nds+nd1]
1803
-            self.DATADICT["Pulse 1"]["CURRENT"][ipm][istack] = DATA[:,1][nps:nps+npul] * invCGain
1804
-            self.DATADICT["Pulse 1"]["PULSE_TIMES"] = TIMES[nps:nps+npul] 
1805
-
1806
-        # plot reference channels?
1807
-        for ichan in rchan:
1808
-            self.DATADICT["Pulse 1"][ichan][ipm][istack] = DATA[:,eval(ichan)+3][nds:nds+nd1] * invGain 
1809
-            self.DATADICT["Pulse 1"]["TIMES"] = TIMES[nds:nds+nd1]
1800
+            # Save into Data Cube 
1801
+            for ichan in chan:
1802
+                self.DATADICT["Pulse 1"][ichan][ipm][istack] = DATA[:,eval(ichan)+3][nds:nds+nd1] * invGain 
1803
+                self.DATADICT["Pulse 1"]["TIMES"] = TIMES[nds:nds+nd1]
1804
+                self.DATADICT["Pulse 1"]["CURRENT"][ipm][istack] = DATA[:,1][nps:nps+npul] * invCGain
1805
+                self.DATADICT["Pulse 1"]["PULSE_TIMES"] = TIMES[nps:nps+npul] 
1806
+
1807
+            # reference channels?
1808
+            for ichan in rchan:
1809
+                self.DATADICT["Pulse 1"][ichan][ipm][istack] = DATA[:,eval(ichan)+3][nds:nds+nd1] * invGain 
1810
+                self.DATADICT["Pulse 1"]["TIMES"] = TIMES[nds:nds+nd1]
1810 1811
 
1811 1812
     def loadFIDData(self, base, procStacks, chanin, rchanin, FIDProc, canvas, deadTime, plot):
1812 1813
         '''
@@ -1861,15 +1862,16 @@ class GMRDataProcessor(SNMRDataProcessor):
1861 1862
             if self.nDAQVersion < 2.3:
1862 1863
                 rawfname = base + "_" + str(istack) 
1863 1864
             else:
1864
-                self.loadGMRBinaryFID( base + "_" + str(istack) + ".lvm" )
1865
+                self.loadGMRBinaryFID( base + "_" + str(istack) + ".lvm", istack )
1865 1866
 
1866 1867
             # Plotting
1867 1868
             if plot: 
1868
-                canvas.ax1.clear()
1869
-                canvas.ax2.clear()
1870
-                canvas.ax3.clear()
1871 1869
 
1872 1870
                 for ipm in range(self.nPulseMoments):
1871
+
1872
+                    canvas.ax1.clear()
1873
+                    canvas.ax2.clear()
1874
+                    canvas.ax3.clear()
1873 1875
                            
1874 1876
                     for ichan in chan:
1875 1877
                         canvas.ax1.plot(self.DATADICT["Pulse 1"]["PULSE_TIMES"], self.DATADICT["Pulse 1"]["CURRENT"][ipm][istack] , color='black')

Loading…
Cancel
Save