##// END OF EJS Templates
Esta version actualiza las librerias de ploteo para graficos RTI, Spectra y Scope, tambien se agregan metodos para procesamiento de Spectra y Voltage. En el caso de Voltage, en la Integracion Coherente se realiza indicando el tiempo de integracion en minutos.
Daniel Valdez -
r108:181a583e8f11
parent child
Show More
This diff has been collapsed as it changes many lines, (1259 lines changed) Show them Hide them
@@ -7,8 +7,13 Created on Feb 7, 2012
7 7 """
8 8
9 9 import numpy
10 import sys
11 import time
12 import datetime
13 import time
10 14 import plplot
11 15
16
12 17 def cmap1_init(colormap="gray"):
13 18
14 19 if colormap == None:
@@ -38,7 +43,43 def cmap1_init(colormap="gray"):
38 43 plplot.plscmap1l(0, i, h, l, s)
39 44
40 45 return None
46
47 if colormap == 'jet':
48 ncolor = 256
49 pos = numpy.zeros((ncolor))
50 r = numpy.zeros((ncolor))
51 g = numpy.zeros((ncolor))
52 b = numpy.zeros((ncolor))
53
54 for i in range(ncolor):
55 if(i <= 35.0/100*(ncolor-1)): rf = 0.0
56 elif (i <= 66.0/100*(ncolor-1)): rf = (100.0/31)*i/(ncolor-1) - 35.0/31
57 elif (i <= 89.0/100*(ncolor-1)): rf = 1.0
58 else: rf = (-100.0/22)*i/(ncolor-1) + 111.0/22
59
60 if(i <= 12.0/100*(ncolor-1)): gf = 0.0
61 elif(i <= 38.0/100*(ncolor-1)): gf = (100.0/26)*i/(ncolor-1) - 12.0/26
62 elif(i <= 64.0/100*(ncolor-1)): gf = 1.0
63 elif(i <= 91.0/100*(ncolor-1)): gf = (-100.0/27)*i/(ncolor-1) + 91.0/27
64 else: gf = 0.0
65
66 if(i <= 11.0/100*(ncolor-1)): bf = (50.0/11)*i/(ncolor-1) + 0.5
67 elif(i <= 34.0/100*(ncolor-1)): bf = 1.0
68 elif(i <= 65.0/100*(ncolor-1)): bf = (-100.0/31)*i/(ncolor-1) + 65.0/31
69 else: bf = 0
70
71 r[i] = rf
72 g[i] = gf
73 b[i] = bf
41 74
75 pos[i] = float(i)/float(ncolor-1)
76
77
78 plplot.plscmap1n(ncolor)
79 plplot.plscmap1l(1, pos, r, g, b)
80
81
82
42 83 if colormap=="br_green":
43 84 ncolor = 256
44 85 # Hue ranges from blue (240 deg) to red (0 or 360 deg)
@@ -147,167 +188,146 def cmap1_init(colormap="gray"):
147 188
148 189 return rgb_lvl
149 190
150 def setColormap(colormap="br_green"):
151 cmap1_init(colormap)
152
153 class BaseGraph:
154 """
155
156 """
157 hasNotRange = True
158
159 xrange = None
160 yrange = None
161 zrange = None
191 def setColormap(colormap="jet"):
192 cmap1_init(colormap)
193
194 def initPlplot(indexPlot,ncol,nrow,winTitle,width,height):
195 plplot.plsstrm(indexPlot)
196 plplot.plparseopts([winTitle],plplot.PL_PARSE_FULL)
197 plplot.plsetopt("geometry", "%dx%d"%(width*ncol,height*nrow))
198 plplot.plsdev("xwin")
199 plplot.plscolbg(255,255,255)
200 plplot.plscol0(1,0,0,0)
201 plplot.plinit()
202 plplot.plspause(False)
203 plplot.plssub(ncol,nrow)
204
205 def clearData(objGraph):
206 objGraph.plotBox(objGraph.xrange[0], objGraph.xrange[1], objGraph.yrange[0], objGraph.yrange[1], "bc", "bc")
162 207
163 xlabel = None
164 ylabel = None
165 title = None
208 objGraph.setColor(15) #Setting Line Color to White
166 209
167 legends = None
210 if objGraph.datatype == "complex":
211 objGraph.basicXYPlot(objGraph.xdata,objGraph.ydata.real)
212 objGraph.basicXYPlot(objGraph.xdata,objGraph.ydata.imag)
213
214 if objGraph.datatype == "real":
215 objGraph.basicXYPlot(objGraph.xdata,objGraph.ydata)
168 216
169 __name = None
217 objGraph.setColor(1) #Setting Line Color to Black
218 # objGraph.setLineStyle(2)
219 # objGraph.plotBox(objGraph.xrange[0], objGraph.xrange[1], objGraph.yrange[0], objGraph.yrange[1], "bcntg", "bc")
220 # objGraph.setLineStyle(1)
221
222 def setStrm(indexPlot):
223 plplot.plsstrm(indexPlot)
224
225 def plFlush():
226 plplot.plflush()
170 227
171 __colormap = None
172 __colbox = None
173 __colleg = None
174
175 __xpos = None
176 __ypos = None
228 def setPlTitle(pltitle,color):
229 setSubpages(1, 0)
230 plplot.pladv(0)
231 plplot.plvpor(0., 1., 0., 1.)
177 232
178 __xopt = None #"bcnst"
179 __yopt = None #"bcnstv"
180
181 __xlpos = None
182 __ylpos = None
233 if color == "black":
234 plplot.plcol0(1)
235 if color == "white":
236 plplot.plcol0(15)
183 237
184 __xrangeIsTime = False
238 plplot.plmtex("t",-1., 0.5, 0.5, pltitle)
185 239
186 #Advanced
240 def setSubpages(ncol,nrow):
241 plplot.plssub(ncol,nrow)
242
243 class BaseGraph:
244 __name = None
245 __xpos = None
246 __ypos = None
247 __subplot = None
187 248 __xg = None
188 249 __yg = None
189
190 def __init__(self):
191 """
192
193 """
194 self.hasNotRange = True
195
196 self.xrange = None
197 self.yrange = None
198 self.zrange = None
199
200 self.xlabel = None
201 self.ylabel = None
202 self.title = None
203
204 self.legends = None
205
206 self.__name = None
207
208 self.__colormap = None
209 self.__colbox = None
210 self.__colleg = None
211
212 self.__xpos = None
213 self.__ypos = None
214
215 self.__xopt = None #"bcnst"
216 self.__yopt = None #"bcnstv"
217
218 self.__xlpos = None
219 self.__ylpos = None
220
221 self.__xrangeIsTime = False
222
223 #Advanced
224 self.__xg = None
225 self.__yg = None
250 xdata = None
251 ydata = None
252 getGrid = True
253 xaxisIsTime = False
254 deltax = None
255 xmin = None
256 xmax = None
257 def __init__(self,name,subplot,xpos,ypos,xlabel,ylabel,title,szchar,xrange,yrange,zrange=None,deltax=1.0):
258 self.setName(name)
259 self.setScreenPos(xpos, ypos)
260 self.setLabels(xlabel,ylabel,title)
261 self.setSubPlot(subplot)
262 self.setSizeOfChar(szchar)
263 self.setXYZrange(xrange,yrange,zrange)
264 self.getGrid = True
265 self.xaxisIsTime = False
266 self.deltax = deltax
267
268 def setXYZrange(self,xrange,yrange,zrange):
269 self.xrange = xrange
270 self.yrange = yrange
271 self.zrange = zrange
226 272
227 273 def setName(self, name):
228 274 self.__name = name
229
230 def setScreenPos(self, xpos, ypos):
275
276 def setScreenPos(self,xpos,ypos):
231 277 self.__xpos = xpos
232 278 self.__ypos = ypos
233
234 def setOpt(self, xopt, yopt):
235 self.__xopt = xopt
236 self.__yopt = yopt
237
238 def setXAxisAsTime(self):
239 self.__xrangeIsTime = True
240
241
242 def setup(self, title=None, xlabel=None, ylabel=None, colormap=None):
243 """
244 """
245 self.title = title
246 self.xlabel = xlabel
247 self.ylabel = ylabel
248 self.__colormap = colormap
249
250 def plotBox(self, xmin, xmax, ymin, ymax, xopt=None, yopt=None, nolabels=False):
251 """
252
253 """
254 if self.__xrangeIsTime:
255 plplot.pltimefmt("%H:%M")
279
280 def setXYData(self,xdata=None,ydata=None,datatype="real"):
281 if((xdata != None) and (ydata != None)):
282 self.xdata = xdata
283 self.ydata = ydata
284 self.datatype = datatype
256 285
257 plplot.plvpor(self.__xpos[0], self.__xpos[1], self.__ypos[0], self.__ypos[1])
258 plplot.plwind(float(xmin),
259 float(xmax),
260 float(ymin),
261 float(ymax)
262 )
263
264 if xopt == None: xopt = self.__xopt
265 if yopt == None: yopt = self.__yopt
266
267 plplot.plbox(xopt, 0.0, 0, yopt, 0.0, 0)
286 if((self.xdata == None) and (self.ydata == None)):
287 return None
268 288
269 if not(nolabels):
270 plplot.pllab(self.xlabel, self.ylabel, self.title)
271
289 return 1
272 290
273 def colorbarPlot(self, xmin=0., xmax=1., ymin=0., ymax=1.):
274 data = numpy.arange(256)
275 data = numpy.reshape(data, (1,-1))
276
277 plplot.plimage(data,
278 float(xmin),
279 float(xmax),
280 float(ymin),
281 float(ymax),
282 0.,
283 255.,
284 float(xmin),
285 float(xmax),
286 float(ymin),
287 float(ymax))
291
292 def setLabels(self,xlabel=None,ylabel=None,title=None):
293 if xlabel != None: self.xlabel = xlabel
294 if ylabel != None: self.ylabel = ylabel
295 if title != None: self.title = title
296
297 def setSubPlot(self,subplot):
298 self.__subplot = subplot
299
300 def setSizeOfChar(self,szchar):
301 self.__szchar = szchar
288 302
289 def basicXYPlot(self, x, y, xmin=None, xmax=None, ymin=None, ymax=None):
303 def setLineStyle(self,style):
304 plplot.pllsty(style)
305
306 def setColor(self,color):
307 plplot.plcol0(color)
308
309 def setXAxisAsTime(self,value=False):
310 self.xaxisIsTime = value
311
312 def basicLineTimePlot(self, x, y, xmin=None, xmax=None, ymin=None, ymax=None, colline=1):
290 313
291 314 if xmin == None: xmin = x[0]
292 315 if xmax == None: xmax = x[-1]
293 316 if ymin == None: ymin = y[0]
294 317 if ymax == None: ymax = y[-1]
295 318
319 plplot.plcol0(colline)
296 320 plplot.plline(x, y)
321 plplot.plcol0(1)
297 322
298 def basicXYwithErrorPlot(self):
299 pass
300
301 def basicLineTimePlot(self, x, y, xmin=None, xmax=None, ymin=None, ymax=None, colline=1):
323 def basicXYPlot(self, x, y, xmin=None, xmax=None, ymin=None, ymax=None):
302 324
303 325 if xmin == None: xmin = x[0]
304 326 if xmax == None: xmax = x[-1]
305 327 if ymin == None: ymin = y[0]
306 328 if ymax == None: ymax = y[-1]
307 329
308 plplot.plcol0(colline)
309 330 plplot.plline(x, y)
310 plplot.plcol0(1)
311 331
312 332 def basicPcolorPlot(self, data, x, y, xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None):
313 333 """
@@ -331,10 +351,10 class BaseGraph:
331 351 float(ymin),
332 352 float(ymax)
333 353 )
334
354
335 355 def __getBoxpltr(self, x, y, deltax=None, deltay=None):
336 356
337 if not(len(x)>1 and len(y)>1):
357 if not(len(x)>0 and len(y)>0):
338 358 raise ValueError, "x axis and y axis are empty"
339 359
340 360 if deltax == None: deltax = x[-1] - x[-2]
@@ -349,555 +369,570 class BaseGraph:
349 369 self.__xg = xg
350 370 self.__yg = yg
351 371
352 def advPcolorPlot(self, data, x, y, zmin=0., zmax=0.):
353 """
354 """
355
356 if self.__xg == None and self.__yg == None:
357 self.__getBoxpltr(x, y)
358
359 plplot.plimagefr(data, x[0], x[-1], y[0], y[-1], 0., 0., zmin, zmax, plplot.pltr2, self.__xg, self.__yg)
372 return xg, yg
373
374
375 def advPcolorPlot(self, data, x, y, xmin=None, xmax=None, ymin=None, ymax=None, zmin=0., zmax=0., deltax=1.0, deltay=None, getGrid = True):
376 if getGrid:
377 xg, yg = self.__getBoxpltr(x, y, deltax, deltay)
378 else:
379 xg = self.__xg
380 yg = self.__yg
381
382 plplot.plimagefr(data,
383 float(xmin),
384 float(xmax),
385 float(ymin),
386 float(ymax),
387 0.,
388 0.,
389 float(zmin),
390 float(zmax),
391 plplot.pltr2,
392 xg,
393 yg)
360 394
361 395
362 class LinearPlot:
363
364 linearGraphObj = BaseGraph()
365
366 __szchar = 1.0
367
368 __xrange = None
369
370 __yrange = None
371
372 __subpage = 0
373 m_BaseGraph= BaseGraph()
374
375
376
377 def __init__(self):
378
379
380 key = "linearplot"
381 self.linearGraphObj = BaseGraph()
382 self.linearGraphObj.setName(key)
383
384 self.__subpage = 0
385
386 def __iniSubpage(self):
396 def colorbarPlot(self, xmin=0., xmax=1., ymin=0., ymax=1.):
397 data = numpy.arange(256)
398 data = numpy.reshape(data, (1,-1))
387 399
388 if plplot.plgdev() == '':
389 raise ValueError, "Plot device has not been initialize"
400 plplot.plimage(data,
401 float(xmin),
402 float(xmax),
403 float(ymin),
404 float(ymax),
405 0.,
406 255.,
407 float(xmin),
408 float(xmax),
409 float(ymin),
410 float(ymax))
411
412 def plotBox(self, xmin, xmax, ymin, ymax, xopt, yopt, nolabels=False):
390 413
391 plplot.pladv(self.__subpage)
392 plplot.plschr(0.0, self.__szchar)
414 plplot.plschr(0.0,self.__szchar-0.05)
415 plplot.pladv(self.__subplot)
416 plplot.plvpor(self.__xpos[0], self.__xpos[1], self.__ypos[0], self.__ypos[1])
417 plplot.plwind(float(xmin), # self.xrange[0]
418 float(xmax), # self.xrange[1]
419 float(ymin), # self.yrange[0]
420 float(ymax) # self.yrange[1]
421 )
393 422
394 setColormap()
395 423
396 def setScreenPos(self, width='small'):
397 424
398 if width == 'small':
399 xi = 0.12; yi = 0.14; xw = 0.78; yw = 0.80
425 if self.xaxisIsTime:
426 plplot.pltimefmt("%H:%M")
427 timedelta = (xmax - xmin + 1)/8.
428 plplot.plbox(xopt, timedelta, 3, yopt, 0.0, 0)
429 else:
430 plplot.plbox(xopt, 0.0, 0, yopt, 0.0, 0)
400 431
401 if width == 'medium':
402 xi = 0.07; yi = 0.10; xw = 0.90; yw = 0.60
403
404 xf = xi + xw
405 yf = yi + yw
406 432
407 self.linearGraphObj.setScreenPos([xi, xf], [yi, yf])
433 if not(nolabels):
434 plplot.pllab(self.xlabel, self.ylabel, self.title)
408 435
409 def setup(self, subpage, title="", xlabel="", ylabel="", XAxisAsTime=False):
410 """
411 """
412
413 self.linearGraphObj.setOpt("bcnts","bcntsv")
414 self.linearGraphObj.setup(title,
415 xlabel,
416 ylabel
417 )
418
419 self.setScreenPos(width='medium')
420
421 if XAxisAsTime:
422 self.linearGraphObj.setXAxisAsTime()
423
424 self.__subpage = subpage
425 # def setRanges(self, xrange, yrange, zrange):
426 #
427 # self.linearGraphObj.setRanges(xrange, yrange, zrange)
436
437 def delLabels(self):
438 self.setColor(15) #Setting Line Color to White
439 plplot.pllab(self.xlabel, self.ylabel, self.title)
440 self.setColor(1) #Setting Line Color to Black
441
442
443
444 def plotImage(self,x,y,z,xrange,yrange,zrange):
445 xi = x[0]
446 xf = x[-1]
447 yi = y[0]
448 yf = y[-1]
449
450 plplot.plimage(z,
451 float(xi),
452 float(xf),
453 float(yi),
454 float(yf),
455 float(zrange[0]),
456 float(zrange[1]),
457 float(xi),
458 float(xf),
459 float(yrange[0]),
460 yrange[1])
461
462 class LinearPlot:
463 linearObjDic = {}
464 __xpos = None
465 __ypos = None
466 def __init__(self,indexPlot,nsubplot,winTitle):
467 self.width = 700
468 self.height = 150
469 ncol = 1
470 nrow = nsubplot
471 initPlplot(indexPlot,ncol,nrow,winTitle,self.width,self.height)
428 472
429 def plotData(self, x, y=None, xmin=None, xmax=None, ymin=None, ymax=None, colline=1):
430 """
431 Inputs:
432
433 x : Numpy array of dimension 1
434 y : Numpy array of dimension 1
435
436 """
473
474 def setFigure(self,indexPlot):
475 setStrm(indexPlot)
437 476
438 try:
439 nX = numpy.shape(x)
440 except:
441 raise ValueError, "x is not a numpy array"
477 def setPosition(self):
442 478
443 if y == None: y = numpy.arange(nX)
479 xi = 0.07; xf = 0.9 #0.8,0.7,0.5
480 yi = 0.15; yf = 0.8
444 481
445 if xmin == None: xmin = x[0]
446 if xmax == None: xmax = x[-1]
447 if ymin == None: ymin = y[0]
448 if ymax == None: ymax = y[-1]
482 xpos = [xi,xf]
483 ypos = [yi,yf]
449 484
450 self.__iniSubpage()
451 self.linearGraphObj.plotBox(xmin, xmax, ymin, ymax)
452 self.linearGraphObj.basicLineTimePlot(x, y, xmin, xmax, ymin, ymax, colline)
453
454 def plotComplexData(self, x, y, xmin=None, xmax=None, ymin=None, ymax=None, colline=1, type='power'):
455 """
456 Inputs:
457
458 x : Numpy array of dimension 1
459 y : Complex numpy array of dimension 1
485 self.__xpos = xpos
486 self.__ypos = ypos
460 487
461 """
488 return xpos,ypos
489
490 def refresh(self):
491 plFlush()
462 492
463 try:
464 nX = numpy.shape(x)
465 except:
466 raise ValueError, "x is not a numpy array"
493 def setup(self,subplot,xmin,xmax,ymin,ymax,title,xlabel,ylabel):
494 szchar = 1.10
495 name = "linear"
496 key = name + "%d"%subplot
497 xrange = [xmin,xmax]
498 yrange = [ymin,ymax]
467 499
468 try:
469 nY = numpy.shape(y)
470 except:
471 raise ValueError, "y is not a numpy array"
500 xpos,ypos = self.setPosition()
501 linearObj = BaseGraph(name,subplot,xpos,ypos,xlabel,ylabel,title,szchar,xrange,yrange)
502 linearObj.plotBox(linearObj.xrange[0], linearObj.xrange[1], linearObj.yrange[0], linearObj.yrange[1], "bcnst", "bcnstv")
503 self.linearObjDic[key] = linearObj
504
505 def plot(self,subplot,x,y,type="power"):
506 name = "linear"
507 key = name + "%d"%subplot
472 508
473 if xmin == None: xmin = x[0]
474 if xmax == None: xmax = x[-1]
475 if ymin == None: ymin = y[0]
476 if ymax == None: ymax = y[-1]
509 linearObj = self.linearObjDic[key]
510 linearObj.plotBox(linearObj.xrange[0], linearObj.xrange[1], linearObj.yrange[0], linearObj.yrange[1], "bcst", "bcst")
477 511
478 self.__iniSubpage()
479 self.linearGraphObj.plotBox(xmin, xmax, ymin, ymax)
512 if linearObj.setXYData() != None:
513 clearData(linearObj)
514
515 else:
516 if type.lower() == 'power':
517 linearObj.setXYData(x,abs(y),"real")
518 if type.lower() == 'iq':
519 linearObj.setXYData(x,y,"complex")
480 520
481 521 if type.lower() == 'power':
482 self.linearGraphObj.basicLineTimePlot(x, abs(y), xmin, xmax, ymin, ymax, colline)
522 colline = 9
523 linearObj.basicLineTimePlot(x, abs(y), xmin, xmax, ymin, ymax, colline)
524 linearObj.setXYData(x,abs(y),"real")
483 525
484 526 if type.lower() == 'iq':
527 colline = 9
528 linearObj.basicLineTimePlot(x=x, y=y.real, colline=colline)
529 colline = 13
530 linearObj.basicLineTimePlot(x=x, y=y.imag, colline=colline)
485 531
486 self.linearGraphObj.basicLineTimePlot(x, y.real, xmin, xmax, ymin, ymax, colline)
487 self.linearGraphObj.basicLineTimePlot(x, y.imag, xmin, xmax, ymin, ymax, colline+1)
488
489 class ColorPlot:
490
491 colorGraphObj = BaseGraph()
492
493 graphObjDict = {}
532 linearObj.setXYData(x,y,"complex")
494 533
495 __subpage = 0
496
497 __showColorbar = False
498
499 __showPowerProfile = True
500
501 __szchar = 0.65
502
503 __xrange = None
504
505 __yrange = None
506
507 __zrange = None
508 m_BaseGraph= BaseGraph()
509
510
511
512 def __init__(self):
513
514 self.graphObjDict = {}
534 linearObj.plotBox(linearObj.xrange[0], linearObj.xrange[1], linearObj.yrange[0], linearObj.yrange[1], "bcst", "bcst")
515 535
516 self.__subpage = 0
517 self.__showColorbar = False
518 self.__showPowerProfile = True
519 536
520 self.__szchar = 0.65
521 self.__xrange = None
522 self.__yrange = None
523 self.__zrange = None
537 # linearObj.plotBox(linearObj.xrange[0], linearObj.xrange[1], linearObj.yrange[0], linearObj.yrange[1], "bc", "bc")
538 # linearObj.basicXYPlot(data,y)
539 # linearObj.setXYData(data,y)
524 540
525 key = "colorplot"
526 self.colorGraphObj = BaseGraph()
527 self.colorGraphObj.setName(key)
541
528 542
529 def setup(self, subpage, title="", xlabel="Frequency", ylabel="Range", colormap="br_green", showColorbar=False, showPowerProfile=False, XAxisAsTime=False):
530 """
531 """
532
533 self.colorGraphObj.setOpt("bcnts","bcntsv")
534 self.colorGraphObj.setup(title,
535 xlabel,
536 ylabel
537 )
538
539 self.__subpage = subpage
540 self.__colormap = colormap
541 self.__showColorbar = showColorbar
542 self.__showPowerProfile = showPowerProfile
543
544 if showColorbar:
545 key = "colorbar"
546
547 cmapObj = BaseGraph()
548 cmapObj.setName(key)
549 cmapObj.setOpt("bc","bcmtv")
550 cmapObj.setup(title="dBs",
551 xlabel="",
552 ylabel="",
553 colormap=colormap)
554
555 self.graphObjDict[key] = cmapObj
556
557
558 if showPowerProfile:
559 key = "powerprof"
560
561 powObj = BaseGraph()
562 powObj.setName(key)
563 powObj.setOpt("bcntg","bc")
564 powObj.setup(title="Power Profile",
565 xlabel="dB",
566 ylabel="")
567
568 self.graphObjDict[key] = powObj
569
570 self.setScreenPos(width='small')
571
572 if XAxisAsTime:
573 self.colorGraphObj.setXAxisAsTime()
574
575 def __iniSubpage(self):
543 class SpectraPlot:
544 pcolorObjDic = {}
545 colorbarObjDic = {}
546 pwprofileObjDic = {}
547 showColorbar = None
548 showPowerProfile = None
549 XAxisAsTime = None
550 widht = None
551 height = None
552 __spcxpos = None
553 __spcypos = None
554 __cmapxpos = None
555 __cmapypos = None
556 __profxpos = None
557 __profypos = None
558 __lastTitle = None
559
560 def __init__(self,indexPlot,nsubplot,winTitle,colormap,showColorbar,showPowerProfile,XAxisAsTime):
561 self.width = 460
562 self.height = 300
563 self.showColorbar = showColorbar
564 self.showPowerProfile = showPowerProfile
565 self.XAxisAsTime = XAxisAsTime
566
567 nrow = 2
568 if (nsubplot%2)==0:
569 ncol = nsubplot/nrow
570 else:
571 ncol = int(nsubplot)/nrow + 1
572
573 initPlplot(indexPlot,ncol,nrow,winTitle,self.width,self.height)
574 setColormap(colormap)
575 self.ncol = ncol
576 self.nrow = nrow
577
578 def setFigure(self,indexPlot):
579 setStrm(indexPlot)
580
581 def setSpectraPos(self): #modificar valores de acuerdo al colorbar y pwprofile
582 if self.showPowerProfile: xi = 0.09; xf = 0.6 #0.075
583 else: xi = 0.15; xf = 0.8 #0.8,0.7,0.5
584 yi = 0.15; yf = 0.80
576 585
577 if plplot.plgdev() == '':
578 raise ValueError, "Plot device has not been initialize"
586 xpos = [xi,xf]
587 ypos = [yi,yf]
579 588
580 plplot.pladv(self.__subpage)
581 plplot.plschr(0.0, self.__szchar)
589 self.__spcxpos = xpos
590 self.__spcypos = ypos
582 591
583 setColormap(self.__colormap)
584
585 def setScreenPos(self, width='small'):
592 return xpos,ypos
593
594 def setColorbarScreenPos(self):
595
596 xi = self.__spcxpos[1] + 0.03; xf = xi + 0.03
597 yi = self.__spcypos[0]; yf = self.__spcypos[1]
586 598
587 if width == 'small':
588 xi = 0.13; yi = 0.12; xw = 0.86; yw = 0.70; xcmapw = 0.04; xpoww = 0.25; deltaxcmap = 0.02; deltaxpow = 0.06
599 xpos = [xi,xf]
600 ypos = [yi,yf]
589 601
590 if width == 'medium':
591 xi = 0.07; yi = 0.10; xw = 0.90; yw = 0.60; xcmapw = 0.04; xpoww = 0.24; deltaxcmap = 0.02; deltaxpow = 0.06
602 self.__cmapxpos = xpos
603 self.__cmapypos = ypos
604
605 return xpos,ypos
606
607 def setPowerprofileScreenPos(self):
592 608
593 if self.__showColorbar:
594 xw -= xcmapw + deltaxcmap
609 xi = self.__cmapxpos[1] + 0.07; xf = xi + 0.25
610 yi = self.__spcypos[0]; yf = self.__spcypos[1]
595 611
596 if self.__showPowerProfile:
597 xw -= xpoww + deltaxpow
598
599 xf = xi + xw
600 yf = yi + yw
601 xcmapf = xf
612 xpos = [xi,xf]
613 ypos = [yi,yf]
602 614
603 self.colorGraphObj.setScreenPos([xi, xf], [yi, yf])
615 self.__profxpos = [xi,xf]
616 self.__profypos = [yi,yf]
604 617
605 if self.__showColorbar:
606 xcmapi = xf + deltaxcmap
607 xcmapf = xcmapi + xcmapw
608
609 key = "colorbar"
610 cmapObj = self.graphObjDict[key]
611 cmapObj.setScreenPos([xcmapi, xcmapf], [yi, yf])
612
613 if self.__showPowerProfile:
614
615 xpowi = xcmapf + deltaxpow
616 xpowf = xpowi + xpoww
618 return xpos,ypos
619
620 def setup(self,subplot,xmin,xmax,ymin,ymax,zmin,zmax,title,xlabel,ylabel):
621 # Config Spectra plot
622 szchar = 0.7
623 name = "spc"
624 key = name + "%d"%subplot
625 xrange = [xmin,xmax]
626 yrange = [ymin,ymax]
627 zrange = [zmin,zmax]
628
629 xpos,ypos = self.setSpectraPos()
630 pcolorObj = BaseGraph(name,subplot,xpos,ypos,xlabel,ylabel,title,szchar,xrange,yrange,zrange)
631 pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], "bcnst", "bcnstv")
632 self.pcolorObjDic[key] = pcolorObj
633
634 # Config Colorbar
635 if self.showColorbar:
636 szchar = 0.65
637 name = "colorbar"
638 key = name + "%d"%subplot
639
640 xpos,ypos = self.setColorbarScreenPos()
641 xrange = [0.,1.]
642 yrange = [zmin,zmax]
643 cmapObj = BaseGraph(name,subplot,xpos,ypos,"","","dB",szchar,xrange,yrange)
644 cmapObj.plotBox(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1], "bc", "bcm")
645 cmapObj.colorbarPlot(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1])
646 cmapObj.plotBox(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1], "bc", "bcmtsv")
647 self.colorbarObjDic[key] = cmapObj
648
649 # Config Power profile
650 if self.showPowerProfile:
651 szchar = 0.55
652 name = "pwprofile"
653 key = name + "%d"%subplot
617 654
618 key = "powerprof"
619 powObj = self.graphObjDict[key]
620 powObj.setScreenPos([xpowi, xpowf], [yi, yf])
621
622
655 xpos,ypos = self.setPowerprofileScreenPos()
656 xrange = [zmin,zmax]
657 yrange = [ymin,ymax]
658 powObj = BaseGraph(name,subplot,xpos,ypos,"dB","","Power Profile",szchar,xrange,yrange)
659 powObj.setLineStyle(2)
660 powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bcntg", "bc")
661 powObj.setLineStyle(1)
662 powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bc", "bc")
663 self.pwprofileObjDic[key] = powObj
623 664
624 def plotData(self, data, x=None, y=None, xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, title = ''):
625 """
626 Inputs:
665 def printTitle(self,pltitle):
666 if self.__lastTitle != None:
667 setPlTitle(self.__lastTitle,"white")
627 668
628 x : Numpy array of dimension 1
629 y : Numpy array of dimension 1
669 self.__lastTitle = pltitle
630 670
631 """
671 setPlTitle(pltitle,"black")
632 672
633 try:
634 nX, nY = numpy.shape(data)
635 except:
636 raise ValueError, "data is not a numpy array"
673 setSubpages(self.ncol,self.nrow)
637 674
638 if x == None: x = numpy.arange(nX)
639 if y == None: y = numpy.arange(nY)
640
641 if xmin == None: xmin = x[0]
642 if xmax == None: xmax = x[-1]
643 if ymin == None: ymin = y[0]
644 if ymax == None: ymax = y[-1]
645 if zmin == None: zmin = numpy.nanmin(data)
646 if zmax == None: zmax = numpy.nanmax(data)
675 def plot(self,subplot,x,y,z,subtitle):
676 # Spectra plot
647 677
648 plplot.plschr(0.0, self.__szchar)
649 self.__iniSubpage()
650 self.colorGraphObj.title = title
651 self.colorGraphObj.plotBox(xmin, xmax, ymin, ymax)
652 self.colorGraphObj.basicPcolorPlot(data, x, y, xmin, xmax, ymin, ymax, zmin, zmax)
678 name = "spc"
679 key = name + "%d"%subplot
653 680
654 if self.__showColorbar:
655
656
657 key = "colorbar"
658 cmapObj = self.graphObjDict[key]
659
660 plplot.plschr(0.0, self.__szchar-0.05)
661 cmapObj.plotBox(0., 1., zmin, zmax)
662 cmapObj.colorbarPlot(0., 1., zmin, zmax)
663
664 if self.__showPowerProfile:
665 power = numpy.average(data, axis=0)
666
667 step = (ymax - ymin)/(nY-1)
668 heis = numpy.arange(ymin, ymax + step, step)
669
670 key = "powerprof"
671 powObj = self.graphObjDict[key]
672
673 plplot.pllsty(2)
674 plplot.plschr(0.0, self.__szchar-0.05)
675 powObj.plotBox(zmin, zmax, ymin, ymax, nolabels=True)
676
677 plplot.pllsty(1)
678 plplot.plschr(0.0, self.__szchar)
679 powObj.plotBox(zmin, zmax, ymin, ymax, xopt='bc', yopt='bc')
680
681 plplot.plcol0(9)
682 powObj.basicXYPlot(power, heis)
683 plplot.plcol0(1)
684
681 # newx = [x[0],x[-1]]
682 pcolorObj = self.pcolorObjDic[key]
683 pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], "bcst", "bcst")
684 pcolorObj.delLabels()
685 pcolorObj.setLabels(title=subtitle)
685 686
686 class ColorPlotX:
687 deltax = None; deltay = None
688
689 pcolorObj.advPcolorPlot(z,
690 x,
691 y,
692 xmin=pcolorObj.xrange[0],
693 xmax=pcolorObj.xrange[1],
694 ymin=pcolorObj.yrange[0],
695 ymax=pcolorObj.yrange[1],
696 zmin=pcolorObj.zrange[0],
697 zmax=pcolorObj.zrange[1],
698 deltax=deltax,
699 deltay=deltay,
700 getGrid=pcolorObj.getGrid)
701
702 pcolorObj.getGrid = False
703
704 pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], "bcst", "bcst")
705
706 # Power Profile
707 if self.showPowerProfile:
708 power = numpy.average(z, axis=0)
709 name = "pwprofile"
710 key = name + "%d"%subplot
711 powObj = self.pwprofileObjDic[key]
712
713 if powObj.setXYData() != None:
714 clearData(powObj)
715 else:
716 powObj.setXYData(power,y)
717
718 powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bc", "bc")
719 powObj.basicXYPlot(power,y)
720 powObj.setXYData(power,y)
721
722 def refresh(self):
723 plFlush()
687 724
725 class RtiPlot:
726
727 pcolorObjDic = {}
728 colorbarObjDic = {}
729 pwprofileObjDic = {}
730 showColorbar = None
731 showPowerProfile = None
732 XAxisAsTime = None
733 widht = None
734 height = None
735 __rtixpos = None
736 __rtiypos = None
737 __cmapxpos = None
738 __cmapypos = None
739 __profxpos = None
740 __profypos = None
741
742 def __init__(self,indexPlot,nsubplot,winTitle,colormap,showColorbar,showPowerProfile,XAxisAsTime):
743 self.width = 700
744 self.height = 150
745 self.showColorbar = showColorbar
746 self.showPowerProfile = showPowerProfile
747 self.XAxisAsTime = XAxisAsTime
748
749 ncol = 1
750 nrow = nsubplot
751 initPlplot(indexPlot,ncol,nrow,winTitle,self.width,self.height)
752 setColormap(colormap)
688 753
689 graphObjDict = {}
690 showColorbar = False
691 showPowerProfile = True
692
693 __szchar = 0.7
694 __xrange = None
695 __yrange = None
696 __zrange = None
697
698 colorGraphObj = BaseGraph()
754 def setFigure(self,indexPlot):
755 setStrm(indexPlot)
699 756
700 def __init__(self):
701
702 key = "colorplot"
703 self.colorGraphObj.setName(key)
704
705 self.__subpage = 0
706
707 self.graphObjDict[key] = self.colorGraphObj
708
709 def __iniSubpage(self):
757 def setRtiScreenPos(self):
758
759 if self.showPowerProfile: xi = 0.07; xf = 0.65
760 else: xi = 0.07; xf = 0.9
761 yi = 0.15; yf = 0.80
710 762
711 if plplot.plgdev() == '':
712 raise ValueError, "Plot device has not been initialize"
763 xpos = [xi,xf]
764 ypos = [yi,yf]
713 765
714 plplot.pladv(self.__subpage)
715 plplot.plschr(0.0, self.__szchar)
766 self.__rtixpos = xpos
767 self.__rtiypos = ypos
716 768
717 setColormap(self.__colormap)
769 return xpos,ypos
718 770
719 def setScreenPos(self, xi = 0.12, yi = 0.14, xw = 0.78, yw = 0.80, xcmapw = 0.05, xpoww = 0.24, deltaxcmap = 0.02, deltaxpow = 0.06):
720
721 if self.showColorbar:
722 xw -= xcmapw + deltaxcmap
723
724 if self.showPowerProfile:
725 xw -= xpoww + deltaxpow
771 def setColorbarScreenPos(self):
772
773 xi = self.__rtixpos[1] + 0.03; xf = xi + 0.03
726 774
727 xf = xi + xw
728 yf = yi + yw
729 xcmapf = xf
775 yi = self.__rtiypos[0]; yf = self.__rtiypos[1]
730 776
731 self.colorGraphObj.setScreenPos([xi, xf], [yi, yf])
777 xpos = [xi,xf]
778 ypos = [yi,yf]
732 779
733 if self.showColorbar:
734 xcmapi = xf + deltaxcmap
735 xcmapf = xcmapi + xcmapw
736
737 key = "colorbar"
738 cmapObj = self.graphObjDict[key]
739 cmapObj.setScreenPos([xcmapi, xcmapf], [yi, yf])
740
741 if self.showPowerProfile:
742
743 xpowi = xcmapf + deltaxpow
744 xpowf = xpowi + xpoww
745
746 key = "powerprof"
747 powObj = self.graphObjDict[key]
748 powObj.setScreenPos([xpowi, xpowf], [yi, yf])
780 self.__cmapxpos = xpos
781 self.__cmapypos = ypos
782
783 return xpos,ypos
749 784
750 def setRanges(self, xrange, yrange, zrange):
751
752 self.colorGraphObj.setRanges(xrange, yrange, zrange)
753
754 keyList = self.graphObjDict.keys()
785 def setPowerprofileScreenPos(self):
755 786
756 key = "colorbar"
757 if key in keyList:
758 cmapObj = self.graphObjDict[key]
759 cmapObj.setRanges([0., 1.], zrange)
760
761 key = "powerprof"
762 if key in keyList:
763 powObj = self.graphObjDict[key]
764 powObj.setRanges(zrange, yrange)
787 xi = self.__cmapxpos[1] + 0.05; xf = xi + 0.20
765 788
766 def setup(self, subpage, title="", xlabel="", ylabel="", colormap="jet", showColorbar=False, showPowerProfile=False, XAxisAsTime=False):
767 """
768 """
789 yi = self.__rtiypos[0]; yf = self.__rtiypos[1]
769 790
770 self.colorGraphObj.setSubpage(subpage)
771 self.colorGraphObj.setSzchar(self.__szchar)
772 self.colorGraphObj.setOpt("bcnts","bcntsv")
773 self.colorGraphObj.setup(title,
774 xlabel,
775 ylabel,
776 colormap)
791 xpos = [xi,xf]
792 ypos = [yi,yf]
777 793
778 if showColorbar:
779 key = "colorbar"
780
781 cmapObj = BaseGraph()
782 cmapObj.setName(key)
783 cmapObj.setSubpage(subpage)
784 cmapObj.setSzchar(self.__szchar)
785 cmapObj.setOpt("bc","bcmt")
786 cmapObj.setup(title="dBs",
787 xlabel="",
788 ylabel="",
789 colormap=colormap)
790
791 self.graphObjDict[key] = cmapObj
792
794 self.__profxpos = [xi,xf]
795 self.__profypos = [yi,yf]
796
797 return xpos,ypos
798
799 def setup(self,subplot,xmin,xmax,ymin,ymax,zmin,zmax,title,xlabel,ylabel,timedata,timezone="lt",npoints=100):
800 # Config Rti plot
801 szchar = 1.10
802 name = "rti"
803 key = name + "%d"%subplot
804
805 # xmin, xmax --> minHour, max Hour : valores que definen el ejex x=[horaInicio,horaFinal]
806 thisDateTime = datetime.datetime.fromtimestamp(timedata)
807 startDateTime = datetime.datetime(thisDateTime.year,thisDateTime.month,thisDateTime.day,xmin,0,0)
808 endDateTime = datetime.datetime(thisDateTime.year,thisDateTime.month,thisDateTime.day,xmax,59,59)
809 deltaTime = 0
810 if timezone == "lt":
811 deltaTime = time.timezone
812 startTimeInSecs = time.mktime(startDateTime.timetuple()) - deltaTime
813 endTimeInSecs = time.mktime(endDateTime.timetuple()) - deltaTime
814
815 xrange = [startTimeInSecs,endTimeInSecs]
816 totalTimeInXrange = endTimeInSecs - startTimeInSecs + 1.
817 deltax = totalTimeInXrange / npoints
818
819 yrange = [ymin,ymax]
820 zrange = [zmin,zmax]
821
822 xpos,ypos = self.setRtiScreenPos()
823 pcolorObj = BaseGraph(name,subplot,xpos,ypos,xlabel,ylabel,title,szchar,xrange,yrange,zrange,deltax)
824 if self.XAxisAsTime:
825 pcolorObj.setXAxisAsTime(self.XAxisAsTime)
826 xopt = "bcnstd"
827 yopt = "bcnstv"
828 else:
829 xopt = "bcnst"
830 yopt = "bcnstv"
831
832 pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], xopt, yopt)
833 self.pcolorObjDic[key] = pcolorObj
793 834
794 if showPowerProfile:
795 key = "powerprof"
796
797 powObj = BaseGraph()
798 powObj.setName(key)
799 powObj.setSubpage(subpage)
800 powObj.setSzchar(self.__szchar)
801 plplot.pllsty(2)
802 powObj.setOpt("bcntg","bc")
803 plplot.pllsty(1)
804 powObj.setup(title="Power Profile",
805 xlabel="dBs",
806 ylabel="")
807
808 self.graphObjDict[key] = powObj
835
836 # Config Colorbar
837 if self.showColorbar:
838 szchar = 0.9
839 name = "colorbar"
840 key = name + "%d"%subplot
809 841
810 self.showColorbar = showColorbar
811 self.showPowerProfile = showPowerProfile
812 self.setScreenPos()
842 xpos,ypos = self.setColorbarScreenPos()
843 xrange = [0.,1.]
844 yrange = [zmin,zmax]
845 cmapObj = BaseGraph(name,subplot,xpos,ypos,"","","dB",szchar,xrange,yrange)
846 cmapObj.plotBox(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1], "bc", "bcm")
847 cmapObj.colorbarPlot(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1])
848 cmapObj.plotBox(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1], "bc", "bcmtsv")
849 self.colorbarObjDic[key] = cmapObj
813 850
814 if XAxisAsTime:
815 self.colorGraphObj.setXAxisAsTime()
816 #self.setScreenPos(xi = 0.05, yi = 0.18, xw = 0.92, yw = 0.74, xcmapw = 0.015, xpoww = 0.14, deltaxcmap = 0.01, deltaxpow = 0.02)
817
818
819 def plotData(self, data, x=None, y=None, xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None):
820 """
821 """
822
823 try:
824 nX, nY = numpy.shape(data)
825 except:
826 raise ValueError, "data is not a numpy array"
827
828 if x == None: x = numpy.arange(nX)
829 if y == None: y = numpy.arange(nY)
830
831 if xmin == None: xmin = x[0]
832 if xmax == None: xmax = x[-1]
833 if ymin == None: ymin = y[0]
834 if ymax == None: ymax = y[-1]
835 if zmin == None: zmin = numpy.nanmin(data)
836 if zmax == None: zmax = numpy.nanmax(data)
837
838 if self.colorGraphObj.hasNotRange:
839 self.setRanges([xmin, xmax], [ymin,ymax], [zmin,zmax])
840
841 self.colorGraphObj.initSubpage()
842 self.colorGraphObj.basicPcolorPlot(data, x, y, xmin, xmax, ymin, ymax, self.colorGraphObj.zrange[0], self.colorGraphObj.zrange[1])
843
844 if self.showColorbar:
845 key = "colorbar"
846 cmapObj = self.graphObjDict[key]
847 cmapObj.colorbarPlot()
848 851
852 # Config Power profile
849 853 if self.showPowerProfile:
850 power = numpy.average(data, axis=1)
851
852 step = (ymax - ymin)/(nY-1)
853 heis = numpy.arange(ymin, ymax + step, step)
854
855 key = "powerprof"
856 powObj = self.graphObjDict[key]
857 powObj.basicXYPlot(power, heis)
858
859 if __name__ == '__main__':
860
861 import numpy
862 plplot.plsetopt("geometry", "%dx%d" %(350*2, 300*2))
863 plplot.plsdev("xwin")
864 plplot.plscolbg(255,255,255)
865 plplot.plscol0(1,0,0,0)
866 plplot.plspause(False)
867 plplot.plinit()
868 plplot.plssub(2, 2)
869
870 nx = 64
871 ny = 100
872
873 data = numpy.random.uniform(-50,50,(nx,ny))
874
875 baseObj = ColorPlot()
876 specObj = ColorPlot()
877 baseObj1 = ColorPlot()
878 specObj1 = ColorPlot()
879
880 baseObj.setup(1, "Spectrum", "Frequency", "Range", "br_green", True, True)
881 specObj.setup(2, "Spectrum", "Frequency", "Range", "br_green", False, True)
854 szchar = 0.8
855 name = "pwprofile"
856 key = name + "%d"%subplot
857
858 xpos,ypos = self.setPowerprofileScreenPos()
859 xrange = [zmin,zmax]
860 yrange = [ymin,ymax]
861 powObj = BaseGraph(name,subplot,xpos,ypos,"dB","","Power Profile",szchar,xrange,yrange)
862 powObj.setLineStyle(2)
863 powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bcntg", "bc")
864 powObj.setLineStyle(1)
865 powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bc", "bc")
866 self.pwprofileObjDic[key] = powObj
882 867
883 baseObj1.setup(3, "Spectrum", "Frequency", "Range", "br_green", False, True)
884 specObj1.setup(4, "Spectrum", "Frequency", "Range", "br_green", False, True)
885
886 data = numpy.random.uniform(-50,50,(nx,ny))
887
888 plplot.plbop()
889 baseObj.plotData(data)
890
891 specObj.plotData(data)
892
893 baseObj1.plotData(data)
894
895 specObj1.plotData(data)
896 868
897 plplot.plflush()
898
899 plplot.plspause(1)
900 plplot.plend()
901 exit(0)
902
903
869 def plot(self,subplot,x,y,z):
870 # RTI plot
871 name = "rti"
872 key = name + "%d"%subplot
873
874 data = numpy.reshape(z, (1,-1))
875 data = numpy.abs(data)
876 data = 10*numpy.log10(data)
877 newx = [x,x+1]
878
879 pcolorObj = self.pcolorObjDic[key]
880
881 if pcolorObj.xaxisIsTime:
882 xopt = "bcstd"
883 yopt = "bcst"
884 else:
885 xopt = "bcst"
886 yopt = "bcst"
887
888 pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], xopt, yopt)
889
890 deltax = pcolorObj.deltax
891 deltay = None
892
893 if pcolorObj.xmin == None and pcolorObj.xmax == None:
894 pcolorObj.xmin = x
895 pcolorObj.xmax = x
896
897 if x >= pcolorObj.xmax:
898 xmin = x
899 xmax = x + deltax
900 x = [x]
901 pcolorObj.advPcolorPlot(data,
902 x,
903 y,
904 xmin=xmin,
905 xmax=xmax,
906 ymin=pcolorObj.yrange[0],
907 ymax=pcolorObj.yrange[1],
908 zmin=pcolorObj.zrange[0],
909 zmax=pcolorObj.zrange[1],
910 deltax=deltax,
911 deltay=deltay,
912 getGrid=pcolorObj.getGrid)
913
914 pcolorObj.xmin = xmin
915 pcolorObj.xmax = xmax
916
917
918 # Power Profile
919 if self.showPowerProfile:
920 data = numpy.reshape(data,(numpy.size(data)))
921 name = "pwprofile"
922 key = name + "%d"%subplot
923 powObj = self.pwprofileObjDic[key]
924
925 if powObj.setXYData() != None:
926 clearData(powObj)
927 powObj.setLineStyle(2)
928 powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bcntg", "bc")
929 powObj.setLineStyle(1)
930 else:
931 powObj.setXYData(data,y)
932
933 powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bc", "bc")
934 powObj.basicXYPlot(data,y)
935 powObj.setXYData(data,y)
936
937 def refresh(self):
938 plFlush() No newline at end of file
@@ -5,10 +5,11 Created on Feb 7, 2012
5 5 @version $Id$
6 6 '''
7 7
8 import os, sys
9 8 import numpy
10 import datetime
9 import os
10 import sys
11 11 import plplot
12 import datetime
12 13
13 14 path = os.path.split(os.getcwd())[0]
14 15 sys.path.append(path)
@@ -17,188 +18,102 from Graphics.BaseGraph import *
17 18 from Model.Spectra import Spectra
18 19
19 20 class Spectrum:
20
21 __isPlotConfig = False
22
23 __isPlotIni = False
24
25 __xrange = None
26
27 __yrange = None
28
29 nGraphs = 0
21 colorplotObj = None
30 22
31 indexPlot = None
32
33 graphObjList = []
34
35 spectraObj = Spectra
36
37 colorGraphObj = ColorPlot()
38 m_Spectra= Spectra()
39
40
41 m_ColorPlot= ColorPlot()
42
43
44
45
46
47 def __init__(self, Spectra, index=0):
48
49 """
50
51 Inputs:
52
53 type: "power" ->> Potencia
54 "iq" ->> Real + Imaginario
55 """
56
23 def __init__(self,Spectra, index):
57 24 self.__isPlotConfig = False
58
59 25 self.__isPlotIni = False
60
61 26 self.__xrange = None
62
63 27 self.__yrange = None
64
65 28 self.nGraphs = 0
66
67 29 self.indexPlot = index
68
69 self.graphObjList = []
70
71 30 self.spectraObj = Spectra
72
73 31
74 def __addGraph(self, subpage, title="", xlabel="", ylabel="", showColorbar=False, showPowerProfile=True, XAxisAsTime=False):
75
76 graphObj = ColorPlot()
77 graphObj.setup(subpage,
78 title,
79 xlabel,
80 ylabel,
81 showColorbar=showColorbar,
82 showPowerProfile=showPowerProfile,
83 XAxisAsTime=XAxisAsTime)
84
85 self.graphObjList.append(graphObj)
86
32 def setup(self,indexPlot,nsubplot,winTitle='',colormap="br_green",showColorbar=False,showPowerProfile=False,XAxisAsTime=False):
33 self.colorplotObj = SpectraPlot(indexPlot,nsubplot,winTitle,colormap,showColorbar,showPowerProfile,XAxisAsTime)
87 34
88 def setup(self, titleList=None, xlabelList=None, ylabelList=None, showColorbar=False, showPowerProfile=True, XAxisAsTime=False):
89
90 nChan = int(self.spectraObj.m_SystemHeader.numChannels)
91 channels = range(nChan)
92
93 myXlabel = "Radial Velocity (m/s)"
94 myYlabel = "Range (km)"
95
96 for i in channels:
97 if titleList != None:
98 myTitle = titleList[i]
99 myXlabel = xlabelList[i]
100 myYlabel = ylabelList[i]
101
102 # if self.spectraObj.m_NoiseObj != None:
103 # noise = '%4.2fdB' %(self.spectraObj.m_NoiseObj[i])
104 # else:
105 noise = '--'
106
107 myTitle = "Channel: %d - Noise: %s" %(i, noise)
108
109 self.__addGraph(i+1,
110 title=myTitle,
111 xlabel=myXlabel,
112 ylabel=myYlabel,
113 showColorbar=showColorbar,
114 showPowerProfile=showPowerProfile,
115 XAxisAsTime=XAxisAsTime)
35 def initPlot(self,xmin,xmax,ymin,ymax,zmin,zmax,titleList,xlabelList,ylabelList):
36 nsubplot = self.spectraObj.nChannels
116 37
117 self.nGraphs = nChan
118 self.__isPlotConfig = True
38 for index in range(nsubplot):
39 title = titleList[index]
40 xlabel = xlabelList[index]
41 ylabel = ylabelList[index]
42 subplot = index
43 self.colorplotObj.setup(subplot+1,xmin,xmax,ymin,ymax,zmin,zmax,title,xlabel,ylabel)
119 44
120 def iniPlot(self, winTitle=""):
45
46 def plotData(self,
47 xmin=None,
48 xmax=None,
49 ymin=None,
50 ymax=None,
51 zmin=None,
52 zmax=None,
53 titleList=None,
54 xlabelList=None,
55 ylabelList=None,
56 winTitle='',
57 colormap = "br_green",
58 showColorbar = True,
59 showPowerProfile = True,
60 XAxisAsTime = False):
61
62 databuffer = 10.*numpy.log10(self.spectraObj.data_spc)
63 noise = 10.*numpy.log10(self.spectraObj.noise)
121 64
122 nx = int(numpy.sqrt(self.nGraphs)+1)
123 #ny = int(self.nGraphs/nx)
65 nsubplot = self.spectraObj.nChannels
66 nsubplot, nX, nY = numpy.shape(databuffer)
124 67
125 plplot.plsstrm(self.indexPlot)
126 plplot.plparseopts([winTitle], plplot.PL_PARSE_FULL)
127 plplot.plsetopt("geometry", "%dx%d" %(300*nx, 240*nx))
128 plplot.plsdev("xwin")
129 plplot.plscolbg(255,255,255)
130 plplot.plscol0(1,0,0,0)
131 plplot.plinit()
132 plplot.plspause(False)
133 plplot.pladv(0)
134 plplot.plssub(nx, nx)
68 x = numpy.arange(nX)
69 y = self.spectraObj.heightList
135 70
136 self.__nx = nx
137 self.__ny = nx
138 self.__isPlotIni = True
139
140
141 def plotData(self, xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, titleList=None, xlabelList=None, ylabelList=None, showColorbar=False, showPowerProfile=True, XAxisAsTime=False, winTitle="Spectra"):
71 indexPlot = self.indexPlot
142 72
143 73 if not(self.__isPlotConfig):
144 self.setup(titleList,
145 xlabelList,
146 ylabelList,
147 showColorbar,
148 showPowerProfile,
149 XAxisAsTime)
74 self.setup(indexPlot,nsubplot,winTitle,colormap,showColorbar,showPowerProfile,XAxisAsTime)
75 self.__isPlotConfig = True
150 76
151 77 if not(self.__isPlotIni):
152 self.iniPlot(winTitle)
153
154 plplot.plsstrm(self.indexPlot)
155
156 data = 10.*numpy.log10(self.spectraObj.data_spc)
157 noise = 10.*numpy.log10(self.spectraObj.noise)
158 #data.shape = Channels x Heights x Profiles
159 # data = numpy.transpose( data, (0,2,1) )
160 #data.shape = Channels x Profiles x Heights
161
162 nChan, nX, nY = numpy.shape(data)
78 if titleList == None:
79 titleList = []
80 for i in range(nsubplot):
81 titleList.append("Channel: %d - Noise: %.2f" %(i, noise[i]))
82
83 if xlabelList == None:
84 xlabelList = []
85 for i in range(nsubplot):
86 xlabelList.append("")
87
88 if ylabelList == None:
89 ylabelList = []
90 for i in range(nsubplot):
91 ylabelList.append("Range (Km)")
92
93 if xmin == None: xmin = x[0]
94 if xmax == None: xmax = x[-1]
95 if ymin == None: ymin = y[0]
96 if ymax == None: ymax = y[-1]
97 if zmin == None: zmin = 0
98 if zmax == None: zmax = 120
99
100 self.initPlot(xmin,xmax,ymin,ymax,zmin,zmax,titleList,xlabelList,ylabelList)
101 self.__isPlotIni = True
163 102
164 x = numpy.arange(nX)
165 y = self.spectraObj.heightList
103 self.colorplotObj.setFigure(indexPlot)
166 104
167 105 thisDatetime = datetime.datetime.fromtimestamp(self.spectraObj.m_BasicHeader.utc)
168 txtDate = "Self Spectra - Date: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
106 pltitle = "Self Spectra - Date: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
169 107
170 if xmin == None: xmin = x[0]
171 if xmax == None: xmax = x[-1]
172 if ymin == None: ymin = y[0]
173 if ymax == None: ymax = y[-1]
174 if zmin == None: zmin = numpy.nanmin(abs(data))
175 if zmax == None: zmax = numpy.nanmax(abs(data))
108 self.colorplotObj.printTitle(pltitle) #setPlTitle(pltitle)
176 109
177 plplot.plbop()
110 for index in range(nsubplot):
111 data = databuffer[index,:,:]
112 subtitle = "Channel: %d - Noise: %.2f" %(index, noise[index])
113 self.colorplotObj.plot(index+1,x,y,data,subtitle)
178 114
179 plplot.plssub(self.__nx, self.__ny)
180 for i in range(self.nGraphs):
181 self.graphObjList[i].plotData(data[i,:,:],
182 x,
183 y,
184 xmin=xmin,
185 xmax=xmax,
186 ymin=ymin,
187 ymax=ymax,
188 zmin=zmin,
189 zmax=zmax,
190 title = "Channel: %d - Noise: %.2f" %(i, noise[i]))
191 115
192 plplot.plssub(1,0)
193 plplot.pladv(0)
194 plplot.plvpor(0., 1., 0., 1.)
195 plplot.plmtex("t",-1., 0.5, 0.5, txtDate)
196 plplot.plflush()
197 plplot.pleop()
198
199 def end(self):
200 plplot.plend()
201
116
117 self.colorplotObj.refresh()
118
202 119
203 if __name__ == '__main__':
204 pass No newline at end of file
@@ -4,9 +4,9 Created on Feb 7, 2012
4 4 @author $Author$
5 5 @version $Id$
6 6 '''
7 import os, sys
8 7 import numpy
9 import plplot
8 import os
9 import sys
10 10
11 11 path = os.path.split(os.getcwd())[0]
12 12 sys.path.append(path)
@@ -15,190 +15,183 from Graphics.BaseGraph import *
15 15 from Model.Voltage import Voltage
16 16
17 17 class Osciloscope:
18 linearplotObj = None
18 19
19 voltageObj = Voltage()
20 def __init__(self, Voltage, index):
21 self.__isPlotConfig = False
22 self.__isPlotIni = False
23 self.__xrange = None
24 self.__yrange = None
25 self.indexPlot = index
26 self.voltageObj = Voltage
20 27
21 linearGraphObj = LinearPlot()
28 def setup(self,indexPlot,nsubplot,winTitle=''):
29 self.linearplotObj = LinearPlot(indexPlot,nsubplot,winTitle)
22 30
23 __isPlotConfig = False
31 def initPlot(self,xmin,xmax,ymin,ymax,titleList,xlabelList,ylabelList):
32 nsubplot = self.voltageObj.nChannels
24 33
25 __isPlotIni = False
26
27 __xrange = None
28
29 __yrange = None
30
31 voltageObj = Voltage()
32
33 nGraphs = 0
34 for index in range(nsubplot):
35 title = titleList[index]
36 xlabel = xlabelList[index]
37 ylabel = ylabelList[index]
38 subplot = index
39 self.linearplotObj.setup(subplot+1,xmin,xmax,ymin,ymax,title,xlabel,ylabel)
34 40
35 indexPlot = None
36
37 graphObjList = []
38 m_LinearPlot= LinearPlot()
39
40
41 m_Voltage= Voltage()
42
43
41 def plotData(self,
42 xmin=None,
43 xmax=None,
44 ymin=None,
45 ymax=None,
46 titleList=None,
47 xlabelList=None,
48 ylabelList=None,
49 winTitle='',
50 type="power"):
44 51
45 def __init__(self, Voltage, index=0):
52 databuffer = self.voltageObj.data
46 53
47 """
54 height = self.voltageObj.heightList
55 nsubplot = self.voltageObj.nChannels
56 indexPlot = self.indexPlot
48 57
49 Inputs:
50
51 type: "power" ->> Potencia
52 "iq" ->> Real + Imaginario
53 """
54
55 self.__isPlotConfig = False
56 58
57 self.__isPlotIni = False
58
59 self.__xrange = None
59 if not(self.__isPlotConfig):
60 self.setup(indexPlot,nsubplot,winTitle)
61 self.__isPlotConfig = True
60 62
61 self.__yrange = None
63 if not(self.__isPlotIni):
64 if titleList == None:
65 titleList = []
66 thisDatetime = datetime.datetime.fromtimestamp(self.voltageObj.m_BasicHeader.utc)
67 txtdate = "Date: %s" %(thisDatetime.strftime("%d-%b-%Y"))
68 for i in range(nsubplot):
69 titleList.append("Channel: %d %s" %(i, txtdate))
70
71 if xlabelList == None:
72 xlabelList = []
73 for i in range(nsubplot):
74 xlabelList.append("")
75
76 if ylabelList == None:
77 ylabelList = []
78 for i in range(nsubplot):
79 ylabelList.append("")
80
81 if xmin == None: xmin = height[0]
82 if xmax == None: xmax = height[-1]
83 if ymin == None: ymin = numpy.nanmin(abs(databuffer))
84 if ymax == None: ymax = numpy.nanmax(abs(databuffer))
85
86 self.initPlot(xmin,xmax,ymin,ymax,titleList,xlabelList,ylabelList)
87 self.__isPlotIni = True
62 88
63 self.voltageObj = None
89 self.linearplotObj.setFigure(indexPlot)
64 90
65 self.nGraphs = 0
91 for index in range(nsubplot):
92 data = databuffer[index,:]
93 self.linearplotObj.plot(subplot=index+1,x=height,y=data,type=type)
66 94
67 self.indexPlot = index
95 self.linearplotObj.refresh()
68 96
69 self.graphObjList = []
70 97
71 self.voltageObj = Voltage
72 98
73
74 def __addGraph(self, subpage, title="", xlabel="", ylabel="", XAxisAsTime=False):
99
75 100
76 graphObj = LinearPlot()
77 graphObj.setup(subpage, title="", xlabel="", ylabel="", XAxisAsTime=False)
78 #graphObj.setScreenPos()
79
80 self.graphObjList.append(graphObj)
101
81 102
82 del graphObj
83
84 # def setXRange(self, xmin, xmax):
85 # self.__xrange = (xmin, xmax)
86 #
87 # def setYRange(self, ymin, ymax):
88 # self.__yrange = (ymin, ymax)
89 103
104 class RTI:
105 colorplotObj = None
90 106
91 def setup(self, titleList=None, xlabelList=None, ylabelList=None, XAxisAsTime=False):
92
93 nChan = int(self.voltageObj.m_SystemHeader.numChannels)
94
95 myTitle = ""
96 myXlabel = ""
97 myYlabel = ""
98
99 for chan in range(nChan):
100 if titleList != None:
101 myTitle = titleList[chan]
102 myXlabel = xlabelList[chan]
103 myYlabel = ylabelList[chan]
104
105 self.__addGraph(chan+1, title=myTitle, xlabel=myXlabel, ylabel=myYlabel, XAxisAsTime=XAxisAsTime)
106
107 self.nGraphs = nChan
108 self.__isPlotConfig = True
109
110 def iniPlot(self, winTitle=""):
111
112 plplot.plsstrm(self.indexPlot)
113 plplot.plparseopts([winTitle], plplot.PL_PARSE_FULL)
114 plplot.plsetopt("geometry", "%dx%d" %(700, 115*self.nGraphs))
115 plplot.plsdev("xwin")
116 plplot.plscolbg(255,255,255)
117 plplot.plscol0(1,0,0,0)
118 plplot.plinit()
119 plplot.plspause(False)
120 plplot.plssub(1, self.nGraphs)
121
122 self.__isPlotIni = True
123
124 def plotData(self, xmin=None, xmax=None, ymin=None, ymax=None, titleList=None, xlabelList=None, ylabelList=None, XAxisAsTime=False, type='iq', winTitle="Voltage"):
125
107 def __init__(self, Voltage, index):
108 self.__isPlotConfig = False
109 self.__isPlotIni = False
110 self.__xrange = None
111 self.__yrange = None
112 self.indexPlot = index
113 self.voltageObj = Voltage
114
115 def setup(self,indexPlot,nsubplot,winTitle='',colormap="br_green",showColorbar=False,showPowerProfile=False,XAxisAsTime=False):
116 self.colorplotObj = RtiPlot(indexPlot,nsubplot,winTitle,colormap,showColorbar,showPowerProfile,XAxisAsTime)
117
118 def initPlot(self,xmin,xmax,ymin,ymax,zmin,zmax,titleList,xlabelList,ylabelList,timezone,npoints):
119
120 nsubplot = self.voltageObj.nChannels
121 timedata = self.voltageObj.m_BasicHeader.utc
122
123 for index in range(nsubplot):
124 title = titleList[index]
125 xlabel = xlabelList[index]
126 ylabel = ylabelList[index]
127 subplot = index
128 self.colorplotObj.setup(subplot+1,xmin,xmax,ymin,ymax,zmin,zmax,title,xlabel,ylabel,timedata,timezone,npoints)
129
130 def plotData(self,
131 xmin=None,
132 xmax=None,
133 ymin=None,
134 ymax=None,
135 zmin=None,
136 zmax=None,
137 titleList=None,
138 xlabelList=None,
139 ylabelList=None,
140 winTitle='',
141 timezone='lt',
142 npoints=1000.0,
143 colormap="br_green",
144 showColorbar=True,
145 showPowerProfile=True,
146 XAxisAsTime=True):
147
148 databuffer = self.voltageObj.data
149 timedata = self.voltageObj.m_BasicHeader.utc
150 height = self.voltageObj.heightList
151 nsubplot = self.voltageObj.nChannels
152 indexPlot = self.indexPlot
153
126 154 if not(self.__isPlotConfig):
127 self.setup(titleList, xlabelList, ylabelList, XAxisAsTime)
128
155 self.setup(indexPlot,nsubplot,winTitle,colormap,showColorbar,showPowerProfile,XAxisAsTime)
156 self.__isPlotConfig = True
157
129 158 if not(self.__isPlotIni):
130 self.iniPlot(winTitle)
131
132 plplot.plsstrm(self.indexPlot)
133
134 data = self.voltageObj.data
135
136 x = self.voltageObj.heightList
159 if titleList == None:
160 titleList = []
161 thisDatetime = datetime.datetime.fromtimestamp(timedata)
162 txtdate = "Date: %s" %(thisDatetime.strftime("%d-%b-%Y"))
163 for i in range(nsubplot):
164 titleList.append("Channel: %d %s" %(i, txtdate))
165
166 if xlabelList == None:
167 xlabelList = []
168 for i in range(nsubplot):
169 xlabelList.append("")
170
171 if ylabelList == None:
172 ylabelList = []
173 for i in range(nsubplot):
174 ylabelList.append("")
175
176 if xmin == None: xmin = 0
177 if xmax == None: xmax = 23
178 if ymin == None: ymin = min(self.voltageObj.heightList)
179 if ymax == None: ymax = max(self.voltageObj.heightList)
180 if zmin == None: zmin = 0
181 if zmax == None: zmax = 50
182
183
184 self.initPlot(xmin,xmax,ymin,ymax,zmin,zmax,titleList,xlabelList,ylabelList,timezone,npoints)
185 self.__isPlotIni = True
137 186
138 if xmin == None: xmin = x[0]
139 if xmax == None: xmax = x[-1]
140 if ymin == None: ymin = numpy.nanmin(abs(data))
141 if ymax == None: ymax = numpy.nanmax(abs(data))
187
188 self.colorplotObj.setFigure(indexPlot)
142 189
143 plplot.plbop()
144 for chan in range(self.nGraphs):
145 y = data[chan,:]
146
147 self.graphObjList[chan].plotComplexData(x, y, xmin, xmax, ymin, ymax, 8, type)
190 if timezone == 'lt':
191 timedata = timedata - time.timezone
148 192
149 plplot.plflush()
150 plplot.pleop()
151
152 def end(self):
153 plplot.plend()
193 for index in range(nsubplot):
194 data = databuffer[index,:]
195 self.colorplotObj.plot(subplot=index+1,x=timedata,y=height,z=data)
154 196
155 class VoltagePlot(object):
156 '''
157 classdocs
158 '''
159
160 __m_Voltage = None
161
162 def __init__(self, voltageObj):
163 '''
164 Constructor
165 '''
166 self.__m_Voltage = voltageObj
167
168 def setup(self):
169 pass
170
171 def addGraph(self, type, xrange=None, yrange=None, zrange=None):
172 pass
173
174 def plotData(self):
175 pass
176
177 if __name__ == '__main__':
178
179 import numpy
180
181 plplot.plsetopt("geometry", "%dx%d" %(450*2, 200*2))
182 plplot.plsdev("xcairo")
183 plplot.plscolbg(255,255,255)
184 plplot.plscol0(1,0,0,0)
185 plplot.plinit()
186 plplot.plssub(1, 2)
187
188 nx = 64
189 ny = 100
190
191 data = numpy.random.uniform(-50,50,(nx,ny))
192
193 baseObj = RTI()
194 baseObj.setup(1, "Spectrum", "Frequency", "Range", "br_green", False, False)
195 baseObj.plotData(data)
196
197 data = numpy.random.uniform(-50,50,(nx,ny))
198
199 base2Obj = RTI()
200 base2Obj.setup(2, "Spectrum", "Frequency", "Range", "br_green", True, True)
201 base2Obj.plotData(data)
202
203 plplot.plend()
204 exit(0) No newline at end of file
197 self.colorplotObj.refresh()
@@ -238,6 +238,7 class SpectraProcessor:
238 238 self.dataOutObj.data_cspc = cspc
239 239 self.dataOutObj.data_dc = dc
240 240 self.dataOutObj.m_ProcessingHeader.blockSize = blocksize
241 self.dataOutObj.m_BasicHeader.utc = self.dataInObj.m_BasicHeader.utc
241 242
242 243
243 244 def addWriter(self,wrpath):
@@ -245,15 +246,12 class SpectraProcessor:
245 246 objWriter.setup(wrpath)
246 247 self.writerObjList.append(objWriter)
247 248
248
249 def addPlotter(self, index=None):
250
249 def addPlotter(self,index=None):
251 250 if index==None:
252 251 index = self.plotterObjIndex
253 252
254 253 plotObj = Spectrum(self.dataOutObj, index)
255 254 self.plotterObjList.append(plotObj)
256
257 255
258 256 def addIntegrator(self,N,timeInterval):
259 257
@@ -271,14 +269,43 class SpectraProcessor:
271 269
272 270 self.writerObjIndex += 1
273 271
274 def plotData(self,xmin=None, xmax=None, ymin=None, ymax=None, winTitle='', index=None):
272 def plotData(self,
273 xmin=None,
274 xmax=None,
275 ymin=None,
276 ymax=None,
277 zmin=None,
278 zmax=None,
279 titleList=None,
280 xlabelList=None,
281 ylabelList=None,
282 winTitle='',
283 colormap="br_green",
284 showColorbar=False,
285 showPowerProfile=False,
286 XAxisAsTime=False,
287 index=None):
288
275 289 if self.dataOutObj.flagNoData:
276 290 return 0
277 291
278 292 if len(self.plotterObjList) <= self.plotterObjIndex:
279 293 self.addPlotter(index)
280 294
281 self.plotterObjList[self.plotterObjIndex].plotData(xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,winTitle=winTitle)
295 self.plotterObjList[self.plotterObjIndex].plotData(xmin,
296 xmax,
297 ymin,
298 ymax,
299 zmin,
300 zmax,
301 titleList,
302 xlabelList,
303 ylabelList,
304 winTitle,
305 colormap,
306 showColorbar,
307 showPowerProfile,
308 XAxisAsTime)
282 309
283 310 self.plotterObjIndex += 1
284 311
@@ -340,7 +367,7 class SpectraProcessor:
340 367 noise = self.noiseObj.bySort(parm)
341 368
342 369 self.dataOutObj.noise = noise
343 print 10*numpy.log10(noise)
370 # print 10*numpy.log10(noise)
344 371
345 372 def selectChannels(self, channelList, pairList=[]):
346 373
@@ -14,6 +14,7 sys.path.append(path)
14 14 from Model.Voltage import Voltage
15 15 from IO.VoltageIO import VoltageWriter
16 16 from Graphics.VoltagePlot import Osciloscope
17 from Graphics.VoltagePlot import RTI
17 18
18 19 class VoltageProcessor:
19 20 '''
@@ -85,7 +86,14 class VoltageProcessor:
85 86 objWriter = VoltageWriter(self.dataOutObj)
86 87 objWriter.setup(wrpath)
87 88 self.writerObjList.append(objWriter)
88
89
90 def addRti(self,index=None):
91 if index==None:
92 index = self.plotterObjIndex
93
94 plotObj = RTI(self.dataOutObj, index)
95 self.plotterObjList.append(plotObj)
96
89 97 def addPlotter(self, index=None):
90 98 if index==None:
91 99 index = self.plotterObjIndex
@@ -118,10 +126,89 class VoltageProcessor:
118 126
119 127 self.writerObjList[self.writerObjIndex].putData()
120 128
121 # myWrObj = self.writerObjList[self.writerObjIndex]
122 # myWrObj.putData()
123
124 129 self.writerObjIndex += 1
130
131 def addScope(self,index=None):
132 if index==None:
133 index = self.plotterObjIndex
134
135 plotObj = Osciloscope(self.dataOutObj, index)
136 self.plotterObjList.append(plotObj)
137
138 def plotScope(self,
139 xmin=None,
140 xmax=None,
141 ymin=None,
142 ymax=None,
143 titleList=None,
144 xlabelList=None,
145 ylabelList=None,
146 winTitle='',
147 type="power",
148 index=None):
149
150 if self.dataOutObj.flagNoData:
151 return 0
152
153 if len(self.plotterObjList) <= self.plotterObjIndex:
154 self.addScope(index)
155
156 self.plotterObjList[self.plotterObjIndex].plotData(xmin,
157 xmax,
158 ymin,
159 ymax,
160 titleList,
161 xlabelList,
162 ylabelList,
163 winTitle,
164 type)
165
166 self.plotterObjIndex += 1
167
168 def plotRti(self,
169 xmin=None,
170 xmax=None,
171 ymin=None,
172 ymax=None,
173 zmin=None,
174 zmax=None,
175 titleList=None,
176 xlabelList=None,
177 ylabelList=None,
178 winTitle='',
179 timezone='lt',
180 npoints=1000.0,
181 colormap="br_green",
182 showColorbar=True,
183 showPowerProfile=False,
184 XAxisAsTime=True,
185 index=None):
186
187 if self.dataOutObj.flagNoData:
188 return 0
189
190 if len(self.plotterObjList) <= self.plotterObjIndex:
191 self.addRti(index)
192
193 self.plotterObjList[self.plotterObjIndex].plotData(xmin,
194 xmax,
195 ymin,
196 ymax,
197 zmin,
198 zmax,
199 titleList,
200 xlabelList,
201 ylabelList,
202 winTitle,
203 timezone,
204 npoints,
205 colormap,
206 showColorbar,
207 showPowerProfile,
208 XAxisAsTime)
209
210 self.plotterObjIndex += 1
211
125 212
126 213 def plotData(self,xmin=None, xmax=None, ymin=None, ymax=None, type='iq', winTitle='', index=None):
127 214 if self.dataOutObj.flagNoData:
@@ -1,15 +1,15
1 1 '''
2 Created on 27/03/2012
2 Created on Jul 31, 2012
3 3
4 4 @author $Author$
5 5 @version $Id$
6 6 '''
7
7 8 import os, sys
8 9 import time, datetime
9 10
10 11 from Model.Voltage import Voltage
11 12 from IO.VoltageIO import *
12 #from Graphics.VoltagePlot import Osciloscope
13 13
14 14 from Model.Spectra import Spectra
15 15 from IO.SpectraIO import *
@@ -24,23 +24,16 class TestSChain():
24 24 self.setValues()
25 25 self.createObjects()
26 26 self.testSChain()
27
28
27
29 28 def setValues( self ):
30 29
31 self.path = "/home/dsuarez/Projects" #1
30 self.path = "/home/dsuarez/Projects"
32 31 self.path = "/Users/jro/Documents/RadarData/EW_Drifts"
33 32 self.path = "/Users/jro/Documents/RadarData/MST_ISR/MST"
34 # self.startDateTime = datetime.datetime(2007,5,1,15,49,0)
35 # self.endDateTime = datetime.datetime(2007,5,1,23,0,0)
36 33
37 34 self.startDateTime = datetime.datetime(2009,01,1,0,0,0)
38 35 self.endDateTime = datetime.datetime(2009,01,31,0,20,0)
39 36
40 # self.startDateTime = datetime.datetime(2011,11,1,0,0,0)
41 # self.endDateTime = datetime.datetime(2011,12,31,0,20,0)
42
43
44 37 self.N = 4
45 38 self.npts = 8
46 39
@@ -50,51 +43,44 class TestSChain():
50 43 self.voltProcObj = VoltageProcessor()
51 44 self.specProcObj = SpectraProcessor()
52 45
53 voltObj1 = self.readerObj.setup(
46 self.voltObj1 = self.readerObj.setup(
54 47 path = self.path,
55 48 startDateTime = self.startDateTime,
56 49 endDateTime = self.endDateTime,
57 50 expLabel = '',
58 51 online = 0)
59 52
60 if not(voltObj1):
53 if not(self.voltObj1):
61 54 sys.exit(0)
62 55
63 voltObj2 = self.voltProcObj.setup(dataInObj = voltObj1)
56 self.voltObj2 = self.voltProcObj.setup(dataInObj = self.voltObj1)
64 57
65 specObj1 = self.specProcObj.setup(dataInObj = voltObj2,
58 self.specObj1 = self.specProcObj.setup(dataInObj = self.voltObj2,
66 59 nFFTPoints = 16)
67 60
68 # voltObj2 = self.voltProcObj.setup(dataInObj = voltObj1,
69 # dataOutObj = voltObj2)
70 #
71 # specObj1 = self.specProcObj.setup(dataInObj = voltObj2,
72 # dataOutObj =specObj1,
73 # nFFTPoints=16)
74
75 61
76 62 def testSChain( self ):
77 63
78 64 ini = time.time()
65
79 66 while(True):
80 67 self.readerObj.getData()
81 68
82 69 self.voltProcObj.init()
83 70
84 # self.voltProcObj.plotData(winTitle='VOLTAGE INPUT', index=1)
85 #
86 # self.voltProcObj.integrator(4)
87 #
88 # self.voltProcObj.plotData(winTitle='VOLTAGE AVG', index=2)
89 #
71 self.voltProcObj.plotScope(winTitle="Scope 1",type="iq", index=1)
90 72
73 self.voltProcObj.plotRti(winTitle='VOLTAGE INPUT', showPowerProfile=True, index=2)
74
75 self.voltProcObj.integrator(4)
76
91 77 self.specProcObj.init()
92 78
93 self.specProcObj.integrator(N=1)
94
95 self.specProcObj.plotData(winTitle='Spectra 1', index=1)
96
97
79 self.specProcObj.integrator(N=4)
80
81 # self.specProcObj.plotSpec(winTitle='Spectra Test', showColorbar=True,showPowerProfile=True,index=3)
82 self.specProcObj.plotData(winTitle='Spectra Test', showColorbar=True,showPowerProfile=True,index=3)
83
98 84 if self.readerObj.flagNoMoreFiles:
99 85 break
100 86
@@ -102,8 +88,6 class TestSChain():
102 88 print 'Block No %04d, Time: %s' %(self.readerObj.nTotalBlocks,
103 89 datetime.datetime.fromtimestamp(self.readerObj.m_BasicHeader.utc),)
104 90
105
106 # self.plotObj.end()
107 91
108 92 if __name__ == '__main__':
109 93 TestSChain() No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now