@@ -1,355 +1,362 | |||
|
1 | ''' | |
|
2 | Created on Feb 7, 2012 | |
|
3 | ||
|
4 | @author $Author$ | |
|
5 | @version $Id$ | |
|
6 | ''' | |
|
7 | ||
|
1 | 8 | import numpy |
|
2 | 9 | import plplot |
|
3 | 10 | |
|
4 | 11 | def cmap1_init(colormap="gray"): |
|
5 | 12 | |
|
6 | 13 | ncolor = None |
|
7 | 14 | rgb_lvl = None |
|
8 | 15 | |
|
9 | 16 | # Routine for defining a specific color map 1 in HLS space. |
|
10 | 17 | # if gray is true, use basic grayscale variation from half-dark to light. |
|
11 | 18 | # otherwise use false color variation from blue (240 deg) to red (360 deg). |
|
12 | 19 | |
|
13 | 20 | # Independent variable of control points. |
|
14 | 21 | i = numpy.array((0., 1.)) |
|
15 | 22 | if colormap=="gray": |
|
16 | 23 | ncolor = 256 |
|
17 | 24 | # Hue for control points. Doesn't matter since saturation is zero. |
|
18 | 25 | h = numpy.array((0., 0.)) |
|
19 | 26 | # Lightness ranging from half-dark (for interest) to light. |
|
20 | 27 | l = numpy.array((0.5, 1.)) |
|
21 | 28 | # Gray scale has zero saturation |
|
22 | 29 | s = numpy.array((0., 0.)) |
|
23 | 30 | |
|
24 | 31 | # number of cmap1 colours is 256 in this case. |
|
25 | 32 | plplot.plscmap1n(ncolor) |
|
26 | 33 | # Interpolate between control points to set up cmap1. |
|
27 | 34 | plplot.plscmap1l(0, i, h, l, s) |
|
28 | 35 | |
|
29 | 36 | return None |
|
30 | 37 | |
|
31 | 38 | if colormap=="br_green": |
|
32 | 39 | ncolor = 256 |
|
33 | 40 | # Hue ranges from blue (240 deg) to red (0 or 360 deg) |
|
34 | 41 | h = numpy.array((240., 0.)) |
|
35 | 42 | # Lightness and saturation are constant (values taken from C example). |
|
36 | 43 | l = numpy.array((0.6, 0.6)) |
|
37 | 44 | s = numpy.array((0.8, 0.8)) |
|
38 | 45 | |
|
39 | 46 | # number of cmap1 colours is 256 in this case. |
|
40 | 47 | plplot.plscmap1n(ncolor) |
|
41 | 48 | # Interpolate between control points to set up cmap1. |
|
42 | 49 | plplot.plscmap1l(0, i, h, l, s) |
|
43 | 50 | |
|
44 | 51 | return None |
|
45 | 52 | |
|
46 | 53 | if colormap=="tricolor": |
|
47 | 54 | ncolor = 3 |
|
48 | 55 | # Hue ranges from blue (240 deg) to red (0 or 360 deg) |
|
49 | 56 | h = numpy.array((240., 0.)) |
|
50 | 57 | # Lightness and saturation are constant (values taken from C example). |
|
51 | 58 | l = numpy.array((0.6, 0.6)) |
|
52 | 59 | s = numpy.array((0.8, 0.8)) |
|
53 | 60 | |
|
54 | 61 | # number of cmap1 colours is 256 in this case. |
|
55 | 62 | plplot.plscmap1n(ncolor) |
|
56 | 63 | # Interpolate between control points to set up cmap1. |
|
57 | 64 | plplot.plscmap1l(0, i, h, l, s) |
|
58 | 65 | |
|
59 | 66 | return None |
|
60 | 67 | |
|
61 | 68 | if colormap == 'rgb' or colormap == 'rgb666': |
|
62 | 69 | |
|
63 | 70 | color_sz = 6 |
|
64 | 71 | ncolor = color_sz*color_sz*color_sz |
|
65 | 72 | pos = numpy.zeros((ncolor)) |
|
66 | 73 | r = numpy.zeros((ncolor)) |
|
67 | 74 | g = numpy.zeros((ncolor)) |
|
68 | 75 | b = numpy.zeros((ncolor)) |
|
69 | 76 | ind = 0 |
|
70 | 77 | for ri in range(color_sz): |
|
71 | 78 | for gi in range(color_sz): |
|
72 | 79 | for bi in range(color_sz): |
|
73 | 80 | r[ind] = ri/(color_sz-1.0) |
|
74 | 81 | g[ind] = gi/(color_sz-1.0) |
|
75 | 82 | b[ind] = bi/(color_sz-1.0) |
|
76 | 83 | pos[ind] = ind/(ncolor-1.0) |
|
77 | 84 | ind += 1 |
|
78 | 85 | rgb_lvl = [6,6,6] #Levels for RGB colors |
|
79 | 86 | |
|
80 | 87 | if colormap == 'rgb676': |
|
81 | 88 | ncolor = 6*7*6 |
|
82 | 89 | pos = numpy.zeros((ncolor)) |
|
83 | 90 | r = numpy.zeros((ncolor)) |
|
84 | 91 | g = numpy.zeros((ncolor)) |
|
85 | 92 | b = numpy.zeros((ncolor)) |
|
86 | 93 | ind = 0 |
|
87 | 94 | for ri in range(8): |
|
88 | 95 | for gi in range(8): |
|
89 | 96 | for bi in range(4): |
|
90 | 97 | r[ind] = ri/(6-1.0) |
|
91 | 98 | g[ind] = gi/(7-1.0) |
|
92 | 99 | b[ind] = bi/(6-1.0) |
|
93 | 100 | pos[ind] = ind/(ncolor-1.0) |
|
94 | 101 | ind += 1 |
|
95 | 102 | rgb_lvl = [6,7,6] #Levels for RGB colors |
|
96 | 103 | |
|
97 | 104 | if colormap == 'rgb685': |
|
98 | 105 | ncolor = 6*8*5 |
|
99 | 106 | pos = numpy.zeros((ncolor)) |
|
100 | 107 | r = numpy.zeros((ncolor)) |
|
101 | 108 | g = numpy.zeros((ncolor)) |
|
102 | 109 | b = numpy.zeros((ncolor)) |
|
103 | 110 | ind = 0 |
|
104 | 111 | for ri in range(8): |
|
105 | 112 | for gi in range(8): |
|
106 | 113 | for bi in range(4): |
|
107 | 114 | r[ind] = ri/(6-1.0) |
|
108 | 115 | g[ind] = gi/(8-1.0) |
|
109 | 116 | b[ind] = bi/(5-1.0) |
|
110 | 117 | pos[ind] = ind/(ncolor-1.0) |
|
111 | 118 | ind += 1 |
|
112 | 119 | rgb_lvl = [6,8,5] #Levels for RGB colors |
|
113 | 120 | |
|
114 | 121 | if colormap == 'rgb884': |
|
115 | 122 | ncolor = 8*8*4 |
|
116 | 123 | pos = numpy.zeros((ncolor)) |
|
117 | 124 | r = numpy.zeros((ncolor)) |
|
118 | 125 | g = numpy.zeros((ncolor)) |
|
119 | 126 | b = numpy.zeros((ncolor)) |
|
120 | 127 | ind = 0 |
|
121 | 128 | for ri in range(8): |
|
122 | 129 | for gi in range(8): |
|
123 | 130 | for bi in range(4): |
|
124 | 131 | r[ind] = ri/(8-1.0) |
|
125 | 132 | g[ind] = gi/(8-1.0) |
|
126 | 133 | b[ind] = bi/(4-1.0) |
|
127 | 134 | pos[ind] = ind/(ncolor-1.0) |
|
128 | 135 | ind += 1 |
|
129 | 136 | rgb_lvl = [8,8,4] #Levels for RGB colors |
|
130 | 137 | |
|
131 | 138 | if ncolor == None: |
|
132 | 139 | raise ValueError, "The colormap selected is not valid" |
|
133 | 140 | |
|
134 | 141 | plplot.plscmap1n(ncolor) |
|
135 | 142 | plplot.plscmap1l(1, pos, r, g, b) |
|
136 | 143 | |
|
137 | 144 | return rgb_lvl |
|
138 | 145 | |
|
139 | 146 | class BasicGraph: |
|
140 | 147 | """ |
|
141 | 148 | |
|
142 | 149 | """ |
|
143 | 150 | |
|
144 | 151 | hasRange = False |
|
145 | 152 | |
|
146 | 153 | xrange = None |
|
147 | 154 | yrange = None |
|
148 | 155 | zrange = None |
|
149 | 156 | |
|
150 | 157 | xlabel = None |
|
151 | 158 | ylabel = None |
|
152 | 159 | title = None |
|
153 | 160 | |
|
154 | 161 | legends = None |
|
155 | 162 | |
|
156 | 163 | __name = None |
|
157 | 164 | __subpage = None |
|
158 | 165 | __szchar = None |
|
159 | 166 | |
|
160 | 167 | __colormap = None |
|
161 | 168 | __colbox = None |
|
162 | 169 | __colleg = None |
|
163 | 170 | |
|
164 | 171 | __xpos = None |
|
165 | 172 | __ypos = None |
|
166 | 173 | |
|
167 | 174 | __xopt = None #"bcnst" |
|
168 | 175 | __yopt = None #"bcnstv" |
|
169 | 176 | |
|
170 | 177 | __xlpos = None |
|
171 | 178 | __ylpos = None |
|
172 | 179 | |
|
173 | 180 | __xrangeIsTime = None |
|
174 | 181 | |
|
175 | 182 | #Advanced |
|
176 | 183 | __xg = None |
|
177 | 184 | __yg = None |
|
178 | 185 | |
|
179 | 186 | def __init__(self): |
|
180 | 187 | """ |
|
181 | 188 | |
|
182 | 189 | """ |
|
183 | 190 | pass |
|
184 | 191 | |
|
185 | 192 | def hasNotXrange(self): |
|
186 | 193 | |
|
187 | 194 | if self.xrange == None: |
|
188 | 195 | return 1 |
|
189 | 196 | |
|
190 | 197 | return 0 |
|
191 | 198 | |
|
192 | 199 | def hasNotYrange(self): |
|
193 | 200 | |
|
194 | 201 | if self.yrange == None: |
|
195 | 202 | return 1 |
|
196 | 203 | |
|
197 | 204 | return 0 |
|
198 | 205 | |
|
199 | 206 | def hasNotZrange(self): |
|
200 | 207 | |
|
201 | 208 | if self.zrange == None: |
|
202 | 209 | return 1 |
|
203 | 210 | |
|
204 | 211 | return 0 |
|
205 | 212 | def setName(self, name): |
|
206 | 213 | self.__name = name |
|
207 | 214 | |
|
208 | 215 | def setScreenPos(self, xpos, ypos): |
|
209 | 216 | self.__xpos = xpos |
|
210 | 217 | self.__ypos = ypos |
|
211 | 218 | |
|
212 | 219 | def setScreenPosbyWidth(self, xoff, yoff, xw, yw): |
|
213 | 220 | self.__xpos = [xoff, xoff + xw] |
|
214 | 221 | self.__ypos = [yoff, yoff + yw] |
|
215 | 222 | |
|
216 | 223 | def setSubpage(self, subpage): |
|
217 | 224 | self.__subpage = subpage |
|
218 | 225 | |
|
219 | 226 | def setSzchar(self, szchar): |
|
220 | 227 | self.__szchar = szchar |
|
221 | 228 | |
|
222 | 229 | def setOpt(self, xopt, yopt): |
|
223 | 230 | self.__xopt = xopt |
|
224 | 231 | self.__yopt = yopt |
|
225 | 232 | |
|
226 | 233 | def setRanges(self, xrange, yrange, zrange=None): |
|
227 | 234 | """ |
|
228 | 235 | """ |
|
229 | 236 | self.xrange = xrange |
|
230 | 237 | |
|
231 | 238 | self.yrange = yrange |
|
232 | 239 | |
|
233 | 240 | if zrange != None: |
|
234 | 241 | self.zrange = zrange |
|
235 | 242 | |
|
236 | 243 | def setColormap(self, colormap=None): |
|
237 | 244 | |
|
238 | 245 | if colormap == None: |
|
239 | 246 | colormap = self.__colormap |
|
240 | 247 | |
|
241 | 248 | cmap1_init(colormap) |
|
242 | 249 | |
|
243 | 250 | def plotBox(self): |
|
244 | 251 | """ |
|
245 | 252 | |
|
246 | 253 | """ |
|
247 | 254 | plplot.plvpor(self.__xpos[0], self.__xpos[1], self.__ypos[0], self.__ypos[1]) |
|
248 | 255 | plplot.plwind(self.xrange[0], self.xrange[1], self.yrange[0], self.yrange[1]) |
|
249 | 256 | plplot.plbox(self.__xopt, 0.0, 0, self.__yopt, 0.0, 0) |
|
250 | 257 | plplot.pllab(self.xlabel, self.ylabel, self.title) |
|
251 | 258 | |
|
252 | 259 | def setup(self, title=None, xlabel=None, ylabel=None, colormap=None): |
|
253 | 260 | """ |
|
254 | 261 | """ |
|
255 | 262 | self.title = title |
|
256 | 263 | self.xlabel = xlabel |
|
257 | 264 | self.ylabel = ylabel |
|
258 | 265 | self.__colormap = colormap |
|
259 | 266 | |
|
260 | 267 | def initSubpage(self): |
|
261 | 268 | |
|
262 | 269 | if plplot.plgdev() == '': |
|
263 | 270 | raise ValueError, "Plot device has not been initialize" |
|
264 | 271 | |
|
265 | 272 | plplot.pladv(self.__subpage) |
|
266 | 273 | plplot.plschr(0.0, self.__szchar) |
|
267 | 274 | |
|
268 | 275 | if self.__xrangeIsTime: |
|
269 | 276 | plplot.pltimefmt("%H:%M") |
|
270 | 277 | |
|
271 | 278 | self.setColormap() |
|
272 | 279 | self.initPlot() |
|
273 | 280 | |
|
274 | 281 | def initPlot(self): |
|
275 | 282 | """ |
|
276 | 283 | |
|
277 | 284 | """ |
|
278 | 285 | if plplot.plgdev() == '': |
|
279 | 286 | raise ValueError, "Plot device has not been initialize" |
|
280 | 287 | |
|
281 | 288 | xrange = self.xrange |
|
282 | 289 | if xrange == None: |
|
283 | 290 | xrange = [0., 1.] |
|
284 | 291 | |
|
285 | 292 | yrange = self.yrange |
|
286 | 293 | if yrange == None: |
|
287 | 294 | yrange = [0., 1.] |
|
288 | 295 | |
|
289 | 296 | plplot.plvpor(self.__xpos[0], self.__xpos[1], self.__ypos[0], self.__ypos[1]) |
|
290 | 297 | plplot.plwind(xrange[0], xrange[1], yrange[0], yrange[1]) |
|
291 | 298 | plplot.plbox(self.__xopt, 0.0, 0, self.__yopt, 0.0, 0) |
|
292 | 299 | plplot.pllab(self.xlabel, self.ylabel, self.title) |
|
293 | 300 | |
|
294 | 301 | def colorbarPlot(self): |
|
295 | 302 | data = numpy.arange(256) |
|
296 | 303 | data = numpy.reshape(data, (1,-1)) |
|
297 | 304 | |
|
298 | 305 | self.plotBox() |
|
299 | 306 | plplot.plimage(data, |
|
300 | 307 | self.xrange[0], |
|
301 | 308 | self.xrange[1], |
|
302 | 309 | self.yrange[0], |
|
303 | 310 | self.yrange[1], |
|
304 | 311 | 0., |
|
305 | 312 | 255., |
|
306 | 313 | self.xrange[0], |
|
307 | 314 | self.xrange[1], |
|
308 | 315 | self.yrange[0], |
|
309 | 316 | self.yrange[1],) |
|
310 | 317 | |
|
311 | 318 | def basicXYPlot(self, x, y): |
|
312 | 319 | self.plotBox() |
|
313 | 320 | plplot.plline(x, y) |
|
314 | 321 | |
|
315 | 322 | def basicXYwithErrorPlot(self): |
|
316 | 323 | pass |
|
317 | 324 | |
|
318 | 325 | def basicLineTimePlot(self): |
|
319 | 326 | pass |
|
320 | 327 | |
|
321 | 328 | def basicPcolorPlot(self, data, xmin, xmax, ymin, ymax, zmin, zmax): |
|
322 | 329 | """ |
|
323 | 330 | """ |
|
324 | 331 | |
|
325 | 332 | self.plotBox() |
|
326 | 333 | plplot.plimage(data, xmin, xmax, ymin, ymax, zmin, zmax, xmin, xmax, ymin, ymax) |
|
327 | 334 | |
|
328 | 335 | |
|
329 | 336 | def __getBoxpltr(self, x, y, deltax=None, deltay=None): |
|
330 | 337 | |
|
331 | 338 | if not(len(x)>1 and len(y)>1): |
|
332 | 339 | raise ValueError, "x axis and y axis are empty" |
|
333 | 340 | |
|
334 | 341 | if deltax == None: deltax = x[-1] - x[-2] |
|
335 | 342 | if deltay == None: deltay = y[-1] - y[-2] |
|
336 | 343 | |
|
337 | 344 | x1 = numpy.append(x, x[-1] + deltax) |
|
338 | 345 | y1 = numpy.append(y, y[-1] + deltay) |
|
339 | 346 | |
|
340 | 347 | xg = (numpy.multiply.outer(x1, numpy.ones(len(y1)))) |
|
341 | 348 | yg = (numpy.multiply.outer(numpy.ones(len(x1)), y1)) |
|
342 | 349 | |
|
343 | 350 | self.__xg = xg |
|
344 | 351 | self.__yg = yg |
|
345 | 352 | |
|
346 | 353 | def advPcolorPlot(self, data, x, y, zmin=0., zmax=0.): |
|
347 | 354 | """ |
|
348 | 355 | """ |
|
349 | 356 | |
|
350 | 357 | if self.__xg == None and self.__yg == None: |
|
351 | 358 | self.__getBoxpltr(x, y) |
|
352 | 359 | |
|
353 | 360 | plplot.plimagefr(data, x[0], x[-1], y[0], y[-1], 0., 0., zmin, zmax, plplot.pltr2, self.__xg, self.__yg) |
|
354 | 361 | |
|
355 | 362 |
@@ -1,227 +1,234 | |||
|
1 | ''' | |
|
2 | Created on Feb 7, 2012 | |
|
3 | ||
|
4 | @author $Author$ | |
|
5 | @version $Id$ | |
|
6 | ''' | |
|
7 | ||
|
1 | 8 | import numpy |
|
2 | 9 | import plplot |
|
3 | 10 | |
|
4 | 11 | from BasicGraph import * |
|
5 | 12 | |
|
6 | 13 | class Spectrum: |
|
7 | 14 | |
|
8 | 15 | graphObjDict = {} |
|
9 | 16 | showColorbar = False |
|
10 | 17 | showPowerProfile = True |
|
11 | 18 | |
|
12 | 19 | __szchar = 0.7 |
|
13 | 20 | __xrange = None |
|
14 | 21 | __yrange = None |
|
15 | 22 | __zrange = None |
|
16 | 23 | specObj = BasicGraph() |
|
17 | 24 | |
|
18 | 25 | |
|
19 | 26 | def __init__(self): |
|
20 | 27 | |
|
21 | 28 | key = "spec" |
|
22 | 29 | |
|
23 | 30 | specObj = BasicGraph() |
|
24 | 31 | specObj.setName(key) |
|
25 | 32 | |
|
26 | 33 | self.graphObjDict[key] = specObj |
|
27 | 34 | |
|
28 | 35 | |
|
29 | 36 | def setup(self, subpage, title="", xlabel="", ylabel="", colormap="jet", showColorbar=False, showPowerProfile=False): |
|
30 | 37 | """ |
|
31 | 38 | """ |
|
32 | 39 | |
|
33 | 40 | xi = 0.12; xw = 0.78; xf = xi + xw |
|
34 | 41 | yi = 0.14; yw = 0.80; yf = yi + yw |
|
35 | 42 | |
|
36 | 43 | xcmapi = xcmapf = 0.; xpowi = xpowf = 0. |
|
37 | 44 | |
|
38 | 45 | key = "spec" |
|
39 | 46 | specObj = self.graphObjDict[key] |
|
40 | 47 | specObj.setSubpage(subpage) |
|
41 | 48 | specObj.setSzchar(self.__szchar) |
|
42 | 49 | specObj.setOpt("bcnts","bcnts") |
|
43 | 50 | specObj.setup(title, |
|
44 | 51 | xlabel, |
|
45 | 52 | ylabel, |
|
46 | 53 | colormap) |
|
47 | 54 | |
|
48 | 55 | if showColorbar: |
|
49 | 56 | key = "colorbar" |
|
50 | 57 | |
|
51 | 58 | cmapObj = BasicGraph() |
|
52 | 59 | cmapObj.setName(key) |
|
53 | 60 | cmapObj.setSubpage(subpage) |
|
54 | 61 | cmapObj.setSzchar(self.__szchar) |
|
55 | 62 | cmapObj.setOpt("bc","bcmt") |
|
56 | 63 | cmapObj.setup(title="dBs", |
|
57 | 64 | xlabel="", |
|
58 | 65 | ylabel="", |
|
59 | 66 | colormap=colormap) |
|
60 | 67 | |
|
61 | 68 | self.graphObjDict[key] = cmapObj |
|
62 | 69 | |
|
63 | 70 | xcmapi = 0. |
|
64 | 71 | xcmapw = 0.05 |
|
65 | 72 | xw -= xcmapw |
|
66 | 73 | |
|
67 | 74 | if showPowerProfile: |
|
68 | 75 | key = "powerprof" |
|
69 | 76 | |
|
70 | 77 | powObj = BasicGraph() |
|
71 | 78 | powObj.setName(key) |
|
72 | 79 | powObj.setSubpage(subpage) |
|
73 | 80 | powObj.setSzchar(self.__szchar) |
|
74 | 81 | plplot.pllsty(2) |
|
75 | 82 | powObj.setOpt("bcntg","bc") |
|
76 | 83 | plplot.pllsty(1) |
|
77 | 84 | powObj.setup(title="Power Profile", |
|
78 | 85 | xlabel="dBs", |
|
79 | 86 | ylabel="") |
|
80 | 87 | |
|
81 | 88 | self.graphObjDict[key] = powObj |
|
82 | 89 | |
|
83 | 90 | xpowi = 0. |
|
84 | 91 | xpoww = 0.24 |
|
85 | 92 | xw -= xpoww |
|
86 | 93 | |
|
87 | 94 | xf = xi + xw |
|
88 | 95 | yf = yi + yw |
|
89 | 96 | xcmapf = xf |
|
90 | 97 | |
|
91 | 98 | specObj.setScreenPos([xi, xf], [yi, yf]) |
|
92 | 99 | |
|
93 | 100 | if showColorbar: |
|
94 | 101 | xcmapi = xf + 0.02 |
|
95 | 102 | xcmapf = xcmapi + xcmapw |
|
96 | 103 | cmapObj.setScreenPos([xcmapi, xcmapf], [yi, yf]) |
|
97 | 104 | |
|
98 | 105 | if showPowerProfile: |
|
99 | 106 | xpowi = xcmapf + 0.06 |
|
100 | 107 | xpowf = xpowi + xpoww |
|
101 | 108 | powObj.setScreenPos([xpowi, xpowf], [yi, yf]) |
|
102 | 109 | |
|
103 | 110 | |
|
104 | 111 | # specObj.initSubpage() |
|
105 | 112 | # |
|
106 | 113 | # if showColorbar: |
|
107 | 114 | # cmapObj.initPlot() |
|
108 | 115 | # |
|
109 | 116 | # if showPowerProfile: |
|
110 | 117 | # powObj.initPlot() |
|
111 | 118 | |
|
112 | 119 | self.showColorbar = showColorbar |
|
113 | 120 | self.showPowerProfile = showPowerProfile |
|
114 | 121 | |
|
115 | 122 | def setRanges(self, xrange, yrange, zrange): |
|
116 | 123 | |
|
117 | 124 | key = "spec" |
|
118 | 125 | specObj = self.graphObjDict[key] |
|
119 | 126 | specObj.setRanges(xrange, yrange, zrange) |
|
120 | 127 | |
|
121 | 128 | keyList = self.graphObjDict.keys() |
|
122 | 129 | |
|
123 | 130 | key = "colorbar" |
|
124 | 131 | if key in keyList: |
|
125 | 132 | cmapObj = self.graphObjDict[key] |
|
126 | 133 | cmapObj.setRanges([0., 1.], zrange) |
|
127 | 134 | |
|
128 | 135 | key = "powerprof" |
|
129 | 136 | if key in keyList: |
|
130 | 137 | powObj = self.graphObjDict[key] |
|
131 | 138 | powObj.setRanges(zrange, yrange) |
|
132 | 139 | |
|
133 | 140 | def plotData(self, data , xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None): |
|
134 | 141 | |
|
135 | 142 | key = "spec" |
|
136 | 143 | specObj = self.graphObjDict[key] |
|
137 | 144 | specObj.initSubpage() |
|
138 | 145 | |
|
139 | 146 | if xmin == None: |
|
140 | 147 | xmin = 0. |
|
141 | 148 | |
|
142 | 149 | if xmax == None: |
|
143 | 150 | xmax = 1. |
|
144 | 151 | |
|
145 | 152 | if ymin == None: |
|
146 | 153 | ymin = 0. |
|
147 | 154 | |
|
148 | 155 | if ymax == None: |
|
149 | 156 | ymax = 1. |
|
150 | 157 | |
|
151 | 158 | if zmin == None: |
|
152 | 159 | zmin = numpy.nanmin(data) |
|
153 | 160 | |
|
154 | 161 | if zmax == None: |
|
155 | 162 | zmax = numpy.nanmax(data) |
|
156 | 163 | |
|
157 | 164 | if not(specObj.hasRange): |
|
158 | 165 | self.setRanges([xmin, xmax], [ymin,ymax], [zmin,zmax]) |
|
159 | 166 | |
|
160 | 167 | specObj.basicPcolorPlot(data, xmin, xmax, ymin, ymax, specObj.zrange[0], specObj.zrange[1]) |
|
161 | 168 | |
|
162 | 169 | if self.showColorbar: |
|
163 | 170 | key = "colorbar" |
|
164 | 171 | cmapObj = self.graphObjDict[key] |
|
165 | 172 | cmapObj.colorbarPlot() |
|
166 | 173 | |
|
167 | 174 | if self.showPowerProfile: |
|
168 | 175 | power = numpy.average(data, axis=1) |
|
169 | 176 | |
|
170 | 177 | step = (ymax - ymin)/(power.shape[0]-1) |
|
171 | 178 | heis = numpy.arange(ymin, ymax + step, step) |
|
172 | 179 | |
|
173 | 180 | key = "powerprof" |
|
174 | 181 | powObj = self.graphObjDict[key] |
|
175 | 182 | powObj.basicXYPlot(power, heis) |
|
176 | 183 | |
|
177 | 184 | class CrossSpectrum: |
|
178 | 185 | graphObjDict = {} |
|
179 | 186 | showColorbar = False |
|
180 | 187 | showPowerProfile = True |
|
181 | 188 | |
|
182 | 189 | __szchar = 0.7 |
|
183 | 190 | __showPhase = False |
|
184 | 191 | __xrange = None |
|
185 | 192 | __yrange = None |
|
186 | 193 | __zrange = None |
|
187 | 194 | m_BasicGraph= BasicGraph() |
|
188 | 195 | |
|
189 | 196 | def __init__(self): |
|
190 | 197 | pass |
|
191 | 198 | |
|
192 | 199 | def setup(self, subpage, title, xlabel, ylabel, colormap, showColorbar, showPowerProfile): |
|
193 | 200 | pass |
|
194 | 201 | |
|
195 | 202 | def setRanges(self, xrange, yrange, zrange): |
|
196 | 203 | pass |
|
197 | 204 | |
|
198 | 205 | def plotData(self, data, xmin, xmax, ymin, ymax, zmin, zmax): |
|
199 | 206 | pass |
|
200 | 207 | |
|
201 | 208 | if __name__ == '__main__': |
|
202 | 209 | |
|
203 | 210 | import numpy |
|
204 | 211 | plplot.plsetopt("geometry", "%dx%d" %(350*2, 300*2)) |
|
205 | 212 | plplot.plsdev("xcairo") |
|
206 | 213 | plplot.plscolbg(255,255,255) |
|
207 | 214 | plplot.plscol0(1,0,0,0) |
|
208 | 215 | plplot.plinit() |
|
209 | 216 | plplot.plssub(2, 2) |
|
210 | 217 | |
|
211 | 218 | nx = 64 |
|
212 | 219 | ny = 100 |
|
213 | 220 | |
|
214 | 221 | data = numpy.random.uniform(-50,50,(nx,ny)) |
|
215 | 222 | |
|
216 | 223 | specObj = Spectrum() |
|
217 | 224 | specObj.setup(1, "Spectrum", "Frequency", "Range", "br_green", False, False) |
|
218 | 225 | specObj.plotData(data) |
|
219 | 226 | |
|
220 | 227 | data = numpy.random.uniform(-50,50,(nx,ny)) |
|
221 | 228 | |
|
222 | 229 | spec2Obj = Spectrum() |
|
223 | 230 | spec2Obj.setup(2, "Spectrum", "Frequency", "Range", "br_green", True, True) |
|
224 | 231 | spec2Obj.plotData(data) |
|
225 | 232 | |
|
226 | 233 | plplot.plend() |
|
227 | 234 | exit(0) No newline at end of file |
@@ -1,17 +1,18 | |||
|
1 | 1 | ''' |
|
2 | 2 | Created on Feb 7, 2012 |
|
3 | 3 | |
|
4 | @author: roj-idl71 | |
|
4 | @author $Author$ | |
|
5 | @version $Id$ | |
|
5 | 6 | ''' |
|
6 | 7 | |
|
7 | 8 | class VoltagePlot(object): |
|
8 | 9 | ''' |
|
9 | 10 | classdocs |
|
10 | 11 | ''' |
|
11 | 12 | |
|
12 | 13 | |
|
13 | 14 | def __init__(self): |
|
14 | 15 | ''' |
|
15 | 16 | Constructor |
|
16 | 17 | ''' |
|
17 | 18 | pass No newline at end of file |
@@ -1,16 +1,17 | |||
|
1 | 1 | ''' |
|
2 | 2 | Created on 23/01/2012 |
|
3 | 3 | |
|
4 | @author: danielangelsuarezmunoz | |
|
4 | @author $Author$ | |
|
5 | @version $Id$ | |
|
5 | 6 | ''' |
|
6 | 7 | |
|
7 | 8 | from Data import DataReader |
|
8 | 9 | from Data import DataWriter |
|
9 | 10 | |
|
10 | 11 | class CorrelationReader(DataReader): |
|
11 | 12 | def __init__(self): |
|
12 | 13 | pass |
|
13 | 14 | |
|
14 | 15 | class CorrelationWriter(DataWriter): |
|
15 | 16 | def __init__(self): |
|
16 | 17 | pass No newline at end of file |
@@ -1,18 +1,19 | |||
|
1 | 1 | ''' |
|
2 | 2 | Created on 23/01/2012 |
|
3 | 3 | |
|
4 | @author: danielangelsuarezmunoz | |
|
4 | @author $Author$ | |
|
5 | @version $Id$ | |
|
5 | 6 | ''' |
|
6 | 7 | |
|
7 | 8 | |
|
8 | 9 | class DataReader: |
|
9 | 10 | __buffer = 0 |
|
10 | 11 | __buffer_count = 0 |
|
11 | 12 | def __init__(self): |
|
12 | 13 | pass |
|
13 | 14 | |
|
14 | 15 | class DataWriter: |
|
15 | 16 | __buffer = 0 |
|
16 | 17 | __buffer_count = 0 |
|
17 | 18 | def __init__(self): |
|
18 | 19 | pass No newline at end of file |
@@ -1,312 +1,319 | |||
|
1 | ''' | |
|
2 | Created on 23/01/2012 | |
|
3 | ||
|
4 | @author $Author$ | |
|
5 | @version $Id$ | |
|
6 | ''' | |
|
7 | ||
|
1 | 8 | import numpy |
|
2 | 9 | |
|
3 | 10 | class PROCFLAG: |
|
4 | 11 | COHERENT_INTEGRATION = numpy.uint32(0x00000001) |
|
5 | 12 | DECODE_DATA = numpy.uint32(0x00000002) |
|
6 | 13 | SPECTRA_CALC = numpy.uint32(0x00000004) |
|
7 | 14 | INCOHERENT_INTEGRATION = numpy.uint32(0x00000008) |
|
8 | 15 | POST_COHERENT_INTEGRATION = numpy.uint32(0x00000010) |
|
9 | 16 | SHIFT_FFT_DATA = numpy.uint32(0x00000020) |
|
10 | 17 | |
|
11 | 18 | DATATYPE_CHAR = numpy.uint32(0x00000040) |
|
12 | 19 | DATATYPE_SHORT = numpy.uint32(0x00000080) |
|
13 | 20 | DATATYPE_LONG = numpy.uint32(0x00000100) |
|
14 | 21 | DATATYPE_INT64 = numpy.uint32(0x00000200) |
|
15 | 22 | DATATYPE_FLOAT = numpy.uint32(0x00000400) |
|
16 | 23 | DATATYPE_DOUBLE = numpy.uint32(0x00000800) |
|
17 | 24 | |
|
18 | 25 | DATAARRANGE_CONTIGUOUS_CH = numpy.uint32(0x00001000) |
|
19 | 26 | DATAARRANGE_CONTIGUOUS_H = numpy.uint32(0x00002000) |
|
20 | 27 | DATAARRANGE_CONTIGUOUS_P = numpy.uint32(0x00004000) |
|
21 | 28 | |
|
22 | 29 | SAVE_CHANNELS_DC = numpy.uint32(0x00008000) |
|
23 | 30 | DEFLIP_DATA = numpy.uint32(0x00010000) |
|
24 | 31 | DEFINE_PROCESS_CODE = numpy.uint32(0x00020000) |
|
25 | 32 | |
|
26 | 33 | ACQ_SYS_NATALIA = numpy.uint32(0x00040000) |
|
27 | 34 | ACQ_SYS_ECHOTEK = numpy.uint32(0x00080000) |
|
28 | 35 | ACQ_SYS_ADRXD = numpy.uint32(0x000C0000) |
|
29 | 36 | ACQ_SYS_JULIA = numpy.uint32(0x00100000) |
|
30 | 37 | ACQ_SYS_XXXXXX = numpy.uint32(0x00140000) |
|
31 | 38 | |
|
32 | 39 | EXP_NAME_ESP = numpy.uint32(0x00200000) |
|
33 | 40 | CHANNEL_NAMES_ESP = numpy.uint32(0x00400000) |
|
34 | 41 | |
|
35 | 42 | OPERATION_MASK = numpy.uint32(0x0000003F) |
|
36 | 43 | DATATYPE_MASK = numpy.uint32(0x00000FC0) |
|
37 | 44 | DATAARRANGE_MASK = numpy.uint32(0x00007000) |
|
38 | 45 | ACQ_SYS_MASK = numpy.uint32(0x001C0000) |
|
39 | 46 | |
|
40 | 47 | class BasicHeader: |
|
41 | 48 | |
|
42 | 49 | size = 0 |
|
43 | 50 | version = 0 |
|
44 | 51 | dataBlock = 0 |
|
45 | 52 | utc = 0 |
|
46 | 53 | miliSecond = 0 |
|
47 | 54 | timeZone = 0 |
|
48 | 55 | dstFlag = 0 |
|
49 | 56 | errorCount = 0 |
|
50 | 57 | struct = numpy.dtype([ |
|
51 | 58 | ('nSize','<u4'), |
|
52 | 59 | ('nVersion','<u2'), |
|
53 | 60 | ('nDataBlockId','<u4'), |
|
54 | 61 | ('nUtime','<u4'), |
|
55 | 62 | ('nMilsec','<u2'), |
|
56 | 63 | ('nTimezone','<i2'), |
|
57 | 64 | ('nDstflag','<i2'), |
|
58 | 65 | ('nErrorCount','<u4') |
|
59 | 66 | ]) |
|
60 | 67 | |
|
61 | 68 | def __init__(self): |
|
62 | 69 | pass |
|
63 | 70 | |
|
64 | 71 | def read(self, fp): |
|
65 | 72 | |
|
66 | 73 | header = numpy.fromfile(fp, self.struct,1) |
|
67 | 74 | self.size = header['nSize'][0] |
|
68 | 75 | self.version = header['nVersion'][0] |
|
69 | 76 | self.dataBlock = header['nDataBlockId'][0] |
|
70 | 77 | self.utc = header['nUtime'][0] |
|
71 | 78 | self.miliSecond = header['nMilsec'][0] |
|
72 | 79 | self.timeZone = header['nTimezone'][0] |
|
73 | 80 | self.dstFlag = header['nDstflag'][0] |
|
74 | 81 | self.errorCount = header['nErrorCount'][0] |
|
75 | 82 | |
|
76 | 83 | return 1 |
|
77 | 84 | |
|
78 | 85 | def copy(self): |
|
79 | 86 | |
|
80 | 87 | obj = BasicHeader() |
|
81 | 88 | obj.size = self.size |
|
82 | 89 | obj.version = self.version |
|
83 | 90 | obj.dataBlock = self.dataBlock |
|
84 | 91 | obj.utc = self.utc |
|
85 | 92 | obj.miliSecond = self.miliSecond |
|
86 | 93 | obj.timeZone = self.timeZone |
|
87 | 94 | obj.dstFlag = self.dstFlag |
|
88 | 95 | obj.errorCount = self.errorCount |
|
89 | 96 | |
|
90 | 97 | return obj |
|
91 | 98 | |
|
92 | 99 | class SystemHeader: |
|
93 | 100 | size = 0 |
|
94 | 101 | numSamples = 0 |
|
95 | 102 | numProfiles = 0 |
|
96 | 103 | numChannels = 0 |
|
97 | 104 | adcResolution = 0 |
|
98 | 105 | pciDioBusWidth = 0 |
|
99 | 106 | struct = numpy.dtype([ |
|
100 | 107 | ('nSize','<u4'), |
|
101 | 108 | ('nNumSamples','<u4'), |
|
102 | 109 | ('nNumProfiles','<u4'), |
|
103 | 110 | ('nNumChannels','<u4'), |
|
104 | 111 | ('nADCResolution','<u4'), |
|
105 | 112 | ('nPCDIOBusWidth','<u4'), |
|
106 | 113 | ]) |
|
107 | 114 | |
|
108 | 115 | def __init__(self): |
|
109 | 116 | pass |
|
110 | 117 | |
|
111 | 118 | def read(self, fp): |
|
112 | 119 | header = numpy.fromfile(fp,self.struct,1) |
|
113 | 120 | self.size = header['nSize'][0] |
|
114 | 121 | self.numSamples = header['nNumSamples'][0] |
|
115 | 122 | self.numProfiles = header['nNumProfiles'][0] |
|
116 | 123 | self.numChannels = header['nNumChannels'][0] |
|
117 | 124 | self.adcResolution = header['nADCResolution'][0] |
|
118 | 125 | self.pciDioBusWidth = header['nPCDIOBusWidth'][0] |
|
119 | 126 | |
|
120 | 127 | |
|
121 | 128 | return 1 |
|
122 | 129 | |
|
123 | 130 | def copy(self): |
|
124 | 131 | |
|
125 | 132 | obj = SystemHeader() |
|
126 | 133 | obj.size = self.size |
|
127 | 134 | obj.numSamples = self.numSamples |
|
128 | 135 | obj.numProfiles = self.numProfiles |
|
129 | 136 | obj.numChannels = self.numChannels |
|
130 | 137 | obj.adcResolution = self.adcResolution |
|
131 | 138 | self.pciDioBusWidth = self.pciDioBusWidth |
|
132 | 139 | |
|
133 | 140 | |
|
134 | 141 | return obj |
|
135 | 142 | |
|
136 | 143 | class RadarControllerHeader: |
|
137 | 144 | size = 0 |
|
138 | 145 | expType = 0 |
|
139 | 146 | nTx = 0 |
|
140 | 147 | ipp = 0 |
|
141 | 148 | txA = 0 |
|
142 | 149 | txB = 0 |
|
143 | 150 | numWindows = 0 |
|
144 | 151 | numTaus = 0 |
|
145 | 152 | codeType = 0 |
|
146 | 153 | line6Function = 0 |
|
147 | 154 | line5Fuction = 0 |
|
148 | 155 | fClock = 0 |
|
149 | 156 | prePulseBefore = 0 |
|
150 | 157 | prePulserAfter = 0 |
|
151 | 158 | rangeIpp = 0 |
|
152 | 159 | rangeTxA = 0 |
|
153 | 160 | rangeTxB = 0 |
|
154 | 161 | struct = numpy.dtype([ |
|
155 | 162 | ('nSize','<u4'), |
|
156 | 163 | ('nExpType','<u4'), |
|
157 | 164 | ('nNTx','<u4'), |
|
158 | 165 | ('fIpp','<f4'), |
|
159 | 166 | ('fTxA','<f4'), |
|
160 | 167 | ('fTxB','<f4'), |
|
161 | 168 | ('nNumWindows','<u4'), |
|
162 | 169 | ('nNumTaus','<u4'), |
|
163 | 170 | ('nCodeType','<u4'), |
|
164 | 171 | ('nLine6Function','<u4'), |
|
165 | 172 | ('nLine5Function','<u4'), |
|
166 | 173 | ('fClock','<f4'), |
|
167 | 174 | ('nPrePulseBefore','<u4'), |
|
168 | 175 | ('nPrePulseAfter','<u4'), |
|
169 | 176 | ('sRangeIPP','<a20'), |
|
170 | 177 | ('sRangeTxA','<a20'), |
|
171 | 178 | ('sRangeTxB','<a20'), |
|
172 | 179 | ]) |
|
173 | 180 | |
|
174 | 181 | |
|
175 | 182 | def __init__(self): |
|
176 | 183 | pass |
|
177 | 184 | |
|
178 | 185 | def read(self, fp): |
|
179 | 186 | header = numpy.fromfile(fp,self.struct,1) |
|
180 | 187 | self.size = header['nSize'][0] |
|
181 | 188 | self.expType = header['nExpType'][0] |
|
182 | 189 | self.nTx = header['nNTx'][0] |
|
183 | 190 | self.ipp = header['fIpp'][0] |
|
184 | 191 | self.txA = header['fTxA'][0] |
|
185 | 192 | self.txB = header['fTxB'][0] |
|
186 | 193 | self.numWindows = header['nNumWindows'][0] |
|
187 | 194 | self.numTaus = header['nNumTaus'][0] |
|
188 | 195 | self.codeType = header['nCodeType'][0] |
|
189 | 196 | self.line6Function = header['nLine6Function'][0] |
|
190 | 197 | self.line5Fuction = header['nLine5Function'][0] |
|
191 | 198 | self.fClock = header['fClock'][0] |
|
192 | 199 | self.prePulseBefore = header['nPrePulseBefore'][0] |
|
193 | 200 | self.prePulserAfter = header['nPrePulseAfter'][0] |
|
194 | 201 | self.rangeIpp = header['sRangeIPP'][0] |
|
195 | 202 | self.rangeTxA = header['sRangeTxA'][0] |
|
196 | 203 | self.rangeTxB = header['sRangeTxB'][0] |
|
197 | 204 | # jump Dynamic Radar Controller Header |
|
198 | 205 | jumpHeader = self.size - 116 |
|
199 | 206 | fp.seek(fp.tell() + jumpHeader) |
|
200 | 207 | |
|
201 | 208 | return 1 |
|
202 | 209 | |
|
203 | 210 | def copy(self): |
|
204 | 211 | |
|
205 | 212 | obj = RadarControllerHeader() |
|
206 | 213 | obj.size = self.size |
|
207 | 214 | obj.expType = self.expType |
|
208 | 215 | obj.nTx = self.nTx |
|
209 | 216 | obj.ipp = self.ipp |
|
210 | 217 | obj.txA = self.txA |
|
211 | 218 | obj.txB = self.txB |
|
212 | 219 | obj.numWindows = self.numWindows |
|
213 | 220 | obj.numTaus = self.numTaus |
|
214 | 221 | obj.codeType = self.codeType |
|
215 | 222 | obj.line6Function = self.line6Function |
|
216 | 223 | obj.line5Fuction = self.line5Fuction |
|
217 | 224 | obj.fClock = self.fClock |
|
218 | 225 | obj.prePulseBefore = self.prePulseBefore |
|
219 | 226 | obj.prePulserAfter = self.prePulserAfter |
|
220 | 227 | obj.rangeIpp = self.rangeIpp |
|
221 | 228 | obj.rangeTxA = self.rangeTxA |
|
222 | 229 | obj.rangeTxB = self.rangeTxB |
|
223 | 230 | |
|
224 | 231 | return obj |
|
225 | 232 | |
|
226 | 233 | class ProcessingHeader: |
|
227 | 234 | size = 0 |
|
228 | 235 | dataType = 0 |
|
229 | 236 | blockSize = 0 |
|
230 | 237 | profilesPerBlock = 0 |
|
231 | 238 | dataBlocksPerFile = 0 |
|
232 | 239 | numWindows = 0 |
|
233 | 240 | processFlags = 0 |
|
234 | 241 | coherentInt = 0 |
|
235 | 242 | incoherentInt = 0 |
|
236 | 243 | totalSpectra = 0 |
|
237 | 244 | struct = numpy.dtype([ |
|
238 | 245 | ('nSize','<u4'), |
|
239 | 246 | ('nDataType','<u4'), |
|
240 | 247 | ('nSizeOfDataBlock','<u4'), |
|
241 | 248 | ('nProfilesperBlock','<u4'), |
|
242 | 249 | ('nDataBlocksperFile','<u4'), |
|
243 | 250 | ('nNumWindows','<u4'), |
|
244 | 251 | ('nProcessFlags','<u4'), |
|
245 | 252 | ('nCoherentIntegrations','<u4'), |
|
246 | 253 | ('nIncoherentIntegrations','<u4'), |
|
247 | 254 | ('nTotalSpectra','<u4') |
|
248 | 255 | ]) |
|
249 | 256 | samplingWindow = 0 |
|
250 | 257 | structSamplingWindow = numpy.dtype([('h0','<f4'),('dh','<f4'),('nsa','<u4')]) |
|
251 | 258 | numHeights = 0 |
|
252 | 259 | firstHeight = 0 |
|
253 | 260 | deltaHeight = 0 |
|
254 | 261 | samplesWin = 0 |
|
255 | 262 | spectraComb = 0 |
|
256 | 263 | numCode = 0 |
|
257 | 264 | codes = 0 |
|
258 | 265 | numBaud = 0 |
|
259 | 266 | |
|
260 | 267 | def __init__(self): |
|
261 | 268 | pass |
|
262 | 269 | |
|
263 | 270 | def read(self, fp): |
|
264 | 271 | header = numpy.fromfile(fp,self.struct,1) |
|
265 | 272 | self.size = header['nSize'][0] |
|
266 | 273 | self.dataType = header['nDataType'][0] |
|
267 | 274 | self.blockSize = header['nSizeOfDataBlock'][0] |
|
268 | 275 | self.profilesPerBlock = header['nProfilesperBlock'][0] |
|
269 | 276 | self.dataBlocksPerFile = header['nDataBlocksperFile'][0] |
|
270 | 277 | self.numWindows = header['nNumWindows'][0] |
|
271 | 278 | self.processFlags = header['nProcessFlags'] |
|
272 | 279 | self.coherentInt = header['nCoherentIntegrations'][0] |
|
273 | 280 | self.incoherentInt = header['nIncoherentIntegrations'][0] |
|
274 | 281 | self.totalSpectra = header['nTotalSpectra'][0] |
|
275 | 282 | self.samplingWindow = numpy.fromfile(fp,self.structSamplingWindow,self.numWindows) |
|
276 | 283 | self.numHeights = numpy.sum(self.samplingWindow['nsa']) |
|
277 | 284 | self.firstHeight = self.samplingWindow['h0'] |
|
278 | 285 | self.deltaHeight = self.samplingWindow['dh'] |
|
279 | 286 | self.samplesWin = self.samplingWindow['nsa'] |
|
280 | 287 | self.spectraComb = numpy.fromfile(fp,'u1',2*self.totalSpectra) |
|
281 | 288 | if self.processFlags & PROCFLAG.DEFINE_PROCESS_CODE == PROCFLAG.DEFINE_PROCESS_CODE: |
|
282 | 289 | self.numCode = numpy.fromfile(fp,'<u4',1) |
|
283 | 290 | self.numBaud = numpy.fromfile(fp,'<u4',1) |
|
284 | 291 | self.codes = numpy.fromfile(fp,'<f4',self.numCode*self.numBaud).reshape(self.numBaud,self.numCode) |
|
285 | 292 | |
|
286 | 293 | |
|
287 | 294 | return 1 |
|
288 | 295 | |
|
289 | 296 | def copy(self): |
|
290 | 297 | |
|
291 | 298 | obj = ProcessingHeader() |
|
292 | 299 | obj.size = self.size |
|
293 | 300 | obj.dataType = self.dataType |
|
294 | 301 | obj.blockSize = self.blockSize |
|
295 | 302 | obj.profilesPerBlock = self.profilesPerBlock |
|
296 | 303 | obj.dataBlocksPerFile = self.dataBlocksPerFile |
|
297 | 304 | obj.numWindows = self.numWindows |
|
298 | 305 | obj.processFlags = self.processFlags |
|
299 | 306 | obj.coherentInt = self.coherentInt |
|
300 | 307 | obj.incoherentInt = self.incoherentInt |
|
301 | 308 | obj.totalSpectra = self.totalSpectra |
|
302 | 309 | obj.samplingWindow = self.samplingWindow |
|
303 | 310 | obj.numHeights = self.numHeights |
|
304 | 311 | obj.firstHeight = self.firstHeight |
|
305 | 312 | obj.deltaHeight = self.deltaHeight |
|
306 | 313 | obj.samplesWin = self.samplesWin |
|
307 | 314 | obj.spectraComb = self.spectraComb |
|
308 | 315 | obj.numCode = self.numCode |
|
309 | 316 | obj.numBaud = self.numBaud |
|
310 | 317 | obj.codes = self.codes |
|
311 | 318 | |
|
312 | 319 | return obj No newline at end of file |
@@ -1,19 +1,20 | |||
|
1 | 1 | ''' |
|
2 | 2 | Created on 23/01/2012 |
|
3 | 3 | |
|
4 | @author: danielangelsuarezmunoz | |
|
4 | @author $Author$ | |
|
5 | @version $Id$ | |
|
5 | 6 | ''' |
|
6 | 7 | |
|
7 | 8 | from Header import * |
|
8 | 9 | from Data import DataReader |
|
9 | 10 | from Data import DataWriter |
|
10 | 11 | |
|
11 | 12 | |
|
12 | 13 | class SpectraReader(DataReader): |
|
13 | 14 | def __init__(self): |
|
14 | 15 | pass |
|
15 | 16 | |
|
16 | 17 | class SpectraWriter(DataWriter): |
|
17 | 18 | def __init__(self): |
|
18 | 19 | pass |
|
19 | 20 |
@@ -1,49 +1,50 | |||
|
1 | 1 | ''' |
|
2 | 2 | Created on 23/01/2012 |
|
3 | 3 | |
|
4 | @author: danielangelsuarezmunoz | |
|
4 | @author $Author$ | |
|
5 | @version $Id$ | |
|
5 | 6 | ''' |
|
6 | 7 | import os |
|
7 | 8 | import sys |
|
8 | 9 | import datetime |
|
9 | 10 | import time |
|
10 | 11 | |
|
11 | 12 | class TestIO(): |
|
12 | 13 | |
|
13 | 14 | def __init__(self): |
|
14 | 15 | self.setValues() |
|
15 | 16 | self.createVoltageObjects() |
|
16 | 17 | self.testReadVoltage() |
|
17 | 18 | pass |
|
18 | 19 | |
|
19 | 20 | def setValues(self): |
|
20 | 21 | |
|
21 | 22 | |
|
22 | 23 | self.path = '/Users/danielangelsuarezmunoz/Documents/Projects' |
|
23 | 24 | self.startDateTime = datetime.datetime(2007,5,1,17,49,0) |
|
24 | 25 | self.endDateTime = datetime.datetime(2007,5,1,18,10,0) |
|
25 | 26 | |
|
26 | 27 | def createVoltageObjects(self): |
|
27 | 28 | path = os.path.split(os.getcwd())[0] |
|
28 | 29 | sys.path.append(path) |
|
29 | 30 | |
|
30 | 31 | from IO.Voltage import VoltageReader |
|
31 | 32 | from Model.Voltage import Voltage |
|
32 | 33 | |
|
33 | 34 | self.voltageModelObj = Voltage() |
|
34 | 35 | self.voltageReaderObj = VoltageReader(self.voltageModelObj) |
|
35 | 36 | self.voltageReaderObj.setup(self.path, self.startDateTime, self.endDateTime) |
|
36 | 37 | |
|
37 | 38 | def testReadVoltage(self): |
|
38 | 39 | while(not(self.voltageReaderObj.noMoreFiles)): |
|
39 | 40 | |
|
40 | 41 | self.voltageReaderObj.getData() |
|
41 | 42 | if self.voltageReaderObj.flagResetProcessing: |
|
42 | 43 | print 'jump' |
|
43 | 44 | |
|
44 | 45 | if self.voltageReaderObj.flagIsNewBlock: |
|
45 | 46 | print 'Block No %04d, Time: %s'%(self.voltageReaderObj.nReadBlocks, |
|
46 | 47 | datetime.datetime.fromtimestamp(self.voltageReaderObj.m_BasicHeader.utc)) |
|
47 | 48 | |
|
48 | 49 | if __name__ == '__main__': |
|
49 | 50 | TestIO() No newline at end of file |
@@ -1,459 +1,459 | |||
|
1 | 1 | ''' |
|
2 | 2 | Created on 23/01/2012 |
|
3 | 3 | |
|
4 | @author: danielangelsuarezmunoz | |
|
4 | @author $Author$ | |
|
5 | @version $Id$ | |
|
5 | 6 | ''' |
|
6 | 7 | |
|
7 | ||
|
8 | 8 | import os, sys |
|
9 | 9 | import numpy |
|
10 | 10 | import glob |
|
11 | 11 | import fnmatch |
|
12 | 12 | import time |
|
13 | 13 | import datetime |
|
14 | 14 | |
|
15 | 15 | from IO.Header import * |
|
16 | 16 | from IO.Data import DataReader |
|
17 | 17 | from IO.Data import DataWriter |
|
18 | 18 | |
|
19 | 19 | path = os.path.split(os.getcwd())[0] |
|
20 | 20 | sys.path.append(path) |
|
21 | 21 | |
|
22 | 22 | from Model.Voltage import Voltage |
|
23 | 23 | |
|
24 | 24 | class VoltageReader(DataReader): |
|
25 | 25 | |
|
26 | 26 | __idFile = None |
|
27 | 27 | |
|
28 | 28 | __fp = None |
|
29 | 29 | |
|
30 | 30 | __startDateTime = None |
|
31 | 31 | |
|
32 | 32 | __endDateTime = None |
|
33 | 33 | |
|
34 | 34 | __dataType = None |
|
35 | 35 | |
|
36 | 36 | __fileSizeByHeader = 0 |
|
37 | 37 | |
|
38 | 38 | __pathList = [] |
|
39 | 39 | |
|
40 | 40 | filenameList = [] |
|
41 | 41 | |
|
42 | 42 | __lastUTTime = 0 |
|
43 | 43 | |
|
44 | 44 | __maxTimeStep = 5 |
|
45 | 45 | |
|
46 | 46 | __flagIsNewFile = 0 |
|
47 | 47 | |
|
48 | 48 | __ippSeconds = 0 |
|
49 | 49 | |
|
50 | 50 | flagResetProcessing = 0 |
|
51 | 51 | |
|
52 | 52 | flagIsNewBlock = 0 |
|
53 | 53 | |
|
54 | 54 | noMoreFiles = 0 |
|
55 | 55 | |
|
56 | 56 | nReadBlocks = 0 |
|
57 | 57 | |
|
58 | 58 | online = 0 |
|
59 | 59 | |
|
60 | 60 | filename = None |
|
61 | 61 | |
|
62 | 62 | fileSize = None |
|
63 | 63 | |
|
64 | 64 | firstHeaderSize = 0 |
|
65 | 65 | |
|
66 | 66 | basicHeaderSize = 24 |
|
67 | 67 | |
|
68 | 68 | m_BasicHeader = BasicHeader() |
|
69 | 69 | |
|
70 | 70 | m_SystemHeader = SystemHeader() |
|
71 | 71 | |
|
72 | 72 | m_RadarControllerHeader = RadarControllerHeader() |
|
73 | 73 | |
|
74 | 74 | m_ProcessingHeader = ProcessingHeader() |
|
75 | 75 | |
|
76 | 76 | m_Voltage = None |
|
77 | 77 | |
|
78 | 78 | __buffer = 0 |
|
79 | 79 | |
|
80 | 80 | __buffer_id = 9999 |
|
81 | 81 | |
|
82 | 82 | def __init__(self, m_Voltage = None): |
|
83 | 83 | |
|
84 | 84 | if m_Voltage == None: |
|
85 | 85 | m_Voltage = Voltage() |
|
86 | 86 | |
|
87 | 87 | self.m_Voltage = m_Voltage |
|
88 | 88 | |
|
89 | 89 | def __rdSystemHeader(self,fp=None): |
|
90 | 90 | if fp == None: |
|
91 | 91 | fp = self.__fp |
|
92 | 92 | |
|
93 | 93 | self.m_SystemHeader.read(fp) |
|
94 | 94 | |
|
95 | 95 | def __rdRadarControllerHeader(self,fp=None): |
|
96 | 96 | if fp == None: |
|
97 | 97 | fp = self.__fp |
|
98 | 98 | |
|
99 | 99 | self.m_RadarControllerHeader.read(fp) |
|
100 | 100 | |
|
101 | 101 | def __rdProcessingHeader(self,fp=None): |
|
102 | 102 | if fp == None: |
|
103 | 103 | fp = self.__fp |
|
104 | 104 | |
|
105 | 105 | self.m_ProcessingHeader.read(fp) |
|
106 | 106 | |
|
107 | 107 | def __searchFiles(self,path, startDateTime, endDateTime, set=None, expLabel = "", ext = ".r"): |
|
108 | 108 | |
|
109 | 109 | print "Searching files ..." |
|
110 | 110 | |
|
111 | 111 | startUtSeconds = time.mktime(startDateTime.timetuple()) |
|
112 | 112 | endUtSeconds = time.mktime(endDateTime.timetuple()) |
|
113 | 113 | |
|
114 | 114 | # startYear = startDateTime.timetuple().tm_year |
|
115 | 115 | # endYear = endDateTime.timetuple().tm_year |
|
116 | 116 | # |
|
117 | 117 | # startDoy = startDateTime.timetuple().tm_yday |
|
118 | 118 | # endDoy = endDateTime.timetuple().tm_yday |
|
119 | 119 | # |
|
120 | 120 | # yearRange = range(startYear,endYear+1) |
|
121 | 121 | # |
|
122 | 122 | # doyDoubleList = [] |
|
123 | 123 | # if startYear == endYear: |
|
124 | 124 | # doyList = range(startDoy,endDoy+1) |
|
125 | 125 | # else: |
|
126 | 126 | # for year in yearRange: |
|
127 | 127 | # if (year == startYear): |
|
128 | 128 | # doyDoubleList.append(range(startDoy,365+1)) |
|
129 | 129 | # elif (year == endYear): |
|
130 | 130 | # doyDoubleList.append(range(1,endDoy+1)) |
|
131 | 131 | # else: |
|
132 | 132 | # doyDoubleList.append(range(1,365+1)) |
|
133 | 133 | # doyList = [] |
|
134 | 134 | # for list in doyDoubleList: |
|
135 | 135 | # doyList = doyList + list |
|
136 | 136 | # |
|
137 | 137 | # dirList = [] |
|
138 | 138 | # for thisPath in os.listdir(path): |
|
139 | 139 | # if os.path.isdir(os.path.join(path,thisPath)): |
|
140 | 140 | # #dirList.append(os.path.join(path,thisPath)) |
|
141 | 141 | # dirList.append(thisPath) |
|
142 | 142 | # |
|
143 | 143 | # pathList = [] |
|
144 | 144 | # pathDict = {} |
|
145 | 145 | # for year in yearRange: |
|
146 | 146 | # for doy in doyList: |
|
147 | 147 | # match = fnmatch.filter(dirList, 'D' + '%4.4d%3.3d' % (year,doy)) |
|
148 | 148 | # if len(match) == 0: |
|
149 | 149 | # match = fnmatch.filter(dirList, 'd' + '%4.4d%3.3d' % (year,doy)) |
|
150 | 150 | # if len(match) == 0: continue |
|
151 | 151 | # if expLabel == '': |
|
152 | 152 | # pathList.append(os.path.join(path,match[0])) |
|
153 | 153 | # pathDict.setdefault(os.path.join(path,match[0])) |
|
154 | 154 | # pathDict[os.path.join(path,match[0])] = [] |
|
155 | 155 | # else: |
|
156 | 156 | # pathList.append(os.path.join(path,os.path.join(match[0],expLabel))) |
|
157 | 157 | # pathDict.setdefault(os.path.join(path,os.path.join(match[0],expLabel))) |
|
158 | 158 | # pathDict[os.path.join(path,os.path.join(match[0],expLabel))] = [] |
|
159 | 159 | |
|
160 | 160 | |
|
161 | 161 | dirList = [] |
|
162 | 162 | for thisPath in os.listdir(path): |
|
163 | 163 | if os.path.isdir(os.path.join(path,thisPath)): |
|
164 | 164 | dirList.append(thisPath) |
|
165 | 165 | |
|
166 | 166 | pathList = [] |
|
167 | 167 | |
|
168 | 168 | thisDateTime = startDateTime |
|
169 | 169 | |
|
170 | 170 | while(thisDateTime <= endDateTime): |
|
171 | 171 | year = thisDateTime.timetuple().tm_year |
|
172 | 172 | doy = thisDateTime.timetuple().tm_yday |
|
173 | 173 | |
|
174 | 174 | match = fnmatch.filter(dirList, '?' + '%4.4d%3.3d' % (year,doy)) |
|
175 | 175 | if len(match) == 0: |
|
176 | 176 | thisDateTime += datetime.timedelta(1) |
|
177 | 177 | continue |
|
178 | 178 | |
|
179 | 179 | pathList.append(os.path.join(path,match[0],expLabel)) |
|
180 | 180 | thisDateTime += datetime.timedelta(1) |
|
181 | 181 | |
|
182 | 182 | filenameList = [] |
|
183 | 183 | for thisPath in pathList: |
|
184 | 184 | fileList = glob.glob1(thisPath, "*%s" %ext) |
|
185 | 185 | #pathDict[thisPath].append(fileList) |
|
186 | 186 | fileList.sort() |
|
187 | 187 | for file in fileList: |
|
188 | 188 | filename = os.path.join(thisPath,file) |
|
189 | 189 | if self.isThisFileinRange(filename, startUtSeconds, endUtSeconds): |
|
190 | 190 | filenameList.append(filename) |
|
191 | 191 | |
|
192 | 192 | self.filenameList = filenameList |
|
193 | 193 | |
|
194 | 194 | return pathList, filenameList |
|
195 | 195 | |
|
196 | 196 | def isThisFileinRange(self, filename, startUTSeconds=None, endUTSeconds=None): |
|
197 | 197 | |
|
198 | 198 | try: |
|
199 | 199 | fp = open(filename,'rb') |
|
200 | 200 | except: |
|
201 | 201 | raise IOError, "The file %s can't be opened" %(filename) |
|
202 | 202 | |
|
203 | 203 | if startUTSeconds==None: |
|
204 | 204 | startUTSeconds = self.startUTCSeconds |
|
205 | 205 | |
|
206 | 206 | if endUTSeconds==None: |
|
207 | 207 | endUTSeconds = self.endUTCSeconds |
|
208 | 208 | |
|
209 | 209 | m_BasicHeader = BasicHeader() |
|
210 | 210 | |
|
211 | 211 | if not(m_BasicHeader.read(fp)): |
|
212 | 212 | return 0 |
|
213 | 213 | |
|
214 | 214 | fp.close() |
|
215 | 215 | |
|
216 | 216 | if not ((startUTSeconds <= m_BasicHeader.utc) and (endUTSeconds >= m_BasicHeader.utc)): |
|
217 | 217 | return 0 |
|
218 | 218 | |
|
219 | 219 | return 1 |
|
220 | 220 | |
|
221 | 221 | def __readBasicHeader(self, fp=None): |
|
222 | 222 | |
|
223 | 223 | if fp == None: |
|
224 | 224 | fp = self.__fp |
|
225 | 225 | |
|
226 | 226 | self.m_BasicHeader.read(fp) |
|
227 | 227 | |
|
228 | 228 | def __readFirstHeader(self): |
|
229 | 229 | |
|
230 | 230 | self.__readBasicHeader() |
|
231 | 231 | self.__rdSystemHeader() |
|
232 | 232 | self.__rdRadarControllerHeader() |
|
233 | 233 | self.__rdProcessingHeader() |
|
234 | 234 | self.firstHeaderSize = self.m_BasicHeader.size |
|
235 | 235 | |
|
236 | 236 | data_type=int(numpy.log2((self.m_ProcessingHeader.processFlags & PROCFLAG.DATATYPE_MASK))-numpy.log2(PROCFLAG.DATATYPE_CHAR)) |
|
237 | 237 | if data_type == 0: |
|
238 | 238 | tmp=numpy.dtype([('real','<i1'),('imag','<i1')]) |
|
239 | 239 | elif data_type == 1: |
|
240 | 240 | tmp=numpy.dtype([('real','<i2'),('imag','<i2')]) |
|
241 | 241 | elif data_type == 2: |
|
242 | 242 | tmp=numpy.dtype([('real','<i4'),('imag','<i4')]) |
|
243 | 243 | elif data_type == 3: |
|
244 | 244 | tmp=numpy.dtype([('real','<i8'),('imag','<i8')]) |
|
245 | 245 | elif data_type == 4: |
|
246 | 246 | tmp=numpy.dtype([('real','<f4'),('imag','<f4')]) |
|
247 | 247 | elif data_type == 5: |
|
248 | 248 | tmp=numpy.dtype([('real','<f8'),('imag','<f8')]) |
|
249 | 249 | else: |
|
250 | 250 | raise ValueError, 'Data type was not defined' |
|
251 | 251 | |
|
252 | 252 | self.__dataType = tmp |
|
253 | 253 | self.__fileSizeByHeader = self.m_ProcessingHeader.dataBlocksPerFile * self.m_ProcessingHeader.blockSize + self.firstHeaderSize + self.basicHeaderSize*(self.m_ProcessingHeader.dataBlocksPerFile - 1) |
|
254 | 254 | c=3E8 |
|
255 | 255 | self.__ippSeconds = 2*1000*self.m_RadarControllerHeader.ipp/c |
|
256 | 256 | |
|
257 | 257 | def __setNextFileOnline(self): |
|
258 | 258 | return 0 |
|
259 | 259 | |
|
260 | 260 | def __setNextFileOffline(self): |
|
261 | 261 | |
|
262 | 262 | idFile = self.__idFile |
|
263 | 263 | while(True): |
|
264 | 264 | |
|
265 | 265 | idFile += 1 |
|
266 | 266 | |
|
267 | 267 | if not(idFile < len(self.filenameList)): |
|
268 | 268 | self.noMoreFiles = 1 |
|
269 | 269 | return 0 |
|
270 | 270 | |
|
271 | 271 | filename = self.filenameList[idFile] |
|
272 | 272 | fileSize = os.path.getsize(filename) |
|
273 | 273 | fp = open(filename,'rb') |
|
274 | 274 | |
|
275 | 275 | currentSize = fileSize - fp.tell() |
|
276 | 276 | neededSize = self.m_ProcessingHeader.blockSize + self.firstHeaderSize |
|
277 | 277 | |
|
278 | 278 | if (currentSize < neededSize): |
|
279 | 279 | continue |
|
280 | 280 | |
|
281 | 281 | break |
|
282 | 282 | |
|
283 | 283 | self.__flagIsNewFile = 1 |
|
284 | 284 | self.__idFile = idFile |
|
285 | 285 | self.filename = filename |
|
286 | 286 | self.fileSize = fileSize |
|
287 | 287 | self.__fp = fp |
|
288 | 288 | |
|
289 | 289 | print 'Setting the file: %s'%self.filename |
|
290 | 290 | |
|
291 | 291 | return 1 |
|
292 | 292 | |
|
293 | 293 | def __setNextFile(self): |
|
294 | 294 | |
|
295 | 295 | if self.online: |
|
296 | 296 | return self.__setNextFileOnline() |
|
297 | 297 | else: |
|
298 | 298 | return self.__setNextFileOffline() |
|
299 | 299 | |
|
300 | 300 | def __setNewBlock(self): |
|
301 | 301 | |
|
302 | 302 | if self.__fp == None: |
|
303 | 303 | return 0 |
|
304 | 304 | |
|
305 | 305 | if self.__flagIsNewFile: |
|
306 | 306 | return 1 |
|
307 | 307 | |
|
308 | 308 | currentSize = self.fileSize - self.__fp.tell() |
|
309 | 309 | neededSize = self.m_ProcessingHeader.blockSize + self.basicHeaderSize |
|
310 | 310 | |
|
311 | 311 | # Bloque Completo |
|
312 | 312 | if (currentSize >= neededSize): |
|
313 | 313 | self.__readBasicHeader() |
|
314 | 314 | return 1 |
|
315 | 315 | |
|
316 | 316 | if not(self.__setNextFile()): |
|
317 | 317 | return 0 |
|
318 | 318 | |
|
319 | 319 | self.__readFirstHeader() |
|
320 | 320 | |
|
321 | 321 | deltaTime = self.m_BasicHeader.utc - self.__lastUTTime # check this |
|
322 | 322 | |
|
323 | 323 | self.flagResetProcessing = 0 |
|
324 | 324 | if deltaTime > self.__maxTimeStep: |
|
325 | 325 | self.flagResetProcessing = 1 |
|
326 | 326 | self.nReadBlocks = 0 |
|
327 | 327 | |
|
328 | 328 | return 1 |
|
329 | 329 | |
|
330 | 330 | def __readBlock(self): |
|
331 | 331 | """Lee el bloque de datos desde la posicion actual del puntero del archivo y |
|
332 | 332 | actualiza todos los parametros relacionados al bloque de datos (data, time, |
|
333 | 333 | etc). La data leida es almacenada en el buffer y el contador de datos leidos es |
|
334 | 334 | seteado a 0 |
|
335 | 335 | """ |
|
336 | 336 | |
|
337 | 337 | pts2read = self.m_ProcessingHeader.profilesPerBlock*self.m_ProcessingHeader.numHeights*self.m_SystemHeader.numChannels |
|
338 | 338 | |
|
339 | 339 | data = numpy.fromfile(self.__fp,self.__dataType,pts2read) |
|
340 | 340 | |
|
341 | 341 | data = data.reshape((self.m_ProcessingHeader.profilesPerBlock, self.m_ProcessingHeader.numHeights, self.m_SystemHeader.numChannels)) |
|
342 | 342 | |
|
343 | 343 | self.__flagIsNewFile = 0 |
|
344 | 344 | |
|
345 | 345 | self.flagIsNewBlock = 1 |
|
346 | 346 | |
|
347 | 347 | self.nReadBlocks += 1 |
|
348 | 348 | |
|
349 | 349 | self.__buffer = data |
|
350 | 350 | |
|
351 | 351 | self.__buffer_id = 0 |
|
352 | 352 | |
|
353 | 353 | def readNextBlock(self): |
|
354 | 354 | |
|
355 | 355 | if not(self.__setNewBlock()): |
|
356 | 356 | return 0 |
|
357 | 357 | |
|
358 | 358 | self.__readBlock() |
|
359 | 359 | |
|
360 | 360 | self.__lastUTTime = self.m_BasicHeader.utc |
|
361 | 361 | |
|
362 | 362 | return 1 |
|
363 | 363 | |
|
364 | 364 | def __hasNotDataInBuffer(self): |
|
365 | 365 | if self.__buffer_id >= self.m_ProcessingHeader.profilesPerBlock: |
|
366 | 366 | return 1 |
|
367 | 367 | |
|
368 | 368 | return 0 |
|
369 | 369 | |
|
370 | 370 | def getData(self): |
|
371 | 371 | """Obtiene un unidad de datos del buffer de lectura y es copiada a la clase "Voltage" |
|
372 | 372 | con todos los parametros asociados a este. cuando no hay datos en el buffer de |
|
373 | 373 | lectura es necesario hacer una nueva lectura de los bloques de datos usando "readNextBlock" |
|
374 | 374 | """ |
|
375 | 375 | self.flagResetProcessing = 0 |
|
376 | 376 | self.flagIsNewBlock = 0 |
|
377 | 377 | |
|
378 | 378 | if self.__hasNotDataInBuffer(): |
|
379 | 379 | self.readNextBlock() |
|
380 | 380 | |
|
381 | 381 | if self.noMoreFiles == 1: |
|
382 | 382 | print 'Process finished' |
|
383 | 383 | return None |
|
384 | 384 | |
|
385 | 385 | data = self.__buffer[self.__buffer_id,:,:] |
|
386 | 386 | |
|
387 | 387 | time = self.m_BasicHeader.utc + self.__buffer_id*self.__ippSeconds |
|
388 | 388 | |
|
389 | 389 | self.m_Voltage.m_BasicHeader = self.m_BasicHeader.copy() |
|
390 | 390 | self.m_Voltage.m_ProcessingHeader = self.m_ProcessingHeader.copy() |
|
391 | 391 | self.m_Voltage.m_RadarControllerHeader = self.m_RadarControllerHeader.copy() |
|
392 | 392 | self.m_Voltage.m_SystemHeader = self.m_SystemHeader.copy() |
|
393 | 393 | self.m_Voltage.m_BasicHeader.utc = time |
|
394 | 394 | self.m_Voltage.data = data |
|
395 | 395 | |
|
396 | 396 | self.__buffer_id += 1 |
|
397 | 397 | |
|
398 | 398 | #call setData - to Data Object |
|
399 | 399 | |
|
400 | 400 | return data |
|
401 | 401 | |
|
402 | 402 | |
|
403 | 403 | def setup(self, path, startDateTime, endDateTime, set=None, expLabel = "", ext = ".r", online = 0): |
|
404 | 404 | |
|
405 | 405 | if online == 0: |
|
406 | 406 | pathList, filenameList = self.__searchFiles(path, startDateTime, endDateTime, set, expLabel, ext) |
|
407 | 407 | |
|
408 | 408 | if len(filenameList) == 0: |
|
409 | 409 | self.__fp = None |
|
410 | 410 | self.noMoreFiles = 1 |
|
411 | 411 | print 'Do not exist files in range: %s - %s'%(startDateTime.ctime(), endDateTime.ctime()) |
|
412 | 412 | return 0 |
|
413 | 413 | |
|
414 | 414 | # for thisFile in filenameList: |
|
415 | 415 | # print thisFile |
|
416 | 416 | |
|
417 | 417 | self.__idFile = -1 |
|
418 | 418 | |
|
419 | 419 | if not(self.__setNextFile()): |
|
420 | 420 | print "No more files" |
|
421 | 421 | return 0 |
|
422 | 422 | |
|
423 | 423 | self.__readFirstHeader() |
|
424 | 424 | |
|
425 | 425 | self.startUTCSeconds = time.mktime(startDateTime.timetuple()) |
|
426 | 426 | self.endUTCSeconds = time.mktime(endDateTime.timetuple()) |
|
427 | 427 | |
|
428 | 428 | self.startYear = startDateTime.timetuple().tm_year |
|
429 | 429 | self.endYear = endDateTime.timetuple().tm_year |
|
430 | 430 | |
|
431 | 431 | self.startDoy = startDateTime.timetuple().tm_yday |
|
432 | 432 | self.endDoy = endDateTime.timetuple().tm_yday |
|
433 | 433 | #call fillHeaderValues() - to Data Object |
|
434 | 434 | |
|
435 | 435 | self.__pathList = pathList |
|
436 | 436 | self.filenameList = filenameList |
|
437 | 437 | self.online = online |
|
438 | 438 | |
|
439 | 439 | class VoltageWriter(DataWriter): |
|
440 | 440 | |
|
441 | 441 | m_BasicHeader= BasicHeader() |
|
442 | 442 | |
|
443 | 443 | |
|
444 | 444 | m_SystemHeader = SystemHeader() |
|
445 | 445 | |
|
446 | 446 | |
|
447 | 447 | m_RadarControllerHeader = RadarControllerHeader() |
|
448 | 448 | |
|
449 | 449 | |
|
450 | 450 | m_ProcessingHeader = ProcessingHeader() |
|
451 | 451 | |
|
452 | 452 | m_Voltage = None |
|
453 | 453 | |
|
454 | 454 | def __init__(self, m_Voltage): |
|
455 | 455 | |
|
456 | 456 | self.m_Voltage = m_Voltage |
|
457 | 457 | |
|
458 | 458 | |
|
459 | 459 | No newline at end of file |
@@ -1,20 +1,21 | |||
|
1 | 1 | ''' |
|
2 | 2 | Created on Feb 7, 2012 |
|
3 | 3 | |
|
4 | @author: roj-idl71 | |
|
4 | @author $Author$ | |
|
5 | @version $Id$ | |
|
5 | 6 | ''' |
|
6 | 7 | |
|
7 | 8 | class Correlation(Data): |
|
8 | 9 | ''' |
|
9 | 10 | classdocs |
|
10 | 11 | ''' |
|
11 | 12 | |
|
12 | 13 | |
|
13 | 14 | def __init__(self): |
|
14 | 15 | ''' |
|
15 | 16 | Constructor |
|
16 | 17 | ''' |
|
17 | 18 | pass |
|
18 | 19 | |
|
19 | 20 | def copy(self): |
|
20 | 21 | pass No newline at end of file |
@@ -1,21 +1,22 | |||
|
1 | 1 | ''' |
|
2 | 2 | Created on Feb 7, 2012 |
|
3 | 3 | |
|
4 | @author: roj-idl71 | |
|
4 | @author $Author$ | |
|
5 | @version $Id$ | |
|
5 | 6 | ''' |
|
6 | 7 | |
|
7 | 8 | class Data: |
|
8 | 9 | ''' |
|
9 | 10 | classdocs |
|
10 | 11 | ''' |
|
11 | 12 | |
|
12 | 13 | |
|
13 | 14 | def __init__(self): |
|
14 | 15 | ''' |
|
15 | 16 | Constructor |
|
16 | 17 | ''' |
|
17 | 18 | pass |
|
18 | 19 | |
|
19 | 20 | def copy(self): |
|
20 | 21 | pass |
|
21 | 22 | No newline at end of file |
@@ -1,18 +1,19 | |||
|
1 | 1 | ''' |
|
2 | 2 | Created on Feb 7, 2012 |
|
3 | 3 | |
|
4 | @author: roj-idl71 | |
|
4 | @author $Author$ | |
|
5 | @version $Id$ | |
|
5 | 6 | ''' |
|
6 | 7 | |
|
7 | 8 | class Noise: |
|
8 | 9 | ''' |
|
9 | 10 | classdocs |
|
10 | 11 | ''' |
|
11 | 12 | |
|
12 | 13 | |
|
13 | 14 | def __init__(self): |
|
14 | 15 | ''' |
|
15 | 16 | Constructor |
|
16 | 17 | ''' |
|
17 | 18 | pass |
|
18 | 19 | No newline at end of file |
@@ -1,21 +1,22 | |||
|
1 | 1 | ''' |
|
2 | 2 | Created on Feb 7, 2012 |
|
3 | 3 | |
|
4 | @author: roj-idl71 | |
|
4 | @author $Author$ | |
|
5 | @version $Id$ | |
|
5 | 6 | ''' |
|
6 | 7 | |
|
7 | 8 | class Spectra(Data): |
|
8 | 9 | ''' |
|
9 | 10 | classdocs |
|
10 | 11 | ''' |
|
11 | 12 | |
|
12 | 13 | |
|
13 | 14 | def __init__(self): |
|
14 | 15 | ''' |
|
15 | 16 | Constructor |
|
16 | 17 | ''' |
|
17 | 18 | pass |
|
18 | 19 | |
|
19 | 20 | def copy(self): |
|
20 | 21 | pass |
|
21 | 22 | No newline at end of file |
@@ -1,47 +1,48 | |||
|
1 | 1 | ''' |
|
2 | 2 | Created on Feb 7, 2012 |
|
3 | 3 | |
|
4 | @author: roj-idl71 | |
|
4 | @author $Author$ | |
|
5 | @version $Id$ | |
|
5 | 6 | ''' |
|
6 | 7 | import os, sys |
|
7 | 8 | |
|
8 | 9 | path = os.path.split(os.getcwd())[0] |
|
9 | 10 | sys.path.append(path) |
|
10 | 11 | |
|
11 | 12 | from Model.Data import Data |
|
12 | 13 | from IO.Header import * |
|
13 | 14 | |
|
14 | 15 | class Voltage(Data): |
|
15 | 16 | ''' |
|
16 | 17 | classdocs |
|
17 | 18 | ''' |
|
18 | 19 | |
|
19 | 20 | |
|
20 | 21 | m_RadarControllerHeader= RadarControllerHeader() |
|
21 | 22 | |
|
22 | 23 | m_ProcessingHeader= ProcessingHeader() |
|
23 | 24 | |
|
24 | 25 | m_SystemHeader= SystemHeader() |
|
25 | 26 | |
|
26 | 27 | m_BasicHeader= BasicHeader() |
|
27 | 28 | |
|
28 | 29 | data = None |
|
29 | 30 | |
|
30 | 31 | noData = True |
|
31 | 32 | |
|
32 | 33 | |
|
33 | 34 | def __init__(self): |
|
34 | 35 | ''' |
|
35 | 36 | Constructor |
|
36 | 37 | ''' |
|
37 | 38 | pass |
|
38 | 39 | |
|
39 | 40 | def copy(self): |
|
40 | 41 | obj = Voltage() |
|
41 | 42 | obj.m_BasicHeader = self.m_BasicHeader.copy() |
|
42 | 43 | obj.m_SystemHeader = self.m_SystemHeader.copy() |
|
43 | 44 | obj.m_RadarControllerHeader = self.m_RadarControllerHeader.copy() |
|
44 | 45 | obj.m_ProcessingHeader = self.m_ProcessingHeader.copy() |
|
45 | 46 | |
|
46 | 47 | return obj |
|
47 | 48 | No newline at end of file |
@@ -0,0 +1,6 | |||
|
1 | ''' | |
|
2 | Created on Feb 7, 2012 | |
|
3 | ||
|
4 | @author $Author$ | |
|
5 | @version $Id$ | |
|
6 | ''' No newline at end of file |
@@ -1,17 +1,18 | |||
|
1 | 1 | ''' |
|
2 | 2 | Created on Feb 7, 2012 |
|
3 | 3 | |
|
4 | @author: roj-idl71 | |
|
4 | @author $Author$ | |
|
5 | @version $Id$ | |
|
5 | 6 | ''' |
|
6 | 7 | |
|
7 | 8 | class CorrelationProcessor: |
|
8 | 9 | ''' |
|
9 | 10 | classdocs |
|
10 | 11 | ''' |
|
11 | 12 | |
|
12 | 13 | |
|
13 | 14 | def __init__(self): |
|
14 | 15 | ''' |
|
15 | 16 | Constructor |
|
16 | 17 | ''' |
|
17 | 18 | pass No newline at end of file |
@@ -1,17 +1,18 | |||
|
1 | 1 | ''' |
|
2 | 2 | Created on Feb 7, 2012 |
|
3 | 3 | |
|
4 | @author: roj-idl71 | |
|
4 | @author $Author$ | |
|
5 | @version $Id$ | |
|
5 | 6 | ''' |
|
6 | 7 | |
|
7 | 8 | class SpectraProcessor: |
|
8 | 9 | ''' |
|
9 | 10 | classdocs |
|
10 | 11 | ''' |
|
11 | 12 | |
|
12 | 13 | |
|
13 | 14 | def __init__(self): |
|
14 | 15 | ''' |
|
15 | 16 | Constructor |
|
16 | 17 | ''' |
|
17 | 18 | pass No newline at end of file |
@@ -1,17 +1,18 | |||
|
1 | 1 | ''' |
|
2 | 2 | Created on Feb 7, 2012 |
|
3 | 3 | |
|
4 | @author: roj-idl71 | |
|
4 | @author $Author$ | |
|
5 | @version $Id$ | |
|
5 | 6 | ''' |
|
6 | 7 | |
|
7 | 8 | class VoltageProcessor: |
|
8 | 9 | ''' |
|
9 | 10 | classdocs |
|
10 | 11 | ''' |
|
11 | 12 | |
|
12 | 13 | |
|
13 | 14 | def __init__(self): |
|
14 | 15 | ''' |
|
15 | 16 | Constructor |
|
16 | 17 | ''' |
|
17 | 18 | pass No newline at end of file |
@@ -0,0 +1,6 | |||
|
1 | ''' | |
|
2 | Created on Feb 7, 2012 | |
|
3 | ||
|
4 | @author $Author$ | |
|
5 | @version $Id$ | |
|
6 | ''' No newline at end of file |
@@ -1,18 +1,19 | |||
|
1 | 1 | ''' |
|
2 | 2 | Created on Feb 7, 2012 |
|
3 | 3 | |
|
4 | @author: roj-idl71 | |
|
4 | @author $Author$ | |
|
5 | @version $Id$ | |
|
5 | 6 | ''' |
|
6 | 7 | |
|
7 | 8 | class FtpServer: |
|
8 | 9 | ''' |
|
9 | 10 | classdocs |
|
10 | 11 | ''' |
|
11 | 12 | |
|
12 | 13 | |
|
13 | 14 | def __init__(self): |
|
14 | 15 | ''' |
|
15 | 16 | Constructor |
|
16 | 17 | ''' |
|
17 | 18 | pass |
|
18 | 19 | No newline at end of file |
@@ -1,19 +1,20 | |||
|
1 | 1 | ''' |
|
2 | 2 | Created on Feb 7, 2012 |
|
3 | 3 | |
|
4 | @author: roj-idl71 | |
|
4 | @author $Author$ | |
|
5 | @version $Id$ | |
|
5 | 6 | ''' |
|
6 | 7 | |
|
7 | 8 | class FtpServerList: |
|
8 | 9 | ''' |
|
9 | 10 | classdocs |
|
10 | 11 | ''' |
|
11 | 12 | |
|
12 | 13 | |
|
13 | 14 | def __init__(self): |
|
14 | 15 | ''' |
|
15 | 16 | Constructor |
|
16 | 17 | ''' |
|
17 | 18 | pass |
|
18 | 19 | m_FtpServer= FtpServer() |
|
19 | 20 |
General Comments 0
You need to be logged in to leave comments.
Login now