##// END OF EJS Templates
Se agrega funcion de test
Daniel Valdez -
r114:a9f71d925311
parent child
Show More
@@ -1,1018 +1,1078
1 """
1 """
2 Created on Feb 7, 2012
2 Created on Feb 7, 2012
3
3
4 @autor $Author$
4 @autor $Author$
5 @version $Id$
5 @version $Id$
6
6
7 """
7 """
8 import os
8 import os
9 import numpy
9 import numpy
10 import sys
10 import sys
11 import time
11 import time
12 import datetime
12 import datetime
13 import time
13 import time
14 import plplot
14 import plplot
15
15
16
16
17 def cmap1_init(colormap="gray"):
17 def cmap1_init(colormap="gray"):
18
18
19 if colormap == None:
19 if colormap == None:
20 return
20 return
21
21
22 ncolor = None
22 ncolor = None
23 rgb_lvl = None
23 rgb_lvl = None
24
24
25 # Routine for defining a specific color map 1 in HLS space.
25 # Routine for defining a specific color map 1 in HLS space.
26 # if gray is true, use basic grayscale variation from half-dark to light.
26 # if gray is true, use basic grayscale variation from half-dark to light.
27 # otherwise use false color variation from blue (240 deg) to red (360 deg).
27 # otherwise use false color variation from blue (240 deg) to red (360 deg).
28
28
29 # Independent variable of control points.
29 # Independent variable of control points.
30 i = numpy.array((0., 1.))
30 i = numpy.array((0., 1.))
31 if colormap=="gray":
31 if colormap=="gray":
32 ncolor = 256
32 ncolor = 256
33 # Hue for control points. Doesn't matter since saturation is zero.
33 # Hue for control points. Doesn't matter since saturation is zero.
34 h = numpy.array((0., 0.))
34 h = numpy.array((0., 0.))
35 # Lightness ranging from half-dark (for interest) to light.
35 # Lightness ranging from half-dark (for interest) to light.
36 l = numpy.array((0.5, 1.))
36 l = numpy.array((0.5, 1.))
37 # Gray scale has zero saturation
37 # Gray scale has zero saturation
38 s = numpy.array((0., 0.))
38 s = numpy.array((0., 0.))
39
39
40 # number of cmap1 colours is 256 in this case.
40 # number of cmap1 colours is 256 in this case.
41 plplot.plscmap1n(ncolor)
41 plplot.plscmap1n(ncolor)
42 # Interpolate between control points to set up cmap1.
42 # Interpolate between control points to set up cmap1.
43 plplot.plscmap1l(0, i, h, l, s)
43 plplot.plscmap1l(0, i, h, l, s)
44
44
45 return None
45 return None
46
46
47 if colormap == 'jet':
47 if colormap == 'jet':
48 ncolor = 256
48 ncolor = 256
49 pos = numpy.zeros((ncolor))
49 pos = numpy.zeros((ncolor))
50 r = numpy.zeros((ncolor))
50 r = numpy.zeros((ncolor))
51 g = numpy.zeros((ncolor))
51 g = numpy.zeros((ncolor))
52 b = numpy.zeros((ncolor))
52 b = numpy.zeros((ncolor))
53
53
54 for i in range(ncolor):
54 for i in range(ncolor):
55 if(i <= 35.0/100*(ncolor-1)): rf = 0.0
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
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
57 elif (i <= 89.0/100*(ncolor-1)): rf = 1.0
58 else: rf = (-100.0/22)*i/(ncolor-1) + 111.0/22
58 else: rf = (-100.0/22)*i/(ncolor-1) + 111.0/22
59
59
60 if(i <= 12.0/100*(ncolor-1)): gf = 0.0
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
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
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
63 elif(i <= 91.0/100*(ncolor-1)): gf = (-100.0/27)*i/(ncolor-1) + 91.0/27
64 else: gf = 0.0
64 else: gf = 0.0
65
65
66 if(i <= 11.0/100*(ncolor-1)): bf = (50.0/11)*i/(ncolor-1) + 0.5
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
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
68 elif(i <= 65.0/100*(ncolor-1)): bf = (-100.0/31)*i/(ncolor-1) + 65.0/31
69 else: bf = 0
69 else: bf = 0
70
70
71 r[i] = rf
71 r[i] = rf
72 g[i] = gf
72 g[i] = gf
73 b[i] = bf
73 b[i] = bf
74
74
75 pos[i] = float(i)/float(ncolor-1)
75 pos[i] = float(i)/float(ncolor-1)
76
76
77
77
78 plplot.plscmap1n(ncolor)
78 plplot.plscmap1n(ncolor)
79 plplot.plscmap1l(1, pos, r, g, b)
79 plplot.plscmap1l(1, pos, r, g, b)
80
80
81
81
82
82
83 if colormap=="br_green":
83 if colormap=="br_green":
84 ncolor = 256
84 ncolor = 256
85 # 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)
86 h = numpy.array((240., 0.))
86 h = numpy.array((240., 0.))
87 # Lightness and saturation are constant (values taken from C example).
87 # Lightness and saturation are constant (values taken from C example).
88 l = numpy.array((0.6, 0.6))
88 l = numpy.array((0.6, 0.6))
89 s = numpy.array((0.8, 0.8))
89 s = numpy.array((0.8, 0.8))
90
90
91 # number of cmap1 colours is 256 in this case.
91 # number of cmap1 colours is 256 in this case.
92 plplot.plscmap1n(ncolor)
92 plplot.plscmap1n(ncolor)
93 # Interpolate between control points to set up cmap1.
93 # Interpolate between control points to set up cmap1.
94 plplot.plscmap1l(0, i, h, l, s)
94 plplot.plscmap1l(0, i, h, l, s)
95
95
96 return None
96 return None
97
97
98 if colormap=="tricolor":
98 if colormap=="tricolor":
99 ncolor = 3
99 ncolor = 3
100 # Hue ranges from blue (240 deg) to red (0 or 360 deg)
100 # Hue ranges from blue (240 deg) to red (0 or 360 deg)
101 h = numpy.array((240., 0.))
101 h = numpy.array((240., 0.))
102 # Lightness and saturation are constant (values taken from C example).
102 # Lightness and saturation are constant (values taken from C example).
103 l = numpy.array((0.6, 0.6))
103 l = numpy.array((0.6, 0.6))
104 s = numpy.array((0.8, 0.8))
104 s = numpy.array((0.8, 0.8))
105
105
106 # number of cmap1 colours is 256 in this case.
106 # number of cmap1 colours is 256 in this case.
107 plplot.plscmap1n(ncolor)
107 plplot.plscmap1n(ncolor)
108 # Interpolate between control points to set up cmap1.
108 # Interpolate between control points to set up cmap1.
109 plplot.plscmap1l(0, i, h, l, s)
109 plplot.plscmap1l(0, i, h, l, s)
110
110
111 return None
111 return None
112
112
113 if colormap == 'rgb' or colormap == 'rgb666':
113 if colormap == 'rgb' or colormap == 'rgb666':
114
114
115 color_sz = 6
115 color_sz = 6
116 ncolor = color_sz*color_sz*color_sz
116 ncolor = color_sz*color_sz*color_sz
117 pos = numpy.zeros((ncolor))
117 pos = numpy.zeros((ncolor))
118 r = numpy.zeros((ncolor))
118 r = numpy.zeros((ncolor))
119 g = numpy.zeros((ncolor))
119 g = numpy.zeros((ncolor))
120 b = numpy.zeros((ncolor))
120 b = numpy.zeros((ncolor))
121 ind = 0
121 ind = 0
122 for ri in range(color_sz):
122 for ri in range(color_sz):
123 for gi in range(color_sz):
123 for gi in range(color_sz):
124 for bi in range(color_sz):
124 for bi in range(color_sz):
125 r[ind] = ri/(color_sz-1.0)
125 r[ind] = ri/(color_sz-1.0)
126 g[ind] = gi/(color_sz-1.0)
126 g[ind] = gi/(color_sz-1.0)
127 b[ind] = bi/(color_sz-1.0)
127 b[ind] = bi/(color_sz-1.0)
128 pos[ind] = ind/(ncolor-1.0)
128 pos[ind] = ind/(ncolor-1.0)
129 ind += 1
129 ind += 1
130 rgb_lvl = [6,6,6] #Levels for RGB colors
130 rgb_lvl = [6,6,6] #Levels for RGB colors
131
131
132 if colormap == 'rgb676':
132 if colormap == 'rgb676':
133 ncolor = 6*7*6
133 ncolor = 6*7*6
134 pos = numpy.zeros((ncolor))
134 pos = numpy.zeros((ncolor))
135 r = numpy.zeros((ncolor))
135 r = numpy.zeros((ncolor))
136 g = numpy.zeros((ncolor))
136 g = numpy.zeros((ncolor))
137 b = numpy.zeros((ncolor))
137 b = numpy.zeros((ncolor))
138 ind = 0
138 ind = 0
139 for ri in range(8):
139 for ri in range(8):
140 for gi in range(8):
140 for gi in range(8):
141 for bi in range(4):
141 for bi in range(4):
142 r[ind] = ri/(6-1.0)
142 r[ind] = ri/(6-1.0)
143 g[ind] = gi/(7-1.0)
143 g[ind] = gi/(7-1.0)
144 b[ind] = bi/(6-1.0)
144 b[ind] = bi/(6-1.0)
145 pos[ind] = ind/(ncolor-1.0)
145 pos[ind] = ind/(ncolor-1.0)
146 ind += 1
146 ind += 1
147 rgb_lvl = [6,7,6] #Levels for RGB colors
147 rgb_lvl = [6,7,6] #Levels for RGB colors
148
148
149 if colormap == 'rgb685':
149 if colormap == 'rgb685':
150 ncolor = 6*8*5
150 ncolor = 6*8*5
151 pos = numpy.zeros((ncolor))
151 pos = numpy.zeros((ncolor))
152 r = numpy.zeros((ncolor))
152 r = numpy.zeros((ncolor))
153 g = numpy.zeros((ncolor))
153 g = numpy.zeros((ncolor))
154 b = numpy.zeros((ncolor))
154 b = numpy.zeros((ncolor))
155 ind = 0
155 ind = 0
156 for ri in range(8):
156 for ri in range(8):
157 for gi in range(8):
157 for gi in range(8):
158 for bi in range(4):
158 for bi in range(4):
159 r[ind] = ri/(6-1.0)
159 r[ind] = ri/(6-1.0)
160 g[ind] = gi/(8-1.0)
160 g[ind] = gi/(8-1.0)
161 b[ind] = bi/(5-1.0)
161 b[ind] = bi/(5-1.0)
162 pos[ind] = ind/(ncolor-1.0)
162 pos[ind] = ind/(ncolor-1.0)
163 ind += 1
163 ind += 1
164 rgb_lvl = [6,8,5] #Levels for RGB colors
164 rgb_lvl = [6,8,5] #Levels for RGB colors
165
165
166 if colormap == 'rgb884':
166 if colormap == 'rgb884':
167 ncolor = 8*8*4
167 ncolor = 8*8*4
168 pos = numpy.zeros((ncolor))
168 pos = numpy.zeros((ncolor))
169 r = numpy.zeros((ncolor))
169 r = numpy.zeros((ncolor))
170 g = numpy.zeros((ncolor))
170 g = numpy.zeros((ncolor))
171 b = numpy.zeros((ncolor))
171 b = numpy.zeros((ncolor))
172 ind = 0
172 ind = 0
173 for ri in range(8):
173 for ri in range(8):
174 for gi in range(8):
174 for gi in range(8):
175 for bi in range(4):
175 for bi in range(4):
176 r[ind] = ri/(8-1.0)
176 r[ind] = ri/(8-1.0)
177 g[ind] = gi/(8-1.0)
177 g[ind] = gi/(8-1.0)
178 b[ind] = bi/(4-1.0)
178 b[ind] = bi/(4-1.0)
179 pos[ind] = ind/(ncolor-1.0)
179 pos[ind] = ind/(ncolor-1.0)
180 ind += 1
180 ind += 1
181 rgb_lvl = [8,8,4] #Levels for RGB colors
181 rgb_lvl = [8,8,4] #Levels for RGB colors
182
182
183 if ncolor == None:
183 if ncolor == None:
184 raise ValueError, "The colormap selected is not valid"
184 raise ValueError, "The colormap selected is not valid"
185
185
186 plplot.plscmap1n(ncolor)
186 plplot.plscmap1n(ncolor)
187 plplot.plscmap1l(1, pos, r, g, b)
187 plplot.plscmap1l(1, pos, r, g, b)
188
188
189 return rgb_lvl
189 return rgb_lvl
190
190
191 def setColormap(colormap="jet"):
191 def setColormap(colormap="jet"):
192 cmap1_init(colormap)
192 cmap1_init(colormap)
193
193
194 def savePlplot(filename,width,height):
194 def savePlplot(filename,width,height):
195 curr_strm = plplot.plgstrm()
195 curr_strm = plplot.plgstrm()
196 save_strm = plplot.plmkstrm()
196 save_strm = plplot.plmkstrm()
197 plplot.plsetopt("geometry", "%dx%d"%(width,height))
197 plplot.plsetopt("geometry", "%dx%d"%(width,height))
198 plplot.plsdev("png")
198 plplot.plsdev("png")
199 plplot.plsfnam(filename)
199 plplot.plsfnam(filename)
200 plplot.plcpstrm(curr_strm,0)
200 plplot.plcpstrm(curr_strm,0)
201 plplot.plreplot()
201 plplot.plreplot()
202 plplot.plend1()
202 plplot.plend1()
203 plplot.plsstrm(curr_strm)
203 plplot.plsstrm(curr_strm)
204
204
205
205
206 def initPlplot(indexPlot,ncol,nrow,winTitle,width,height):
206 def initPlplot(indexPlot,ncol,nrow,winTitle,width,height):
207 plplot.plsstrm(indexPlot)
207 plplot.plsstrm(indexPlot)
208 plplot.plparseopts([winTitle],plplot.PL_PARSE_FULL)
208 plplot.plparseopts([winTitle],plplot.PL_PARSE_FULL)
209 plplot.plsetopt("geometry", "%dx%d"%(width*ncol,height*nrow))
209 plplot.plsetopt("geometry", "%dx%d"%(width*ncol,height*nrow))
210 plplot.plsdev("xwin")
210 plplot.plsdev("xwin")
211 plplot.plscolbg(255,255,255)
211 plplot.plscolbg(255,255,255)
212 plplot.plscol0(1,0,0,0)
212 plplot.plscol0(1,0,0,0)
213 plplot.plinit()
213 plplot.plinit()
214 plplot.plspause(False)
214 plplot.plspause(False)
215 plplot.plssub(ncol,nrow)
215 plplot.plssub(ncol,nrow)
216
216
217 def setNewPage():
217 def setNewPage():
218 plplot.plbop()
218 plplot.plbop()
219 plplot.pladv(0)
219 plplot.pladv(0)
220
220
221 def closePage():
221 def closePage():
222 plplot.pleop()
222 plplot.pleop()
223
223
224 def clearData(objGraph):
224 def clearData(objGraph):
225 objGraph.plotBox(objGraph.xrange[0], objGraph.xrange[1], objGraph.yrange[0], objGraph.yrange[1], "bc", "bc")
225 objGraph.plotBox(objGraph.xrange[0], objGraph.xrange[1], objGraph.yrange[0], objGraph.yrange[1], "bc", "bc")
226
226
227 objGraph.setColor(15) #Setting Line Color to White
227 objGraph.setColor(15) #Setting Line Color to White
228
228
229 if objGraph.datatype == "complex":
229 if objGraph.datatype == "complex":
230 objGraph.basicXYPlot(objGraph.xdata,objGraph.ydata.real)
230 objGraph.basicXYPlot(objGraph.xdata,objGraph.ydata.real)
231 objGraph.basicXYPlot(objGraph.xdata,objGraph.ydata.imag)
231 objGraph.basicXYPlot(objGraph.xdata,objGraph.ydata.imag)
232
232
233 if objGraph.datatype == "real":
233 if objGraph.datatype == "real":
234 objGraph.basicXYPlot(objGraph.xdata,objGraph.ydata)
234 objGraph.basicXYPlot(objGraph.xdata,objGraph.ydata)
235
235
236 objGraph.setColor(1) #Setting Line Color to Black
236 objGraph.setColor(1) #Setting Line Color to Black
237 # objGraph.setLineStyle(2)
237 # objGraph.setLineStyle(2)
238 # objGraph.plotBox(objGraph.xrange[0], objGraph.xrange[1], objGraph.yrange[0], objGraph.yrange[1], "bcntg", "bc")
238 # objGraph.plotBox(objGraph.xrange[0], objGraph.xrange[1], objGraph.yrange[0], objGraph.yrange[1], "bcntg", "bc")
239 # objGraph.setLineStyle(1)
239 # objGraph.setLineStyle(1)
240
240
241 def setStrm(indexPlot):
241 def setStrm(indexPlot):
242 plplot.plsstrm(indexPlot)
242 plplot.plsstrm(indexPlot)
243
243
244 def plFlush():
244 def plFlush():
245 plplot.plflush()
245 plplot.plflush()
246
247 def plShow():
248 plplot.plspause(True)
249 plplot.plend()
246
250
247 def setPlTitle(pltitle,color, szchar=0.7):
251 def setPlTitle(pltitle,color, szchar=0.7):
248 setSubpages(1, 0)
252 setSubpages(1, 0)
249 plplot.pladv(0)
253 plplot.pladv(0)
250 plplot.plvpor(0., 1., 0., 1.)
254 plplot.plvpor(0., 1., 0., 1.)
251
255
252 if color == "black":
256 if color == "black":
253 plplot.plcol0(1)
257 plplot.plcol0(1)
254 if color == "white":
258 if color == "white":
255 plplot.plcol0(15)
259 plplot.plcol0(15)
256
260
257 plplot.plschr(0.0,szchar)
261 plplot.plschr(0.0,szchar)
258 plplot.plmtex("t",-1., 0.5, 0.5, pltitle)
262 plplot.plmtex("t",-1., 0.5, 0.5, pltitle)
259
263
260 def setSubpages(ncol,nrow):
264 def setSubpages(ncol,nrow):
261 plplot.plssub(ncol,nrow)
265 plplot.plssub(ncol,nrow)
262
266
263 class BaseGraph:
267 class BaseGraph:
264
268
265 __name = None
269 __name = None
266 __xpos = None
270 __xpos = None
267 __ypos = None
271 __ypos = None
268 __subplot = None
272 __subplot = None
269 __xg = None
273 __xg = None
270 __yg = None
274 __yg = None
271 xdata = None
275 xdata = None
272 ydata = None
276 ydata = None
273 getGrid = True
277 getGrid = True
274 xaxisIsTime = False
278 xaxisIsTime = False
275 deltax = None
279 deltax = None
276 xmin = None
280 xmin = None
277 xmax = None
281 xmax = None
278
282
279 def __init__(self,name,subplot,xpos,ypos,xlabel,ylabel,title,szchar,xrange,yrange,zrange=None,deltax=1.0):
283 def __init__(self,name,subplot,xpos,ypos,xlabel,ylabel,title,szchar,xrange,yrange,zrange=None,deltax=1.0):
280
284
281 self.setName(name)
285 self.setName(name)
282 self.setScreenPos(xpos, ypos)
286 self.setScreenPos(xpos, ypos)
283 self.setLabels(xlabel,ylabel,title)
287 self.setLabels(xlabel,ylabel,title)
284 self.setSubPlot(subplot)
288 self.setSubPlot(subplot)
285 self.setSizeOfChar(szchar)
289 self.setSizeOfChar(szchar)
286 self.setXYZrange(xrange,yrange,zrange)
290 self.setXYZrange(xrange,yrange,zrange)
287 self.getGrid = True
291 self.getGrid = True
288 self.xaxisIsTime = False
292 self.xaxisIsTime = False
289 self.deltax = deltax
293 self.deltax = deltax
290
294
291 def setXYZrange(self,xrange,yrange,zrange):
295 def setXYZrange(self,xrange,yrange,zrange):
292 self.xrange = xrange
296 self.xrange = xrange
293 self.yrange = yrange
297 self.yrange = yrange
294 self.zrange = zrange
298 self.zrange = zrange
295
299
296 def setName(self, name):
300 def setName(self, name):
297 self.__name = name
301 self.__name = name
298
302
299 def setScreenPos(self,xpos,ypos):
303 def setScreenPos(self,xpos,ypos):
300 self.__xpos = xpos
304 self.__xpos = xpos
301 self.__ypos = ypos
305 self.__ypos = ypos
302
306
303 def setXYData(self,xdata=None,ydata=None,datatype="real"):
307 def setXYData(self,xdata=None,ydata=None,datatype="real"):
304 if((xdata != None) and (ydata != None)):
308 if((xdata != None) and (ydata != None)):
305 self.xdata = xdata
309 self.xdata = xdata
306 self.ydata = ydata
310 self.ydata = ydata
307 self.datatype = datatype
311 self.datatype = datatype
308
312
309 if((self.xdata == None) and (self.ydata == None)):
313 if((self.xdata == None) and (self.ydata == None)):
310 return None
314 return None
311
315
312 return 1
316 return 1
313
317
314
318
315 def setLabels(self,xlabel=None,ylabel=None,title=None):
319 def setLabels(self,xlabel=None,ylabel=None,title=None):
316 if xlabel != None: self.xlabel = xlabel
320 if xlabel != None: self.xlabel = xlabel
317 if ylabel != None: self.ylabel = ylabel
321 if ylabel != None: self.ylabel = ylabel
318 if title != None: self.title = title
322 if title != None: self.title = title
319
323
320 def setSubPlot(self,subplot):
324 def setSubPlot(self,subplot):
321 self.__subplot = subplot
325 self.__subplot = subplot
322
326
323 def setSizeOfChar(self,szchar):
327 def setSizeOfChar(self,szchar):
324 self.__szchar = szchar
328 self.__szchar = szchar
325
329
326 def setLineStyle(self,style):
330 def setLineStyle(self,style):
327 plplot.pllsty(style)
331 plplot.pllsty(style)
328
332
329 def setColor(self,color):
333 def setColor(self,color):
330 plplot.plcol0(color)
334 plplot.plcol0(color)
331
335
332 def setXAxisAsTime(self,value=False):
336 def setXAxisAsTime(self,value=False):
333 self.xaxisIsTime = value
337 self.xaxisIsTime = value
334
338
335 def basicLineTimePlot(self, x, y, xmin=None, xmax=None, ymin=None, ymax=None, colline=1):
339 def basicLineTimePlot(self, x, y, xmin=None, xmax=None, ymin=None, ymax=None, colline=1):
336
340
337 if xmin == None: xmin = x[0]
341 if xmin == None: xmin = x[0]
338 if xmax == None: xmax = x[-1]
342 if xmax == None: xmax = x[-1]
339 if ymin == None: ymin = y[0]
343 if ymin == None: ymin = y[0]
340 if ymax == None: ymax = y[-1]
344 if ymax == None: ymax = y[-1]
341
345
342 plplot.plcol0(colline)
346 plplot.plcol0(colline)
343 plplot.plline(x, y)
347 plplot.plline(x, y)
344 plplot.plcol0(1)
348 plplot.plcol0(1)
345
349
346 def basicXYPlot(self, x, y, xmin=None, xmax=None, ymin=None, ymax=None):
350 def basicXYPlot(self, x, y, xmin=None, xmax=None, ymin=None, ymax=None):
347
351
348 if xmin == None: xmin = x[0]
352 if xmin == None: xmin = x[0]
349 if xmax == None: xmax = x[-1]
353 if xmax == None: xmax = x[-1]
350 if ymin == None: ymin = y[0]
354 if ymin == None: ymin = y[0]
351 if ymax == None: ymax = y[-1]
355 if ymax == None: ymax = y[-1]
352
356
353 plplot.plline(x, y)
357 plplot.plline(x, y)
354
358
355 def basicPcolorPlot(self, data, x, y, xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None):
359 def basicPcolorPlot(self, data, x, y, xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None):
356 """
360 """
357 """
361 """
358 if xmin == None: xmin = x[0]
362 if xmin == None: xmin = x[0]
359 if xmax == None: xmax = x[-1]
363 if xmax == None: xmax = x[-1]
360 if ymin == None: ymin = y[0]
364 if ymin == None: ymin = y[0]
361 if ymax == None: ymax = y[-1]
365 if ymax == None: ymax = y[-1]
362 if zmin == None: zmin = numpy.nanmin(data)
366 if zmin == None: zmin = numpy.nanmin(data)
363 if zmax == None: zmax = numpy.nanmax(data)
367 if zmax == None: zmax = numpy.nanmax(data)
364
368
365 plplot.plimage(data,
369 plplot.plimage(data,
366 float(x[0]),
370 float(x[0]),
367 float(x[-1]),
371 float(x[-1]),
368 float(y[0]),
372 float(y[0]),
369 float(y[-1]),
373 float(y[-1]),
370 float(zmin),
374 float(zmin),
371 float(zmax),
375 float(zmax),
372 float(xmin),
376 float(xmin),
373 float(xmax),
377 float(xmax),
374 float(ymin),
378 float(ymin),
375 float(ymax)
379 float(ymax)
376 )
380 )
377
381
378 def __getBoxpltr(self, x, y, deltax=None, deltay=None):
382 def __getBoxpltr(self, x, y, deltax=None, deltay=None):
379
383
380 if not(len(x)>0 and len(y)>0):
384 if not(len(x)>0 and len(y)>0):
381 raise ValueError, "x axis and y axis are empty"
385 raise ValueError, "x axis and y axis are empty"
382
386
383 if deltax == None: deltax = x[-1] - x[-2]
387 if deltax == None: deltax = x[-1] - x[-2]
384 if deltay == None: deltay = y[-1] - y[-2]
388 if deltay == None: deltay = y[-1] - y[-2]
385
389
386 x1 = numpy.append(x, x[-1] + deltax)
390 x1 = numpy.append(x, x[-1] + deltax)
387 y1 = numpy.append(y, y[-1] + deltay)
391 y1 = numpy.append(y, y[-1] + deltay)
388
392
389 xg = (numpy.multiply.outer(x1, numpy.ones(len(y1))))
393 xg = (numpy.multiply.outer(x1, numpy.ones(len(y1))))
390 yg = (numpy.multiply.outer(numpy.ones(len(x1)), y1))
394 yg = (numpy.multiply.outer(numpy.ones(len(x1)), y1))
391
395
392 self.__xg = xg
396 self.__xg = xg
393 self.__yg = yg
397 self.__yg = yg
394
398
395 return xg, yg
399 return xg, yg
396
400
397
401
398 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):
402 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):
399 if getGrid:
403 if getGrid:
400 xg, yg = self.__getBoxpltr(x, y, deltax, deltay)
404 xg, yg = self.__getBoxpltr(x, y, deltax, deltay)
401 else:
405 else:
402 xg = self.__xg
406 xg = self.__xg
403 yg = self.__yg
407 yg = self.__yg
404
408
405 plplot.plimagefr(data,
409 plplot.plimagefr(data,
406 float(xmin),
410 float(xmin),
407 float(xmax),
411 float(xmax),
408 float(ymin),
412 float(ymin),
409 float(ymax),
413 float(ymax),
410 0.,
414 0.,
411 0.,
415 0.,
412 float(zmin),
416 float(zmin),
413 float(zmax),
417 float(zmax),
414 plplot.pltr2,
418 plplot.pltr2,
415 xg,
419 xg,
416 yg)
420 yg)
417
421
418
422
419 def colorbarPlot(self, xmin=0., xmax=1., ymin=0., ymax=1.):
423 def colorbarPlot(self, xmin=0., xmax=1., ymin=0., ymax=1.):
420 data = numpy.arange(256)
424 data = numpy.arange(256)
421 data = numpy.reshape(data, (1,-1))
425 data = numpy.reshape(data, (1,-1))
422
426
423 plplot.plimage(data,
427 plplot.plimage(data,
424 float(xmin),
428 float(xmin),
425 float(xmax),
429 float(xmax),
426 float(ymin),
430 float(ymin),
427 float(ymax),
431 float(ymax),
428 0.,
432 0.,
429 255.,
433 255.,
430 float(xmin),
434 float(xmin),
431 float(xmax),
435 float(xmax),
432 float(ymin),
436 float(ymin),
433 float(ymax))
437 float(ymax))
434
438
435 def plotBox(self, xmin, xmax, ymin, ymax, xopt, yopt, nolabels=False):
439 def plotBox(self, xmin, xmax, ymin, ymax, xopt, yopt, nolabels=False):
436
440
437 plplot.plschr(0.0,self.__szchar-0.05)
441 plplot.plschr(0.0,self.__szchar-0.05)
438 plplot.pladv(self.__subplot)
442 plplot.pladv(self.__subplot)
439 plplot.plvpor(self.__xpos[0], self.__xpos[1], self.__ypos[0], self.__ypos[1])
443 plplot.plvpor(self.__xpos[0], self.__xpos[1], self.__ypos[0], self.__ypos[1])
440 plplot.plwind(float(xmin), # self.xrange[0]
444 plplot.plwind(float(xmin), # self.xrange[0]
441 float(xmax), # self.xrange[1]
445 float(xmax), # self.xrange[1]
442 float(ymin), # self.yrange[0]
446 float(ymin), # self.yrange[0]
443 float(ymax) # self.yrange[1]
447 float(ymax) # self.yrange[1]
444 )
448 )
445
449
446
450
447
451
448 if self.xaxisIsTime:
452 if self.xaxisIsTime:
449 plplot.pltimefmt("%H:%M")
453 plplot.pltimefmt("%H:%M")
450 timedelta = (xmax - xmin + 1)/8.
454 timedelta = (xmax - xmin + 1)/8.
451 plplot.plbox(xopt, timedelta, 3, yopt, 0.0, 0)
455 plplot.plbox(xopt, timedelta, 3, yopt, 0.0, 0)
452 else:
456 else:
453 plplot.plbox(xopt, 0.0, 0, yopt, 0.0, 0)
457 plplot.plbox(xopt, 0.0, 0, yopt, 0.0, 0)
454
458
455
459
456 if not(nolabels):
460 if not(nolabels):
457 plplot.pllab(self.xlabel, self.ylabel, self.title)
461 plplot.pllab(self.xlabel, self.ylabel, self.title)
458
462
459
463
460 def delLabels(self):
464 def delLabels(self):
461 self.setColor(15) #Setting Line Color to White
465 self.setColor(15) #Setting Line Color to White
462 plplot.pllab(self.xlabel, self.ylabel, self.title)
466 plplot.pllab(self.xlabel, self.ylabel, self.title)
463 self.setColor(1) #Setting Line Color to Black
467 self.setColor(1) #Setting Line Color to Black
464
468
465
469
466
470
467 def plotImage(self,x,y,z,xrange,yrange,zrange):
471 def plotImage(self,x,y,z,xrange,yrange,zrange):
468 xi = x[0]
472 xi = x[0]
469 xf = x[-1]
473 xf = x[-1]
470 yi = y[0]
474 yi = y[0]
471 yf = y[-1]
475 yf = y[-1]
472
476
473 plplot.plimage(z,
477 plplot.plimage(z,
474 float(xi),
478 float(xi),
475 float(xf),
479 float(xf),
476 float(yi),
480 float(yi),
477 float(yf),
481 float(yf),
478 float(zrange[0]),
482 float(zrange[0]),
479 float(zrange[1]),
483 float(zrange[1]),
480 float(xi),
484 float(xi),
481 float(xf),
485 float(xf),
482 float(yrange[0]),
486 float(yrange[0]),
483 yrange[1])
487 yrange[1])
484
488
485 class LinearPlot:
489 class LinearPlot:
486 linearObjDic = {}
490 linearObjDic = {}
487 __xpos = None
491 __xpos = None
488 __ypos = None
492 __ypos = None
489 def __init__(self,indexPlot,nsubplot,winTitle):
493 def __init__(self,indexPlot,nsubplot,winTitle):
490 self.width = 700
494 self.width = 700
491 self.height = 150
495 self.height = 150
492 ncol = 1
496 ncol = 1
493 nrow = nsubplot
497 nrow = nsubplot
494 initPlplot(indexPlot,ncol,nrow,winTitle,self.width,self.height)
498 initPlplot(indexPlot,ncol,nrow,winTitle,self.width,self.height)
495
499
496
500
497 def setFigure(self,indexPlot):
501 def setFigure(self,indexPlot):
498 setStrm(indexPlot)
502 setStrm(indexPlot)
499
503
500 def setPosition(self):
504 def setPosition(self):
501
505
502 xi = 0.07; xf = 0.9 #0.8,0.7,0.5
506 xi = 0.07; xf = 0.9 #0.8,0.7,0.5
503 yi = 0.15; yf = 0.8
507 yi = 0.15; yf = 0.8
504
508
505 xpos = [xi,xf]
509 xpos = [xi,xf]
506 ypos = [yi,yf]
510 ypos = [yi,yf]
507
511
508 self.__xpos = xpos
512 self.__xpos = xpos
509 self.__ypos = ypos
513 self.__ypos = ypos
510
514
511 return xpos,ypos
515 return xpos,ypos
512
516
517 def show(self):
518 plShow()
519
513 def refresh(self):
520 def refresh(self):
514 plFlush()
521 plFlush()
515
522
516 def setup(self,subplot,xmin,xmax,ymin,ymax,title,xlabel,ylabel):
523 def setup(self,subplot,xmin,xmax,ymin,ymax,title,xlabel,ylabel):
517 szchar = 1.10
524 szchar = 1.10
518 name = "linear"
525 name = "linear"
519 key = name + "%d"%subplot
526 key = name + "%d"%subplot
520 xrange = [xmin,xmax]
527 xrange = [xmin,xmax]
521 yrange = [ymin,ymax]
528 yrange = [ymin,ymax]
522
529
523 xpos,ypos = self.setPosition()
530 xpos,ypos = self.setPosition()
524 linearObj = BaseGraph(name,subplot,xpos,ypos,xlabel,ylabel,title,szchar,xrange,yrange)
531 linearObj = BaseGraph(name,subplot,xpos,ypos,xlabel,ylabel,title,szchar,xrange,yrange)
525 linearObj.plotBox(linearObj.xrange[0], linearObj.xrange[1], linearObj.yrange[0], linearObj.yrange[1], "bcnst", "bcnstv")
532 linearObj.plotBox(linearObj.xrange[0], linearObj.xrange[1], linearObj.yrange[0], linearObj.yrange[1], "bcnst", "bcnstv")
526 self.linearObjDic[key] = linearObj
533 self.linearObjDic[key] = linearObj
527
534
528 def plot(self,subplot,x,y,type="power"):
535 def plot(self,subplot,x,y,type="power"):
529 name = "linear"
536 name = "linear"
530 key = name + "%d"%subplot
537 key = name + "%d"%subplot
531
538
532 linearObj = self.linearObjDic[key]
539 linearObj = self.linearObjDic[key]
533 linearObj.plotBox(linearObj.xrange[0], linearObj.xrange[1], linearObj.yrange[0], linearObj.yrange[1], "bcst", "bcst")
540 linearObj.plotBox(linearObj.xrange[0], linearObj.xrange[1], linearObj.yrange[0], linearObj.yrange[1], "bcst", "bcst")
534
541
535 if linearObj.setXYData() != None:
542 if linearObj.setXYData() != None:
536 clearData(linearObj)
543 clearData(linearObj)
537
544
538 else:
545 else:
546 if type.lower() == 'simple':
547 linearObj.setXYData(x,y,"real")
539 if type.lower() == 'power':
548 if type.lower() == 'power':
540 linearObj.setXYData(x,abs(y),"real")
549 linearObj.setXYData(x,abs(y),"real")
541 if type.lower() == 'iq':
550 if type.lower() == 'iq':
542 linearObj.setXYData(x,y,"complex")
551 linearObj.setXYData(x,y,"complex")
543
552
553 if type.lower() == 'simple':
554 colline = 9
555 linearObj.basicLineTimePlot(x, y, xmin, xmax, ymin, ymax, colline)
556 linearObj.setXYData(x,y,"real")
557
544 if type.lower() == 'power':
558 if type.lower() == 'power':
545 colline = 9
559 colline = 9
546 linearObj.basicLineTimePlot(x, abs(y), xmin, xmax, ymin, ymax, colline)
560 linearObj.basicLineTimePlot(x, abs(y), xmin, xmax, ymin, ymax, colline)
547 linearObj.setXYData(x,abs(y),"real")
561 linearObj.setXYData(x,abs(y),"real")
548
562
549 if type.lower() == 'iq':
563 if type.lower() == 'iq':
550 colline = 9
564 colline = 9
551 linearObj.basicLineTimePlot(x=x, y=y.real, colline=colline)
565 linearObj.basicLineTimePlot(x=x, y=y.real, colline=colline)
552 colline = 13
566 colline = 13
553 linearObj.basicLineTimePlot(x=x, y=y.imag, colline=colline)
567 linearObj.basicLineTimePlot(x=x, y=y.imag, colline=colline)
554
568
555 linearObj.setXYData(x,y,"complex")
569 linearObj.setXYData(x,y,"complex")
556
570
557 linearObj.plotBox(linearObj.xrange[0], linearObj.xrange[1], linearObj.yrange[0], linearObj.yrange[1], "bcst", "bcst")
571 linearObj.plotBox(linearObj.xrange[0], linearObj.xrange[1], linearObj.yrange[0], linearObj.yrange[1], "bcst", "bcst")
558
572
559
573
560 # linearObj.plotBox(linearObj.xrange[0], linearObj.xrange[1], linearObj.yrange[0], linearObj.yrange[1], "bc", "bc")
574 # linearObj.plotBox(linearObj.xrange[0], linearObj.xrange[1], linearObj.yrange[0], linearObj.yrange[1], "bc", "bc")
561 # linearObj.basicXYPlot(data,y)
575 # linearObj.basicXYPlot(data,y)
562 # linearObj.setXYData(data,y)
576 # linearObj.setXYData(data,y)
563
577
564
578
565
579
566 class PcolorPlot:
580 class PcolorPlot:
567 pcolorObjDic = {}
581 pcolorObjDic = {}
568 colorbarObjDic = {}
582 colorbarObjDic = {}
569 pwprofileObjDic = {}
583 pwprofileObjDic = {}
570 showColorbar = None
584 showColorbar = None
571 showPowerProfile = None
585 showPowerProfile = None
572 XAxisAsTime = None
586 XAxisAsTime = None
573 width = None
587 width = None
574 height = None
588 height = None
575 __spcxpos = None
589 __spcxpos = None
576 __spcypos = None
590 __spcypos = None
577 __cmapxpos = None
591 __cmapxpos = None
578 __cmapypos = None
592 __cmapypos = None
579 __profxpos = None
593 __profxpos = None
580 __profypos = None
594 __profypos = None
581 __lastTitle = None
595 __lastTitle = None
582
596
583 def __init__(self,indexPlot,nsubplot,winTitle,colormap,showColorbar,showPowerProfile,XAxisAsTime):
597 def __init__(self,indexPlot,nsubplot,winTitle,colormap,showColorbar,showPowerProfile,XAxisAsTime):
584 self.width = 460
598 self.width = 460
585 self.height = 300
599 self.height = 300
586 self.showColorbar = showColorbar
600 self.showColorbar = showColorbar
587 self.showPowerProfile = showPowerProfile
601 self.showPowerProfile = showPowerProfile
588 self.XAxisAsTime = XAxisAsTime
602 self.XAxisAsTime = XAxisAsTime
589
603
590
604
591 ncol = int(numpy.sqrt(nsubplot)+0.9)
605 ncol = int(numpy.sqrt(nsubplot)+0.9)
592 nrow = int(nsubplot*1./ncol + 0.9)
606 nrow = int(nsubplot*1./ncol + 0.9)
593
607
594 initPlplot(indexPlot,ncol,nrow,winTitle,self.width,self.height)
608 initPlplot(indexPlot,ncol,nrow,winTitle,self.width,self.height)
595 setColormap(colormap)
609 setColormap(colormap)
596 self.ncol = ncol
610 self.ncol = ncol
597 self.nrow = nrow
611 self.nrow = nrow
598
612
599 def setFigure(self,indexPlot):
613 def setFigure(self,indexPlot):
600 setStrm(indexPlot)
614 setStrm(indexPlot)
601
615
602 def setSpectraPos(self): #modificar valores de acuerdo al colorbar y pwprofile
616 def setSpectraPos(self): #modificar valores de acuerdo al colorbar y pwprofile
603 if self.showPowerProfile: xi = 0.09; xf = 0.6 #0.075
617 if self.showPowerProfile: xi = 0.09; xf = 0.6 #0.075
604 else: xi = 0.15; xf = 0.8 #0.8,0.7,0.5
618 else: xi = 0.15; xf = 0.8 #0.8,0.7,0.5
605 yi = 0.15; yf = 0.80
619 yi = 0.15; yf = 0.80
606
620
607 xpos = [xi,xf]
621 xpos = [xi,xf]
608 ypos = [yi,yf]
622 ypos = [yi,yf]
609
623
610 self.__spcxpos = xpos
624 self.__spcxpos = xpos
611 self.__spcypos = ypos
625 self.__spcypos = ypos
612
626
613 return xpos,ypos
627 return xpos,ypos
614
628
615 def setColorbarScreenPos(self):
629 def setColorbarScreenPos(self):
616
630
617 xi = self.__spcxpos[1] + 0.03; xf = xi + 0.03
631 xi = self.__spcxpos[1] + 0.03; xf = xi + 0.03
618 yi = self.__spcypos[0]; yf = self.__spcypos[1]
632 yi = self.__spcypos[0]; yf = self.__spcypos[1]
619
633
620 xpos = [xi,xf]
634 xpos = [xi,xf]
621 ypos = [yi,yf]
635 ypos = [yi,yf]
622
636
623 self.__cmapxpos = xpos
637 self.__cmapxpos = xpos
624 self.__cmapypos = ypos
638 self.__cmapypos = ypos
625
639
626 return xpos,ypos
640 return xpos,ypos
627
641
628 def setPowerprofileScreenPos(self):
642 def setPowerprofileScreenPos(self):
629
643
630 xi = self.__cmapxpos[1] + 0.07; xf = xi + 0.25
644 xi = self.__cmapxpos[1] + 0.07; xf = xi + 0.25
631 yi = self.__spcypos[0]; yf = self.__spcypos[1]
645 yi = self.__spcypos[0]; yf = self.__spcypos[1]
632
646
633 xpos = [xi,xf]
647 xpos = [xi,xf]
634 ypos = [yi,yf]
648 ypos = [yi,yf]
635
649
636 self.__profxpos = [xi,xf]
650 self.__profxpos = [xi,xf]
637 self.__profypos = [yi,yf]
651 self.__profypos = [yi,yf]
638
652
639 return xpos,ypos
653 return xpos,ypos
640
654
641 def createObjects(self,subplot,xmin,xmax,ymin,ymax,zmin,zmax,title,xlabel,ylabel):
655 def createObjects(self,subplot,xmin,xmax,ymin,ymax,zmin,zmax,title,xlabel,ylabel):
642 """
656 """
643 Crea los objetos necesarios para un subplot
657 Crea los objetos necesarios para un subplot
644 """
658 """
645
659
646 # Config Spectra plot
660 # Config Spectra plot
647
661
648 szchar = 0.7
662 szchar = 0.7
649 name = "spc"
663 name = "spc"
650 key = name + "%d"%subplot
664 key = name + "%d"%subplot
651 xrange = [xmin,xmax]
665 xrange = [xmin,xmax]
652 yrange = [ymin,ymax]
666 yrange = [ymin,ymax]
653 zrange = [zmin,zmax]
667 zrange = [zmin,zmax]
654
668
655 xpos,ypos = self.setSpectraPos()
669 xpos,ypos = self.setSpectraPos()
656 pcolorObj = BaseGraph(name,subplot,xpos,ypos,xlabel,ylabel,title,szchar,xrange,yrange,zrange)
670 pcolorObj = BaseGraph(name,subplot,xpos,ypos,xlabel,ylabel,title,szchar,xrange,yrange,zrange)
657 self.pcolorObjDic[key] = pcolorObj
671 self.pcolorObjDic[key] = pcolorObj
658
672
659 # Config Colorbar
673 # Config Colorbar
660 if self.showColorbar:
674 if self.showColorbar:
661 szchar = 0.65
675 szchar = 0.65
662 name = "colorbar"
676 name = "colorbar"
663 key = name + "%d"%subplot
677 key = name + "%d"%subplot
664
678
665 xpos,ypos = self.setColorbarScreenPos()
679 xpos,ypos = self.setColorbarScreenPos()
666 xrange = [0.,1.]
680 xrange = [0.,1.]
667 yrange = [zmin,zmax]
681 yrange = [zmin,zmax]
668 cmapObj = BaseGraph(name,subplot,xpos,ypos,"","","dB",szchar,xrange,yrange)
682 cmapObj = BaseGraph(name,subplot,xpos,ypos,"","","dB",szchar,xrange,yrange)
669 self.colorbarObjDic[key] = cmapObj
683 self.colorbarObjDic[key] = cmapObj
670
684
671 # Config Power profile
685 # Config Power profile
672 if self.showPowerProfile:
686 if self.showPowerProfile:
673 szchar = 0.55
687 szchar = 0.55
674 name = "pwprofile"
688 name = "pwprofile"
675 key = name + "%d"%subplot
689 key = name + "%d"%subplot
676
690
677 xpos,ypos = self.setPowerprofileScreenPos()
691 xpos,ypos = self.setPowerprofileScreenPos()
678 xrange = [zmin,zmax]
692 xrange = [zmin,zmax]
679 yrange = [ymin,ymax]
693 yrange = [ymin,ymax]
680 powObj = BaseGraph(name,subplot,xpos,ypos,"dB","","Power Profile",szchar,xrange,yrange)
694 powObj = BaseGraph(name,subplot,xpos,ypos,"dB","","Power Profile",szchar,xrange,yrange)
681 self.pwprofileObjDic[key] = powObj
695 self.pwprofileObjDic[key] = powObj
682
696
683 def setNewPage(self, pltitle='No title'):
697 def setNewPage(self, pltitle='No title'):
684 szchar = 0.7
698 szchar = 0.7
685 setNewPage()
699 setNewPage()
686 setPlTitle(pltitle,"black", szchar=szchar)
700 setPlTitle(pltitle,"black", szchar=szchar)
687 setSubpages(self.ncol, self.nrow)
701 setSubpages(self.ncol, self.nrow)
688
702
689 def closePage(self):
703 def closePage(self):
690 closePage()
704 closePage()
691
705
692 def iniPlot(self,subplot):
706 def iniPlot(self,subplot):
693 """
707 """
694 Inicializa los subplots con su frame, titulo, etc
708 Inicializa los subplots con su frame, titulo, etc
695 """
709 """
696
710
697 # Config Spectra plot
711 # Config Spectra plot
698 name = "spc"
712 name = "spc"
699 key = name + "%d"%subplot
713 key = name + "%d"%subplot
700
714
701 pcolorObj = self.pcolorObjDic[key]
715 pcolorObj = self.pcolorObjDic[key]
702 pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], "bcnst", "bcnstv")
716 pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], "bcnst", "bcnstv")
703
717
704 # Config Colorbar
718 # Config Colorbar
705 if self.showColorbar:
719 if self.showColorbar:
706 name = "colorbar"
720 name = "colorbar"
707 key = name + "%d"%subplot
721 key = name + "%d"%subplot
708
722
709 cmapObj = self.colorbarObjDic[key]
723 cmapObj = self.colorbarObjDic[key]
710 cmapObj.plotBox(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1], "bc", "bcmtsv")
724 cmapObj.plotBox(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1], "bc", "bcmtsv")
711 cmapObj.colorbarPlot(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1])
725 cmapObj.colorbarPlot(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1])
712 # cmapObj.plotBox(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1], "bc", "bcmtsv")
726 # cmapObj.plotBox(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1], "bc", "bcmtsv")
713
727
714 # Config Power profile
728 # Config Power profile
715 if self.showPowerProfile:
729 if self.showPowerProfile:
716 name = "pwprofile"
730 name = "pwprofile"
717 key = name + "%d"%subplot
731 key = name + "%d"%subplot
718
732
719 powObj = self.pwprofileObjDic[key]
733 powObj = self.pwprofileObjDic[key]
720 powObj.setLineStyle(2)
734 powObj.setLineStyle(2)
721 powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bcntg", "bc")
735 powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bcntg", "bc")
722 powObj.setLineStyle(1)
736 powObj.setLineStyle(1)
723 powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bc", "bc")
737 powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bc", "bc")
724
738
725 def printTitle(self,pltitle):
739 def printTitle(self,pltitle):
726 # if self.__lastTitle != None:
740 # if self.__lastTitle != None:
727 # setPlTitle(self.__lastTitle,"white")
741 # setPlTitle(self.__lastTitle,"white")
728 #
742 #
729 # self.__lastTitle = pltitle
743 # self.__lastTitle = pltitle
730
744
731 setPlTitle(pltitle,"black")
745 setPlTitle(pltitle,"black")
732
746
733 # setSubpages(self.ncol,self.nrow)
747 # setSubpages(self.ncol,self.nrow)
734
748
735 def plot(self,subplot,x,y,z,subtitle):
749 def plot(self,subplot,x,y,z,subtitle):
736 # Spectra plot
750 # Spectra plot
737
751
738 name = "spc"
752 name = "spc"
739 key = name + "%d"%subplot
753 key = name + "%d"%subplot
740
754
741 # newx = [x[0],x[-1]]
755 # newx = [x[0],x[-1]]
742 pcolorObj = self.pcolorObjDic[key]
756 pcolorObj = self.pcolorObjDic[key]
743
757
744 pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], "bcst", "bcst")
758 pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], "bcst", "bcst")
745
759
746 #pcolorObj.delLabels()
760 #pcolorObj.delLabels()
747 pcolorObj.setLabels(title=subtitle)
761 pcolorObj.setLabels(title=subtitle)
748
762
749 deltax = None; deltay = None
763 deltax = None; deltay = None
750
764
751 pcolorObj.advPcolorPlot(z,
765 pcolorObj.advPcolorPlot(z,
752 x,
766 x,
753 y,
767 y,
754 xmin=pcolorObj.xrange[0],
768 xmin=pcolorObj.xrange[0],
755 xmax=pcolorObj.xrange[1],
769 xmax=pcolorObj.xrange[1],
756 ymin=pcolorObj.yrange[0],
770 ymin=pcolorObj.yrange[0],
757 ymax=pcolorObj.yrange[1],
771 ymax=pcolorObj.yrange[1],
758 zmin=pcolorObj.zrange[0],
772 zmin=pcolorObj.zrange[0],
759 zmax=pcolorObj.zrange[1],
773 zmax=pcolorObj.zrange[1],
760 deltax=deltax,
774 deltax=deltax,
761 deltay=deltay,
775 deltay=deltay,
762 getGrid=pcolorObj.getGrid)
776 getGrid=pcolorObj.getGrid)
763
777
764 #Solo se calcula la primera vez que se ingresa a la funcion
778 #Solo se calcula la primera vez que se ingresa a la funcion
765 pcolorObj.getGrid = False
779 pcolorObj.getGrid = False
766
780
767 pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], "bcst", "bcst", nolabels=True)
781 pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], "bcst", "bcst", nolabels=True)
768
782
769 # Power Profile
783 # Power Profile
770 if self.showPowerProfile:
784 if self.showPowerProfile:
771 power = numpy.average(z, axis=0)
785 power = numpy.average(z, axis=0)
772 name = "pwprofile"
786 name = "pwprofile"
773 key = name + "%d"%subplot
787 key = name + "%d"%subplot
774 powObj = self.pwprofileObjDic[key]
788 powObj = self.pwprofileObjDic[key]
775
789
776 if powObj.setXYData() != None:
790 if powObj.setXYData() != None:
777 #clearData(powObj)
791 #clearData(powObj)
778 powObj.setLineStyle(2)
792 powObj.setLineStyle(2)
779 powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bcntg", "bc")
793 powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bcntg", "bc")
780 powObj.setLineStyle(1)
794 powObj.setLineStyle(1)
781 else:
795 else:
782 powObj.setXYData(power,y)
796 powObj.setXYData(power,y)
783
797
784 powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bc", "bc")
798 powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bc", "bc")
785 powObj.basicXYPlot(power,y)
799 powObj.basicXYPlot(power,y)
786 powObj.setXYData(power,y)
800 powObj.setXYData(power,y)
787
801
788 def savePlot(self,indexPlot,filename):
802 def savePlot(self,indexPlot,filename):
789
803
790 width = self.width*self.ncol
804 width = self.width*self.ncol
791 hei = self.height*self.nrow
805 hei = self.height*self.nrow
792 savePlplot(filename,width,hei)
806 savePlplot(filename,width,hei)
793
807
794 def refresh(self):
808 def refresh(self):
795 plFlush()
809 plFlush()
796
810
797 class RtiPlot:
811 class RtiPlot:
798
812
799 pcolorObjDic = {}
813 pcolorObjDic = {}
800 colorbarObjDic = {}
814 colorbarObjDic = {}
801 pwprofileObjDic = {}
815 pwprofileObjDic = {}
802 showColorbar = None
816 showColorbar = None
803 showPowerProfile = None
817 showPowerProfile = None
804 XAxisAsTime = None
818 XAxisAsTime = None
805 widht = None
819 widht = None
806 height = None
820 height = None
807 __rtixpos = None
821 __rtixpos = None
808 __rtiypos = None
822 __rtiypos = None
809 __cmapxpos = None
823 __cmapxpos = None
810 __cmapypos = None
824 __cmapypos = None
811 __profxpos = None
825 __profxpos = None
812 __profypos = None
826 __profypos = None
813
827
814 def __init__(self,indexPlot,nsubplot,winTitle,colormap,showColorbar,showPowerProfile,XAxisAsTime):
828 def __init__(self,indexPlot,nsubplot,winTitle,colormap,showColorbar,showPowerProfile,XAxisAsTime):
815 self.width = 700
829 self.width = 700
816 self.height = 150
830 self.height = 150
817 self.showColorbar = showColorbar
831 self.showColorbar = showColorbar
818 self.showPowerProfile = showPowerProfile
832 self.showPowerProfile = showPowerProfile
819 self.XAxisAsTime = XAxisAsTime
833 self.XAxisAsTime = XAxisAsTime
820
834
821 ncol = 1
835 ncol = 1
822 nrow = nsubplot
836 nrow = nsubplot
823 initPlplot(indexPlot,ncol,nrow,winTitle,self.width,self.height)
837 initPlplot(indexPlot,ncol,nrow,winTitle,self.width,self.height)
824 setColormap(colormap)
838 setColormap(colormap)
825 self.ncol = ncol
839 self.ncol = ncol
826 self.nrow = nrow
840 self.nrow = nrow
827
841
828 def setFigure(self,indexPlot):
842 def setFigure(self,indexPlot):
829 setStrm(indexPlot)
843 setStrm(indexPlot)
830
844
831 def setRtiScreenPos(self):
845 def setRtiScreenPos(self):
832
846
833 if self.showPowerProfile: xi = 0.07; xf = 0.65
847 if self.showPowerProfile: xi = 0.07; xf = 0.65
834 else: xi = 0.07; xf = 0.9
848 else: xi = 0.07; xf = 0.9
835 yi = 0.15; yf = 0.80
849 yi = 0.15; yf = 0.80
836
850
837 xpos = [xi,xf]
851 xpos = [xi,xf]
838 ypos = [yi,yf]
852 ypos = [yi,yf]
839
853
840 self.__rtixpos = xpos
854 self.__rtixpos = xpos
841 self.__rtiypos = ypos
855 self.__rtiypos = ypos
842
856
843 return xpos,ypos
857 return xpos,ypos
844
858
845 def setColorbarScreenPos(self):
859 def setColorbarScreenPos(self):
846
860
847 xi = self.__rtixpos[1] + 0.03; xf = xi + 0.03
861 xi = self.__rtixpos[1] + 0.03; xf = xi + 0.03
848
862
849 yi = self.__rtiypos[0]; yf = self.__rtiypos[1]
863 yi = self.__rtiypos[0]; yf = self.__rtiypos[1]
850
864
851 xpos = [xi,xf]
865 xpos = [xi,xf]
852 ypos = [yi,yf]
866 ypos = [yi,yf]
853
867
854 self.__cmapxpos = xpos
868 self.__cmapxpos = xpos
855 self.__cmapypos = ypos
869 self.__cmapypos = ypos
856
870
857 return xpos,ypos
871 return xpos,ypos
858
872
859 def setPowerprofileScreenPos(self):
873 def setPowerprofileScreenPos(self):
860
874
861 xi = self.__cmapxpos[1] + 0.05; xf = xi + 0.20
875 xi = self.__cmapxpos[1] + 0.05; xf = xi + 0.20
862
876
863 yi = self.__rtiypos[0]; yf = self.__rtiypos[1]
877 yi = self.__rtiypos[0]; yf = self.__rtiypos[1]
864
878
865 xpos = [xi,xf]
879 xpos = [xi,xf]
866 ypos = [yi,yf]
880 ypos = [yi,yf]
867
881
868 self.__profxpos = [xi,xf]
882 self.__profxpos = [xi,xf]
869 self.__profypos = [yi,yf]
883 self.__profypos = [yi,yf]
870
884
871 return xpos,ypos
885 return xpos,ypos
872
886
873 def setup(self,subplot,xmin,xmax,ymin,ymax,zmin,zmax,title,xlabel,ylabel,timedata,timezone="lt",npoints=100):
887 def setup(self,subplot,xmin,xmax,ymin,ymax,zmin,zmax,title,xlabel,ylabel,timedata,timezone="lt",npoints=100):
874 # Config Rti plot
888 # Config Rti plot
875 szchar = 1.10
889 szchar = 1.10
876 name = "rti"
890 name = "rti"
877 key = name + "%d"%subplot
891 key = name + "%d"%subplot
878
892
879 # xmin, xmax --> minHour, max Hour : valores que definen el ejex x=[horaInicio,horaFinal]
893 # xmin, xmax --> minHour, max Hour : valores que definen el ejex x=[horaInicio,horaFinal]
880 thisDateTime = datetime.datetime.fromtimestamp(timedata)
894 thisDateTime = datetime.datetime.fromtimestamp(timedata)
881 startDateTime = datetime.datetime(thisDateTime.year,thisDateTime.month,thisDateTime.day,xmin,0,0)
895 startDateTime = datetime.datetime(thisDateTime.year,thisDateTime.month,thisDateTime.day,xmin,0,0)
882 endDateTime = datetime.datetime(thisDateTime.year,thisDateTime.month,thisDateTime.day,xmax,59,59)
896 endDateTime = datetime.datetime(thisDateTime.year,thisDateTime.month,thisDateTime.day,xmax,59,59)
883 deltaTime = 0
897 deltaTime = 0
884 if timezone == "lt":
898 if timezone == "lt":
885 deltaTime = time.timezone
899 deltaTime = time.timezone
886 startTimeInSecs = time.mktime(startDateTime.timetuple()) - deltaTime
900 startTimeInSecs = time.mktime(startDateTime.timetuple()) - deltaTime
887 endTimeInSecs = time.mktime(endDateTime.timetuple()) - deltaTime
901 endTimeInSecs = time.mktime(endDateTime.timetuple()) - deltaTime
888
902
889 xrange = [startTimeInSecs,endTimeInSecs]
903 xrange = [startTimeInSecs,endTimeInSecs]
890 totalTimeInXrange = endTimeInSecs - startTimeInSecs + 1.
904 totalTimeInXrange = endTimeInSecs - startTimeInSecs + 1.
891 deltax = totalTimeInXrange / npoints
905 deltax = totalTimeInXrange / npoints
892
906
893 yrange = [ymin,ymax]
907 yrange = [ymin,ymax]
894 zrange = [zmin,zmax]
908 zrange = [zmin,zmax]
895
909
896 xpos,ypos = self.setRtiScreenPos()
910 xpos,ypos = self.setRtiScreenPos()
897 pcolorObj = BaseGraph(name,subplot,xpos,ypos,xlabel,ylabel,title,szchar,xrange,yrange,zrange,deltax)
911 pcolorObj = BaseGraph(name,subplot,xpos,ypos,xlabel,ylabel,title,szchar,xrange,yrange,zrange,deltax)
898 if self.XAxisAsTime:
912 if self.XAxisAsTime:
899 pcolorObj.setXAxisAsTime(self.XAxisAsTime)
913 pcolorObj.setXAxisAsTime(self.XAxisAsTime)
900 xopt = "bcnstd"
914 xopt = "bcnstd"
901 yopt = "bcnstv"
915 yopt = "bcnstv"
902 else:
916 else:
903 xopt = "bcnst"
917 xopt = "bcnst"
904 yopt = "bcnstv"
918 yopt = "bcnstv"
905
919
906 pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], xopt, yopt)
920 pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], xopt, yopt)
907 self.pcolorObjDic[key] = pcolorObj
921 self.pcolorObjDic[key] = pcolorObj
908
922
909
923
910 # Config Colorbar
924 # Config Colorbar
911 if self.showColorbar:
925 if self.showColorbar:
912 szchar = 0.9
926 szchar = 0.9
913 name = "colorbar"
927 name = "colorbar"
914 key = name + "%d"%subplot
928 key = name + "%d"%subplot
915
929
916 xpos,ypos = self.setColorbarScreenPos()
930 xpos,ypos = self.setColorbarScreenPos()
917 xrange = [0.,1.]
931 xrange = [0.,1.]
918 yrange = [zmin,zmax]
932 yrange = [zmin,zmax]
919 cmapObj = BaseGraph(name,subplot,xpos,ypos,"","","dB",szchar,xrange,yrange)
933 cmapObj = BaseGraph(name,subplot,xpos,ypos,"","","dB",szchar,xrange,yrange)
920 cmapObj.plotBox(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1], "bc", "bcm")
934 cmapObj.plotBox(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1], "bc", "bcm")
921 cmapObj.colorbarPlot(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1])
935 cmapObj.colorbarPlot(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1])
922 cmapObj.plotBox(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1], "bc", "bcmtsv")
936 cmapObj.plotBox(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1], "bc", "bcmtsv")
923 self.colorbarObjDic[key] = cmapObj
937 self.colorbarObjDic[key] = cmapObj
924
938
925
939
926 # Config Power profile
940 # Config Power profile
927 if self.showPowerProfile:
941 if self.showPowerProfile:
928 szchar = 0.8
942 szchar = 0.8
929 name = "pwprofile"
943 name = "pwprofile"
930 key = name + "%d"%subplot
944 key = name + "%d"%subplot
931
945
932 xpos,ypos = self.setPowerprofileScreenPos()
946 xpos,ypos = self.setPowerprofileScreenPos()
933 xrange = [zmin,zmax]
947 xrange = [zmin,zmax]
934 yrange = [ymin,ymax]
948 yrange = [ymin,ymax]
935 powObj = BaseGraph(name,subplot,xpos,ypos,"dB","","Power Profile",szchar,xrange,yrange)
949 powObj = BaseGraph(name,subplot,xpos,ypos,"dB","","Power Profile",szchar,xrange,yrange)
936 powObj.setLineStyle(2)
950 powObj.setLineStyle(2)
937 powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bcntg", "bc")
951 powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bcntg", "bc")
938 powObj.setLineStyle(1)
952 powObj.setLineStyle(1)
939 powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bc", "bc")
953 powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bc", "bc")
940 self.pwprofileObjDic[key] = powObj
954 self.pwprofileObjDic[key] = powObj
941
955
942
956
943 def plot(self,subplot,x,y,z):
957 def plot(self,subplot,x,y,z):
944 # RTI plot
958 # RTI plot
945 name = "rti"
959 name = "rti"
946 key = name + "%d"%subplot
960 key = name + "%d"%subplot
947
961
948 data = numpy.reshape(z, (1,-1))
962 data = numpy.reshape(z, (1,-1))
949 data = numpy.abs(data)
963 data = numpy.abs(data)
950 data = 10*numpy.log10(data)
964 data = 10*numpy.log10(data)
951 newx = [x,x+1]
965 newx = [x,x+1]
952
966
953 pcolorObj = self.pcolorObjDic[key]
967 pcolorObj = self.pcolorObjDic[key]
954
968
955 if pcolorObj.xaxisIsTime:
969 if pcolorObj.xaxisIsTime:
956 xopt = "bcstd"
970 xopt = "bcstd"
957 yopt = "bcst"
971 yopt = "bcst"
958 else:
972 else:
959 xopt = "bcst"
973 xopt = "bcst"
960 yopt = "bcst"
974 yopt = "bcst"
961
975
962 pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], xopt, yopt)
976 pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], xopt, yopt)
963
977
964 deltax = pcolorObj.deltax
978 deltax = pcolorObj.deltax
965 deltay = None
979 deltay = None
966
980
967 if pcolorObj.xmin == None and pcolorObj.xmax == None:
981 if pcolorObj.xmin == None and pcolorObj.xmax == None:
968 pcolorObj.xmin = x
982 pcolorObj.xmin = x
969 pcolorObj.xmax = x
983 pcolorObj.xmax = x
970
984
971 if x >= pcolorObj.xmax:
985 if x >= pcolorObj.xmax:
972 xmin = x
986 xmin = x
973 xmax = x + deltax
987 xmax = x + deltax
974 x = [x]
988 x = [x]
975 pcolorObj.advPcolorPlot(data,
989 pcolorObj.advPcolorPlot(data,
976 x,
990 x,
977 y,
991 y,
978 xmin=xmin,
992 xmin=xmin,
979 xmax=xmax,
993 xmax=xmax,
980 ymin=pcolorObj.yrange[0],
994 ymin=pcolorObj.yrange[0],
981 ymax=pcolorObj.yrange[1],
995 ymax=pcolorObj.yrange[1],
982 zmin=pcolorObj.zrange[0],
996 zmin=pcolorObj.zrange[0],
983 zmax=pcolorObj.zrange[1],
997 zmax=pcolorObj.zrange[1],
984 deltax=deltax,
998 deltax=deltax,
985 deltay=deltay,
999 deltay=deltay,
986 getGrid=pcolorObj.getGrid)
1000 getGrid=pcolorObj.getGrid)
987
1001
988 pcolorObj.xmin = xmin
1002 pcolorObj.xmin = xmin
989 pcolorObj.xmax = xmax
1003 pcolorObj.xmax = xmax
990
1004
991
1005
992 # Power Profile
1006 # Power Profile
993 if self.showPowerProfile:
1007 if self.showPowerProfile:
994 data = numpy.reshape(data,(numpy.size(data)))
1008 data = numpy.reshape(data,(numpy.size(data)))
995 name = "pwprofile"
1009 name = "pwprofile"
996 key = name + "%d"%subplot
1010 key = name + "%d"%subplot
997 powObj = self.pwprofileObjDic[key]
1011 powObj = self.pwprofileObjDic[key]
998
1012
999 if powObj.setXYData() != None:
1013 if powObj.setXYData() != None:
1000 clearData(powObj)
1014 clearData(powObj)
1001 powObj.setLineStyle(2)
1015 powObj.setLineStyle(2)
1002 powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bcntg", "bc")
1016 powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bcntg", "bc")
1003 powObj.setLineStyle(1)
1017 powObj.setLineStyle(1)
1004 else:
1018 else:
1005 powObj.setXYData(data,y)
1019 powObj.setXYData(data,y)
1006
1020
1007 powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bc", "bc")
1021 powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bc", "bc")
1008 powObj.basicXYPlot(data,y)
1022 powObj.basicXYPlot(data,y)
1009 powObj.setXYData(data,y)
1023 powObj.setXYData(data,y)
1010
1024
1011 def savePlot(self,indexPlot,filename):
1025 def savePlot(self,indexPlot,filename):
1012
1026
1013 width = self.width*self.ncol
1027 width = self.width*self.ncol
1014 hei = self.height*self.nrow
1028 hei = self.height*self.nrow
1015 savePlplot(filename,width,hei)
1029 savePlplot(filename,width,hei)
1016
1030
1017 def refresh(self):
1031 def refresh(self):
1018 plFlush() No newline at end of file
1032 plFlush()
1033
1034 if __name__ == '__main__':
1035
1036 #Setting the signal
1037 fs = 8000
1038 f0 = 200
1039 f1 = 400
1040 T = 1./fs
1041 x = numpy.arange(160)
1042 y1 = numpy.sin(2*numpy.pi*f0*x*T)
1043 y2 = numpy.sin(2*numpy.pi*f1*x*T)
1044 signalList = [y1,y2]
1045
1046 xmin = numpy.min(x)
1047 xmax = numpy.max(x)
1048 ymin = numpy.min(y1)
1049 ymax = numpy.max(y1)
1050
1051 # Creating Object
1052 indexPlot = 1
1053 nsubplot = 2
1054 winTitle = "mi grafico v1"
1055
1056 subplotTitle = "subplot - No."
1057 xlabel = ""
1058 ylabel = ""
1059
1060 linearObj = LinearPlot(indexPlot,nsubplot,winTitle)
1061
1062 #Config SubPlots
1063 for subplot in range(nsubplot):
1064 indexplot = subplot + 1
1065 title = subplotTitle + '%d'%indexplot
1066 linearObj.setup(indexplot, xmin, xmax, ymin, ymax, title, xlabel, ylabel)
1067
1068 #Plotting
1069 type = "simple"
1070 for subplot in range(nsubplot):
1071 indexplot = subplot + 1
1072 y = signalList[subplot]
1073 linearObj.plot(indexplot, x, y, type)
1074
1075 linearObj.refresh()
1076 linearObj.show()
1077
1078 print "end" No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now