|
@@ -34,6 +34,48 @@ plt.register_cmap(name='inferno_r', cmap=cmaps.inferno_r)
|
34
|
34
|
plt.register_cmap(name='magma', cmap=cmaps.magma)
|
35
|
35
|
plt.register_cmap(name='magma_r', cmap=cmaps.magma_r)
|
36
|
36
|
|
|
37
|
+
|
|
38
|
+def loadGMRBinaryFID( rawfname, istack, info ):
|
|
39
|
+ """ Reads a single binary GMR file and fills into DATADICT
|
|
40
|
+ """
|
|
41
|
+
|
|
42
|
+ #################################################################################
|
|
43
|
+ # figure out key data indices
|
|
44
|
+ # Pulse
|
|
45
|
+ nps = (int)((info["prePulseDelay"])*info["samp"])
|
|
46
|
+ npul = (int)(self.pulseLength[0]*self.samp) #+ 100
|
|
47
|
+
|
|
48
|
+ # Data
|
|
49
|
+ nds = nps+npul+(int)((self.deadTime)*self.samp); # indice pulse 1 data starts
|
|
50
|
+ nd1 = (int)(1.*self.samp) # samples in first pulse
|
|
51
|
+
|
|
52
|
+ invGain = 1./self.RxGain
|
|
53
|
+ invCGain = self.CurrentGain
|
|
54
|
+
|
|
55
|
+ pulse = "Pulse 1"
|
|
56
|
+ chan = self.DATADICT[pulse]["chan"]
|
|
57
|
+ rchan = self.DATADICT[pulse]["rchan"]
|
|
58
|
+
|
|
59
|
+ rawFile = open( rawfname, 'rb')
|
|
60
|
+
|
|
61
|
+ T = N_samp * self.dt
|
|
62
|
+ TIMES = np.arange(0, T, self.dt) - .0002 # small offset in GMR DAQ?
|
|
63
|
+
|
|
64
|
+ for ipm in range(self.nPulseMoments):
|
|
65
|
+ buf1 = rawFile.read(4)
|
|
66
|
+ buf2 = rawFile.read(4)
|
|
67
|
+
|
|
68
|
+ N_chan = struct.unpack('>i', buf1 )[0]
|
|
69
|
+ N_samp = struct.unpack('>i', buf2 )[0]
|
|
70
|
+
|
|
71
|
+ DATA = np.zeros([N_samp, N_chan+1])
|
|
72
|
+ for ichan in range(N_chan):
|
|
73
|
+ DATADUMP = rawFile.read(4*N_samp)
|
|
74
|
+ for irec in range(N_samp):
|
|
75
|
+ DATA[irec,ichan] = struct.unpack('>f', DATADUMP[irec*4:irec*4+4])[0]
|
|
76
|
+
|
|
77
|
+ return DATA, TIMES
|
|
78
|
+
|
37
|
79
|
class SNMRDataProcessor(QObject):
|
38
|
80
|
""" Revised class for preprocessing sNMR Data.
|
39
|
81
|
Derived types can read GMR files
|
|
@@ -724,49 +766,49 @@ class GMRDataProcessor(SNMRDataProcessor):
|
724
|
766
|
for ipm in range(0, self.DATADICT["nPulseMoments"]):
|
725
|
767
|
|
726
|
768
|
# Time since pulse rather than since record starts...
|
727
|
|
- if clip > 0:
|
728
|
|
- time_sp = 1e3 * (self.DATADICT[pulse]["TIMES"][clip-1::] - self.DATADICT[pulse]["PULSE_TIMES"][-1] )
|
729
|
|
- else:
|
730
|
|
- time_sp = 1e3 * (self.DATADICT[pulse]["TIMES"] - self.DATADICT[pulse]["PULSE_TIMES"][-1] )
|
|
769
|
+ #if clip > 0:
|
|
770
|
+ # time_sp = 1e3 * (self.DATADICT[pulse]["TIMES"][clip:] - self.DATADICT[pulse]["PULSE_TIMES"][-1] )
|
|
771
|
+ #else:
|
|
772
|
+ time_sp = 1e3 * (self.DATADICT[pulse]["TIMES"] - self.DATADICT[pulse]["PULSE_TIMES"][-1] )
|
731
|
773
|
|
732
|
774
|
#GT, GD, GTT, sig_stack, isum = rotate.gateIntegrate( self.DATADICT["CA"][pulse][chan][ipm,:], time_sp, gpd, self.sigma[pulse][chan], 1.5 )
|
733
|
775
|
#GT2, GP, GTT, sig_stack_err, isum = rotate.gateIntegrate( self.DATADICT["NR"][pulse][chan][ipm,:], time_sp, gpd, self.sigma[pulse][chan], 1.5 )
|
734
|
776
|
|
735
|
|
- GT, GCA, GTT, sig_stack, isum = rotate.gateIntegrate( self.DATADICT["CA"][pulse][chan][ipm,:], time_sp, gpd, self.sigma[pulse][chan], 1.5 )
|
736
|
|
- GT, GNR, GTT, sig_stack, isum = rotate.gateIntegrate( self.DATADICT["NR"][pulse][chan][ipm,:], time_sp, gpd, self.sigma[pulse][chan], 1.5 )
|
737
|
|
- GT, GRE, GTT, sig_stack, isum = rotate.gateIntegrate( self.DATADICT["RE"][pulse][chan][ipm,:], time_sp, gpd, self.sigma[pulse][chan], 1.5 )
|
738
|
|
- GT, GIM, GTT, sig_stack, isum = rotate.gateIntegrate( self.DATADICT["IM"][pulse][chan][ipm,:], time_sp, gpd, self.sigma[pulse][chan], 1.5 )
|
739
|
|
- GT, GIP, GTT, sig_stack, isum = rotate.gateIntegrate( self.DATADICT["IP"][pulse][chan][ipm,:], time_sp, gpd, self.sigma[pulse][chan], 1.5 )
|
|
777
|
+ GT, GCA, GTT, sig_stack, isum = rotate.gateIntegrate( self.DATADICT["CA"][pulse][chan][ipm], time_sp, gpd, self.sigma[pulse][chan], 1.5 )
|
|
778
|
+ GT, GNR, GTT, sig_stack, isum = rotate.gateIntegrate( self.DATADICT["NR"][pulse][chan][ipm], time_sp, gpd, self.sigma[pulse][chan], 1.5 )
|
|
779
|
+ GT, GRE, GTT, sig_stack, isum = rotate.gateIntegrate( self.DATADICT["RE"][pulse][chan][ipm], time_sp, gpd, self.sigma[pulse][chan], 1.5 )
|
|
780
|
+ GT, GIM, GTT, sig_stack, isum = rotate.gateIntegrate( self.DATADICT["IM"][pulse][chan][ipm], time_sp, gpd, self.sigma[pulse][chan], 1.5 )
|
|
781
|
+ GT, GIP, GTT, sig_stack, isum = rotate.gateIntegrate( self.DATADICT["IP"][pulse][chan][ipm], time_sp, gpd, self.sigma[pulse][chan], 1.5 )
|
740
|
782
|
|
741
|
783
|
if ipm == 0:
|
742
|
784
|
# self.GATED[chan]["DATA"] = np.zeros( ( self.DATADICT["nPulseMoments"], len(GT)) )
|
743
|
785
|
# self.GATED[chan]["ERR"] = np.zeros( ( self.DATADICT["nPulseMoments"], len(GT)) )
|
744
|
786
|
# self.GATED[chan]["SIGMA"] = np.zeros( ( self.DATADICT["nPulseMoments"], len(GT)) )
|
745
|
|
- self.GATED[chan]["CA"] = np.zeros( ( self.DATADICT["nPulseMoments"], len(GT)) )
|
746
|
|
- self.GATED[chan]["NR"] = np.zeros( ( self.DATADICT["nPulseMoments"], len(GT)) )
|
747
|
|
- self.GATED[chan]["RE"] = np.zeros( ( self.DATADICT["nPulseMoments"], len(GT)) )
|
748
|
|
- self.GATED[chan]["IM"] = np.zeros( ( self.DATADICT["nPulseMoments"], len(GT)) )
|
749
|
|
- self.GATED[chan]["IP"] = np.zeros( ( self.DATADICT["nPulseMoments"], len(GT)) )
|
|
787
|
+ self.GATED[chan]["CA"] = np.zeros( ( self.DATADICT["nPulseMoments"], len(GT)-clip) )
|
|
788
|
+ self.GATED[chan]["NR"] = np.zeros( ( self.DATADICT["nPulseMoments"], len(GT)-clip) )
|
|
789
|
+ self.GATED[chan]["RE"] = np.zeros( ( self.DATADICT["nPulseMoments"], len(GT)-clip) )
|
|
790
|
+ self.GATED[chan]["IM"] = np.zeros( ( self.DATADICT["nPulseMoments"], len(GT)-clip) )
|
|
791
|
+ self.GATED[chan]["IP"] = np.zeros( ( self.DATADICT["nPulseMoments"], len(GT)-clip) )
|
750
|
792
|
self.GATED[chan]["isum"] = isum
|
751
|
793
|
|
752
|
794
|
#self.GATED[chan]["DATA"][ipm] = GD.real
|
753
|
|
- self.GATEDABSCISSA = GT
|
754
|
|
- self.GATEDWINDOW = GTT
|
|
795
|
+ self.GATEDABSCISSA = GT[clip:]
|
|
796
|
+ self.GATEDWINDOW = GTT[clip:]
|
755
|
797
|
#self.GATED[chan]["SIGMA"][ipm] = sig_stack #_err # GP.real
|
756
|
798
|
#self.GATED[chan]["ERR"][ipm] = GP.real
|
757
|
799
|
|
758
|
|
- self.GATED[chan]["CA"][ipm] = GCA.real
|
759
|
|
- self.GATED[chan]["NR"][ipm] = GNR.real
|
760
|
|
- self.GATED[chan]["RE"][ipm] = GRE.real
|
761
|
|
- self.GATED[chan]["IM"][ipm] = GIM.real
|
762
|
|
- self.GATED[chan]["IP"][ipm] = GIP.real
|
|
800
|
+ self.GATED[chan]["CA"][ipm] = GCA.real[clip:]
|
|
801
|
+ self.GATED[chan]["NR"][ipm] = GNR.real[clip:]
|
|
802
|
+ self.GATED[chan]["RE"][ipm] = GRE.real[clip:]
|
|
803
|
+ self.GATED[chan]["IM"][ipm] = GIM.real[clip:]
|
|
804
|
+ self.GATED[chan]["IP"][ipm] = GIP.real[clip:]
|
763
|
805
|
|
764
|
806
|
percent = int(1e2* (float)((ipm)+ichan*self.DATADICT["nPulseMoments"]) /
|
765
|
807
|
(float)(self.DATADICT["nPulseMoments"] * len(self.DATADICT[pulse]["chan"])))
|
766
|
808
|
self.progressTrigger.emit(percent)
|
767
|
809
|
|
768
|
|
- self.GATED[chan]["GTT"] = GTT
|
769
|
|
- self.GATED[chan]["GT"] = GT
|
|
810
|
+ self.GATED[chan]["GTT"] = GTT[clip:]
|
|
811
|
+ self.GATED[chan]["GT"] = GT[clip:]
|
770
|
812
|
self.GATED[chan]["QQ"] = QQ
|
771
|
813
|
ichan += 1
|
772
|
814
|
self.doneTrigger.emit()
|
|
@@ -1911,17 +1953,29 @@ class GMRDataProcessor(SNMRDataProcessor):
|
1911
|
1953
|
##############################################
|
1912
|
1954
|
# Read in binary (.lvm) data
|
1913
|
1955
|
iistack = 0
|
|
1956
|
+ fnames = []
|
1914
|
1957
|
for istack in procStacks:
|
1915
|
|
-
|
1916
|
1958
|
if self.nDAQVersion < 2.3:
|
1917
|
1959
|
#rawfname = base + "_" + str(istack)
|
1918
|
1960
|
self.loadGMRASCIIFID( base + "_" + str(istack), istack )
|
1919
|
1961
|
else:
|
1920
|
1962
|
self.loadGMRBinaryFID( base + "_" + str(istack) + ".lvm", istack )
|
|
1963
|
+ #fnames.append( base + "_" + str(istack) + ".lvm" )
|
|
1964
|
+
|
|
1965
|
+ percent = (int) (1e2*((float)((iistack*self.nPulseMoments+ipm+1)) / (len(procStacks)*self.nPulseMoments)))
|
|
1966
|
+ self.progressTrigger.emit(percent)
|
|
1967
|
+ iistack += 1
|
1921
|
1968
|
|
1922
|
|
- # Plotting
|
1923
|
|
- if plot:
|
|
1969
|
+ # multiprocessing load data
|
|
1970
|
+ #info = {}
|
|
1971
|
+ #info["prePulseDelay"] = self.prePulseDelay
|
|
1972
|
+ #with multiprocessing.Pool() as pool:
|
|
1973
|
+ # 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))
|
1924
|
1974
|
|
|
1975
|
+ # Plotting
|
|
1976
|
+ if plot:
|
|
1977
|
+ iistack = 0
|
|
1978
|
+ for istack in procStacks:
|
1925
|
1979
|
for ipm in range(self.nPulseMoments):
|
1926
|
1980
|
canvas.ax1.clear()
|
1927
|
1981
|
canvas.ax2.clear()
|
|
@@ -1948,13 +2002,11 @@ class GMRDataProcessor(SNMRDataProcessor):
|
1948
|
2002
|
canvas.ax2.set_xlabel("time [s]", fontsize=8)
|
1949
|
2003
|
canvas.ax2.ticklabel_format(style='sci', scilimits=(0,0), axis='y')
|
1950
|
2004
|
canvas.ax3.ticklabel_format(style='sci', scilimits=(0,0), axis='y')
|
1951
|
|
-
|
1952
|
2005
|
canvas.draw()
|
1953
|
2006
|
|
1954
|
2007
|
percent = (int) (1e2*((float)((iistack*self.nPulseMoments+ipm+1)) / (len(procStacks)*self.nPulseMoments)))
|
1955
|
2008
|
self.progressTrigger.emit(percent)
|
1956
|
|
-
|
1957
|
|
- iistack += 1
|
|
2009
|
+ iistack += 1
|
1958
|
2010
|
|
1959
|
2011
|
self.enableDSP()
|
1960
|
2012
|
self.doneTrigger.emit()
|