##// END OF EJS Templates
-Los graficos de Spectra fueron agrandados...
Miguel Valdez -
r161:4c3983336b46
parent child
Show More
@@ -1,412 +1,412
1 import numpy
1 import numpy
2 import datetime
2 import datetime
3 import time
3 import time
4 import os
4 import os
5 from schainPlotLib import Driver
5 from schainPlotLib import Driver
6
6
7 class Figure:
7 class Figure:
8
8
9 __isDriverOpen = False
9 __isDriverOpen = False
10 __isFigureOpen = False
10 __isFigureOpen = False
11 __isConfig = False
11 __isConfig = False
12 __counter = 0
12 __counter = 0
13 drvObj = None
13 drvObj = None
14 driver = None
14 driver = None
15 idfigure = None
15 idfigure = None
16 nframes = None
16 nframes = None
17 wintitle = None
17 wintitle = None
18 colormap = None
18 colormap = None
19 overplot = None
19 overplot = None
20 colorbar = None
20 colorbar = None
21
21
22 frameObjList = []
22 frameObjList = []
23
23
24 xw = None
24 xw = None
25 yw = None
25 yw = None
26
26
27 xmin = None
27 xmin = None
28 xmax = None
28 xmax = None
29 ymin = None
29 ymin = None
30 ymax = None
30 ymax = None
31
31
32 minvalue = None
32 minvalue = None
33 maxvalue = None
33 maxvalue = None
34 deltax = None
34 deltax = None
35 deltay = None
35 deltay = None
36
36
37
37
38 figuretitle = ""
38 figuretitle = ""
39 xrangestep = None
39 xrangestep = None
40
40
41 def __init__(self,idfigure, nframes, wintitle, xw=600, yw=800, overplot=0, driver='plplot', colormap=None, colorbar= True, *args):
41 def __init__(self,idfigure, nframes, wintitle, xw=600, yw=800, overplot=0, driver='plplot', colormap=None, colorbar= True, *args):
42
42
43 self.__isDriverOpen = False
43 self.__isDriverOpen = False
44 self.__isFigureOpen = False
44 self.__isFigureOpen = False
45 self.__isConfig = False
45 self.__isConfig = False
46 self.__counter = 0
46 self.__counter = 0
47
47
48 self.drvObj = Driver(driver, idfigure, xw, yw, wintitle, overplot, colormap, colorbar)
48 self.drvObj = Driver(driver, idfigure, xw, yw, wintitle, overplot, colormap, colorbar)
49 self.driver = driver
49 self.driver = driver
50 self.idfigure = idfigure
50 self.idfigure = idfigure
51 self.nframes = nframes
51 self.nframes = nframes
52 self.wintitle = wintitle
52 self.wintitle = wintitle
53 self.colormap = colormap
53 self.colormap = colormap
54 self.overplot = overplot
54 self.overplot = overplot
55 self.colorbar = colorbar
55 self.colorbar = colorbar
56
56
57 self.xw = xw
57 self.xw = xw
58 self.yw = yw
58 self.yw = yw
59
59
60 self.frameObjList = []
60 self.frameObjList = []
61
61
62 self.drvObj.driver.setFigure()
62 self.drvObj.driver.setFigure()
63 self.drvObj.driver.setColormap(colormap)
63 self.drvObj.driver.setColormap(colormap)
64
64
65 def __openDriver(self):
65 def __openDriver(self):
66
66
67 self.drvObj.driver.openDriver()
67 self.drvObj.driver.openDriver()
68
68
69 def __newPage(self):
69 def __newPage(self):
70
70
71
71
72 self.drvObj.driver.openPage()
72 self.drvObj.driver.openPage()
73 nrows, ncolumns = self.getSubplots()
73 nrows, ncolumns = self.getSubplots()
74 self.drvObj.driver.setFigTitle(self.figuretitle)
74 self.drvObj.driver.setFigTitle(self.figuretitle)
75 self.drvObj.driver.setSubPlots(nrows, ncolumns)
75 self.drvObj.driver.setSubPlots(nrows, ncolumns)
76
76
77 def __closePage(self):
77 def __closePage(self):
78
78
79 self.drvObj.driver.closeFigure()
79 self.drvObj.driver.closeFigure()
80
80
81 def selectFigure(self):
81 def selectFigure(self):
82
82
83 self.drvObj.driver.selectFigure()
83 self.drvObj.driver.selectFigure()
84
84
85 def __isOutOfXRange(self,x):
85 def __isOutOfXRange(self,x):
86 try:
86 try:
87 if ((x>=self.xmin) and (x<self.xmax)):
87 if ((x>=self.xmin) and (x<self.xmax)):
88 return 0
88 return 0
89 except:
89 except:
90 return 0
90 return 0
91
91
92 return 1
92 return 1
93
93
94 def changeXRange(self,x):
94 def changeXRange(self,x):
95
95
96 pass
96 pass
97
97
98 def __refresh(self):
98 def __refresh(self):
99 self.drvObj.driver.refresh()
99 self.drvObj.driver.refresh()
100
100
101 def createFrames(self):
101 def createFrames(self):
102
102
103 self.frameObjList = []
103 self.frameObjList = []
104
104
105 raise ValueError, "No implemented"
105 raise ValueError, "No implemented"
106
106
107 def save(self,filename):
107 def save(self,filename):
108
108
109 self.drvObj.driver.save(filename)
109 self.drvObj.driver.save(filename)
110
110
111 def plot1DArray(self, data1D, x=None, channelList=None, xmin=None, xmax=None, minvalue=None, maxvalue=None, figuretitle=None, save=False, gpath='./', ratio=1):
111 def plot1DArray(self, data1D, x=None, channelList=None, xmin=None, xmax=None, minvalue=None, maxvalue=None, figuretitle=None, save=False, gpath='./', ratio=1):
112
112
113 nx, ny = data1D.shape
113 nx, ny = data1D.shape
114
114
115 if channelList == None:
115 if channelList == None:
116 channelList = range(nx)
116 channelList = range(nx)
117
117
118 if x == None:
118 if x == None:
119 x = numpy.arange(data1D.size)
119 x = numpy.arange(data1D.size)
120
120
121 if figuretitle == None:
121 if figuretitle == None:
122 self.figuretitle = ""
122 self.figuretitle = ""
123 else:
123 else:
124 self.figuretitle = figuretitle
124 self.figuretitle = figuretitle
125
125
126 if not(self.__isDriverOpen):
126 if not(self.__isDriverOpen):
127 self.__openDriver()
127 self.__openDriver()
128 self.__isDriverOpen = True
128 self.__isDriverOpen = True
129
129
130 if not(self.__isConfig):
130 if not(self.__isConfig):
131 self.xmin = xmin
131 self.xmin = xmin
132 self.xmax = xmax
132 self.xmax = xmax
133 self.minvalue = minvalue
133 self.minvalue = minvalue
134 self.maxvalue = maxvalue
134 self.maxvalue = maxvalue
135
135
136 if self.xmin == None: self.xmin = numpy.min(x)
136 if self.xmin == None: self.xmin = numpy.min(x)
137 if self.xmax == None: self.xmax = numpy.max(x)
137 if self.xmax == None: self.xmax = numpy.max(x)
138 if self.minvalue == None: self.minvalue = numpy.min(data1D)
138 if self.minvalue == None: self.minvalue = numpy.min(data1D)
139 if self.maxvalue == None: self.maxvalue = numpy.max(data1D)
139 if self.maxvalue == None: self.maxvalue = numpy.max(data1D)
140
140
141 self.createFrames()
141 self.createFrames()
142 self.__isConfig = True
142 self.__isConfig = True
143
143
144
144
145
145
146 self.selectFigure()
146 self.selectFigure()
147 self.__newPage()
147 self.__newPage()
148
148
149
149
150 for channel in range(len(channelList)):
150 for channel in range(len(channelList)):
151 frameObj = self.frameObjList[channel]
151 frameObj = self.frameObjList[channel]
152 frameObj.init(xmin=self.xmin,
152 frameObj.init(xmin=self.xmin,
153 xmax=self.xmax,
153 xmax=self.xmax,
154 ymin=self.minvalue,
154 ymin=self.minvalue,
155 ymax=self.maxvalue,
155 ymax=self.maxvalue,
156 minvalue=self.minvalue,
156 minvalue=self.minvalue,
157 maxvalue=self.maxvalue)
157 maxvalue=self.maxvalue)
158
158
159 for channel in range(len(channelList)):
159 for channel in range(len(channelList)):
160 dataCh = data1D[channel,:]
160 dataCh = data1D[channel,:]
161 frameObj = self.frameObjList[channel]
161 frameObj = self.frameObjList[channel]
162 frameObj.plot(x, dataCh)
162 frameObj.plot(x, dataCh)
163
163
164 self.__refresh()
164 self.__refresh()
165
165
166 if save:
166 if save:
167 if self.__counter == 0:
167 if self.__counter == 0:
168 path = gpath
168 path = gpath
169 now = datetime.datetime.now()
169 now = datetime.datetime.now()
170 file = "plot_img%02d_%d_%d.png"%(self.idfigure, time.mktime(now.timetuple()), now.microsecond)
170 file = "plot_img%02d_%d_%d.png"%(self.idfigure, time.mktime(now.timetuple()), now.microsecond)
171 filename = os.path.join(path,file)
171 filename = os.path.join(path,file)
172 self.save(filename)
172 self.save(filename)
173 self.__counter += 1
173 self.__counter += 1
174
174
175 if self.__counter == ratio:
175 if self.__counter == ratio:
176 self.__counter = 0
176 self.__counter = 0
177
177
178
178
179 self.__closePage()
179 self.__closePage()
180
180
181
181
182 def plotPcolor(self,data,
182 def plotPcolor(self,data,
183 x=None,
183 x=None,
184 y=None,
184 y=None,
185 channelList=None,
185 channelList=None,
186 xmin=None,
186 xmin=None,
187 xmax=None,
187 xmax=None,
188 ymin=None,
188 ymin=None,
189 ymax=None,
189 ymax=None,
190 minvalue=None,
190 minvalue=None,
191 maxvalue=None,
191 maxvalue=None,
192 figuretitle=None,
192 figuretitle=None,
193 xrangestep=None,
193 xrangestep=None,
194 deltax=None,
194 deltax=None,
195 save=False,
195 save=False,
196 gpath='./',
196 gpath='./',
197 ratio=1,
197 ratio=1,
198 cleardata=False,
198 cleardata=False,
199 *args):
199 *args):
200
200
201
201
202 if figuretitle == None:
202 if figuretitle == None:
203 self.figuretitle = ""
203 self.figuretitle = ""
204 else:
204 else:
205 self.figuretitle = figuretitle
205 self.figuretitle = figuretitle
206
206
207
207
208 if not(self.__isDriverOpen):
208 if not(self.__isDriverOpen):
209 self.__openDriver()
209 self.__openDriver()
210 self.__isDriverOpen = True
210 self.__isDriverOpen = True
211
211
212 if not(self.__isConfig):
212 if not(self.__isConfig):
213
213
214 self.setParms(data,x,y,xmin,xmax,ymin,ymax,minvalue,maxvalue,xrangestep,deltax)
214 self.setParms(data,x,y,xmin,xmax,ymin,ymax,minvalue,maxvalue,xrangestep,deltax)
215
215
216 self.createFrames()
216 self.createFrames()
217 self.__isConfig = True
217 self.__isConfig = True
218
218
219 if (self.__isOutOfXRange(x)):
219 if (self.__isOutOfXRange(x)):
220
220
221 if not(self.changeXRange(x)):
221 if not(self.changeXRange(x)):
222 return 0
222 return 0
223
223
224 self.__closePage()
224 self.__closePage()
225 self.__isFigureOpen = False
225 self.__isFigureOpen = False
226
226
227 self.selectFigure()
227 self.selectFigure()
228
228
229 if not(self.__isFigureOpen):
229 if not(self.__isFigureOpen):
230 self.__newPage()
230 self.__newPage()
231 self.__isFigureOpen = True
231 self.__isFigureOpen = True
232
232
233 for channel in range(len(channelList)):
233 for channel in range(len(channelList)):
234 if len(args) != 0: value = args[0][channel]
234 if len(args) != 0: value = args[0][channel]
235 else: value = args
235 else: value = args
236
236
237 frameObj = self.frameObjList[channel]
237 frameObj = self.frameObjList[channel]
238 frameObj.init(self.xmin,
238 frameObj.init(self.xmin,
239 self.xmax,
239 self.xmax,
240 self.ymin,
240 self.ymin,
241 self.ymax,
241 self.ymax,
242 self.minvalue,
242 self.minvalue,
243 self.maxvalue,
243 self.maxvalue,
244 self.deltax,
244 self.deltax,
245 self.deltay,
245 self.deltay,
246 self.colorbar,
246 self.colorbar,
247 value)
247 value)
248
248
249
249
250 for channel in range(len(channelList)):
250 for channel in range(len(channelList)):
251 dataCh = data[channel,:]
251 dataCh = data[channel,:]
252 frameObj = self.frameObjList[channel]
252 frameObj = self.frameObjList[channel]
253 frameObj.plot(x, y, dataCh)
253 frameObj.plot(x, y, dataCh)
254
254
255
255
256 self.__refresh()
256 self.__refresh()
257
257
258 if save:
258 if save:
259 if self.__counter == 0:
259 if self.__counter == 0:
260 path = gpath
260 path = gpath
261 now = datetime.datetime.now()
261 now = datetime.datetime.now()
262 file = "pcolor_img%02d_%d_%d.png"%(self.idfigure, time.mktime(now.timetuple()), now.microsecond)
262 file = "pcolor_img%02d_%d_%d.png"%(self.idfigure, time.mktime(now.timetuple()), now.microsecond)
263 filename = os.path.join(path,file)
263 filename = os.path.join(path,file)
264 self.save(filename)
264 self.save(filename)
265 self.__counter += 1
265 self.__counter += 1
266
266
267 if self.__counter == ratio:
267 if self.__counter == ratio:
268 self.__counter = 0
268 self.__counter = 0
269
269
270
270
271 if cleardata == True:
271 if cleardata == True:
272 self.__closePage()
272 self.__closePage()
273 self.__isFigureOpen = False
273 self.__isFigureOpen = False
274
274
275
275
276
276
277
277
278 class Frame:
278 class Frame:
279
279
280 drvObj = None
280 drvObj = None
281 idFrame = None
281 idFrame = None
282 nplots = None
282 nplots = None
283 plotObjList = []
283 plotObjList = []
284 title = ""
284 title = ""
285
285
286 def __init__(self,drvObj, idframe):
286 def __init__(self,drvObj, idframe):
287
287
288 self.drvObj = drvObj
288 self.drvObj = drvObj
289 self.idframe = idframe
289 self.idframe = idframe
290 nplots = None
290 nplots = None
291 self.plotObjList = []
291 self.plotObjList = []
292
292
293 self.createPlots()
293 self.createPlots()
294
294
295 def createPlots(self):
295 def createPlots(self):
296 raise ValueError, "No implemented"
296 raise ValueError, "No implemented"
297
297
298 def getScreenPosMainPlot(self):
298 def getScreenPosMainPlot(self):
299 raise ValueError, "No implemented"
299 raise ValueError, "No implemented"
300
300
301 def getScreenPosGraph1(self):
301 def getScreenPosGraph1(self):
302 raise ValueError, "No implemented"
302 raise ValueError, "No implemented"
303
303
304 def getScreenPos(self, nplot):
304 def getScreenPos(self, nplot):
305
305
306 if nplot == 0:
306 if nplot == 0:
307 xi, yi, xw, yw = self.getScreenPosMainPlot()
307 xi, yi, xw, yw = self.getScreenPosMainPlot()
308
308
309 if nplot == 1:
309 if nplot == 1:
310 xi, yi, xw, yw = self.getScreenPosGraph1()
310 xi, yi, xw, yw = self.getScreenPosGraph1()
311
311
312 return xi, yi, xw, yw
312 return xi, yi, xw, yw
313
313
314
314
315 def init(self, xmin, xmax, ymin, ymax, minvalue, maxvalue, deltax=None, deltay=None, colorbar=False, *args):
315 def init(self, xmin, xmax, ymin, ymax, minvalue, maxvalue, deltax=None, deltay=None, colorbar=False, *args):
316
316
317 for plotObj in self.plotObjList:
317 for plotObj in self.plotObjList:
318 plotObj.setBox(xmin, xmax, ymin, ymax, minvalue, maxvalue, deltax, deltay, colorbar, *args)
318 plotObj.setBox(xmin, xmax, ymin, ymax, minvalue, maxvalue, deltax, deltay, colorbar, *args)
319 plotObj.plotBox()
319 plotObj.plotBox()
320
320
321
321
322
322
323 class Plot:
323 class Plot:
324
324
325 drvObj = None
325 drvObj = None
326 idframe = None
326 idframe = None
327 idplot = None
327 idplot = None
328 xi = None
328 xi = None
329 yi = None
329 yi = None
330 xw = None
330 xw = None
331 yw = None
331 yw = None
332
332
333 title = ""
333 title = ""
334 xlabel = ""
334 xlabel = ""
335 ylabel = ""
335 ylabel = ""
336 xaxisastime = None
336 xaxisastime = None
337 timefmt = None
337 timefmt = None
338 xopt = ""
338 xopt = ""
339 yopt = ""
339 yopt = ""
340 xpos = None
340 xpos = None
341 ypos = None
341 ypos = None
342 szchar = None
342 szchar = None
343 idframe = None
343 idframe = None
344 idplot = None
344 idplot = None
345 colorbar = None
345 colorbar = None
346 cbxpos = None
346 cbxpos = None
347 cbypos = None
347 cbypos = None
348
348
349 def __init__(self, drvObj, idframe, idplot, xi, yi, xw, yw):
349 def __init__(self, drvObj, idframe, idplot, xi, yi, xw, yw):
350
350
351 self.drvObj = drvObj
351 self.drvObj = drvObj
352 self.idframe = idframe
352 self.idframe = idframe
353 self.idplot = idplot
353 self.idplot = idplot
354 self.xi = xi
354 self.xi = xi
355 self.yi = yi
355 self.yi = yi
356 self.xw = xw
356 self.xw = xw
357 self.yw = yw
357 self.yw = yw
358
358
359
359
360 def plotBox(self):
360 def plotBox(self):
361
361
362 self.drvObj.driver.plotBox(self.idframe,
362 self.drvObj.driver.plotBox(self.idframe,
363 self.xpos,
363 self.xpos,
364 self.ypos,
364 self.ypos,
365 self.xmin,
365 self.xmin,
366 self.xmax,
366 self.xmax,
367 self.ymin,
367 self.ymin,
368 self.ymax,
368 self.ymax,
369 self.minvalue,
369 self.minvalue,
370 self.maxvalue,
370 self.maxvalue,
371 self.xopt,
371 self.xopt,
372 self.yopt,
372 self.yopt,
373 self.szchar,
373 self.szchar,
374 self.xaxisastime,
374 self.xaxisastime,
375 self.timefmt)
375 self.timefmt)
376
376
377 self.drvObj.driver.setPlotLabels(self.idframe, self.xlabel, self.ylabel, self.title)
377 self.drvObj.driver.setPlotLabels(self.idframe, self.xlabel, self.ylabel, self.title)
378
378
379 if self.colorbar:
379 if self.colorbar:
380 self.drvObj.driver.plotColorbar(self.minvalue, self.maxvalue, self.cbxpos,self.cbypos)
380 self.drvObj.driver.plotColorbar(self.minvalue, self.maxvalue, self.cbxpos,self.cbypos)
381
381
382 def plotPcolor(self, x, y, z, deltax, deltay, getGrid):
382 def plotPcolor(self, x, y, z, deltax, deltay, getGrid):
383
383
384 self.drvObj.driver.pcolor(self.idframe,
384 self.drvObj.driver.pcolor(self.idframe,
385 self.xpos,
385 self.xpos,
386 self.ypos,
386 self.ypos,
387 z,
387 z,
388 x,
388 x,
389 y,
389 y,
390 self.xmin,
390 self.xmin,
391 self.xmax,
391 self.xmax,
392 self.ymin,
392 self.ymin,
393 self.ymax,
393 self.ymax,
394 self.minvalue,
394 self.minvalue,
395 self.maxvalue,
395 self.maxvalue,
396 deltax,
396 deltax,
397 deltay,
397 deltay,
398 getGrid,
398 getGrid,
399 self.xaxisastime,
399 self.xaxisastime,
400 self.timefmt)
400 self.timefmt)
401
401
402 def plotBasicLine(self,x, y, color):
402 def plotBasicLine(self,x, y, color, xopt='bcst', yopt='bcst'):
403 """
403 """
404 Inputs:
404 Inputs:
405 x:
405 x:
406
406
407 y:
407 y:
408
408
409 color:
409 color:
410 """
410 """
411 self.drvObj.driver.basicLine(self.idframe, self.xpos, self.ypos, x, y, self.xmin, self.xmax, self.ymin, self.ymax, color)
411 self.drvObj.driver.basicLine(self.idframe, self.xpos, self.ypos, x, y, self.xmin, self.xmax, self.ymin, self.ymax, color, xopt=xopt, yopt=yopt)
412 No newline at end of file
412
@@ -1,515 +1,516
1 import plplot
1 import plplot
2 import numpy
2 import numpy
3 import sys
3 import sys
4 import plplot #condicional
4 import plplot #condicional
5
5
6 import matplotlib as mpl
6 import matplotlib as mpl
7 #mpl.use('TKAgg')
7 #mpl.use('TKAgg')
8 import matplotlib.pyplot as plt
8 import matplotlib.pyplot as plt
9
9
10 class Driver:
10 class Driver:
11 def __init__(self,driver, idfigure, xw, yw, wintitle, overplot, colormap, colorbar):
11 def __init__(self,driver, idfigure, xw, yw, wintitle, overplot, colormap, colorbar):
12 if driver == "plplot":
12 if driver == "plplot":
13 self.driver = PlplotDriver(idfigure, xw, yw, wintitle, overplot, colormap, colorbar)
13 self.driver = PlplotDriver(idfigure, xw, yw, wintitle, overplot, colormap, colorbar)
14 elif driver == "mpl":
14 elif driver == "mpl":
15 self.driver = MplDriver(idfigure, xw, yw, wintitle, overplot, colormap, colorbar)
15 self.driver = MplDriver(idfigure, xw, yw, wintitle, overplot, colormap, colorbar)
16 else:
16 else:
17 raise ValueError, "The driver: %s is not defined"%driver
17 raise ValueError, "The driver: %s is not defined"%driver
18
18
19 class PlplotDriver:
19 class PlplotDriver:
20
20
21 __isDriverOpen = False
21 __isDriverOpen = False
22 pldriver = None
22 pldriver = None
23 __xg = None
23 __xg = None
24 __yg = None
24 __yg = None
25 def __init__(self, idfigure, xw, yw, wintitle, overplot, colormap, colorbar):
25 def __init__(self, idfigure, xw, yw, wintitle, overplot, colormap, colorbar):
26
26
27 if idfigure == None:
27 if idfigure == None:
28 raise ValueError, 'idfigure input must be defined'
28 raise ValueError, 'idfigure input must be defined'
29
29
30 self.idfigure = idfigure
30 self.idfigure = idfigure
31 self.xw = xw
31 self.xw = xw
32 self.yw = yw
32 self.yw = yw
33 self.wintitle = wintitle
33 self.wintitle = wintitle
34 self.overplot = overplot
34 self.overplot = overplot
35 self.colormap = colormap
35 self.colormap = colormap
36 self.colorbar = colorbar
36 self.colorbar = colorbar
37
37
38 def setFigure(self):
38 def setFigure(self):
39 """
39 """
40 previous configuration to open(init) the plplot driver
40 previous configuration to open(init) the plplot driver
41 """
41 """
42 plplot.plsstrm(self.idfigure)
42 plplot.plsstrm(self.idfigure)
43 plplot.plparseopts([self.wintitle],plplot.PL_PARSE_FULL)
43 plplot.plparseopts([self.wintitle],plplot.PL_PARSE_FULL)
44 plplot.plsetopt("geometry", "%dx%d"%(self.xw, self.yw))
44 plplot.plsetopt("geometry", "%dx%d"%(self.xw, self.yw))
45
45
46 def selectFigure(self):
46 def selectFigure(self):
47
47
48 plplot.plsstrm(self.idfigure)
48 plplot.plsstrm(self.idfigure)
49
49
50
50 def openDriver(self, pldriver=None):
51 def openDriver(self, pldriver=None):
51 if pldriver == None:
52 if pldriver == None:
52 if sys.platform == "linux":
53 if sys.platform == "linux":
53 pldriver = "xcairo"
54 pldriver = "xcairo"
54
55
55 if sys.platform == "linux2":
56 if sys.platform == "linux2":
56 pldriver = "xcairo"
57 pldriver = "xcairo"
57
58
58 elif sys.platform == "darwin":
59 elif sys.platform == "darwin":
59 pldriver = "xwin"
60 pldriver = "xwin"
60
61
61 else:
62 else:
62 pldriver = ""
63 pldriver = ""
63
64
64 plplot.plsdev("xwin") #para pruebas
65 plplot.plsdev("xwin") #para pruebas
65 plplot.plscolbg(255,255,255)
66 plplot.plscolbg(255,255,255)
66 plplot.plscol0(1,0,0,0)
67 plplot.plscol0(1,0,0,0)
67 plplot.plinit()
68 plplot.plinit()
68 plplot.plspause(False)
69 plplot.plspause(False)
69
70
70 self.pldriver = pldriver
71 self.pldriver = pldriver
71
72
72 def closeDriver(self):
73 def closeDriver(self):
73 pass
74 pass
74
75
75 def openPage(self):
76 def openPage(self):
76 plplot.plbop()
77 plplot.plbop()
77 plplot.pladv(0)
78 #plplot.pladv(0)
78
79
79 def closePage(self):
80 def closePage(self):
80 plplot.pleop()
81 plplot.pleop()
81
82
82 def openFigure(self):
83 def openFigure(self):
83 plplot.plbop()
84 plplot.plbop()
84 plplot.pladv(0)
85 plplot.pladv(0)
85
86
86 def closeFigure(self):
87 def closeFigure(self):
87 plplot.pleop()
88 plplot.pleop()
88
89
89 def setSubPlots(self,nrows, ncolumns):
90 def setSubPlots(self,nrows, ncolumns):
90 plplot.plssub(ncolumns,nrows)
91 plplot.plssub(ncolumns, nrows)
91
92
92 def setPlotLabels(self, id, xlabel, ylabel, title):
93 def setPlotLabels(self, id, xlabel, ylabel, title):
93 plplot.pllab(xlabel, ylabel, title)
94 plplot.pllab(xlabel, ylabel, title)
94
95
95 def setFigTitle(self, title,color="black", szchar=0.55):
96 def setFigTitle(self, title,color="black", szchar=0.55):
96 self.setSubPlots(1, 0)
97 self.setSubPlots(1, 1)
97 plplot.pladv(0)
98 plplot.pladv(0)
98 plplot.plvpor(0., 1., 0., 1.)
99 plplot.plvpor(0., 1., 0., 1.)
99
100
100 if color == "black":
101 if color == "black":
101 plplot.plcol0(1)
102 plplot.plcol0(1)
102 if color == "white":
103 if color == "white":
103 plplot.plcol0(15)
104 plplot.plcol0(15)
104
105
105 plplot.plschr(0.0,szchar)
106 plplot.plschr(0.0,szchar)
106 plplot.plmtex("t",-1., 0.5, 0.5, title)
107 plplot.plmtex("t",-1., 0.5, 0.5, title)
107
108
108 def plotColorbar(self, minvalue, maxvalue, xpos, ypos):
109 def plotColorbar(self, minvalue, maxvalue, xpos, ypos):
109 # plplot.pladv(id)
110 # plplot.pladv(id)
110 # plplot.plschr(0.0,szchar-0.05)
111 # plplot.plschr(0.0,szchar-0.05)
111 xmin = 0; xmax = 1
112 xmin = 0; xmax = 1
112 ymin = minvalue; ymax = maxvalue
113 ymin = minvalue; ymax = maxvalue
113 plplot.plvpor(xpos[0], xpos[1], ypos[0], ypos[1])
114 plplot.plvpor(xpos[0], xpos[1], ypos[0], ypos[1])
114 plplot.plwind(float(xmin), float(xmax), float(ymin), float(ymax))
115 plplot.plwind(float(xmin), float(xmax), float(ymin), float(ymax))
115 plplot.plbox("bc", 0.0, 0, "bcmtsv", 0.0, 0)
116 plplot.plbox("bc", 0.0, 0, "bcmtsv", 0.0, 0)
116
117
117 data = numpy.arange(256)
118 data = numpy.arange(256)
118 data = numpy.reshape(data, (1,-1))
119 data = numpy.reshape(data, (1,-1))
119
120
120 plplot.plimage(data,
121 plplot.plimage(data,
121 float(xmin),
122 float(xmin),
122 float(xmax),
123 float(xmax),
123 float(ymin),
124 float(ymin),
124 float(ymax),
125 float(ymax),
125 0.,
126 0.,
126 255.,
127 255.,
127 float(xmin),
128 float(xmin),
128 float(xmax),
129 float(xmax),
129 float(ymin),
130 float(ymin),
130 float(ymax))
131 float(ymax))
131
132
132
133
133 def __getGrid(self, x, y, deltax=None, deltay=None):
134 def __getGrid(self, x, y, deltax=None, deltay=None):
134
135
135 if not(len(x)>0 and len(y)>0):
136 if not(len(x)>0 and len(y)>0):
136 raise ValueError, "x axis and y axis are empty"
137 raise ValueError, "x axis and y axis are empty"
137
138
138 if deltax == None: deltax = x[-1] - x[-2]
139 if deltax == None: deltax = x[-1] - x[-2]
139 if deltay == None: deltay = y[-1] - y[-2]
140 if deltay == None: deltay = y[-1] - y[-2]
140
141
141 x1 = numpy.append(x, x[-1] + deltax)
142 x1 = numpy.append(x, x[-1] + deltax)
142 y1 = numpy.append(y, y[-1] + deltay)
143 y1 = numpy.append(y, y[-1] + deltay)
143
144
144 xg = (numpy.multiply.outer(x1, numpy.ones(len(y1))))
145 xg = (numpy.multiply.outer(x1, numpy.ones(len(y1))))
145 yg = (numpy.multiply.outer(numpy.ones(len(x1)), y1))
146 yg = (numpy.multiply.outer(numpy.ones(len(x1)), y1))
146
147
147 return xg, yg
148 return xg, yg
148
149
149
150
150 def pcolor(self, id, xpos, ypos, data, x, y, xmin, xmax, ymin, ymax, zmin, zmax, deltax=None, deltay=None, getGrid=True, xaxisastime = False, timefmt="%H:%M"):
151 def pcolor(self, id, xpos, ypos, data, x, y, xmin, xmax, ymin, ymax, zmin, zmax, deltax=None, deltay=None, getGrid=True, xaxisastime = False, timefmt="%H:%M"):
151
152
152 plplot.pladv(id)
153 plplot.pladv(id)
153 plplot.plvpor(xpos[0], xpos[1], ypos[0], ypos[1])
154 plplot.plvpor(xpos[0], xpos[1], ypos[0], ypos[1])
154 plplot.plwind(float(xmin),float(xmax), float(ymin), float(ymax))
155 plplot.plwind(float(xmin),float(xmax), float(ymin), float(ymax))
155
156
156 if xaxisastime:
157 if xaxisastime:
157 timedelta = (xmax - xmin + 1)/8.
158 timedelta = (xmax - xmin + 1)/8.
158
159
159 if getGrid:
160 if getGrid:
160 self.__xg, self.__yg = self.__getGrid(x, y, deltax, deltay)
161 self.__xg, self.__yg = self.__getGrid(x, y, deltax, deltay)
161
162
162 if deltax == None: deltax = x[-1] - x[0]
163 if deltax == None: deltax = x[-1] - x[0]
163 # if deltay == None: deltay = y[-1] - y[-2]
164 # if deltay == None: deltay = y[-1] - y[-2]
164
165
165 xmin = x[0]
166 xmin = x[0]
166 xmax = xmin + deltax
167 xmax = xmin + deltax
167
168
168 plplot.plimagefr(data,
169 plplot.plimagefr(data,
169 float(xmin),
170 float(xmin),
170 float(xmax),
171 float(xmax),
171 float(ymin),
172 float(ymin),
172 float(ymax),
173 float(ymax),
173 0.,
174 0.,
174 0.,
175 0.,
175 float(zmin),
176 float(zmin),
176 float(zmax),
177 float(zmax),
177 plplot.pltr2,
178 plplot.pltr2,
178 self.__xg,
179 self.__xg,
179 self.__yg)
180 self.__yg)
180
181
181 if xaxisastime:
182 if xaxisastime:
182 plplot.pltimefmt(timefmt)
183 plplot.pltimefmt(timefmt)
183 xopt = "bcstd"
184 xopt = "bcstd"
184 yopt = "bcst"
185 yopt = "bcst"
185 plplot.plbox(xopt, timedelta, 3, yopt, 0.0, 0)
186 plplot.plbox(xopt, timedelta, 3, yopt, 0.0, 0)
186 else:
187 else:
187 xopt = "bcst"
188 xopt = "bcst"
188 yopt = "bcst"
189 yopt = "bcst"
189 plplot.plbox(xopt, 0.0, 0, yopt, 0.0, 0)
190 plplot.plbox(xopt, 0.0, 0, yopt, 0.0, 0)
190
191
191
192
192 def plotBox(self, id, xpos, ypos, xmin, xmax, ymin, ymax, minvalue, maxvalue, xopt, yopt, szchar=0.6, xaxisastime = False, timefmt="%H:%M"):
193 def plotBox(self, id, xpos, ypos, xmin, xmax, ymin, ymax, minvalue, maxvalue, xopt, yopt, szchar=0.6, xaxisastime = False, timefmt="%H:%M"):
193 """
194 """
194 xopt, yopt: entradas que no se aplican en MPL
195 xopt, yopt: entradas que no se aplican en MPL
195 """
196 """
196 plplot.pladv(id)
197 plplot.pladv(id)
197 plplot.plschr(0.0,szchar-0.05)
198 plplot.plschr(0.0,szchar-0.05)
198 plplot.plvpor(xpos[0], xpos[1], ypos[0], ypos[1])
199 plplot.plvpor(xpos[0], xpos[1], ypos[0], ypos[1])
199 plplot.plwind(float(xmin), float(xmax), float(ymin), float(ymax))
200 plplot.plwind(float(xmin), float(xmax), float(ymin), float(ymax))
200 if xaxisastime:
201 if xaxisastime:
201 plplot.pltimefmt(timefmt)
202 plplot.pltimefmt(timefmt)
202 timedelta = (xmax - xmin + 1)/8.
203 timedelta = (xmax - xmin + 1)/8.
203 plplot.plbox(xopt, timedelta, 3, yopt, 0.0, 0)
204 plplot.plbox(xopt, timedelta, 3, yopt, 0.0, 0)
204 else:
205 else:
205 plplot.plbox(xopt, 0.0, 0, yopt, 0.0, 0)
206 plplot.plbox(xopt, 0.0, 0, yopt, 0.0, 0)
206
207
207 def refresh(self):
208 def refresh(self):
208 plplot.plflush()
209 plplot.plflush()
209
210
210 def show(self):
211 def show(self):
211 plplot.plspause(True)
212 plplot.plspause(True)
212 plplot.plend()
213 plplot.plend()
213
214
214 def basicLine(self, id, xpos, ypos, x, y, xmin, xmax, ymin, ymax, color):
215 def basicLine(self, id, xpos, ypos, x, y, xmin, xmax, ymin, ymax, color, xopt="bcst", yopt="bcst"):
215
216
216 """
217 """
217 Inputs:
218 Inputs:
218 x: datos en el eje x
219 x: datos en el eje x
219
220
220 y: datos en el eje y
221 y: datos en el eje y
221
222
222 xmin, xmax: intervalo de datos en el eje x
223 xmin, xmax: intervalo de datos en el eje x
223
224
224 ymin, ymax: intervalo de datos en el eje y
225 ymin, ymax: intervalo de datos en el eje y
225
226
226 color: color de la linea a dibujarse
227 color: color de la linea a dibujarse
227
228
228 id: identificador del plot, en este caso indica al frame que pertenece, la posicion de cada
229 id: identificador del plot, en este caso indica al frame que pertenece, la posicion de cada
229 plot esta definido por xpos, ypos.
230 plot esta definido por xpos, ypos.
230
231
231 xpos,ypos: coordenadas que indican la posicion del plot en el frame
232 xpos,ypos: coordenadas que indican la posicion del plot en el frame
232
233
233 """
234 """
234
235
235 plplot.pladv(id)
236 plplot.pladv(id)
236 plplot.plvpor(xpos[0], xpos[1], ypos[0], ypos[1])
237 plplot.plvpor(xpos[0], xpos[1], ypos[0], ypos[1])
237 plplot.plwind(float(xmin),float(xmax), float(ymin), float(ymax))
238 plplot.plwind(float(xmin),float(xmax), float(ymin), float(ymax))
238
239
239 if color == "blue":
240 if color == "blue":
240 colline = 9
241 colline = 9
241 if color == "green":
242 if color == "green":
242 colline = 3
243 colline = 3
243
244
244 plplot.plcol0(colline)
245 plplot.plcol0(colline)
245 plplot.plline(x, y)
246 plplot.plline(x, y)
246 plplot.plcol0(1)
247 plplot.plcol0(1)
247 plplot.plbox("bcst", 0.0, 0, "bcst", 0.0, 0)
248 # plplot.plbox(xopt, 0.0, 0, yopt, 0.0, 0)
248
249
249 def save(self, filename):
250 def save(self, filename):
250 curr_strm = plplot.plgstrm()
251 curr_strm = plplot.plgstrm()
251 save_strm = plplot.plmkstrm()
252 save_strm = plplot.plmkstrm()
252 plplot.plsetopt("geometry", "%dx%d"%(self.xw,self.yw))
253 plplot.plsetopt("geometry", "%dx%d"%(self.xw,self.yw))
253 plplot.plsdev("png")
254 plplot.plsdev("png")
254 plplot.plsfnam(filename)
255 plplot.plsfnam(filename)
255 plplot.plcpstrm(curr_strm,0)
256 plplot.plcpstrm(curr_strm,0)
256 plplot.plreplot()
257 plplot.plreplot()
257 plplot.plend1()
258 plplot.plend1()
258 plplot.plsstrm(curr_strm)
259 plplot.plsstrm(curr_strm)
259
260
260 def setColormap(self, colormap="gray"):
261 def setColormap(self, colormap="gray"):
261
262
262 if colormap == None:
263 if colormap == None:
263 return
264 return
264
265
265 ncolor = None
266 ncolor = None
266 rgb_lvl = None
267 rgb_lvl = None
267
268
268 # Routine for defining a specific color map 1 in HLS space.
269 # Routine for defining a specific color map 1 in HLS space.
269 # if gray is true, use basic grayscale variation from half-dark to light.
270 # if gray is true, use basic grayscale variation from half-dark to light.
270 # otherwise use false color variation from blue (240 deg) to red (360 deg).
271 # otherwise use false color variation from blue (240 deg) to red (360 deg).
271
272
272 # Independent variable of control points.
273 # Independent variable of control points.
273 i = numpy.array((0., 1.))
274 i = numpy.array((0., 1.))
274 if colormap=="gray":
275 if colormap=="gray":
275 ncolor = 256
276 ncolor = 256
276 # Hue for control points. Doesn't matter since saturation is zero.
277 # Hue for control points. Doesn't matter since saturation is zero.
277 h = numpy.array((0., 0.))
278 h = numpy.array((0., 0.))
278 # Lightness ranging from half-dark (for interest) to light.
279 # Lightness ranging from half-dark (for interest) to light.
279 l = numpy.array((0.5, 1.))
280 l = numpy.array((0.5, 1.))
280 # Gray scale has zero saturation
281 # Gray scale has zero saturation
281 s = numpy.array((0., 0.))
282 s = numpy.array((0., 0.))
282
283
283 # number of cmap1 colours is 256 in this case.
284 # number of cmap1 colours is 256 in this case.
284 plplot.plscmap1n(ncolor)
285 plplot.plscmap1n(ncolor)
285 # Interpolate between control points to set up cmap1.
286 # Interpolate between control points to set up cmap1.
286 plplot.plscmap1l(0, i, h, l, s)
287 plplot.plscmap1l(0, i, h, l, s)
287
288
288 return None
289 return None
289
290
290 if colormap == 'jet':
291 if colormap == 'jet':
291 ncolor = 256
292 ncolor = 256
292 pos = numpy.zeros((ncolor))
293 pos = numpy.zeros((ncolor))
293 r = numpy.zeros((ncolor))
294 r = numpy.zeros((ncolor))
294 g = numpy.zeros((ncolor))
295 g = numpy.zeros((ncolor))
295 b = numpy.zeros((ncolor))
296 b = numpy.zeros((ncolor))
296
297
297 for i in range(ncolor):
298 for i in range(ncolor):
298 if(i <= 35.0/100*(ncolor-1)): rf = 0.0
299 if(i <= 35.0/100*(ncolor-1)): rf = 0.0
299 elif (i <= 66.0/100*(ncolor-1)): rf = (100.0/31)*i/(ncolor-1) - 35.0/31
300 elif (i <= 66.0/100*(ncolor-1)): rf = (100.0/31)*i/(ncolor-1) - 35.0/31
300 elif (i <= 89.0/100*(ncolor-1)): rf = 1.0
301 elif (i <= 89.0/100*(ncolor-1)): rf = 1.0
301 else: rf = (-100.0/22)*i/(ncolor-1) + 111.0/22
302 else: rf = (-100.0/22)*i/(ncolor-1) + 111.0/22
302
303
303 if(i <= 12.0/100*(ncolor-1)): gf = 0.0
304 if(i <= 12.0/100*(ncolor-1)): gf = 0.0
304 elif(i <= 38.0/100*(ncolor-1)): gf = (100.0/26)*i/(ncolor-1) - 12.0/26
305 elif(i <= 38.0/100*(ncolor-1)): gf = (100.0/26)*i/(ncolor-1) - 12.0/26
305 elif(i <= 64.0/100*(ncolor-1)): gf = 1.0
306 elif(i <= 64.0/100*(ncolor-1)): gf = 1.0
306 elif(i <= 91.0/100*(ncolor-1)): gf = (-100.0/27)*i/(ncolor-1) + 91.0/27
307 elif(i <= 91.0/100*(ncolor-1)): gf = (-100.0/27)*i/(ncolor-1) + 91.0/27
307 else: gf = 0.0
308 else: gf = 0.0
308
309
309 if(i <= 11.0/100*(ncolor-1)): bf = (50.0/11)*i/(ncolor-1) + 0.5
310 if(i <= 11.0/100*(ncolor-1)): bf = (50.0/11)*i/(ncolor-1) + 0.5
310 elif(i <= 34.0/100*(ncolor-1)): bf = 1.0
311 elif(i <= 34.0/100*(ncolor-1)): bf = 1.0
311 elif(i <= 65.0/100*(ncolor-1)): bf = (-100.0/31)*i/(ncolor-1) + 65.0/31
312 elif(i <= 65.0/100*(ncolor-1)): bf = (-100.0/31)*i/(ncolor-1) + 65.0/31
312 else: bf = 0
313 else: bf = 0
313
314
314 r[i] = rf
315 r[i] = rf
315 g[i] = gf
316 g[i] = gf
316 b[i] = bf
317 b[i] = bf
317
318
318 pos[i] = float(i)/float(ncolor-1)
319 pos[i] = float(i)/float(ncolor-1)
319
320
320
321
321 plplot.plscmap1n(ncolor)
322 plplot.plscmap1n(ncolor)
322 plplot.plscmap1l(1, pos, r, g, b)
323 plplot.plscmap1l(1, pos, r, g, b)
323
324
324
325
325
326
326 if colormap=="br_green":
327 if colormap=="br_green":
327 ncolor = 256
328 ncolor = 256
328 # Hue ranges from blue (240 deg) to red (0 or 360 deg)
329 # Hue ranges from blue (240 deg) to red (0 or 360 deg)
329 h = numpy.array((240., 0.))
330 h = numpy.array((240., 0.))
330 # Lightness and saturation are constant (values taken from C example).
331 # Lightness and saturation are constant (values taken from C example).
331 l = numpy.array((0.6, 0.6))
332 l = numpy.array((0.6, 0.6))
332 s = numpy.array((0.8, 0.8))
333 s = numpy.array((0.8, 0.8))
333
334
334 # number of cmap1 colours is 256 in this case.
335 # number of cmap1 colours is 256 in this case.
335 plplot.plscmap1n(ncolor)
336 plplot.plscmap1n(ncolor)
336 # Interpolate between control points to set up cmap1.
337 # Interpolate between control points to set up cmap1.
337 plplot.plscmap1l(0, i, h, l, s)
338 plplot.plscmap1l(0, i, h, l, s)
338
339
339 return None
340 return None
340
341
341 if colormap=="tricolor":
342 if colormap=="tricolor":
342 ncolor = 3
343 ncolor = 3
343 # Hue ranges from blue (240 deg) to red (0 or 360 deg)
344 # Hue ranges from blue (240 deg) to red (0 or 360 deg)
344 h = numpy.array((240., 0.))
345 h = numpy.array((240., 0.))
345 # Lightness and saturation are constant (values taken from C example).
346 # Lightness and saturation are constant (values taken from C example).
346 l = numpy.array((0.6, 0.6))
347 l = numpy.array((0.6, 0.6))
347 s = numpy.array((0.8, 0.8))
348 s = numpy.array((0.8, 0.8))
348
349
349 # number of cmap1 colours is 256 in this case.
350 # number of cmap1 colours is 256 in this case.
350 plplot.plscmap1n(ncolor)
351 plplot.plscmap1n(ncolor)
351 # Interpolate between control points to set up cmap1.
352 # Interpolate between control points to set up cmap1.
352 plplot.plscmap1l(0, i, h, l, s)
353 plplot.plscmap1l(0, i, h, l, s)
353
354
354 return None
355 return None
355
356
356 if colormap == 'rgb' or colormap == 'rgb666':
357 if colormap == 'rgb' or colormap == 'rgb666':
357
358
358 color_sz = 6
359 color_sz = 6
359 ncolor = color_sz*color_sz*color_sz
360 ncolor = color_sz*color_sz*color_sz
360 pos = numpy.zeros((ncolor))
361 pos = numpy.zeros((ncolor))
361 r = numpy.zeros((ncolor))
362 r = numpy.zeros((ncolor))
362 g = numpy.zeros((ncolor))
363 g = numpy.zeros((ncolor))
363 b = numpy.zeros((ncolor))
364 b = numpy.zeros((ncolor))
364 ind = 0
365 ind = 0
365 for ri in range(color_sz):
366 for ri in range(color_sz):
366 for gi in range(color_sz):
367 for gi in range(color_sz):
367 for bi in range(color_sz):
368 for bi in range(color_sz):
368 r[ind] = ri/(color_sz-1.0)
369 r[ind] = ri/(color_sz-1.0)
369 g[ind] = gi/(color_sz-1.0)
370 g[ind] = gi/(color_sz-1.0)
370 b[ind] = bi/(color_sz-1.0)
371 b[ind] = bi/(color_sz-1.0)
371 pos[ind] = ind/(ncolor-1.0)
372 pos[ind] = ind/(ncolor-1.0)
372 ind += 1
373 ind += 1
373 rgb_lvl = [6,6,6] #Levels for RGB colors
374 rgb_lvl = [6,6,6] #Levels for RGB colors
374
375
375 if colormap == 'rgb676':
376 if colormap == 'rgb676':
376 ncolor = 6*7*6
377 ncolor = 6*7*6
377 pos = numpy.zeros((ncolor))
378 pos = numpy.zeros((ncolor))
378 r = numpy.zeros((ncolor))
379 r = numpy.zeros((ncolor))
379 g = numpy.zeros((ncolor))
380 g = numpy.zeros((ncolor))
380 b = numpy.zeros((ncolor))
381 b = numpy.zeros((ncolor))
381 ind = 0
382 ind = 0
382 for ri in range(8):
383 for ri in range(8):
383 for gi in range(8):
384 for gi in range(8):
384 for bi in range(4):
385 for bi in range(4):
385 r[ind] = ri/(6-1.0)
386 r[ind] = ri/(6-1.0)
386 g[ind] = gi/(7-1.0)
387 g[ind] = gi/(7-1.0)
387 b[ind] = bi/(6-1.0)
388 b[ind] = bi/(6-1.0)
388 pos[ind] = ind/(ncolor-1.0)
389 pos[ind] = ind/(ncolor-1.0)
389 ind += 1
390 ind += 1
390 rgb_lvl = [6,7,6] #Levels for RGB colors
391 rgb_lvl = [6,7,6] #Levels for RGB colors
391
392
392 if colormap == 'rgb685':
393 if colormap == 'rgb685':
393 ncolor = 6*8*5
394 ncolor = 6*8*5
394 pos = numpy.zeros((ncolor))
395 pos = numpy.zeros((ncolor))
395 r = numpy.zeros((ncolor))
396 r = numpy.zeros((ncolor))
396 g = numpy.zeros((ncolor))
397 g = numpy.zeros((ncolor))
397 b = numpy.zeros((ncolor))
398 b = numpy.zeros((ncolor))
398 ind = 0
399 ind = 0
399 for ri in range(8):
400 for ri in range(8):
400 for gi in range(8):
401 for gi in range(8):
401 for bi in range(4):
402 for bi in range(4):
402 r[ind] = ri/(6-1.0)
403 r[ind] = ri/(6-1.0)
403 g[ind] = gi/(8-1.0)
404 g[ind] = gi/(8-1.0)
404 b[ind] = bi/(5-1.0)
405 b[ind] = bi/(5-1.0)
405 pos[ind] = ind/(ncolor-1.0)
406 pos[ind] = ind/(ncolor-1.0)
406 ind += 1
407 ind += 1
407 rgb_lvl = [6,8,5] #Levels for RGB colors
408 rgb_lvl = [6,8,5] #Levels for RGB colors
408
409
409 if colormap == 'rgb884':
410 if colormap == 'rgb884':
410 ncolor = 8*8*4
411 ncolor = 8*8*4
411 pos = numpy.zeros((ncolor))
412 pos = numpy.zeros((ncolor))
412 r = numpy.zeros((ncolor))
413 r = numpy.zeros((ncolor))
413 g = numpy.zeros((ncolor))
414 g = numpy.zeros((ncolor))
414 b = numpy.zeros((ncolor))
415 b = numpy.zeros((ncolor))
415 ind = 0
416 ind = 0
416 for ri in range(8):
417 for ri in range(8):
417 for gi in range(8):
418 for gi in range(8):
418 for bi in range(4):
419 for bi in range(4):
419 r[ind] = ri/(8-1.0)
420 r[ind] = ri/(8-1.0)
420 g[ind] = gi/(8-1.0)
421 g[ind] = gi/(8-1.0)
421 b[ind] = bi/(4-1.0)
422 b[ind] = bi/(4-1.0)
422 pos[ind] = ind/(ncolor-1.0)
423 pos[ind] = ind/(ncolor-1.0)
423 ind += 1
424 ind += 1
424 rgb_lvl = [8,8,4] #Levels for RGB colors
425 rgb_lvl = [8,8,4] #Levels for RGB colors
425
426
426 if ncolor == None:
427 if ncolor == None:
427 raise ValueError, "The colormap selected (%s) is not valid" %(colormap)
428 raise ValueError, "The colormap selected (%s) is not valid" %(colormap)
428
429
429 plplot.plscmap1n(ncolor)
430 plplot.plscmap1n(ncolor)
430 plplot.plscmap1l(1, pos, r, g, b)
431 plplot.plscmap1l(1, pos, r, g, b)
431
432
432 return rgb_lvl
433 return rgb_lvl
433
434
434
435
435 class MplDriver:
436 class MplDriver:
436 # fig = None
437 # fig = None
437 nrows = None
438 nrows = None
438 ncolumns = None
439 ncolumns = None
439 __axesId = None
440 __axesId = None
440 __setData = None
441 __setData = None
441
442
442 def __init__(self, idfigure, xw, yw, wintitle, overplot, colormap, colorbar):
443 def __init__(self, idfigure, xw, yw, wintitle, overplot, colormap, colorbar):
443
444
444 if idfigure == None:
445 if idfigure == None:
445 raise ValueError, 'idfigure input must be defined'
446 raise ValueError, 'idfigure input must be defined'
446 self.idfigure = idfigure
447 self.idfigure = idfigure
447 self.xw = xw
448 self.xw = xw
448 self.yw = yw
449 self.yw = yw
449 self.wintitle = wintitle
450 self.wintitle = wintitle
450 self.overplot = overplot
451 self.overplot = overplot
451 self.colormap = colormap
452 self.colormap = colormap
452 self.colorbar = colorbar
453 self.colorbar = colorbar
453 self.__axesId = {}
454 self.__axesId = {}
454
455
455 def setFigure(self):
456 def setFigure(self):
456 plt.ioff()
457 plt.ioff()
457 fig = plt.figure(self.idfigure)
458 fig = plt.figure(self.idfigure)
458 fig.canvas.manager.set_window_title(self.wintitle)
459 fig.canvas.manager.set_window_title(self.wintitle)
459 fig.canvas.resize(self.xw,self.yw)
460 fig.canvas.resize(self.xw,self.yw)
460 plt.ion()
461 plt.ion()
461
462
462
463
463 def setColormap(self, colormap):
464 def setColormap(self, colormap):
464 pass
465 pass
465
466
466 def openDriver(self):
467 def openDriver(self):
467 pass
468 pass
468
469
469 def openFigure(self):
470 def openFigure(self):
470 pass
471 pass
471
472
472 def setFigTitle(self,title):
473 def setFigTitle(self,title):
473 fig = plt.figure(self.idfigure)
474 fig = plt.figure(self.idfigure)
474 fig.suptitle(title,fontsize=11, fontweight='bold')
475 fig.suptitle(title,fontsize=11, fontweight='bold')
475
476
476 def setSubPlots(self,nrows,ncolumns):
477 def setSubPlots(self,nrows,ncolumns):
477 fig = plt.figure(self.idfigure)
478 fig = plt.figure(self.idfigure)
478 self.nrows = nrows
479 self.nrows = nrows
479 self.ncolumns = ncolumns
480 self.ncolumns = ncolumns
480 #self.__axesId = fig.add_subplot(nrows,ncolumns)
481 #self.__axesId = fig.add_subplot(nrows,ncolumns)
481
482
482 def plotBox(self, id, xpos, ypos, xmin, xmax, ymin, ymax, minvalue, maxvalue, xopt, yopt, szchar, xaxisastime, timefmt):
483 def plotBox(self, id, xpos, ypos, xmin, xmax, ymin, ymax, minvalue, maxvalue, xopt, yopt, szchar, xaxisastime, timefmt):
483 fig = plt.figure(self.idfigure)
484 fig = plt.figure(self.idfigure)
484 ax = fig.add_subplot(self.nrows,self.ncolumns,id)
485 ax = fig.add_subplot(self.nrows,self.ncolumns,id)
485 ax.set_xlim([xmin,xmax])
486 ax.set_xlim([xmin,xmax])
486 ax.set_ylim([ymin,ymax])
487 ax.set_ylim([ymin,ymax])
487 self.__axesId.setdefault(id)
488 self.__axesId.setdefault(id)
488 self.__axesId[id] = ax
489 self.__axesId[id] = ax
489
490
490
491
491 def setPlotLabels(self, id, xlabel, ylabel, title):
492 def setPlotLabels(self, id, xlabel, ylabel, title):
492 ax = self.__axesId[id]
493 ax = self.__axesId[id]
493 ax.set_xlabel(xlabel)
494 ax.set_xlabel(xlabel)
494 ax.set_ylabel(ylabel)
495 ax.set_ylabel(ylabel)
495 ax.set_title(title)
496 ax.set_title(title)
496
497
497 def basicLine(self, id, xpos, ypos, x, y, xmin, xmax, ymin, ymax, color):
498 def basicLine(self, id, xpos, ypos, x, y, xmin, xmax, ymin, ymax, color):
498 ax = self.__axesId[id]
499 ax = self.__axesId[id]
499
500
500 if self.__setData == None:
501 if self.__setData == None:
501 ax.plot(x,y,color)
502 ax.plot(x,y,color)
502 self.__setData = True
503 self.__setData = True
503 else:
504 else:
504 ax.lines[0].set_data(x,y)
505 ax.lines[0].set_data(x,y)
505
506
506 def refresh(self):
507 def refresh(self):
507 plt.draw()
508 plt.draw()
508
509
509
510
510 def plotColorbar(self):
511 def plotColorbar(self):
511 pass
512 pass
512
513
513
514
514 def closePage(self):
515 def closePage(self):
515 pass No newline at end of file
516 pass
@@ -1,695 +1,699
1 import numpy
1 import numpy
2 import datetime
2 import datetime
3 import time
3 import time
4 from schainPlot import *
4 from schainPlot import *
5
5
6 class CrossSpc(Figure):
6 class CrossSpc(Figure):
7 overplot = 0
7 overplot = 0
8 xw = 900
8 xw = 900
9 yw = 650
9 yw = 650
10 showprofile = False
10 showprofile = False
11 signalA = None
11 signalA = None
12 signalB = None
12 signalB = None
13 coherence = None
13 coherence = None
14 phase = None
14 phase = None
15
15
16 def __init__(self, idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile):
16 def __init__(self, idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile):
17 Figure.__init__(self,idfigure, nframes, wintitle, self.xw, self.yw, self.overplot, driver, colormap, colorbar)
17 Figure.__init__(self,idfigure, nframes, wintitle, self.xw, self.yw, self.overplot, driver, colormap, colorbar)
18
18
19 self.showprofile = showprofile
19 self.showprofile = showprofile
20 self.signalA = None
20 self.signalA = None
21 self.signalB = None
21 self.signalB = None
22 self.coherence = None
22 self.coherence = None
23 self.phase = None
23 self.phase = None
24
24
25 def getSubplots(self):
25 def getSubplots(self):
26 nrows = self.nframes
26 nrows = self.nframes
27 ncolumns = 1
27 ncolumns = 1
28 return nrows, ncolumns
28 return nrows, ncolumns
29
29
30 def setParms(self, data, x, y, xmin, xmax, ymin, ymax, minvalue, maxvalue, *args):
30 def setParms(self, data, x, y, xmin, xmax, ymin, ymax, minvalue, maxvalue, *args):
31
31
32 if xmin == None: xmin = numpy.min(x)
32 if xmin == None: xmin = numpy.min(x)
33 if xmax == None: xmax = numpy.max(x)
33 if xmax == None: xmax = numpy.max(x)
34 if ymin == None: ymin = numpy.min(y)
34 if ymin == None: ymin = numpy.min(y)
35 if ymax == None: ymax = numpy.max(y)
35 if ymax == None: ymax = numpy.max(y)
36 if minvalue == None: minvalue = 20.
36 if minvalue == None: minvalue = 20.
37 if maxvalue == None: maxvalue = 90.
37 if maxvalue == None: maxvalue = 90.
38
38
39 self.signalA = self.data[0]
39 self.signalA = self.data[0]
40 self.signalB = self.data[1]
40 self.signalB = self.data[1]
41 self.coherence = self.data[2]
41 self.coherence = self.data[2]
42 self.phase = self.data[3]
42 self.phase = self.data[3]
43
43
44 self.xmin = xmin
44 self.xmin = xmin
45 self.xmax = xmax
45 self.xmax = xmax
46 self.minrange = ymin
46 self.minrange = ymin
47 self.maxrange = ymax
47 self.maxrange = ymax
48 self.ymin = ymin
48 self.ymin = ymin
49 self.ymax = ymax
49 self.ymax = ymax
50 self.minvalue = minvalue
50 self.minvalue = minvalue
51 self.maxvalue = maxvalue
51 self.maxvalue = maxvalue
52
52
53 def changeXRange(self, *args):
53 def changeXRange(self, *args):
54 pass
54 pass
55
55
56 def createFrames(self):
56 def createFrames(self):
57 self.frameObjList = []
57 self.frameObjList = []
58
58
59 for frame in range(self.nframes):
59 for frame in range(self.nframes):
60 frameObj = CrossSpcFrame(self.drvObj,frame + 1, self.colorbar, self.showprofile)
60 frameObj = CrossSpcFrame(self.drvObj,frame + 1, self.colorbar, self.showprofile)
61 self.frameObjList.append(frameObj)
61 self.frameObjList.append(frameObj)
62
62
63
63
64 class CrossSpcFrame(Frame):
64 class CrossSpcFrame(Frame):
65 xi = None
65 xi = None
66 xw = None
66 xw = None
67 yi = None
67 yi = None
68 yw = None
68 yw = None
69 alpha = None
69 alpha = None
70 def __init__(self):
70 def __init__(self):
71 self.drvObj = drvObj
71 self.drvObj = drvObj
72 self.idframe = idframe
72 self.idframe = idframe
73 self.nplots = 4
73 self.nplots = 4
74
74
75 if showprofile:
75 if showprofile:
76 self.nplots += 4
76 self.nplots += 4
77
77
78 self.colorbar = colorbar
78 self.colorbar = colorbar
79 self.showprofile = showprofile
79 self.showprofile = showprofile
80 self.xi = 0.
80 self.xi = 0.
81 self.xw = 0.
81 self.xw = 0.
82 self.yi = 0.
82 self.yi = 0.
83 self.yw = 0.
83 self.yw = 0.
84 self.alpha = 1.
84 self.alpha = 1.
85
85
86 self.createPlots()
86 self.createPlots()
87
87
88 def createPlots(self):
88 def createPlots(self):
89 plotObjList = []
89 plotObjList = []
90 idplot = 0
90 idplot = 0
91 counter_plot = 0
91 counter_plot = 0
92 for i in range(self.nplots):
92 for i in range(self.nplots):
93 xi, yi, xw, yw = self.getScreenPos(idplot)
93 xi, yi, xw, yw = self.getScreenPos(idplot)
94 plotObj = SpcPlot(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, self.colorbar)
94 plotObj = SpcPlot(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, self.colorbar)
95 plotObjList.append(plotObj)
95 plotObjList.append(plotObj)
96
96
97 if self.showprofile:
97 if self.showprofile:
98 xi, yi, xw, yw = self.getScreenPosGraph1(idplot)
98 xi, yi, xw, yw = self.getScreenPosGraph1(idplot)
99 type = "pwbox"
99 type = "pwbox"
100 title = ""
100 title = ""
101 xlabel = "dB"
101 xlabel = "dB"
102 ylabel = ""
102 ylabel = ""
103 idplot += 1
103 idplot += 1
104 plotObj = Plot1D(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, type, title, xlabel, ylabel)
104 plotObj = Plot1D(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, type, title, xlabel, ylabel)
105 plotObjList.append(plotObj)
105 plotObjList.append(plotObj)
106 idplot += 1
106 idplot += 1
107
107
108 self.plotObjList = plotObjList
108 self.plotObjList = plotObjList
109
109
110 # def getScreenPos(self,idplot):
110 # def getScreenPos(self,idplot):
111 # pass
111 # pass
112
112
113 def getScreenPos(self, diplot):
113 def getScreenPos(self, diplot):
114
114
115 xi = self.xi
115 xi = self.xi
116 xw = self.xw
116 xw = self.xw
117
117
118 if self.showprofile:
118 if self.showprofile:
119 width = 0.55
119 width = 0.55
120 xw += width
120 xw += width
121
121
122
122
123
123
124
124
125 self.xi = 0.15 + idplot*self.alpha
125 self.xi = 0.15 + idplot*self.alpha
126
126
127 if self.showprofile:
127 if self.showprofile:
128 width = 0.55
128 width = 0.55
129 self.xw += width
129 self.xw += width
130
130
131 else:
131 else:
132 width = 0.65
132 width = 0.65
133 self.xw += width
133 self.xw += width
134
134
135 if self.colorbar:
135 if self.colorbar:
136 self.xw = self.xw - 0.06
136 self.xw = self.xw - 0.06
137
137
138
138
139 self.alpha = self.xw
139 self.alpha = self.xw
140
140
141 yi = 0.20; yw = 0.75
141 yi = 0.20; yw = 0.75
142
142
143 return xi, yi, xw, yw
143 return xi, yi, xw, yw
144
144
145 def getScreenPosGraph1(self):
145 def getScreenPosGraph1(self):
146 if self.colorbar:
146 if self.colorbar:
147 xi = self.xw + 0.08
147 xi = self.xw + 0.08
148 else:
148 else:
149 xi = self.xw + 0.05
149 xi = self.xw + 0.05
150
150
151 xw = xi + 0.2
151 xw = xi + 0.2
152
152
153 self.alpha = xw
153 self.alpha = xw
154
154
155 if self.colorbar:
155 if self.colorbar:
156 self.xi = 0.65 + 0.08
156 self.xi = 0.65 + 0.08
157 else:
157 else:
158 self.xi = 0.75 + 0.05
158 self.xi = 0.75 + 0.05
159
159
160 xw = xi + 0.2
160 xw = xi + 0.2
161
161
162 yi = 0.2; yw = 0.75
162 yi = 0.2; yw = 0.75
163
163
164 return xi, yi, xw, yw
164 return xi, yi, xw, yw
165
165
166 def plot(self,x, y, data):
166 def plot(self,x, y, data):
167 plotObj = self.plotObjList[0]
167 plotObj = self.plotObjList[0]
168 plotObj.plot(x,y,data)
168 plotObj.plot(x,y,data)
169
169
170 if self.showprofile:
170 if self.showprofile:
171 plotObj = self.plotObjList[1]
171 plotObj = self.plotObjList[1]
172 avg_data = numpy.average(data, axis=0)
172 avg_data = numpy.average(data, axis=0)
173 plotObj.plot(avg_data,y)
173 plotObj.plot(avg_data,y)
174
174
175
175
176 class SpcFigure(Figure):
176 class SpcFigure(Figure):
177 overplot = 0
177 overplot = 0
178 xw = 900
178 xw = 900
179 yw = 650
179 yw = 650
180 showprofile = False
180 showprofile = False
181
181
182 def __init__(self, idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile):
182 def __init__(self, idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile):
183 Figure.__init__(self,idfigure, nframes, wintitle, self.xw, self.yw, self.overplot, driver, colormap, colorbar)
183 Figure.__init__(self,idfigure, nframes, wintitle, self.xw, self.yw, self.overplot, driver, colormap, colorbar)
184
184
185 self.showprofile = showprofile
185 self.showprofile = showprofile
186
186
187 def getSubplots(self):
187 def getSubplots(self):
188 ncolumns = int(numpy.sqrt(self.nframes)+0.9)
188 ncolumns = int(numpy.sqrt(self.nframes)+0.9)
189 nrows = int(self.nframes*1./ncolumns + 0.9)
189 nrows = int(self.nframes*1./ncolumns + 0.9)
190
190
191 return nrows, ncolumns
191 return nrows, ncolumns
192
192
193 def setParms(self, data, x, y, xmin, xmax, ymin, ymax, minvalue, maxvalue, *args):
193 def setParms(self, data, x, y, xmin, xmax, ymin, ymax, minvalue, maxvalue, *args):
194
194
195 if xmin == None: xmin = numpy.min(x)
195 if xmin == None: xmin = numpy.min(x)
196 if xmax == None: xmax = numpy.max(x)
196 if xmax == None: xmax = numpy.max(x)
197 if ymin == None: ymin = numpy.min(y)
197 if ymin == None: ymin = numpy.min(y)
198 if ymax == None: ymax = numpy.max(y)
198 if ymax == None: ymax = numpy.max(y)
199 if minvalue == None: minvalue = 20.
199 if minvalue == None: minvalue = 20.
200 if maxvalue == None: maxvalue = 90.
200 if maxvalue == None: maxvalue = 90.
201
201
202 self.xmin = xmin
202 self.xmin = xmin
203 self.xmax = xmax
203 self.xmax = xmax
204 self.minrange = ymin
204 self.minrange = ymin
205 self.maxrange = ymax
205 self.maxrange = ymax
206 self.ymin = ymin
206 self.ymin = ymin
207 self.ymax = ymax
207 self.ymax = ymax
208 self.minvalue = minvalue
208 self.minvalue = minvalue
209 self.maxvalue = maxvalue
209 self.maxvalue = maxvalue
210
210
211
211
212 def changeXRange(self, *args):
212 def changeXRange(self, *args):
213 pass
213 pass
214
214
215 def createFrames(self):
215 def createFrames(self):
216
216
217 self.frameObjList = []
217 self.frameObjList = []
218
218
219 for frame in range(self.nframes):
219 for frame in range(self.nframes):
220 frameObj = SpcFrame(self.drvObj,frame + 1, self.colorbar, self.showprofile)
220 frameObj = SpcFrame(self.drvObj,frame + 1, self.colorbar, self.showprofile)
221 self.frameObjList.append(frameObj)
221 self.frameObjList.append(frameObj)
222
222
223 class SpcFrame(Frame):
223 class SpcFrame(Frame):
224 def __init__(self,drvObj,idframe,colorbar,showprofile):
224 def __init__(self,drvObj,idframe,colorbar,showprofile):
225 self.drvObj = drvObj
225 self.drvObj = drvObj
226 self.idframe = idframe
226 self.idframe = idframe
227 self.nplots = 1
227 self.nplots = 1
228
228
229 if showprofile:
229 if showprofile:
230 self.nplots += 1
230 self.nplots += 1
231
231
232 self.colorbar = colorbar
232 self.colorbar = colorbar
233 self.showprofile = showprofile
233 self.showprofile = showprofile
234 self.createPlots()
234 self.createPlots()
235
235
236 def createPlots(self):
236 def createPlots(self):
237 plotObjList = []
237 plotObjList = []
238 idplot = 0
238 idplot = 0
239 xi, yi, xw, yw = self.getScreenPos(idplot)
239 xi, yi, xw, yw = self.getScreenPos(idplot)
240 plotObj = SpcPlot(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, self.colorbar)
240 plotObj = SpcPlot(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, self.colorbar)
241 plotObjList.append(plotObj)
241 plotObjList.append(plotObj)
242
242
243 if self.showprofile:
243 if self.showprofile:
244 idplot = 1
244 idplot = 1
245 xi, yi, xw, yw = self.getScreenPos(idplot)
245 xi, yi, xw, yw = self.getScreenPos(idplot)
246 type = "pwbox"
246 type = "pwbox"
247 title = ""
247 title = ""
248 xlabel = "dB"
248 xlabel = "dB"
249 ylabel = ""
249 ylabel = ""
250 szchar = 0.70
250 szchar = 0.70
251 plotObj = Plot1D(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, type, title, xlabel, ylabel, szchar)
251 plotObj = Plot1D(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, type, title, xlabel, ylabel, szchar)
252 plotObjList.append(plotObj)
252 plotObjList.append(plotObj)
253
253
254 self.plotObjList = plotObjList
254 self.plotObjList = plotObjList
255
255
256 def getScreenPosMainPlot(self):
256 def getScreenPosMainPlot(self):
257 xi = 0.15
257
258 xi = 0.10
258
259
259 if self.showprofile:
260 if self.showprofile:
260 xw = 0.55
261 xw = 0.62
261
262
262 else:
263 else:
263 xw = 0.65
264 xw = 0.9
264
265
265 if self.colorbar:
266 if self.colorbar:
266 xw = xw - 0.06
267 xw = xw - 0.06
267
268
268 yi = 0.20; yw = 0.75
269 yi = 0.1; yw = 0.87
269
270
270 return xi, yi, xw, yw
271 return xi, yi, xw, yw
271
272
272 def getScreenPosGraph1(self):
273 def getScreenPosGraph1(self):
274
273 if self.colorbar:
275 if self.colorbar:
274 xi = 0.65 + 0.08
276 xi = 0.65 + 0.08
275 else:
277 else:
276 xi = 0.75 + 0.05
278 xi = 0.75 + 0.05
277
279
278 xw = xi + 0.2
280 xw = xi + 0.2
279
281
280 yi = 0.2; yw = 0.75
282 yi = 0.1; yw = 0.87
281
283
282 return xi, yi, xw, yw
284 return xi, yi, xw, yw
283
285
284 def plot(self,x, y, data):
286 def plot(self,x, y, data):
285 plotObj = self.plotObjList[0]
287 plotObj = self.plotObjList[0]
286 plotObj.plot(x,y,data)
288 plotObj.plot(x,y,data)
287
289
288 if self.showprofile:
290 if self.showprofile:
289 plotObj = self.plotObjList[1]
291 plotObj = self.plotObjList[1]
290 avg_data = numpy.average(data, axis=0)
292 avg_data = numpy.average(data, axis=0)
291 plotObj.plot(avg_data,y)
293 plotObj.plot(avg_data,y)
292
294
293 class SpcPlot(Plot):
295 class SpcPlot(Plot):
294
296
295 getGrid = True
297 getGrid = True
296
298
297 def __init__(self, drvObj, idframe, idplot, xi, yi, xw, yw, colorbar):
299 def __init__(self, drvObj, idframe, idplot, xi, yi, xw, yw, colorbar):
298 self.drvObj = drvObj
300 self.drvObj = drvObj
299 self.idframe = idframe
301 self.idframe = idframe
300 self.idplot = idplot
302 self.idplot = idplot
301 self.xi = xi
303 self.xi = xi
302 self.yi = yi
304 self.yi = yi
303 self.xw = xw
305 self.xw = xw
304 self.yw = yw
306 self.yw = yw
305 self.colorbar = colorbar
307 self.colorbar = colorbar
306
308
307 if self.colorbar:
309 if self.colorbar:
308 cbxi = xw + 0.03
310 cbxi = xw + 0.03
309 cbxw = cbxi + 0.03
311 cbxw = cbxi + 0.03
310 cbyi = yi
312 cbyi = yi
311 cbyw = yw
313 cbyw = yw
312 self.cbxpos = [cbxi,cbxw]
314 self.cbxpos = [cbxi,cbxw]
313 self.cbypos = [cbyi,cbyw]
315 self.cbypos = [cbyi,cbyw]
314
316
315 self.xpos = [self.xi,self.xw]
317 self.xpos = [self.xi,self.xw]
316 self.ypos = [self.yi,self.yw]
318 self.ypos = [self.yi,self.yw]
317 self.xaxisastime = False
319 self.xaxisastime = False
318 self.timefmt = None
320 self.timefmt = None
319 self.xopt = "bcnst"
321 self.xopt = "bcnst"
320 self.yopt = "bcnstv"
322 self.yopt = "bcnstv"
321
323
322 self.szchar = 0.7
324 self.szchar = 0.7
323 self.strforchannel = "Channel %d"%self.idframe
325 self.strforchannel = "Channel %d"%self.idframe
324 self.xlabel = "m/s"
326 self.xlabel = "m/s"
325 self.ylabel = "Range (Km)"
327 self.ylabel = "Range (Km)"
326
328
327 def setBox(self, xmin, xmax, ymin, ymax, minvalue, maxvalue, *args):
329 def setBox(self, xmin, xmax, ymin, ymax, minvalue, maxvalue, *args):
328 self.xmin = xmin
330 self.xmin = xmin
329 self.xmax = xmax
331 self.xmax = xmax
330 self.ymin = ymin
332 self.ymin = ymin
331 self.ymax = ymax
333 self.ymax = ymax
332 self.minvalue = minvalue
334 self.minvalue = minvalue
333 self.maxvalue = maxvalue
335 self.maxvalue = maxvalue
334 self.colorbar = args[2]
336 self.colorbar = args[2]
335 self.title = "%s - %s"%(self.strforchannel,args[3])
337 self.title = "%s - %s"%(self.strforchannel,args[3])
336
338
337
339
338
340
339 def plot(self, x, y, data):
341 def plot(self, x, y, data):
340 z = data
342 z = data
341 deltax = None
343 deltax = None
342 deltay = None
344 deltay = None
343 self.plotPcolor(x, y, z, deltax, deltay, self.getGrid)
345 self.plotPcolor(x, y, z, deltax, deltay, self.getGrid)
344 self.getGrid = False
346 self.getGrid = False
345
347
346
348
347 class RTIFigure(Figure):
349 class RTIFigure(Figure):
348 overplot = 1
350 overplot = 1
349 xw = 700
351 xw = 700
350 yw = 650
352 yw = 650
351 showprofile = False
353 showprofile = False
352 starttime = None
354 starttime = None
353 endtime = None
355 endtime = None
354 minrange = None
356 minrange = None
355 maxrange = None
357 maxrange = None
356 minvalue = None
358 minvalue = None
357 maxvalue = None
359 maxvalue = None
358 xrangestepinsecs = None
360 xrangestepinsecs = None
359 timefmt=None
361 timefmt=None
360
362
361 def __init__(self, idfigure, nframes, wintitle, driver, colormap="br_green", colorbar= True, showprofile=False):
363 def __init__(self, idfigure, nframes, wintitle, driver, colormap="br_green", colorbar= True, showprofile=False):
362 Figure.__init__(self,idfigure, nframes, wintitle, self.xw, self.yw, self.overplot, driver, colormap, colorbar)
364 Figure.__init__(self,idfigure, nframes, wintitle, self.xw, self.yw, self.overplot, driver, colormap, colorbar)
363
365
364 self.showprofile = showprofile
366 self.showprofile = showprofile
365
367
366 def getSubplots(self):
368 def getSubplots(self):
367 nrows = self.nframes
369 nrows = self.nframes
368 ncolumns = 1
370 ncolumns = 1
369 return nrows, ncolumns
371 return nrows, ncolumns
370
372
371 def setParms(self, data, x, y, xmin, xmax, ymin, ymax, minvalue, maxvalue, xrangestep, deltax):
373 def setParms(self, data, x, y, xmin, xmax, ymin, ymax, minvalue, maxvalue, xrangestep, deltax):
372
374
373 self.starttime = xmin
375 self.starttime = xmin
374 self.endtime = xmax
376 self.endtime = xmax
375
377
376 cdatetime = datetime.datetime.utcfromtimestamp(x)
378 cdatetime = datetime.datetime.utcfromtimestamp(x)
377
379
378 mindatetime = datetime.datetime(cdatetime.year,cdatetime.month,cdatetime.day,self.starttime.hour,self.starttime.minute,self.starttime.second)
380 mindatetime = datetime.datetime(cdatetime.year,cdatetime.month,cdatetime.day,self.starttime.hour,self.starttime.minute,self.starttime.second)
379
381
380 maxdatetime = mindatetime + datetime.timedelta(seconds=xrangestep)
382 maxdatetime = mindatetime + datetime.timedelta(seconds=xrangestep)
381 self.xrangestepinsecs = xrangestep
383 self.xrangestepinsecs = xrangestep
382
384
383 xmin = time.mktime(mindatetime.timetuple())
385 xmin = time.mktime(mindatetime.timetuple())
384 xmax = time.mktime(maxdatetime.timetuple())
386 xmax = time.mktime(maxdatetime.timetuple())
385
387
386 if self.xrangestepinsecs<=60.:
388 if self.xrangestepinsecs<=60.:
387 self.timefmt="%H:%M:%S"
389 self.timefmt="%H:%M:%S"
388
390
389 if self.xrangestepinsecs>0. and self.xrangestepinsecs<=1200.:
391 if self.xrangestepinsecs>0. and self.xrangestepinsecs<=1200.:
390 self.timefmt="%H:%M:%S"
392 self.timefmt="%H:%M:%S"
391
393
392 if self.xrangestepinsecs>1200. and self.xrangestepinsecs<=86400.:
394 if self.xrangestepinsecs>1200. and self.xrangestepinsecs<=86400.:
393 self.timefmt="%H:%M"
395 self.timefmt="%H:%M"
394
396
395 if self.xrangestepinsecs>86400.:
397 if self.xrangestepinsecs>86400.:
396 self.timefmt="%y:%m:%d:%H"
398 self.timefmt="%y:%m:%d:%H"
397
399
398 if ymin == None: ymin = numpy.min(y)
400 if ymin == None: ymin = numpy.min(y)
399 if ymax == None: ymax = numpy.max(y)
401 if ymax == None: ymax = numpy.max(y)
400
402
401 if minvalue == None: minvalue = 0.
403 if minvalue == None: minvalue = 0.
402 if maxvalue == None: maxvalue = 50.
404 if maxvalue == None: maxvalue = 50.
403
405
404 self.xmin = xmin
406 self.xmin = xmin
405 self.xmax = xmax
407 self.xmax = xmax
406 self.minrange = ymin
408 self.minrange = ymin
407 self.maxrange = ymax
409 self.maxrange = ymax
408 self.ymin = ymin
410 self.ymin = ymin
409 self.ymax = ymax
411 self.ymax = ymax
410 self.minvalue = minvalue
412 self.minvalue = minvalue
411 self.maxvalue = maxvalue
413 self.maxvalue = maxvalue
412 self.xrangestep = xrangestep
414 self.xrangestep = xrangestep
413 self.deltax = deltax
415 self.deltax = deltax
414
416
415 def changeXRange(self,x):
417 def changeXRange(self,x):
416
418
417 cdatetime = datetime.datetime.utcfromtimestamp(x)
419 cdatetime = datetime.datetime.utcfromtimestamp(x)
418
420
419 if ((cdatetime.time()>=self.starttime) and (cdatetime.time()<self.endtime)):
421 if ((cdatetime.time()>=self.starttime) and (cdatetime.time()<self.endtime)):
420
422
421 mindatetime = datetime.datetime(cdatetime.year,cdatetime.month,cdatetime.day,cdatetime.hour,cdatetime.minute,cdatetime.second)
423 mindatetime = datetime.datetime(cdatetime.year,cdatetime.month,cdatetime.day,cdatetime.hour,cdatetime.minute,cdatetime.second)
422
424
423 self.xmin = time.mktime(mindatetime.timetuple()) - time.timezone
425 self.xmin = time.mktime(mindatetime.timetuple()) - time.timezone
424 self.xmax = self.xmin + self.xrangestepinsecs
426 self.xmax = self.xmin + self.xrangestepinsecs
425
427
426 self.figuretitle = "%s %s : %s"%(self.figuretitle,
428 self.figuretitle = "%s %s : %s"%(self.figuretitle,
427 datetime.datetime.utcfromtimestamp(self.xmin).strftime("%d-%b-%Y %H:%M:%S"),
429 datetime.datetime.utcfromtimestamp(self.xmin).strftime("%d-%b-%Y %H:%M:%S"),
428 datetime.datetime.utcfromtimestamp(self.xmax).strftime("%d-%b-%Y %H:%M:%S"))
430 datetime.datetime.utcfromtimestamp(self.xmax).strftime("%d-%b-%Y %H:%M:%S"))
429 return 1
431 return 1
430
432
431 return 0
433 return 0
432
434
433 def createFrames(self):
435 def createFrames(self):
434
436
435 self.frameObjList = []
437 self.frameObjList = []
436
438
437 for frame in range(self.nframes):
439 for frame in range(self.nframes):
438 frameObj = RTIFrame(self.drvObj,frame + 1, self.colorbar, self.showprofile, self.timefmt)
440 frameObj = RTIFrame(self.drvObj,frame + 1, self.colorbar, self.showprofile, self.timefmt)
439 self.frameObjList.append(frameObj)
441 self.frameObjList.append(frameObj)
440
442
441 class RTIFrame(Frame):
443 class RTIFrame(Frame):
442 def __init__(self,drvObj,idframe,colorbar,showprofile, timefmt):
444 def __init__(self,drvObj,idframe,colorbar,showprofile, timefmt):
443 self.drvObj = drvObj
445 self.drvObj = drvObj
444 self.idframe = idframe
446 self.idframe = idframe
445 self.nplots = 1
447 self.nplots = 1
446
448
447 if showprofile:
449 if showprofile:
448 self.nplots += 1
450 self.nplots += 1
449
451
450 self.colorbar = colorbar
452 self.colorbar = colorbar
451 self.showprofile = showprofile
453 self.showprofile = showprofile
452 self.timefmt = timefmt
454 self.timefmt = timefmt
453 self.createPlots()
455 self.createPlots()
454
456
455 def createPlots(self):
457 def createPlots(self):
456 plotObjList = []
458 plotObjList = []
457
459
458 idplot = 0
460 idplot = 0
459 xi, yi, xw, yw = self.getScreenPos(idplot)
461 xi, yi, xw, yw = self.getScreenPos(idplot)
460
462
461 plotObj = RTIPlot(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, self.colorbar, self.timefmt)
463 plotObj = RTIPlot(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, self.colorbar, self.timefmt)
462 plotObjList.append(plotObj)
464 plotObjList.append(plotObj)
463
465
464 if self.showprofile:
466 if self.showprofile:
465 idplot = 1
467 idplot = 1
466 xi, yi, xw, yw = self.getScreenPos(idplot)
468 xi, yi, xw, yw = self.getScreenPos(idplot)
467 type = "pwbox"
469 type = "pwbox"
468 title = ""
470 title = ""
469 xlabel = "dB"
471 xlabel = "dB"
470 ylabel = ""
472 ylabel = ""
471 szchar = 0.75
473 szchar = 0.75
472 plotObj = Plot1D(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, type, title, xlabel, ylabel, szchar)
474 plotObj = Plot1D(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, type, title, xlabel, ylabel, szchar)
473 plotObjList.append(plotObj)
475 plotObjList.append(plotObj)
474
476
475 self.plotObjList = plotObjList
477 self.plotObjList = plotObjList
476
478
477 def getScreenPosMainPlot(self):
479 def getScreenPosMainPlot(self):
478 xi = 0.07
480 xi = 0.07
479 if self.showprofile:
481 if self.showprofile:
480 xw = 0.65
482 xw = 0.65
481 else:
483 else:
482 xw = 0.9
484 xw = 0.9
483
485
484 if self.colorbar:
486 if self.colorbar:
485 xw = xw - 0.06
487 xw = xw - 0.06
486
488
487 yi = 0.20; yw = 0.75
489 yi = 0.20; yw = 0.75
488
490
489 return xi, yi, xw, yw
491 return xi, yi, xw, yw
490
492
491 def getScreenPosGraph1(self):
493 def getScreenPosGraph1(self):
492 if self.colorbar:
494 if self.colorbar:
493 xi = 0.65 + 0.08
495 xi = 0.65 + 0.08
494 else:
496 else:
495 xi = 0.9 + 0.05
497 xi = 0.9 + 0.05
496
498
497 xw = xi + 0.2
499 xw = xi + 0.2
498
500
499 yi = 0.2; yw = 0.75
501 yi = 0.2; yw = 0.75
500
502
501 return xi, yi, xw, yw
503 return xi, yi, xw, yw
502
504
503 def plot(self, currenttime, range, data):
505 def plot(self, currenttime, range, data):
504 plotObj = self.plotObjList[0]
506 plotObj = self.plotObjList[0]
505 plotObj.plot(currenttime,range,data)
507 plotObj.plot(currenttime,range,data)
506
508
507 if self.showprofile:
509 if self.showprofile:
508 plotObj = self.plotObjList[1]
510 plotObj = self.plotObjList[1]
509 plotObj.plot(data,range)
511 plotObj.plot(data,range)
510
512
511
513
512 class RTIPlot(Plot):
514 class RTIPlot(Plot):
513 deltax = None
515 deltax = None
514 deltay = None
516 deltay = None
515 xrange = [None,None]
517 xrange = [None,None]
516 xminpos = None
518 xminpos = None
517 xmaxpos = None
519 xmaxpos = None
518 xg = None
520 xg = None
519 yg = None
521 yg = None
520
522
521 def __init__(self,drvObj, idframe, idplot, xi, yi, xw, yw, colorbar, timefmt):
523 def __init__(self,drvObj, idframe, idplot, xi, yi, xw, yw, colorbar, timefmt):
522 self.drvObj = drvObj
524 self.drvObj = drvObj
523 self.idframe = idframe
525 self.idframe = idframe
524 self.idplot = idplot
526 self.idplot = idplot
525 self.xi = xi
527 self.xi = xi
526 self.yi = yi
528 self.yi = yi
527 self.xw = xw
529 self.xw = xw
528 self.yw = yw
530 self.yw = yw
529 self.colorbar = colorbar
531 self.colorbar = colorbar
530
532
531 if self.colorbar:
533 if self.colorbar:
532 cbxi = xw + 0.03
534 cbxi = xw + 0.03
533 cbxw = cbxi + 0.03
535 cbxw = cbxi + 0.03
534 cbyi = yi
536 cbyi = yi
535 cbyw = yw
537 cbyw = yw
536 self.cbxpos = [cbxi,cbxw]
538 self.cbxpos = [cbxi,cbxw]
537 self.cbypos = [cbyi,cbyw]
539 self.cbypos = [cbyi,cbyw]
538
540
539 self.xpos = [self.xi,self.xw]
541 self.xpos = [self.xi,self.xw]
540 self.ypos = [self.yi,self.yw]
542 self.ypos = [self.yi,self.yw]
541 self.xaxisastime = True
543 self.xaxisastime = True
542 self.timefmt = timefmt
544 self.timefmt = timefmt
543 self.xopt = "bcnstd"
545 self.xopt = "bcnstd"
544 self.yopt = "bcnstv"
546 self.yopt = "bcnstv"
545
547
546 self.szchar = 1.0
548 self.szchar = 1.0
547 self.title = "Channel %d"%self.idframe
549 self.title = "Channel %d"%self.idframe
548 self.xlabel = "Local Time"
550 self.xlabel = "Local Time"
549 self.ylabel = "Range (Km)"
551 self.ylabel = "Range (Km)"
550
552
551
553
552 def setBox(self, xmin, xmax, ymin, ymax, minvalue, maxvalue, deltax=None, deltay=None, colorbar=True, *args):
554 def setBox(self, xmin, xmax, ymin, ymax, minvalue, maxvalue, deltax=None, deltay=None, colorbar=True, *args):
553 self.xmin = xmin
555 self.xmin = xmin
554 self.xmax = xmax
556 self.xmax = xmax
555 self.ymin = ymin
557 self.ymin = ymin
556 self.ymax = ymax
558 self.ymax = ymax
557 self.minvalue = minvalue
559 self.minvalue = minvalue
558 self.maxvalue = maxvalue
560 self.maxvalue = maxvalue
559 self.deltax = deltax
561 self.deltax = deltax
560 self.deltay = deltay
562 self.deltay = deltay
561 self.colorbar = colorbar
563 self.colorbar = colorbar
562
564
563 def plot(self, currenttime, range, data):
565 def plot(self, currenttime, range, data):
564
566
565 if self.xmaxpos == None:
567 if self.xmaxpos == None:
566 self.xmaxpos = currenttime
568 self.xmaxpos = currenttime
567
569
568 # if currenttime >= self.xmaxpos:
570 # if currenttime >= self.xmaxpos:
569
571
570 self.xminpos = currenttime
572 self.xminpos = currenttime
571 self.xmaxpos = currenttime + self.deltax
573 self.xmaxpos = currenttime + self.deltax
572 x = [currenttime]
574 x = [currenttime]
573 y = range
575 y = range
574 z = numpy.reshape(data, (1,-1))
576 z = numpy.reshape(data, (1,-1))
575 getGrid = True
577 getGrid = True
576
578
577 self.plotPcolor(x, y, z, self.deltax, self.deltay, getGrid)
579 self.plotPcolor(x, y, z, self.deltax, self.deltay, getGrid)
578
580
579
581
580 class ScopeFigure(Figure):
582 class ScopeFigure(Figure):
581 overplot = 0
583 overplot = 0
582 xw = 700
584 xw = 700
583 yw = 650
585 yw = 650
584 colorbar = None
586 colorbar = None
585
587
586 def __init__(self,idfigure,nframes,wintitle,driver):
588 def __init__(self,idfigure,nframes,wintitle,driver):
587 colormap = None
589 colormap = None
588 colorbar = False
590 colorbar = False
589
591
590 Figure.__init__(self,idfigure, nframes, wintitle, self.xw, self.yw, self.overplot, driver, colormap, colorbar)
592 Figure.__init__(self,idfigure, nframes, wintitle, self.xw, self.yw, self.overplot, driver, colormap, colorbar)
591
593
592
594
593 def getSubplots(self):
595 def getSubplots(self):
594 nrows = self.nframes
596 nrows = self.nframes
595 ncolumns = 1
597 ncolumns = 1
596 return nrows, ncolumns
598 return nrows, ncolumns
597
599
598 def createFrames(self):
600 def createFrames(self):
599
601
600 self.frameObjList = []
602 self.frameObjList = []
601
603
602 for frame in range(self.nframes):
604 for frame in range(self.nframes):
603 frameObj = ScopeFrame(self.drvObj,frame + 1)
605 frameObj = ScopeFrame(self.drvObj,frame + 1)
604 self.frameObjList.append(frameObj)
606 self.frameObjList.append(frameObj)
605
607
606
608
607 class ScopeFrame(Frame):
609 class ScopeFrame(Frame):
608 xlabel = ""
610 xlabel = ""
609 ylabel = ""
611 ylabel = ""
610 title = ""
612 title = ""
611 szchar = 1.1
613 szchar = 1.1
612
614
613 def __init__(self,drvObj,idframe):
615 def __init__(self,drvObj,idframe):
614 self.drvObj = drvObj
616 self.drvObj = drvObj
615 self.idframe = idframe
617 self.idframe = idframe
616 self.nplots = 1
618 self.nplots = 1
617 self.createPlots()
619 self.createPlots()
618 # Frame.__init__(self, drvObj, idframe)
620 # Frame.__init__(self, drvObj, idframe)
619
621
620 def getScreenPosMainPlot(self):#cada Frame determina las coordenadas de los plots
622 def getScreenPosMainPlot(self):#cada Frame determina las coordenadas de los plots
621 xi = 0.08; xw = 0.9
623 xi = 0.08; xw = 0.9
622 yi = 0.20; yw = 0.75
624 yi = 0.20; yw = 0.75
623 return xi,yi,xw,yw
625 return xi,yi,xw,yw
624
626
625 def createPlots(self):
627 def createPlots(self):
626 plotObjList = []
628 plotObjList = []
627 for idplot in range(self.nplots):
629 for idplot in range(self.nplots):
628 xi, yi, xw, yw = self.getScreenPos(idplot)
630 xi, yi, xw, yw = self.getScreenPos(idplot)
629 type = "scopebox"
631 type = "scopebox"
630 title = "Channel %d"%self.idframe
632 title = "Channel %d"%self.idframe
631 xlabel = "range (Km)"
633 xlabel = "range (Km)"
632 ylabel = "intensity"
634 ylabel = "intensity"
633 plotObj = Plot1D(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, type, title, xlabel, ylabel, self.szchar)
635 plotObj = Plot1D(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, type, title, xlabel, ylabel, self.szchar)
634 plotObjList.append(plotObj)
636 plotObjList.append(plotObj)
635
637
636 self.plotObjList = plotObjList
638 self.plotObjList = plotObjList
637
639
638
640
639 def plot(self, x, y, z=None):
641 def plot(self, x, y, z=None):
640 for plotObj in self.plotObjList:
642 for plotObj in self.plotObjList:
641 plotObj.plot(x, y)
643 plotObj.plot(x, y)
642
644
643
645
644 class Plot1D(Plot):
646 class Plot1D(Plot):
645 # type, title, xlabel, ylabel
647 # type, title, xlabel, ylabel
646 def __init__(self, drvObj, idframe, idplot, xi, yi, xw, yw, type, title, xlabel, ylabel, szchar):
648 def __init__(self, drvObj, idframe, idplot, xi, yi, xw, yw, type, title, xlabel, ylabel, szchar):
647 self.drvObj = drvObj
649 self.drvObj = drvObj
648 self.idframe = idframe
650 self.idframe = idframe
649 self.idplot = idplot
651 self.idplot = idplot
650 self.xi = xi
652 self.xi = xi
651 self.yi = yi
653 self.yi = yi
652 self.xw = xw
654 self.xw = xw
653 self.yw = yw
655 self.yw = yw
654 self.xpos = [self.xi,self.xw]
656 self.xpos = [self.xi,self.xw]
655 self.ypos = [self.yi,self.yw]
657 self.ypos = [self.yi,self.yw]
656 self.xaxisastime = False
658 self.xaxisastime = False
657 self.timefmt = None
659 self.timefmt = None
658 self.xopt = "bcnst"
660 self.xopt = "bcnst"
659 self.yopt = "bcnstv"
661 self.yopt = "bcnstv"
660 self.szchar = szchar
662 self.szchar = szchar
661 self.type = type
663 self.type = type
662 self.title = title
664 self.title = title
663 self.xlabel = xlabel
665 self.xlabel = xlabel
664 self.ylabel = ylabel
666 self.ylabel = ylabel
665
667
666
668
667
669
668 def setBox(self, xmin, xmax, ymin, ymax, minvalue, maxvalue, *args):
670 def setBox(self, xmin, xmax, ymin, ymax, minvalue, maxvalue, *args):
669 if self.type == "pwbox":
671 if self.type == "pwbox":
670 self.xmin = minvalue
672 self.xmin = minvalue
671 self.xmax = maxvalue
673 self.xmax = maxvalue
672 self.ymin = ymin
674 self.ymin = ymin
673 self.ymax = ymax
675 self.ymax = ymax
674 self.minvalue = minvalue
676 self.minvalue = minvalue
675 self.maxvalue = maxvalue
677 self.maxvalue = maxvalue
678 self.xopt = "bcnstg"
679 self.yopt = "bcmstv"
676
680
677 else:
681 else:
678 self.xmin = xmin
682 self.xmin = xmin
679 self.xmax = xmax
683 self.xmax = xmax
680 self.ymin = ymin
684 self.ymin = ymin
681 self.ymax = ymax
685 self.ymax = ymax
682 self.minvalue = minvalue
686 self.minvalue = minvalue
683 self.maxvalue = maxvalue
687 self.maxvalue = maxvalue
684
688
685 self.colorbar = False
689 self.colorbar = False
686
690
687 def plot(self,x,y):
691 def plot(self,x,y):
688 if y.dtype == "complex128":
692 if y.dtype == "complex128":
689 color="blue"
693 color="blue"
690 self.plotBasicLine(x, y.real, color)
694 self.plotBasicLine(x, y.real, color)
691 color="red"
695 color="red"
692 self.plotBasicLine(x, y.imag, color)
696 self.plotBasicLine(x, y.imag, color)
693 else:
697 else:
694 color="blue"
698 color="blue"
695 self.plotBasicLine(x, y, color)
699 self.plotBasicLine(x, y, color)
General Comments 0
You need to be logged in to leave comments. Login now