@@ -1,519 +1,521 | |||
|
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 | 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 | 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 | 85 | def init(self, id, nplots, wintitle): |
|
86 | 86 | |
|
87 | 87 | raise ValueError, "This method has been replaced with createFigure" |
|
88 | 88 | |
|
89 | 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 | 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 | 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 | 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 | decimationx = None | |
|
208 | decimationy = None | |
|
209 | ||
|
207 | 210 | __MAXNUMX = 1000 |
|
208 | 211 | __MAXNUMY = 500 |
|
209 | 212 | |
|
210 | 213 | def __init__(self, *args): |
|
211 | 214 | |
|
212 | 215 | """ |
|
213 | 216 | |
|
214 | 217 | Input: |
|
215 | 218 | *args : Los parametros necesarios son |
|
216 | 219 | fig, nrow, ncol, xpos, ypos, colspan, rowspan |
|
217 | 220 | """ |
|
218 | 221 | |
|
219 | 222 | ax = self.__driver.createAxes(*args) |
|
220 | 223 | self.fig = args[0] |
|
221 | 224 | self.ax = ax |
|
222 | 225 | self.plot = None |
|
223 | 226 | |
|
224 | 227 | self.__firsttime = True |
|
225 | 228 | self.idlineList = [] |
|
226 | 229 | |
|
227 | 230 | self.x_buffer = numpy.array([]) |
|
228 | 231 | self.z_buffer = numpy.array([]) |
|
229 | 232 | |
|
230 | 233 | def setText(self, text): |
|
231 | 234 | |
|
232 | 235 | self.__driver.setAxesText(self.ax, text) |
|
233 | 236 | |
|
234 | 237 | def setXAxisAsTime(self): |
|
235 | 238 | pass |
|
236 | 239 | |
|
237 | 240 | def pline(self, x, y, |
|
238 | 241 | xmin=None, xmax=None, |
|
239 | 242 | ymin=None, ymax=None, |
|
240 | 243 | xlabel='', ylabel='', |
|
241 | 244 | title='', |
|
242 | 245 | **kwargs): |
|
243 | 246 | |
|
244 | 247 | """ |
|
245 | 248 | |
|
246 | 249 | Input: |
|
247 | 250 | x : |
|
248 | 251 | y : |
|
249 | 252 | xmin : |
|
250 | 253 | xmax : |
|
251 | 254 | ymin : |
|
252 | 255 | ymax : |
|
253 | 256 | xlabel : |
|
254 | 257 | ylabel : |
|
255 | 258 | title : |
|
256 | 259 | **kwargs : Los parametros aceptados son |
|
257 | 260 | |
|
258 | 261 | ticksize |
|
259 | 262 | ytick_visible |
|
260 | 263 | """ |
|
261 | 264 | |
|
262 | 265 | if self.__firsttime: |
|
263 | 266 | |
|
264 | 267 | if xmin == None: xmin = numpy.nanmin(x) |
|
265 | 268 | if xmax == None: xmax = numpy.nanmax(x) |
|
266 | 269 | if ymin == None: ymin = numpy.nanmin(y) |
|
267 | 270 | if ymax == None: ymax = numpy.nanmax(y) |
|
268 | 271 | |
|
269 | 272 | self.plot = self.__driver.createPline(self.ax, x, y, |
|
270 | 273 | xmin, xmax, |
|
271 | 274 | ymin, ymax, |
|
272 | 275 | xlabel=xlabel, |
|
273 | 276 | ylabel=ylabel, |
|
274 | 277 | title=title, |
|
275 | 278 | **kwargs) |
|
276 | 279 | |
|
277 | 280 | self.idlineList.append(0) |
|
278 | 281 | self.__firsttime = False |
|
279 | 282 | return |
|
280 | 283 | |
|
281 | 284 | self.__driver.pline(self.plot, x, y, xlabel=xlabel, |
|
282 | 285 | ylabel=ylabel, |
|
283 | 286 | title=title) |
|
284 | 287 | |
|
285 | 288 | def addpline(self, x, y, idline, **kwargs): |
|
286 | 289 | lines = self.ax.lines |
|
287 | 290 | |
|
288 | 291 | if idline in self.idlineList: |
|
289 | 292 | self.__driver.set_linedata(self.ax, x, y, idline) |
|
290 | 293 | |
|
291 | 294 | if idline not in(self.idlineList): |
|
292 | 295 | self.__driver.addpline(self.ax, x, y, **kwargs) |
|
293 | 296 | self.idlineList.append(idline) |
|
294 | 297 | |
|
295 | 298 | return |
|
296 | 299 | |
|
297 | 300 | def pmultiline(self, x, y, |
|
298 | 301 | xmin=None, xmax=None, |
|
299 | 302 | ymin=None, ymax=None, |
|
300 | 303 | xlabel='', ylabel='', |
|
301 | 304 | title='', |
|
302 | 305 | **kwargs): |
|
303 | 306 | |
|
304 | 307 | if self.__firsttime: |
|
305 | 308 | |
|
306 | 309 | if xmin == None: xmin = numpy.nanmin(x) |
|
307 | 310 | if xmax == None: xmax = numpy.nanmax(x) |
|
308 | 311 | if ymin == None: ymin = numpy.nanmin(y) |
|
309 | 312 | if ymax == None: ymax = numpy.nanmax(y) |
|
310 | 313 | |
|
311 | 314 | self.plot = self.__driver.createPmultiline(self.ax, x, y, |
|
312 | 315 | xmin, xmax, |
|
313 | 316 | ymin, ymax, |
|
314 | 317 | xlabel=xlabel, |
|
315 | 318 | ylabel=ylabel, |
|
316 | 319 | title=title, |
|
317 | 320 | **kwargs) |
|
318 | 321 | self.__firsttime = False |
|
319 | 322 | return |
|
320 | 323 | |
|
321 | 324 | self.__driver.pmultiline(self.plot, x, y, xlabel=xlabel, |
|
322 | 325 | ylabel=ylabel, |
|
323 | 326 | title=title) |
|
324 | 327 | |
|
325 | 328 | def pmultilineyaxis(self, x, y, |
|
326 | 329 | xmin=None, xmax=None, |
|
327 | 330 | ymin=None, ymax=None, |
|
328 | 331 | xlabel='', ylabel='', |
|
329 | 332 | title='', |
|
330 | 333 | **kwargs): |
|
331 | 334 | |
|
332 | 335 | if self.__firsttime: |
|
333 | 336 | |
|
334 | 337 | if xmin == None: xmin = numpy.nanmin(x) |
|
335 | 338 | if xmax == None: xmax = numpy.nanmax(x) |
|
336 | 339 | if ymin == None: ymin = numpy.nanmin(y) |
|
337 | 340 | if ymax == None: ymax = numpy.nanmax(y) |
|
338 | 341 | |
|
339 | 342 | self.plot = self.__driver.createPmultilineYAxis(self.ax, x, y, |
|
340 | 343 | xmin, xmax, |
|
341 | 344 | ymin, ymax, |
|
342 | 345 | xlabel=xlabel, |
|
343 | 346 | ylabel=ylabel, |
|
344 | 347 | title=title, |
|
345 | 348 | **kwargs) |
|
346 | 349 | if self.xmin == None: self.xmin = xmin |
|
347 | 350 | if self.xmax == None: self.xmax = xmax |
|
348 | 351 | if self.ymin == None: self.ymin = ymin |
|
349 | 352 | if self.ymax == None: self.ymax = ymax |
|
350 | 353 | |
|
351 | 354 | self.__firsttime = False |
|
352 | 355 | return |
|
353 | 356 | |
|
354 | 357 | self.__driver.pmultilineyaxis(self.plot, x, y, xlabel=xlabel, |
|
355 | 358 | ylabel=ylabel, |
|
356 | 359 | title=title) |
|
357 | 360 | |
|
358 | 361 | def pcolor(self, x, y, z, |
|
359 | 362 | xmin=None, xmax=None, |
|
360 | 363 | ymin=None, ymax=None, |
|
361 | 364 | zmin=None, zmax=None, |
|
362 | 365 | xlabel='', ylabel='', |
|
363 | 366 | title='', rti = False, colormap='jet', |
|
364 | 367 | **kwargs): |
|
365 | 368 | |
|
366 | 369 | """ |
|
367 | 370 | Input: |
|
368 | 371 | x : |
|
369 | 372 | y : |
|
370 | 373 | x : |
|
371 | 374 | xmin : |
|
372 | 375 | xmax : |
|
373 | 376 | ymin : |
|
374 | 377 | ymax : |
|
375 | 378 | zmin : |
|
376 | 379 | zmax : |
|
377 | 380 | xlabel : |
|
378 | 381 | ylabel : |
|
379 | 382 | title : |
|
380 | 383 | **kwargs : Los parametros aceptados son |
|
381 | 384 | ticksize=9, |
|
382 | 385 | cblabel='' |
|
383 | 386 | rti = True or False |
|
384 | 387 | """ |
|
385 | 388 | |
|
386 | 389 | if self.__firsttime: |
|
387 | 390 | |
|
388 | 391 | if xmin == None: xmin = numpy.nanmin(x) |
|
389 | 392 | if xmax == None: xmax = numpy.nanmax(x) |
|
390 | 393 | if ymin == None: ymin = numpy.nanmin(y) |
|
391 | 394 | if ymax == None: ymax = numpy.nanmax(y) |
|
392 | 395 | if zmin == None: zmin = numpy.nanmin(z) |
|
393 | 396 | if zmax == None: zmax = numpy.nanmax(z) |
|
394 | 397 | |
|
395 | 398 | |
|
396 | 399 | self.plot = self.__driver.createPcolor(self.ax, x, y, z, |
|
397 | 400 | xmin, xmax, |
|
398 | 401 | ymin, ymax, |
|
399 | 402 | zmin, zmax, |
|
400 | 403 | xlabel=xlabel, |
|
401 | 404 | ylabel=ylabel, |
|
402 | 405 | title=title, |
|
403 | 406 | colormap=colormap, |
|
404 | 407 | **kwargs) |
|
405 | 408 | |
|
406 | 409 | if self.xmin == None: self.xmin = xmin |
|
407 | 410 | if self.xmax == None: self.xmax = xmax |
|
408 | 411 | if self.ymin == None: self.ymin = ymin |
|
409 | 412 | if self.ymax == None: self.ymax = ymax |
|
410 | 413 | if self.zmin == None: self.zmin = zmin |
|
411 | 414 | if self.zmax == None: self.zmax = zmax |
|
412 | 415 | |
|
413 | 416 | self.__firsttime = False |
|
414 | 417 | return |
|
415 | 418 | |
|
416 | 419 | if rti: |
|
417 | 420 | self.__driver.addpcolor(self.ax, x, y, z, self.zmin, self.zmax, |
|
418 | 421 | xlabel=xlabel, |
|
419 | 422 | ylabel=ylabel, |
|
420 | 423 | title=title, |
|
421 | 424 | colormap=colormap) |
|
422 | 425 | return |
|
423 | 426 | |
|
424 | 427 | self.__driver.pcolor(self.plot, z, |
|
425 | 428 | xlabel=xlabel, |
|
426 | 429 | ylabel=ylabel, |
|
427 | 430 | title=title) |
|
428 | 431 | |
|
429 | 432 | def pcolorbuffer(self, x, y, z, |
|
430 | 433 | xmin=None, xmax=None, |
|
431 | 434 | ymin=None, ymax=None, |
|
432 | 435 | zmin=None, zmax=None, |
|
433 | 436 | xlabel='', ylabel='', |
|
434 |
title='', rti = |
|
|
437 | title='', rti = True, colormap='jet', | |
|
435 | 438 | maxNumX = None, maxNumY = None, |
|
436 | 439 | **kwargs): |
|
437 | 440 | |
|
438 | 441 | if maxNumX == None: |
|
439 | 442 | maxNumX = self.__MAXNUMX |
|
440 | 443 | |
|
441 | 444 | if maxNumY == None: |
|
442 | 445 | maxNumY = self.__MAXNUMY |
|
443 | 446 | |
|
444 | 447 | if self.__firsttime: |
|
445 | 448 | self.z_buffer = z |
|
446 | 449 | self.x_buffer = numpy.hstack((self.x_buffer, x)) |
|
447 | 450 | |
|
448 | 451 | if xmin == None: xmin = numpy.nanmin(x) |
|
449 | 452 | if xmax == None: xmax = numpy.nanmax(x) |
|
450 | 453 | if ymin == None: ymin = numpy.nanmin(y) |
|
451 | 454 | if ymax == None: ymax = numpy.nanmax(y) |
|
452 | 455 | if zmin == None: zmin = numpy.nanmin(z) |
|
453 | 456 | if zmax == None: zmax = numpy.nanmax(z) |
|
454 | 457 | |
|
455 | 458 | |
|
456 | 459 | self.plot = self.__driver.createPcolor(self.ax, self.x_buffer, y, z, |
|
457 | 460 | xmin, xmax, |
|
458 | 461 | ymin, ymax, |
|
459 | 462 | zmin, zmax, |
|
460 | 463 | xlabel=xlabel, |
|
461 | 464 | ylabel=ylabel, |
|
462 | 465 | title=title, |
|
463 | 466 | colormap=colormap, |
|
464 | 467 | **kwargs) |
|
465 | 468 | |
|
466 | 469 | if self.xmin == None: self.xmin = xmin |
|
467 | 470 | if self.xmax == None: self.xmax = xmax |
|
468 | 471 | if self.ymin == None: self.ymin = ymin |
|
469 | 472 | if self.ymax == None: self.ymax = ymax |
|
470 | 473 | if self.zmin == None: self.zmin = zmin |
|
471 | 474 | if self.zmax == None: self.zmax = zmax |
|
472 | 475 | |
|
476 | self.__firsttime = False | |
|
477 | return | |
|
473 | 478 | |
|
474 | deltax = (xmax - xmin)/maxNumX | |
|
475 | deltay = (ymax - ymin)/maxNumY | |
|
479 | self.x_buffer = numpy.hstack((self.x_buffer, x[-1])) | |
|
480 | self.z_buffer = numpy.hstack((self.z_buffer, z)) | |
|
481 | ||
|
482 | if self.decimationx == None: | |
|
483 | deltax = (self.xmax - self.xmin)/maxNumX | |
|
484 | deltay = (self.ymax - self.ymin)/maxNumY | |
|
476 | 485 | |
|
477 |
resolutionx = x[ |
|
|
486 | resolutionx = self.x_buffer[2]-self.x_buffer[0] | |
|
478 | 487 | resolutiony = y[1]-y[0] |
|
479 | 488 | |
|
480 | 489 | self.decimationx = numpy.ceil(deltax / resolutionx) |
|
481 | 490 | self.decimationy = numpy.ceil(deltay / resolutiony) |
|
482 | ||
|
483 | self.__firsttime = False | |
|
484 | return | |
|
485 | 491 | |
|
486 | if rti: | |
|
487 | if x[0]>self.x_buffer[-1]: | |
|
488 | gap = z.copy() | |
|
489 | gap[:] = self.__missing | |
|
490 | self.z_buffer = numpy.hstack((self.z_buffer, gap)) | |
|
491 | self.z_buffer = numpy.ma.masked_inside(self.z_buffer,0.99*self.__missing,1.01*self.__missing) | |
|
492 | self.x_buffer = numpy.hstack((self.x_buffer, x)) | |
|
493 | ||
|
494 |
|
|
|
495 | self.x_buffer = numpy.hstack((self.x_buffer, x[-1])) | |
|
496 | ||
|
497 | self.z_buffer = numpy.hstack((self.z_buffer, z)) | |
|
498 | ||
|
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) | |
|
502 | ||
|
503 | x_buffer = self.x_buffer[::self.decimationx] | |
|
504 | y_buffer = y[::self.decimationy] | |
|
505 | z_buffer = z_buffer[::self.decimationx, ::self.decimationy] | |
|
506 | #=================================================== | |
|
507 | ||
|
508 | self.__driver.addpcolorbuffer(self.ax, x_buffer, y_buffer, z_buffer, self.zmin, self.zmax, | |
|
509 | xlabel=xlabel, | |
|
510 | ylabel=ylabel, | |
|
511 | title=title, | |
|
512 | colormap=colormap) | |
|
513 |
|
|
|
492 | z_buffer = self.z_buffer.reshape(-1,len(y)) | |
|
493 | ||
|
494 | x_buffer = self.x_buffer[::self.decimationx] | |
|
495 | y_buffer = y[::self.decimationy] | |
|
496 | z_buffer = z_buffer[::self.decimationx, ::self.decimationy] | |
|
497 | #=================================================== | |
|
498 | ||
|
499 | x_buffer, y_buffer, z_buffer = self.__fillGaps(x_buffer, y_buffer, z_buffer) | |
|
500 | ||
|
501 | self.__driver.addpcolorbuffer(self.ax, x_buffer, y_buffer, z_buffer, self.zmin, self.zmax, | |
|
502 | xlabel=xlabel, | |
|
503 | ylabel=ylabel, | |
|
504 | title=title, | |
|
505 | colormap=colormap) | |
|
506 | def __fillGaps(self, x_buffer, y_buffer, z_buffer): | |
|
507 | ||
|
508 | deltas = x_buffer[1:] - x_buffer[0:-1] | |
|
509 | x_median = numpy.median(deltas) | |
|
510 | ||
|
511 | index = numpy.where(deltas >= 2*x_median) | |
|
512 | ||
|
513 | if len(index[0]) != 0: | |
|
514 | z_buffer[index[0],::] = self.__missing | |
|
515 | z_buffer = numpy.ma.masked_inside(z_buffer,0.99*self.__missing,1.01*self.__missing) | |
|
516 | ||
|
517 | return x_buffer, y_buffer, z_buffer | |
|
518 | ||
|
519 | ||
|
514 | 520 | |
|
515 | self.__driver.pcolor(self.plot, z, | |
|
516 | xlabel=xlabel, | |
|
517 | ylabel=ylabel, | |
|
518 | title=title) | |
|
519 | 521 | No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now