##// END OF EJS Templates
Se agrega codigo para refresco de datos en ploteo de perfiles en Spectra Plot
Daniel Valdez -
r109:e0bd0a5e21f6
parent child
Show More
@@ -1,938 +1,941
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
8
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 initPlplot(indexPlot,ncol,nrow,winTitle,width,height):
194 def initPlplot(indexPlot,ncol,nrow,winTitle,width,height):
195 plplot.plsstrm(indexPlot)
195 plplot.plsstrm(indexPlot)
196 plplot.plparseopts([winTitle],plplot.PL_PARSE_FULL)
196 plplot.plparseopts([winTitle],plplot.PL_PARSE_FULL)
197 plplot.plsetopt("geometry", "%dx%d"%(width*ncol,height*nrow))
197 plplot.plsetopt("geometry", "%dx%d"%(width*ncol,height*nrow))
198 plplot.plsdev("xwin")
198 plplot.plsdev("xwin")
199 plplot.plscolbg(255,255,255)
199 plplot.plscolbg(255,255,255)
200 plplot.plscol0(1,0,0,0)
200 plplot.plscol0(1,0,0,0)
201 plplot.plinit()
201 plplot.plinit()
202 plplot.plspause(False)
202 plplot.plspause(False)
203 plplot.plssub(ncol,nrow)
203 plplot.plssub(ncol,nrow)
204
204
205 def clearData(objGraph):
205 def clearData(objGraph):
206 objGraph.plotBox(objGraph.xrange[0], objGraph.xrange[1], objGraph.yrange[0], objGraph.yrange[1], "bc", "bc")
206 objGraph.plotBox(objGraph.xrange[0], objGraph.xrange[1], objGraph.yrange[0], objGraph.yrange[1], "bc", "bc")
207
207
208 objGraph.setColor(15) #Setting Line Color to White
208 objGraph.setColor(15) #Setting Line Color to White
209
209
210 if objGraph.datatype == "complex":
210 if objGraph.datatype == "complex":
211 objGraph.basicXYPlot(objGraph.xdata,objGraph.ydata.real)
211 objGraph.basicXYPlot(objGraph.xdata,objGraph.ydata.real)
212 objGraph.basicXYPlot(objGraph.xdata,objGraph.ydata.imag)
212 objGraph.basicXYPlot(objGraph.xdata,objGraph.ydata.imag)
213
213
214 if objGraph.datatype == "real":
214 if objGraph.datatype == "real":
215 objGraph.basicXYPlot(objGraph.xdata,objGraph.ydata)
215 objGraph.basicXYPlot(objGraph.xdata,objGraph.ydata)
216
216
217 objGraph.setColor(1) #Setting Line Color to Black
217 objGraph.setColor(1) #Setting Line Color to Black
218 # objGraph.setLineStyle(2)
218 # objGraph.setLineStyle(2)
219 # objGraph.plotBox(objGraph.xrange[0], objGraph.xrange[1], objGraph.yrange[0], objGraph.yrange[1], "bcntg", "bc")
219 # objGraph.plotBox(objGraph.xrange[0], objGraph.xrange[1], objGraph.yrange[0], objGraph.yrange[1], "bcntg", "bc")
220 # objGraph.setLineStyle(1)
220 # objGraph.setLineStyle(1)
221
221
222 def setStrm(indexPlot):
222 def setStrm(indexPlot):
223 plplot.plsstrm(indexPlot)
223 plplot.plsstrm(indexPlot)
224
224
225 def plFlush():
225 def plFlush():
226 plplot.plflush()
226 plplot.plflush()
227
227
228 def setPlTitle(pltitle,color):
228 def setPlTitle(pltitle,color):
229 setSubpages(1, 0)
229 setSubpages(1, 0)
230 plplot.pladv(0)
230 plplot.pladv(0)
231 plplot.plvpor(0., 1., 0., 1.)
231 plplot.plvpor(0., 1., 0., 1.)
232
232
233 if color == "black":
233 if color == "black":
234 plplot.plcol0(1)
234 plplot.plcol0(1)
235 if color == "white":
235 if color == "white":
236 plplot.plcol0(15)
236 plplot.plcol0(15)
237
237
238 plplot.plmtex("t",-1., 0.5, 0.5, pltitle)
238 plplot.plmtex("t",-1., 0.5, 0.5, pltitle)
239
239
240 def setSubpages(ncol,nrow):
240 def setSubpages(ncol,nrow):
241 plplot.plssub(ncol,nrow)
241 plplot.plssub(ncol,nrow)
242
242
243 class BaseGraph:
243 class BaseGraph:
244 __name = None
244 __name = None
245 __xpos = None
245 __xpos = None
246 __ypos = None
246 __ypos = None
247 __subplot = None
247 __subplot = None
248 __xg = None
248 __xg = None
249 __yg = None
249 __yg = None
250 xdata = None
250 xdata = None
251 ydata = None
251 ydata = None
252 getGrid = True
252 getGrid = True
253 xaxisIsTime = False
253 xaxisIsTime = False
254 deltax = None
254 deltax = None
255 xmin = None
255 xmin = None
256 xmax = None
256 xmax = None
257 def __init__(self,name,subplot,xpos,ypos,xlabel,ylabel,title,szchar,xrange,yrange,zrange=None,deltax=1.0):
257 def __init__(self,name,subplot,xpos,ypos,xlabel,ylabel,title,szchar,xrange,yrange,zrange=None,deltax=1.0):
258 self.setName(name)
258 self.setName(name)
259 self.setScreenPos(xpos, ypos)
259 self.setScreenPos(xpos, ypos)
260 self.setLabels(xlabel,ylabel,title)
260 self.setLabels(xlabel,ylabel,title)
261 self.setSubPlot(subplot)
261 self.setSubPlot(subplot)
262 self.setSizeOfChar(szchar)
262 self.setSizeOfChar(szchar)
263 self.setXYZrange(xrange,yrange,zrange)
263 self.setXYZrange(xrange,yrange,zrange)
264 self.getGrid = True
264 self.getGrid = True
265 self.xaxisIsTime = False
265 self.xaxisIsTime = False
266 self.deltax = deltax
266 self.deltax = deltax
267
267
268 def setXYZrange(self,xrange,yrange,zrange):
268 def setXYZrange(self,xrange,yrange,zrange):
269 self.xrange = xrange
269 self.xrange = xrange
270 self.yrange = yrange
270 self.yrange = yrange
271 self.zrange = zrange
271 self.zrange = zrange
272
272
273 def setName(self, name):
273 def setName(self, name):
274 self.__name = name
274 self.__name = name
275
275
276 def setScreenPos(self,xpos,ypos):
276 def setScreenPos(self,xpos,ypos):
277 self.__xpos = xpos
277 self.__xpos = xpos
278 self.__ypos = ypos
278 self.__ypos = ypos
279
279
280 def setXYData(self,xdata=None,ydata=None,datatype="real"):
280 def setXYData(self,xdata=None,ydata=None,datatype="real"):
281 if((xdata != None) and (ydata != None)):
281 if((xdata != None) and (ydata != None)):
282 self.xdata = xdata
282 self.xdata = xdata
283 self.ydata = ydata
283 self.ydata = ydata
284 self.datatype = datatype
284 self.datatype = datatype
285
285
286 if((self.xdata == None) and (self.ydata == None)):
286 if((self.xdata == None) and (self.ydata == None)):
287 return None
287 return None
288
288
289 return 1
289 return 1
290
290
291
291
292 def setLabels(self,xlabel=None,ylabel=None,title=None):
292 def setLabels(self,xlabel=None,ylabel=None,title=None):
293 if xlabel != None: self.xlabel = xlabel
293 if xlabel != None: self.xlabel = xlabel
294 if ylabel != None: self.ylabel = ylabel
294 if ylabel != None: self.ylabel = ylabel
295 if title != None: self.title = title
295 if title != None: self.title = title
296
296
297 def setSubPlot(self,subplot):
297 def setSubPlot(self,subplot):
298 self.__subplot = subplot
298 self.__subplot = subplot
299
299
300 def setSizeOfChar(self,szchar):
300 def setSizeOfChar(self,szchar):
301 self.__szchar = szchar
301 self.__szchar = szchar
302
302
303 def setLineStyle(self,style):
303 def setLineStyle(self,style):
304 plplot.pllsty(style)
304 plplot.pllsty(style)
305
305
306 def setColor(self,color):
306 def setColor(self,color):
307 plplot.plcol0(color)
307 plplot.plcol0(color)
308
308
309 def setXAxisAsTime(self,value=False):
309 def setXAxisAsTime(self,value=False):
310 self.xaxisIsTime = value
310 self.xaxisIsTime = value
311
311
312 def basicLineTimePlot(self, x, y, xmin=None, xmax=None, ymin=None, ymax=None, colline=1):
312 def basicLineTimePlot(self, x, y, xmin=None, xmax=None, ymin=None, ymax=None, colline=1):
313
313
314 if xmin == None: xmin = x[0]
314 if xmin == None: xmin = x[0]
315 if xmax == None: xmax = x[-1]
315 if xmax == None: xmax = x[-1]
316 if ymin == None: ymin = y[0]
316 if ymin == None: ymin = y[0]
317 if ymax == None: ymax = y[-1]
317 if ymax == None: ymax = y[-1]
318
318
319 plplot.plcol0(colline)
319 plplot.plcol0(colline)
320 plplot.plline(x, y)
320 plplot.plline(x, y)
321 plplot.plcol0(1)
321 plplot.plcol0(1)
322
322
323 def basicXYPlot(self, x, y, xmin=None, xmax=None, ymin=None, ymax=None):
323 def basicXYPlot(self, x, y, xmin=None, xmax=None, ymin=None, ymax=None):
324
324
325 if xmin == None: xmin = x[0]
325 if xmin == None: xmin = x[0]
326 if xmax == None: xmax = x[-1]
326 if xmax == None: xmax = x[-1]
327 if ymin == None: ymin = y[0]
327 if ymin == None: ymin = y[0]
328 if ymax == None: ymax = y[-1]
328 if ymax == None: ymax = y[-1]
329
329
330 plplot.plline(x, y)
330 plplot.plline(x, y)
331
331
332 def basicPcolorPlot(self, data, x, y, xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None):
332 def basicPcolorPlot(self, data, x, y, xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None):
333 """
333 """
334 """
334 """
335 if xmin == None: xmin = x[0]
335 if xmin == None: xmin = x[0]
336 if xmax == None: xmax = x[-1]
336 if xmax == None: xmax = x[-1]
337 if ymin == None: ymin = y[0]
337 if ymin == None: ymin = y[0]
338 if ymax == None: ymax = y[-1]
338 if ymax == None: ymax = y[-1]
339 if zmin == None: zmin = numpy.nanmin(data)
339 if zmin == None: zmin = numpy.nanmin(data)
340 if zmax == None: zmax = numpy.nanmax(data)
340 if zmax == None: zmax = numpy.nanmax(data)
341
341
342 plplot.plimage(data,
342 plplot.plimage(data,
343 float(x[0]),
343 float(x[0]),
344 float(x[-1]),
344 float(x[-1]),
345 float(y[0]),
345 float(y[0]),
346 float(y[-1]),
346 float(y[-1]),
347 float(zmin),
347 float(zmin),
348 float(zmax),
348 float(zmax),
349 float(xmin),
349 float(xmin),
350 float(xmax),
350 float(xmax),
351 float(ymin),
351 float(ymin),
352 float(ymax)
352 float(ymax)
353 )
353 )
354
354
355 def __getBoxpltr(self, x, y, deltax=None, deltay=None):
355 def __getBoxpltr(self, x, y, deltax=None, deltay=None):
356
356
357 if not(len(x)>0 and len(y)>0):
357 if not(len(x)>0 and len(y)>0):
358 raise ValueError, "x axis and y axis are empty"
358 raise ValueError, "x axis and y axis are empty"
359
359
360 if deltax == None: deltax = x[-1] - x[-2]
360 if deltax == None: deltax = x[-1] - x[-2]
361 if deltay == None: deltay = y[-1] - y[-2]
361 if deltay == None: deltay = y[-1] - y[-2]
362
362
363 x1 = numpy.append(x, x[-1] + deltax)
363 x1 = numpy.append(x, x[-1] + deltax)
364 y1 = numpy.append(y, y[-1] + deltay)
364 y1 = numpy.append(y, y[-1] + deltay)
365
365
366 xg = (numpy.multiply.outer(x1, numpy.ones(len(y1))))
366 xg = (numpy.multiply.outer(x1, numpy.ones(len(y1))))
367 yg = (numpy.multiply.outer(numpy.ones(len(x1)), y1))
367 yg = (numpy.multiply.outer(numpy.ones(len(x1)), y1))
368
368
369 self.__xg = xg
369 self.__xg = xg
370 self.__yg = yg
370 self.__yg = yg
371
371
372 return xg, yg
372 return xg, yg
373
373
374
374
375 def advPcolorPlot(self, data, x, y, xmin=None, xmax=None, ymin=None, ymax=None, zmin=0., zmax=0., deltax=1.0, deltay=None, getGrid = True):
375 def advPcolorPlot(self, data, x, y, xmin=None, xmax=None, ymin=None, ymax=None, zmin=0., zmax=0., deltax=1.0, deltay=None, getGrid = True):
376 if getGrid:
376 if getGrid:
377 xg, yg = self.__getBoxpltr(x, y, deltax, deltay)
377 xg, yg = self.__getBoxpltr(x, y, deltax, deltay)
378 else:
378 else:
379 xg = self.__xg
379 xg = self.__xg
380 yg = self.__yg
380 yg = self.__yg
381
381
382 plplot.plimagefr(data,
382 plplot.plimagefr(data,
383 float(xmin),
383 float(xmin),
384 float(xmax),
384 float(xmax),
385 float(ymin),
385 float(ymin),
386 float(ymax),
386 float(ymax),
387 0.,
387 0.,
388 0.,
388 0.,
389 float(zmin),
389 float(zmin),
390 float(zmax),
390 float(zmax),
391 plplot.pltr2,
391 plplot.pltr2,
392 xg,
392 xg,
393 yg)
393 yg)
394
394
395
395
396 def colorbarPlot(self, xmin=0., xmax=1., ymin=0., ymax=1.):
396 def colorbarPlot(self, xmin=0., xmax=1., ymin=0., ymax=1.):
397 data = numpy.arange(256)
397 data = numpy.arange(256)
398 data = numpy.reshape(data, (1,-1))
398 data = numpy.reshape(data, (1,-1))
399
399
400 plplot.plimage(data,
400 plplot.plimage(data,
401 float(xmin),
401 float(xmin),
402 float(xmax),
402 float(xmax),
403 float(ymin),
403 float(ymin),
404 float(ymax),
404 float(ymax),
405 0.,
405 0.,
406 255.,
406 255.,
407 float(xmin),
407 float(xmin),
408 float(xmax),
408 float(xmax),
409 float(ymin),
409 float(ymin),
410 float(ymax))
410 float(ymax))
411
411
412 def plotBox(self, xmin, xmax, ymin, ymax, xopt, yopt, nolabels=False):
412 def plotBox(self, xmin, xmax, ymin, ymax, xopt, yopt, nolabels=False):
413
413
414 plplot.plschr(0.0,self.__szchar-0.05)
414 plplot.plschr(0.0,self.__szchar-0.05)
415 plplot.pladv(self.__subplot)
415 plplot.pladv(self.__subplot)
416 plplot.plvpor(self.__xpos[0], self.__xpos[1], self.__ypos[0], self.__ypos[1])
416 plplot.plvpor(self.__xpos[0], self.__xpos[1], self.__ypos[0], self.__ypos[1])
417 plplot.plwind(float(xmin), # self.xrange[0]
417 plplot.plwind(float(xmin), # self.xrange[0]
418 float(xmax), # self.xrange[1]
418 float(xmax), # self.xrange[1]
419 float(ymin), # self.yrange[0]
419 float(ymin), # self.yrange[0]
420 float(ymax) # self.yrange[1]
420 float(ymax) # self.yrange[1]
421 )
421 )
422
422
423
423
424
424
425 if self.xaxisIsTime:
425 if self.xaxisIsTime:
426 plplot.pltimefmt("%H:%M")
426 plplot.pltimefmt("%H:%M")
427 timedelta = (xmax - xmin + 1)/8.
427 timedelta = (xmax - xmin + 1)/8.
428 plplot.plbox(xopt, timedelta, 3, yopt, 0.0, 0)
428 plplot.plbox(xopt, timedelta, 3, yopt, 0.0, 0)
429 else:
429 else:
430 plplot.plbox(xopt, 0.0, 0, yopt, 0.0, 0)
430 plplot.plbox(xopt, 0.0, 0, yopt, 0.0, 0)
431
431
432
432
433 if not(nolabels):
433 if not(nolabels):
434 plplot.pllab(self.xlabel, self.ylabel, self.title)
434 plplot.pllab(self.xlabel, self.ylabel, self.title)
435
435
436
436
437 def delLabels(self):
437 def delLabels(self):
438 self.setColor(15) #Setting Line Color to White
438 self.setColor(15) #Setting Line Color to White
439 plplot.pllab(self.xlabel, self.ylabel, self.title)
439 plplot.pllab(self.xlabel, self.ylabel, self.title)
440 self.setColor(1) #Setting Line Color to Black
440 self.setColor(1) #Setting Line Color to Black
441
441
442
442
443
443
444 def plotImage(self,x,y,z,xrange,yrange,zrange):
444 def plotImage(self,x,y,z,xrange,yrange,zrange):
445 xi = x[0]
445 xi = x[0]
446 xf = x[-1]
446 xf = x[-1]
447 yi = y[0]
447 yi = y[0]
448 yf = y[-1]
448 yf = y[-1]
449
449
450 plplot.plimage(z,
450 plplot.plimage(z,
451 float(xi),
451 float(xi),
452 float(xf),
452 float(xf),
453 float(yi),
453 float(yi),
454 float(yf),
454 float(yf),
455 float(zrange[0]),
455 float(zrange[0]),
456 float(zrange[1]),
456 float(zrange[1]),
457 float(xi),
457 float(xi),
458 float(xf),
458 float(xf),
459 float(yrange[0]),
459 float(yrange[0]),
460 yrange[1])
460 yrange[1])
461
461
462 class LinearPlot:
462 class LinearPlot:
463 linearObjDic = {}
463 linearObjDic = {}
464 __xpos = None
464 __xpos = None
465 __ypos = None
465 __ypos = None
466 def __init__(self,indexPlot,nsubplot,winTitle):
466 def __init__(self,indexPlot,nsubplot,winTitle):
467 self.width = 700
467 self.width = 700
468 self.height = 150
468 self.height = 150
469 ncol = 1
469 ncol = 1
470 nrow = nsubplot
470 nrow = nsubplot
471 initPlplot(indexPlot,ncol,nrow,winTitle,self.width,self.height)
471 initPlplot(indexPlot,ncol,nrow,winTitle,self.width,self.height)
472
472
473
473
474 def setFigure(self,indexPlot):
474 def setFigure(self,indexPlot):
475 setStrm(indexPlot)
475 setStrm(indexPlot)
476
476
477 def setPosition(self):
477 def setPosition(self):
478
478
479 xi = 0.07; xf = 0.9 #0.8,0.7,0.5
479 xi = 0.07; xf = 0.9 #0.8,0.7,0.5
480 yi = 0.15; yf = 0.8
480 yi = 0.15; yf = 0.8
481
481
482 xpos = [xi,xf]
482 xpos = [xi,xf]
483 ypos = [yi,yf]
483 ypos = [yi,yf]
484
484
485 self.__xpos = xpos
485 self.__xpos = xpos
486 self.__ypos = ypos
486 self.__ypos = ypos
487
487
488 return xpos,ypos
488 return xpos,ypos
489
489
490 def refresh(self):
490 def refresh(self):
491 plFlush()
491 plFlush()
492
492
493 def setup(self,subplot,xmin,xmax,ymin,ymax,title,xlabel,ylabel):
493 def setup(self,subplot,xmin,xmax,ymin,ymax,title,xlabel,ylabel):
494 szchar = 1.10
494 szchar = 1.10
495 name = "linear"
495 name = "linear"
496 key = name + "%d"%subplot
496 key = name + "%d"%subplot
497 xrange = [xmin,xmax]
497 xrange = [xmin,xmax]
498 yrange = [ymin,ymax]
498 yrange = [ymin,ymax]
499
499
500 xpos,ypos = self.setPosition()
500 xpos,ypos = self.setPosition()
501 linearObj = BaseGraph(name,subplot,xpos,ypos,xlabel,ylabel,title,szchar,xrange,yrange)
501 linearObj = BaseGraph(name,subplot,xpos,ypos,xlabel,ylabel,title,szchar,xrange,yrange)
502 linearObj.plotBox(linearObj.xrange[0], linearObj.xrange[1], linearObj.yrange[0], linearObj.yrange[1], "bcnst", "bcnstv")
502 linearObj.plotBox(linearObj.xrange[0], linearObj.xrange[1], linearObj.yrange[0], linearObj.yrange[1], "bcnst", "bcnstv")
503 self.linearObjDic[key] = linearObj
503 self.linearObjDic[key] = linearObj
504
504
505 def plot(self,subplot,x,y,type="power"):
505 def plot(self,subplot,x,y,type="power"):
506 name = "linear"
506 name = "linear"
507 key = name + "%d"%subplot
507 key = name + "%d"%subplot
508
508
509 linearObj = self.linearObjDic[key]
509 linearObj = self.linearObjDic[key]
510 linearObj.plotBox(linearObj.xrange[0], linearObj.xrange[1], linearObj.yrange[0], linearObj.yrange[1], "bcst", "bcst")
510 linearObj.plotBox(linearObj.xrange[0], linearObj.xrange[1], linearObj.yrange[0], linearObj.yrange[1], "bcst", "bcst")
511
511
512 if linearObj.setXYData() != None:
512 if linearObj.setXYData() != None:
513 clearData(linearObj)
513 clearData(linearObj)
514
514
515 else:
515 else:
516 if type.lower() == 'power':
516 if type.lower() == 'power':
517 linearObj.setXYData(x,abs(y),"real")
517 linearObj.setXYData(x,abs(y),"real")
518 if type.lower() == 'iq':
518 if type.lower() == 'iq':
519 linearObj.setXYData(x,y,"complex")
519 linearObj.setXYData(x,y,"complex")
520
520
521 if type.lower() == 'power':
521 if type.lower() == 'power':
522 colline = 9
522 colline = 9
523 linearObj.basicLineTimePlot(x, abs(y), xmin, xmax, ymin, ymax, colline)
523 linearObj.basicLineTimePlot(x, abs(y), xmin, xmax, ymin, ymax, colline)
524 linearObj.setXYData(x,abs(y),"real")
524 linearObj.setXYData(x,abs(y),"real")
525
525
526 if type.lower() == 'iq':
526 if type.lower() == 'iq':
527 colline = 9
527 colline = 9
528 linearObj.basicLineTimePlot(x=x, y=y.real, colline=colline)
528 linearObj.basicLineTimePlot(x=x, y=y.real, colline=colline)
529 colline = 13
529 colline = 13
530 linearObj.basicLineTimePlot(x=x, y=y.imag, colline=colline)
530 linearObj.basicLineTimePlot(x=x, y=y.imag, colline=colline)
531
531
532 linearObj.setXYData(x,y,"complex")
532 linearObj.setXYData(x,y,"complex")
533
533
534 linearObj.plotBox(linearObj.xrange[0], linearObj.xrange[1], linearObj.yrange[0], linearObj.yrange[1], "bcst", "bcst")
534 linearObj.plotBox(linearObj.xrange[0], linearObj.xrange[1], linearObj.yrange[0], linearObj.yrange[1], "bcst", "bcst")
535
535
536
536
537 # linearObj.plotBox(linearObj.xrange[0], linearObj.xrange[1], linearObj.yrange[0], linearObj.yrange[1], "bc", "bc")
537 # linearObj.plotBox(linearObj.xrange[0], linearObj.xrange[1], linearObj.yrange[0], linearObj.yrange[1], "bc", "bc")
538 # linearObj.basicXYPlot(data,y)
538 # linearObj.basicXYPlot(data,y)
539 # linearObj.setXYData(data,y)
539 # linearObj.setXYData(data,y)
540
540
541
541
542
542
543 class SpectraPlot:
543 class SpectraPlot:
544 pcolorObjDic = {}
544 pcolorObjDic = {}
545 colorbarObjDic = {}
545 colorbarObjDic = {}
546 pwprofileObjDic = {}
546 pwprofileObjDic = {}
547 showColorbar = None
547 showColorbar = None
548 showPowerProfile = None
548 showPowerProfile = None
549 XAxisAsTime = None
549 XAxisAsTime = None
550 widht = None
550 widht = None
551 height = None
551 height = None
552 __spcxpos = None
552 __spcxpos = None
553 __spcypos = None
553 __spcypos = None
554 __cmapxpos = None
554 __cmapxpos = None
555 __cmapypos = None
555 __cmapypos = None
556 __profxpos = None
556 __profxpos = None
557 __profypos = None
557 __profypos = None
558 __lastTitle = None
558 __lastTitle = None
559
559
560 def __init__(self,indexPlot,nsubplot,winTitle,colormap,showColorbar,showPowerProfile,XAxisAsTime):
560 def __init__(self,indexPlot,nsubplot,winTitle,colormap,showColorbar,showPowerProfile,XAxisAsTime):
561 self.width = 460
561 self.width = 460
562 self.height = 300
562 self.height = 300
563 self.showColorbar = showColorbar
563 self.showColorbar = showColorbar
564 self.showPowerProfile = showPowerProfile
564 self.showPowerProfile = showPowerProfile
565 self.XAxisAsTime = XAxisAsTime
565 self.XAxisAsTime = XAxisAsTime
566
566
567 nrow = 2
567 nrow = 2
568 if (nsubplot%2)==0:
568 if (nsubplot%2)==0:
569 ncol = nsubplot/nrow
569 ncol = nsubplot/nrow
570 else:
570 else:
571 ncol = int(nsubplot)/nrow + 1
571 ncol = int(nsubplot)/nrow + 1
572
572
573 initPlplot(indexPlot,ncol,nrow,winTitle,self.width,self.height)
573 initPlplot(indexPlot,ncol,nrow,winTitle,self.width,self.height)
574 setColormap(colormap)
574 setColormap(colormap)
575 self.ncol = ncol
575 self.ncol = ncol
576 self.nrow = nrow
576 self.nrow = nrow
577
577
578 def setFigure(self,indexPlot):
578 def setFigure(self,indexPlot):
579 setStrm(indexPlot)
579 setStrm(indexPlot)
580
580
581 def setSpectraPos(self): #modificar valores de acuerdo al colorbar y pwprofile
581 def setSpectraPos(self): #modificar valores de acuerdo al colorbar y pwprofile
582 if self.showPowerProfile: xi = 0.09; xf = 0.6 #0.075
582 if self.showPowerProfile: xi = 0.09; xf = 0.6 #0.075
583 else: xi = 0.15; xf = 0.8 #0.8,0.7,0.5
583 else: xi = 0.15; xf = 0.8 #0.8,0.7,0.5
584 yi = 0.15; yf = 0.80
584 yi = 0.15; yf = 0.80
585
585
586 xpos = [xi,xf]
586 xpos = [xi,xf]
587 ypos = [yi,yf]
587 ypos = [yi,yf]
588
588
589 self.__spcxpos = xpos
589 self.__spcxpos = xpos
590 self.__spcypos = ypos
590 self.__spcypos = ypos
591
591
592 return xpos,ypos
592 return xpos,ypos
593
593
594 def setColorbarScreenPos(self):
594 def setColorbarScreenPos(self):
595
595
596 xi = self.__spcxpos[1] + 0.03; xf = xi + 0.03
596 xi = self.__spcxpos[1] + 0.03; xf = xi + 0.03
597 yi = self.__spcypos[0]; yf = self.__spcypos[1]
597 yi = self.__spcypos[0]; yf = self.__spcypos[1]
598
598
599 xpos = [xi,xf]
599 xpos = [xi,xf]
600 ypos = [yi,yf]
600 ypos = [yi,yf]
601
601
602 self.__cmapxpos = xpos
602 self.__cmapxpos = xpos
603 self.__cmapypos = ypos
603 self.__cmapypos = ypos
604
604
605 return xpos,ypos
605 return xpos,ypos
606
606
607 def setPowerprofileScreenPos(self):
607 def setPowerprofileScreenPos(self):
608
608
609 xi = self.__cmapxpos[1] + 0.07; xf = xi + 0.25
609 xi = self.__cmapxpos[1] + 0.07; xf = xi + 0.25
610 yi = self.__spcypos[0]; yf = self.__spcypos[1]
610 yi = self.__spcypos[0]; yf = self.__spcypos[1]
611
611
612 xpos = [xi,xf]
612 xpos = [xi,xf]
613 ypos = [yi,yf]
613 ypos = [yi,yf]
614
614
615 self.__profxpos = [xi,xf]
615 self.__profxpos = [xi,xf]
616 self.__profypos = [yi,yf]
616 self.__profypos = [yi,yf]
617
617
618 return xpos,ypos
618 return xpos,ypos
619
619
620 def setup(self,subplot,xmin,xmax,ymin,ymax,zmin,zmax,title,xlabel,ylabel):
620 def setup(self,subplot,xmin,xmax,ymin,ymax,zmin,zmax,title,xlabel,ylabel):
621 # Config Spectra plot
621 # Config Spectra plot
622 szchar = 0.7
622 szchar = 0.7
623 name = "spc"
623 name = "spc"
624 key = name + "%d"%subplot
624 key = name + "%d"%subplot
625 xrange = [xmin,xmax]
625 xrange = [xmin,xmax]
626 yrange = [ymin,ymax]
626 yrange = [ymin,ymax]
627 zrange = [zmin,zmax]
627 zrange = [zmin,zmax]
628
628
629 xpos,ypos = self.setSpectraPos()
629 xpos,ypos = self.setSpectraPos()
630 pcolorObj = BaseGraph(name,subplot,xpos,ypos,xlabel,ylabel,title,szchar,xrange,yrange,zrange)
630 pcolorObj = BaseGraph(name,subplot,xpos,ypos,xlabel,ylabel,title,szchar,xrange,yrange,zrange)
631 pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], "bcnst", "bcnstv")
631 pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], "bcnst", "bcnstv")
632 self.pcolorObjDic[key] = pcolorObj
632 self.pcolorObjDic[key] = pcolorObj
633
633
634 # Config Colorbar
634 # Config Colorbar
635 if self.showColorbar:
635 if self.showColorbar:
636 szchar = 0.65
636 szchar = 0.65
637 name = "colorbar"
637 name = "colorbar"
638 key = name + "%d"%subplot
638 key = name + "%d"%subplot
639
639
640 xpos,ypos = self.setColorbarScreenPos()
640 xpos,ypos = self.setColorbarScreenPos()
641 xrange = [0.,1.]
641 xrange = [0.,1.]
642 yrange = [zmin,zmax]
642 yrange = [zmin,zmax]
643 cmapObj = BaseGraph(name,subplot,xpos,ypos,"","","dB",szchar,xrange,yrange)
643 cmapObj = BaseGraph(name,subplot,xpos,ypos,"","","dB",szchar,xrange,yrange)
644 cmapObj.plotBox(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1], "bc", "bcm")
644 cmapObj.plotBox(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1], "bc", "bcm")
645 cmapObj.colorbarPlot(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1])
645 cmapObj.colorbarPlot(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1])
646 cmapObj.plotBox(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1], "bc", "bcmtsv")
646 cmapObj.plotBox(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1], "bc", "bcmtsv")
647 self.colorbarObjDic[key] = cmapObj
647 self.colorbarObjDic[key] = cmapObj
648
648
649 # Config Power profile
649 # Config Power profile
650 if self.showPowerProfile:
650 if self.showPowerProfile:
651 szchar = 0.55
651 szchar = 0.55
652 name = "pwprofile"
652 name = "pwprofile"
653 key = name + "%d"%subplot
653 key = name + "%d"%subplot
654
654
655 xpos,ypos = self.setPowerprofileScreenPos()
655 xpos,ypos = self.setPowerprofileScreenPos()
656 xrange = [zmin,zmax]
656 xrange = [zmin,zmax]
657 yrange = [ymin,ymax]
657 yrange = [ymin,ymax]
658 powObj = BaseGraph(name,subplot,xpos,ypos,"dB","","Power Profile",szchar,xrange,yrange)
658 powObj = BaseGraph(name,subplot,xpos,ypos,"dB","","Power Profile",szchar,xrange,yrange)
659 powObj.setLineStyle(2)
659 powObj.setLineStyle(2)
660 powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bcntg", "bc")
660 powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bcntg", "bc")
661 powObj.setLineStyle(1)
661 powObj.setLineStyle(1)
662 powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bc", "bc")
662 powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bc", "bc")
663 self.pwprofileObjDic[key] = powObj
663 self.pwprofileObjDic[key] = powObj
664
664
665 def printTitle(self,pltitle):
665 def printTitle(self,pltitle):
666 if self.__lastTitle != None:
666 if self.__lastTitle != None:
667 setPlTitle(self.__lastTitle,"white")
667 setPlTitle(self.__lastTitle,"white")
668
668
669 self.__lastTitle = pltitle
669 self.__lastTitle = pltitle
670
670
671 setPlTitle(pltitle,"black")
671 setPlTitle(pltitle,"black")
672
672
673 setSubpages(self.ncol,self.nrow)
673 setSubpages(self.ncol,self.nrow)
674
674
675 def plot(self,subplot,x,y,z,subtitle):
675 def plot(self,subplot,x,y,z,subtitle):
676 # Spectra plot
676 # Spectra plot
677
677
678 name = "spc"
678 name = "spc"
679 key = name + "%d"%subplot
679 key = name + "%d"%subplot
680
680
681 # newx = [x[0],x[-1]]
681 # newx = [x[0],x[-1]]
682 pcolorObj = self.pcolorObjDic[key]
682 pcolorObj = self.pcolorObjDic[key]
683 pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], "bcst", "bcst")
683 pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], "bcst", "bcst")
684 pcolorObj.delLabels()
684 pcolorObj.delLabels()
685 pcolorObj.setLabels(title=subtitle)
685 pcolorObj.setLabels(title=subtitle)
686
686
687 deltax = None; deltay = None
687 deltax = None; deltay = None
688
688
689 pcolorObj.advPcolorPlot(z,
689 pcolorObj.advPcolorPlot(z,
690 x,
690 x,
691 y,
691 y,
692 xmin=pcolorObj.xrange[0],
692 xmin=pcolorObj.xrange[0],
693 xmax=pcolorObj.xrange[1],
693 xmax=pcolorObj.xrange[1],
694 ymin=pcolorObj.yrange[0],
694 ymin=pcolorObj.yrange[0],
695 ymax=pcolorObj.yrange[1],
695 ymax=pcolorObj.yrange[1],
696 zmin=pcolorObj.zrange[0],
696 zmin=pcolorObj.zrange[0],
697 zmax=pcolorObj.zrange[1],
697 zmax=pcolorObj.zrange[1],
698 deltax=deltax,
698 deltax=deltax,
699 deltay=deltay,
699 deltay=deltay,
700 getGrid=pcolorObj.getGrid)
700 getGrid=pcolorObj.getGrid)
701
701
702 pcolorObj.getGrid = False
702 pcolorObj.getGrid = False
703
703
704 pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], "bcst", "bcst")
704 pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], "bcst", "bcst")
705
705
706 # Power Profile
706 # Power Profile
707 if self.showPowerProfile:
707 if self.showPowerProfile:
708 power = numpy.average(z, axis=0)
708 power = numpy.average(z, axis=0)
709 name = "pwprofile"
709 name = "pwprofile"
710 key = name + "%d"%subplot
710 key = name + "%d"%subplot
711 powObj = self.pwprofileObjDic[key]
711 powObj = self.pwprofileObjDic[key]
712
712
713 if powObj.setXYData() != None:
713 if powObj.setXYData() != None:
714 clearData(powObj)
714 clearData(powObj)
715 powObj.setLineStyle(2)
716 powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bcntg", "bc")
717 powObj.setLineStyle(1)
715 else:
718 else:
716 powObj.setXYData(power,y)
719 powObj.setXYData(power,y)
717
720
718 powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bc", "bc")
721 powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bc", "bc")
719 powObj.basicXYPlot(power,y)
722 powObj.basicXYPlot(power,y)
720 powObj.setXYData(power,y)
723 powObj.setXYData(power,y)
721
724
722 def refresh(self):
725 def refresh(self):
723 plFlush()
726 plFlush()
724
727
725 class RtiPlot:
728 class RtiPlot:
726
729
727 pcolorObjDic = {}
730 pcolorObjDic = {}
728 colorbarObjDic = {}
731 colorbarObjDic = {}
729 pwprofileObjDic = {}
732 pwprofileObjDic = {}
730 showColorbar = None
733 showColorbar = None
731 showPowerProfile = None
734 showPowerProfile = None
732 XAxisAsTime = None
735 XAxisAsTime = None
733 widht = None
736 widht = None
734 height = None
737 height = None
735 __rtixpos = None
738 __rtixpos = None
736 __rtiypos = None
739 __rtiypos = None
737 __cmapxpos = None
740 __cmapxpos = None
738 __cmapypos = None
741 __cmapypos = None
739 __profxpos = None
742 __profxpos = None
740 __profypos = None
743 __profypos = None
741
744
742 def __init__(self,indexPlot,nsubplot,winTitle,colormap,showColorbar,showPowerProfile,XAxisAsTime):
745 def __init__(self,indexPlot,nsubplot,winTitle,colormap,showColorbar,showPowerProfile,XAxisAsTime):
743 self.width = 700
746 self.width = 700
744 self.height = 150
747 self.height = 150
745 self.showColorbar = showColorbar
748 self.showColorbar = showColorbar
746 self.showPowerProfile = showPowerProfile
749 self.showPowerProfile = showPowerProfile
747 self.XAxisAsTime = XAxisAsTime
750 self.XAxisAsTime = XAxisAsTime
748
751
749 ncol = 1
752 ncol = 1
750 nrow = nsubplot
753 nrow = nsubplot
751 initPlplot(indexPlot,ncol,nrow,winTitle,self.width,self.height)
754 initPlplot(indexPlot,ncol,nrow,winTitle,self.width,self.height)
752 setColormap(colormap)
755 setColormap(colormap)
753
756
754 def setFigure(self,indexPlot):
757 def setFigure(self,indexPlot):
755 setStrm(indexPlot)
758 setStrm(indexPlot)
756
759
757 def setRtiScreenPos(self):
760 def setRtiScreenPos(self):
758
761
759 if self.showPowerProfile: xi = 0.07; xf = 0.65
762 if self.showPowerProfile: xi = 0.07; xf = 0.65
760 else: xi = 0.07; xf = 0.9
763 else: xi = 0.07; xf = 0.9
761 yi = 0.15; yf = 0.80
764 yi = 0.15; yf = 0.80
762
765
763 xpos = [xi,xf]
766 xpos = [xi,xf]
764 ypos = [yi,yf]
767 ypos = [yi,yf]
765
768
766 self.__rtixpos = xpos
769 self.__rtixpos = xpos
767 self.__rtiypos = ypos
770 self.__rtiypos = ypos
768
771
769 return xpos,ypos
772 return xpos,ypos
770
773
771 def setColorbarScreenPos(self):
774 def setColorbarScreenPos(self):
772
775
773 xi = self.__rtixpos[1] + 0.03; xf = xi + 0.03
776 xi = self.__rtixpos[1] + 0.03; xf = xi + 0.03
774
777
775 yi = self.__rtiypos[0]; yf = self.__rtiypos[1]
778 yi = self.__rtiypos[0]; yf = self.__rtiypos[1]
776
779
777 xpos = [xi,xf]
780 xpos = [xi,xf]
778 ypos = [yi,yf]
781 ypos = [yi,yf]
779
782
780 self.__cmapxpos = xpos
783 self.__cmapxpos = xpos
781 self.__cmapypos = ypos
784 self.__cmapypos = ypos
782
785
783 return xpos,ypos
786 return xpos,ypos
784
787
785 def setPowerprofileScreenPos(self):
788 def setPowerprofileScreenPos(self):
786
789
787 xi = self.__cmapxpos[1] + 0.05; xf = xi + 0.20
790 xi = self.__cmapxpos[1] + 0.05; xf = xi + 0.20
788
791
789 yi = self.__rtiypos[0]; yf = self.__rtiypos[1]
792 yi = self.__rtiypos[0]; yf = self.__rtiypos[1]
790
793
791 xpos = [xi,xf]
794 xpos = [xi,xf]
792 ypos = [yi,yf]
795 ypos = [yi,yf]
793
796
794 self.__profxpos = [xi,xf]
797 self.__profxpos = [xi,xf]
795 self.__profypos = [yi,yf]
798 self.__profypos = [yi,yf]
796
799
797 return xpos,ypos
800 return xpos,ypos
798
801
799 def setup(self,subplot,xmin,xmax,ymin,ymax,zmin,zmax,title,xlabel,ylabel,timedata,timezone="lt",npoints=100):
802 def setup(self,subplot,xmin,xmax,ymin,ymax,zmin,zmax,title,xlabel,ylabel,timedata,timezone="lt",npoints=100):
800 # Config Rti plot
803 # Config Rti plot
801 szchar = 1.10
804 szchar = 1.10
802 name = "rti"
805 name = "rti"
803 key = name + "%d"%subplot
806 key = name + "%d"%subplot
804
807
805 # xmin, xmax --> minHour, max Hour : valores que definen el ejex x=[horaInicio,horaFinal]
808 # xmin, xmax --> minHour, max Hour : valores que definen el ejex x=[horaInicio,horaFinal]
806 thisDateTime = datetime.datetime.fromtimestamp(timedata)
809 thisDateTime = datetime.datetime.fromtimestamp(timedata)
807 startDateTime = datetime.datetime(thisDateTime.year,thisDateTime.month,thisDateTime.day,xmin,0,0)
810 startDateTime = datetime.datetime(thisDateTime.year,thisDateTime.month,thisDateTime.day,xmin,0,0)
808 endDateTime = datetime.datetime(thisDateTime.year,thisDateTime.month,thisDateTime.day,xmax,59,59)
811 endDateTime = datetime.datetime(thisDateTime.year,thisDateTime.month,thisDateTime.day,xmax,59,59)
809 deltaTime = 0
812 deltaTime = 0
810 if timezone == "lt":
813 if timezone == "lt":
811 deltaTime = time.timezone
814 deltaTime = time.timezone
812 startTimeInSecs = time.mktime(startDateTime.timetuple()) - deltaTime
815 startTimeInSecs = time.mktime(startDateTime.timetuple()) - deltaTime
813 endTimeInSecs = time.mktime(endDateTime.timetuple()) - deltaTime
816 endTimeInSecs = time.mktime(endDateTime.timetuple()) - deltaTime
814
817
815 xrange = [startTimeInSecs,endTimeInSecs]
818 xrange = [startTimeInSecs,endTimeInSecs]
816 totalTimeInXrange = endTimeInSecs - startTimeInSecs + 1.
819 totalTimeInXrange = endTimeInSecs - startTimeInSecs + 1.
817 deltax = totalTimeInXrange / npoints
820 deltax = totalTimeInXrange / npoints
818
821
819 yrange = [ymin,ymax]
822 yrange = [ymin,ymax]
820 zrange = [zmin,zmax]
823 zrange = [zmin,zmax]
821
824
822 xpos,ypos = self.setRtiScreenPos()
825 xpos,ypos = self.setRtiScreenPos()
823 pcolorObj = BaseGraph(name,subplot,xpos,ypos,xlabel,ylabel,title,szchar,xrange,yrange,zrange,deltax)
826 pcolorObj = BaseGraph(name,subplot,xpos,ypos,xlabel,ylabel,title,szchar,xrange,yrange,zrange,deltax)
824 if self.XAxisAsTime:
827 if self.XAxisAsTime:
825 pcolorObj.setXAxisAsTime(self.XAxisAsTime)
828 pcolorObj.setXAxisAsTime(self.XAxisAsTime)
826 xopt = "bcnstd"
829 xopt = "bcnstd"
827 yopt = "bcnstv"
830 yopt = "bcnstv"
828 else:
831 else:
829 xopt = "bcnst"
832 xopt = "bcnst"
830 yopt = "bcnstv"
833 yopt = "bcnstv"
831
834
832 pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], xopt, yopt)
835 pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], xopt, yopt)
833 self.pcolorObjDic[key] = pcolorObj
836 self.pcolorObjDic[key] = pcolorObj
834
837
835
838
836 # Config Colorbar
839 # Config Colorbar
837 if self.showColorbar:
840 if self.showColorbar:
838 szchar = 0.9
841 szchar = 0.9
839 name = "colorbar"
842 name = "colorbar"
840 key = name + "%d"%subplot
843 key = name + "%d"%subplot
841
844
842 xpos,ypos = self.setColorbarScreenPos()
845 xpos,ypos = self.setColorbarScreenPos()
843 xrange = [0.,1.]
846 xrange = [0.,1.]
844 yrange = [zmin,zmax]
847 yrange = [zmin,zmax]
845 cmapObj = BaseGraph(name,subplot,xpos,ypos,"","","dB",szchar,xrange,yrange)
848 cmapObj = BaseGraph(name,subplot,xpos,ypos,"","","dB",szchar,xrange,yrange)
846 cmapObj.plotBox(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1], "bc", "bcm")
849 cmapObj.plotBox(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1], "bc", "bcm")
847 cmapObj.colorbarPlot(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1])
850 cmapObj.colorbarPlot(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1])
848 cmapObj.plotBox(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1], "bc", "bcmtsv")
851 cmapObj.plotBox(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1], "bc", "bcmtsv")
849 self.colorbarObjDic[key] = cmapObj
852 self.colorbarObjDic[key] = cmapObj
850
853
851
854
852 # Config Power profile
855 # Config Power profile
853 if self.showPowerProfile:
856 if self.showPowerProfile:
854 szchar = 0.8
857 szchar = 0.8
855 name = "pwprofile"
858 name = "pwprofile"
856 key = name + "%d"%subplot
859 key = name + "%d"%subplot
857
860
858 xpos,ypos = self.setPowerprofileScreenPos()
861 xpos,ypos = self.setPowerprofileScreenPos()
859 xrange = [zmin,zmax]
862 xrange = [zmin,zmax]
860 yrange = [ymin,ymax]
863 yrange = [ymin,ymax]
861 powObj = BaseGraph(name,subplot,xpos,ypos,"dB","","Power Profile",szchar,xrange,yrange)
864 powObj = BaseGraph(name,subplot,xpos,ypos,"dB","","Power Profile",szchar,xrange,yrange)
862 powObj.setLineStyle(2)
865 powObj.setLineStyle(2)
863 powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bcntg", "bc")
866 powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bcntg", "bc")
864 powObj.setLineStyle(1)
867 powObj.setLineStyle(1)
865 powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bc", "bc")
868 powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bc", "bc")
866 self.pwprofileObjDic[key] = powObj
869 self.pwprofileObjDic[key] = powObj
867
870
868
871
869 def plot(self,subplot,x,y,z):
872 def plot(self,subplot,x,y,z):
870 # RTI plot
873 # RTI plot
871 name = "rti"
874 name = "rti"
872 key = name + "%d"%subplot
875 key = name + "%d"%subplot
873
876
874 data = numpy.reshape(z, (1,-1))
877 data = numpy.reshape(z, (1,-1))
875 data = numpy.abs(data)
878 data = numpy.abs(data)
876 data = 10*numpy.log10(data)
879 data = 10*numpy.log10(data)
877 newx = [x,x+1]
880 newx = [x,x+1]
878
881
879 pcolorObj = self.pcolorObjDic[key]
882 pcolorObj = self.pcolorObjDic[key]
880
883
881 if pcolorObj.xaxisIsTime:
884 if pcolorObj.xaxisIsTime:
882 xopt = "bcstd"
885 xopt = "bcstd"
883 yopt = "bcst"
886 yopt = "bcst"
884 else:
887 else:
885 xopt = "bcst"
888 xopt = "bcst"
886 yopt = "bcst"
889 yopt = "bcst"
887
890
888 pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], xopt, yopt)
891 pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], xopt, yopt)
889
892
890 deltax = pcolorObj.deltax
893 deltax = pcolorObj.deltax
891 deltay = None
894 deltay = None
892
895
893 if pcolorObj.xmin == None and pcolorObj.xmax == None:
896 if pcolorObj.xmin == None and pcolorObj.xmax == None:
894 pcolorObj.xmin = x
897 pcolorObj.xmin = x
895 pcolorObj.xmax = x
898 pcolorObj.xmax = x
896
899
897 if x >= pcolorObj.xmax:
900 if x >= pcolorObj.xmax:
898 xmin = x
901 xmin = x
899 xmax = x + deltax
902 xmax = x + deltax
900 x = [x]
903 x = [x]
901 pcolorObj.advPcolorPlot(data,
904 pcolorObj.advPcolorPlot(data,
902 x,
905 x,
903 y,
906 y,
904 xmin=xmin,
907 xmin=xmin,
905 xmax=xmax,
908 xmax=xmax,
906 ymin=pcolorObj.yrange[0],
909 ymin=pcolorObj.yrange[0],
907 ymax=pcolorObj.yrange[1],
910 ymax=pcolorObj.yrange[1],
908 zmin=pcolorObj.zrange[0],
911 zmin=pcolorObj.zrange[0],
909 zmax=pcolorObj.zrange[1],
912 zmax=pcolorObj.zrange[1],
910 deltax=deltax,
913 deltax=deltax,
911 deltay=deltay,
914 deltay=deltay,
912 getGrid=pcolorObj.getGrid)
915 getGrid=pcolorObj.getGrid)
913
916
914 pcolorObj.xmin = xmin
917 pcolorObj.xmin = xmin
915 pcolorObj.xmax = xmax
918 pcolorObj.xmax = xmax
916
919
917
920
918 # Power Profile
921 # Power Profile
919 if self.showPowerProfile:
922 if self.showPowerProfile:
920 data = numpy.reshape(data,(numpy.size(data)))
923 data = numpy.reshape(data,(numpy.size(data)))
921 name = "pwprofile"
924 name = "pwprofile"
922 key = name + "%d"%subplot
925 key = name + "%d"%subplot
923 powObj = self.pwprofileObjDic[key]
926 powObj = self.pwprofileObjDic[key]
924
927
925 if powObj.setXYData() != None:
928 if powObj.setXYData() != None:
926 clearData(powObj)
929 clearData(powObj)
927 powObj.setLineStyle(2)
930 powObj.setLineStyle(2)
928 powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bcntg", "bc")
931 powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bcntg", "bc")
929 powObj.setLineStyle(1)
932 powObj.setLineStyle(1)
930 else:
933 else:
931 powObj.setXYData(data,y)
934 powObj.setXYData(data,y)
932
935
933 powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bc", "bc")
936 powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], "bc", "bc")
934 powObj.basicXYPlot(data,y)
937 powObj.basicXYPlot(data,y)
935 powObj.setXYData(data,y)
938 powObj.setXYData(data,y)
936
939
937 def refresh(self):
940 def refresh(self):
938 plFlush() No newline at end of file
941 plFlush()
General Comments 0
You need to be logged in to leave comments. Login now