@@ -1,497 +1,519 | |||
|
1 | 1 | import os |
|
2 | 2 | import numpy |
|
3 | 3 | import time, datetime |
|
4 | 4 | import mpldriver |
|
5 | 5 | from customftp import * |
|
6 | 6 | |
|
7 | 7 | class Figure: |
|
8 | 8 | |
|
9 | 9 | __driver = mpldriver |
|
10 | 10 | fig = None |
|
11 | 11 | |
|
12 |
id |
|
|
12 | id = None | |
|
13 | 13 | wintitle = None |
|
14 | 14 | width = None |
|
15 | 15 | height = None |
|
16 | 16 | nplots = None |
|
17 | 17 | timerange = None |
|
18 | 18 | |
|
19 | 19 | axesObjList = [] |
|
20 | 20 | |
|
21 | 21 | WIDTH = None |
|
22 | 22 | HEIGHT = None |
|
23 | 23 | PREFIX = 'fig' |
|
24 | 24 | |
|
25 | 25 | def __init__(self): |
|
26 | 26 | |
|
27 | 27 | raise ValueError, "This method is not implemented" |
|
28 | 28 | |
|
29 | 29 | def __del__(self): |
|
30 | 30 | |
|
31 | 31 | self.__driver.closeFigure() |
|
32 | 32 | |
|
33 | 33 | def getFilename(self, name, ext='.png'): |
|
34 | 34 | |
|
35 |
path = '%s%03d' %(self.PREFIX, self.id |
|
|
35 | path = '%s%03d' %(self.PREFIX, self.id) | |
|
36 | 36 | filename = '%s_%s%s' %(self.PREFIX, name, ext) |
|
37 | 37 | |
|
38 | 38 | return os.path.join(path, filename) |
|
39 | 39 | |
|
40 | 40 | def getAxesObjList(self): |
|
41 | 41 | |
|
42 | 42 | return self.axesObjList |
|
43 | 43 | |
|
44 | 44 | def getSubplots(self): |
|
45 | 45 | |
|
46 | 46 | raise ValueError, "Abstract method: This method should be defined" |
|
47 | 47 | |
|
48 | 48 | def getScreenDim(self, widthplot, heightplot): |
|
49 | 49 | |
|
50 | 50 | nrow, ncol = self.getSubplots() |
|
51 | 51 | |
|
52 | 52 | widthscreen = widthplot*ncol |
|
53 | 53 | heightscreen = heightplot*nrow |
|
54 | 54 | |
|
55 | 55 | return widthscreen, heightscreen |
|
56 | 56 | |
|
57 | 57 | def getTimeLim(self, x, xmin, xmax): |
|
58 | 58 | |
|
59 | 59 | thisdatetime = datetime.datetime.utcfromtimestamp(numpy.min(x)) |
|
60 | 60 | thisdate = datetime.datetime.combine(thisdatetime.date(), datetime.time(0,0,0)) |
|
61 | 61 | |
|
62 | 62 | #################################################### |
|
63 | 63 | #If the x is out of xrange |
|
64 | 64 | if xmax < (thisdatetime - thisdate).seconds/(60*60.): |
|
65 | 65 | xmin = None |
|
66 | 66 | xmax = None |
|
67 | 67 | |
|
68 | 68 | if xmin == None: |
|
69 | 69 | td = thisdatetime - thisdate |
|
70 | 70 | xmin = td.seconds/(60*60.) |
|
71 | 71 | |
|
72 | 72 | if xmax == None: |
|
73 | 73 | xmax = xmin + self.timerange/(60*60.) |
|
74 | 74 | |
|
75 | 75 | mindt = thisdate + datetime.timedelta(hours=xmin) - datetime.timedelta(seconds=time.timezone) |
|
76 | 76 | tmin = time.mktime(mindt.timetuple()) |
|
77 | 77 | |
|
78 | 78 | maxdt = thisdate + datetime.timedelta(hours=xmax) - datetime.timedelta(seconds=time.timezone) |
|
79 | 79 | tmax = time.mktime(maxdt.timetuple()) |
|
80 | 80 | |
|
81 | 81 | self.timerange = tmax - tmin |
|
82 | 82 | |
|
83 | 83 | return tmin, tmax |
|
84 | 84 | |
|
85 |
def init(self, id |
|
|
85 | def init(self, id, nplots, wintitle): | |
|
86 | 86 | |
|
87 | 87 | raise ValueError, "This method has been replaced with createFigure" |
|
88 | 88 | |
|
89 |
def createFigure(self, id |
|
|
89 | def createFigure(self, id, wintitle, widthplot=None, heightplot=None, show=True): | |
|
90 | 90 | |
|
91 | 91 | """ |
|
92 | 92 | Crea la figura de acuerdo al driver y parametros seleccionados seleccionados. |
|
93 | 93 | Las dimensiones de la pantalla es calculada a partir de los atributos self.WIDTH |
|
94 | 94 | y self.HEIGHT y el numero de subplots (nrow, ncol) |
|
95 | 95 | |
|
96 | 96 | Input: |
|
97 |
id |
|
|
97 | id : Los parametros necesarios son | |
|
98 | 98 | wintitle : |
|
99 | 99 | |
|
100 | 100 | """ |
|
101 | 101 | |
|
102 | 102 | if widthplot == None: |
|
103 | 103 | widthplot = self.WIDTH |
|
104 | 104 | |
|
105 | 105 | if heightplot == None: |
|
106 | 106 | heightplot = self.HEIGHT |
|
107 | 107 | |
|
108 |
self.id |
|
|
108 | self.id = id | |
|
109 | 109 | |
|
110 | 110 | self.wintitle = wintitle |
|
111 | 111 | |
|
112 | 112 | self.widthscreen, self.heightscreen = self.getScreenDim(widthplot, heightplot) |
|
113 | 113 | |
|
114 |
self.fig = self.__driver.createFigure(id |
|
|
114 | self.fig = self.__driver.createFigure(id=self.id, | |
|
115 | 115 | wintitle=self.wintitle, |
|
116 | 116 | width=self.widthscreen, |
|
117 | 117 | height=self.heightscreen, |
|
118 | 118 | show=show) |
|
119 | 119 | |
|
120 | 120 | self.axesObjList = [] |
|
121 | 121 | |
|
122 | 122 | |
|
123 | 123 | def setDriver(self, driver=mpldriver): |
|
124 | 124 | |
|
125 | 125 | self.__driver = driver |
|
126 | 126 | |
|
127 | 127 | def setTitle(self, title): |
|
128 | 128 | |
|
129 | 129 | self.__driver.setTitle(self.fig, title) |
|
130 | 130 | |
|
131 | 131 | def setWinTitle(self, title): |
|
132 | 132 | |
|
133 | 133 | self.__driver.setWinTitle(self.fig, title=title) |
|
134 | 134 | |
|
135 | 135 | def setTextFromAxes(self, text): |
|
136 | 136 | |
|
137 | 137 | raise ValueError, "Este metodo ha sido reemplazaado con el metodo setText de la clase Axes" |
|
138 | 138 | |
|
139 | 139 | def makeAxes(self, nrow, ncol, xpos, ypos, colspan, rowspan): |
|
140 | 140 | |
|
141 | 141 | raise ValueError, "Este metodo ha sido reemplazaado con el metodo addAxes" |
|
142 | 142 | |
|
143 | 143 | def addAxes(self, *args): |
|
144 | 144 | """ |
|
145 | 145 | |
|
146 | 146 | Input: |
|
147 | 147 | *args : Los parametros necesarios son |
|
148 | 148 | nrow, ncol, xpos, ypos, colspan, rowspan |
|
149 | 149 | """ |
|
150 | 150 | |
|
151 | 151 | axesObj = Axes(self.fig, *args) |
|
152 | 152 | self.axesObjList.append(axesObj) |
|
153 | 153 | |
|
154 | 154 | def saveFigure(self, figpath, figfile, *args): |
|
155 | 155 | |
|
156 | 156 | filename = os.path.join(figpath, figfile) |
|
157 | 157 | |
|
158 | 158 | fullpath = os.path.split(filename)[0] |
|
159 | 159 | |
|
160 | 160 | if not os.path.exists(fullpath): |
|
161 | 161 | subpath = os.path.split(fullpath)[0] |
|
162 | 162 | |
|
163 | 163 | if not os.path.exists(subpath): |
|
164 | 164 | os.mkdir(subpath) |
|
165 | 165 | |
|
166 | 166 | os.mkdir(fullpath) |
|
167 | 167 | |
|
168 | 168 | self.__driver.saveFigure(self.fig, filename, *args) |
|
169 | 169 | |
|
170 | 170 | def sendByFTP(self, figfilename): |
|
171 | 171 | ftpObj = Ftp() |
|
172 | 172 | ftpObj.upload(figfilename) |
|
173 | 173 | ftpObj.close() |
|
174 | 174 | |
|
175 | 175 | def draw(self): |
|
176 | 176 | |
|
177 | 177 | self.__driver.draw(self.fig) |
|
178 | 178 | |
|
179 | 179 | def run(self): |
|
180 | 180 | |
|
181 | 181 | raise ValueError, "This method is not implemented" |
|
182 | 182 | |
|
183 | 183 | axesList = property(getAxesObjList) |
|
184 | 184 | |
|
185 | 185 | |
|
186 | 186 | class Axes: |
|
187 | 187 | |
|
188 | 188 | __driver = mpldriver |
|
189 | 189 | fig = None |
|
190 | 190 | ax = None |
|
191 | 191 | plot = None |
|
192 | 192 | __missing = 1E30 |
|
193 | 193 | __firsttime = None |
|
194 | 194 | |
|
195 | 195 | __showprofile = False |
|
196 | 196 | |
|
197 | 197 | xmin = None |
|
198 | 198 | xmax = None |
|
199 | 199 | ymin = None |
|
200 | 200 | ymax = None |
|
201 | 201 | zmin = None |
|
202 | 202 | zmax = None |
|
203 | 203 | |
|
204 | 204 | x_buffer = None |
|
205 | 205 | z_buffer = None |
|
206 | 206 | |
|
207 | __MAXNUMX = 1000 | |
|
208 | __MAXNUMY = 500 | |
|
209 | ||
|
207 | 210 | def __init__(self, *args): |
|
208 | 211 | |
|
209 | 212 | """ |
|
210 | 213 | |
|
211 | 214 | Input: |
|
212 | 215 | *args : Los parametros necesarios son |
|
213 | 216 | fig, nrow, ncol, xpos, ypos, colspan, rowspan |
|
214 | 217 | """ |
|
215 | 218 | |
|
216 | 219 | ax = self.__driver.createAxes(*args) |
|
217 | 220 | self.fig = args[0] |
|
218 | 221 | self.ax = ax |
|
219 | 222 | self.plot = None |
|
220 | 223 | |
|
221 | 224 | self.__firsttime = True |
|
222 | 225 | self.idlineList = [] |
|
223 | 226 | |
|
224 | 227 | self.x_buffer = numpy.array([]) |
|
225 | 228 | self.z_buffer = numpy.array([]) |
|
226 | 229 | |
|
227 | 230 | def setText(self, text): |
|
228 | 231 | |
|
229 | 232 | self.__driver.setAxesText(self.ax, text) |
|
230 | 233 | |
|
231 | 234 | def setXAxisAsTime(self): |
|
232 | 235 | pass |
|
233 | 236 | |
|
234 | 237 | def pline(self, x, y, |
|
235 | 238 | xmin=None, xmax=None, |
|
236 | 239 | ymin=None, ymax=None, |
|
237 | 240 | xlabel='', ylabel='', |
|
238 | 241 | title='', |
|
239 | 242 | **kwargs): |
|
240 | 243 | |
|
241 | 244 | """ |
|
242 | 245 | |
|
243 | 246 | Input: |
|
244 | 247 | x : |
|
245 | 248 | y : |
|
246 | 249 | xmin : |
|
247 | 250 | xmax : |
|
248 | 251 | ymin : |
|
249 | 252 | ymax : |
|
250 | 253 | xlabel : |
|
251 | 254 | ylabel : |
|
252 | 255 | title : |
|
253 | 256 | **kwargs : Los parametros aceptados son |
|
254 | 257 | |
|
255 | 258 | ticksize |
|
256 | 259 | ytick_visible |
|
257 | 260 | """ |
|
258 | 261 | |
|
259 | 262 | if self.__firsttime: |
|
260 | 263 | |
|
261 | 264 | if xmin == None: xmin = numpy.nanmin(x) |
|
262 | 265 | if xmax == None: xmax = numpy.nanmax(x) |
|
263 | 266 | if ymin == None: ymin = numpy.nanmin(y) |
|
264 | 267 | if ymax == None: ymax = numpy.nanmax(y) |
|
265 | 268 | |
|
266 | 269 | self.plot = self.__driver.createPline(self.ax, x, y, |
|
267 | 270 | xmin, xmax, |
|
268 | 271 | ymin, ymax, |
|
269 | 272 | xlabel=xlabel, |
|
270 | 273 | ylabel=ylabel, |
|
271 | 274 | title=title, |
|
272 | 275 | **kwargs) |
|
273 | 276 | |
|
274 | 277 | self.idlineList.append(0) |
|
275 | 278 | self.__firsttime = False |
|
276 | 279 | return |
|
277 | 280 | |
|
278 | 281 | self.__driver.pline(self.plot, x, y, xlabel=xlabel, |
|
279 | 282 | ylabel=ylabel, |
|
280 | 283 | title=title) |
|
281 | 284 | |
|
282 | 285 | def addpline(self, x, y, idline, **kwargs): |
|
283 | 286 | lines = self.ax.lines |
|
284 | 287 | |
|
285 | 288 | if idline in self.idlineList: |
|
286 | 289 | self.__driver.set_linedata(self.ax, x, y, idline) |
|
287 | 290 | |
|
288 | 291 | if idline not in(self.idlineList): |
|
289 | 292 | self.__driver.addpline(self.ax, x, y, **kwargs) |
|
290 | 293 | self.idlineList.append(idline) |
|
291 | 294 | |
|
292 | 295 | return |
|
293 | 296 | |
|
294 | 297 | def pmultiline(self, x, y, |
|
295 | 298 | xmin=None, xmax=None, |
|
296 | 299 | ymin=None, ymax=None, |
|
297 | 300 | xlabel='', ylabel='', |
|
298 | 301 | title='', |
|
299 | 302 | **kwargs): |
|
300 | 303 | |
|
301 | 304 | if self.__firsttime: |
|
302 | 305 | |
|
303 | 306 | if xmin == None: xmin = numpy.nanmin(x) |
|
304 | 307 | if xmax == None: xmax = numpy.nanmax(x) |
|
305 | 308 | if ymin == None: ymin = numpy.nanmin(y) |
|
306 | 309 | if ymax == None: ymax = numpy.nanmax(y) |
|
307 | 310 | |
|
308 | 311 | self.plot = self.__driver.createPmultiline(self.ax, x, y, |
|
309 | 312 | xmin, xmax, |
|
310 | 313 | ymin, ymax, |
|
311 | 314 | xlabel=xlabel, |
|
312 | 315 | ylabel=ylabel, |
|
313 | 316 | title=title, |
|
314 | 317 | **kwargs) |
|
315 | 318 | self.__firsttime = False |
|
316 | 319 | return |
|
317 | 320 | |
|
318 | 321 | self.__driver.pmultiline(self.plot, x, y, xlabel=xlabel, |
|
319 | 322 | ylabel=ylabel, |
|
320 | 323 | title=title) |
|
321 | 324 | |
|
322 | 325 | def pmultilineyaxis(self, x, y, |
|
323 | 326 | xmin=None, xmax=None, |
|
324 | 327 | ymin=None, ymax=None, |
|
325 | 328 | xlabel='', ylabel='', |
|
326 | 329 | title='', |
|
327 | 330 | **kwargs): |
|
328 | 331 | |
|
329 | 332 | if self.__firsttime: |
|
330 | 333 | |
|
331 | 334 | if xmin == None: xmin = numpy.nanmin(x) |
|
332 | 335 | if xmax == None: xmax = numpy.nanmax(x) |
|
333 | 336 | if ymin == None: ymin = numpy.nanmin(y) |
|
334 | 337 | if ymax == None: ymax = numpy.nanmax(y) |
|
335 | 338 | |
|
336 | 339 | self.plot = self.__driver.createPmultilineYAxis(self.ax, x, y, |
|
337 | 340 | xmin, xmax, |
|
338 | 341 | ymin, ymax, |
|
339 | 342 | xlabel=xlabel, |
|
340 | 343 | ylabel=ylabel, |
|
341 | 344 | title=title, |
|
342 | 345 | **kwargs) |
|
343 | 346 | if self.xmin == None: self.xmin = xmin |
|
344 | 347 | if self.xmax == None: self.xmax = xmax |
|
345 | 348 | if self.ymin == None: self.ymin = ymin |
|
346 | 349 | if self.ymax == None: self.ymax = ymax |
|
347 | 350 | |
|
348 | 351 | self.__firsttime = False |
|
349 | 352 | return |
|
350 | 353 | |
|
351 | 354 | self.__driver.pmultilineyaxis(self.plot, x, y, xlabel=xlabel, |
|
352 | 355 | ylabel=ylabel, |
|
353 | 356 | title=title) |
|
354 | 357 | |
|
355 | 358 | def pcolor(self, x, y, z, |
|
356 | 359 | xmin=None, xmax=None, |
|
357 | 360 | ymin=None, ymax=None, |
|
358 | 361 | zmin=None, zmax=None, |
|
359 | 362 | xlabel='', ylabel='', |
|
360 | 363 | title='', rti = False, colormap='jet', |
|
361 | 364 | **kwargs): |
|
362 | 365 | |
|
363 | 366 | """ |
|
364 | 367 | Input: |
|
365 | 368 | x : |
|
366 | 369 | y : |
|
367 | 370 | x : |
|
368 | 371 | xmin : |
|
369 | 372 | xmax : |
|
370 | 373 | ymin : |
|
371 | 374 | ymax : |
|
372 | 375 | zmin : |
|
373 | 376 | zmax : |
|
374 | 377 | xlabel : |
|
375 | 378 | ylabel : |
|
376 | 379 | title : |
|
377 | 380 | **kwargs : Los parametros aceptados son |
|
378 | 381 | ticksize=9, |
|
379 | 382 | cblabel='' |
|
380 | 383 | rti = True or False |
|
381 | 384 | """ |
|
382 | 385 | |
|
383 | 386 | if self.__firsttime: |
|
384 | 387 | |
|
385 | 388 | if xmin == None: xmin = numpy.nanmin(x) |
|
386 | 389 | if xmax == None: xmax = numpy.nanmax(x) |
|
387 | 390 | if ymin == None: ymin = numpy.nanmin(y) |
|
388 | 391 | if ymax == None: ymax = numpy.nanmax(y) |
|
389 | 392 | if zmin == None: zmin = numpy.nanmin(z) |
|
390 | 393 | if zmax == None: zmax = numpy.nanmax(z) |
|
391 | 394 | |
|
392 | 395 | |
|
393 | 396 | self.plot = self.__driver.createPcolor(self.ax, x, y, z, |
|
394 | 397 | xmin, xmax, |
|
395 | 398 | ymin, ymax, |
|
396 | 399 | zmin, zmax, |
|
397 | 400 | xlabel=xlabel, |
|
398 | 401 | ylabel=ylabel, |
|
399 | 402 | title=title, |
|
400 | 403 | colormap=colormap, |
|
401 | 404 | **kwargs) |
|
402 | 405 | |
|
403 | 406 | if self.xmin == None: self.xmin = xmin |
|
404 | 407 | if self.xmax == None: self.xmax = xmax |
|
405 | 408 | if self.ymin == None: self.ymin = ymin |
|
406 | 409 | if self.ymax == None: self.ymax = ymax |
|
407 | 410 | if self.zmin == None: self.zmin = zmin |
|
408 | 411 | if self.zmax == None: self.zmax = zmax |
|
409 | 412 | |
|
410 | 413 | self.__firsttime = False |
|
411 | 414 | return |
|
412 | 415 | |
|
413 | 416 | if rti: |
|
414 | 417 | self.__driver.addpcolor(self.ax, x, y, z, self.zmin, self.zmax, |
|
415 | 418 | xlabel=xlabel, |
|
416 | 419 | ylabel=ylabel, |
|
417 | 420 | title=title, |
|
418 | 421 | colormap=colormap) |
|
419 | 422 | return |
|
420 | 423 | |
|
421 | 424 | self.__driver.pcolor(self.plot, z, |
|
422 | 425 | xlabel=xlabel, |
|
423 | 426 | ylabel=ylabel, |
|
424 | 427 | title=title) |
|
425 | 428 | |
|
426 | 429 | def pcolorbuffer(self, x, y, z, |
|
427 | 430 | xmin=None, xmax=None, |
|
428 | 431 | ymin=None, ymax=None, |
|
429 | 432 | zmin=None, zmax=None, |
|
430 | 433 | xlabel='', ylabel='', |
|
431 | 434 | title='', rti = False, colormap='jet', |
|
435 | maxNumX = None, maxNumY = None, | |
|
432 | 436 | **kwargs): |
|
433 | 437 | |
|
438 | if maxNumX == None: | |
|
439 | maxNumX = self.__MAXNUMX | |
|
440 | ||
|
441 | if maxNumY == None: | |
|
442 | maxNumY = self.__MAXNUMY | |
|
434 | 443 | |
|
435 | 444 | if self.__firsttime: |
|
436 | 445 | self.z_buffer = z |
|
437 | 446 | self.x_buffer = numpy.hstack((self.x_buffer, x)) |
|
438 | 447 | |
|
439 | 448 | if xmin == None: xmin = numpy.nanmin(x) |
|
440 | 449 | if xmax == None: xmax = numpy.nanmax(x) |
|
441 | 450 | if ymin == None: ymin = numpy.nanmin(y) |
|
442 | 451 | if ymax == None: ymax = numpy.nanmax(y) |
|
443 | 452 | if zmin == None: zmin = numpy.nanmin(z) |
|
444 | 453 | if zmax == None: zmax = numpy.nanmax(z) |
|
445 | 454 | |
|
446 | 455 | |
|
447 | 456 | self.plot = self.__driver.createPcolor(self.ax, self.x_buffer, y, z, |
|
448 | 457 | xmin, xmax, |
|
449 | 458 | ymin, ymax, |
|
450 | 459 | zmin, zmax, |
|
451 | 460 | xlabel=xlabel, |
|
452 | 461 | ylabel=ylabel, |
|
453 | 462 | title=title, |
|
454 | 463 | colormap=colormap, |
|
455 | 464 | **kwargs) |
|
456 | 465 | |
|
457 | 466 | if self.xmin == None: self.xmin = xmin |
|
458 | 467 | if self.xmax == None: self.xmax = xmax |
|
459 | 468 | if self.ymin == None: self.ymin = ymin |
|
460 | 469 | if self.ymax == None: self.ymax = ymax |
|
461 | 470 | if self.zmin == None: self.zmin = zmin |
|
462 | 471 | if self.zmax == None: self.zmax = zmax |
|
463 | 472 | |
|
473 | ||
|
474 | deltax = (xmax - xmin)/maxNumX | |
|
475 | deltay = (ymax - ymin)/maxNumY | |
|
476 | ||
|
477 | resolutionx = x[1]-x[0] | |
|
478 | resolutiony = y[1]-y[0] | |
|
479 | ||
|
480 | self.decimationx = numpy.ceil(deltax / resolutionx) | |
|
481 | self.decimationy = numpy.ceil(deltay / resolutiony) | |
|
482 | ||
|
464 | 483 | self.__firsttime = False |
|
465 | 484 | return |
|
466 | 485 | |
|
467 | 486 | if rti: |
|
468 | 487 | if x[0]>self.x_buffer[-1]: |
|
469 | 488 | gap = z.copy() |
|
470 | 489 | gap[:] = self.__missing |
|
471 | 490 | self.z_buffer = numpy.hstack((self.z_buffer, gap)) |
|
472 | 491 | self.z_buffer = numpy.ma.masked_inside(self.z_buffer,0.99*self.__missing,1.01*self.__missing) |
|
473 | 492 | self.x_buffer = numpy.hstack((self.x_buffer, x)) |
|
474 | 493 | |
|
475 | 494 | else: |
|
476 | 495 | self.x_buffer = numpy.hstack((self.x_buffer, x[-1])) |
|
477 | 496 | |
|
478 | 497 | self.z_buffer = numpy.hstack((self.z_buffer, z)) |
|
479 | 498 | |
|
480 | newydim = len(y) | |
|
481 | ||
|
482 | 499 | # self.z_buffer = numpy.ma.masked_inside(self.z_buffer,0.99*self.__missing,1.01*self.__missing) |
|
500 | ydim = len(y) | |
|
501 | z_buffer = self.z_buffer.reshape(-1,ydim) | |
|
483 | 502 | |
|
484 |
|
|
|
503 | x_buffer = self.x_buffer[::self.decimationx] | |
|
504 | y_buffer = y[::self.decimationy] | |
|
505 | z_buffer = z_buffer[::self.decimationx, ::self.decimationy] | |
|
506 | #=================================================== | |
|
485 | 507 | |
|
486 |
self.__driver.addpcolorbuffer(self.ax, |
|
|
508 | self.__driver.addpcolorbuffer(self.ax, x_buffer, y_buffer, z_buffer, self.zmin, self.zmax, | |
|
487 | 509 | xlabel=xlabel, |
|
488 | 510 | ylabel=ylabel, |
|
489 | 511 | title=title, |
|
490 | 512 | colormap=colormap) |
|
491 | 513 | return |
|
492 | 514 | |
|
493 | 515 | self.__driver.pcolor(self.plot, z, |
|
494 | 516 | xlabel=xlabel, |
|
495 | 517 | ylabel=ylabel, |
|
496 | 518 | title=title) |
|
497 | 519 | No newline at end of file |
@@ -1,382 +1,382 | |||
|
1 | 1 | import numpy |
|
2 | 2 | import datetime |
|
3 | 3 | import sys |
|
4 | 4 | import matplotlib |
|
5 | 5 | |
|
6 | 6 | if 'linux' in sys.platform: |
|
7 | 7 | matplotlib.use("TKAgg") |
|
8 | 8 | |
|
9 | 9 | if 'darwin' in sys.platform: |
|
10 | 10 | matplotlib.use("TKAgg") |
|
11 | 11 | |
|
12 | 12 | import matplotlib.pyplot |
|
13 | 13 | |
|
14 | 14 | from mpl_toolkits.axes_grid1 import make_axes_locatable |
|
15 | 15 | from matplotlib.ticker import * |
|
16 | 16 | |
|
17 | 17 | ########################################### |
|
18 | 18 | #Actualizacion de las funciones del driver |
|
19 | 19 | ########################################### |
|
20 | 20 | |
|
21 |
def createFigure(id |
|
|
21 | def createFigure(id, wintitle, width, height, facecolor="w", show=True): | |
|
22 | 22 | |
|
23 | 23 | matplotlib.pyplot.ioff() |
|
24 |
fig = matplotlib.pyplot.figure(num=id |
|
|
24 | fig = matplotlib.pyplot.figure(num=id, facecolor=facecolor) | |
|
25 | 25 | fig.canvas.manager.set_window_title(wintitle) |
|
26 | 26 | fig.canvas.manager.resize(width, height) |
|
27 | 27 | matplotlib.pyplot.ion() |
|
28 | 28 | if show: |
|
29 | 29 | matplotlib.pyplot.show() |
|
30 | 30 | |
|
31 | 31 | return fig |
|
32 | 32 | |
|
33 | 33 | def closeFigure(show=True): |
|
34 | 34 | |
|
35 | 35 | matplotlib.pyplot.ioff() |
|
36 | 36 | if show: |
|
37 | 37 | matplotlib.pyplot.show() |
|
38 | 38 | |
|
39 | 39 | return |
|
40 | 40 | |
|
41 | 41 | def saveFigure(fig, filename): |
|
42 | 42 | |
|
43 | 43 | matplotlib.pyplot.ioff() |
|
44 | 44 | fig.savefig(filename) |
|
45 | 45 | matplotlib.pyplot.ion() |
|
46 | 46 | |
|
47 | 47 | def setWinTitle(fig, title): |
|
48 | 48 | |
|
49 | 49 | fig.canvas.manager.set_window_title(title) |
|
50 | 50 | |
|
51 | 51 | def setTitle(fig, title): |
|
52 | 52 | |
|
53 | 53 | fig.suptitle(title) |
|
54 | 54 | |
|
55 | 55 | def createAxes(fig, nrow, ncol, xpos, ypos, colspan, rowspan): |
|
56 | 56 | |
|
57 | 57 | matplotlib.pyplot.ioff() |
|
58 | 58 | matplotlib.pyplot.figure(fig.number) |
|
59 | 59 | axes = matplotlib.pyplot.subplot2grid((nrow, ncol), |
|
60 | 60 | (xpos, ypos), |
|
61 | 61 | colspan=colspan, |
|
62 | 62 | rowspan=rowspan) |
|
63 | 63 | |
|
64 | 64 | matplotlib.pyplot.ion() |
|
65 | 65 | return axes |
|
66 | 66 | |
|
67 | 67 | def setAxesText(ax, text): |
|
68 | 68 | |
|
69 | 69 | ax.annotate(text, |
|
70 | 70 | xy = (.1, .99), |
|
71 | 71 | xycoords = 'figure fraction', |
|
72 | 72 | horizontalalignment = 'left', |
|
73 | 73 | verticalalignment = 'top', |
|
74 | 74 | fontsize = 10) |
|
75 | 75 | |
|
76 | 76 | def printLabels(ax, xlabel, ylabel, title): |
|
77 | 77 | |
|
78 | 78 | ax.set_xlabel(xlabel, size=11) |
|
79 | 79 | ax.set_ylabel(ylabel, size=11) |
|
80 | 80 | ax.set_title(title, size=12) |
|
81 | 81 | |
|
82 | 82 | def createPline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='', |
|
83 | 83 | ticksize=9, xtick_visible=True, ytick_visible=True, |
|
84 | 84 | nxticks=4, nyticks=10, |
|
85 | 85 | grid=None): |
|
86 | 86 | |
|
87 | 87 | """ |
|
88 | 88 | |
|
89 | 89 | Input: |
|
90 | 90 | grid : None, 'both', 'x', 'y' |
|
91 | 91 | """ |
|
92 | 92 | |
|
93 | 93 | matplotlib.pyplot.ioff() |
|
94 | 94 | |
|
95 | 95 | ax.set_xlim([xmin,xmax]) |
|
96 | 96 | ax.set_ylim([ymin,ymax]) |
|
97 | 97 | |
|
98 | 98 | printLabels(ax, xlabel, ylabel, title) |
|
99 | 99 | |
|
100 | 100 | ###################################################### |
|
101 | 101 | if (xmax-xmin)<=1: |
|
102 | 102 | xtickspos = numpy.linspace(xmin,xmax,nxticks) |
|
103 | 103 | xtickspos = numpy.array([float("%.1f"%i) for i in xtickspos]) |
|
104 | 104 | ax.set_xticks(xtickspos) |
|
105 | 105 | else: |
|
106 | 106 | xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/(nxticks)) + int(xmin) |
|
107 | 107 | ax.set_xticks(xtickspos) |
|
108 | 108 | |
|
109 | 109 | for tick in ax.get_xticklabels(): |
|
110 | 110 | tick.set_visible(xtick_visible) |
|
111 | 111 | |
|
112 | 112 | for tick in ax.xaxis.get_major_ticks(): |
|
113 | 113 | tick.label.set_fontsize(ticksize) |
|
114 | 114 | |
|
115 | 115 | ###################################################### |
|
116 | 116 | for tick in ax.get_yticklabels(): |
|
117 | 117 | tick.set_visible(ytick_visible) |
|
118 | 118 | |
|
119 | 119 | for tick in ax.yaxis.get_major_ticks(): |
|
120 | 120 | tick.label.set_fontsize(ticksize) |
|
121 | 121 | |
|
122 | 122 | ax.plot(x, y) |
|
123 | 123 | iplot = ax.lines[-1] |
|
124 | 124 | |
|
125 | 125 | ###################################################### |
|
126 | 126 | if '0.' in matplotlib.__version__[0:2]: |
|
127 | 127 | print "The matplotlib version has to be updated to 1.1 or newer" |
|
128 | 128 | return iplot |
|
129 | 129 | |
|
130 | 130 | if '1.0.' in matplotlib.__version__[0:4]: |
|
131 | 131 | print "The matplotlib version has to be updated to 1.1 or newer" |
|
132 | 132 | return iplot |
|
133 | 133 | |
|
134 | 134 | if grid != None: |
|
135 | 135 | ax.grid(b=True, which='major', axis=grid) |
|
136 | 136 | |
|
137 | 137 | matplotlib.pyplot.tight_layout() |
|
138 | 138 | |
|
139 | 139 | matplotlib.pyplot.ion() |
|
140 | 140 | |
|
141 | 141 | return iplot |
|
142 | 142 | |
|
143 | 143 | def set_linedata(ax, x, y, idline): |
|
144 | 144 | |
|
145 | 145 | ax.lines[idline].set_data(x,y) |
|
146 | 146 | |
|
147 | 147 | def pline(iplot, x, y, xlabel='', ylabel='', title=''): |
|
148 | 148 | |
|
149 | 149 | ax = iplot.get_axes() |
|
150 | 150 | |
|
151 | 151 | printLabels(ax, xlabel, ylabel, title) |
|
152 | 152 | |
|
153 | 153 | set_linedata(ax, x, y, idline=0) |
|
154 | 154 | |
|
155 | 155 | def addpline(ax, x, y, color, linestyle, lw): |
|
156 | 156 | |
|
157 | 157 | ax.plot(x,y,color=color,linestyle=linestyle,lw=lw) |
|
158 | 158 | |
|
159 | 159 | |
|
160 | 160 | def createPcolor(ax, x, y, z, xmin, xmax, ymin, ymax, zmin, zmax, |
|
161 | 161 | xlabel='', ylabel='', title='', ticksize = 9, |
|
162 | 162 | colormap='jet',cblabel='', cbsize="5%", |
|
163 | 163 | XAxisAsTime=False): |
|
164 | 164 | |
|
165 | 165 | matplotlib.pyplot.ioff() |
|
166 | 166 | |
|
167 | 167 | divider = make_axes_locatable(ax) |
|
168 | 168 | ax_cb = divider.new_horizontal(size=cbsize, pad=0.05) |
|
169 | 169 | fig = ax.get_figure() |
|
170 | 170 | fig.add_axes(ax_cb) |
|
171 | 171 | |
|
172 | 172 | ax.set_xlim([xmin,xmax]) |
|
173 | 173 | ax.set_ylim([ymin,ymax]) |
|
174 | 174 | |
|
175 | 175 | printLabels(ax, xlabel, ylabel, title) |
|
176 | 176 | |
|
177 | 177 | imesh = ax.pcolormesh(x,y,z.T, vmin=zmin, vmax=zmax, cmap=matplotlib.pyplot.get_cmap(colormap)) |
|
178 | 178 | cb = matplotlib.pyplot.colorbar(imesh, cax=ax_cb) |
|
179 | 179 | cb.set_label(cblabel) |
|
180 | 180 | |
|
181 | 181 | # for tl in ax_cb.get_yticklabels(): |
|
182 | 182 | # tl.set_visible(True) |
|
183 | 183 | |
|
184 | 184 | for tick in ax.yaxis.get_major_ticks(): |
|
185 | 185 | tick.label.set_fontsize(ticksize) |
|
186 | 186 | |
|
187 | 187 | for tick in ax.xaxis.get_major_ticks(): |
|
188 | 188 | tick.label.set_fontsize(ticksize) |
|
189 | 189 | |
|
190 | 190 | for tick in cb.ax.get_yticklabels(): |
|
191 | 191 | tick.set_fontsize(ticksize) |
|
192 | 192 | |
|
193 | 193 | ax_cb.yaxis.tick_right() |
|
194 | 194 | |
|
195 | 195 | if '0.' in matplotlib.__version__[0:2]: |
|
196 | 196 | print "The matplotlib version has to be updated to 1.1 or newer" |
|
197 | 197 | return imesh |
|
198 | 198 | |
|
199 | 199 | if '1.0.' in matplotlib.__version__[0:4]: |
|
200 | 200 | print "The matplotlib version has to be updated to 1.1 or newer" |
|
201 | 201 | return imesh |
|
202 | 202 | |
|
203 | 203 | matplotlib.pyplot.tight_layout() |
|
204 | 204 | |
|
205 | 205 | if XAxisAsTime: |
|
206 | 206 | |
|
207 | 207 | func = lambda x, pos: ('%s') %(datetime.datetime.utcfromtimestamp(x).strftime("%H:%M:%S")) |
|
208 | 208 | ax.xaxis.set_major_formatter(FuncFormatter(func)) |
|
209 | 209 | ax.xaxis.set_major_locator(LinearLocator(7)) |
|
210 | 210 | |
|
211 | 211 | matplotlib.pyplot.ion() |
|
212 | 212 | return imesh |
|
213 | 213 | |
|
214 | 214 | def pcolor(imesh, z, xlabel='', ylabel='', title=''): |
|
215 | 215 | |
|
216 | 216 | z = z.T |
|
217 | 217 | |
|
218 | 218 | ax = imesh.get_axes() |
|
219 | 219 | |
|
220 | 220 | printLabels(ax, xlabel, ylabel, title) |
|
221 | 221 | |
|
222 | 222 | imesh.set_array(z.ravel()) |
|
223 | 223 | |
|
224 | 224 | def addpcolor(ax, x, y, z, zmin, zmax, xlabel='', ylabel='', title='', colormap='jet'): |
|
225 | 225 | |
|
226 | 226 | printLabels(ax, xlabel, ylabel, title) |
|
227 | 227 | |
|
228 | 228 | ax.pcolormesh(x,y,z.T,vmin=zmin,vmax=zmax, cmap=matplotlib.pyplot.get_cmap(colormap)) |
|
229 | 229 | |
|
230 | 230 | def addpcolorbuffer(ax, x, y, z, zmin, zmax, xlabel='', ylabel='', title='', colormap='jet'): |
|
231 | 231 | |
|
232 | 232 | printLabels(ax, xlabel, ylabel, title) |
|
233 | 233 | |
|
234 | 234 | ax.collections.remove(ax.collections[0]) |
|
235 | 235 | |
|
236 | 236 | ax.pcolormesh(x,y,z.T,vmin=zmin,vmax=zmax, cmap=matplotlib.pyplot.get_cmap(colormap)) |
|
237 | 237 | |
|
238 | 238 | def createPmultiline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='', legendlabels=None, |
|
239 | 239 | ticksize=9, xtick_visible=True, ytick_visible=True, |
|
240 | 240 | nxticks=4, nyticks=10, |
|
241 | 241 | grid=None): |
|
242 | 242 | |
|
243 | 243 | """ |
|
244 | 244 | |
|
245 | 245 | Input: |
|
246 | 246 | grid : None, 'both', 'x', 'y' |
|
247 | 247 | """ |
|
248 | 248 | |
|
249 | 249 | matplotlib.pyplot.ioff() |
|
250 | 250 | |
|
251 | 251 | lines = ax.plot(x.T, y) |
|
252 | 252 | leg = ax.legend(lines, legendlabels, loc='upper right') |
|
253 | 253 | leg.get_frame().set_alpha(0.5) |
|
254 | 254 | ax.set_xlim([xmin,xmax]) |
|
255 | 255 | ax.set_ylim([ymin,ymax]) |
|
256 | 256 | printLabels(ax, xlabel, ylabel, title) |
|
257 | 257 | |
|
258 | 258 | xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/(nxticks)) + int(xmin) |
|
259 | 259 | ax.set_xticks(xtickspos) |
|
260 | 260 | |
|
261 | 261 | for tick in ax.get_xticklabels(): |
|
262 | 262 | tick.set_visible(xtick_visible) |
|
263 | 263 | |
|
264 | 264 | for tick in ax.xaxis.get_major_ticks(): |
|
265 | 265 | tick.label.set_fontsize(ticksize) |
|
266 | 266 | |
|
267 | 267 | for tick in ax.get_yticklabels(): |
|
268 | 268 | tick.set_visible(ytick_visible) |
|
269 | 269 | |
|
270 | 270 | for tick in ax.yaxis.get_major_ticks(): |
|
271 | 271 | tick.label.set_fontsize(ticksize) |
|
272 | 272 | |
|
273 | 273 | iplot = ax.lines[-1] |
|
274 | 274 | |
|
275 | 275 | if '0.' in matplotlib.__version__[0:2]: |
|
276 | 276 | print "The matplotlib version has to be updated to 1.1 or newer" |
|
277 | 277 | return iplot |
|
278 | 278 | |
|
279 | 279 | if '1.0.' in matplotlib.__version__[0:4]: |
|
280 | 280 | print "The matplotlib version has to be updated to 1.1 or newer" |
|
281 | 281 | return iplot |
|
282 | 282 | |
|
283 | 283 | if grid != None: |
|
284 | 284 | ax.grid(b=True, which='major', axis=grid) |
|
285 | 285 | |
|
286 | 286 | matplotlib.pyplot.tight_layout() |
|
287 | 287 | |
|
288 | 288 | matplotlib.pyplot.ion() |
|
289 | 289 | |
|
290 | 290 | return iplot |
|
291 | 291 | |
|
292 | 292 | |
|
293 | 293 | def pmultiline(iplot, x, y, xlabel='', ylabel='', title=''): |
|
294 | 294 | |
|
295 | 295 | ax = iplot.get_axes() |
|
296 | 296 | |
|
297 | 297 | printLabels(ax, xlabel, ylabel, title) |
|
298 | 298 | |
|
299 | 299 | for i in range(len(ax.lines)): |
|
300 | 300 | line = ax.lines[i] |
|
301 | 301 | line.set_data(x[i,:],y) |
|
302 | 302 | |
|
303 | 303 | def createPmultilineYAxis(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='', legendlabels=None, |
|
304 | 304 | ticksize=9, xtick_visible=True, ytick_visible=True, |
|
305 | 305 | nxticks=4, nyticks=10, marker='.', markersize=10, linestyle="None", |
|
306 | 306 | grid=None, XAxisAsTime=False): |
|
307 | 307 | |
|
308 | 308 | """ |
|
309 | 309 | |
|
310 | 310 | Input: |
|
311 | 311 | grid : None, 'both', 'x', 'y' |
|
312 | 312 | """ |
|
313 | 313 | |
|
314 | 314 | matplotlib.pyplot.ioff() |
|
315 | 315 | |
|
316 | 316 | # lines = ax.plot(x, y.T, marker=marker,markersize=markersize,linestyle=linestyle) |
|
317 | 317 | lines = ax.plot(x, y.T, linestyle='None', marker='.', markersize=markersize) |
|
318 | 318 | leg = ax.legend(lines, legendlabels, loc='upper left', bbox_to_anchor=(1.01, 1.00), numpoints=1, handlelength=1.5, \ |
|
319 | 319 | handletextpad=0.5, borderpad=0.5, labelspacing=0.5, borderaxespad=0.) |
|
320 | 320 | |
|
321 | 321 | for label in leg.get_texts(): label.set_fontsize(9) |
|
322 | 322 | |
|
323 | 323 | ax.set_xlim([xmin,xmax]) |
|
324 | 324 | ax.set_ylim([ymin,ymax]) |
|
325 | 325 | printLabels(ax, xlabel, ylabel, title) |
|
326 | 326 | |
|
327 | 327 | # xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/(nxticks)) + int(xmin) |
|
328 | 328 | # ax.set_xticks(xtickspos) |
|
329 | 329 | |
|
330 | 330 | for tick in ax.get_xticklabels(): |
|
331 | 331 | tick.set_visible(xtick_visible) |
|
332 | 332 | |
|
333 | 333 | for tick in ax.xaxis.get_major_ticks(): |
|
334 | 334 | tick.label.set_fontsize(ticksize) |
|
335 | 335 | |
|
336 | 336 | for tick in ax.get_yticklabels(): |
|
337 | 337 | tick.set_visible(ytick_visible) |
|
338 | 338 | |
|
339 | 339 | for tick in ax.yaxis.get_major_ticks(): |
|
340 | 340 | tick.label.set_fontsize(ticksize) |
|
341 | 341 | |
|
342 | 342 | iplot = ax.lines[-1] |
|
343 | 343 | |
|
344 | 344 | if '0.' in matplotlib.__version__[0:2]: |
|
345 | 345 | print "The matplotlib version has to be updated to 1.1 or newer" |
|
346 | 346 | return iplot |
|
347 | 347 | |
|
348 | 348 | if '1.0.' in matplotlib.__version__[0:4]: |
|
349 | 349 | print "The matplotlib version has to be updated to 1.1 or newer" |
|
350 | 350 | return iplot |
|
351 | 351 | |
|
352 | 352 | if grid != None: |
|
353 | 353 | ax.grid(b=True, which='major', axis=grid) |
|
354 | 354 | |
|
355 | 355 | matplotlib.pyplot.tight_layout() |
|
356 | 356 | |
|
357 | 357 | if XAxisAsTime: |
|
358 | 358 | |
|
359 | 359 | func = lambda x, pos: ('%s') %(datetime.datetime.utcfromtimestamp(x).strftime("%H:%M:%S")) |
|
360 | 360 | ax.xaxis.set_major_formatter(FuncFormatter(func)) |
|
361 | 361 | ax.xaxis.set_major_locator(LinearLocator(7)) |
|
362 | 362 | |
|
363 | 363 | matplotlib.pyplot.ion() |
|
364 | 364 | |
|
365 | 365 | return iplot |
|
366 | 366 | |
|
367 | 367 | def pmultilineyaxis(iplot, x, y, xlabel='', ylabel='', title=''): |
|
368 | 368 | |
|
369 | 369 | ax = iplot.get_axes() |
|
370 | 370 | |
|
371 | 371 | printLabels(ax, xlabel, ylabel, title) |
|
372 | 372 | |
|
373 | 373 | for i in range(len(ax.lines)): |
|
374 | 374 | line = ax.lines[i] |
|
375 | 375 | line.set_data(x,y[i,:]) |
|
376 | 376 | |
|
377 | 377 | def draw(fig): |
|
378 | 378 | |
|
379 | 379 | if type(fig) == 'int': |
|
380 | 380 | raise ValueError, "This parameter should be of tpye matplotlib figure" |
|
381 | 381 | |
|
382 | 382 | fig.canvas.draw() No newline at end of file |
@@ -1,1363 +1,1365 | |||
|
1 | 1 | import numpy |
|
2 | 2 | import time, datetime, os |
|
3 | 3 | from graphics.figure import * |
|
4 | 4 | def isRealtime(utcdatatime): |
|
5 | 5 | utcnow = time.mktime(datetime.datetime.utcnow().timetuple()) |
|
6 | 6 | delta = utcnow - utcdatatime # abs |
|
7 | 7 | if delta >= 5*60.: |
|
8 | 8 | return False |
|
9 | 9 | return True |
|
10 | 10 | |
|
11 | 11 | class CrossSpectraPlot(Figure): |
|
12 | 12 | |
|
13 | 13 | __isConfig = None |
|
14 | 14 | __nsubplots = None |
|
15 | 15 | |
|
16 | 16 | WIDTH = None |
|
17 | 17 | HEIGHT = None |
|
18 | 18 | WIDTHPROF = None |
|
19 | 19 | HEIGHTPROF = None |
|
20 | 20 | PREFIX = 'cspc' |
|
21 | 21 | |
|
22 | 22 | def __init__(self): |
|
23 | 23 | |
|
24 | 24 | self.__isConfig = False |
|
25 | 25 | self.__nsubplots = 4 |
|
26 | 26 | |
|
27 | 27 | self.WIDTH = 250 |
|
28 | 28 | self.HEIGHT = 250 |
|
29 | 29 | self.WIDTHPROF = 0 |
|
30 | 30 | self.HEIGHTPROF = 0 |
|
31 | 31 | |
|
32 | 32 | def getSubplots(self): |
|
33 | 33 | |
|
34 | 34 | ncol = 4 |
|
35 | 35 | nrow = self.nplots |
|
36 | 36 | |
|
37 | 37 | return nrow, ncol |
|
38 | 38 | |
|
39 |
def setup(self, id |
|
|
39 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
|
40 | 40 | |
|
41 | 41 | self.__showprofile = showprofile |
|
42 | 42 | self.nplots = nplots |
|
43 | 43 | |
|
44 | 44 | ncolspan = 1 |
|
45 | 45 | colspan = 1 |
|
46 | 46 | |
|
47 |
self.createFigure(id |
|
|
47 | self.createFigure(id = id, | |
|
48 | 48 | wintitle = wintitle, |
|
49 | 49 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
50 | 50 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
51 | 51 | show=True) |
|
52 | 52 | |
|
53 | 53 | nrow, ncol = self.getSubplots() |
|
54 | 54 | |
|
55 | 55 | counter = 0 |
|
56 | 56 | for y in range(nrow): |
|
57 | 57 | for x in range(ncol): |
|
58 | 58 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
59 | 59 | |
|
60 | 60 | counter += 1 |
|
61 | 61 | |
|
62 |
def run(self, dataOut, id |
|
|
62 | def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True', | |
|
63 | 63 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
64 | 64 | save=False, figpath='./', figfile=None, |
|
65 | 65 | power_cmap='jet', coherence_cmap='jet', phase_cmap='RdBu_r', show=True): |
|
66 | 66 | |
|
67 | 67 | """ |
|
68 | 68 | |
|
69 | 69 | Input: |
|
70 | 70 | dataOut : |
|
71 |
id |
|
|
71 | id : | |
|
72 | 72 | wintitle : |
|
73 | 73 | channelList : |
|
74 | 74 | showProfile : |
|
75 | 75 | xmin : None, |
|
76 | 76 | xmax : None, |
|
77 | 77 | ymin : None, |
|
78 | 78 | ymax : None, |
|
79 | 79 | zmin : None, |
|
80 | 80 | zmax : None |
|
81 | 81 | """ |
|
82 | 82 | |
|
83 | 83 | if pairsList == None: |
|
84 | 84 | pairsIndexList = dataOut.pairsIndexList |
|
85 | 85 | else: |
|
86 | 86 | pairsIndexList = [] |
|
87 | 87 | for pair in pairsList: |
|
88 | 88 | if pair not in dataOut.pairsList: |
|
89 | 89 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) |
|
90 | 90 | pairsIndexList.append(dataOut.pairsList.index(pair)) |
|
91 | 91 | |
|
92 | 92 | if pairsIndexList == []: |
|
93 | 93 | return |
|
94 | 94 | |
|
95 | 95 | if len(pairsIndexList) > 4: |
|
96 | 96 | pairsIndexList = pairsIndexList[0:4] |
|
97 | 97 | factor = dataOut.normFactor |
|
98 | 98 | x = dataOut.getVelRange(1) |
|
99 | 99 | y = dataOut.getHeiRange() |
|
100 | 100 | z = dataOut.data_spc[:,:,:]/factor |
|
101 | 101 | # z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
102 | 102 | avg = numpy.abs(numpy.average(z, axis=1)) |
|
103 | 103 | noise = dataOut.getNoise()/factor |
|
104 | 104 | |
|
105 | 105 | zdB = 10*numpy.log10(z) |
|
106 | 106 | avgdB = 10*numpy.log10(avg) |
|
107 | 107 | noisedB = 10*numpy.log10(noise) |
|
108 | 108 | |
|
109 | 109 | |
|
110 | 110 | #thisDatetime = dataOut.datatime |
|
111 | 111 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) |
|
112 | 112 | title = wintitle + " Cross-Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
113 | 113 | xlabel = "Velocity (m/s)" |
|
114 | 114 | ylabel = "Range (Km)" |
|
115 | 115 | |
|
116 | 116 | if not self.__isConfig: |
|
117 | 117 | |
|
118 | 118 | nplots = len(pairsIndexList) |
|
119 | 119 | |
|
120 |
self.setup(id |
|
|
120 | self.setup(id=id, | |
|
121 | 121 | nplots=nplots, |
|
122 | 122 | wintitle=wintitle, |
|
123 | 123 | showprofile=showprofile, |
|
124 | 124 | show=show) |
|
125 | 125 | |
|
126 | 126 | if xmin == None: xmin = numpy.nanmin(x) |
|
127 | 127 | if xmax == None: xmax = numpy.nanmax(x) |
|
128 | 128 | if ymin == None: ymin = numpy.nanmin(y) |
|
129 | 129 | if ymax == None: ymax = numpy.nanmax(y) |
|
130 | 130 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 |
|
131 | 131 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 |
|
132 | 132 | |
|
133 | 133 | self.__isConfig = True |
|
134 | 134 | |
|
135 | 135 | self.setWinTitle(title) |
|
136 | 136 | |
|
137 | 137 | for i in range(self.nplots): |
|
138 | 138 | pair = dataOut.pairsList[pairsIndexList[i]] |
|
139 | 139 | |
|
140 | 140 | title = "Channel %d: %4.2fdB" %(pair[0], noisedB[pair[0]]) |
|
141 | 141 | zdB = 10.*numpy.log10(dataOut.data_spc[pair[0],:,:]/factor) |
|
142 | 142 | axes0 = self.axesList[i*self.__nsubplots] |
|
143 | 143 | axes0.pcolor(x, y, zdB, |
|
144 | 144 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
145 | 145 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
146 | 146 | ticksize=9, colormap=power_cmap, cblabel='') |
|
147 | 147 | |
|
148 | 148 | title = "Channel %d: %4.2fdB" %(pair[1], noisedB[pair[1]]) |
|
149 | 149 | zdB = 10.*numpy.log10(dataOut.data_spc[pair[1],:,:]/factor) |
|
150 | 150 | axes0 = self.axesList[i*self.__nsubplots+1] |
|
151 | 151 | axes0.pcolor(x, y, zdB, |
|
152 | 152 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
153 | 153 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
154 | 154 | ticksize=9, colormap=power_cmap, cblabel='') |
|
155 | 155 | |
|
156 | 156 | coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:]) |
|
157 | 157 | coherence = numpy.abs(coherenceComplex) |
|
158 | 158 | # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi |
|
159 | 159 | phase = numpy.arctan2(coherenceComplex.imag, coherenceComplex.real)*180/numpy.pi |
|
160 | 160 | |
|
161 | 161 | title = "Coherence %d%d" %(pair[0], pair[1]) |
|
162 | 162 | axes0 = self.axesList[i*self.__nsubplots+2] |
|
163 | 163 | axes0.pcolor(x, y, coherence, |
|
164 | 164 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1, |
|
165 | 165 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
166 | 166 | ticksize=9, colormap=coherence_cmap, cblabel='') |
|
167 | 167 | |
|
168 | 168 | title = "Phase %d%d" %(pair[0], pair[1]) |
|
169 | 169 | axes0 = self.axesList[i*self.__nsubplots+3] |
|
170 | 170 | axes0.pcolor(x, y, phase, |
|
171 | 171 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180, |
|
172 | 172 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
173 | 173 | ticksize=9, colormap=phase_cmap, cblabel='') |
|
174 | 174 | |
|
175 | 175 | |
|
176 | 176 | |
|
177 | 177 | self.draw() |
|
178 | 178 | |
|
179 | 179 | if save: |
|
180 | 180 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
181 | 181 | if figfile == None: |
|
182 | 182 | figfile = self.getFilename(name = date) |
|
183 | 183 | |
|
184 | 184 | self.saveFigure(figpath, figfile) |
|
185 | 185 | |
|
186 | 186 | |
|
187 | 187 | class RTIPlot(Figure): |
|
188 | 188 | |
|
189 | 189 | __isConfig = None |
|
190 | 190 | __nsubplots = None |
|
191 | 191 | |
|
192 | 192 | WIDTHPROF = None |
|
193 | 193 | HEIGHTPROF = None |
|
194 | 194 | PREFIX = 'rti' |
|
195 | 195 | |
|
196 | 196 | def __init__(self): |
|
197 | 197 | |
|
198 | 198 | self.timerange = 2*60*60 |
|
199 | 199 | self.__isConfig = False |
|
200 | 200 | self.__nsubplots = 1 |
|
201 | 201 | |
|
202 | 202 | self.WIDTH = 800 |
|
203 | 203 | self.HEIGHT = 150 |
|
204 | 204 | self.WIDTHPROF = 120 |
|
205 | 205 | self.HEIGHTPROF = 0 |
|
206 |
self.counter |
|
|
206 | self.counter_imagwr = 0 | |
|
207 | 207 | |
|
208 | 208 | def getSubplots(self): |
|
209 | 209 | |
|
210 | 210 | ncol = 1 |
|
211 | 211 | nrow = self.nplots |
|
212 | 212 | |
|
213 | 213 | return nrow, ncol |
|
214 | 214 | |
|
215 |
def setup(self, id |
|
|
215 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
|
216 | 216 | |
|
217 | 217 | self.__showprofile = showprofile |
|
218 | 218 | self.nplots = nplots |
|
219 | 219 | |
|
220 | 220 | ncolspan = 1 |
|
221 | 221 | colspan = 1 |
|
222 | 222 | if showprofile: |
|
223 | 223 | ncolspan = 7 |
|
224 | 224 | colspan = 6 |
|
225 | 225 | self.__nsubplots = 2 |
|
226 | 226 | |
|
227 |
self.createFigure(id |
|
|
227 | self.createFigure(id = id, | |
|
228 | 228 | wintitle = wintitle, |
|
229 | 229 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
230 | 230 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
231 | 231 | show=show) |
|
232 | 232 | |
|
233 | 233 | nrow, ncol = self.getSubplots() |
|
234 | 234 | |
|
235 | 235 | counter = 0 |
|
236 | 236 | for y in range(nrow): |
|
237 | 237 | for x in range(ncol): |
|
238 | 238 | |
|
239 | 239 | if counter >= self.nplots: |
|
240 | 240 | break |
|
241 | 241 | |
|
242 | 242 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
243 | 243 | |
|
244 | 244 | if showprofile: |
|
245 | 245 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
246 | 246 | |
|
247 | 247 | counter += 1 |
|
248 | 248 | |
|
249 |
def run(self, dataOut, id |
|
|
249 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True', | |
|
250 | 250 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
251 | 251 | timerange=None, |
|
252 |
save=False, figpath='./', figfile=None, ftp=False, |
|
|
252 | save=False, figpath='./', figfile=None, ftp=False, res_imagwr=1, show=True): | |
|
253 | 253 | |
|
254 | 254 | """ |
|
255 | 255 | |
|
256 | 256 | Input: |
|
257 | 257 | dataOut : |
|
258 |
id |
|
|
258 | id : | |
|
259 | 259 | wintitle : |
|
260 | 260 | channelList : |
|
261 | 261 | showProfile : |
|
262 | 262 | xmin : None, |
|
263 | 263 | xmax : None, |
|
264 | 264 | ymin : None, |
|
265 | 265 | ymax : None, |
|
266 | 266 | zmin : None, |
|
267 | 267 | zmax : None |
|
268 | 268 | """ |
|
269 | 269 | |
|
270 | 270 | if channelList == None: |
|
271 | 271 | channelIndexList = dataOut.channelIndexList |
|
272 | 272 | else: |
|
273 | 273 | channelIndexList = [] |
|
274 | 274 | for channel in channelList: |
|
275 | 275 | if channel not in dataOut.channelList: |
|
276 | 276 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
277 | 277 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
278 | 278 | |
|
279 | 279 | if timerange != None: |
|
280 | 280 | self.timerange = timerange |
|
281 | 281 | |
|
282 | 282 | tmin = None |
|
283 | 283 | tmax = None |
|
284 | 284 | factor = dataOut.normFactor |
|
285 | 285 | x = dataOut.getTimeRange() |
|
286 | 286 | y = dataOut.getHeiRange() |
|
287 | 287 | |
|
288 | 288 | z = dataOut.data_spc[channelIndexList,:,:]/factor |
|
289 | 289 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
290 | 290 | avg = numpy.average(z, axis=1) |
|
291 | 291 | |
|
292 | 292 | avgdB = 10.*numpy.log10(avg) |
|
293 | 293 | |
|
294 | 294 | |
|
295 | 295 | # thisDatetime = dataOut.datatime |
|
296 | 296 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) |
|
297 | 297 | title = wintitle + " RTI: %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
298 | 298 | xlabel = "" |
|
299 | 299 | ylabel = "Range (Km)" |
|
300 | 300 | |
|
301 | 301 | if not self.__isConfig: |
|
302 | 302 | |
|
303 | 303 | nplots = len(channelIndexList) |
|
304 | 304 | |
|
305 |
self.setup(id |
|
|
305 | self.setup(id=id, | |
|
306 | 306 | nplots=nplots, |
|
307 | 307 | wintitle=wintitle, |
|
308 | 308 | showprofile=showprofile, |
|
309 | 309 | show=show) |
|
310 | 310 | |
|
311 | 311 | tmin, tmax = self.getTimeLim(x, xmin, xmax) |
|
312 | 312 | if ymin == None: ymin = numpy.nanmin(y) |
|
313 | 313 | if ymax == None: ymax = numpy.nanmax(y) |
|
314 | 314 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 |
|
315 | 315 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 |
|
316 | 316 | |
|
317 | 317 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
318 | 318 | self.__isConfig = True |
|
319 | 319 | |
|
320 | 320 | |
|
321 | 321 | self.setWinTitle(title) |
|
322 | 322 | |
|
323 | 323 | for i in range(self.nplots): |
|
324 | 324 | title = "Channel %d: %s" %(dataOut.channelList[i]+1, thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
325 | 325 | axes = self.axesList[i*self.__nsubplots] |
|
326 | 326 | zdB = avgdB[i].reshape((1,-1)) |
|
327 | 327 | axes.pcolorbuffer(x, y, zdB, |
|
328 | 328 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
329 | 329 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
330 | 330 | ticksize=9, cblabel='', cbsize="1%") |
|
331 | 331 | |
|
332 | 332 | if self.__showprofile: |
|
333 | 333 | axes = self.axesList[i*self.__nsubplots +1] |
|
334 | 334 | axes.pline(avgdB[i], y, |
|
335 | 335 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, |
|
336 | 336 | xlabel='dB', ylabel='', title='', |
|
337 | 337 | ytick_visible=False, |
|
338 | 338 | grid='x') |
|
339 | 339 | |
|
340 | 340 | self.draw() |
|
341 | 341 | |
|
342 | 342 | if save: |
|
343 | 343 | |
|
344 | if figfile == None: | |
|
345 | figfile = self.getFilename(name = self.name) | |
|
346 | ||
|
347 | self.saveFigure(figpath, figfile) | |
|
348 | ||
|
349 | self.counterftp += 1 | |
|
350 | if (ftp and (self.counterftp==ftpratio)): | |
|
351 |
|
|
|
352 | self.sendByFTP(figfilename) | |
|
353 | self.counterftp = 0 | |
|
344 | self.counter_imagwr += 1 | |
|
345 | if (self.counter_imagwr==res_imagwr): | |
|
346 | ||
|
347 | ||
|
348 | fig_file = self.getFilename(name = self.name) | |
|
349 | self.saveFigure(figpath, fig_file) | |
|
350 | if ftp: | |
|
351 | self.saveFigure(figpath, figfile) | |
|
352 | figfilename = os.path.join(figpath,figfile) | |
|
353 | self.sendByFTP(figfilename) | |
|
354 | ||
|
355 | self.counter_imagwr = 0 | |
|
354 | 356 | |
|
355 | 357 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: |
|
356 | 358 | self.__isConfig = False |
|
357 | 359 | |
|
358 | 360 | class SpectraPlot(Figure): |
|
359 | 361 | |
|
360 | 362 | __isConfig = None |
|
361 | 363 | __nsubplots = None |
|
362 | 364 | |
|
363 | 365 | WIDTHPROF = None |
|
364 | 366 | HEIGHTPROF = None |
|
365 | 367 | PREFIX = 'spc' |
|
366 | 368 | |
|
367 | 369 | def __init__(self): |
|
368 | 370 | |
|
369 | 371 | self.__isConfig = False |
|
370 | 372 | self.__nsubplots = 1 |
|
371 | 373 | |
|
372 | 374 | self.WIDTH = 230 |
|
373 | 375 | self.HEIGHT = 250 |
|
374 | 376 | self.WIDTHPROF = 120 |
|
375 | 377 | self.HEIGHTPROF = 0 |
|
376 | 378 | |
|
377 | 379 | def getSubplots(self): |
|
378 | 380 | |
|
379 | 381 | ncol = int(numpy.sqrt(self.nplots)+0.9) |
|
380 | 382 | nrow = int(self.nplots*1./ncol + 0.9) |
|
381 | 383 | |
|
382 | 384 | return nrow, ncol |
|
383 | 385 | |
|
384 |
def setup(self, id |
|
|
386 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
|
385 | 387 | |
|
386 | 388 | self.__showprofile = showprofile |
|
387 | 389 | self.nplots = nplots |
|
388 | 390 | |
|
389 | 391 | ncolspan = 1 |
|
390 | 392 | colspan = 1 |
|
391 | 393 | if showprofile: |
|
392 | 394 | ncolspan = 3 |
|
393 | 395 | colspan = 2 |
|
394 | 396 | self.__nsubplots = 2 |
|
395 | 397 | |
|
396 |
self.createFigure(id |
|
|
398 | self.createFigure(id = id, | |
|
397 | 399 | wintitle = wintitle, |
|
398 | 400 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
399 | 401 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
400 | 402 | show=show) |
|
401 | 403 | |
|
402 | 404 | nrow, ncol = self.getSubplots() |
|
403 | 405 | |
|
404 | 406 | counter = 0 |
|
405 | 407 | for y in range(nrow): |
|
406 | 408 | for x in range(ncol): |
|
407 | 409 | |
|
408 | 410 | if counter >= self.nplots: |
|
409 | 411 | break |
|
410 | 412 | |
|
411 | 413 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
412 | 414 | |
|
413 | 415 | if showprofile: |
|
414 | 416 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
415 | 417 | |
|
416 | 418 | counter += 1 |
|
417 | 419 | |
|
418 |
def run(self, dataOut, id |
|
|
420 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True', | |
|
419 | 421 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
420 | 422 | save=False, figpath='./', figfile=None, show=True): |
|
421 | 423 | |
|
422 | 424 | """ |
|
423 | 425 | |
|
424 | 426 | Input: |
|
425 | 427 | dataOut : |
|
426 |
id |
|
|
428 | id : | |
|
427 | 429 | wintitle : |
|
428 | 430 | channelList : |
|
429 | 431 | showProfile : |
|
430 | 432 | xmin : None, |
|
431 | 433 | xmax : None, |
|
432 | 434 | ymin : None, |
|
433 | 435 | ymax : None, |
|
434 | 436 | zmin : None, |
|
435 | 437 | zmax : None |
|
436 | 438 | """ |
|
437 | 439 | |
|
438 | 440 | if channelList == None: |
|
439 | 441 | channelIndexList = dataOut.channelIndexList |
|
440 | 442 | else: |
|
441 | 443 | channelIndexList = [] |
|
442 | 444 | for channel in channelList: |
|
443 | 445 | if channel not in dataOut.channelList: |
|
444 | 446 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
445 | 447 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
446 | 448 | factor = dataOut.normFactor |
|
447 | 449 | x = dataOut.getVelRange(1) |
|
448 | 450 | y = dataOut.getHeiRange() |
|
449 | 451 | |
|
450 | 452 | z = dataOut.data_spc[channelIndexList,:,:]/factor |
|
451 | 453 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
452 | 454 | avg = numpy.average(z, axis=1) |
|
453 | 455 | noise = dataOut.getNoise()/factor |
|
454 | 456 | |
|
455 | 457 | zdB = 10*numpy.log10(z) |
|
456 | 458 | avgdB = 10*numpy.log10(avg) |
|
457 | 459 | noisedB = 10*numpy.log10(noise) |
|
458 | 460 | |
|
459 | 461 | #thisDatetime = dataOut.datatime |
|
460 | 462 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) |
|
461 | 463 | title = wintitle + " Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
462 | 464 | xlabel = "Velocity (m/s)" |
|
463 | 465 | ylabel = "Range (Km)" |
|
464 | 466 | |
|
465 | 467 | if not self.__isConfig: |
|
466 | 468 | |
|
467 | 469 | nplots = len(channelIndexList) |
|
468 | 470 | |
|
469 |
self.setup(id |
|
|
471 | self.setup(id=id, | |
|
470 | 472 | nplots=nplots, |
|
471 | 473 | wintitle=wintitle, |
|
472 | 474 | showprofile=showprofile, |
|
473 | 475 | show=show) |
|
474 | 476 | |
|
475 | 477 | if xmin == None: xmin = numpy.nanmin(x) |
|
476 | 478 | if xmax == None: xmax = numpy.nanmax(x) |
|
477 | 479 | if ymin == None: ymin = numpy.nanmin(y) |
|
478 | 480 | if ymax == None: ymax = numpy.nanmax(y) |
|
479 | 481 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 |
|
480 | 482 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 |
|
481 | 483 | |
|
482 | 484 | self.__isConfig = True |
|
483 | 485 | |
|
484 | 486 | self.setWinTitle(title) |
|
485 | 487 | |
|
486 | 488 | for i in range(self.nplots): |
|
487 | 489 | title = "Channel %d: %4.2fdB" %(dataOut.channelList[i]+1, noisedB[i]) |
|
488 | 490 | axes = self.axesList[i*self.__nsubplots] |
|
489 | 491 | axes.pcolor(x, y, zdB[i,:,:], |
|
490 | 492 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
491 | 493 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
492 | 494 | ticksize=9, cblabel='') |
|
493 | 495 | |
|
494 | 496 | if self.__showprofile: |
|
495 | 497 | axes = self.axesList[i*self.__nsubplots +1] |
|
496 | 498 | axes.pline(avgdB[i], y, |
|
497 | 499 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, |
|
498 | 500 | xlabel='dB', ylabel='', title='', |
|
499 | 501 | ytick_visible=False, |
|
500 | 502 | grid='x') |
|
501 | 503 | |
|
502 | 504 | noiseline = numpy.repeat(noisedB[i], len(y)) |
|
503 | 505 | axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2) |
|
504 | 506 | |
|
505 | 507 | self.draw() |
|
506 | 508 | |
|
507 | 509 | if save: |
|
508 | 510 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
509 | 511 | if figfile == None: |
|
510 | 512 | figfile = self.getFilename(name = date) |
|
511 | 513 | |
|
512 | 514 | self.saveFigure(figpath, figfile) |
|
513 | 515 | |
|
514 | 516 | class Scope(Figure): |
|
515 | 517 | |
|
516 | 518 | __isConfig = None |
|
517 | 519 | |
|
518 | 520 | def __init__(self): |
|
519 | 521 | |
|
520 | 522 | self.__isConfig = False |
|
521 | 523 | self.WIDTH = 600 |
|
522 | 524 | self.HEIGHT = 200 |
|
523 | 525 | |
|
524 | 526 | def getSubplots(self): |
|
525 | 527 | |
|
526 | 528 | nrow = self.nplots |
|
527 | 529 | ncol = 3 |
|
528 | 530 | return nrow, ncol |
|
529 | 531 | |
|
530 |
def setup(self, id |
|
|
532 | def setup(self, id, nplots, wintitle, show): | |
|
531 | 533 | |
|
532 | 534 | self.nplots = nplots |
|
533 | 535 | |
|
534 |
self.createFigure(id |
|
|
536 | self.createFigure(id=id, | |
|
535 | 537 | wintitle=wintitle, |
|
536 | 538 | show=show) |
|
537 | 539 | |
|
538 | 540 | nrow,ncol = self.getSubplots() |
|
539 | 541 | colspan = 3 |
|
540 | 542 | rowspan = 1 |
|
541 | 543 | |
|
542 | 544 | for i in range(nplots): |
|
543 | 545 | self.addAxes(nrow, ncol, i, 0, colspan, rowspan) |
|
544 | 546 | |
|
545 | 547 | |
|
546 | 548 | |
|
547 |
def run(self, dataOut, id |
|
|
549 | def run(self, dataOut, id, wintitle="", channelList=None, | |
|
548 | 550 | xmin=None, xmax=None, ymin=None, ymax=None, save=False, |
|
549 | 551 | figpath='./', figfile=None, show=True): |
|
550 | 552 | |
|
551 | 553 | """ |
|
552 | 554 | |
|
553 | 555 | Input: |
|
554 | 556 | dataOut : |
|
555 |
id |
|
|
557 | id : | |
|
556 | 558 | wintitle : |
|
557 | 559 | channelList : |
|
558 | 560 | xmin : None, |
|
559 | 561 | xmax : None, |
|
560 | 562 | ymin : None, |
|
561 | 563 | ymax : None, |
|
562 | 564 | """ |
|
563 | 565 | |
|
564 | 566 | if channelList == None: |
|
565 | 567 | channelIndexList = dataOut.channelIndexList |
|
566 | 568 | else: |
|
567 | 569 | channelIndexList = [] |
|
568 | 570 | for channel in channelList: |
|
569 | 571 | if channel not in dataOut.channelList: |
|
570 | 572 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
571 | 573 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
572 | 574 | |
|
573 | 575 | x = dataOut.heightList |
|
574 | 576 | y = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:]) |
|
575 | 577 | y = y.real |
|
576 | 578 | |
|
577 | 579 | #thisDatetime = dataOut.datatime |
|
578 | 580 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) |
|
579 | 581 | title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
580 | 582 | xlabel = "Range (Km)" |
|
581 | 583 | ylabel = "Intensity" |
|
582 | 584 | |
|
583 | 585 | if not self.__isConfig: |
|
584 | 586 | nplots = len(channelIndexList) |
|
585 | 587 | |
|
586 |
self.setup(id |
|
|
588 | self.setup(id=id, | |
|
587 | 589 | nplots=nplots, |
|
588 | 590 | wintitle=wintitle, |
|
589 | 591 | show=show) |
|
590 | 592 | |
|
591 | 593 | if xmin == None: xmin = numpy.nanmin(x) |
|
592 | 594 | if xmax == None: xmax = numpy.nanmax(x) |
|
593 | 595 | if ymin == None: ymin = numpy.nanmin(y) |
|
594 | 596 | if ymax == None: ymax = numpy.nanmax(y) |
|
595 | 597 | |
|
596 | 598 | self.__isConfig = True |
|
597 | 599 | |
|
598 | 600 | self.setWinTitle(title) |
|
599 | 601 | |
|
600 | 602 | for i in range(len(self.axesList)): |
|
601 | 603 | title = "Channel %d" %(i) |
|
602 | 604 | axes = self.axesList[i] |
|
603 | 605 | ychannel = y[i,:] |
|
604 | 606 | axes.pline(x, ychannel, |
|
605 | 607 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, |
|
606 | 608 | xlabel=xlabel, ylabel=ylabel, title=title) |
|
607 | 609 | |
|
608 | 610 | self.draw() |
|
609 | 611 | |
|
610 | 612 | if save: |
|
611 | 613 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
612 | 614 | if figfile == None: |
|
613 | 615 | figfile = self.getFilename(name = date) |
|
614 | 616 | |
|
615 | 617 | self.saveFigure(figpath, figfile) |
|
616 | 618 | |
|
617 | 619 | class PowerProfilePlot(Figure): |
|
618 | 620 | __isConfig = None |
|
619 | 621 | __nsubplots = None |
|
620 | 622 | |
|
621 | 623 | WIDTHPROF = None |
|
622 | 624 | HEIGHTPROF = None |
|
623 | 625 | PREFIX = 'spcprofile' |
|
624 | 626 | |
|
625 | 627 | def __init__(self): |
|
626 | 628 | self.__isConfig = False |
|
627 | 629 | self.__nsubplots = 1 |
|
628 | 630 | |
|
629 | 631 | self.WIDTH = 300 |
|
630 | 632 | self.HEIGHT = 500 |
|
631 | 633 | |
|
632 | 634 | def getSubplots(self): |
|
633 | 635 | ncol = 1 |
|
634 | 636 | nrow = 1 |
|
635 | 637 | |
|
636 | 638 | return nrow, ncol |
|
637 | 639 | |
|
638 |
def setup(self, id |
|
|
640 | def setup(self, id, nplots, wintitle, show): | |
|
639 | 641 | |
|
640 | 642 | self.nplots = nplots |
|
641 | 643 | |
|
642 | 644 | ncolspan = 1 |
|
643 | 645 | colspan = 1 |
|
644 | 646 | |
|
645 |
self.createFigure(id |
|
|
647 | self.createFigure(id = id, | |
|
646 | 648 | wintitle = wintitle, |
|
647 | 649 | widthplot = self.WIDTH, |
|
648 | 650 | heightplot = self.HEIGHT, |
|
649 | 651 | show=show) |
|
650 | 652 | |
|
651 | 653 | nrow, ncol = self.getSubplots() |
|
652 | 654 | |
|
653 | 655 | counter = 0 |
|
654 | 656 | for y in range(nrow): |
|
655 | 657 | for x in range(ncol): |
|
656 | 658 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
657 | 659 | |
|
658 |
def run(self, dataOut, id |
|
|
660 | def run(self, dataOut, id, wintitle="", channelList=None, | |
|
659 | 661 | xmin=None, xmax=None, ymin=None, ymax=None, |
|
660 | 662 | save=False, figpath='./', figfile=None, show=True): |
|
661 | 663 | |
|
662 | 664 | if channelList == None: |
|
663 | 665 | channelIndexList = dataOut.channelIndexList |
|
664 | 666 | channelList = dataOut.channelList |
|
665 | 667 | else: |
|
666 | 668 | channelIndexList = [] |
|
667 | 669 | for channel in channelList: |
|
668 | 670 | if channel not in dataOut.channelList: |
|
669 | 671 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
670 | 672 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
671 | 673 | |
|
672 | 674 | factor = dataOut.normFactor |
|
673 | 675 | y = dataOut.getHeiRange() |
|
674 | 676 | x = dataOut.data_spc[channelIndexList,:,:]/factor |
|
675 | 677 | x = numpy.where(numpy.isfinite(x), x, numpy.NAN) |
|
676 | 678 | avg = numpy.average(x, axis=1) |
|
677 | 679 | |
|
678 | 680 | avgdB = 10*numpy.log10(avg) |
|
679 | 681 | |
|
680 | 682 | #thisDatetime = dataOut.datatime |
|
681 | 683 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) |
|
682 | 684 | title = wintitle + " Power Profile %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
683 | 685 | xlabel = "dB" |
|
684 | 686 | ylabel = "Range (Km)" |
|
685 | 687 | |
|
686 | 688 | if not self.__isConfig: |
|
687 | 689 | |
|
688 | 690 | nplots = 1 |
|
689 | 691 | |
|
690 |
self.setup(id |
|
|
692 | self.setup(id=id, | |
|
691 | 693 | nplots=nplots, |
|
692 | 694 | wintitle=wintitle, |
|
693 | 695 | show=show) |
|
694 | 696 | |
|
695 | 697 | if ymin == None: ymin = numpy.nanmin(y) |
|
696 | 698 | if ymax == None: ymax = numpy.nanmax(y) |
|
697 | 699 | if xmin == None: xmin = numpy.nanmin(avgdB)*0.9 |
|
698 | 700 | if xmax == None: xmax = numpy.nanmax(avgdB)*0.9 |
|
699 | 701 | |
|
700 | 702 | self.__isConfig = True |
|
701 | 703 | |
|
702 | 704 | self.setWinTitle(title) |
|
703 | 705 | |
|
704 | 706 | |
|
705 | 707 | title = "Power Profile: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
706 | 708 | axes = self.axesList[0] |
|
707 | 709 | |
|
708 | 710 | legendlabels = ["channel %d"%x for x in channelList] |
|
709 | 711 | axes.pmultiline(avgdB, y, |
|
710 | 712 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, |
|
711 | 713 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, |
|
712 | 714 | ytick_visible=True, nxticks=5, |
|
713 | 715 | grid='x') |
|
714 | 716 | |
|
715 | 717 | self.draw() |
|
716 | 718 | |
|
717 | 719 | if save: |
|
718 | 720 | date = thisDatetime.strftime("%Y%m%d") |
|
719 | 721 | if figfile == None: |
|
720 | 722 | figfile = self.getFilename(name = date) |
|
721 | 723 | |
|
722 | 724 | self.saveFigure(figpath, figfile) |
|
723 | 725 | |
|
724 | 726 | class CoherenceMap(Figure): |
|
725 | 727 | __isConfig = None |
|
726 | 728 | __nsubplots = None |
|
727 | 729 | |
|
728 | 730 | WIDTHPROF = None |
|
729 | 731 | HEIGHTPROF = None |
|
730 | 732 | PREFIX = 'cmap' |
|
731 | 733 | |
|
732 | 734 | def __init__(self): |
|
733 | 735 | self.timerange = 2*60*60 |
|
734 | 736 | self.__isConfig = False |
|
735 | 737 | self.__nsubplots = 1 |
|
736 | 738 | |
|
737 | 739 | self.WIDTH = 800 |
|
738 | 740 | self.HEIGHT = 150 |
|
739 | 741 | self.WIDTHPROF = 120 |
|
740 | 742 | self.HEIGHTPROF = 0 |
|
741 |
self.counter |
|
|
743 | self.counter_imagwr = 0 | |
|
742 | 744 | |
|
743 | 745 | def getSubplots(self): |
|
744 | 746 | ncol = 1 |
|
745 | 747 | nrow = self.nplots*2 |
|
746 | 748 | |
|
747 | 749 | return nrow, ncol |
|
748 | 750 | |
|
749 |
def setup(self, id |
|
|
751 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
|
750 | 752 | self.__showprofile = showprofile |
|
751 | 753 | self.nplots = nplots |
|
752 | 754 | |
|
753 | 755 | ncolspan = 1 |
|
754 | 756 | colspan = 1 |
|
755 | 757 | if showprofile: |
|
756 | 758 | ncolspan = 7 |
|
757 | 759 | colspan = 6 |
|
758 | 760 | self.__nsubplots = 2 |
|
759 | 761 | |
|
760 |
self.createFigure(id |
|
|
762 | self.createFigure(id = id, | |
|
761 | 763 | wintitle = wintitle, |
|
762 | 764 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
763 | 765 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
764 | 766 | show=True) |
|
765 | 767 | |
|
766 | 768 | nrow, ncol = self.getSubplots() |
|
767 | 769 | |
|
768 | 770 | for y in range(nrow): |
|
769 | 771 | for x in range(ncol): |
|
770 | 772 | |
|
771 | 773 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
772 | 774 | |
|
773 | 775 | if showprofile: |
|
774 | 776 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
775 | 777 | |
|
776 |
def run(self, dataOut, id |
|
|
778 | def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True', | |
|
777 | 779 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
778 | 780 | timerange=None, |
|
779 |
save=False, figpath='./', figfile=None, ftp=False, |
|
|
781 | save=False, figpath='./', figfile=None, ftp=False, res_imagwr=1, | |
|
780 | 782 | coherence_cmap='jet', phase_cmap='RdBu_r', show=True): |
|
781 | 783 | |
|
782 | 784 | if pairsList == None: |
|
783 | 785 | pairsIndexList = dataOut.pairsIndexList |
|
784 | 786 | else: |
|
785 | 787 | pairsIndexList = [] |
|
786 | 788 | for pair in pairsList: |
|
787 | 789 | if pair not in dataOut.pairsList: |
|
788 | 790 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) |
|
789 | 791 | pairsIndexList.append(dataOut.pairsList.index(pair)) |
|
790 | 792 | |
|
791 | 793 | if timerange != None: |
|
792 | 794 | self.timerange = timerange |
|
793 | 795 | |
|
794 | 796 | if pairsIndexList == []: |
|
795 | 797 | return |
|
796 | 798 | |
|
797 | 799 | if len(pairsIndexList) > 4: |
|
798 | 800 | pairsIndexList = pairsIndexList[0:4] |
|
799 | 801 | |
|
800 | 802 | tmin = None |
|
801 | 803 | tmax = None |
|
802 | 804 | x = dataOut.getTimeRange() |
|
803 | 805 | y = dataOut.getHeiRange() |
|
804 | 806 | |
|
805 | 807 | #thisDatetime = dataOut.datatime |
|
806 | 808 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) |
|
807 | 809 | title = wintitle + " CoherenceMap: %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
808 | 810 | xlabel = "" |
|
809 | 811 | ylabel = "Range (Km)" |
|
810 | 812 | |
|
811 | 813 | if not self.__isConfig: |
|
812 | 814 | nplots = len(pairsIndexList) |
|
813 |
self.setup(id |
|
|
815 | self.setup(id=id, | |
|
814 | 816 | nplots=nplots, |
|
815 | 817 | wintitle=wintitle, |
|
816 | 818 | showprofile=showprofile, |
|
817 | 819 | show=show) |
|
818 | 820 | |
|
819 | 821 | tmin, tmax = self.getTimeLim(x, xmin, xmax) |
|
820 | 822 | if ymin == None: ymin = numpy.nanmin(y) |
|
821 | 823 | if ymax == None: ymax = numpy.nanmax(y) |
|
822 | 824 | |
|
823 | 825 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
824 | 826 | |
|
825 | 827 | self.__isConfig = True |
|
826 | 828 | |
|
827 | 829 | self.setWinTitle(title) |
|
828 | 830 | |
|
829 | 831 | for i in range(self.nplots): |
|
830 | 832 | |
|
831 | 833 | pair = dataOut.pairsList[pairsIndexList[i]] |
|
832 | 834 | coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:]) |
|
833 | 835 | avgcoherenceComplex = numpy.average(coherenceComplex, axis=0) |
|
834 | 836 | coherence = numpy.abs(avgcoherenceComplex) |
|
835 | 837 | # coherence = numpy.abs(coherenceComplex) |
|
836 | 838 | # avg = numpy.average(coherence, axis=0) |
|
837 | 839 | |
|
838 | 840 | z = coherence.reshape((1,-1)) |
|
839 | 841 | |
|
840 | 842 | counter = 0 |
|
841 | 843 | |
|
842 | 844 | title = "Coherence %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
843 | 845 | axes = self.axesList[i*self.__nsubplots*2] |
|
844 | 846 | axes.pcolorbuffer(x, y, z, |
|
845 | 847 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1, |
|
846 | 848 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
847 | 849 | ticksize=9, cblabel='', colormap=coherence_cmap, cbsize="1%") |
|
848 | 850 | |
|
849 | 851 | if self.__showprofile: |
|
850 | 852 | counter += 1 |
|
851 | 853 | axes = self.axesList[i*self.__nsubplots*2 + counter] |
|
852 | 854 | axes.pline(coherence, y, |
|
853 | 855 | xmin=0, xmax=1, ymin=ymin, ymax=ymax, |
|
854 | 856 | xlabel='', ylabel='', title='', ticksize=7, |
|
855 | 857 | ytick_visible=False, nxticks=5, |
|
856 | 858 | grid='x') |
|
857 | 859 | |
|
858 | 860 | counter += 1 |
|
859 | 861 | # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi |
|
860 | 862 | phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi |
|
861 | 863 | # avg = numpy.average(phase, axis=0) |
|
862 | 864 | z = phase.reshape((1,-1)) |
|
863 | 865 | |
|
864 | 866 | title = "Phase %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
865 | 867 | axes = self.axesList[i*self.__nsubplots*2 + counter] |
|
866 | 868 | axes.pcolorbuffer(x, y, z, |
|
867 | 869 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180, |
|
868 | 870 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
869 | 871 | ticksize=9, cblabel='', colormap=phase_cmap, cbsize="1%") |
|
870 | 872 | |
|
871 | 873 | if self.__showprofile: |
|
872 | 874 | counter += 1 |
|
873 | 875 | axes = self.axesList[i*self.__nsubplots*2 + counter] |
|
874 | 876 | axes.pline(phase, y, |
|
875 | 877 | xmin=-180, xmax=180, ymin=ymin, ymax=ymax, |
|
876 | 878 | xlabel='', ylabel='', title='', ticksize=7, |
|
877 | 879 | ytick_visible=False, nxticks=4, |
|
878 | 880 | grid='x') |
|
879 | 881 | |
|
880 | 882 | self.draw() |
|
881 | 883 | |
|
882 | 884 | if save: |
|
883 | 885 | |
|
884 | if figfile == None: | |
|
885 | figfile = self.getFilename(name = self.name) | |
|
886 | ||
|
887 | self.saveFigure(figpath, figfile) | |
|
888 | ||
|
889 | self.counterftp += 1 | |
|
890 | if (ftp and (self.counterftp==ftpratio)): | |
|
891 | figfilename = os.path.join(figpath,figfile) | |
|
892 | self.sendByFTP(figfilename) | |
|
893 |
self.counter |
|
|
886 | self.counter_imagwr += 1 | |
|
887 | if (self.counter_imagwr==res_imagwr): | |
|
888 | fig_file = self.getFilename(name = self.name) | |
|
889 | self.saveFigure(figpath, fig_file) | |
|
890 | if ftp: | |
|
891 | self.saveFigure(figpath, figfile) | |
|
892 | figfilename = os.path.join(figpath,figfile) | |
|
893 | self.sendByFTP(figfilename) | |
|
894 | ||
|
895 | self.counter_imagwr = 0 | |
|
894 | 896 | |
|
895 | 897 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: |
|
896 | 898 | self.__isConfig = False |
|
897 | 899 | |
|
898 | 900 | class RTIfromNoise(Figure): |
|
899 | 901 | |
|
900 | 902 | __isConfig = None |
|
901 | 903 | __nsubplots = None |
|
902 | 904 | |
|
903 | 905 | PREFIX = 'rtinoise' |
|
904 | 906 | |
|
905 | 907 | def __init__(self): |
|
906 | 908 | |
|
907 | 909 | self.timerange = 24*60*60 |
|
908 | 910 | self.__isConfig = False |
|
909 | 911 | self.__nsubplots = 1 |
|
910 | 912 | |
|
911 | 913 | self.WIDTH = 820 |
|
912 | 914 | self.HEIGHT = 200 |
|
913 | 915 | self.WIDTHPROF = 120 |
|
914 | 916 | self.HEIGHTPROF = 0 |
|
915 | 917 | self.xdata = None |
|
916 | 918 | self.ydata = None |
|
917 | 919 | |
|
918 | 920 | def getSubplots(self): |
|
919 | 921 | |
|
920 | 922 | ncol = 1 |
|
921 | 923 | nrow = 1 |
|
922 | 924 | |
|
923 | 925 | return nrow, ncol |
|
924 | 926 | |
|
925 |
def setup(self, id |
|
|
927 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
|
926 | 928 | |
|
927 | 929 | self.__showprofile = showprofile |
|
928 | 930 | self.nplots = nplots |
|
929 | 931 | |
|
930 | 932 | ncolspan = 7 |
|
931 | 933 | colspan = 6 |
|
932 | 934 | self.__nsubplots = 2 |
|
933 | 935 | |
|
934 |
self.createFigure(id |
|
|
936 | self.createFigure(id = id, | |
|
935 | 937 | wintitle = wintitle, |
|
936 | 938 | widthplot = self.WIDTH+self.WIDTHPROF, |
|
937 | 939 | heightplot = self.HEIGHT+self.HEIGHTPROF, |
|
938 | 940 | show=show) |
|
939 | 941 | |
|
940 | 942 | nrow, ncol = self.getSubplots() |
|
941 | 943 | |
|
942 | 944 | self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1) |
|
943 | 945 | |
|
944 | 946 | |
|
945 |
def run(self, dataOut, id |
|
|
947 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True', | |
|
946 | 948 | xmin=None, xmax=None, ymin=None, ymax=None, |
|
947 | 949 | timerange=None, |
|
948 | 950 | save=False, figpath='./', figfile=None, show=True): |
|
949 | 951 | |
|
950 | 952 | if channelList == None: |
|
951 | 953 | channelIndexList = dataOut.channelIndexList |
|
952 | 954 | channelList = dataOut.channelList |
|
953 | 955 | else: |
|
954 | 956 | channelIndexList = [] |
|
955 | 957 | for channel in channelList: |
|
956 | 958 | if channel not in dataOut.channelList: |
|
957 | 959 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
958 | 960 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
959 | 961 | |
|
960 | 962 | if timerange != None: |
|
961 | 963 | self.timerange = timerange |
|
962 | 964 | |
|
963 | 965 | tmin = None |
|
964 | 966 | tmax = None |
|
965 | 967 | x = dataOut.getTimeRange() |
|
966 | 968 | y = dataOut.getHeiRange() |
|
967 | 969 | factor = dataOut.normFactor |
|
968 | 970 | noise = dataOut.getNoise()/factor |
|
969 | 971 | noisedB = 10*numpy.log10(noise) |
|
970 | 972 | |
|
971 | 973 | #thisDatetime = dataOut.datatime |
|
972 | 974 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) |
|
973 | 975 | title = wintitle + " RTI Noise: %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
974 | 976 | xlabel = "" |
|
975 | 977 | ylabel = "Range (Km)" |
|
976 | 978 | |
|
977 | 979 | if not self.__isConfig: |
|
978 | 980 | |
|
979 | 981 | nplots = 1 |
|
980 | 982 | |
|
981 |
self.setup(id |
|
|
983 | self.setup(id=id, | |
|
982 | 984 | nplots=nplots, |
|
983 | 985 | wintitle=wintitle, |
|
984 | 986 | showprofile=showprofile, |
|
985 | 987 | show=show) |
|
986 | 988 | |
|
987 | 989 | tmin, tmax = self.getTimeLim(x, xmin, xmax) |
|
988 | 990 | if ymin == None: ymin = numpy.nanmin(noisedB) |
|
989 | 991 | if ymax == None: ymax = numpy.nanmax(noisedB) |
|
990 | 992 | |
|
991 | 993 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
992 | 994 | self.__isConfig = True |
|
993 | 995 | |
|
994 | 996 | self.xdata = numpy.array([]) |
|
995 | 997 | self.ydata = numpy.array([]) |
|
996 | 998 | |
|
997 | 999 | self.setWinTitle(title) |
|
998 | 1000 | |
|
999 | 1001 | |
|
1000 | 1002 | title = "RTI Noise %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
1001 | 1003 | |
|
1002 | 1004 | legendlabels = ["channel %d"%idchannel for idchannel in channelList] |
|
1003 | 1005 | axes = self.axesList[0] |
|
1004 | 1006 | |
|
1005 | 1007 | self.xdata = numpy.hstack((self.xdata, x[0:1])) |
|
1006 | 1008 | |
|
1007 | 1009 | if len(self.ydata)==0: |
|
1008 | 1010 | self.ydata = noisedB[channelIndexList].reshape(-1,1) |
|
1009 | 1011 | else: |
|
1010 | 1012 | self.ydata = numpy.hstack((self.ydata, noisedB[channelIndexList].reshape(-1,1))) |
|
1011 | 1013 | |
|
1012 | 1014 | |
|
1013 | 1015 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, |
|
1014 | 1016 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, |
|
1015 | 1017 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid", |
|
1016 | 1018 | XAxisAsTime=True |
|
1017 | 1019 | ) |
|
1018 | 1020 | |
|
1019 | 1021 | self.draw() |
|
1020 | 1022 | |
|
1021 | 1023 | if save: |
|
1022 | 1024 | |
|
1023 | 1025 | if figfile == None: |
|
1024 | 1026 | figfile = self.getFilename(name = self.name) |
|
1025 | 1027 | |
|
1026 | 1028 | self.saveFigure(figpath, figfile) |
|
1027 | 1029 | |
|
1028 | 1030 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: |
|
1029 | 1031 | self.__isConfig = False |
|
1030 | 1032 | del self.xdata |
|
1031 | 1033 | del self.ydata |
|
1032 | 1034 | |
|
1033 | 1035 | |
|
1034 | 1036 | class SpectraHeisScope(Figure): |
|
1035 | 1037 | |
|
1036 | 1038 | |
|
1037 | 1039 | __isConfig = None |
|
1038 | 1040 | __nsubplots = None |
|
1039 | 1041 | |
|
1040 | 1042 | WIDTHPROF = None |
|
1041 | 1043 | HEIGHTPROF = None |
|
1042 | 1044 | PREFIX = 'spc' |
|
1043 | 1045 | |
|
1044 | 1046 | def __init__(self): |
|
1045 | 1047 | |
|
1046 | 1048 | self.__isConfig = False |
|
1047 | 1049 | self.__nsubplots = 1 |
|
1048 | 1050 | |
|
1049 | 1051 | self.WIDTH = 230 |
|
1050 | 1052 | self.HEIGHT = 250 |
|
1051 | 1053 | self.WIDTHPROF = 120 |
|
1052 | 1054 | self.HEIGHTPROF = 0 |
|
1053 |
self.counter |
|
|
1055 | self.counter_imagwr = 0 | |
|
1054 | 1056 | |
|
1055 | 1057 | def getSubplots(self): |
|
1056 | 1058 | |
|
1057 | 1059 | ncol = int(numpy.sqrt(self.nplots)+0.9) |
|
1058 | 1060 | nrow = int(self.nplots*1./ncol + 0.9) |
|
1059 | 1061 | |
|
1060 | 1062 | return nrow, ncol |
|
1061 | 1063 | |
|
1062 |
def setup(self, id |
|
|
1064 | def setup(self, id, nplots, wintitle, show): | |
|
1063 | 1065 | |
|
1064 | 1066 | showprofile = False |
|
1065 | 1067 | self.__showprofile = showprofile |
|
1066 | 1068 | self.nplots = nplots |
|
1067 | 1069 | |
|
1068 | 1070 | ncolspan = 1 |
|
1069 | 1071 | colspan = 1 |
|
1070 | 1072 | if showprofile: |
|
1071 | 1073 | ncolspan = 3 |
|
1072 | 1074 | colspan = 2 |
|
1073 | 1075 | self.__nsubplots = 2 |
|
1074 | 1076 | |
|
1075 |
self.createFigure(id |
|
|
1077 | self.createFigure(id = id, | |
|
1076 | 1078 | wintitle = wintitle, |
|
1077 | 1079 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
1078 | 1080 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
1079 | 1081 | show = show) |
|
1080 | 1082 | |
|
1081 | 1083 | nrow, ncol = self.getSubplots() |
|
1082 | 1084 | |
|
1083 | 1085 | counter = 0 |
|
1084 | 1086 | for y in range(nrow): |
|
1085 | 1087 | for x in range(ncol): |
|
1086 | 1088 | |
|
1087 | 1089 | if counter >= self.nplots: |
|
1088 | 1090 | break |
|
1089 | 1091 | |
|
1090 | 1092 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
1091 | 1093 | |
|
1092 | 1094 | if showprofile: |
|
1093 | 1095 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
1094 | 1096 | |
|
1095 | 1097 | counter += 1 |
|
1096 | 1098 | |
|
1097 | 1099 | # __isConfig = None |
|
1098 | 1100 | # def __init__(self): |
|
1099 | 1101 | # |
|
1100 | 1102 | # self.__isConfig = False |
|
1101 | 1103 | # self.WIDTH = 600 |
|
1102 | 1104 | # self.HEIGHT = 200 |
|
1103 | 1105 | # |
|
1104 | 1106 | # def getSubplots(self): |
|
1105 | 1107 | # |
|
1106 | 1108 | # nrow = self.nplots |
|
1107 | 1109 | # ncol = 3 |
|
1108 | 1110 | # return nrow, ncol |
|
1109 | 1111 | # |
|
1110 |
# def setup(self, id |
|
|
1112 | # def setup(self, id, nplots, wintitle): | |
|
1111 | 1113 | # |
|
1112 | 1114 | # self.nplots = nplots |
|
1113 | 1115 | # |
|
1114 |
# self.createFigure(id |
|
|
1116 | # self.createFigure(id, wintitle) | |
|
1115 | 1117 | # |
|
1116 | 1118 | # nrow,ncol = self.getSubplots() |
|
1117 | 1119 | # colspan = 3 |
|
1118 | 1120 | # rowspan = 1 |
|
1119 | 1121 | # |
|
1120 | 1122 | # for i in range(nplots): |
|
1121 | 1123 | # self.addAxes(nrow, ncol, i, 0, colspan, rowspan) |
|
1122 | 1124 | |
|
1123 |
def run(self, dataOut, id |
|
|
1125 | def run(self, dataOut, id, wintitle="", channelList=None, | |
|
1124 | 1126 | xmin=None, xmax=None, ymin=None, ymax=None, save=False, |
|
1125 |
figpath='./', figfile=None, ftp=False, |
|
|
1127 | figpath='./', figfile=None, ftp=False, res_imagwr=1, show=True): | |
|
1126 | 1128 | |
|
1127 | 1129 | """ |
|
1128 | 1130 | |
|
1129 | 1131 | Input: |
|
1130 | 1132 | dataOut : |
|
1131 |
id |
|
|
1133 | id : | |
|
1132 | 1134 | wintitle : |
|
1133 | 1135 | channelList : |
|
1134 | 1136 | xmin : None, |
|
1135 | 1137 | xmax : None, |
|
1136 | 1138 | ymin : None, |
|
1137 | 1139 | ymax : None, |
|
1138 | 1140 | """ |
|
1139 | 1141 | |
|
1140 | 1142 | if dataOut.realtime: |
|
1141 | 1143 | if not(isRealtime(utcdatatime = dataOut.utctime)): |
|
1142 | 1144 | print 'Skipping this plot function' |
|
1143 | 1145 | return |
|
1144 | 1146 | |
|
1145 | 1147 | if channelList == None: |
|
1146 | 1148 | channelIndexList = dataOut.channelIndexList |
|
1147 | 1149 | else: |
|
1148 | 1150 | channelIndexList = [] |
|
1149 | 1151 | for channel in channelList: |
|
1150 | 1152 | if channel not in dataOut.channelList: |
|
1151 | 1153 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
1152 | 1154 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
1153 | 1155 | |
|
1154 | 1156 | # x = dataOut.heightList |
|
1155 | 1157 | c = 3E8 |
|
1156 | 1158 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] |
|
1157 | 1159 | #deberia cambiar para el caso de 1Mhz y 100KHz |
|
1158 | 1160 | x = numpy.arange(-1*dataOut.nHeights/2.,dataOut.nHeights/2.)*(c/(2*deltaHeight*dataOut.nHeights*1000)) |
|
1159 | 1161 | x= x/(10000.0) |
|
1160 | 1162 | # y = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:]) |
|
1161 | 1163 | # y = y.real |
|
1162 | 1164 | datadB = 10.*numpy.log10(dataOut.data_spc) |
|
1163 | 1165 | y = datadB |
|
1164 | 1166 | |
|
1165 | 1167 | #thisDatetime = dataOut.datatime |
|
1166 | 1168 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) |
|
1167 | 1169 | title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
1168 | 1170 | xlabel = "Frequency x 10000" |
|
1169 | 1171 | ylabel = "Intensity (dB)" |
|
1170 | 1172 | |
|
1171 | 1173 | if not self.__isConfig: |
|
1172 | 1174 | nplots = len(channelIndexList) |
|
1173 | 1175 | |
|
1174 |
self.setup(id |
|
|
1176 | self.setup(id=id, | |
|
1175 | 1177 | nplots=nplots, |
|
1176 | 1178 | wintitle=wintitle, |
|
1177 | 1179 | show=show) |
|
1178 | 1180 | |
|
1179 | 1181 | if xmin == None: xmin = numpy.nanmin(x) |
|
1180 | 1182 | if xmax == None: xmax = numpy.nanmax(x) |
|
1181 | 1183 | if ymin == None: ymin = numpy.nanmin(y) |
|
1182 | 1184 | if ymax == None: ymax = numpy.nanmax(y) |
|
1183 | 1185 | |
|
1184 | 1186 | self.__isConfig = True |
|
1185 | 1187 | |
|
1186 | 1188 | self.setWinTitle(title) |
|
1187 | 1189 | |
|
1188 | 1190 | for i in range(len(self.axesList)): |
|
1189 | 1191 | ychannel = y[i,:] |
|
1190 | 1192 | title = "Channel %d - peak:%.2f" %(i,numpy.max(ychannel)) |
|
1191 | 1193 | axes = self.axesList[i] |
|
1192 | 1194 | axes.pline(x, ychannel, |
|
1193 | 1195 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, |
|
1194 | 1196 | xlabel=xlabel, ylabel=ylabel, title=title, grid='both') |
|
1195 | 1197 | |
|
1196 | 1198 | |
|
1197 | 1199 | self.draw() |
|
1198 | 1200 | |
|
1199 | 1201 | if save: |
|
1200 | 1202 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
1201 | 1203 | if figfile == None: |
|
1202 | 1204 | figfile = self.getFilename(name = date) |
|
1203 | 1205 | |
|
1204 | 1206 | self.saveFigure(figpath, figfile) |
|
1205 | 1207 | |
|
1206 |
self.counter |
|
|
1207 |
if (ftp and (self.counter |
|
|
1208 | self.counter_imagwr += 1 | |
|
1209 | if (ftp and (self.counter_imagwr==res_imagwr)): | |
|
1208 | 1210 | figfilename = os.path.join(figpath,figfile) |
|
1209 | 1211 | self.sendByFTP(figfilename) |
|
1210 |
self.counter |
|
|
1212 | self.counter_imagwr = 0 | |
|
1211 | 1213 | |
|
1212 | 1214 | |
|
1213 | 1215 | class RTIfromSpectraHeis(Figure): |
|
1214 | 1216 | |
|
1215 | 1217 | __isConfig = None |
|
1216 | 1218 | __nsubplots = None |
|
1217 | 1219 | |
|
1218 | 1220 | PREFIX = 'rtinoise' |
|
1219 | 1221 | |
|
1220 | 1222 | def __init__(self): |
|
1221 | 1223 | |
|
1222 | 1224 | self.timerange = 24*60*60 |
|
1223 | 1225 | self.__isConfig = False |
|
1224 | 1226 | self.__nsubplots = 1 |
|
1225 | 1227 | |
|
1226 | 1228 | self.WIDTH = 820 |
|
1227 | 1229 | self.HEIGHT = 200 |
|
1228 | 1230 | self.WIDTHPROF = 120 |
|
1229 | 1231 | self.HEIGHTPROF = 0 |
|
1230 |
self.counter |
|
|
1232 | self.counter_imagwr = 0 | |
|
1231 | 1233 | self.xdata = None |
|
1232 | 1234 | self.ydata = None |
|
1233 | 1235 | |
|
1234 | 1236 | def getSubplots(self): |
|
1235 | 1237 | |
|
1236 | 1238 | ncol = 1 |
|
1237 | 1239 | nrow = 1 |
|
1238 | 1240 | |
|
1239 | 1241 | return nrow, ncol |
|
1240 | 1242 | |
|
1241 |
def setup(self, id |
|
|
1243 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
|
1242 | 1244 | |
|
1243 | 1245 | self.__showprofile = showprofile |
|
1244 | 1246 | self.nplots = nplots |
|
1245 | 1247 | |
|
1246 | 1248 | ncolspan = 7 |
|
1247 | 1249 | colspan = 6 |
|
1248 | 1250 | self.__nsubplots = 2 |
|
1249 | 1251 | |
|
1250 |
self.createFigure(id |
|
|
1252 | self.createFigure(id = id, | |
|
1251 | 1253 | wintitle = wintitle, |
|
1252 | 1254 | widthplot = self.WIDTH+self.WIDTHPROF, |
|
1253 | 1255 | heightplot = self.HEIGHT+self.HEIGHTPROF, |
|
1254 | 1256 | show = show) |
|
1255 | 1257 | |
|
1256 | 1258 | nrow, ncol = self.getSubplots() |
|
1257 | 1259 | |
|
1258 | 1260 | self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1) |
|
1259 | 1261 | |
|
1260 | 1262 | |
|
1261 |
def run(self, dataOut, id |
|
|
1263 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True', | |
|
1262 | 1264 | xmin=None, xmax=None, ymin=None, ymax=None, |
|
1263 | 1265 | timerange=None, |
|
1264 |
save=False, figpath='./', figfile=None, ftp=False, |
|
|
1266 | save=False, figpath='./', figfile=None, ftp=False, res_imagwr=1, show=True): | |
|
1265 | 1267 | |
|
1266 | 1268 | if channelList == None: |
|
1267 | 1269 | channelIndexList = dataOut.channelIndexList |
|
1268 | 1270 | channelList = dataOut.channelList |
|
1269 | 1271 | else: |
|
1270 | 1272 | channelIndexList = [] |
|
1271 | 1273 | for channel in channelList: |
|
1272 | 1274 | if channel not in dataOut.channelList: |
|
1273 | 1275 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
1274 | 1276 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
1275 | 1277 | |
|
1276 | 1278 | if timerange != None: |
|
1277 | 1279 | self.timerange = timerange |
|
1278 | 1280 | |
|
1279 | 1281 | tmin = None |
|
1280 | 1282 | tmax = None |
|
1281 | 1283 | x = dataOut.getTimeRange() |
|
1282 | 1284 | y = dataOut.getHeiRange() |
|
1283 | 1285 | |
|
1284 | 1286 | factor = 1 |
|
1285 | 1287 | data = dataOut.data_spc/factor |
|
1286 | 1288 | data = numpy.average(data,axis=1) |
|
1287 | 1289 | datadB = 10*numpy.log10(data) |
|
1288 | 1290 | |
|
1289 | 1291 | # factor = dataOut.normFactor |
|
1290 | 1292 | # noise = dataOut.getNoise()/factor |
|
1291 | 1293 | # noisedB = 10*numpy.log10(noise) |
|
1292 | 1294 | |
|
1293 | 1295 | #thisDatetime = dataOut.datatime |
|
1294 | 1296 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) |
|
1295 | 1297 | title = wintitle + " RTI: %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
1296 | 1298 | xlabel = "Local Time" |
|
1297 | 1299 | ylabel = "Intensity (dB)" |
|
1298 | 1300 | |
|
1299 | 1301 | if not self.__isConfig: |
|
1300 | 1302 | |
|
1301 | 1303 | nplots = 1 |
|
1302 | 1304 | |
|
1303 |
self.setup(id |
|
|
1305 | self.setup(id=id, | |
|
1304 | 1306 | nplots=nplots, |
|
1305 | 1307 | wintitle=wintitle, |
|
1306 | 1308 | showprofile=showprofile, |
|
1307 | 1309 | show=show) |
|
1308 | 1310 | |
|
1309 | 1311 | tmin, tmax = self.getTimeLim(x, xmin, xmax) |
|
1310 | 1312 | if ymin == None: ymin = numpy.nanmin(datadB) |
|
1311 | 1313 | if ymax == None: ymax = numpy.nanmax(datadB) |
|
1312 | 1314 | |
|
1313 | 1315 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
1314 | 1316 | self.__isConfig = True |
|
1315 | 1317 | |
|
1316 | 1318 | self.xdata = numpy.array([]) |
|
1317 | 1319 | self.ydata = numpy.array([]) |
|
1318 | 1320 | |
|
1319 | 1321 | self.setWinTitle(title) |
|
1320 | 1322 | |
|
1321 | 1323 | |
|
1322 | 1324 | # title = "RTI %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
1323 | 1325 | title = "RTI-Noise - %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
1324 | 1326 | |
|
1325 | 1327 | legendlabels = ["channel %d"%idchannel for idchannel in channelList] |
|
1326 | 1328 | axes = self.axesList[0] |
|
1327 | 1329 | |
|
1328 | 1330 | self.xdata = numpy.hstack((self.xdata, x[0:1])) |
|
1329 | 1331 | |
|
1330 | 1332 | if len(self.ydata)==0: |
|
1331 | 1333 | self.ydata = datadB[channelIndexList].reshape(-1,1) |
|
1332 | 1334 | else: |
|
1333 | 1335 | self.ydata = numpy.hstack((self.ydata, datadB[channelIndexList].reshape(-1,1))) |
|
1334 | 1336 | |
|
1335 | 1337 | |
|
1336 | 1338 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, |
|
1337 | 1339 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, |
|
1338 | 1340 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='.', markersize=8, linestyle="solid", grid='both', |
|
1339 | 1341 | XAxisAsTime=True |
|
1340 | 1342 | ) |
|
1341 | 1343 | |
|
1342 | 1344 | self.draw() |
|
1343 | 1345 | |
|
1344 | 1346 | if save: |
|
1345 | 1347 | |
|
1346 | 1348 | if figfile == None: |
|
1347 | 1349 | figfile = self.getFilename(name = self.name) |
|
1348 | 1350 | |
|
1349 | 1351 | self.saveFigure(figpath, figfile) |
|
1350 | 1352 | |
|
1351 |
self.counter |
|
|
1352 |
if (ftp and (self.counter |
|
|
1353 | self.counter_imagwr += 1 | |
|
1354 | if (ftp and (self.counter_imagwr==res_imagwr)): | |
|
1353 | 1355 | figfilename = os.path.join(figpath,figfile) |
|
1354 | 1356 | self.sendByFTP(figfilename) |
|
1355 |
self.counter |
|
|
1357 | self.counter_imagwr = 0 | |
|
1356 | 1358 | |
|
1357 | 1359 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: |
|
1358 | 1360 | self.__isConfig = False |
|
1359 | 1361 | del self.xdata |
|
1360 | 1362 | del self.ydata |
|
1361 | 1363 | |
|
1362 | 1364 | |
|
1363 | 1365 | No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now