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