@@ -1,234 +1,234 | |||||
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 numpy |
|
8 | import numpy | |
9 | import plplot |
|
9 | import plplot | |
10 |
|
10 | |||
11 |
from Bas |
|
11 | from BaseGraph import * | |
12 |
|
12 | |||
13 | class Spectrum: |
|
13 | class Spectrum: | |
14 |
|
14 | |||
15 | graphObjDict = {} |
|
15 | graphObjDict = {} | |
16 | showColorbar = False |
|
16 | showColorbar = False | |
17 | showPowerProfile = True |
|
17 | showPowerProfile = True | |
18 |
|
18 | |||
19 | __szchar = 0.7 |
|
19 | __szchar = 0.7 | |
20 | __xrange = None |
|
20 | __xrange = None | |
21 | __yrange = None |
|
21 | __yrange = None | |
22 | __zrange = None |
|
22 | __zrange = None | |
23 |
s |
|
23 | baseObj = BaseGraph() | |
24 |
|
24 | |||
25 |
|
25 | |||
26 | def __init__(self): |
|
26 | def __init__(self): | |
27 |
|
27 | |||
28 | key = "spec" |
|
28 | key = "spec" | |
29 |
|
29 | |||
30 |
s |
|
30 | baseObj = BaseGraph() | |
31 |
s |
|
31 | baseObj.setName(key) | |
32 |
|
32 | |||
33 |
self.graphObjDict[key] = s |
|
33 | self.graphObjDict[key] = baseObj | |
34 |
|
34 | |||
35 |
|
35 | |||
36 | def setup(self, subpage, title="", xlabel="", ylabel="", colormap="jet", showColorbar=False, showPowerProfile=False): |
|
36 | def setup(self, subpage, title="", xlabel="", ylabel="", colormap="jet", showColorbar=False, showPowerProfile=False): | |
37 | """ |
|
37 | """ | |
38 | """ |
|
38 | """ | |
39 |
|
39 | |||
40 | xi = 0.12; xw = 0.78; xf = xi + xw |
|
40 | xi = 0.12; xw = 0.78; xf = xi + xw | |
41 | yi = 0.14; yw = 0.80; yf = yi + yw |
|
41 | yi = 0.14; yw = 0.80; yf = yi + yw | |
42 |
|
42 | |||
43 | xcmapi = xcmapf = 0.; xpowi = xpowf = 0. |
|
43 | xcmapi = xcmapf = 0.; xpowi = xpowf = 0. | |
44 |
|
44 | |||
45 | key = "spec" |
|
45 | key = "spec" | |
46 |
s |
|
46 | baseObj = self.graphObjDict[key] | |
47 |
s |
|
47 | baseObj.setSubpage(subpage) | |
48 |
s |
|
48 | baseObj.setSzchar(self.__szchar) | |
49 |
s |
|
49 | baseObj.setOpt("bcnts","bcnts") | |
50 |
s |
|
50 | baseObj.setup(title, | |
51 | xlabel, |
|
51 | xlabel, | |
52 | ylabel, |
|
52 | ylabel, | |
53 | colormap) |
|
53 | colormap) | |
54 |
|
54 | |||
55 | if showColorbar: |
|
55 | if showColorbar: | |
56 | key = "colorbar" |
|
56 | key = "colorbar" | |
57 |
|
57 | |||
58 |
cmapObj = Bas |
|
58 | cmapObj = BaseGraph() | |
59 | cmapObj.setName(key) |
|
59 | cmapObj.setName(key) | |
60 | cmapObj.setSubpage(subpage) |
|
60 | cmapObj.setSubpage(subpage) | |
61 | cmapObj.setSzchar(self.__szchar) |
|
61 | cmapObj.setSzchar(self.__szchar) | |
62 | cmapObj.setOpt("bc","bcmt") |
|
62 | cmapObj.setOpt("bc","bcmt") | |
63 | cmapObj.setup(title="dBs", |
|
63 | cmapObj.setup(title="dBs", | |
64 | xlabel="", |
|
64 | xlabel="", | |
65 | ylabel="", |
|
65 | ylabel="", | |
66 | colormap=colormap) |
|
66 | colormap=colormap) | |
67 |
|
67 | |||
68 | self.graphObjDict[key] = cmapObj |
|
68 | self.graphObjDict[key] = cmapObj | |
69 |
|
69 | |||
70 | xcmapi = 0. |
|
70 | xcmapi = 0. | |
71 | xcmapw = 0.05 |
|
71 | xcmapw = 0.05 | |
72 | xw -= xcmapw |
|
72 | xw -= xcmapw | |
73 |
|
73 | |||
74 | if showPowerProfile: |
|
74 | if showPowerProfile: | |
75 | key = "powerprof" |
|
75 | key = "powerprof" | |
76 |
|
76 | |||
77 |
powObj = Bas |
|
77 | powObj = BaseGraph() | |
78 | powObj.setName(key) |
|
78 | powObj.setName(key) | |
79 | powObj.setSubpage(subpage) |
|
79 | powObj.setSubpage(subpage) | |
80 | powObj.setSzchar(self.__szchar) |
|
80 | powObj.setSzchar(self.__szchar) | |
81 | plplot.pllsty(2) |
|
81 | plplot.pllsty(2) | |
82 | powObj.setOpt("bcntg","bc") |
|
82 | powObj.setOpt("bcntg","bc") | |
83 | plplot.pllsty(1) |
|
83 | plplot.pllsty(1) | |
84 | powObj.setup(title="Power Profile", |
|
84 | powObj.setup(title="Power Profile", | |
85 | xlabel="dBs", |
|
85 | xlabel="dBs", | |
86 | ylabel="") |
|
86 | ylabel="") | |
87 |
|
87 | |||
88 | self.graphObjDict[key] = powObj |
|
88 | self.graphObjDict[key] = powObj | |
89 |
|
89 | |||
90 | xpowi = 0. |
|
90 | xpowi = 0. | |
91 | xpoww = 0.24 |
|
91 | xpoww = 0.24 | |
92 | xw -= xpoww |
|
92 | xw -= xpoww | |
93 |
|
93 | |||
94 | xf = xi + xw |
|
94 | xf = xi + xw | |
95 | yf = yi + yw |
|
95 | yf = yi + yw | |
96 | xcmapf = xf |
|
96 | xcmapf = xf | |
97 |
|
97 | |||
98 |
s |
|
98 | baseObj.setScreenPos([xi, xf], [yi, yf]) | |
99 |
|
99 | |||
100 | if showColorbar: |
|
100 | if showColorbar: | |
101 | xcmapi = xf + 0.02 |
|
101 | xcmapi = xf + 0.02 | |
102 | xcmapf = xcmapi + xcmapw |
|
102 | xcmapf = xcmapi + xcmapw | |
103 | cmapObj.setScreenPos([xcmapi, xcmapf], [yi, yf]) |
|
103 | cmapObj.setScreenPos([xcmapi, xcmapf], [yi, yf]) | |
104 |
|
104 | |||
105 | if showPowerProfile: |
|
105 | if showPowerProfile: | |
106 | xpowi = xcmapf + 0.06 |
|
106 | xpowi = xcmapf + 0.06 | |
107 | xpowf = xpowi + xpoww |
|
107 | xpowf = xpowi + xpoww | |
108 | powObj.setScreenPos([xpowi, xpowf], [yi, yf]) |
|
108 | powObj.setScreenPos([xpowi, xpowf], [yi, yf]) | |
109 |
|
109 | |||
110 |
|
110 | |||
111 |
# s |
|
111 | # baseObj.initSubpage() | |
112 | # |
|
112 | # | |
113 | # if showColorbar: |
|
113 | # if showColorbar: | |
114 | # cmapObj.initPlot() |
|
114 | # cmapObj.initPlot() | |
115 | # |
|
115 | # | |
116 | # if showPowerProfile: |
|
116 | # if showPowerProfile: | |
117 | # powObj.initPlot() |
|
117 | # powObj.initPlot() | |
118 |
|
118 | |||
119 | self.showColorbar = showColorbar |
|
119 | self.showColorbar = showColorbar | |
120 | self.showPowerProfile = showPowerProfile |
|
120 | self.showPowerProfile = showPowerProfile | |
121 |
|
121 | |||
122 | def setRanges(self, xrange, yrange, zrange): |
|
122 | def setRanges(self, xrange, yrange, zrange): | |
123 |
|
123 | |||
124 | key = "spec" |
|
124 | key = "spec" | |
125 |
s |
|
125 | baseObj = self.graphObjDict[key] | |
126 |
s |
|
126 | baseObj.setRanges(xrange, yrange, zrange) | |
127 |
|
127 | |||
128 | keyList = self.graphObjDict.keys() |
|
128 | keyList = self.graphObjDict.keys() | |
129 |
|
129 | |||
130 | key = "colorbar" |
|
130 | key = "colorbar" | |
131 | if key in keyList: |
|
131 | if key in keyList: | |
132 | cmapObj = self.graphObjDict[key] |
|
132 | cmapObj = self.graphObjDict[key] | |
133 | cmapObj.setRanges([0., 1.], zrange) |
|
133 | cmapObj.setRanges([0., 1.], zrange) | |
134 |
|
134 | |||
135 | key = "powerprof" |
|
135 | key = "powerprof" | |
136 | if key in keyList: |
|
136 | if key in keyList: | |
137 | powObj = self.graphObjDict[key] |
|
137 | powObj = self.graphObjDict[key] | |
138 | powObj.setRanges(zrange, yrange) |
|
138 | powObj.setRanges(zrange, yrange) | |
139 |
|
139 | |||
140 | def plotData(self, data , xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None): |
|
140 | def plotData(self, data , xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None): | |
141 |
|
141 | |||
142 | key = "spec" |
|
142 | key = "spec" | |
143 |
s |
|
143 | baseObj = self.graphObjDict[key] | |
144 |
s |
|
144 | baseObj.initSubpage() | |
145 |
|
145 | |||
146 | if xmin == None: |
|
146 | if xmin == None: | |
147 | xmin = 0. |
|
147 | xmin = 0. | |
148 |
|
148 | |||
149 | if xmax == None: |
|
149 | if xmax == None: | |
150 | xmax = 1. |
|
150 | xmax = 1. | |
151 |
|
151 | |||
152 | if ymin == None: |
|
152 | if ymin == None: | |
153 | ymin = 0. |
|
153 | ymin = 0. | |
154 |
|
154 | |||
155 | if ymax == None: |
|
155 | if ymax == None: | |
156 | ymax = 1. |
|
156 | ymax = 1. | |
157 |
|
157 | |||
158 | if zmin == None: |
|
158 | if zmin == None: | |
159 | zmin = numpy.nanmin(data) |
|
159 | zmin = numpy.nanmin(data) | |
160 |
|
160 | |||
161 | if zmax == None: |
|
161 | if zmax == None: | |
162 | zmax = numpy.nanmax(data) |
|
162 | zmax = numpy.nanmax(data) | |
163 |
|
163 | |||
164 |
if not(s |
|
164 | if not(baseObj.hasRange): | |
165 | self.setRanges([xmin, xmax], [ymin,ymax], [zmin,zmax]) |
|
165 | self.setRanges([xmin, xmax], [ymin,ymax], [zmin,zmax]) | |
166 |
|
166 | |||
167 |
s |
|
167 | baseObj.basicPcolorPlot(data, xmin, xmax, ymin, ymax, baseObj.zrange[0], baseObj.zrange[1]) | |
168 |
|
168 | |||
169 | if self.showColorbar: |
|
169 | if self.showColorbar: | |
170 | key = "colorbar" |
|
170 | key = "colorbar" | |
171 | cmapObj = self.graphObjDict[key] |
|
171 | cmapObj = self.graphObjDict[key] | |
172 | cmapObj.colorbarPlot() |
|
172 | cmapObj.colorbarPlot() | |
173 |
|
173 | |||
174 | if self.showPowerProfile: |
|
174 | if self.showPowerProfile: | |
175 | power = numpy.average(data, axis=1) |
|
175 | power = numpy.average(data, axis=1) | |
176 |
|
176 | |||
177 | step = (ymax - ymin)/(power.shape[0]-1) |
|
177 | step = (ymax - ymin)/(power.shape[0]-1) | |
178 | heis = numpy.arange(ymin, ymax + step, step) |
|
178 | heis = numpy.arange(ymin, ymax + step, step) | |
179 |
|
179 | |||
180 | key = "powerprof" |
|
180 | key = "powerprof" | |
181 | powObj = self.graphObjDict[key] |
|
181 | powObj = self.graphObjDict[key] | |
182 | powObj.basicXYPlot(power, heis) |
|
182 | powObj.basicXYPlot(power, heis) | |
183 |
|
183 | |||
184 | class CrossSpectrum: |
|
184 | class CrossSpectrum: | |
185 | graphObjDict = {} |
|
185 | graphObjDict = {} | |
186 | showColorbar = False |
|
186 | showColorbar = False | |
187 | showPowerProfile = True |
|
187 | showPowerProfile = True | |
188 |
|
188 | |||
189 | __szchar = 0.7 |
|
189 | __szchar = 0.7 | |
190 | __showPhase = False |
|
190 | __showPhase = False | |
191 | __xrange = None |
|
191 | __xrange = None | |
192 | __yrange = None |
|
192 | __yrange = None | |
193 | __zrange = None |
|
193 | __zrange = None | |
194 |
m_Bas |
|
194 | m_BaseGraph= BaseGraph() | |
195 |
|
195 | |||
196 | def __init__(self): |
|
196 | def __init__(self): | |
197 | pass |
|
197 | pass | |
198 |
|
198 | |||
199 | def setup(self, subpage, title, xlabel, ylabel, colormap, showColorbar, showPowerProfile): |
|
199 | def setup(self, subpage, title, xlabel, ylabel, colormap, showColorbar, showPowerProfile): | |
200 | pass |
|
200 | pass | |
201 |
|
201 | |||
202 | def setRanges(self, xrange, yrange, zrange): |
|
202 | def setRanges(self, xrange, yrange, zrange): | |
203 | pass |
|
203 | pass | |
204 |
|
204 | |||
205 | def plotData(self, data, xmin, xmax, ymin, ymax, zmin, zmax): |
|
205 | def plotData(self, data, xmin, xmax, ymin, ymax, zmin, zmax): | |
206 | pass |
|
206 | pass | |
207 |
|
207 | |||
208 | if __name__ == '__main__': |
|
208 | if __name__ == '__main__': | |
209 |
|
209 | |||
210 | import numpy |
|
210 | import numpy | |
211 | plplot.plsetopt("geometry", "%dx%d" %(350*2, 300*2)) |
|
211 | plplot.plsetopt("geometry", "%dx%d" %(350*2, 300*2)) | |
212 | plplot.plsdev("xcairo") |
|
212 | plplot.plsdev("xcairo") | |
213 | plplot.plscolbg(255,255,255) |
|
213 | plplot.plscolbg(255,255,255) | |
214 | plplot.plscol0(1,0,0,0) |
|
214 | plplot.plscol0(1,0,0,0) | |
215 | plplot.plinit() |
|
215 | plplot.plinit() | |
216 | plplot.plssub(2, 2) |
|
216 | plplot.plssub(2, 2) | |
217 |
|
217 | |||
218 | nx = 64 |
|
218 | nx = 64 | |
219 | ny = 100 |
|
219 | ny = 100 | |
220 |
|
220 | |||
221 | data = numpy.random.uniform(-50,50,(nx,ny)) |
|
221 | data = numpy.random.uniform(-50,50,(nx,ny)) | |
222 |
|
222 | |||
223 |
s |
|
223 | baseObj = ColorPlot() | |
224 |
s |
|
224 | baseObj.setup(1, "Spectrum", "Frequency", "Range", "br_green", False, False) | |
225 |
s |
|
225 | baseObj.plotData(data) | |
226 |
|
226 | |||
227 | data = numpy.random.uniform(-50,50,(nx,ny)) |
|
227 | data = numpy.random.uniform(-50,50,(nx,ny)) | |
228 |
|
228 | |||
229 |
spec2Obj = |
|
229 | spec2Obj = ColorPlot() | |
230 | spec2Obj.setup(2, "Spectrum", "Frequency", "Range", "br_green", True, True) |
|
230 | spec2Obj.setup(2, "Spectrum", "Frequency", "Range", "br_green", True, True) | |
231 | spec2Obj.plotData(data) |
|
231 | spec2Obj.plotData(data) | |
232 |
|
232 | |||
233 | plplot.plend() |
|
233 | plplot.plend() | |
234 | exit(0) No newline at end of file |
|
234 | exit(0) |
@@ -1,18 +1,96 | |||||
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 | |||
|
8 | import numpy | |||
|
9 | import plplot | |||
7 |
|
10 | |||
|
11 | path = os.path.split(os.getcwd())[0] | |||
|
12 | sys.path.append(path) | |||
|
13 | ||||
|
14 | from Graphics.BasicGraph import * | |||
|
15 | from Model.Voltage import Voltage | |||
|
16 | ||||
|
17 | class Osciloscope(): | |||
|
18 | ||||
|
19 | graphObjDict = {} | |||
|
20 | showPower = True | |||
|
21 | ||||
|
22 | __szchar = 0.7 | |||
|
23 | __xrange = None | |||
|
24 | __yrange = None | |||
|
25 | __zrange = None | |||
|
26 | ||||
|
27 | def __init__(self): | |||
|
28 | key = "osc" | |||
|
29 | ||||
|
30 | baseObj = BasicGraph() | |||
|
31 | baseObj.setName(key) | |||
|
32 | ||||
|
33 | self.graphObjDict[key] = baseObj | |||
|
34 | ||||
|
35 | ||||
|
36 | def setup(self, subpage, title="", xlabel="", ylabel="", colormap="jet", showColorbar=False, showPowerProfile=False): | |||
|
37 | pass | |||
|
38 | ||||
|
39 | def setRanges(self, xrange, yrange, zrange): | |||
|
40 | pass | |||
|
41 | ||||
|
42 | def plotData(self, data , xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None): | |||
|
43 | pass | |||
|
44 | ||||
|
45 | ||||
|
46 | ||||
8 | class VoltagePlot(object): |
|
47 | class VoltagePlot(object): | |
9 | ''' |
|
48 | ''' | |
10 | classdocs |
|
49 | classdocs | |
11 | ''' |
|
50 | ''' | |
12 |
|
51 | |||
13 |
|
52 | __m_Voltage = None | ||
14 | def __init__(self): |
|
53 | ||
|
54 | def __init__(self, m_Voltage): | |||
15 | ''' |
|
55 | ''' | |
16 | Constructor |
|
56 | Constructor | |
17 | ''' |
|
57 | ''' | |
18 | pass No newline at end of file |
|
58 | self.__m_Voltage = m_Voltage | |
|
59 | ||||
|
60 | def setup(self): | |||
|
61 | pass | |||
|
62 | ||||
|
63 | def addGraph(self, type, xrange=None, yrange=None, zrange=None): | |||
|
64 | pass | |||
|
65 | ||||
|
66 | def plotData(self): | |||
|
67 | pass | |||
|
68 | ||||
|
69 | if __name__ == '__main__': | |||
|
70 | ||||
|
71 | import numpy | |||
|
72 | ||||
|
73 | plplot.plsetopt("geometry", "%dx%d" %(450*2, 200*2)) | |||
|
74 | plplot.plsdev("xcairo") | |||
|
75 | plplot.plscolbg(255,255,255) | |||
|
76 | plplot.plscol0(1,0,0,0) | |||
|
77 | plplot.plinit() | |||
|
78 | plplot.plssub(1, 2) | |||
|
79 | ||||
|
80 | nx = 64 | |||
|
81 | ny = 100 | |||
|
82 | ||||
|
83 | data = numpy.random.uniform(-50,50,(nx,ny)) | |||
|
84 | ||||
|
85 | baseObj = RTI() | |||
|
86 | baseObj.setup(1, "Spectrum", "Frequency", "Range", "br_green", False, False) | |||
|
87 | baseObj.plotData(data) | |||
|
88 | ||||
|
89 | data = numpy.random.uniform(-50,50,(nx,ny)) | |||
|
90 | ||||
|
91 | base2Obj = RTI() | |||
|
92 | base2Obj.setup(2, "Spectrum", "Frequency", "Range", "br_green", True, True) | |||
|
93 | base2Obj.plotData(data) | |||
|
94 | ||||
|
95 | plplot.plend() | |||
|
96 | exit(0) No newline at end of file |
@@ -1,459 +1,460 | |||||
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 |
|
12 | import time | |
13 | import datetime |
|
13 | import datetime | |
14 |
|
14 | |||
|
15 | path = os.path.split(os.getcwd())[0] | |||
|
16 | sys.path.append(path) | |||
|
17 | ||||
15 | from IO.Header import * |
|
18 | from IO.Header import * | |
16 | from IO.Data import DataReader |
|
19 | from IO.Data import DataReader | |
17 | from IO.Data import DataWriter |
|
20 | from IO.Data import DataWriter | |
18 |
|
21 | |||
19 | path = os.path.split(os.getcwd())[0] |
|
|||
20 | sys.path.append(path) |
|
|||
21 |
|
||||
22 | from Model.Voltage import Voltage |
|
22 | from Model.Voltage import Voltage | |
23 |
|
23 | |||
24 | class VoltageReader(DataReader): |
|
24 | class VoltageReader(DataReader): | |
25 |
|
25 | |||
26 | __idFile = None |
|
26 | __idFile = None | |
27 |
|
27 | |||
28 | __fp = None |
|
28 | __fp = None | |
29 |
|
29 | |||
30 | __startDateTime = None |
|
30 | __startDateTime = None | |
31 |
|
31 | |||
32 | __endDateTime = None |
|
32 | __endDateTime = None | |
33 |
|
33 | |||
34 | __dataType = None |
|
34 | __dataType = None | |
35 |
|
35 | |||
36 | __fileSizeByHeader = 0 |
|
36 | __fileSizeByHeader = 0 | |
37 |
|
37 | |||
38 | __pathList = [] |
|
38 | __pathList = [] | |
39 |
|
39 | |||
40 | filenameList = [] |
|
40 | filenameList = [] | |
41 |
|
41 | |||
42 | __lastUTTime = 0 |
|
42 | __lastUTTime = 0 | |
43 |
|
43 | |||
44 | __maxTimeStep = 5 |
|
44 | __maxTimeStep = 5 | |
45 |
|
45 | |||
46 | __flagIsNewFile = 0 |
|
46 | __flagIsNewFile = 0 | |
47 |
|
47 | |||
48 | __ippSeconds = 0 |
|
48 | __ippSeconds = 0 | |
49 |
|
49 | |||
50 | flagResetProcessing = 0 |
|
50 | flagResetProcessing = 0 | |
51 |
|
51 | |||
52 | flagIsNewBlock = 0 |
|
52 | flagIsNewBlock = 0 | |
53 |
|
53 | |||
54 | noMoreFiles = 0 |
|
54 | noMoreFiles = 0 | |
55 |
|
55 | |||
56 | nReadBlocks = 0 |
|
56 | nReadBlocks = 0 | |
57 |
|
57 | |||
58 | online = 0 |
|
58 | online = 0 | |
59 |
|
59 | |||
60 | filename = None |
|
60 | filename = None | |
61 |
|
61 | |||
62 | fileSize = None |
|
62 | fileSize = None | |
63 |
|
63 | |||
64 | firstHeaderSize = 0 |
|
64 | firstHeaderSize = 0 | |
65 |
|
65 | |||
66 | basicHeaderSize = 24 |
|
66 | basicHeaderSize = 24 | |
67 |
|
67 | |||
68 | m_BasicHeader = BasicHeader() |
|
68 | m_BasicHeader = BasicHeader() | |
69 |
|
69 | |||
70 | m_SystemHeader = SystemHeader() |
|
70 | m_SystemHeader = SystemHeader() | |
71 |
|
71 | |||
72 | m_RadarControllerHeader = RadarControllerHeader() |
|
72 | m_RadarControllerHeader = RadarControllerHeader() | |
73 |
|
73 | |||
74 | m_ProcessingHeader = ProcessingHeader() |
|
74 | m_ProcessingHeader = ProcessingHeader() | |
75 |
|
75 | |||
76 | m_Voltage = None |
|
76 | m_Voltage = None | |
77 |
|
77 | |||
78 | __buffer = 0 |
|
78 | __buffer = 0 | |
79 |
|
79 | |||
80 | __buffer_id = 9999 |
|
80 | __buffer_id = 9999 | |
81 |
|
81 | |||
82 | def __init__(self, m_Voltage = None): |
|
82 | def __init__(self, m_Voltage = None): | |
83 |
|
83 | |||
84 | if m_Voltage == None: |
|
84 | if m_Voltage == None: | |
85 | m_Voltage = Voltage() |
|
85 | m_Voltage = Voltage() | |
86 |
|
86 | |||
87 | self.m_Voltage = m_Voltage |
|
87 | self.m_Voltage = m_Voltage | |
88 |
|
88 | |||
89 | def __rdSystemHeader(self,fp=None): |
|
89 | def __rdSystemHeader(self,fp=None): | |
90 | if fp == None: |
|
90 | if fp == None: | |
91 | fp = self.__fp |
|
91 | fp = self.__fp | |
92 |
|
92 | |||
93 | self.m_SystemHeader.read(fp) |
|
93 | self.m_SystemHeader.read(fp) | |
94 |
|
94 | |||
95 | def __rdRadarControllerHeader(self,fp=None): |
|
95 | def __rdRadarControllerHeader(self,fp=None): | |
96 | if fp == None: |
|
96 | if fp == None: | |
97 | fp = self.__fp |
|
97 | fp = self.__fp | |
98 |
|
98 | |||
99 | self.m_RadarControllerHeader.read(fp) |
|
99 | self.m_RadarControllerHeader.read(fp) | |
100 |
|
100 | |||
101 | def __rdProcessingHeader(self,fp=None): |
|
101 | def __rdProcessingHeader(self,fp=None): | |
102 | if fp == None: |
|
102 | if fp == None: | |
103 | fp = self.__fp |
|
103 | fp = self.__fp | |
104 |
|
104 | |||
105 | self.m_ProcessingHeader.read(fp) |
|
105 | self.m_ProcessingHeader.read(fp) | |
106 |
|
106 | |||
107 | def __searchFiles(self,path, startDateTime, endDateTime, set=None, expLabel = "", ext = ".r"): |
|
107 | def __searchFiles(self,path, startDateTime, endDateTime, set=None, expLabel = "", ext = ".r"): | |
108 |
|
108 | |||
109 | print "Searching files ..." |
|
109 | print "Searching files ..." | |
110 |
|
110 | |||
111 | startUtSeconds = time.mktime(startDateTime.timetuple()) |
|
111 | startUtSeconds = time.mktime(startDateTime.timetuple()) | |
112 | endUtSeconds = time.mktime(endDateTime.timetuple()) |
|
112 | endUtSeconds = time.mktime(endDateTime.timetuple()) | |
113 |
|
113 | |||
114 | # startYear = startDateTime.timetuple().tm_year |
|
114 | # startYear = startDateTime.timetuple().tm_year | |
115 | # endYear = endDateTime.timetuple().tm_year |
|
115 | # endYear = endDateTime.timetuple().tm_year | |
116 | # |
|
116 | # | |
117 | # startDoy = startDateTime.timetuple().tm_yday |
|
117 | # startDoy = startDateTime.timetuple().tm_yday | |
118 | # endDoy = endDateTime.timetuple().tm_yday |
|
118 | # endDoy = endDateTime.timetuple().tm_yday | |
119 | # |
|
119 | # | |
120 | # yearRange = range(startYear,endYear+1) |
|
120 | # yearRange = range(startYear,endYear+1) | |
121 | # |
|
121 | # | |
122 | # doyDoubleList = [] |
|
122 | # doyDoubleList = [] | |
123 | # if startYear == endYear: |
|
123 | # if startYear == endYear: | |
124 | # doyList = range(startDoy,endDoy+1) |
|
124 | # doyList = range(startDoy,endDoy+1) | |
125 | # else: |
|
125 | # else: | |
126 | # for year in yearRange: |
|
126 | # for year in yearRange: | |
127 | # if (year == startYear): |
|
127 | # if (year == startYear): | |
128 | # doyDoubleList.append(range(startDoy,365+1)) |
|
128 | # doyDoubleList.append(range(startDoy,365+1)) | |
129 | # elif (year == endYear): |
|
129 | # elif (year == endYear): | |
130 | # doyDoubleList.append(range(1,endDoy+1)) |
|
130 | # doyDoubleList.append(range(1,endDoy+1)) | |
131 | # else: |
|
131 | # else: | |
132 | # doyDoubleList.append(range(1,365+1)) |
|
132 | # doyDoubleList.append(range(1,365+1)) | |
133 | # doyList = [] |
|
133 | # doyList = [] | |
134 | # for list in doyDoubleList: |
|
134 | # for list in doyDoubleList: | |
135 | # doyList = doyList + list |
|
135 | # doyList = doyList + list | |
136 | # |
|
136 | # | |
137 | # dirList = [] |
|
137 | # dirList = [] | |
138 | # for thisPath in os.listdir(path): |
|
138 | # for thisPath in os.listdir(path): | |
139 | # if os.path.isdir(os.path.join(path,thisPath)): |
|
139 | # if os.path.isdir(os.path.join(path,thisPath)): | |
140 | # #dirList.append(os.path.join(path,thisPath)) |
|
140 | # #dirList.append(os.path.join(path,thisPath)) | |
141 | # dirList.append(thisPath) |
|
141 | # dirList.append(thisPath) | |
142 | # |
|
142 | # | |
143 | # pathList = [] |
|
143 | # pathList = [] | |
144 | # pathDict = {} |
|
144 | # pathDict = {} | |
145 | # for year in yearRange: |
|
145 | # for year in yearRange: | |
146 | # for doy in doyList: |
|
146 | # for doy in doyList: | |
147 | # match = fnmatch.filter(dirList, 'D' + '%4.4d%3.3d' % (year,doy)) |
|
147 | # match = fnmatch.filter(dirList, 'D' + '%4.4d%3.3d' % (year,doy)) | |
148 | # if len(match) == 0: |
|
148 | # if len(match) == 0: | |
149 | # match = fnmatch.filter(dirList, 'd' + '%4.4d%3.3d' % (year,doy)) |
|
149 | # match = fnmatch.filter(dirList, 'd' + '%4.4d%3.3d' % (year,doy)) | |
150 | # if len(match) == 0: continue |
|
150 | # if len(match) == 0: continue | |
151 | # if expLabel == '': |
|
151 | # if expLabel == '': | |
152 | # pathList.append(os.path.join(path,match[0])) |
|
152 | # pathList.append(os.path.join(path,match[0])) | |
153 | # pathDict.setdefault(os.path.join(path,match[0])) |
|
153 | # pathDict.setdefault(os.path.join(path,match[0])) | |
154 | # pathDict[os.path.join(path,match[0])] = [] |
|
154 | # pathDict[os.path.join(path,match[0])] = [] | |
155 | # else: |
|
155 | # else: | |
156 | # pathList.append(os.path.join(path,os.path.join(match[0],expLabel))) |
|
156 | # pathList.append(os.path.join(path,os.path.join(match[0],expLabel))) | |
157 | # pathDict.setdefault(os.path.join(path,os.path.join(match[0],expLabel))) |
|
157 | # pathDict.setdefault(os.path.join(path,os.path.join(match[0],expLabel))) | |
158 | # pathDict[os.path.join(path,os.path.join(match[0],expLabel))] = [] |
|
158 | # pathDict[os.path.join(path,os.path.join(match[0],expLabel))] = [] | |
159 |
|
159 | |||
160 |
|
160 | |||
161 | dirList = [] |
|
161 | dirList = [] | |
162 | for thisPath in os.listdir(path): |
|
162 | for thisPath in os.listdir(path): | |
163 | if os.path.isdir(os.path.join(path,thisPath)): |
|
163 | if os.path.isdir(os.path.join(path,thisPath)): | |
164 | dirList.append(thisPath) |
|
164 | dirList.append(thisPath) | |
165 |
|
165 | |||
166 | pathList = [] |
|
166 | pathList = [] | |
167 |
|
167 | |||
168 | thisDateTime = startDateTime |
|
168 | thisDateTime = startDateTime | |
169 |
|
169 | |||
170 | while(thisDateTime <= endDateTime): |
|
170 | while(thisDateTime <= endDateTime): | |
171 | year = thisDateTime.timetuple().tm_year |
|
171 | year = thisDateTime.timetuple().tm_year | |
172 | doy = thisDateTime.timetuple().tm_yday |
|
172 | doy = thisDateTime.timetuple().tm_yday | |
173 |
|
173 | |||
174 | match = fnmatch.filter(dirList, '?' + '%4.4d%3.3d' % (year,doy)) |
|
174 | match = fnmatch.filter(dirList, '?' + '%4.4d%3.3d' % (year,doy)) | |
175 | if len(match) == 0: |
|
175 | if len(match) == 0: | |
176 | thisDateTime += datetime.timedelta(1) |
|
176 | thisDateTime += datetime.timedelta(1) | |
177 | continue |
|
177 | continue | |
178 |
|
178 | |||
179 | pathList.append(os.path.join(path,match[0],expLabel)) |
|
179 | pathList.append(os.path.join(path,match[0],expLabel)) | |
180 | thisDateTime += datetime.timedelta(1) |
|
180 | thisDateTime += datetime.timedelta(1) | |
181 |
|
181 | |||
182 | filenameList = [] |
|
182 | filenameList = [] | |
183 | for thisPath in pathList: |
|
183 | for thisPath in pathList: | |
184 | fileList = glob.glob1(thisPath, "*%s" %ext) |
|
184 | fileList = glob.glob1(thisPath, "*%s" %ext) | |
185 | #pathDict[thisPath].append(fileList) |
|
185 | #pathDict[thisPath].append(fileList) | |
186 | fileList.sort() |
|
186 | fileList.sort() | |
187 | for file in fileList: |
|
187 | for file in fileList: | |
188 | filename = os.path.join(thisPath,file) |
|
188 | filename = os.path.join(thisPath,file) | |
189 | if self.isThisFileinRange(filename, startUtSeconds, endUtSeconds): |
|
189 | if self.isThisFileinRange(filename, startUtSeconds, endUtSeconds): | |
190 | filenameList.append(filename) |
|
190 | filenameList.append(filename) | |
191 |
|
191 | |||
192 | self.filenameList = filenameList |
|
192 | self.filenameList = filenameList | |
193 |
|
193 | |||
194 | return pathList, filenameList |
|
194 | return pathList, filenameList | |
195 |
|
195 | |||
196 | def isThisFileinRange(self, filename, startUTSeconds=None, endUTSeconds=None): |
|
196 | def isThisFileinRange(self, filename, startUTSeconds=None, endUTSeconds=None): | |
197 |
|
197 | |||
198 | try: |
|
198 | try: | |
199 | fp = open(filename,'rb') |
|
199 | fp = open(filename,'rb') | |
200 | except: |
|
200 | except: | |
201 | raise IOError, "The file %s can't be opened" %(filename) |
|
201 | raise IOError, "The file %s can't be opened" %(filename) | |
202 |
|
202 | |||
203 | if startUTSeconds==None: |
|
203 | if startUTSeconds==None: | |
204 | startUTSeconds = self.startUTCSeconds |
|
204 | startUTSeconds = self.startUTCSeconds | |
205 |
|
205 | |||
206 | if endUTSeconds==None: |
|
206 | if endUTSeconds==None: | |
207 | endUTSeconds = self.endUTCSeconds |
|
207 | endUTSeconds = self.endUTCSeconds | |
208 |
|
208 | |||
209 | m_BasicHeader = BasicHeader() |
|
209 | m_BasicHeader = BasicHeader() | |
210 |
|
210 | |||
211 | if not(m_BasicHeader.read(fp)): |
|
211 | if not(m_BasicHeader.read(fp)): | |
212 | return 0 |
|
212 | return 0 | |
213 |
|
213 | |||
214 | fp.close() |
|
214 | fp.close() | |
215 |
|
215 | |||
216 | if not ((startUTSeconds <= m_BasicHeader.utc) and (endUTSeconds >= m_BasicHeader.utc)): |
|
216 | if not ((startUTSeconds <= m_BasicHeader.utc) and (endUTSeconds >= m_BasicHeader.utc)): | |
217 | return 0 |
|
217 | return 0 | |
218 |
|
218 | |||
219 | return 1 |
|
219 | return 1 | |
220 |
|
220 | |||
221 | def __readBasicHeader(self, fp=None): |
|
221 | def __readBasicHeader(self, fp=None): | |
222 |
|
222 | |||
223 | if fp == None: |
|
223 | if fp == None: | |
224 | fp = self.__fp |
|
224 | fp = self.__fp | |
225 |
|
225 | |||
226 | self.m_BasicHeader.read(fp) |
|
226 | self.m_BasicHeader.read(fp) | |
227 |
|
227 | |||
228 | def __readFirstHeader(self): |
|
228 | def __readFirstHeader(self): | |
229 |
|
229 | |||
230 | self.__readBasicHeader() |
|
230 | self.__readBasicHeader() | |
231 | self.__rdSystemHeader() |
|
231 | self.__rdSystemHeader() | |
232 | self.__rdRadarControllerHeader() |
|
232 | self.__rdRadarControllerHeader() | |
233 | self.__rdProcessingHeader() |
|
233 | self.__rdProcessingHeader() | |
234 | self.firstHeaderSize = self.m_BasicHeader.size |
|
234 | self.firstHeaderSize = self.m_BasicHeader.size | |
235 |
|
235 | |||
236 | data_type=int(numpy.log2((self.m_ProcessingHeader.processFlags & PROCFLAG.DATATYPE_MASK))-numpy.log2(PROCFLAG.DATATYPE_CHAR)) |
|
236 | data_type=int(numpy.log2((self.m_ProcessingHeader.processFlags & PROCFLAG.DATATYPE_MASK))-numpy.log2(PROCFLAG.DATATYPE_CHAR)) | |
237 | if data_type == 0: |
|
237 | if data_type == 0: | |
238 | tmp=numpy.dtype([('real','<i1'),('imag','<i1')]) |
|
238 | tmp=numpy.dtype([('real','<i1'),('imag','<i1')]) | |
239 | elif data_type == 1: |
|
239 | elif data_type == 1: | |
240 | tmp=numpy.dtype([('real','<i2'),('imag','<i2')]) |
|
240 | tmp=numpy.dtype([('real','<i2'),('imag','<i2')]) | |
241 | elif data_type == 2: |
|
241 | elif data_type == 2: | |
242 | tmp=numpy.dtype([('real','<i4'),('imag','<i4')]) |
|
242 | tmp=numpy.dtype([('real','<i4'),('imag','<i4')]) | |
243 | elif data_type == 3: |
|
243 | elif data_type == 3: | |
244 | tmp=numpy.dtype([('real','<i8'),('imag','<i8')]) |
|
244 | tmp=numpy.dtype([('real','<i8'),('imag','<i8')]) | |
245 | elif data_type == 4: |
|
245 | elif data_type == 4: | |
246 | tmp=numpy.dtype([('real','<f4'),('imag','<f4')]) |
|
246 | tmp=numpy.dtype([('real','<f4'),('imag','<f4')]) | |
247 | elif data_type == 5: |
|
247 | elif data_type == 5: | |
248 | tmp=numpy.dtype([('real','<f8'),('imag','<f8')]) |
|
248 | tmp=numpy.dtype([('real','<f8'),('imag','<f8')]) | |
249 | else: |
|
249 | else: | |
250 | raise ValueError, 'Data type was not defined' |
|
250 | raise ValueError, 'Data type was not defined' | |
251 |
|
251 | |||
252 | self.__dataType = tmp |
|
252 | self.__dataType = tmp | |
253 | self.__fileSizeByHeader = self.m_ProcessingHeader.dataBlocksPerFile * self.m_ProcessingHeader.blockSize + self.firstHeaderSize + self.basicHeaderSize*(self.m_ProcessingHeader.dataBlocksPerFile - 1) |
|
253 | self.__fileSizeByHeader = self.m_ProcessingHeader.dataBlocksPerFile * self.m_ProcessingHeader.blockSize + self.firstHeaderSize + self.basicHeaderSize*(self.m_ProcessingHeader.dataBlocksPerFile - 1) | |
254 | c=3E8 |
|
254 | c=3E8 | |
255 | self.__ippSeconds = 2*1000*self.m_RadarControllerHeader.ipp/c |
|
255 | self.__ippSeconds = 2*1000*self.m_RadarControllerHeader.ipp/c | |
256 |
|
256 | |||
257 | def __setNextFileOnline(self): |
|
257 | def __setNextFileOnline(self): | |
258 | return 0 |
|
258 | return 0 | |
259 |
|
259 | |||
260 | def __setNextFileOffline(self): |
|
260 | def __setNextFileOffline(self): | |
261 |
|
261 | |||
262 | idFile = self.__idFile |
|
262 | idFile = self.__idFile | |
263 | while(True): |
|
263 | while(True): | |
264 |
|
264 | |||
265 | idFile += 1 |
|
265 | idFile += 1 | |
266 |
|
266 | |||
267 | if not(idFile < len(self.filenameList)): |
|
267 | if not(idFile < len(self.filenameList)): | |
268 | self.noMoreFiles = 1 |
|
268 | self.noMoreFiles = 1 | |
269 | return 0 |
|
269 | return 0 | |
270 |
|
270 | |||
271 | filename = self.filenameList[idFile] |
|
271 | filename = self.filenameList[idFile] | |
272 | fileSize = os.path.getsize(filename) |
|
272 | fileSize = os.path.getsize(filename) | |
273 | fp = open(filename,'rb') |
|
273 | fp = open(filename,'rb') | |
274 |
|
274 | |||
275 | currentSize = fileSize - fp.tell() |
|
275 | currentSize = fileSize - fp.tell() | |
276 | neededSize = self.m_ProcessingHeader.blockSize + self.firstHeaderSize |
|
276 | neededSize = self.m_ProcessingHeader.blockSize + self.firstHeaderSize | |
277 |
|
277 | |||
278 | if (currentSize < neededSize): |
|
278 | if (currentSize < neededSize): | |
279 | continue |
|
279 | continue | |
280 |
|
280 | |||
281 | break |
|
281 | break | |
282 |
|
282 | |||
283 | self.__flagIsNewFile = 1 |
|
283 | self.__flagIsNewFile = 1 | |
284 | self.__idFile = idFile |
|
284 | self.__idFile = idFile | |
285 | self.filename = filename |
|
285 | self.filename = filename | |
286 | self.fileSize = fileSize |
|
286 | self.fileSize = fileSize | |
287 | self.__fp = fp |
|
287 | self.__fp = fp | |
288 |
|
288 | |||
289 | print 'Setting the file: %s'%self.filename |
|
289 | print 'Setting the file: %s'%self.filename | |
290 |
|
290 | |||
291 | return 1 |
|
291 | return 1 | |
292 |
|
292 | |||
293 | def __setNextFile(self): |
|
293 | def __setNextFile(self): | |
294 |
|
294 | |||
295 | if self.online: |
|
295 | if self.online: | |
296 | return self.__setNextFileOnline() |
|
296 | return self.__setNextFileOnline() | |
297 | else: |
|
297 | else: | |
298 | return self.__setNextFileOffline() |
|
298 | return self.__setNextFileOffline() | |
299 |
|
299 | |||
300 | def __setNewBlock(self): |
|
300 | def __setNewBlock(self): | |
301 |
|
301 | |||
302 | if self.__fp == None: |
|
302 | if self.__fp == None: | |
303 | return 0 |
|
303 | return 0 | |
304 |
|
304 | |||
305 | if self.__flagIsNewFile: |
|
305 | if self.__flagIsNewFile: | |
306 | return 1 |
|
306 | return 1 | |
307 |
|
307 | |||
308 | currentSize = self.fileSize - self.__fp.tell() |
|
308 | currentSize = self.fileSize - self.__fp.tell() | |
309 | neededSize = self.m_ProcessingHeader.blockSize + self.basicHeaderSize |
|
309 | neededSize = self.m_ProcessingHeader.blockSize + self.basicHeaderSize | |
310 |
|
310 | |||
311 | # Bloque Completo |
|
311 | # Bloque Completo | |
312 | if (currentSize >= neededSize): |
|
312 | if (currentSize >= neededSize): | |
313 | self.__readBasicHeader() |
|
313 | self.__readBasicHeader() | |
314 | return 1 |
|
314 | return 1 | |
315 |
|
315 | |||
316 | if not(self.__setNextFile()): |
|
316 | if not(self.__setNextFile()): | |
317 | return 0 |
|
317 | return 0 | |
318 |
|
318 | |||
319 | self.__readFirstHeader() |
|
319 | self.__readFirstHeader() | |
320 |
|
320 | |||
321 | deltaTime = self.m_BasicHeader.utc - self.__lastUTTime # check this |
|
321 | deltaTime = self.m_BasicHeader.utc - self.__lastUTTime # check this | |
322 |
|
322 | |||
323 | self.flagResetProcessing = 0 |
|
323 | self.flagResetProcessing = 0 | |
324 | if deltaTime > self.__maxTimeStep: |
|
324 | if deltaTime > self.__maxTimeStep: | |
325 | self.flagResetProcessing = 1 |
|
325 | self.flagResetProcessing = 1 | |
326 | self.nReadBlocks = 0 |
|
326 | self.nReadBlocks = 0 | |
327 |
|
327 | |||
328 | return 1 |
|
328 | return 1 | |
329 |
|
329 | |||
330 | def __readBlock(self): |
|
330 | def __readBlock(self): | |
331 | """Lee el bloque de datos desde la posicion actual del puntero del archivo y |
|
331 | """Lee el bloque de datos desde la posicion actual del puntero del archivo y | |
332 | actualiza todos los parametros relacionados al bloque de datos (data, time, |
|
332 | actualiza todos los parametros relacionados al bloque de datos (data, time, | |
333 | etc). La data leida es almacenada en el buffer y el contador de datos leidos es |
|
333 | etc). La data leida es almacenada en el buffer y el contador de datos leidos es | |
334 | seteado a 0 |
|
334 | seteado a 0 | |
335 | """ |
|
335 | """ | |
336 |
|
336 | |||
337 | pts2read = self.m_ProcessingHeader.profilesPerBlock*self.m_ProcessingHeader.numHeights*self.m_SystemHeader.numChannels |
|
337 | pts2read = self.m_ProcessingHeader.profilesPerBlock*self.m_ProcessingHeader.numHeights*self.m_SystemHeader.numChannels | |
338 |
|
338 | |||
339 | data = numpy.fromfile(self.__fp,self.__dataType,pts2read) |
|
339 | data = numpy.fromfile(self.__fp,self.__dataType,pts2read) | |
340 |
|
340 | |||
341 | data = data.reshape((self.m_ProcessingHeader.profilesPerBlock, self.m_ProcessingHeader.numHeights, self.m_SystemHeader.numChannels)) |
|
341 | data = data.reshape((self.m_ProcessingHeader.profilesPerBlock, self.m_ProcessingHeader.numHeights, self.m_SystemHeader.numChannels)) | |
342 |
|
342 | |||
343 | self.__flagIsNewFile = 0 |
|
343 | self.__flagIsNewFile = 0 | |
344 |
|
344 | |||
345 | self.flagIsNewBlock = 1 |
|
345 | self.flagIsNewBlock = 1 | |
346 |
|
346 | |||
347 | self.nReadBlocks += 1 |
|
347 | self.nReadBlocks += 1 | |
348 |
|
348 | |||
349 | self.__buffer = data |
|
349 | self.__buffer = data | |
350 |
|
350 | |||
351 | self.__buffer_id = 0 |
|
351 | self.__buffer_id = 0 | |
352 |
|
352 | |||
353 | def readNextBlock(self): |
|
353 | def readNextBlock(self): | |
354 |
|
354 | |||
355 | if not(self.__setNewBlock()): |
|
355 | if not(self.__setNewBlock()): | |
356 | return 0 |
|
356 | return 0 | |
357 |
|
357 | |||
358 | self.__readBlock() |
|
358 | self.__readBlock() | |
359 |
|
359 | |||
360 | self.__lastUTTime = self.m_BasicHeader.utc |
|
360 | self.__lastUTTime = self.m_BasicHeader.utc | |
361 |
|
361 | |||
362 | return 1 |
|
362 | return 1 | |
363 |
|
363 | |||
364 | def __hasNotDataInBuffer(self): |
|
364 | def __hasNotDataInBuffer(self): | |
365 | if self.__buffer_id >= self.m_ProcessingHeader.profilesPerBlock: |
|
365 | if self.__buffer_id >= self.m_ProcessingHeader.profilesPerBlock: | |
366 | return 1 |
|
366 | return 1 | |
367 |
|
367 | |||
368 | return 0 |
|
368 | return 0 | |
369 |
|
369 | |||
370 | def getData(self): |
|
370 | def getData(self): | |
371 | """Obtiene un unidad de datos del buffer de lectura y es copiada a la clase "Voltage" |
|
371 | """Obtiene un unidad de datos del buffer de lectura y es copiada a la clase "Voltage" | |
372 | con todos los parametros asociados a este. cuando no hay datos en el buffer de |
|
372 | con todos los parametros asociados a este. cuando no hay datos en el buffer de | |
373 | lectura es necesario hacer una nueva lectura de los bloques de datos usando "readNextBlock" |
|
373 | lectura es necesario hacer una nueva lectura de los bloques de datos usando "readNextBlock" | |
374 | """ |
|
374 | """ | |
375 | self.flagResetProcessing = 0 |
|
375 | self.flagResetProcessing = 0 | |
376 | self.flagIsNewBlock = 0 |
|
376 | self.flagIsNewBlock = 0 | |
377 |
|
377 | |||
378 | if self.__hasNotDataInBuffer(): |
|
378 | if self.__hasNotDataInBuffer(): | |
379 | self.readNextBlock() |
|
379 | self.readNextBlock() | |
380 |
|
380 | |||
381 | if self.noMoreFiles == 1: |
|
381 | if self.noMoreFiles == 1: | |
382 | print 'Process finished' |
|
382 | print 'Process finished' | |
383 | return None |
|
383 | return None | |
384 |
|
384 | |||
|
385 | #data es un numpy array de 3 dmensiones (perfiles, alturas y canales) | |||
385 | data = self.__buffer[self.__buffer_id,:,:] |
|
386 | data = self.__buffer[self.__buffer_id,:,:] | |
386 |
|
387 | |||
387 | time = self.m_BasicHeader.utc + self.__buffer_id*self.__ippSeconds |
|
388 | time = self.m_BasicHeader.utc + self.__buffer_id*self.__ippSeconds | |
388 |
|
389 | |||
389 | self.m_Voltage.m_BasicHeader = self.m_BasicHeader.copy() |
|
390 | self.m_Voltage.m_BasicHeader = self.m_BasicHeader.copy() | |
390 | self.m_Voltage.m_ProcessingHeader = self.m_ProcessingHeader.copy() |
|
391 | self.m_Voltage.m_ProcessingHeader = self.m_ProcessingHeader.copy() | |
391 | self.m_Voltage.m_RadarControllerHeader = self.m_RadarControllerHeader.copy() |
|
392 | self.m_Voltage.m_RadarControllerHeader = self.m_RadarControllerHeader.copy() | |
392 | self.m_Voltage.m_SystemHeader = self.m_SystemHeader.copy() |
|
393 | self.m_Voltage.m_SystemHeader = self.m_SystemHeader.copy() | |
393 | self.m_Voltage.m_BasicHeader.utc = time |
|
394 | self.m_Voltage.m_BasicHeader.utc = time | |
394 | self.m_Voltage.data = data |
|
395 | self.m_Voltage.data = data | |
395 |
|
396 | |||
396 | self.__buffer_id += 1 |
|
397 | self.__buffer_id += 1 | |
397 |
|
398 | |||
398 | #call setData - to Data Object |
|
399 | #call setData - to Data Object | |
399 |
|
400 | |||
400 | return data |
|
401 | return data | |
401 |
|
402 | |||
402 |
|
403 | |||
403 | def setup(self, path, startDateTime, endDateTime, set=None, expLabel = "", ext = ".r", online = 0): |
|
404 | def setup(self, path, startDateTime, endDateTime, set=None, expLabel = "", ext = ".r", online = 0): | |
404 |
|
405 | |||
405 | if online == 0: |
|
406 | if online == 0: | |
406 | pathList, filenameList = self.__searchFiles(path, startDateTime, endDateTime, set, expLabel, ext) |
|
407 | pathList, filenameList = self.__searchFiles(path, startDateTime, endDateTime, set, expLabel, ext) | |
407 |
|
408 | |||
408 | if len(filenameList) == 0: |
|
409 | if len(filenameList) == 0: | |
409 | self.__fp = None |
|
410 | self.__fp = None | |
410 | self.noMoreFiles = 1 |
|
411 | self.noMoreFiles = 1 | |
411 | print 'Do not exist files in range: %s - %s'%(startDateTime.ctime(), endDateTime.ctime()) |
|
412 | print 'Do not exist files in range: %s - %s'%(startDateTime.ctime(), endDateTime.ctime()) | |
412 | return 0 |
|
413 | return 0 | |
413 |
|
414 | |||
414 | # for thisFile in filenameList: |
|
415 | # for thisFile in filenameList: | |
415 | # print thisFile |
|
416 | # print thisFile | |
416 |
|
417 | |||
417 | self.__idFile = -1 |
|
418 | self.__idFile = -1 | |
418 |
|
419 | |||
419 | if not(self.__setNextFile()): |
|
420 | if not(self.__setNextFile()): | |
420 | print "No more files" |
|
421 | print "No more files" | |
421 | return 0 |
|
422 | return 0 | |
422 |
|
423 | |||
423 | self.__readFirstHeader() |
|
424 | self.__readFirstHeader() | |
424 |
|
425 | |||
425 | self.startUTCSeconds = time.mktime(startDateTime.timetuple()) |
|
426 | self.startUTCSeconds = time.mktime(startDateTime.timetuple()) | |
426 | self.endUTCSeconds = time.mktime(endDateTime.timetuple()) |
|
427 | self.endUTCSeconds = time.mktime(endDateTime.timetuple()) | |
427 |
|
428 | |||
428 | self.startYear = startDateTime.timetuple().tm_year |
|
429 | self.startYear = startDateTime.timetuple().tm_year | |
429 | self.endYear = endDateTime.timetuple().tm_year |
|
430 | self.endYear = endDateTime.timetuple().tm_year | |
430 |
|
431 | |||
431 | self.startDoy = startDateTime.timetuple().tm_yday |
|
432 | self.startDoy = startDateTime.timetuple().tm_yday | |
432 | self.endDoy = endDateTime.timetuple().tm_yday |
|
433 | self.endDoy = endDateTime.timetuple().tm_yday | |
433 | #call fillHeaderValues() - to Data Object |
|
434 | #call fillHeaderValues() - to Data Object | |
434 |
|
435 | |||
435 | self.__pathList = pathList |
|
436 | self.__pathList = pathList | |
436 | self.filenameList = filenameList |
|
437 | self.filenameList = filenameList | |
437 | self.online = online |
|
438 | self.online = online | |
438 |
|
439 | |||
439 | class VoltageWriter(DataWriter): |
|
440 | class VoltageWriter(DataWriter): | |
440 |
|
441 | |||
441 | m_BasicHeader= BasicHeader() |
|
442 | m_BasicHeader= BasicHeader() | |
442 |
|
443 | |||
443 |
|
444 | |||
444 | m_SystemHeader = SystemHeader() |
|
445 | m_SystemHeader = SystemHeader() | |
445 |
|
446 | |||
446 |
|
447 | |||
447 | m_RadarControllerHeader = RadarControllerHeader() |
|
448 | m_RadarControllerHeader = RadarControllerHeader() | |
448 |
|
449 | |||
449 |
|
450 | |||
450 | m_ProcessingHeader = ProcessingHeader() |
|
451 | m_ProcessingHeader = ProcessingHeader() | |
451 |
|
452 | |||
452 | m_Voltage = None |
|
453 | m_Voltage = None | |
453 |
|
454 | |||
454 | def __init__(self, m_Voltage): |
|
455 | def __init__(self, m_Voltage): | |
455 |
|
456 | |||
456 | self.m_Voltage = m_Voltage |
|
457 | self.m_Voltage = m_Voltage | |
457 |
|
458 | |||
458 |
|
459 | |||
459 | No newline at end of file |
|
460 |
@@ -1,48 +1,49 | |||||
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 |
|
8 | |||
9 | path = os.path.split(os.getcwd())[0] |
|
9 | path = os.path.split(os.getcwd())[0] | |
10 | sys.path.append(path) |
|
10 | sys.path.append(path) | |
11 |
|
11 | |||
12 | from Model.Data import Data |
|
12 | from Model.Data import Data | |
13 | from IO.Header import * |
|
13 | from IO.Header import * | |
14 |
|
14 | |||
15 | class Voltage(Data): |
|
15 | class Voltage(Data): | |
16 | ''' |
|
16 | ''' | |
17 | classdocs |
|
17 | classdocs | |
18 | ''' |
|
18 | ''' | |
19 |
|
19 | |||
20 |
|
20 | |||
21 | m_RadarControllerHeader= RadarControllerHeader() |
|
21 | m_RadarControllerHeader= RadarControllerHeader() | |
22 |
|
22 | |||
23 | m_ProcessingHeader= ProcessingHeader() |
|
23 | m_ProcessingHeader= ProcessingHeader() | |
24 |
|
24 | |||
25 | m_SystemHeader= SystemHeader() |
|
25 | m_SystemHeader= SystemHeader() | |
26 |
|
26 | |||
27 | m_BasicHeader= BasicHeader() |
|
27 | m_BasicHeader= BasicHeader() | |
28 |
|
28 | |||
|
29 | #data es un numpy array de 3 dmensiones (perfiles, alturas y canales) | |||
29 | data = None |
|
30 | data = None | |
30 |
|
31 | |||
31 | noData = True |
|
32 | noData = True | |
32 |
|
33 | |||
33 |
|
34 | |||
34 | def __init__(self): |
|
35 | def __init__(self): | |
35 | ''' |
|
36 | ''' | |
36 | Constructor |
|
37 | Constructor | |
37 | ''' |
|
38 | ''' | |
38 | pass |
|
39 | pass | |
39 |
|
40 | |||
40 | def copy(self): |
|
41 | def copy(self): | |
41 | obj = Voltage() |
|
42 | obj = Voltage() | |
42 | obj.m_BasicHeader = self.m_BasicHeader.copy() |
|
43 | obj.m_BasicHeader = self.m_BasicHeader.copy() | |
43 | obj.m_SystemHeader = self.m_SystemHeader.copy() |
|
44 | obj.m_SystemHeader = self.m_SystemHeader.copy() | |
44 | obj.m_RadarControllerHeader = self.m_RadarControllerHeader.copy() |
|
45 | obj.m_RadarControllerHeader = self.m_RadarControllerHeader.copy() | |
45 | obj.m_ProcessingHeader = self.m_ProcessingHeader.copy() |
|
46 | obj.m_ProcessingHeader = self.m_ProcessingHeader.copy() | |
46 |
|
47 | |||
47 | return obj |
|
48 | return obj | |
48 | No newline at end of file |
|
49 |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now