@@ -1,178 +1,178 | |||||
1 | ''' |
|
1 | ''' | |
2 | Created on Feb 7, 2012 |
|
2 | Created on Feb 7, 2012 | |
3 |
|
3 | |||
4 | @author $Author$ |
|
4 | @author $Author$ | |
5 | @version $Id$ |
|
5 | @version $Id$ | |
6 | ''' |
|
6 | ''' | |
7 |
|
7 | |||
8 | import os, sys |
|
8 | import os, sys | |
9 | import numpy |
|
9 | import numpy | |
10 | import datetime |
|
10 | import datetime | |
11 | import plplot |
|
11 | import plplot | |
12 |
|
12 | |||
13 | path = os.path.split(os.getcwd())[0] |
|
13 | path = os.path.split(os.getcwd())[0] | |
14 | sys.path.append(path) |
|
14 | sys.path.append(path) | |
15 |
|
15 | |||
16 | from Graphics.BaseGraph import * |
|
16 | from Graphics.BaseGraph import * | |
17 | from Model.Spectra import Spectra |
|
17 | from Model.Spectra import Spectra | |
18 |
|
18 | |||
19 | class Spectrum(): |
|
19 | class Spectrum(): | |
20 |
|
20 | |||
21 | def __init__(self, Spectra, index=0): |
|
21 | def __init__(self, Spectra, index=0): | |
22 |
|
22 | |||
23 | """ |
|
23 | """ | |
24 |
|
24 | |||
25 | Inputs: |
|
25 | Inputs: | |
26 |
|
26 | |||
27 | type: "power" ->> Potencia |
|
27 | type: "power" ->> Potencia | |
28 | "iq" ->> Real + Imaginario |
|
28 | "iq" ->> Real + Imaginario | |
29 | """ |
|
29 | """ | |
30 |
|
30 | |||
31 | self.__isPlotConfig = False |
|
31 | self.__isPlotConfig = False | |
32 |
|
32 | |||
33 | self.__isPlotIni = False |
|
33 | self.__isPlotIni = False | |
34 |
|
34 | |||
35 | self.__xrange = None |
|
35 | self.__xrange = None | |
36 |
|
36 | |||
37 | self.__yrange = None |
|
37 | self.__yrange = None | |
38 |
|
38 | |||
39 | self.nGraphs = 0 |
|
39 | self.nGraphs = 0 | |
40 |
|
40 | |||
41 | self.indexPlot = index |
|
41 | self.indexPlot = index | |
42 |
|
42 | |||
43 | self.graphObjList = [] |
|
43 | self.graphObjList = [] | |
44 |
|
44 | |||
45 | self.m_Spectra = Spectra |
|
45 | self.m_Spectra = Spectra | |
46 |
|
46 | |||
47 |
|
47 | |||
48 | def __addGraph(self, subpage, title="", xlabel="", ylabel="", showColorbar=False, showPowerProfile=True, XAxisAsTime=False): |
|
48 | def __addGraph(self, subpage, title="", xlabel="", ylabel="", showColorbar=False, showPowerProfile=True, XAxisAsTime=False): | |
49 |
|
49 | |||
50 | graphObj = ColorPlot() |
|
50 | graphObj = ColorPlot() | |
51 | graphObj.setup(subpage, |
|
51 | graphObj.setup(subpage, | |
52 | title, |
|
52 | title, | |
53 | xlabel, |
|
53 | xlabel, | |
54 | ylabel, |
|
54 | ylabel, | |
55 | showColorbar=showColorbar, |
|
55 | showColorbar=showColorbar, | |
56 | showPowerProfile=showPowerProfile, |
|
56 | showPowerProfile=showPowerProfile, | |
57 | XAxisAsTime=XAxisAsTime) |
|
57 | XAxisAsTime=XAxisAsTime) | |
58 |
|
58 | |||
59 | self.graphObjList.append(graphObj) |
|
59 | self.graphObjList.append(graphObj) | |
60 |
|
60 | |||
61 |
|
61 | |||
62 | def setup(self, titleList=None, xlabelList=None, ylabelList=None, showColorbar=False, showPowerProfile=True, XAxisAsTime=False): |
|
62 | def setup(self, titleList=None, xlabelList=None, ylabelList=None, showColorbar=False, showPowerProfile=True, XAxisAsTime=False): | |
63 |
|
63 | |||
64 | nChan = int(self.m_Spectra.m_SystemHeader.numChannels) |
|
64 | nChan = int(self.m_Spectra.m_SystemHeader.numChannels) | |
65 | channels = range(nChan) |
|
65 | channels = range(nChan) | |
66 |
|
66 | |||
67 | myXlabel = "Radial Velocity (m/s)" |
|
67 | myXlabel = "Radial Velocity (m/s)" | |
68 | myYlabel = "Range (km)" |
|
68 | myYlabel = "Range (km)" | |
69 |
|
69 | |||
70 | for i in channels: |
|
70 | for i in channels: | |
71 | if titleList != None: |
|
71 | if titleList != None: | |
72 | myTitle = titleList[i] |
|
72 | myTitle = titleList[i] | |
73 | myXlabel = xlabelList[i] |
|
73 | myXlabel = xlabelList[i] | |
74 | myYlabel = ylabelList[i] |
|
74 | myYlabel = ylabelList[i] | |
75 |
|
75 | |||
76 | # if self.m_Spectra.m_NoiseObj != None: |
|
76 | # if self.m_Spectra.m_NoiseObj != None: | |
77 | # noise = '%4.2fdB' %(self.m_Spectra.m_NoiseObj[i]) |
|
77 | # noise = '%4.2fdB' %(self.m_Spectra.m_NoiseObj[i]) | |
78 | # else: |
|
78 | # else: | |
79 | noise = '--' |
|
79 | noise = '--' | |
80 |
|
80 | |||
81 | myTitle = "Channel: %d - Noise: %s" %(i, noise) |
|
81 | myTitle = "Channel: %d - Noise: %s" %(i, noise) | |
82 |
|
82 | |||
83 | self.__addGraph(i+1, |
|
83 | self.__addGraph(i+1, | |
84 | title=myTitle, |
|
84 | title=myTitle, | |
85 | xlabel=myXlabel, |
|
85 | xlabel=myXlabel, | |
86 | ylabel=myYlabel, |
|
86 | ylabel=myYlabel, | |
87 | showColorbar=showColorbar, |
|
87 | showColorbar=showColorbar, | |
88 | showPowerProfile=showPowerProfile, |
|
88 | showPowerProfile=showPowerProfile, | |
89 | XAxisAsTime=XAxisAsTime) |
|
89 | XAxisAsTime=XAxisAsTime) | |
90 |
|
90 | |||
91 | self.nGraphs = nChan |
|
91 | self.nGraphs = nChan | |
92 | self.__isPlotConfig = True |
|
92 | self.__isPlotConfig = True | |
93 |
|
93 | |||
94 | def iniPlot(self, winTitle=""): |
|
94 | def iniPlot(self, winTitle=""): | |
95 |
|
95 | |||
96 | nx = int(numpy.sqrt(self.nGraphs)+1) |
|
96 | nx = int(numpy.sqrt(self.nGraphs)+1) | |
97 | #ny = int(self.nGraphs/nx) |
|
97 | #ny = int(self.nGraphs/nx) | |
98 |
|
98 | |||
99 | plplot.plsstrm(self.indexPlot) |
|
99 | plplot.plsstrm(self.indexPlot) | |
100 | plplot.plparseopts([winTitle], plplot.PL_PARSE_FULL) |
|
100 | plplot.plparseopts([winTitle], plplot.PL_PARSE_FULL) | |
101 | plplot.plsetopt("geometry", "%dx%d" %(300*nx, 240*nx)) |
|
101 | plplot.plsetopt("geometry", "%dx%d" %(300*nx, 240*nx)) | |
102 | plplot.plsdev("xwin") |
|
102 | plplot.plsdev("xwin") | |
103 | plplot.plscolbg(255,255,255) |
|
103 | plplot.plscolbg(255,255,255) | |
104 | plplot.plscol0(1,0,0,0) |
|
104 | plplot.plscol0(1,0,0,0) | |
105 | plplot.plinit() |
|
105 | plplot.plinit() | |
106 | plplot.plspause(False) |
|
106 | plplot.plspause(False) | |
107 | plplot.pladv(0) |
|
107 | plplot.pladv(0) | |
108 | plplot.plssub(nx, nx) |
|
108 | plplot.plssub(nx, nx) | |
109 |
|
109 | |||
110 | self.__nx = nx |
|
110 | self.__nx = nx | |
111 | self.__ny = nx |
|
111 | self.__ny = nx | |
112 | self.__isPlotIni = True |
|
112 | self.__isPlotIni = True | |
113 |
|
113 | |||
114 |
|
114 | |||
115 | def plotData(self, xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, titleList=None, xlabelList=None, ylabelList=None, showColorbar=False, showPowerProfile=True, XAxisAsTime=False, winTitle="Spectra"): |
|
115 | def plotData(self, xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, titleList=None, xlabelList=None, ylabelList=None, showColorbar=False, showPowerProfile=True, XAxisAsTime=False, winTitle="Spectra"): | |
116 |
|
116 | |||
117 | if not(self.__isPlotConfig): |
|
117 | if not(self.__isPlotConfig): | |
118 | self.setup(titleList, |
|
118 | self.setup(titleList, | |
119 | xlabelList, |
|
119 | xlabelList, | |
120 | ylabelList, |
|
120 | ylabelList, | |
121 | showColorbar, |
|
121 | showColorbar, | |
122 | showPowerProfile, |
|
122 | showPowerProfile, | |
123 | XAxisAsTime) |
|
123 | XAxisAsTime) | |
124 |
|
124 | |||
125 | if not(self.__isPlotIni): |
|
125 | if not(self.__isPlotIni): | |
126 | self.iniPlot(winTitle) |
|
126 | self.iniPlot(winTitle) | |
127 |
|
127 | |||
128 | plplot.plsstrm(self.indexPlot) |
|
128 | plplot.plsstrm(self.indexPlot) | |
129 |
|
129 | |||
130 | data = 10.*numpy.log10(self.m_Spectra.data_spc) |
|
130 | data = 10.*numpy.log10(self.m_Spectra.data_spc) | |
131 |
|
131 | |||
132 | #data.shape = Channels x Heights x Profiles |
|
132 | #data.shape = Channels x Heights x Profiles | |
133 | data = numpy.transpose( data, (0,2,1) ) |
|
133 | # data = numpy.transpose( data, (0,2,1) ) | |
134 | #data.shape = Channels x Profiles x Heights |
|
134 | #data.shape = Channels x Profiles x Heights | |
135 |
|
135 | |||
136 | nChan, nX, nY = numpy.shape(data) |
|
136 | nChan, nX, nY = numpy.shape(data) | |
137 |
|
137 | |||
138 | x = numpy.arange(nX) |
|
138 | x = numpy.arange(nX) | |
139 | y = self.m_Spectra.heights |
|
139 | y = self.m_Spectra.heights | |
140 |
|
140 | |||
141 | thisDatetime = datetime.datetime.fromtimestamp(self.m_Spectra.m_BasicHeader.utc) |
|
141 | thisDatetime = datetime.datetime.fromtimestamp(self.m_Spectra.m_BasicHeader.utc) | |
142 | txtDate = "Self Spectra - Date: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
142 | txtDate = "Self Spectra - Date: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
143 |
|
143 | |||
144 | if xmin == None: xmin = x[0] |
|
144 | if xmin == None: xmin = x[0] | |
145 | if xmax == None: xmax = x[-1] |
|
145 | if xmax == None: xmax = x[-1] | |
146 | if ymin == None: ymin = y[0] |
|
146 | if ymin == None: ymin = y[0] | |
147 | if ymax == None: ymax = y[-1] |
|
147 | if ymax == None: ymax = y[-1] | |
148 | if zmin == None: zmin = numpy.nanmin(abs(data)) |
|
148 | if zmin == None: zmin = numpy.nanmin(abs(data)) | |
149 | if zmax == None: zmax = numpy.nanmax(abs(data)) |
|
149 | if zmax == None: zmax = numpy.nanmax(abs(data)) | |
150 |
|
150 | |||
151 | plplot.plbop() |
|
151 | plplot.plbop() | |
152 |
|
152 | |||
153 | plplot.plssub(self.__nx, self.__ny) |
|
153 | plplot.plssub(self.__nx, self.__ny) | |
154 | for i in range(self.nGraphs): |
|
154 | for i in range(self.nGraphs): | |
155 | self.graphObjList[i].iniSubpage() |
|
155 | self.graphObjList[i].iniSubpage() | |
156 | self.graphObjList[i].plotData(data[i,:,:], |
|
156 | self.graphObjList[i].plotData(data[i,:,:], | |
157 | x, |
|
157 | x, | |
158 | y, |
|
158 | y, | |
159 | xmin=xmin, |
|
159 | xmin=xmin, | |
160 | xmax=xmax, |
|
160 | xmax=xmax, | |
161 | ymin=ymin, |
|
161 | ymin=ymin, | |
162 | ymax=ymax, |
|
162 | ymax=ymax, | |
163 | zmin=zmin, |
|
163 | zmin=zmin, | |
164 | zmax=zmax) |
|
164 | zmax=zmax) | |
165 |
|
165 | |||
166 | plplot.plssub(1,0) |
|
166 | plplot.plssub(1,0) | |
167 | plplot.pladv(0) |
|
167 | plplot.pladv(0) | |
168 | plplot.plvpor(0., 1., 0., 1.) |
|
168 | plplot.plvpor(0., 1., 0., 1.) | |
169 | plplot.plmtex("t",-1., 0.5, 0.5, txtDate) |
|
169 | plplot.plmtex("t",-1., 0.5, 0.5, txtDate) | |
170 | plplot.plflush() |
|
170 | plplot.plflush() | |
171 | plplot.pleop() |
|
171 | plplot.pleop() | |
172 |
|
172 | |||
173 | def end(self): |
|
173 | def end(self): | |
174 | plplot.plend() |
|
174 | plplot.plend() | |
175 |
|
175 | |||
176 |
|
176 | |||
177 | if __name__ == '__main__': |
|
177 | if __name__ == '__main__': | |
178 | pass No newline at end of file |
|
178 | pass |
@@ -1,182 +1,182 | |||||
1 | ''' |
|
1 | ''' | |
2 | Created on Feb 7, 2012 |
|
2 | Created on Feb 7, 2012 | |
3 |
|
3 | |||
4 | @author $Author$ |
|
4 | @author $Author$ | |
5 | @version $Id$ |
|
5 | @version $Id$ | |
6 | ''' |
|
6 | ''' | |
7 | import os, sys |
|
7 | import os, sys | |
8 | import numpy |
|
8 | import numpy | |
9 | import plplot |
|
9 | import plplot | |
10 |
|
10 | |||
11 | path = os.path.split(os.getcwd())[0] |
|
11 | path = os.path.split(os.getcwd())[0] | |
12 | sys.path.append(path) |
|
12 | sys.path.append(path) | |
13 |
|
13 | |||
14 | from Graphics.BaseGraph import * |
|
14 | from Graphics.BaseGraph import * | |
15 | from Model.Voltage import Voltage |
|
15 | from Model.Voltage import Voltage | |
16 |
|
16 | |||
17 | class Osciloscope(): |
|
17 | class Osciloscope(): | |
18 |
|
18 | |||
19 | def __init__(self, Voltage, index=0): |
|
19 | def __init__(self, Voltage, index=0): | |
20 |
|
20 | |||
21 | """ |
|
21 | """ | |
22 |
|
22 | |||
23 | Inputs: |
|
23 | Inputs: | |
24 |
|
24 | |||
25 | type: "power" ->> Potencia |
|
25 | type: "power" ->> Potencia | |
26 | "iq" ->> Real + Imaginario |
|
26 | "iq" ->> Real + Imaginario | |
27 | """ |
|
27 | """ | |
28 |
|
28 | |||
29 | self.__isPlotConfig = False |
|
29 | self.__isPlotConfig = False | |
30 |
|
30 | |||
31 | self.__isPlotIni = False |
|
31 | self.__isPlotIni = False | |
32 |
|
32 | |||
33 | self.__xrange = None |
|
33 | self.__xrange = None | |
34 |
|
34 | |||
35 | self.__yrange = None |
|
35 | self.__yrange = None | |
36 |
|
36 | |||
37 | self.m_Voltage = None |
|
37 | self.m_Voltage = None | |
38 |
|
38 | |||
39 | self.nGraphs = 0 |
|
39 | self.nGraphs = 0 | |
40 |
|
40 | |||
41 | self.indexPlot = index |
|
41 | self.indexPlot = index | |
42 |
|
42 | |||
43 | self.graphObjList = [] |
|
43 | self.graphObjList = [] | |
44 |
|
44 | |||
45 | self.m_Voltage = Voltage |
|
45 | self.m_Voltage = Voltage | |
46 |
|
46 | |||
47 |
|
47 | |||
48 | def __addGraph(self, subpage, title="", xlabel="", ylabel="", XAxisAsTime=False): |
|
48 | def __addGraph(self, subpage, title="", xlabel="", ylabel="", XAxisAsTime=False): | |
49 |
|
49 | |||
50 | graphObj = LinearPlot() |
|
50 | graphObj = LinearPlot() | |
51 | graphObj.setup(subpage, title="", xlabel="", ylabel="", XAxisAsTime=False) |
|
51 | graphObj.setup(subpage, title="", xlabel="", ylabel="", XAxisAsTime=False) | |
52 | #graphObj.setScreenPos() |
|
52 | #graphObj.setScreenPos() | |
53 |
|
53 | |||
54 | self.graphObjList.append(graphObj) |
|
54 | self.graphObjList.append(graphObj) | |
55 |
|
55 | |||
56 | del graphObj |
|
56 | del graphObj | |
57 |
|
57 | |||
58 | # def setXRange(self, xmin, xmax): |
|
58 | # def setXRange(self, xmin, xmax): | |
59 | # self.__xrange = (xmin, xmax) |
|
59 | # self.__xrange = (xmin, xmax) | |
60 | # |
|
60 | # | |
61 | # def setYRange(self, ymin, ymax): |
|
61 | # def setYRange(self, ymin, ymax): | |
62 | # self.__yrange = (ymin, ymax) |
|
62 | # self.__yrange = (ymin, ymax) | |
63 |
|
63 | |||
64 |
|
64 | |||
65 | def setup(self, titleList=None, xlabelList=None, ylabelList=None, XAxisAsTime=False): |
|
65 | def setup(self, titleList=None, xlabelList=None, ylabelList=None, XAxisAsTime=False): | |
66 |
|
66 | |||
67 | nChan = int(self.m_Voltage.m_SystemHeader.numChannels) |
|
67 | nChan = int(self.m_Voltage.m_SystemHeader.numChannels) | |
68 |
|
68 | |||
69 | myTitle = "" |
|
69 | myTitle = "" | |
70 | myXlabel = "" |
|
70 | myXlabel = "" | |
71 | myYlabel = "" |
|
71 | myYlabel = "" | |
72 |
|
72 | |||
73 |
for |
|
73 | for chan in range(nChan): | |
74 | if titleList != None: |
|
74 | if titleList != None: | |
75 |
myTitle = titleList[ |
|
75 | myTitle = titleList[chan] | |
76 |
myXlabel = xlabelList[ |
|
76 | myXlabel = xlabelList[chan] | |
77 |
myYlabel = ylabelList[ |
|
77 | myYlabel = ylabelList[chan] | |
78 |
|
78 | |||
79 |
self.__addGraph( |
|
79 | self.__addGraph(chan+1, title=myTitle, xlabel=myXlabel, ylabel=myYlabel, XAxisAsTime=XAxisAsTime) | |
80 |
|
80 | |||
81 | self.nGraphs = nChan |
|
81 | self.nGraphs = nChan | |
82 | self.__isPlotConfig = True |
|
82 | self.__isPlotConfig = True | |
83 |
|
83 | |||
84 | def iniPlot(self, winTitle=""): |
|
84 | def iniPlot(self, winTitle=""): | |
85 |
|
85 | |||
86 | plplot.plsstrm(self.indexPlot) |
|
86 | plplot.plsstrm(self.indexPlot) | |
87 | plplot.plparseopts([winTitle], plplot.PL_PARSE_FULL) |
|
87 | plplot.plparseopts([winTitle], plplot.PL_PARSE_FULL) | |
88 | plplot.plsetopt("geometry", "%dx%d" %(700, 115*self.nGraphs)) |
|
88 | plplot.plsetopt("geometry", "%dx%d" %(700, 115*self.nGraphs)) | |
89 | plplot.plsdev("xwin") |
|
89 | plplot.plsdev("xwin") | |
90 | plplot.plscolbg(255,255,255) |
|
90 | plplot.plscolbg(255,255,255) | |
91 | plplot.plscol0(1,0,0,0) |
|
91 | plplot.plscol0(1,0,0,0) | |
92 | plplot.plinit() |
|
92 | plplot.plinit() | |
93 | plplot.plspause(False) |
|
93 | plplot.plspause(False) | |
94 | plplot.plssub(1, self.nGraphs) |
|
94 | plplot.plssub(1, self.nGraphs) | |
95 |
|
95 | |||
96 | self.__isPlotIni = True |
|
96 | self.__isPlotIni = True | |
97 |
|
97 | |||
98 | def plotData(self, xmin=None, xmax=None, ymin=None, ymax=None, idProfile=None, titleList=None, xlabelList=None, ylabelList=None, XAxisAsTime=False, type='iq', winTitle="Voltage"): |
|
98 | def plotData(self, xmin=None, xmax=None, ymin=None, ymax=None, idProfile=None, titleList=None, xlabelList=None, ylabelList=None, XAxisAsTime=False, type='iq', winTitle="Voltage"): | |
99 |
|
99 | |||
100 | if idProfile != None and idProfile != self.m_Voltage.idProfile: |
|
100 | if idProfile != None and idProfile != self.m_Voltage.idProfile: | |
101 | return |
|
101 | return | |
102 |
|
102 | |||
103 | if not(self.__isPlotConfig): |
|
103 | if not(self.__isPlotConfig): | |
104 | self.setup(titleList, xlabelList, ylabelList, XAxisAsTime) |
|
104 | self.setup(titleList, xlabelList, ylabelList, XAxisAsTime) | |
105 |
|
105 | |||
106 | if not(self.__isPlotIni): |
|
106 | if not(self.__isPlotIni): | |
107 | self.iniPlot(winTitle) |
|
107 | self.iniPlot(winTitle) | |
108 |
|
108 | |||
109 | plplot.plsstrm(self.indexPlot) |
|
109 | plplot.plsstrm(self.indexPlot) | |
110 |
|
110 | |||
111 | data = self.m_Voltage.data |
|
111 | data = self.m_Voltage.data | |
112 |
|
112 | |||
113 | x = self.m_Voltage.heights |
|
113 | x = self.m_Voltage.heights | |
114 |
|
114 | |||
115 | if xmin == None: xmin = x[0] |
|
115 | if xmin == None: xmin = x[0] | |
116 | if xmax == None: xmax = x[-1] |
|
116 | if xmax == None: xmax = x[-1] | |
117 | if ymin == None: ymin = numpy.nanmin(abs(data)) |
|
117 | if ymin == None: ymin = numpy.nanmin(abs(data)) | |
118 | if ymax == None: ymax = numpy.nanmax(abs(data)) |
|
118 | if ymax == None: ymax = numpy.nanmax(abs(data)) | |
119 |
|
119 | |||
120 | plplot.plbop() |
|
120 | plplot.plbop() | |
121 |
for |
|
121 | for chan in range(self.nGraphs): | |
122 |
y = data[: |
|
122 | y = data[chan,:] | |
123 |
|
123 | |||
124 |
self.graphObjList[ |
|
124 | self.graphObjList[chan].iniSubpage() | |
125 |
self.graphObjList[ |
|
125 | self.graphObjList[chan].plotComplexData(x, y, xmin, xmax, ymin, ymax, 8, type) | |
126 |
|
126 | |||
127 | plplot.plflush() |
|
127 | plplot.plflush() | |
128 | plplot.pleop() |
|
128 | plplot.pleop() | |
129 |
|
129 | |||
130 | def end(self): |
|
130 | def end(self): | |
131 | plplot.plend() |
|
131 | plplot.plend() | |
132 |
|
132 | |||
133 | class VoltagePlot(object): |
|
133 | class VoltagePlot(object): | |
134 | ''' |
|
134 | ''' | |
135 | classdocs |
|
135 | classdocs | |
136 | ''' |
|
136 | ''' | |
137 |
|
137 | |||
138 | __m_Voltage = None |
|
138 | __m_Voltage = None | |
139 |
|
139 | |||
140 | def __init__(self, m_Voltage): |
|
140 | def __init__(self, m_Voltage): | |
141 | ''' |
|
141 | ''' | |
142 | Constructor |
|
142 | Constructor | |
143 | ''' |
|
143 | ''' | |
144 | self.__m_Voltage = m_Voltage |
|
144 | self.__m_Voltage = m_Voltage | |
145 |
|
145 | |||
146 | def setup(self): |
|
146 | def setup(self): | |
147 | pass |
|
147 | pass | |
148 |
|
148 | |||
149 | def addGraph(self, type, xrange=None, yrange=None, zrange=None): |
|
149 | def addGraph(self, type, xrange=None, yrange=None, zrange=None): | |
150 | pass |
|
150 | pass | |
151 |
|
151 | |||
152 | def plotData(self): |
|
152 | def plotData(self): | |
153 | pass |
|
153 | pass | |
154 |
|
154 | |||
155 | if __name__ == '__main__': |
|
155 | if __name__ == '__main__': | |
156 |
|
156 | |||
157 | import numpy |
|
157 | import numpy | |
158 |
|
158 | |||
159 | plplot.plsetopt("geometry", "%dx%d" %(450*2, 200*2)) |
|
159 | plplot.plsetopt("geometry", "%dx%d" %(450*2, 200*2)) | |
160 | plplot.plsdev("xcairo") |
|
160 | plplot.plsdev("xcairo") | |
161 | plplot.plscolbg(255,255,255) |
|
161 | plplot.plscolbg(255,255,255) | |
162 | plplot.plscol0(1,0,0,0) |
|
162 | plplot.plscol0(1,0,0,0) | |
163 | plplot.plinit() |
|
163 | plplot.plinit() | |
164 | plplot.plssub(1, 2) |
|
164 | plplot.plssub(1, 2) | |
165 |
|
165 | |||
166 | nx = 64 |
|
166 | nx = 64 | |
167 | ny = 100 |
|
167 | ny = 100 | |
168 |
|
168 | |||
169 | data = numpy.random.uniform(-50,50,(nx,ny)) |
|
169 | data = numpy.random.uniform(-50,50,(nx,ny)) | |
170 |
|
170 | |||
171 | baseObj = RTI() |
|
171 | baseObj = RTI() | |
172 | baseObj.setup(1, "Spectrum", "Frequency", "Range", "br_green", False, False) |
|
172 | baseObj.setup(1, "Spectrum", "Frequency", "Range", "br_green", False, False) | |
173 | baseObj.plotData(data) |
|
173 | baseObj.plotData(data) | |
174 |
|
174 | |||
175 | data = numpy.random.uniform(-50,50,(nx,ny)) |
|
175 | data = numpy.random.uniform(-50,50,(nx,ny)) | |
176 |
|
176 | |||
177 | base2Obj = RTI() |
|
177 | base2Obj = RTI() | |
178 | base2Obj.setup(2, "Spectrum", "Frequency", "Range", "br_green", True, True) |
|
178 | base2Obj.setup(2, "Spectrum", "Frequency", "Range", "br_green", True, True) | |
179 | base2Obj.plotData(data) |
|
179 | base2Obj.plotData(data) | |
180 |
|
180 | |||
181 | plplot.plend() |
|
181 | plplot.plend() | |
182 | exit(0) No newline at end of file |
|
182 | exit(0) |
@@ -1,392 +1,398 | |||||
1 | ''' |
|
1 | ''' | |
2 | Created on 23/01/2012 |
|
2 | Created on 23/01/2012 | |
3 |
|
3 | |||
4 | @author $Author$ |
|
4 | @author $Author$ | |
5 | @version $Id$ |
|
5 | @version $Id$ | |
6 | ''' |
|
6 | ''' | |
7 |
|
7 | |||
8 | import os, sys |
|
8 | import os, sys | |
9 | import numpy |
|
9 | import numpy | |
10 | import glob |
|
10 | import glob | |
11 | import fnmatch |
|
11 | import fnmatch | |
12 | import time, datetime |
|
12 | import time, datetime | |
13 |
|
13 | |||
14 | path = os.path.split(os.getcwd())[0] |
|
14 | path = os.path.split(os.getcwd())[0] | |
15 | sys.path.append(path) |
|
15 | sys.path.append(path) | |
16 |
|
16 | |||
17 | from Model.JROHeader import * |
|
17 | from Model.JROHeader import * | |
18 | from Model.Voltage import Voltage |
|
18 | from Model.Voltage import Voltage | |
19 |
|
19 | |||
20 | from IO.DataIO import JRODataReader |
|
20 | from IO.DataIO import JRODataReader | |
21 | from IO.DataIO import JRODataWriter |
|
21 | from IO.DataIO import JRODataWriter | |
22 |
|
22 | |||
23 |
|
23 | |||
24 | class VoltageReader(JRODataReader): |
|
24 | class VoltageReader(JRODataReader): | |
25 | """ |
|
25 | """ | |
26 | Esta clase permite leer datos de voltage desde archivos en formato rawdata (.r). La lectura |
|
26 | Esta clase permite leer datos de voltage desde archivos en formato rawdata (.r). La lectura | |
27 | de los datos siempre se realiza por bloques. Los datos leidos (array de 3 dimensiones: |
|
27 | de los datos siempre se realiza por bloques. Los datos leidos (array de 3 dimensiones: | |
28 | perfiles*alturas*canales) son almacenados en la variable "buffer". |
|
28 | perfiles*alturas*canales) son almacenados en la variable "buffer". | |
29 |
|
29 | |||
30 | perfiles * alturas * canales |
|
30 | perfiles * alturas * canales | |
31 |
|
31 | |||
32 | Esta clase contiene instancias (objetos) de las clases BasicHeader, SystemHeader, |
|
32 | Esta clase contiene instancias (objetos) de las clases BasicHeader, SystemHeader, | |
33 | RadarControllerHeader y Voltage. Los tres primeros se usan para almacenar informacion de la |
|
33 | RadarControllerHeader y Voltage. Los tres primeros se usan para almacenar informacion de la | |
34 | cabecera de datos (metadata), y el cuarto (Voltage) para obtener y almacenar un perfil de |
|
34 | cabecera de datos (metadata), y el cuarto (Voltage) para obtener y almacenar un perfil de | |
35 | datos desde el "buffer" cada vez que se ejecute el metodo "getData". |
|
35 | datos desde el "buffer" cada vez que se ejecute el metodo "getData". | |
36 |
|
36 | |||
37 | Example: |
|
37 | Example: | |
38 |
|
38 | |||
39 | dpath = "/home/myuser/data" |
|
39 | dpath = "/home/myuser/data" | |
40 |
|
40 | |||
41 | startTime = datetime.datetime(2010,1,20,0,0,0,0,0,0) |
|
41 | startTime = datetime.datetime(2010,1,20,0,0,0,0,0,0) | |
42 |
|
42 | |||
43 | endTime = datetime.datetime(2010,1,21,23,59,59,0,0,0) |
|
43 | endTime = datetime.datetime(2010,1,21,23,59,59,0,0,0) | |
44 |
|
44 | |||
45 | readerObj = VoltageReader() |
|
45 | readerObj = VoltageReader() | |
46 |
|
46 | |||
47 | readerObj.setup(dpath, startTime, endTime) |
|
47 | readerObj.setup(dpath, startTime, endTime) | |
48 |
|
48 | |||
49 | while(True): |
|
49 | while(True): | |
50 |
|
50 | |||
51 | #to get one profile |
|
51 | #to get one profile | |
52 | profile = readerObj.getData() |
|
52 | profile = readerObj.getData() | |
53 |
|
53 | |||
54 | #print the profile |
|
54 | #print the profile | |
55 | print profile |
|
55 | print profile | |
56 |
|
56 | |||
57 | #If you want to see all datablock |
|
57 | #If you want to see all datablock | |
58 | print readerObj.datablock |
|
58 | print readerObj.datablock | |
59 |
|
59 | |||
60 | if readerObj.flagNoMoreFiles: |
|
60 | if readerObj.flagNoMoreFiles: | |
61 | break |
|
61 | break | |
62 |
|
62 | |||
63 | """ |
|
63 | """ | |
64 | m_DataObj = None |
|
64 | m_DataObj = None | |
65 |
|
65 | |||
66 | idProfile = 0 |
|
66 | idProfile = 0 | |
67 |
|
67 | |||
68 | datablock = None |
|
68 | datablock = None | |
69 |
|
69 | |||
70 | pts2read = 0 |
|
70 | pts2read = 0 | |
71 |
|
71 | |||
72 | utc = 0 |
|
72 | utc = 0 | |
73 |
|
73 | |||
74 | ext = ".r" |
|
74 | ext = ".r" | |
75 |
|
75 | |||
76 | optchar = "D" |
|
76 | optchar = "D" | |
77 |
|
77 | |||
78 |
|
78 | |||
79 | def __init__(self, m_Voltage=None): |
|
79 | def __init__(self, m_Voltage=None): | |
80 | """ |
|
80 | """ | |
81 | Inicializador de la clase VoltageReader para la lectura de datos de voltage. |
|
81 | Inicializador de la clase VoltageReader para la lectura de datos de voltage. | |
82 |
|
82 | |||
83 | Input: |
|
83 | Input: | |
84 | m_Voltage : Objeto de la clase Voltage. Este objeto sera utilizado para |
|
84 | m_Voltage : Objeto de la clase Voltage. Este objeto sera utilizado para | |
85 | almacenar un perfil de datos cada vez que se haga un requerimiento |
|
85 | almacenar un perfil de datos cada vez que se haga un requerimiento | |
86 | (getData). El perfil sera obtenido a partir del buffer de datos, |
|
86 | (getData). El perfil sera obtenido a partir del buffer de datos, | |
87 | si el buffer esta vacio se hara un nuevo proceso de lectura de un |
|
87 | si el buffer esta vacio se hara un nuevo proceso de lectura de un | |
88 | bloque de datos. |
|
88 | bloque de datos. | |
89 | Si este parametro no es pasado se creara uno internamente. |
|
89 | Si este parametro no es pasado se creara uno internamente. | |
90 |
|
90 | |||
91 | Variables afectadas: |
|
91 | Variables afectadas: | |
92 | self.m_DataObj |
|
92 | self.m_DataObj | |
93 |
|
93 | |||
94 | Return: |
|
94 | Return: | |
95 | None |
|
95 | None | |
96 | """ |
|
96 | """ | |
97 | if m_Voltage == None: |
|
97 | if m_Voltage == None: | |
98 | m_Voltage = Voltage() |
|
98 | m_Voltage = Voltage() | |
99 |
|
99 | |||
100 | if not(isinstance(m_Voltage, Voltage)): |
|
100 | if not(isinstance(m_Voltage, Voltage)): | |
101 | raise ValueError, "in VoltageReader, m_Voltage must be an Voltage class object" |
|
101 | raise ValueError, "in VoltageReader, m_Voltage must be an Voltage class object" | |
102 |
|
102 | |||
103 | self.m_DataObj = m_Voltage |
|
103 | self.m_DataObj = m_Voltage | |
104 |
|
104 | |||
105 |
|
105 | |||
106 | def __hasNotDataInBuffer(self): |
|
106 | def __hasNotDataInBuffer(self): | |
107 | if self.datablockIndex >= self.m_ProcessingHeader.profilesPerBlock: |
|
107 | if self.datablockIndex >= self.m_ProcessingHeader.profilesPerBlock: | |
108 | return 1 |
|
108 | return 1 | |
109 | return 0 |
|
109 | return 0 | |
110 |
|
110 | |||
111 |
|
111 | |||
112 | def getBlockDimension(self): |
|
112 | def getBlockDimension(self): | |
113 | """ |
|
113 | """ | |
114 | Obtiene la cantidad de puntos a leer por cada bloque de datos |
|
114 | Obtiene la cantidad de puntos a leer por cada bloque de datos | |
115 |
|
115 | |||
116 | Affected: |
|
116 | Affected: | |
117 | self.pts2read |
|
117 | self.pts2read | |
118 | self.blocksize |
|
118 | self.blocksize | |
119 |
|
119 | |||
120 | Return: |
|
120 | Return: | |
121 | None |
|
121 | None | |
122 | """ |
|
122 | """ | |
123 | self.pts2read = self.m_ProcessingHeader.profilesPerBlock * self.m_ProcessingHeader.numHeights * self.m_SystemHeader.numChannels |
|
123 | self.pts2read = self.m_ProcessingHeader.profilesPerBlock * self.m_ProcessingHeader.numHeights * self.m_SystemHeader.numChannels | |
124 | self.blocksize = self.pts2read |
|
124 | self.blocksize = self.pts2read | |
125 | self.m_DataObj.nProfiles = self.m_ProcessingHeader.profilesPerBlock |
|
125 | self.m_DataObj.nProfiles = self.m_ProcessingHeader.profilesPerBlock | |
126 |
|
126 | |||
127 |
|
127 | |||
128 | def readBlock(self): |
|
128 | def readBlock(self): | |
129 | """ |
|
129 | """ | |
130 | readBlock lee el bloque de datos desde la posicion actual del puntero del archivo |
|
130 | readBlock lee el bloque de datos desde la posicion actual del puntero del archivo | |
131 | (self.fp) y actualiza todos los parametros relacionados al bloque de datos |
|
131 | (self.fp) y actualiza todos los parametros relacionados al bloque de datos | |
132 | (metadata + data). La data leida es almacenada en el buffer y el contador del buffer |
|
132 | (metadata + data). La data leida es almacenada en el buffer y el contador del buffer | |
133 | es seteado a 0 |
|
133 | es seteado a 0 | |
134 |
|
134 | |||
135 | Inputs: |
|
135 | Inputs: | |
136 | None |
|
136 | None | |
137 |
|
137 | |||
138 | Return: |
|
138 | Return: | |
139 | None |
|
139 | None | |
140 |
|
140 | |||
141 | Affected: |
|
141 | Affected: | |
142 | self.datablockIndex |
|
142 | self.datablockIndex | |
143 | self.datablock |
|
143 | self.datablock | |
144 | self.flagIsNewFile |
|
144 | self.flagIsNewFile | |
145 | self.idProfile |
|
145 | self.idProfile | |
146 | self.flagIsNewBlock |
|
146 | self.flagIsNewBlock | |
147 | self.nReadBlocks |
|
147 | self.nReadBlocks | |
148 |
|
148 | |||
149 | Exceptions: |
|
149 | Exceptions: | |
150 | Si un bloque leido no es un bloque valido |
|
150 | Si un bloque leido no es un bloque valido | |
151 | """ |
|
151 | """ | |
152 | blockOk_flag = False |
|
152 | blockOk_flag = False | |
153 | fpointer = self.fp.tell() |
|
153 | fpointer = self.fp.tell() | |
154 |
|
154 | |||
155 | junk = numpy.fromfile( self.fp, self.dataType, self.pts2read ) |
|
155 | junk = numpy.fromfile( self.fp, self.dataType, self.pts2read ) | |
156 |
|
156 | |||
157 | if self.online: |
|
157 | if self.online: | |
158 | if junk.size != self.blocksize: |
|
158 | if junk.size != self.blocksize: | |
159 | for nTries in range( self.nTries ): |
|
159 | for nTries in range( self.nTries ): | |
160 | print "\tWaiting %0.2f sec for the next block, try %03d ..." % (self.delay, nTries+1) |
|
160 | print "\tWaiting %0.2f sec for the next block, try %03d ..." % (self.delay, nTries+1) | |
161 | time.sleep( self.delay ) |
|
161 | time.sleep( self.delay ) | |
162 | self.fp.seek( fpointer ) |
|
162 | self.fp.seek( fpointer ) | |
163 | fpointer = self.fp.tell() |
|
163 | fpointer = self.fp.tell() | |
164 |
|
164 | |||
165 | junk = numpy.fromfile( self.fp, self.dataType, self.pts2read ) |
|
165 | junk = numpy.fromfile( self.fp, self.dataType, self.pts2read ) | |
166 |
|
166 | |||
167 | if junk.size == self.blocksize: |
|
167 | if junk.size == self.blocksize: | |
168 | blockOk_flag = True |
|
168 | blockOk_flag = True | |
169 | break |
|
169 | break | |
170 |
|
170 | |||
171 | if not( blockOk_flag ): |
|
171 | if not( blockOk_flag ): | |
172 | return 0 |
|
172 | return 0 | |
173 |
|
173 | |||
174 | try: |
|
174 | try: | |
175 | junk = junk.reshape( (self.m_ProcessingHeader.profilesPerBlock, self.m_ProcessingHeader.numHeights, self.m_SystemHeader.numChannels) ) |
|
175 | junk = junk.reshape( (self.m_ProcessingHeader.profilesPerBlock, self.m_ProcessingHeader.numHeights, self.m_SystemHeader.numChannels) ) | |
176 | except: |
|
176 | except: | |
177 | print "Data file %s is invalid" % self.filename |
|
177 | print "Data file %s is invalid" % self.filename | |
178 | return 0 |
|
178 | return 0 | |
179 |
|
179 | |||
|
180 | junk = numpy.transpose(junk, (2,0,1)) | |||
180 | self.datablock = junk['real'] + junk['imag']*1j |
|
181 | self.datablock = junk['real'] + junk['imag']*1j | |
181 |
|
182 | |||
182 | self.datablockIndex = 0 |
|
183 | self.datablockIndex = 0 | |
183 | self.flagIsNewFile = 0 |
|
184 | self.flagIsNewFile = 0 | |
184 | self.idProfile = 0 |
|
185 | self.idProfile = 0 | |
185 | self.flagIsNewBlock = 1 |
|
186 | self.flagIsNewBlock = 1 | |
186 |
|
187 | |||
187 | self.nReadBlocks += 1 |
|
188 | self.nReadBlocks += 1 | |
188 | self.nBlocks += 1 |
|
189 | self.nBlocks += 1 | |
189 |
|
190 | |||
190 | return 1 |
|
191 | return 1 | |
191 |
|
192 | |||
192 |
|
193 | |||
193 | def getData(self): |
|
194 | def getData(self): | |
194 | """ |
|
195 | """ | |
195 | getData obtiene una unidad de datos del buffer de lectura y la copia a la clase "Voltage" |
|
196 | getData obtiene una unidad de datos del buffer de lectura y la copia a la clase "Voltage" | |
196 | con todos los parametros asociados a este (metadata). cuando no hay datos en el buffer de |
|
197 | con todos los parametros asociados a este (metadata). cuando no hay datos en el buffer de | |
197 | lectura es necesario hacer una nueva lectura de los bloques de datos usando "readNextBlock" |
|
198 | lectura es necesario hacer una nueva lectura de los bloques de datos usando "readNextBlock" | |
198 |
|
199 | |||
199 | Ademas incrementa el contador del buffer en 1. |
|
200 | Ademas incrementa el contador del buffer en 1. | |
200 |
|
201 | |||
201 | Return: |
|
202 | Return: | |
202 | data : retorna un perfil de voltages (alturas * canales) copiados desde el |
|
203 | data : retorna un perfil de voltages (alturas * canales) copiados desde el | |
203 | buffer. Si no hay mas archivos a leer retorna None. |
|
204 | buffer. Si no hay mas archivos a leer retorna None. | |
204 |
|
205 | |||
205 | Variables afectadas: |
|
206 | Variables afectadas: | |
206 | self.m_DataObj |
|
207 | self.m_DataObj | |
207 | self.datablockIndex |
|
208 | self.datablockIndex | |
208 | self.idProfile |
|
209 | self.idProfile | |
209 |
|
210 | |||
210 | Affected: |
|
211 | Affected: | |
211 | self.m_DataObj |
|
212 | self.m_DataObj | |
212 | self.datablockIndex |
|
213 | self.datablockIndex | |
213 | self.flagResetProcessing |
|
214 | self.flagResetProcessing | |
214 | self.flagIsNewBlock |
|
215 | self.flagIsNewBlock | |
215 | self.idProfile |
|
216 | self.idProfile | |
216 | """ |
|
217 | """ | |
217 | if self.flagNoMoreFiles: return 0 |
|
218 | if self.flagNoMoreFiles: return 0 | |
218 |
|
219 | |||
219 | self.flagResetProcessing = 0 |
|
220 | self.flagResetProcessing = 0 | |
220 | self.flagIsNewBlock = 0 |
|
221 | self.flagIsNewBlock = 0 | |
221 |
|
222 | |||
222 | if self.__hasNotDataInBuffer(): |
|
223 | if self.__hasNotDataInBuffer(): | |
223 |
|
224 | |||
224 | if not( self.readNextBlock() ): |
|
225 | if not( self.readNextBlock() ): | |
225 | self.setNextFile() |
|
226 | self.setNextFile() | |
226 | return 0 |
|
227 | return 0 | |
227 |
|
228 | |||
228 | self.m_DataObj.m_BasicHeader = self.m_BasicHeader.copy() |
|
229 | self.m_DataObj.m_BasicHeader = self.m_BasicHeader.copy() | |
229 | self.m_DataObj.m_ProcessingHeader = self.m_ProcessingHeader.copy() |
|
230 | self.m_DataObj.m_ProcessingHeader = self.m_ProcessingHeader.copy() | |
230 | self.m_DataObj.m_RadarControllerHeader = self.m_RadarControllerHeader.copy() |
|
231 | self.m_DataObj.m_RadarControllerHeader = self.m_RadarControllerHeader.copy() | |
231 | self.m_DataObj.m_SystemHeader = self.m_SystemHeader.copy() |
|
232 | self.m_DataObj.m_SystemHeader = self.m_SystemHeader.copy() | |
232 | self.m_DataObj.heights = self.heights |
|
233 | self.m_DataObj.heights = self.heights | |
233 | self.m_DataObj.dataType = self.dataType |
|
234 | self.m_DataObj.dataType = self.dataType | |
234 |
|
235 | |||
235 | if self.flagNoMoreFiles == 1: |
|
236 | if self.flagNoMoreFiles == 1: | |
236 | print 'Process finished' |
|
237 | print 'Process finished' | |
237 | return 0 |
|
238 | return 0 | |
238 |
|
239 | |||
239 | #data es un numpy array de 3 dmensiones (perfiles, alturas y canales) |
|
240 | #data es un numpy array de 3 dmensiones (perfiles, alturas y canales) | |
240 |
|
241 | |||
241 | if self.datablock == None: |
|
242 | if self.datablock == None: | |
242 | self.m_DataObj.flagNoData = True |
|
243 | self.m_DataObj.flagNoData = True | |
243 | return 0 |
|
244 | return 0 | |
244 |
|
245 | |||
245 | time = self.m_BasicHeader.utc + self.datablockIndex * self.ippSeconds |
|
246 | time = self.m_BasicHeader.utc + self.datablockIndex * self.ippSeconds | |
246 | self.utc = time |
|
247 | self.utc = time | |
247 | #self.m_DataObj.m_BasicHeader.utc = time |
|
248 | #self.m_DataObj.m_BasicHeader.utc = time | |
248 |
|
249 | |||
249 | self.m_DataObj.flagNoData = False |
|
250 | self.m_DataObj.flagNoData = False | |
250 | self.m_DataObj.flagResetProcessing = self.flagResetProcessing |
|
251 | self.m_DataObj.flagResetProcessing = self.flagResetProcessing | |
251 |
|
252 | |||
252 |
self.m_DataObj.data = self.datablock[self.datablockIndex,: |
|
253 | self.m_DataObj.data = self.datablock[:,self.datablockIndex,:] | |
253 | self.m_DataObj.idProfile = self.idProfile |
|
254 | self.m_DataObj.idProfile = self.idProfile | |
254 |
|
255 | |||
255 | self.datablockIndex += 1 |
|
256 | self.datablockIndex += 1 | |
256 | self.idProfile += 1 |
|
257 | self.idProfile += 1 | |
257 |
|
258 | |||
258 | #call setData - to Data Object |
|
259 | #call setData - to Data Object | |
259 |
|
260 | |||
260 | return 1 #self.m_DataObj.data |
|
261 | return 1 #self.m_DataObj.data | |
261 |
|
262 | |||
262 |
|
263 | |||
263 | class VoltageWriter( JRODataWriter ): |
|
264 | class VoltageWriter( JRODataWriter ): | |
264 | """ |
|
265 | """ | |
265 | Esta clase permite escribir datos de voltajes a archivos procesados (.r). La escritura |
|
266 | Esta clase permite escribir datos de voltajes a archivos procesados (.r). La escritura | |
266 | de los datos siempre se realiza por bloques. |
|
267 | de los datos siempre se realiza por bloques. | |
267 | """ |
|
268 | """ | |
268 | __configHeaderFile = 'wrSetHeadet.txt' |
|
269 | __configHeaderFile = 'wrSetHeadet.txt' | |
269 |
|
270 | |||
270 | m_DataObj = None |
|
271 | m_DataObj = None | |
271 |
|
272 | |||
272 | ext = ".r" |
|
273 | ext = ".r" | |
273 |
|
274 | |||
274 | optchar = "D" |
|
275 | optchar = "D" | |
275 |
|
276 | |||
276 | datablock = None |
|
277 | datablock = None | |
277 |
|
278 | |||
278 | datablockIndex = 0 |
|
279 | datablockIndex = 0 | |
279 |
|
280 | |||
280 | shapeBuffer = None |
|
281 | shapeBuffer = None | |
281 |
|
282 | |||
282 |
|
283 | |||
283 | def __init__(self, m_Voltage=None): |
|
284 | def __init__(self, m_Voltage=None): | |
284 | """ |
|
285 | """ | |
285 | Inicializador de la clase VoltageWriter para la escritura de datos de espectros. |
|
286 | Inicializador de la clase VoltageWriter para la escritura de datos de espectros. | |
286 |
|
287 | |||
287 | Affected: |
|
288 | Affected: | |
288 | self.m_DataObj |
|
289 | self.m_DataObj | |
289 |
|
290 | |||
290 | Return: None |
|
291 | Return: None | |
291 | """ |
|
292 | """ | |
292 | if m_Voltage == None: |
|
293 | if m_Voltage == None: | |
293 | m_Voltage = Voltage() |
|
294 | m_Voltage = Voltage() | |
294 |
|
295 | |||
295 | if not( isinstance(m_Voltage, Voltage) ): |
|
296 | if not( isinstance(m_Voltage, Voltage) ): | |
296 | raise ValueError, "in VoltageReader, m_Spectra must be an Spectra class object" |
|
297 | raise ValueError, "in VoltageReader, m_Spectra must be an Spectra class object" | |
297 |
|
298 | |||
298 | self.m_DataObj = m_Voltage |
|
299 | self.m_DataObj = m_Voltage | |
299 |
|
300 | |||
300 |
|
301 | |||
301 | def hasAllDataInBuffer(self): |
|
302 | def hasAllDataInBuffer(self): | |
302 | if self.datablockIndex >= self.m_ProcessingHeader.profilesPerBlock: |
|
303 | if self.datablockIndex >= self.m_ProcessingHeader.profilesPerBlock: | |
303 | return 1 |
|
304 | return 1 | |
304 | return 0 |
|
305 | return 0 | |
305 |
|
306 | |||
306 |
|
307 | |||
307 | def setBlockDimension(self): |
|
308 | def setBlockDimension(self): | |
308 | """ |
|
309 | """ | |
309 | Obtiene las formas dimensionales del los subbloques de datos que componen un bloque |
|
310 | Obtiene las formas dimensionales del los subbloques de datos que componen un bloque | |
310 |
|
311 | |||
311 | Affected: |
|
312 | Affected: | |
312 | self.shape_spc_Buffer |
|
313 | self.shape_spc_Buffer | |
313 | self.shape_cspc_Buffer |
|
314 | self.shape_cspc_Buffer | |
314 | self.shape_dc_Buffer |
|
315 | self.shape_dc_Buffer | |
315 |
|
316 | |||
316 | Return: None |
|
317 | Return: None | |
317 | """ |
|
318 | """ | |
318 | self.shapeBuffer = (self.m_ProcessingHeader.profilesPerBlock, |
|
319 | self.shapeBuffer = (self.m_ProcessingHeader.profilesPerBlock, | |
319 | self.m_ProcessingHeader.numHeights, |
|
320 | self.m_ProcessingHeader.numHeights, | |
320 | self.m_SystemHeader.numChannels ) |
|
321 | self.m_SystemHeader.numChannels ) | |
321 |
|
322 | |||
322 |
self.datablock = numpy.zeros(self. |
|
323 | self.datablock = numpy.zeros(self.m_SystemHeader.numChannels, | |
|
324 | self.m_ProcessingHeader.profilesPerBlock, | |||
|
325 | self.m_ProcessingHeader.numHeights, | |||
|
326 | numpy.dtype('complex')) | |||
323 |
|
327 | |||
324 |
|
328 | |||
325 | def writeBlock(self): |
|
329 | def writeBlock(self): | |
326 | """ |
|
330 | """ | |
327 | Escribe el buffer en el file designado |
|
331 | Escribe el buffer en el file designado | |
328 |
|
332 | |||
329 | Affected: |
|
333 | Affected: | |
330 | self.datablockIndex |
|
334 | self.datablockIndex | |
331 | self.flagIsNewFile |
|
335 | self.flagIsNewFile | |
332 | self.flagIsNewBlock |
|
336 | self.flagIsNewBlock | |
333 | self.nWriteBlocks |
|
337 | self.nWriteBlocks | |
334 | self.blocksCounter |
|
338 | self.blocksCounter | |
335 |
|
339 | |||
336 | Return: None |
|
340 | Return: None | |
337 | """ |
|
341 | """ | |
338 | data = numpy.zeros( self.shapeBuffer, self.dataType ) |
|
342 | data = numpy.zeros( self.shapeBuffer, self.dataType ) | |
339 |
|
343 | |||
340 | data['real'] = self.datablock.real |
|
344 | junk = numpy.transpose(self.datablock, (1,2,0)) | |
341 | data['imag'] = self.datablock.imag |
|
345 | ||
|
346 | data['real'] = junk.real | |||
|
347 | data['imag'] = junk.imag | |||
342 |
|
348 | |||
343 | data = data.reshape( (-1) ) |
|
349 | data = data.reshape( (-1) ) | |
344 |
|
350 | |||
345 | data.tofile( self.fp ) |
|
351 | data.tofile( self.fp ) | |
346 |
|
352 | |||
347 | self.datablock.fill(0) |
|
353 | self.datablock.fill(0) | |
348 | self.datablockIndex = 0 |
|
354 | self.datablockIndex = 0 | |
349 | self.flagIsNewFile = 0 |
|
355 | self.flagIsNewFile = 0 | |
350 | self.flagIsNewBlock = 1 |
|
356 | self.flagIsNewBlock = 1 | |
351 | self.nWriteBlocks += 1 |
|
357 | self.nWriteBlocks += 1 | |
352 | self.blocksCounter += 1 |
|
358 | self.blocksCounter += 1 | |
353 |
|
359 | |||
354 |
|
360 | |||
355 | def putData(self): |
|
361 | def putData(self): | |
356 | """ |
|
362 | """ | |
357 | Setea un bloque de datos y luego los escribe en un file |
|
363 | Setea un bloque de datos y luego los escribe en un file | |
358 |
|
364 | |||
359 | Affected: |
|
365 | Affected: | |
360 | self.flagIsNewBlock |
|
366 | self.flagIsNewBlock | |
361 | self.datablockIndex |
|
367 | self.datablockIndex | |
362 |
|
368 | |||
363 | Return: |
|
369 | Return: | |
364 | 0 : Si no hay data o no hay mas files que puedan escribirse |
|
370 | 0 : Si no hay data o no hay mas files que puedan escribirse | |
365 | 1 : Si se escribio la data de un bloque en un file |
|
371 | 1 : Si se escribio la data de un bloque en un file | |
366 | """ |
|
372 | """ | |
367 | self.flagIsNewBlock = 0 |
|
373 | self.flagIsNewBlock = 0 | |
368 |
|
374 | |||
369 | if self.m_DataObj.flagNoData: |
|
375 | if self.m_DataObj.flagNoData: | |
370 | return 0 |
|
376 | return 0 | |
371 |
|
377 | |||
372 | if self.m_DataObj.flagResetProcessing: |
|
378 | if self.m_DataObj.flagResetProcessing: | |
373 |
|
379 | |||
374 | self.datablock.fill(0) |
|
380 | self.datablock.fill(0) | |
375 | self.datablockIndex = 0 |
|
381 | self.datablockIndex = 0 | |
376 | self.setNextFile() |
|
382 | self.setNextFile() | |
377 |
|
383 | |||
378 |
self.datablock[self.datablockIndex |
|
384 | self.datablock[:,self.datablockIndex,:] = self.m_DataObj.data | |
379 |
|
385 | |||
380 | self.datablockIndex += 1 |
|
386 | self.datablockIndex += 1 | |
381 |
|
387 | |||
382 | if self.hasAllDataInBuffer(): |
|
388 | if self.hasAllDataInBuffer(): | |
383 | #if self.flagIsNewFile: |
|
389 | #if self.flagIsNewFile: | |
384 | self.getHeader() |
|
390 | self.getHeader() | |
385 | self.writeNextBlock() |
|
391 | self.writeNextBlock() | |
386 |
|
392 | |||
387 | if self.flagNoMoreFiles: |
|
393 | if self.flagNoMoreFiles: | |
388 | #print 'Process finished' |
|
394 | #print 'Process finished' | |
389 | return 0 |
|
395 | return 0 | |
390 |
|
396 | |||
391 | return 1 |
|
397 | return 1 | |
392 | No newline at end of file |
|
398 |
@@ -1,183 +1,186 | |||||
1 | ''' |
|
1 | ''' | |
2 | Created on Feb 7, 2012 |
|
2 | Created on Feb 7, 2012 | |
3 |
|
3 | |||
4 | @author $Author$ |
|
4 | @author $Author$ | |
5 | @version $Id$ |
|
5 | @version $Id$ | |
6 | ''' |
|
6 | ''' | |
7 | import os, sys |
|
7 | import os, sys | |
8 | import numpy |
|
8 | import numpy | |
9 |
|
9 | |||
10 | path = os.path.split(os.getcwd())[0] |
|
10 | path = os.path.split(os.getcwd())[0] | |
11 | sys.path.append(path) |
|
11 | sys.path.append(path) | |
12 |
|
12 | |||
13 | from Model.Spectra import Spectra |
|
13 | from Model.Spectra import Spectra | |
14 | from IO.SpectraIO import SpectraWriter |
|
14 | from IO.SpectraIO import SpectraWriter | |
15 | from Graphics.SpectraPlot import Spectrum |
|
15 | from Graphics.SpectraPlot import Spectrum | |
16 |
|
16 | |||
17 |
|
17 | |||
18 | class SpectraProcessor: |
|
18 | class SpectraProcessor: | |
19 | ''' |
|
19 | ''' | |
20 | classdocs |
|
20 | classdocs | |
21 | ''' |
|
21 | ''' | |
22 |
|
22 | |||
23 | def __init__(self, spectraInObj, spectraOutObj=None, npts = None): |
|
23 | def __init__(self, spectraInObj, spectraOutObj=None, npts = None): | |
24 | ''' |
|
24 | ''' | |
25 | Constructor |
|
25 | Constructor | |
26 | ''' |
|
26 | ''' | |
27 | self.spectraInObj = spectraInObj |
|
27 | self.spectraInObj = spectraInObj | |
28 |
|
28 | |||
29 | if spectraOutObj == None: |
|
29 | if spectraOutObj == None: | |
30 | self.spectraOutObj = Spectra() |
|
30 | self.spectraOutObj = Spectra() | |
31 | else: |
|
31 | else: | |
32 | self.spectraOutObj = spectraOutObj |
|
32 | self.spectraOutObj = spectraOutObj | |
33 |
|
33 | |||
34 |
|
34 | |||
35 | self.integratorIndex = None |
|
35 | self.integratorIndex = None | |
36 | self.decoderIndex = None |
|
36 | self.decoderIndex = None | |
37 | self.writerIndex = None |
|
37 | self.writerIndex = None | |
38 | self.plotterIndex = None |
|
38 | self.plotterIndex = None | |
39 |
|
39 | |||
40 | if npts != None: |
|
40 | if npts != None: | |
41 | self.spectraOutObj.nPoints = npts |
|
41 | self.spectraOutObj.nPoints = npts | |
42 |
|
42 | |||
43 | self.npts = self.spectraOutObj.nPoints |
|
43 | self.npts = self.spectraOutObj.nPoints | |
44 |
|
44 | |||
45 | self.integratorList = [] |
|
45 | self.integratorList = [] | |
46 | self.decoderList = [] |
|
46 | self.decoderList = [] | |
47 | self.writerList = [] |
|
47 | self.writerList = [] | |
48 | self.plotterList = [] |
|
48 | self.plotterList = [] | |
49 |
|
49 | |||
50 | self.buffer = None |
|
50 | self.buffer = None | |
51 | self.ptsId = 0 |
|
51 | self.ptsId = 0 | |
52 |
|
52 | |||
53 | def init(self): |
|
53 | def init(self): | |
54 | self.integratorIndex = 0 |
|
54 | self.integratorIndex = 0 | |
55 | self.decoderIndex = 0 |
|
55 | self.decoderIndex = 0 | |
56 | self.writerIndex = 0 |
|
56 | self.writerIndex = 0 | |
57 | self.plotterIndex = 0 |
|
57 | self.plotterIndex = 0 | |
58 |
|
58 | |||
59 | if not( isinstance(self.spectraInObj, Spectra) ): |
|
59 | if not( isinstance(self.spectraInObj, Spectra) ): | |
60 | self.getFft() |
|
60 | self.getFft() | |
61 | else: |
|
61 | else: | |
62 | self.spectraOutObj.copy(self.spectraInObj) |
|
62 | self.spectraOutObj.copy(self.spectraInObj) | |
63 |
|
63 | |||
64 |
|
64 | |||
65 | def getFft(self): |
|
65 | def getFft(self): | |
66 |
|
66 | |||
67 | if self.buffer == None: |
|
67 | if self.buffer == None: | |
68 |
nheis = self.spectraInObj.data.shape[ |
|
68 | nheis = self.spectraInObj.data.shape[1] | |
69 |
nchannel = self.spectraInObj.data.shape[ |
|
69 | nchannel = self.spectraInObj.data.shape[0] | |
70 | npoints = self.spectraOutObj.nPoints |
|
70 | npoints = self.spectraOutObj.nPoints | |
71 |
self.buffer = numpy.zeros((nchannel,nheis |
|
71 | self.buffer = numpy.zeros((nchannel,npoints,nheis),dtype='complex') | |
72 |
|
|
72 | ||
73 | data = numpy.transpose(self.spectraInObj.data) |
|
73 | self.buffer[:,self.ptsId,:] = self.spectraInObj.data | |
74 | self.buffer[:,:,self.ptsId] = data |
|
|||
75 | self.ptsId += 1 |
|
74 | self.ptsId += 1 | |
76 | self.spectraOutObj.flagNoData = True |
|
75 | self.spectraOutObj.flagNoData = True | |
77 | if self.ptsId >= self.spectraOutObj.nPoints: |
|
76 | if self.ptsId >= self.spectraOutObj.nPoints: | |
78 |
data_spc = numpy.fft.fft(self.buffer,axis= |
|
77 | data_spc = numpy.fft.fft(self.buffer,axis=1) | |
79 | self.ptsId = 0 |
|
78 | self.ptsId = 0 | |
80 | self.buffer = None |
|
79 | self.buffer = None | |
81 |
|
80 | |||
82 | #calculo de self-spectra |
|
81 | #calculo de self-spectra | |
83 | self.spectraOutObj.data_spc = numpy.abs(data_spc * numpy.conjugate(data_spc)) |
|
82 | self.spectraOutObj.data_spc = numpy.abs(data_spc * numpy.conjugate(data_spc)) | |
84 |
|
83 | |||
85 |
|
||||
86 |
|
||||
87 | #calculo de cross-spectra |
|
84 | #calculo de cross-spectra | |
88 | #self.m_Spectra.data_cspc = self.__data_cspc |
|
85 | #self.m_Spectra.data_cspc = self.__data_cspc | |
89 |
|
86 | |||
90 |
|
||||
91 | #escribiendo dc |
|
87 | #escribiendo dc | |
92 | #self.m_Spectra.data_dc = self.__data_dc |
|
88 | #self.m_Spectra.data_dc = self.__data_dc | |
93 |
|
89 | |||
94 |
|
||||
95 | self.spectraOutObj.flagNoData = False |
|
90 | self.spectraOutObj.flagNoData = False | |
96 |
|
|
91 | ||
|
92 | self.spectraOutObj.heights = self.spectraInObj.heights | |||
|
93 | self.spectraOutObj.m_BasicHeader = self.spectraInObj.m_BasicHeader.copy() | |||
|
94 | self.spectraOutObj.m_ProcessingHeader = self.spectraInObj.m_ProcessingHeader.copy() | |||
|
95 | self.spectraOutObj.m_RadarControllerHeader = self.spectraInObj.m_RadarControllerHeader.copy() | |||
|
96 | self.spectraOutObj.m_SystemHeader = self.spectraInObj.m_SystemHeader.copy() | |||
97 |
|
97 | |||
98 | def addWriter(self,wrpath): |
|
98 | def addWriter(self,wrpath): | |
99 | objWriter = SpectraWriter(self.spectraOutObj) |
|
99 | objWriter = SpectraWriter(self.spectraOutObj) | |
100 | objWriter.setup(wrpath) |
|
100 | objWriter.setup(wrpath) | |
101 | self.writerList.append(objWriter) |
|
101 | self.writerList.append(objWriter) | |
102 |
|
102 | |||
103 |
|
103 | |||
104 | def addPlotter(self): |
|
104 | def addPlotter(self, index=None): | |
|
105 | ||||
|
106 | if index==None: | |||
|
107 | index = self.plotterIndex | |||
105 |
|
108 | |||
106 |
plotObj = Spectrum(self.spectraOutObj, |
|
109 | plotObj = Spectrum(self.spectraOutObj, index) | |
107 | self.plotterList.append(plotObj) |
|
110 | self.plotterList.append(plotObj) | |
108 |
|
111 | |||
109 |
|
112 | |||
110 | def addIntegrator(self,N): |
|
113 | def addIntegrator(self,N): | |
111 |
|
114 | |||
112 | objIncohInt = IncoherentIntegration(N) |
|
115 | objIncohInt = IncoherentIntegration(N) | |
113 | self.integratorList.append(objIncohInt) |
|
116 | self.integratorList.append(objIncohInt) | |
114 |
|
117 | |||
115 |
|
118 | |||
116 | def writeData(self): |
|
119 | def writeData(self): | |
117 | if self.voltageOutObj.flagNoData: |
|
120 | if self.voltageOutObj.flagNoData: | |
118 | return 0 |
|
121 | return 0 | |
119 |
|
122 | |||
120 | if len(self.writerList) <= self.writerIndex: |
|
123 | if len(self.writerList) <= self.writerIndex: | |
121 | self.addWriter(wrpath) |
|
124 | self.addWriter(wrpath) | |
122 |
|
125 | |||
123 | self.writerList[self.writerIndex].putData() |
|
126 | self.writerList[self.writerIndex].putData() | |
124 |
|
127 | |||
125 | self.writerIndex += 1 |
|
128 | self.writerIndex += 1 | |
126 |
|
129 | |||
127 | def plotData(self,xmin=None, xmax=None, ymin=None, ymax=None, winTitle=''): |
|
130 | def plotData(self,xmin=None, xmax=None, ymin=None, ymax=None, winTitle='', index=None): | |
128 | if self.spectraOutObj.flagNoData: |
|
131 | if self.spectraOutObj.flagNoData: | |
129 | return 0 |
|
132 | return 0 | |
130 |
|
133 | |||
131 | if len(self.plotterList) <= self.plotterIndex: |
|
134 | if len(self.plotterList) <= self.plotterIndex: | |
132 | self.addPlotter() |
|
135 | self.addPlotter(index) | |
133 |
|
136 | |||
134 | self.plotterList[self.plotterIndex].plotData(xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,winTitle=winTitle) |
|
137 | self.plotterList[self.plotterIndex].plotData(xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,winTitle=winTitle) | |
135 |
|
138 | |||
136 | self.plotterIndex += 1 |
|
139 | self.plotterIndex += 1 | |
137 |
|
140 | |||
138 | def integrator(self, N): |
|
141 | def integrator(self, N): | |
139 | if self.spectraOutObj.flagNoData: |
|
142 | if self.spectraOutObj.flagNoData: | |
140 | return 0 |
|
143 | return 0 | |
141 |
|
144 | |||
142 | if len(self.integratorList) <= self.integratorIndex: |
|
145 | if len(self.integratorList) <= self.integratorIndex: | |
143 | self.addIntegrator(N) |
|
146 | self.addIntegrator(N) | |
144 |
|
147 | |||
145 | myCohIntObj = self.integratorList[self.integratorIndex] |
|
148 | myCohIntObj = self.integratorList[self.integratorIndex] | |
146 | myCohIntObj.exe(self.spectraOutObj.data_spc) |
|
149 | myCohIntObj.exe(self.spectraOutObj.data_spc) | |
147 |
|
150 | |||
148 | if myCohIntObj.flag: |
|
151 | if myCohIntObj.flag: | |
149 | self.spectraOutObj.data_spc = myCohIntObj.data |
|
152 | self.spectraOutObj.data_spc = myCohIntObj.data | |
150 | self.spectraOutObj.m_ProcessingHeader.incoherentInt *= N |
|
153 | self.spectraOutObj.m_ProcessingHeader.incoherentInt *= N | |
151 | self.spectraOutObj.flagNoData = False |
|
154 | self.spectraOutObj.flagNoData = False | |
152 |
|
155 | |||
153 | else: |
|
156 | else: | |
154 | self.spectraOutObj.flagNoData = True |
|
157 | self.spectraOutObj.flagNoData = True | |
155 |
|
158 | |||
156 | self.integratorIndex += 1 |
|
159 | self.integratorIndex += 1 | |
157 |
|
160 | |||
158 | class IncoherentIntegration: |
|
161 | class IncoherentIntegration: | |
159 | def __init__(self, N): |
|
162 | def __init__(self, N): | |
160 | self.profCounter = 1 |
|
163 | self.profCounter = 1 | |
161 | self.data = None |
|
164 | self.data = None | |
162 | self.buffer = None |
|
165 | self.buffer = None | |
163 | self.flag = False |
|
166 | self.flag = False | |
164 | self.nIncohInt = N |
|
167 | self.nIncohInt = N | |
165 |
|
168 | |||
166 | def exe(self,data): |
|
169 | def exe(self,data): | |
167 | print 'intg:', self.profCounter |
|
170 | print 'intg:', self.profCounter | |
168 |
|
171 | |||
169 | if self.buffer == None: |
|
172 | if self.buffer == None: | |
170 | self.buffer = data |
|
173 | self.buffer = data | |
171 | else: |
|
174 | else: | |
172 | self.buffer = self.buffer + data |
|
175 | self.buffer = self.buffer + data | |
173 |
|
176 | |||
174 | if self.profCounter == self.nIncohInt: |
|
177 | if self.profCounter == self.nIncohInt: | |
175 | self.data = self.buffer |
|
178 | self.data = self.buffer | |
176 | self.buffer = None |
|
179 | self.buffer = None | |
177 | self.profCounter = 0 |
|
180 | self.profCounter = 0 | |
178 | self.flag = True |
|
181 | self.flag = True | |
179 | else: |
|
182 | else: | |
180 | self.flag = False |
|
183 | self.flag = False | |
181 |
|
184 | |||
182 | self.profCounter += 1 |
|
185 | self.profCounter += 1 | |
183 |
|
186 |
@@ -1,247 +1,247 | |||||
1 | ''' |
|
1 | ''' | |
2 | Created on Feb 7, 2012 |
|
2 | Created on Feb 7, 2012 | |
3 |
|
3 | |||
4 | @author $Author$ |
|
4 | @author $Author$ | |
5 | @version $Id$ |
|
5 | @version $Id$ | |
6 | ''' |
|
6 | ''' | |
7 |
|
7 | |||
8 | import os, sys |
|
8 | import os, sys | |
9 | import numpy |
|
9 | import numpy | |
10 |
|
10 | |||
11 | path = os.path.split(os.getcwd())[0] |
|
11 | path = os.path.split(os.getcwd())[0] | |
12 | sys.path.append(path) |
|
12 | sys.path.append(path) | |
13 |
|
13 | |||
14 | from Model.Voltage import Voltage |
|
14 | from Model.Voltage import Voltage | |
15 | from IO.VoltageIO import VoltageWriter |
|
15 | from IO.VoltageIO import VoltageWriter | |
16 | from Graphics.VoltagePlot import Osciloscope |
|
16 | from Graphics.VoltagePlot import Osciloscope | |
17 |
|
17 | |||
18 | class VoltageProcessor: |
|
18 | class VoltageProcessor: | |
19 | ''' |
|
19 | ''' | |
20 | classdocs |
|
20 | classdocs | |
21 | ''' |
|
21 | ''' | |
22 |
|
22 | |||
23 | def __init__(self, voltageInObj, voltageOutObj=None): |
|
23 | def __init__(self, voltageInObj, voltageOutObj=None): | |
24 | ''' |
|
24 | ''' | |
25 | Constructor |
|
25 | Constructor | |
26 | ''' |
|
26 | ''' | |
27 |
|
27 | |||
28 | self.voltageInObj = voltageInObj |
|
28 | self.voltageInObj = voltageInObj | |
29 |
|
29 | |||
30 | if voltageOutObj == None: |
|
30 | if voltageOutObj == None: | |
31 | self.voltageOutObj = Voltage() |
|
31 | self.voltageOutObj = Voltage() | |
32 | else: |
|
32 | else: | |
33 | self.voltageOutObj = voltageOutObj |
|
33 | self.voltageOutObj = voltageOutObj | |
34 |
|
34 | |||
35 | self.integratorIndex = None |
|
35 | self.integratorIndex = None | |
36 | self.decoderIndex = None |
|
36 | self.decoderIndex = None | |
37 | self.writerIndex = None |
|
37 | self.writerIndex = None | |
38 | self.plotterIndex = None |
|
38 | self.plotterIndex = None | |
39 |
|
39 | |||
40 | self.integratorList = [] |
|
40 | self.integratorList = [] | |
41 | self.decoderList = [] |
|
41 | self.decoderList = [] | |
42 | self.writerList = [] |
|
42 | self.writerList = [] | |
43 | self.plotterList = [] |
|
43 | self.plotterList = [] | |
44 |
|
44 | |||
45 | def init(self): |
|
45 | def init(self): | |
46 | self.integratorIndex = 0 |
|
46 | self.integratorIndex = 0 | |
47 | self.decoderIndex = 0 |
|
47 | self.decoderIndex = 0 | |
48 | self.writerIndex = 0 |
|
48 | self.writerIndex = 0 | |
49 | self.plotterIndex = 0 |
|
49 | self.plotterIndex = 0 | |
50 | self.voltageOutObj.copy(self.voltageInObj) |
|
50 | self.voltageOutObj.copy(self.voltageInObj) | |
51 |
|
51 | |||
52 | def addWriter(self,wrpath): |
|
52 | def addWriter(self,wrpath): | |
53 | objWriter = VoltageWriter(self.voltageOutObj) |
|
53 | objWriter = VoltageWriter(self.voltageOutObj) | |
54 | objWriter.setup(wrpath) |
|
54 | objWriter.setup(wrpath) | |
55 | self.writerList.append(objWriter) |
|
55 | self.writerList.append(objWriter) | |
56 |
|
56 | |||
57 | def addPlotter(self): |
|
57 | def addPlotter(self): | |
58 |
|
58 | |||
59 | plotObj = Osciloscope(self.voltageOutObj,self.plotterIndex) |
|
59 | plotObj = Osciloscope(self.voltageOutObj,self.plotterIndex) | |
60 | self.plotterList.append(plotObj) |
|
60 | self.plotterList.append(plotObj) | |
61 |
|
61 | |||
62 | def addIntegrator(self,N): |
|
62 | def addIntegrator(self,N): | |
63 |
|
63 | |||
64 | objCohInt = CoherentIntegrator(N) |
|
64 | objCohInt = CoherentIntegrator(N) | |
65 | self.integratorList.append(objCohInt) |
|
65 | self.integratorList.append(objCohInt) | |
66 |
|
66 | |||
67 | def addDecoder(self,code,ncode,nbaud): |
|
67 | def addDecoder(self,code,ncode,nbaud): | |
68 |
|
68 | |||
69 | objDecoder = Decoder(code,ncode,nbaud) |
|
69 | objDecoder = Decoder(code,ncode,nbaud) | |
70 | self.decoderList.append(objDecoder) |
|
70 | self.decoderList.append(objDecoder) | |
71 |
|
71 | |||
72 | def writeData(self,wrpath): |
|
72 | def writeData(self,wrpath): | |
73 | if self.voltageOutObj.flagNoData: |
|
73 | if self.voltageOutObj.flagNoData: | |
74 | return 0 |
|
74 | return 0 | |
75 |
|
75 | |||
76 | if len(self.writerList) <= self.writerIndex: |
|
76 | if len(self.writerList) <= self.writerIndex: | |
77 | self.addWriter(wrpath) |
|
77 | self.addWriter(wrpath) | |
78 |
|
78 | |||
79 | self.writerList[self.writerIndex].putData() |
|
79 | self.writerList[self.writerIndex].putData() | |
80 |
|
80 | |||
81 | # myWrObj = self.writerList[self.writerIndex] |
|
81 | # myWrObj = self.writerList[self.writerIndex] | |
82 | # myWrObj.putData() |
|
82 | # myWrObj.putData() | |
83 |
|
83 | |||
84 | self.writerIndex += 1 |
|
84 | self.writerIndex += 1 | |
85 |
|
85 | |||
86 | def plotData(self,idProfile, type, xmin=None, xmax=None, ymin=None, ymax=None, winTitle=''): |
|
86 | def plotData(self,idProfile, type, xmin=None, xmax=None, ymin=None, ymax=None, winTitle=''): | |
87 | if self.voltageOutObj.flagNoData: |
|
87 | if self.voltageOutObj.flagNoData: | |
88 | return 0 |
|
88 | return 0 | |
89 |
|
89 | |||
90 | if len(self.plotterList) <= self.plotterIndex: |
|
90 | if len(self.plotterList) <= self.plotterIndex: | |
91 | self.addPlotter() |
|
91 | self.addPlotter() | |
92 |
|
92 | |||
93 | self.plotterList[self.plotterIndex].plotData(type=type, xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,winTitle=winTitle) |
|
93 | self.plotterList[self.plotterIndex].plotData(type=type, xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,winTitle=winTitle) | |
94 |
|
94 | |||
95 | self.plotterIndex += 1 |
|
95 | self.plotterIndex += 1 | |
96 |
|
96 | |||
97 | def integrator(self, N): |
|
97 | def integrator(self, N): | |
98 | if self.voltageOutObj.flagNoData: |
|
98 | if self.voltageOutObj.flagNoData: | |
99 | return 0 |
|
99 | return 0 | |
100 |
|
100 | |||
101 | if len(self.integratorList) <= self.integratorIndex: |
|
101 | if len(self.integratorList) <= self.integratorIndex: | |
102 | self.addIntegrator(N) |
|
102 | self.addIntegrator(N) | |
103 |
|
103 | |||
104 | myCohIntObj = self.integratorList[self.integratorIndex] |
|
104 | myCohIntObj = self.integratorList[self.integratorIndex] | |
105 | myCohIntObj.exe(self.voltageOutObj.data) |
|
105 | myCohIntObj.exe(self.voltageOutObj.data) | |
106 |
|
106 | |||
107 | if myCohIntObj.flag: |
|
107 | if myCohIntObj.flag: | |
108 | self.voltageOutObj.data = myCohIntObj.data |
|
108 | self.voltageOutObj.data = myCohIntObj.data | |
109 | self.voltageOutObj.m_ProcessingHeader.coherentInt *= N |
|
109 | self.voltageOutObj.m_ProcessingHeader.coherentInt *= N | |
110 | self.voltageOutObj.flagNoData = False |
|
110 | self.voltageOutObj.flagNoData = False | |
111 |
|
111 | |||
112 | else: |
|
112 | else: | |
113 | self.voltageOutObj.flagNoData = True |
|
113 | self.voltageOutObj.flagNoData = True | |
114 |
|
114 | |||
115 | self.integratorIndex += 1 |
|
115 | self.integratorIndex += 1 | |
116 |
|
116 | |||
117 | def decoder(self,code=None,type = 0): |
|
117 | def decoder(self,code=None,type = 0): | |
118 | if self.voltageOutObj.flagNoData: |
|
118 | if self.voltageOutObj.flagNoData: | |
119 | return 0 |
|
119 | return 0 | |
120 | if code == None: |
|
120 | if code == None: | |
121 | code = self.voltageOutObj.m_RadarControllerHeader.code |
|
121 | code = self.voltageOutObj.m_RadarControllerHeader.code | |
122 | ncode, nbaud = code.shape |
|
122 | ncode, nbaud = code.shape | |
123 |
|
123 | |||
124 | if len(self.decoderList) <= self.decoderIndex: |
|
124 | if len(self.decoderList) <= self.decoderIndex: | |
125 | self.addDecoder(code,ncode,nbaud) |
|
125 | self.addDecoder(code,ncode,nbaud) | |
126 |
|
126 | |||
127 | myDecodObj = self.decoderList[self.decoderIndex] |
|
127 | myDecodObj = self.decoderList[self.decoderIndex] | |
128 | myDecodObj.exe(data=self.voltageOutObj.data,type=type) |
|
128 | myDecodObj.exe(data=self.voltageOutObj.data,type=type) | |
129 |
|
129 | |||
130 | if myDecodObj.flag: |
|
130 | if myDecodObj.flag: | |
131 | self.voltageOutObj.data = myDecodObj.data |
|
131 | self.voltageOutObj.data = myDecodObj.data | |
132 | self.voltageOutObj.flagNoData = False |
|
132 | self.voltageOutObj.flagNoData = False | |
133 | else: |
|
133 | else: | |
134 | self.voltageOutObj.flagNoData = True |
|
134 | self.voltageOutObj.flagNoData = True | |
135 |
|
135 | |||
136 | self.decoderIndex += 1 |
|
136 | self.decoderIndex += 1 | |
137 |
|
137 | |||
138 | def removeDC(self): |
|
138 | def removeDC(self): | |
139 | pass |
|
139 | pass | |
140 |
|
140 | |||
141 | def removeSignalInt(self): |
|
141 | def removeSignalInt(self): | |
142 | pass |
|
142 | pass | |
143 |
|
143 | |||
144 | def selChannel(self): |
|
144 | def selChannel(self): | |
145 | pass |
|
145 | pass | |
146 |
|
146 | |||
147 | def selRange(self): |
|
147 | def selRange(self): | |
148 | pass |
|
148 | pass | |
149 |
|
149 | |||
150 | def selProfiles(self): |
|
150 | def selProfiles(self): | |
151 | pass |
|
151 | pass | |
152 |
|
152 | |||
153 |
|
153 | |||
154 | class Decoder: |
|
154 | class Decoder: | |
155 | def __init__(self,code, ncode, nbaud): |
|
155 | def __init__(self,code, ncode, nbaud): | |
156 | self.buffer = None |
|
156 | self.buffer = None | |
157 | self.profCounter = 1 |
|
157 | self.profCounter = 1 | |
158 | self.nCode = ncode |
|
158 | self.nCode = ncode | |
159 | self.nBaud = nbaud |
|
159 | self.nBaud = nbaud | |
160 | self.codeIndex = 0 |
|
160 | self.codeIndex = 0 | |
161 | self.code = code #this is a List |
|
161 | self.code = code #this is a List | |
162 | self.fft_code = None |
|
162 | self.fft_code = None | |
163 | self.flag = False |
|
163 | self.flag = False | |
164 | self.setCodeFft = False |
|
164 | self.setCodeFft = False | |
165 |
|
165 | |||
166 | def exe(self, data, ndata=None, type = 0): |
|
166 | def exe(self, data, ndata=None, type = 0): | |
167 |
if ndata == None: ndata = data.shape[ |
|
167 | if ndata == None: ndata = data.shape[1] | |
168 |
|
168 | |||
169 | if type == 0: |
|
169 | if type == 0: | |
170 | self.convolutionInFreq(data,ndata) |
|
170 | self.convolutionInFreq(data,ndata) | |
171 |
|
171 | |||
172 | if type == 1: |
|
172 | if type == 1: | |
173 | self.convolutionInTime(data, ndata) |
|
173 | self.convolutionInTime(data, ndata) | |
174 |
|
174 | |||
175 | def convolutionInFreq(self,data,ndata): |
|
175 | def convolutionInFreq(self,data,ndata): | |
176 |
|
176 | |||
177 | newcode = numpy.zeros(ndata) |
|
177 | newcode = numpy.zeros(ndata) | |
178 | newcode[0:self.nBaud] = self.code[self.codeIndex] |
|
178 | newcode[0:self.nBaud] = self.code[self.codeIndex] | |
179 |
|
179 | |||
180 | self.codeIndex += 1 |
|
180 | self.codeIndex += 1 | |
181 |
|
181 | |||
182 |
fft_data = numpy.fft.fft(data, axis= |
|
182 | fft_data = numpy.fft.fft(data, axis=1) | |
183 | fft_code = numpy.conj(numpy.fft.fft(newcode)) |
|
183 | fft_code = numpy.conj(numpy.fft.fft(newcode)) | |
184 |
fft_code = fft_code.reshape(len(fft_code) |
|
184 | fft_code = fft_code.reshape(1,len(fft_code)) | |
185 |
|
185 | |||
186 | conv = fft_data.copy() |
|
186 | conv = fft_data.copy() | |
187 | conv.fill(0) |
|
187 | conv.fill(0) | |
188 |
|
188 | |||
189 | conv = fft_data*fft_code # This other way to calculate multiplication between bidimensional arrays |
|
189 | conv = fft_data*fft_code # This other way to calculate multiplication between bidimensional arrays | |
190 | # for i in range(ndata): |
|
190 | # for i in range(ndata): | |
191 | # conv[i,:] = fft_data[i,:]*fft_code[i] |
|
191 | # conv[i,:] = fft_data[i,:]*fft_code[i] | |
192 |
|
192 | |||
193 |
self.data = numpy.fft.ifft(conv,axis= |
|
193 | self.data = numpy.fft.ifft(conv,axis=1) | |
194 | self.flag = True |
|
194 | self.flag = True | |
195 |
|
195 | |||
196 | if self.profCounter == self.nCode: |
|
196 | if self.profCounter == self.nCode: | |
197 | self.profCounter = 0 |
|
197 | self.profCounter = 0 | |
198 | self.codeIndex = 0 |
|
198 | self.codeIndex = 0 | |
199 |
|
199 | |||
200 | self.profCounter += 1 |
|
200 | self.profCounter += 1 | |
201 |
|
201 | |||
202 | def convolutionInTime(self, data, ndata): |
|
202 | def convolutionInTime(self, data, ndata): | |
203 |
|
203 | |||
204 | nchannel = data.shape[1] |
|
204 | nchannel = data.shape[1] | |
205 | newcode = self.code[self.codeIndex] |
|
205 | newcode = self.code[self.codeIndex] | |
206 | self.codeIndex += 1 |
|
206 | self.codeIndex += 1 | |
207 | conv = data.copy() |
|
207 | conv = data.copy() | |
208 | for i in range(nchannel): |
|
208 | for i in range(nchannel): | |
209 |
conv[: |
|
209 | conv[i,:] = numpy.correlate(data[i,:], newcode, 'same') | |
210 |
|
210 | |||
211 | self.data = conv |
|
211 | self.data = conv | |
212 | self.flag = True |
|
212 | self.flag = True | |
213 |
|
213 | |||
214 | if self.profCounter == self.nCode: |
|
214 | if self.profCounter == self.nCode: | |
215 | self.profCounter = 0 |
|
215 | self.profCounter = 0 | |
216 | self.codeIndex = 0 |
|
216 | self.codeIndex = 0 | |
217 |
|
217 | |||
218 | self.profCounter += 1 |
|
218 | self.profCounter += 1 | |
219 |
|
219 | |||
220 |
|
220 | |||
221 | class CoherentIntegrator: |
|
221 | class CoherentIntegrator: | |
222 | def __init__(self, N): |
|
222 | def __init__(self, N): | |
223 | self.profCounter = 1 |
|
223 | self.profCounter = 1 | |
224 | self.data = None |
|
224 | self.data = None | |
225 | self.buffer = None |
|
225 | self.buffer = None | |
226 | self.flag = False |
|
226 | self.flag = False | |
227 | self.nCohInt = N |
|
227 | self.nCohInt = N | |
228 |
|
228 | |||
229 | def exe(self,data): |
|
229 | def exe(self,data): | |
230 |
|
230 | |||
231 | if self.buffer == None: |
|
231 | if self.buffer == None: | |
232 | self.buffer = data |
|
232 | self.buffer = data | |
233 | else: |
|
233 | else: | |
234 | self.buffer = self.buffer + data |
|
234 | self.buffer = self.buffer + data | |
235 |
|
235 | |||
236 | if self.profCounter == self.nCohInt: |
|
236 | if self.profCounter == self.nCohInt: | |
237 | self.data = self.buffer |
|
237 | self.data = self.buffer | |
238 | self.buffer = None |
|
238 | self.buffer = None | |
239 | self.profCounter = 0 |
|
239 | self.profCounter = 0 | |
240 | self.flag = True |
|
240 | self.flag = True | |
241 | else: |
|
241 | else: | |
242 | self.flag = False |
|
242 | self.flag = False | |
243 |
|
243 | |||
244 | self.profCounter += 1 |
|
244 | self.profCounter += 1 | |
245 |
|
245 | |||
246 |
|
246 | |||
247 | No newline at end of file |
|
247 |
@@ -1,71 +1,73 | |||||
1 | ''' |
|
1 | ''' | |
2 | Created on 23/01/2012 |
|
2 | Created on 23/01/2012 | |
3 |
|
3 | |||
4 | @author $Author$ |
|
4 | @author $Author$ | |
5 | @version $Id$ |
|
5 | @version $Id$ | |
6 | ''' |
|
6 | ''' | |
7 | import os, sys |
|
7 | import os, sys | |
8 | import time, datetime |
|
8 | import time, datetime | |
9 |
|
9 | |||
10 | from Model.JROData import JROData |
|
10 | from Model.JROData import JROData | |
11 | from IO.DataIO import * |
|
11 | from IO.DataIO import * | |
12 | #=============================================================================== |
|
12 | #=============================================================================== | |
13 | # from Graphics.DataPlot import Osciloscope |
|
13 | # from Graphics.DataPlot import Osciloscope | |
14 | # |
|
14 | # | |
15 | # from Model.Spectra import Spectra |
|
15 | # from Model.Spectra import Spectra | |
16 | # from IO.SpectraIO import * |
|
16 | # from IO.SpectraIO import * | |
17 | # from Graphics.SpectraPlot import Spectrum |
|
17 | # from Graphics.SpectraPlot import Spectrum | |
18 | #=============================================================================== |
|
18 | #=============================================================================== | |
19 |
|
19 | |||
20 | class TestSChain(): |
|
20 | class TestSChain(): | |
21 |
|
21 | |||
22 |
|
22 | |||
23 | def __init__(self): |
|
23 | def __init__(self): | |
24 | self.setValues() |
|
24 | self.setValues() | |
25 | self.createObjects() |
|
25 | self.createObjects() | |
26 | self.testSChain() |
|
26 | self.testSChain() | |
27 | pass |
|
27 | pass | |
28 |
|
28 | |||
29 | def setValues(self): |
|
29 | def setValues(self): | |
30 |
|
30 | |||
31 | self.path = "/home/valentin/Tmp/RAWDATA" |
|
31 | #self.path = "/home/valentin/Tmp/RAWDATA" | |
32 | self.startDateTime = datetime.datetime(2009,11,2,00,00,0) |
|
32 | self.path = "/home/dsuarez/Projects" | |
33 | self.endDateTime = datetime.datetime(2009,11,30,18,10,0) |
|
33 | #self.wrpath = "/home/dsuarez/Projects/testWR" | |
|
34 | self.startDateTime = datetime.datetime(2007,5,1,15,49,0) | |||
|
35 | self.endDateTime = datetime.datetime(2007,5,1,16,0,0) | |||
34 |
|
36 | |||
35 | def createObjects(self): |
|
37 | def createObjects(self): | |
36 |
|
38 | |||
37 | self.Obj = JROData() |
|
39 | self.Obj = JROData() | |
38 | self.readerObj = JRODataReader(self.Obj) |
|
40 | self.readerObj = JRODataReader(self.Obj) | |
39 | #self.plotObj = Spectrum(self.Obj) |
|
41 | #self.plotObj = Spectrum(self.Obj) | |
40 |
|
42 | |||
41 | if not(self.readerObj.setup(self.path, self.startDateTime, self.endDateTime, ext = '.pdata', expLabel='', online =1)): |
|
43 | if not(self.readerObj.setup(self.path, self.startDateTime, self.endDateTime, ext = '.pdata', expLabel='', online =1)): | |
42 | sys.exit(0) |
|
44 | sys.exit(0) | |
43 |
|
45 | |||
44 | def testSChain(self): |
|
46 | def testSChain(self): | |
45 |
|
47 | |||
46 | ini = time.time() |
|
48 | ini = time.time() | |
47 | while(True): |
|
49 | while(True): | |
48 | if self.readerObj.getData(): |
|
50 | if self.readerObj.getData(): | |
49 | print "", |
|
51 | print "", | |
50 | #self.plotObj.plotData(zmin=40, zmax=140, showColorbar=True, showPowerProfile=True) |
|
52 | #self.plotObj.plotData(zmin=40, zmax=140, showColorbar=True, showPowerProfile=True) | |
51 |
|
53 | |||
52 | # self.writerObj.putData() |
|
54 | # self.writerObj.putData() | |
53 |
|
55 | |||
54 |
|
56 | |||
55 | if self.readerObj.noMoreFiles: |
|
57 | if self.readerObj.noMoreFiles: | |
56 | break |
|
58 | break | |
57 |
|
59 | |||
58 | if self.readerObj.flagIsNewBlock and self.readerObj.nReadBlocks: |
|
60 | if self.readerObj.flagIsNewBlock and self.readerObj.nReadBlocks: | |
59 | print 'Block No %04d, Time: %s' %(self.readerObj.nReadBlocks, |
|
61 | print 'Block No %04d, Time: %s' %(self.readerObj.nReadBlocks, | |
60 | datetime.datetime.fromtimestamp(self.readerObj.m_BasicHeader.utc),) |
|
62 | datetime.datetime.fromtimestamp(self.readerObj.m_BasicHeader.utc),) | |
61 | #=============================================================== |
|
63 | #=============================================================== | |
62 | # fin = time.time() |
|
64 | # fin = time.time() | |
63 | # print 'Tiempo de un bloque leido y escrito: [%6.5f]' %(fin - ini) |
|
65 | # print 'Tiempo de un bloque leido y escrito: [%6.5f]' %(fin - ini) | |
64 | # ini = time.time() |
|
66 | # ini = time.time() | |
65 | #=============================================================== |
|
67 | #=============================================================== | |
66 |
|
68 | |||
67 | #time.sleep(0.5) |
|
69 | #time.sleep(0.5) | |
68 | self.plotObj.end() |
|
70 | self.plotObj.end() | |
69 |
|
71 | |||
70 | if __name__ == '__main__': |
|
72 | if __name__ == '__main__': | |
71 | TestSChain() No newline at end of file |
|
73 | TestSChain() |
@@ -1,59 +1,102 | |||||
1 | ''' |
|
1 | ''' | |
2 | Created on 27/03/2012 |
|
2 | Created on 27/03/2012 | |
3 |
|
3 | |||
4 | @author $Author$ |
|
4 | @author $Author$ | |
5 | @version $Id$ |
|
5 | @version $Id$ | |
6 | ''' |
|
6 | ''' | |
7 | import os, sys |
|
7 | import os, sys | |
8 | import time, datetime |
|
8 | import time, datetime | |
9 |
|
9 | |||
10 | from Model.Voltage import Voltage |
|
10 | from Model.Voltage import Voltage | |
11 | from IO.VoltageIO import * |
|
11 | from IO.VoltageIO import * | |
12 | from Graphics.VoltagePlot import Osciloscope |
|
12 | #from Graphics.VoltagePlot import Osciloscope | |
|
13 | ||||
|
14 | from Model.Spectra import Spectra | |||
|
15 | from IO.SpectraIO import * | |||
|
16 | ||||
|
17 | from Processing.VoltageProcessor import * | |||
|
18 | from Processing.SpectraProcessor import * | |||
13 |
|
19 | |||
14 | class TestSChain(): |
|
20 | class TestSChain(): | |
15 |
|
21 | |||
16 | def __init__(self): |
|
22 | def __init__(self): | |
17 | self.setValues() |
|
23 | self.setValues() | |
18 | self.createObjects() |
|
24 | self.createObjects() | |
19 | self.testSChain() |
|
25 | self.testSChain() | |
20 |
|
|
26 | ||
21 |
|
27 | |||
22 | def setValues( self ): |
|
28 | def setValues( self ): | |
23 |
|
29 | |||
24 |
self.path = "/home/ |
|
30 | self.path = "/home/dsuarez/Projects" #1 | |
25 | #self.path = "/home/valentin/Tmp/VOLTAGE2" #2 |
|
31 | #self.path = "/home/valentin/Tmp/VOLTAGE2" #2 | |
26 |
self.startDateTime = datetime.datetime(20 |
|
32 | # self.startDateTime = datetime.datetime(2007,5,1,15,49,0) | |
27 |
self.endDateTime = datetime.datetime(20 |
|
33 | # self.endDateTime = datetime.datetime(2007,5,1,23,0,0) | |
|
34 | ||||
|
35 | self.startDateTime = datetime.datetime(2011,10,4,0,0,0) | |||
|
36 | self.endDateTime = datetime.datetime(2011,10,4,0,20,0) | |||
|
37 | self.N = 2 | |||
|
38 | self.npts = 4 | |||
28 |
|
39 | |||
29 | def createObjects( self ): |
|
40 | def createObjects( self ): | |
30 |
|
41 | |||
31 | self.Obj = Voltage() |
|
42 | self.Obj = Voltage() | |
|
43 | self.OutObj = Voltage() | |||
32 | self.readerObj = VoltageReader(self.Obj) |
|
44 | self.readerObj = VoltageReader(self.Obj) | |
33 |
self.p |
|
45 | self.procObj = VoltageProcessor(self.Obj, self.OutObj) | |
|
46 | ||||
|
47 | self.spectraObj = Spectra() | |||
|
48 | self.specProcObj = SpectraProcessor(self.OutObj, self.spectraObj,self.npts) | |||
|
49 | ||||
|
50 | ||||
|
51 | #self.plotObj = Osciloscope(self.Obj) | |||
34 |
|
52 | |||
35 | if not(self.readerObj.setup( self.path, self.startDateTime, self.endDateTime, expLabel='', online =0) ): |
|
53 | if not(self.readerObj.setup( self.path, self.startDateTime, self.endDateTime, expLabel='', online =0) ): | |
36 | sys.exit(0) |
|
54 | sys.exit(0) | |
|
55 | ||||
|
56 | # if not(self.readerObj.setup(self.path, self.startDateTime, self.endDateTime)): | |||
|
57 | # sys.exit(0) | |||
37 |
|
58 | |||
38 | def testSChain( self ): |
|
59 | def testSChain( self ): | |
39 |
|
60 | |||
40 | ini = time.time() |
|
61 | ini = time.time() | |
41 | while(True): |
|
62 | while(True): | |
42 |
|
|
63 | self.readerObj.getData() | |
43 | self.plotObj.plotData(idProfile=0, type='power' ) |
|
|||
44 |
|
64 | |||
45 | if self.readerObj.flagNoMoreFiles: |
|
65 | self.procObj.init() | |
46 | break |
|
|||
47 |
|
66 | |||
|
67 | self.procObj.plotData(idProfile = 1, type='power',winTitle='figura 1') | |||
|
68 | ||||
|
69 | self.procObj.decoder(type=0) | |||
|
70 | ||||
|
71 | # self.procObj.plotData(idProfile = 1, type='iq', xmin=0, xmax=100,winTitle='figura 2') | |||
|
72 | # | |||
|
73 | # self.procObj.integrator(self.N) | |||
|
74 | ||||
|
75 | self.procObj.plotData(idProfile = 1, type='power',winTitle='figura 3') | |||
|
76 | ||||
|
77 | self.specProcObj.init() | |||
|
78 | ||||
|
79 | self.specProcObj.integrator(2) | |||
|
80 | ||||
|
81 | self.specProcObj.plotData(winTitle='Spectra 1', index=2) | |||
|
82 | ||||
|
83 | # if self.readerObj.getData(): | |||
|
84 | # self.plotObj.plotData(idProfile=0, type='power' ) | |||
|
85 | # | |||
|
86 | # | |||
|
87 | # if self.readerObj.flagNoMoreFiles: | |||
|
88 | # break | |||
|
89 | # | |||
48 | if self.readerObj.flagIsNewBlock: |
|
90 | if self.readerObj.flagIsNewBlock: | |
49 | print 'Block No %04d, Time: %s' %(self.readerObj.nReadBlocks, |
|
91 | print 'Block No %04d, Time: %s' %(self.readerObj.nReadBlocks, | |
50 | datetime.datetime.fromtimestamp(self.readerObj.m_BasicHeader.utc),) |
|
92 | datetime.datetime.fromtimestamp(self.readerObj.m_BasicHeader.utc),) | |
|
93 | ||||
51 | # fin = time.time() |
|
94 | # fin = time.time() | |
52 | # print 'Tiempo de un bloque leido y escrito: [%6.5f]' %(fin - ini) |
|
95 | # print 'Tiempo de un bloque leido y escrito: [%6.5f]' %(fin - ini) | |
53 | # ini = time.time() |
|
96 | # ini = time.time() | |
54 |
|
97 | |||
55 | #time.sleep(0.5) |
|
98 | #time.sleep(0.5) | |
56 | self.plotObj.end() |
|
99 | # self.plotObj.end() | |
57 |
|
100 | |||
58 | if __name__ == '__main__': |
|
101 | if __name__ == '__main__': | |
59 | TestSChain() No newline at end of file |
|
102 | TestSChain() |
General Comments 0
You need to be logged in to leave comments.
Login now