##// 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 import numpy
9 import numpy
10 import sys
11 import time
12 import datetime
13 import time
10 import plplot
14 import plplot
11
15
16
12 def cmap1_init(colormap="gray"):
17 def cmap1_init(colormap="gray"):
13
18
14 if colormap == None:
19 if colormap == None:
@@ -38,7 +43,43 def cmap1_init(colormap="gray"):
38 plplot.plscmap1l(0, i, h, l, s)
43 plplot.plscmap1l(0, i, h, l, s)
39
44
40 return None
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 if colormap=="br_green":
83 if colormap=="br_green":
43 ncolor = 256
84 ncolor = 256
44 # Hue ranges from blue (240 deg) to red (0 or 360 deg)
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 return rgb_lvl
189 return rgb_lvl
149
190
150 def setColormap(colormap="br_green"):
191 def setColormap(colormap="jet"):
151 cmap1_init(colormap)
192 cmap1_init(colormap)
152
193
153 class BaseGraph:
194 def initPlplot(indexPlot,ncol,nrow,winTitle,width,height):
154 """
195 plplot.plsstrm(indexPlot)
155
196 plplot.plparseopts([winTitle],plplot.PL_PARSE_FULL)
156 """
197 plplot.plsetopt("geometry", "%dx%d"%(width*ncol,height*nrow))
157 hasNotRange = True
198 plplot.plsdev("xwin")
158
199 plplot.plscolbg(255,255,255)
159 xrange = None
200 plplot.plscol0(1,0,0,0)
160 yrange = None
201 plplot.plinit()
161 zrange = None
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
208 objGraph.setColor(15) #Setting Line Color to White
164 ylabel = None
165 title = None
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
228 def setPlTitle(pltitle,color):
172 __colbox = None
229 setSubpages(1, 0)
173 __colleg = None
230 plplot.pladv(0)
174
231 plplot.plvpor(0., 1., 0., 1.)
175 __xpos = None
176 __ypos = None
177
232
178 __xopt = None #"bcnst"
233 if color == "black":
179 __yopt = None #"bcnstv"
234 plplot.plcol0(1)
180
235 if color == "white":
181 __xlpos = None
236 plplot.plcol0(15)
182 __ylpos = None
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 __xg = None
248 __xg = None
188 __yg = None
249 __yg = None
189
250 xdata = None
190 def __init__(self):
251 ydata = None
191 """
252 getGrid = True
192
253 xaxisIsTime = False
193 """
254 deltax = None
194 self.hasNotRange = True
255 xmin = None
195
256 xmax = None
196 self.xrange = None
257 def __init__(self,name,subplot,xpos,ypos,xlabel,ylabel,title,szchar,xrange,yrange,zrange=None,deltax=1.0):
197 self.yrange = None
258 self.setName(name)
198 self.zrange = None
259 self.setScreenPos(xpos, ypos)
199
260 self.setLabels(xlabel,ylabel,title)
200 self.xlabel = None
261 self.setSubPlot(subplot)
201 self.ylabel = None
262 self.setSizeOfChar(szchar)
202 self.title = None
263 self.setXYZrange(xrange,yrange,zrange)
203
264 self.getGrid = True
204 self.legends = None
265 self.xaxisIsTime = False
205
266 self.deltax = deltax
206 self.__name = None
267
207
268 def setXYZrange(self,xrange,yrange,zrange):
208 self.__colormap = None
269 self.xrange = xrange
209 self.__colbox = None
270 self.yrange = yrange
210 self.__colleg = None
271 self.zrange = zrange
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
226
272
227 def setName(self, name):
273 def setName(self, name):
228 self.__name = name
274 self.__name = name
229
275
230 def setScreenPos(self, xpos, ypos):
276 def setScreenPos(self,xpos,ypos):
231 self.__xpos = xpos
277 self.__xpos = xpos
232 self.__ypos = ypos
278 self.__ypos = ypos
233
279
234 def setOpt(self, xopt, yopt):
280 def setXYData(self,xdata=None,ydata=None,datatype="real"):
235 self.__xopt = xopt
281 if((xdata != None) and (ydata != None)):
236 self.__yopt = yopt
282 self.xdata = xdata
237
283 self.ydata = ydata
238 def setXAxisAsTime(self):
284 self.datatype = datatype
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")
256
285
257 plplot.plvpor(self.__xpos[0], self.__xpos[1], self.__ypos[0], self.__ypos[1])
286 if((self.xdata == None) and (self.ydata == None)):
258 plplot.plwind(float(xmin),
287 return None
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)
268
288
269 if not(nolabels):
289 return 1
270 plplot.pllab(self.xlabel, self.ylabel, self.title)
271
272
290
273 def colorbarPlot(self, xmin=0., xmax=1., ymin=0., ymax=1.):
291
274 data = numpy.arange(256)
292 def setLabels(self,xlabel=None,ylabel=None,title=None):
275 data = numpy.reshape(data, (1,-1))
293 if xlabel != None: self.xlabel = xlabel
276
294 if ylabel != None: self.ylabel = ylabel
277 plplot.plimage(data,
295 if title != None: self.title = title
278 float(xmin),
296
279 float(xmax),
297 def setSubPlot(self,subplot):
280 float(ymin),
298 self.__subplot = subplot
281 float(ymax),
299
282 0.,
300 def setSizeOfChar(self,szchar):
283 255.,
301 self.__szchar = szchar
284 float(xmin),
285 float(xmax),
286 float(ymin),
287 float(ymax))
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 if xmin == None: xmin = x[0]
314 if xmin == None: xmin = x[0]
292 if xmax == None: xmax = x[-1]
315 if xmax == None: xmax = x[-1]
293 if ymin == None: ymin = y[0]
316 if ymin == None: ymin = y[0]
294 if ymax == None: ymax = y[-1]
317 if ymax == None: ymax = y[-1]
295
318
319 plplot.plcol0(colline)
296 plplot.plline(x, y)
320 plplot.plline(x, y)
321 plplot.plcol0(1)
297
322
298 def basicXYwithErrorPlot(self):
323 def basicXYPlot(self, x, y, xmin=None, xmax=None, ymin=None, ymax=None):
299 pass
300
301 def basicLineTimePlot(self, x, y, xmin=None, xmax=None, ymin=None, ymax=None, colline=1):
302
324
303 if xmin == None: xmin = x[0]
325 if xmin == None: xmin = x[0]
304 if xmax == None: xmax = x[-1]
326 if xmax == None: xmax = x[-1]
305 if ymin == None: ymin = y[0]
327 if ymin == None: ymin = y[0]
306 if ymax == None: ymax = y[-1]
328 if ymax == None: ymax = y[-1]
307
329
308 plplot.plcol0(colline)
309 plplot.plline(x, y)
330 plplot.plline(x, y)
310 plplot.plcol0(1)
311
331
312 def basicPcolorPlot(self, data, x, y, xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None):
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 float(ymin),
351 float(ymin),
332 float(ymax)
352 float(ymax)
333 )
353 )
334
354
335 def __getBoxpltr(self, x, y, deltax=None, deltay=None):
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 raise ValueError, "x axis and y axis are empty"
358 raise ValueError, "x axis and y axis are empty"
339
359
340 if deltax == None: deltax = x[-1] - x[-2]
360 if deltax == None: deltax = x[-1] - x[-2]
@@ -349,555 +369,570 class BaseGraph:
349 self.__xg = xg
369 self.__xg = xg
350 self.__yg = yg
370 self.__yg = yg
351
371
352 def advPcolorPlot(self, data, x, y, zmin=0., zmax=0.):
372 return xg, yg
353 """
373
354 """
374
355
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):
356 if self.__xg == None and self.__yg == None:
376 if getGrid:
357 self.__getBoxpltr(x, y)
377 xg, yg = self.__getBoxpltr(x, y, deltax, deltay)
358
378 else:
359 plplot.plimagefr(data, x[0], x[-1], y[0], y[-1], 0., 0., zmin, zmax, plplot.pltr2, self.__xg, self.__yg)
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:
396 def colorbarPlot(self, xmin=0., xmax=1., ymin=0., ymax=1.):
363
397 data = numpy.arange(256)
364 linearGraphObj = BaseGraph()
398 data = numpy.reshape(data, (1,-1))
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):
387
399
388 if plplot.plgdev() == '':
400 plplot.plimage(data,
389 raise ValueError, "Plot device has not been initialize"
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)
414 plplot.plschr(0.0,self.__szchar-0.05)
392 plplot.plschr(0.0, self.__szchar)
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':
425 if self.xaxisIsTime:
399 xi = 0.12; yi = 0.14; xw = 0.78; yw = 0.80
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):
436
410 """
437 def delLabels(self):
411 """
438 self.setColor(15) #Setting Line Color to White
412
439 plplot.pllab(self.xlabel, self.ylabel, self.title)
413 self.linearGraphObj.setOpt("bcnts","bcntsv")
440 self.setColor(1) #Setting Line Color to Black
414 self.linearGraphObj.setup(title,
441
415 xlabel,
442
416 ylabel
443
417 )
444 def plotImage(self,x,y,z,xrange,yrange,zrange):
418
445 xi = x[0]
419 self.setScreenPos(width='medium')
446 xf = x[-1]
420
447 yi = y[0]
421 if XAxisAsTime:
448 yf = y[-1]
422 self.linearGraphObj.setXAxisAsTime()
449
423
450 plplot.plimage(z,
424 self.__subpage = subpage
451 float(xi),
425 # def setRanges(self, xrange, yrange, zrange):
452 float(xf),
426 #
453 float(yi),
427 # self.linearGraphObj.setRanges(xrange, yrange, zrange)
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):
473
430 """
474 def setFigure(self,indexPlot):
431 Inputs:
475 setStrm(indexPlot)
432
433 x : Numpy array of dimension 1
434 y : Numpy array of dimension 1
435
436 """
437
476
438 try:
477 def setPosition(self):
439 nX = numpy.shape(x)
440 except:
441 raise ValueError, "x is not a numpy array"
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]
482 xpos = [xi,xf]
446 if xmax == None: xmax = x[-1]
483 ypos = [yi,yf]
447 if ymin == None: ymin = y[0]
448 if ymax == None: ymax = y[-1]
449
484
450 self.__iniSubpage()
485 self.__xpos = xpos
451 self.linearGraphObj.plotBox(xmin, xmax, ymin, ymax)
486 self.__ypos = ypos
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
460
487
461 """
488 return xpos,ypos
489
490 def refresh(self):
491 plFlush()
462
492
463 try:
493 def setup(self,subplot,xmin,xmax,ymin,ymax,title,xlabel,ylabel):
464 nX = numpy.shape(x)
494 szchar = 1.10
465 except:
495 name = "linear"
466 raise ValueError, "x is not a numpy array"
496 key = name + "%d"%subplot
497 xrange = [xmin,xmax]
498 yrange = [ymin,ymax]
467
499
468 try:
500 xpos,ypos = self.setPosition()
469 nY = numpy.shape(y)
501 linearObj = BaseGraph(name,subplot,xpos,ypos,xlabel,ylabel,title,szchar,xrange,yrange)
470 except:
502 linearObj.plotBox(linearObj.xrange[0], linearObj.xrange[1], linearObj.yrange[0], linearObj.yrange[1], "bcnst", "bcnstv")
471 raise ValueError, "y is not a numpy array"
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]
509 linearObj = self.linearObjDic[key]
474 if xmax == None: xmax = x[-1]
510 linearObj.plotBox(linearObj.xrange[0], linearObj.xrange[1], linearObj.yrange[0], linearObj.yrange[1], "bcst", "bcst")
475 if ymin == None: ymin = y[0]
476 if ymax == None: ymax = y[-1]
477
511
478 self.__iniSubpage()
512 if linearObj.setXYData() != None:
479 self.linearGraphObj.plotBox(xmin, xmax, ymin, ymax)
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 if type.lower() == 'power':
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 if type.lower() == 'iq':
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)
532 linearObj.setXYData(x,y,"complex")
487 self.linearGraphObj.basicLineTimePlot(x, y.imag, xmin, xmax, ymin, ymax, colline+1)
488
489 class ColorPlot:
490
491 colorGraphObj = BaseGraph()
492
493 graphObjDict = {}
494
533
495 __subpage = 0
534 linearObj.plotBox(linearObj.xrange[0], linearObj.xrange[1], linearObj.yrange[0], linearObj.yrange[1], "bcst", "bcst")
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 = {}
515
535
516 self.__subpage = 0
517 self.__showColorbar = False
518 self.__showPowerProfile = True
519
536
520 self.__szchar = 0.65
537 # linearObj.plotBox(linearObj.xrange[0], linearObj.xrange[1], linearObj.yrange[0], linearObj.yrange[1], "bc", "bc")
521 self.__xrange = None
538 # linearObj.basicXYPlot(data,y)
522 self.__yrange = None
539 # linearObj.setXYData(data,y)
523 self.__zrange = None
524
540
525 key = "colorplot"
541
526 self.colorGraphObj = BaseGraph()
527 self.colorGraphObj.setName(key)
528
542
529 def setup(self, subpage, title="", xlabel="Frequency", ylabel="Range", colormap="br_green", showColorbar=False, showPowerProfile=False, XAxisAsTime=False):
543 class SpectraPlot:
530 """
544 pcolorObjDic = {}
531 """
545 colorbarObjDic = {}
532
546 pwprofileObjDic = {}
533 self.colorGraphObj.setOpt("bcnts","bcntsv")
547 showColorbar = None
534 self.colorGraphObj.setup(title,
548 showPowerProfile = None
535 xlabel,
549 XAxisAsTime = None
536 ylabel
550 widht = None
537 )
551 height = None
538
552 __spcxpos = None
539 self.__subpage = subpage
553 __spcypos = None
540 self.__colormap = colormap
554 __cmapxpos = None
541 self.__showColorbar = showColorbar
555 __cmapypos = None
542 self.__showPowerProfile = showPowerProfile
556 __profxpos = None
543
557 __profypos = None
544 if showColorbar:
558 __lastTitle = None
545 key = "colorbar"
559
546
560 def __init__(self,indexPlot,nsubplot,winTitle,colormap,showColorbar,showPowerProfile,XAxisAsTime):
547 cmapObj = BaseGraph()
561 self.width = 460
548 cmapObj.setName(key)
562 self.height = 300
549 cmapObj.setOpt("bc","bcmtv")
563 self.showColorbar = showColorbar
550 cmapObj.setup(title="dBs",
564 self.showPowerProfile = showPowerProfile
551 xlabel="",
565 self.XAxisAsTime = XAxisAsTime
552 ylabel="",
566
553 colormap=colormap)
567 nrow = 2
554
568 if (nsubplot%2)==0:
555 self.graphObjDict[key] = cmapObj
569 ncol = nsubplot/nrow
556
570 else:
557
571 ncol = int(nsubplot)/nrow + 1
558 if showPowerProfile:
572
559 key = "powerprof"
573 initPlplot(indexPlot,ncol,nrow,winTitle,self.width,self.height)
560
574 setColormap(colormap)
561 powObj = BaseGraph()
575 self.ncol = ncol
562 powObj.setName(key)
576 self.nrow = nrow
563 powObj.setOpt("bcntg","bc")
577
564 powObj.setup(title="Power Profile",
578 def setFigure(self,indexPlot):
565 xlabel="dB",
579 setStrm(indexPlot)
566 ylabel="")
580
567
581 def setSpectraPos(self): #modificar valores de acuerdo al colorbar y pwprofile
568 self.graphObjDict[key] = powObj
582 if self.showPowerProfile: xi = 0.09; xf = 0.6 #0.075
569
583 else: xi = 0.15; xf = 0.8 #0.8,0.7,0.5
570 self.setScreenPos(width='small')
584 yi = 0.15; yf = 0.80
571
572 if XAxisAsTime:
573 self.colorGraphObj.setXAxisAsTime()
574
575 def __iniSubpage(self):
576
585
577 if plplot.plgdev() == '':
586 xpos = [xi,xf]
578 raise ValueError, "Plot device has not been initialize"
587 ypos = [yi,yf]
579
588
580 plplot.pladv(self.__subpage)
589 self.__spcxpos = xpos
581 plplot.plschr(0.0, self.__szchar)
590 self.__spcypos = ypos
582
591
583 setColormap(self.__colormap)
592 return xpos,ypos
584
593
585 def setScreenPos(self, width='small'):
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':
599 xpos = [xi,xf]
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
600 ypos = [yi,yf]
589
601
590 if width == 'medium':
602 self.__cmapxpos = xpos
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
603 self.__cmapypos = ypos
604
605 return xpos,ypos
606
607 def setPowerprofileScreenPos(self):
592
608
593 if self.__showColorbar:
609 xi = self.__cmapxpos[1] + 0.07; xf = xi + 0.25
594 xw -= xcmapw + deltaxcmap
610 yi = self.__spcypos[0]; yf = self.__spcypos[1]
595
611
596 if self.__showPowerProfile:
612 xpos = [xi,xf]
597 xw -= xpoww + deltaxpow
613 ypos = [yi,yf]
598
599 xf = xi + xw
600 yf = yi + yw
601 xcmapf = xf
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:
618 return xpos,ypos
606 xcmapi = xf + deltaxcmap
619
607 xcmapf = xcmapi + xcmapw
620 def setup(self,subplot,xmin,xmax,ymin,ymax,zmin,zmax,title,xlabel,ylabel):
608
621 # Config Spectra plot
609 key = "colorbar"
622 szchar = 0.7
610 cmapObj = self.graphObjDict[key]
623 name = "spc"
611 cmapObj.setScreenPos([xcmapi, xcmapf], [yi, yf])
624 key = name + "%d"%subplot
612
625 xrange = [xmin,xmax]
613 if self.__showPowerProfile:
626 yrange = [ymin,ymax]
614
627 zrange = [zmin,zmax]
615 xpowi = xcmapf + deltaxpow
628
616 xpowf = xpowi + xpoww
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"
655 xpos,ypos = self.setPowerprofileScreenPos()
619 powObj = self.graphObjDict[key]
656 xrange = [zmin,zmax]
620 powObj.setScreenPos([xpowi, xpowf], [yi, yf])
657 yrange = [ymin,ymax]
621
658 powObj = BaseGraph(name,subplot,xpos,ypos,"dB","","Power Profile",szchar,xrange,yrange)
622
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 = ''):
665 def printTitle(self,pltitle):
625 """
666 if self.__lastTitle != None:
626 Inputs:
667 setPlTitle(self.__lastTitle,"white")
627
668
628 x : Numpy array of dimension 1
669 self.__lastTitle = pltitle
629 y : Numpy array of dimension 1
630
670
631 """
671 setPlTitle(pltitle,"black")
632
672
633 try:
673 setSubpages(self.ncol,self.nrow)
634 nX, nY = numpy.shape(data)
635 except:
636 raise ValueError, "data is not a numpy array"
637
674
638 if x == None: x = numpy.arange(nX)
675 def plot(self,subplot,x,y,z,subtitle):
639 if y == None: y = numpy.arange(nY)
676 # Spectra plot
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)
647
677
648 plplot.plschr(0.0, self.__szchar)
678 name = "spc"
649 self.__iniSubpage()
679 key = name + "%d"%subplot
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)
653
680
654 if self.__showColorbar:
681 # newx = [x[0],x[-1]]
655
682 pcolorObj = self.pcolorObjDic[key]
656
683 pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], "bcst", "bcst")
657 key = "colorbar"
684 pcolorObj.delLabels()
658 cmapObj = self.graphObjDict[key]
685 pcolorObj.setLabels(title=subtitle)
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
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 = {}
754 def setFigure(self,indexPlot):
690 showColorbar = False
755 setStrm(indexPlot)
691 showPowerProfile = True
692
693 __szchar = 0.7
694 __xrange = None
695 __yrange = None
696 __zrange = None
697
698 colorGraphObj = BaseGraph()
699
756
700 def __init__(self):
757 def setRtiScreenPos(self):
701
758
702 key = "colorplot"
759 if self.showPowerProfile: xi = 0.07; xf = 0.65
703 self.colorGraphObj.setName(key)
760 else: xi = 0.07; xf = 0.9
704
761 yi = 0.15; yf = 0.80
705 self.__subpage = 0
706
707 self.graphObjDict[key] = self.colorGraphObj
708
709 def __iniSubpage(self):
710
762
711 if plplot.plgdev() == '':
763 xpos = [xi,xf]
712 raise ValueError, "Plot device has not been initialize"
764 ypos = [yi,yf]
713
765
714 plplot.pladv(self.__subpage)
766 self.__rtixpos = xpos
715 plplot.plschr(0.0, self.__szchar)
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):
771 def setColorbarScreenPos(self):
720
772
721 if self.showColorbar:
773 xi = self.__rtixpos[1] + 0.03; xf = xi + 0.03
722 xw -= xcmapw + deltaxcmap
723
724 if self.showPowerProfile:
725 xw -= xpoww + deltaxpow
726
774
727 xf = xi + xw
775 yi = self.__rtiypos[0]; yf = self.__rtiypos[1]
728 yf = yi + yw
729 xcmapf = xf
730
776
731 self.colorGraphObj.setScreenPos([xi, xf], [yi, yf])
777 xpos = [xi,xf]
778 ypos = [yi,yf]
732
779
733 if self.showColorbar:
780 self.__cmapxpos = xpos
734 xcmapi = xf + deltaxcmap
781 self.__cmapypos = ypos
735 xcmapf = xcmapi + xcmapw
782
736
783 return xpos,ypos
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])
749
784
750 def setRanges(self, xrange, yrange, zrange):
785 def setPowerprofileScreenPos(self):
751
752 self.colorGraphObj.setRanges(xrange, yrange, zrange)
753
754 keyList = self.graphObjDict.keys()
755
786
756 key = "colorbar"
787 xi = self.__cmapxpos[1] + 0.05; xf = xi + 0.20
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)
765
788
766 def setup(self, subpage, title="", xlabel="", ylabel="", colormap="jet", showColorbar=False, showPowerProfile=False, XAxisAsTime=False):
789 yi = self.__rtiypos[0]; yf = self.__rtiypos[1]
767 """
768 """
769
790
770 self.colorGraphObj.setSubpage(subpage)
791 xpos = [xi,xf]
771 self.colorGraphObj.setSzchar(self.__szchar)
792 ypos = [yi,yf]
772 self.colorGraphObj.setOpt("bcnts","bcntsv")
773 self.colorGraphObj.setup(title,
774 xlabel,
775 ylabel,
776 colormap)
777
793
778 if showColorbar:
794 self.__profxpos = [xi,xf]
779 key = "colorbar"
795 self.__profypos = [yi,yf]
780
796
781 cmapObj = BaseGraph()
797 return xpos,ypos
782 cmapObj.setName(key)
798
783 cmapObj.setSubpage(subpage)
799 def setup(self,subplot,xmin,xmax,ymin,ymax,zmin,zmax,title,xlabel,ylabel,timedata,timezone="lt",npoints=100):
784 cmapObj.setSzchar(self.__szchar)
800 # Config Rti plot
785 cmapObj.setOpt("bc","bcmt")
801 szchar = 1.10
786 cmapObj.setup(title="dBs",
802 name = "rti"
787 xlabel="",
803 key = name + "%d"%subplot
788 ylabel="",
804
789 colormap=colormap)
805 # xmin, xmax --> minHour, max Hour : valores que definen el ejex x=[horaInicio,horaFinal]
790
806 thisDateTime = datetime.datetime.fromtimestamp(timedata)
791 self.graphObjDict[key] = cmapObj
807 startDateTime = datetime.datetime(thisDateTime.year,thisDateTime.month,thisDateTime.day,xmin,0,0)
792
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:
835
795 key = "powerprof"
836 # Config Colorbar
796
837 if self.showColorbar:
797 powObj = BaseGraph()
838 szchar = 0.9
798 powObj.setName(key)
839 name = "colorbar"
799 powObj.setSubpage(subpage)
840 key = name + "%d"%subplot
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
809
841
810 self.showColorbar = showColorbar
842 xpos,ypos = self.setColorbarScreenPos()
811 self.showPowerProfile = showPowerProfile
843 xrange = [0.,1.]
812 self.setScreenPos()
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 if self.showPowerProfile:
853 if self.showPowerProfile:
850 power = numpy.average(data, axis=1)
854 szchar = 0.8
851
855 name = "pwprofile"
852 step = (ymax - ymin)/(nY-1)
856 key = name + "%d"%subplot
853 heis = numpy.arange(ymin, ymax + step, step)
857
854
858 xpos,ypos = self.setPowerprofileScreenPos()
855 key = "powerprof"
859 xrange = [zmin,zmax]
856 powObj = self.graphObjDict[key]
860 yrange = [ymin,ymax]
857 powObj.basicXYPlot(power, heis)
861 powObj = BaseGraph(name,subplot,xpos,ypos,"dB","","Power Profile",szchar,xrange,yrange)
858
862 powObj.setLineStyle(2)
859 if __name__ == '__main__':
863 powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bcntg", "bc")
860
864 powObj.setLineStyle(1)
861 import numpy
865 powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bc", "bc")
862 plplot.plsetopt("geometry", "%dx%d" %(350*2, 300*2))
866 self.pwprofileObjDic[key] = powObj
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)
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()
869 def plot(self,subplot,x,y,z):
898
870 # RTI plot
899 plplot.plspause(1)
871 name = "rti"
900 plplot.plend()
872 key = name + "%d"%subplot
901 exit(0)
873
902
874 data = numpy.reshape(z, (1,-1))
903
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 @version $Id$
5 @version $Id$
6 '''
6 '''
7
7
8 import os, sys
9 import numpy
8 import numpy
10 import datetime
9 import os
10 import sys
11 import plplot
11 import plplot
12 import datetime
12
13
13 path = os.path.split(os.getcwd())[0]
14 path = os.path.split(os.getcwd())[0]
14 sys.path.append(path)
15 sys.path.append(path)
@@ -17,188 +18,102 from Graphics.BaseGraph import *
17 from Model.Spectra import Spectra
18 from Model.Spectra import Spectra
18
19
19 class Spectrum:
20 class Spectrum:
20
21 colorplotObj = None
21 __isPlotConfig = False
22
23 __isPlotIni = False
24
25 __xrange = None
26
27 __yrange = None
28
29 nGraphs = 0
30
22
31 indexPlot = None
23 def __init__(self,Spectra, index):
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
57 self.__isPlotConfig = False
24 self.__isPlotConfig = False
58
59 self.__isPlotIni = False
25 self.__isPlotIni = False
60
61 self.__xrange = None
26 self.__xrange = None
62
63 self.__yrange = None
27 self.__yrange = None
64
65 self.nGraphs = 0
28 self.nGraphs = 0
66
67 self.indexPlot = index
29 self.indexPlot = index
68
69 self.graphObjList = []
70
71 self.spectraObj = Spectra
30 self.spectraObj = Spectra
72
73
31
74 def __addGraph(self, subpage, title="", xlabel="", ylabel="", showColorbar=False, showPowerProfile=True, XAxisAsTime=False):
32 def setup(self,indexPlot,nsubplot,winTitle='',colormap="br_green",showColorbar=False,showPowerProfile=False,XAxisAsTime=False):
75
33 self.colorplotObj = SpectraPlot(indexPlot,nsubplot,winTitle,colormap,showColorbar,showPowerProfile,XAxisAsTime)
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
87
34
88 def setup(self, titleList=None, xlabelList=None, ylabelList=None, showColorbar=False, showPowerProfile=True, XAxisAsTime=False):
35 def initPlot(self,xmin,xmax,ymin,ymax,zmin,zmax,titleList,xlabelList,ylabelList):
89
36 nsubplot = self.spectraObj.nChannels
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)
116
37
117 self.nGraphs = nChan
38 for index in range(nsubplot):
118 self.__isPlotConfig = True
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)
65 nsubplot = self.spectraObj.nChannels
123 #ny = int(self.nGraphs/nx)
66 nsubplot, nX, nY = numpy.shape(databuffer)
124
67
125 plplot.plsstrm(self.indexPlot)
68 x = numpy.arange(nX)
126 plplot.plparseopts([winTitle], plplot.PL_PARSE_FULL)
69 y = self.spectraObj.heightList
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)
135
70
136 self.__nx = nx
71 indexPlot = self.indexPlot
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"):
142
72
143 if not(self.__isPlotConfig):
73 if not(self.__isPlotConfig):
144 self.setup(titleList,
74 self.setup(indexPlot,nsubplot,winTitle,colormap,showColorbar,showPowerProfile,XAxisAsTime)
145 xlabelList,
75 self.__isPlotConfig = True
146 ylabelList,
147 showColorbar,
148 showPowerProfile,
149 XAxisAsTime)
150
76
151 if not(self.__isPlotIni):
77 if not(self.__isPlotIni):
152 self.iniPlot(winTitle)
78 if titleList == None:
153
79 titleList = []
154 plplot.plsstrm(self.indexPlot)
80 for i in range(nsubplot):
155
81 titleList.append("Channel: %d - Noise: %.2f" %(i, noise[i]))
156 data = 10.*numpy.log10(self.spectraObj.data_spc)
82
157 noise = 10.*numpy.log10(self.spectraObj.noise)
83 if xlabelList == None:
158 #data.shape = Channels x Heights x Profiles
84 xlabelList = []
159 # data = numpy.transpose( data, (0,2,1) )
85 for i in range(nsubplot):
160 #data.shape = Channels x Profiles x Heights
86 xlabelList.append("")
161
87
162 nChan, nX, nY = numpy.shape(data)
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)
103 self.colorplotObj.setFigure(indexPlot)
165 y = self.spectraObj.heightList
166
104
167 thisDatetime = datetime.datetime.fromtimestamp(self.spectraObj.m_BasicHeader.utc)
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]
108 self.colorplotObj.printTitle(pltitle) #setPlTitle(pltitle)
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))
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)
116
193 plplot.pladv(0)
117 self.colorplotObj.refresh()
194 plplot.plvpor(0., 1., 0., 1.)
118
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
202
119
203 if __name__ == '__main__':
204 pass No newline at end of file
@@ -4,9 +4,9 Created on Feb 7, 2012
4 @author $Author$
4 @author $Author$
5 @version $Id$
5 @version $Id$
6 '''
6 '''
7 import os, sys
8 import numpy
7 import numpy
9 import plplot
8 import os
9 import sys
10
10
11 path = os.path.split(os.getcwd())[0]
11 path = os.path.split(os.getcwd())[0]
12 sys.path.append(path)
12 sys.path.append(path)
@@ -15,190 +15,183 from Graphics.BaseGraph import *
15 from Model.Voltage import Voltage
15 from Model.Voltage import Voltage
16
16
17 class Osciloscope:
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
34 for index in range(nsubplot):
26
35 title = titleList[index]
27 __xrange = None
36 xlabel = xlabelList[index]
28
37 ylabel = ylabelList[index]
29 __yrange = None
38 subplot = index
30
39 self.linearplotObj.setup(subplot+1,xmin,xmax,ymin,ymax,title,xlabel,ylabel)
31 voltageObj = Voltage()
32
33 nGraphs = 0
34
40
35 indexPlot = None
41 def plotData(self,
36
42 xmin=None,
37 graphObjList = []
43 xmax=None,
38 m_LinearPlot= LinearPlot()
44 ymin=None,
39
45 ymax=None,
40
46 titleList=None,
41 m_Voltage= Voltage()
47 xlabelList=None,
42
48 ylabelList=None,
43
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
59 if not(self.__isPlotConfig):
58
60 self.setup(indexPlot,nsubplot,winTitle)
59 self.__xrange = None
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
99
74 def __addGraph(self, subpage, title="", xlabel="", ylabel="", XAxisAsTime=False):
75
100
76 graphObj = LinearPlot()
101
77 graphObj.setup(subpage, title="", xlabel="", ylabel="", XAxisAsTime=False)
78 #graphObj.setScreenPos()
79
80 self.graphObjList.append(graphObj)
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):
107 def __init__(self, Voltage, index):
92
108 self.__isPlotConfig = False
93 nChan = int(self.voltageObj.m_SystemHeader.numChannels)
109 self.__isPlotIni = False
94
110 self.__xrange = None
95 myTitle = ""
111 self.__yrange = None
96 myXlabel = ""
112 self.indexPlot = index
97 myYlabel = ""
113 self.voltageObj = Voltage
98
114
99 for chan in range(nChan):
115 def setup(self,indexPlot,nsubplot,winTitle='',colormap="br_green",showColorbar=False,showPowerProfile=False,XAxisAsTime=False):
100 if titleList != None:
116 self.colorplotObj = RtiPlot(indexPlot,nsubplot,winTitle,colormap,showColorbar,showPowerProfile,XAxisAsTime)
101 myTitle = titleList[chan]
117
102 myXlabel = xlabelList[chan]
118 def initPlot(self,xmin,xmax,ymin,ymax,zmin,zmax,titleList,xlabelList,ylabelList,timezone,npoints):
103 myYlabel = ylabelList[chan]
119
104
120 nsubplot = self.voltageObj.nChannels
105 self.__addGraph(chan+1, title=myTitle, xlabel=myXlabel, ylabel=myYlabel, XAxisAsTime=XAxisAsTime)
121 timedata = self.voltageObj.m_BasicHeader.utc
106
122
107 self.nGraphs = nChan
123 for index in range(nsubplot):
108 self.__isPlotConfig = True
124 title = titleList[index]
109
125 xlabel = xlabelList[index]
110 def iniPlot(self, winTitle=""):
126 ylabel = ylabelList[index]
111
127 subplot = index
112 plplot.plsstrm(self.indexPlot)
128 self.colorplotObj.setup(subplot+1,xmin,xmax,ymin,ymax,zmin,zmax,title,xlabel,ylabel,timedata,timezone,npoints)
113 plplot.plparseopts([winTitle], plplot.PL_PARSE_FULL)
129
114 plplot.plsetopt("geometry", "%dx%d" %(700, 115*self.nGraphs))
130 def plotData(self,
115 plplot.plsdev("xwin")
131 xmin=None,
116 plplot.plscolbg(255,255,255)
132 xmax=None,
117 plplot.plscol0(1,0,0,0)
133 ymin=None,
118 plplot.plinit()
134 ymax=None,
119 plplot.plspause(False)
135 zmin=None,
120 plplot.plssub(1, self.nGraphs)
136 zmax=None,
121
137 titleList=None,
122 self.__isPlotIni = True
138 xlabelList=None,
123
139 ylabelList=None,
124 def plotData(self, xmin=None, xmax=None, ymin=None, ymax=None, titleList=None, xlabelList=None, ylabelList=None, XAxisAsTime=False, type='iq', winTitle="Voltage"):
140 winTitle='',
125
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 if not(self.__isPlotConfig):
154 if not(self.__isPlotConfig):
127 self.setup(titleList, xlabelList, ylabelList, XAxisAsTime)
155 self.setup(indexPlot,nsubplot,winTitle,colormap,showColorbar,showPowerProfile,XAxisAsTime)
128
156 self.__isPlotConfig = True
157
129 if not(self.__isPlotIni):
158 if not(self.__isPlotIni):
130 self.iniPlot(winTitle)
159 if titleList == None:
131
160 titleList = []
132 plplot.plsstrm(self.indexPlot)
161 thisDatetime = datetime.datetime.fromtimestamp(timedata)
133
162 txtdate = "Date: %s" %(thisDatetime.strftime("%d-%b-%Y"))
134 data = self.voltageObj.data
163 for i in range(nsubplot):
135
164 titleList.append("Channel: %d %s" %(i, txtdate))
136 x = self.voltageObj.heightList
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]
187
139 if xmax == None: xmax = x[-1]
188 self.colorplotObj.setFigure(indexPlot)
140 if ymin == None: ymin = numpy.nanmin(abs(data))
141 if ymax == None: ymax = numpy.nanmax(abs(data))
142
189
143 plplot.plbop()
190 if timezone == 'lt':
144 for chan in range(self.nGraphs):
191 timedata = timedata - time.timezone
145 y = data[chan,:]
146
147 self.graphObjList[chan].plotComplexData(x, y, xmin, xmax, ymin, ymax, 8, type)
148
192
149 plplot.plflush()
193 for index in range(nsubplot):
150 plplot.pleop()
194 data = databuffer[index,:]
151
195 self.colorplotObj.plot(subplot=index+1,x=timedata,y=height,z=data)
152 def end(self):
153 plplot.plend()
154
196
155 class VoltagePlot(object):
197 self.colorplotObj.refresh()
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
@@ -238,6 +238,7 class SpectraProcessor:
238 self.dataOutObj.data_cspc = cspc
238 self.dataOutObj.data_cspc = cspc
239 self.dataOutObj.data_dc = dc
239 self.dataOutObj.data_dc = dc
240 self.dataOutObj.m_ProcessingHeader.blockSize = blocksize
240 self.dataOutObj.m_ProcessingHeader.blockSize = blocksize
241 self.dataOutObj.m_BasicHeader.utc = self.dataInObj.m_BasicHeader.utc
241
242
242
243
243 def addWriter(self,wrpath):
244 def addWriter(self,wrpath):
@@ -245,15 +246,12 class SpectraProcessor:
245 objWriter.setup(wrpath)
246 objWriter.setup(wrpath)
246 self.writerObjList.append(objWriter)
247 self.writerObjList.append(objWriter)
247
248
248
249 def addPlotter(self,index=None):
249 def addPlotter(self, index=None):
250
251 if index==None:
250 if index==None:
252 index = self.plotterObjIndex
251 index = self.plotterObjIndex
253
252
254 plotObj = Spectrum(self.dataOutObj, index)
253 plotObj = Spectrum(self.dataOutObj, index)
255 self.plotterObjList.append(plotObj)
254 self.plotterObjList.append(plotObj)
256
257
255
258 def addIntegrator(self,N,timeInterval):
256 def addIntegrator(self,N,timeInterval):
259
257
@@ -271,14 +269,43 class SpectraProcessor:
271
269
272 self.writerObjIndex += 1
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 if self.dataOutObj.flagNoData:
289 if self.dataOutObj.flagNoData:
276 return 0
290 return 0
277
291
278 if len(self.plotterObjList) <= self.plotterObjIndex:
292 if len(self.plotterObjList) <= self.plotterObjIndex:
279 self.addPlotter(index)
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 self.plotterObjIndex += 1
310 self.plotterObjIndex += 1
284
311
@@ -340,7 +367,7 class SpectraProcessor:
340 noise = self.noiseObj.bySort(parm)
367 noise = self.noiseObj.bySort(parm)
341
368
342 self.dataOutObj.noise = noise
369 self.dataOutObj.noise = noise
343 print 10*numpy.log10(noise)
370 # print 10*numpy.log10(noise)
344
371
345 def selectChannels(self, channelList, pairList=[]):
372 def selectChannels(self, channelList, pairList=[]):
346
373
@@ -14,6 +14,7 sys.path.append(path)
14 from Model.Voltage import Voltage
14 from Model.Voltage import Voltage
15 from IO.VoltageIO import VoltageWriter
15 from IO.VoltageIO import VoltageWriter
16 from Graphics.VoltagePlot import Osciloscope
16 from Graphics.VoltagePlot import Osciloscope
17 from Graphics.VoltagePlot import RTI
17
18
18 class VoltageProcessor:
19 class VoltageProcessor:
19 '''
20 '''
@@ -85,7 +86,14 class VoltageProcessor:
85 objWriter = VoltageWriter(self.dataOutObj)
86 objWriter = VoltageWriter(self.dataOutObj)
86 objWriter.setup(wrpath)
87 objWriter.setup(wrpath)
87 self.writerObjList.append(objWriter)
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 def addPlotter(self, index=None):
97 def addPlotter(self, index=None):
90 if index==None:
98 if index==None:
91 index = self.plotterObjIndex
99 index = self.plotterObjIndex
@@ -118,10 +126,89 class VoltageProcessor:
118
126
119 self.writerObjList[self.writerObjIndex].putData()
127 self.writerObjList[self.writerObjIndex].putData()
120
128
121 # myWrObj = self.writerObjList[self.writerObjIndex]
122 # myWrObj.putData()
123
124 self.writerObjIndex += 1
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 def plotData(self,xmin=None, xmax=None, ymin=None, ymax=None, type='iq', winTitle='', index=None):
213 def plotData(self,xmin=None, xmax=None, ymin=None, ymax=None, type='iq', winTitle='', index=None):
127 if self.dataOutObj.flagNoData:
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 @author $Author$
4 @author $Author$
5 @version $Id$
5 @version $Id$
6 '''
6 '''
7
7 import os, sys
8 import os, sys
8 import time, datetime
9 import time, datetime
9
10
10 from Model.Voltage import Voltage
11 from Model.Voltage import Voltage
11 from IO.VoltageIO import *
12 from IO.VoltageIO import *
12 #from Graphics.VoltagePlot import Osciloscope
13
13
14 from Model.Spectra import Spectra
14 from Model.Spectra import Spectra
15 from IO.SpectraIO import *
15 from IO.SpectraIO import *
@@ -24,23 +24,16 class TestSChain():
24 self.setValues()
24 self.setValues()
25 self.createObjects()
25 self.createObjects()
26 self.testSChain()
26 self.testSChain()
27
27
28
29 def setValues( self ):
28 def setValues( self ):
30
29
31 self.path = "/home/dsuarez/Projects" #1
30 self.path = "/home/dsuarez/Projects"
32 self.path = "/Users/jro/Documents/RadarData/EW_Drifts"
31 self.path = "/Users/jro/Documents/RadarData/EW_Drifts"
33 self.path = "/Users/jro/Documents/RadarData/MST_ISR/MST"
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 self.startDateTime = datetime.datetime(2009,01,1,0,0,0)
34 self.startDateTime = datetime.datetime(2009,01,1,0,0,0)
38 self.endDateTime = datetime.datetime(2009,01,31,0,20,0)
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 self.N = 4
37 self.N = 4
45 self.npts = 8
38 self.npts = 8
46
39
@@ -50,51 +43,44 class TestSChain():
50 self.voltProcObj = VoltageProcessor()
43 self.voltProcObj = VoltageProcessor()
51 self.specProcObj = SpectraProcessor()
44 self.specProcObj = SpectraProcessor()
52
45
53 voltObj1 = self.readerObj.setup(
46 self.voltObj1 = self.readerObj.setup(
54 path = self.path,
47 path = self.path,
55 startDateTime = self.startDateTime,
48 startDateTime = self.startDateTime,
56 endDateTime = self.endDateTime,
49 endDateTime = self.endDateTime,
57 expLabel = '',
50 expLabel = '',
58 online = 0)
51 online = 0)
59
52
60 if not(voltObj1):
53 if not(self.voltObj1):
61 sys.exit(0)
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 nFFTPoints = 16)
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 def testSChain( self ):
62 def testSChain( self ):
77
63
78 ini = time.time()
64 ini = time.time()
65
79 while(True):
66 while(True):
80 self.readerObj.getData()
67 self.readerObj.getData()
81
68
82 self.voltProcObj.init()
69 self.voltProcObj.init()
83
70
84 # self.voltProcObj.plotData(winTitle='VOLTAGE INPUT', index=1)
71 self.voltProcObj.plotScope(winTitle="Scope 1",type="iq", index=1)
85 #
86 # self.voltProcObj.integrator(4)
87 #
88 # self.voltProcObj.plotData(winTitle='VOLTAGE AVG', index=2)
89 #
90
72
73 self.voltProcObj.plotRti(winTitle='VOLTAGE INPUT', showPowerProfile=True, index=2)
74
75 self.voltProcObj.integrator(4)
76
91 self.specProcObj.init()
77 self.specProcObj.init()
92
78
93 self.specProcObj.integrator(N=1)
79 self.specProcObj.integrator(N=4)
94
80
95 self.specProcObj.plotData(winTitle='Spectra 1', index=1)
81 # self.specProcObj.plotSpec(winTitle='Spectra Test', showColorbar=True,showPowerProfile=True,index=3)
96
82 self.specProcObj.plotData(winTitle='Spectra Test', showColorbar=True,showPowerProfile=True,index=3)
97
83
98 if self.readerObj.flagNoMoreFiles:
84 if self.readerObj.flagNoMoreFiles:
99 break
85 break
100
86
@@ -102,8 +88,6 class TestSChain():
102 print 'Block No %04d, Time: %s' %(self.readerObj.nTotalBlocks,
88 print 'Block No %04d, Time: %s' %(self.readerObj.nTotalBlocks,
103 datetime.datetime.fromtimestamp(self.readerObj.m_BasicHeader.utc),)
89 datetime.datetime.fromtimestamp(self.readerObj.m_BasicHeader.utc),)
104
90
105
106 # self.plotObj.end()
107
91
108 if __name__ == '__main__':
92 if __name__ == '__main__':
109 TestSChain() No newline at end of file
93 TestSChain()
General Comments 0
You need to be logged in to leave comments. Login now