@@ -1,883 +1,883 | |||||
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: BaseGraph.py 117 2012-09-04 21:16:59Z dsuarez $ |
|
5 | @version $Id$ | |
6 |
|
6 | |||
7 | ''' |
|
7 | ''' | |
8 |
|
8 | |||
9 | import numpy |
|
9 | import numpy | |
10 |
|
10 | |||
11 | import time |
|
11 | import time | |
12 | import datetime |
|
12 | import datetime | |
13 |
|
13 | |||
14 |
|
14 | |||
15 | import matplotlib as mpl |
|
15 | import matplotlib as mpl | |
16 | mpl.use('TKAgg') |
|
16 | mpl.use('TKAgg') | |
17 | import matplotlib.pyplot as plt |
|
17 | import matplotlib.pyplot as plt | |
18 |
|
18 | |||
19 | import scitools.numpyutils as sn |
|
19 | import scitools.numpyutils as sn | |
20 |
|
20 | |||
21 | def cmap1_init(colormap='gray'): |
|
21 | def cmap1_init(colormap='gray'): | |
22 | pass |
|
22 | pass | |
23 |
|
23 | |||
24 | def setColormap(colormap='jet'): |
|
24 | def setColormap(colormap='jet'): | |
25 | pass |
|
25 | pass | |
26 |
|
26 | |||
27 | def savePlplot(filename,width,height): |
|
27 | def savePlplot(filename,width,height): | |
28 | pass |
|
28 | pass | |
29 |
|
29 | |||
30 | def initMatplotlib(indexFig,ncol,nrow,winTitle,width,height): |
|
30 | def initMatplotlib(indexFig,ncol,nrow,winTitle,width,height): | |
31 |
|
31 | |||
32 | plt.ioff() |
|
32 | plt.ioff() | |
33 | fig = plt.figure(indexFig) |
|
33 | fig = plt.figure(indexFig) | |
34 | fig.canvas.manager.set_window_title(winTitle) |
|
34 | fig.canvas.manager.set_window_title(winTitle) | |
35 | fig.canvas.manager.resize(width,height) |
|
35 | fig.canvas.manager.resize(width,height) | |
36 | # fig.add_subplot(nrow,ncol,1) |
|
36 | # fig.add_subplot(nrow,ncol,1) | |
37 | plt.ion() |
|
37 | plt.ion() | |
38 |
|
38 | |||
39 | def setNewPage(): |
|
39 | def setNewPage(): | |
40 | plt.clf() |
|
40 | plt.clf() | |
41 |
|
41 | |||
42 | def closePage(): |
|
42 | def closePage(): | |
43 | pass |
|
43 | pass | |
44 |
|
44 | |||
45 | def clearData(objGraph): |
|
45 | def clearData(objGraph): | |
46 | objGraph.plotBox(objGraph.xrange[0], objGraph.xrange[1], objGraph.yrange[0], objGraph.yrange[1], 'bc', 'bc') |
|
46 | objGraph.plotBox(objGraph.xrange[0], objGraph.xrange[1], objGraph.yrange[0], objGraph.yrange[1], 'bc', 'bc') | |
47 |
|
47 | |||
48 | objGraph.setColor(15) #Setting Line Color to White |
|
48 | objGraph.setColor(15) #Setting Line Color to White | |
49 |
|
49 | |||
50 | if objGraph.datatype == 'complex': |
|
50 | if objGraph.datatype == 'complex': | |
51 | objGraph.basicXYPlot(objGraph.xdata,objGraph.ydata.real) |
|
51 | objGraph.basicXYPlot(objGraph.xdata,objGraph.ydata.real) | |
52 | objGraph.basicXYPlot(objGraph.xdata,objGraph.ydata.imag) |
|
52 | objGraph.basicXYPlot(objGraph.xdata,objGraph.ydata.imag) | |
53 |
|
53 | |||
54 | if objGraph.datatype == 'real': |
|
54 | if objGraph.datatype == 'real': | |
55 | objGraph.basicXYPlot(objGraph.xdata,objGraph.ydata) |
|
55 | objGraph.basicXYPlot(objGraph.xdata,objGraph.ydata) | |
56 |
|
56 | |||
57 | objGraph.setColor(1) |
|
57 | objGraph.setColor(1) | |
58 |
|
58 | |||
59 | def setFigure(indexFig): |
|
59 | def setFigure(indexFig): | |
60 | plt.figure(indexFig) |
|
60 | plt.figure(indexFig) | |
61 |
|
61 | |||
62 | def refresh(): |
|
62 | def refresh(): | |
63 | plt.draw() |
|
63 | plt.draw() | |
64 |
|
64 | |||
65 | def show(): |
|
65 | def show(): | |
66 | plt.ioff() |
|
66 | plt.ioff() | |
67 | plt.show() |
|
67 | plt.show() | |
68 | plt.ion() |
|
68 | plt.ion() | |
69 |
|
69 | |||
70 | def setPlTitle(pltitle,color, szchar=0.7): |
|
70 | def setPlTitle(pltitle,color, szchar=0.7): | |
71 | pass |
|
71 | pass | |
72 |
|
72 | |||
73 | def setSubpages(ncol,nrow): |
|
73 | def setSubpages(ncol,nrow): | |
74 | pass |
|
74 | pass | |
75 |
|
75 | |||
76 | class BaseGraph: |
|
76 | class BaseGraph: | |
77 |
|
77 | |||
78 | __name = None |
|
78 | __name = None | |
79 | __xpos = None |
|
79 | __xpos = None | |
80 | __ypos = None |
|
80 | __ypos = None | |
81 | __subplot = None |
|
81 | __subplot = None | |
82 | __xg = None |
|
82 | __xg = None | |
83 | __yg = None |
|
83 | __yg = None | |
84 | __axesId = None |
|
84 | __axesId = None | |
85 | xdata = None |
|
85 | xdata = None | |
86 | ydata = None |
|
86 | ydata = None | |
87 | getGrid = True |
|
87 | getGrid = True | |
88 | xaxisIsTime = False |
|
88 | xaxisIsTime = False | |
89 | deltax = None |
|
89 | deltax = None | |
90 | xmin = None |
|
90 | xmin = None | |
91 | xmax = None |
|
91 | xmax = None | |
92 |
|
92 | |||
93 | def __init__(self,name,subplot,xpos,ypos,xlabel,ylabel,title,szchar,xrange,yrange,zrange=None,deltax=1.0): |
|
93 | def __init__(self,name,subplot,xpos,ypos,xlabel,ylabel,title,szchar,xrange,yrange,zrange=None,deltax=1.0): | |
94 |
|
94 | |||
95 | self.setName(name) |
|
95 | self.setName(name) | |
96 | self.setScreenPos(xpos, ypos) |
|
96 | self.setScreenPos(xpos, ypos) | |
97 | self.setSubPlot(subplot) |
|
97 | self.setSubPlot(subplot) | |
98 | self.setXYZrange(xrange,yrange,zrange) |
|
98 | self.setXYZrange(xrange,yrange,zrange) | |
99 | self.setSizeOfChar(szchar) |
|
99 | self.setSizeOfChar(szchar) | |
100 | self.setLabels(xlabel,ylabel,title) |
|
100 | self.setLabels(xlabel,ylabel,title) | |
101 | self.getGrid = True |
|
101 | self.getGrid = True | |
102 | self.xaxisIsTime = False |
|
102 | self.xaxisIsTime = False | |
103 | self.deltax = deltax |
|
103 | self.deltax = deltax | |
104 | pass |
|
104 | pass | |
105 |
|
105 | |||
106 | def makeAxes(self,indexFig,nrow,ncol,subplot): |
|
106 | def makeAxes(self,indexFig,nrow,ncol,subplot): | |
107 | fig = plt.figure(indexFig) |
|
107 | fig = plt.figure(indexFig) | |
108 | self.__axesId = fig.add_subplot(nrow,ncol,subplot) |
|
108 | self.__axesId = fig.add_subplot(nrow,ncol,subplot) | |
109 |
|
109 | |||
110 | def setParentAxesId(self,parent): |
|
110 | def setParentAxesId(self,parent): | |
111 | self.__axesId = parent.__axesId |
|
111 | self.__axesId = parent.__axesId | |
112 |
|
112 | |||
113 | def setName(self, name): |
|
113 | def setName(self, name): | |
114 | self.__name = name |
|
114 | self.__name = name | |
115 |
|
115 | |||
116 | def setScreenPos(self,xpos,ypos): |
|
116 | def setScreenPos(self,xpos,ypos): | |
117 | self.__xpos = xpos |
|
117 | self.__xpos = xpos | |
118 | self.__ypos = ypos |
|
118 | self.__ypos = ypos | |
119 |
|
119 | |||
120 | def setSubPlot(self,subplot): |
|
120 | def setSubPlot(self,subplot): | |
121 | self.__subplot = subplot |
|
121 | self.__subplot = subplot | |
122 |
|
122 | |||
123 | def setXYZrange(self,xrange,yrange,zrange): |
|
123 | def setXYZrange(self,xrange,yrange,zrange): | |
124 | self.xrange = xrange |
|
124 | self.xrange = xrange | |
125 | self.yrange = yrange |
|
125 | self.yrange = yrange | |
126 | self.zrange = zrange |
|
126 | self.zrange = zrange | |
127 |
|
127 | |||
128 | def setSizeOfChar(self,szchar): |
|
128 | def setSizeOfChar(self,szchar): | |
129 | self.__szchar = szchar |
|
129 | self.__szchar = szchar | |
130 |
|
130 | |||
131 | def setLabels(self,xlabel=None,ylabel=None,title=None): |
|
131 | def setLabels(self,xlabel=None,ylabel=None,title=None): | |
132 | if xlabel != None: self.xlabel = xlabel |
|
132 | if xlabel != None: self.xlabel = xlabel | |
133 | if ylabel != None: self.ylabel = ylabel |
|
133 | if ylabel != None: self.ylabel = ylabel | |
134 | if title != None: self.title = title |
|
134 | if title != None: self.title = title | |
135 |
|
135 | |||
136 | def setXYData(self,xdata=None,ydata=None,datatype='real'): |
|
136 | def setXYData(self,xdata=None,ydata=None,datatype='real'): | |
137 | if ((xdata != None) and (ydata != None)): |
|
137 | if ((xdata != None) and (ydata != None)): | |
138 | self.xdata = xdata |
|
138 | self.xdata = xdata | |
139 | self.ydata = ydata |
|
139 | self.ydata = ydata | |
140 | self.datatype = datatype |
|
140 | self.datatype = datatype | |
141 | if ((self.xdata == None) and (self.ydata == None)): |
|
141 | if ((self.xdata == None) and (self.ydata == None)): | |
142 | return None |
|
142 | return None | |
143 | return 1 |
|
143 | return 1 | |
144 |
|
144 | |||
145 | def setLineStyle(self, style): |
|
145 | def setLineStyle(self, style): | |
146 | pass |
|
146 | pass | |
147 |
|
147 | |||
148 | def setColor(self, color): |
|
148 | def setColor(self, color): | |
149 | pass |
|
149 | pass | |
150 |
|
150 | |||
151 | def setXAxisAsTime(self, value=False): |
|
151 | def setXAxisAsTime(self, value=False): | |
152 | self.xaxisIsTime = value |
|
152 | self.xaxisIsTime = value | |
153 |
|
153 | |||
154 | def basicLineTimePlot(self, x, y, colline=1): |
|
154 | def basicLineTimePlot(self, x, y, colline=1): | |
155 | ax = self.__axesId |
|
155 | ax = self.__axesId | |
156 | if self.setXYData() == None: |
|
156 | if self.setXYData() == None: | |
157 | ax.plot(x,y) |
|
157 | ax.plot(x,y) | |
158 | plt.tight_layout() |
|
158 | plt.tight_layout() | |
159 | else: |
|
159 | else: | |
160 | ax.lines[0].set_data(x,y) |
|
160 | ax.lines[0].set_data(x,y) | |
161 |
|
161 | |||
162 | def basicXYPlot(self, x, y): |
|
162 | def basicXYPlot(self, x, y): | |
163 | ax = self.__axesId |
|
163 | ax = self.__axesId | |
164 | if self.setXYData() == None: |
|
164 | if self.setXYData() == None: | |
165 | ax.plot(x,y) |
|
165 | ax.plot(x,y) | |
166 | else: |
|
166 | else: | |
167 | ax.lines[0].set_data(x,y) |
|
167 | ax.lines[0].set_data(x,y) | |
168 |
|
168 | |||
169 | def basicPcolorPlot(self, data, x, y, xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None): |
|
169 | def basicPcolorPlot(self, data, x, y, xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None): | |
170 | pass |
|
170 | pass | |
171 |
|
171 | |||
172 | def __getBoxpltr(self, x, y, deltax=None, deltay=None): |
|
172 | def __getBoxpltr(self, x, y, deltax=None, deltay=None): | |
173 | pass |
|
173 | pass | |
174 |
|
174 | |||
175 | 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): |
|
175 | 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): | |
176 | ax = self.__axesId |
|
176 | ax = self.__axesId | |
177 | ax.pcolormesh(x,y,data.T,vmin=zmin,vmax=zmax) |
|
177 | ax.pcolormesh(x,y,data.T,vmin=zmin,vmax=zmax) | |
178 |
|
178 | |||
179 | def colorbarPlot(self, xmin=0., xmax=1., ymin=0., ymax=1.): |
|
179 | def colorbarPlot(self, xmin=0., xmax=1., ymin=0., ymax=1.): | |
180 | ax = self.__axesId |
|
180 | ax = self.__axesId | |
181 | cax, kw = mpl.colorbar.make_axes(ax) |
|
181 | cax, kw = mpl.colorbar.make_axes(ax) | |
182 | norm = mpl.colors.Normalize(vmin=ymin, vmax=ymax) |
|
182 | norm = mpl.colors.Normalize(vmin=ymin, vmax=ymax) | |
183 | cb = mpl.colorbar.ColorbarBase(cax,norm=norm,**kw) |
|
183 | cb = mpl.colorbar.ColorbarBase(cax,norm=norm,**kw) | |
184 | self.__colorbarId = cb |
|
184 | self.__colorbarId = cb | |
185 | cb.set_label(self.title) |
|
185 | cb.set_label(self.title) | |
186 |
|
186 | |||
187 | def plotBox(self, xmin, xmax, ymin, ymax, xopt, yopt, nolabels=False): |
|
187 | def plotBox(self, xmin, xmax, ymin, ymax, xopt, yopt, nolabels=False): | |
188 | ax = self.__axesId |
|
188 | ax = self.__axesId | |
189 | ax.set_xlim([xmin,xmax]) |
|
189 | ax.set_xlim([xmin,xmax]) | |
190 | ax.set_ylim([ymin,ymax]) |
|
190 | ax.set_ylim([ymin,ymax]) | |
191 |
|
191 | |||
192 | if not(nolabels): |
|
192 | if not(nolabels): | |
193 | ax.set_xlabel(self.xlabel) |
|
193 | ax.set_xlabel(self.xlabel) | |
194 | ax.set_ylabel(self.ylabel) |
|
194 | ax.set_ylabel(self.ylabel) | |
195 | ax.set_title(self.title) |
|
195 | ax.set_title(self.title) | |
196 |
|
196 | |||
197 | def delLabels(self): |
|
197 | def delLabels(self): | |
198 | pass |
|
198 | pass | |
199 |
|
199 | |||
200 | def plotImage(self,x,y,z,xrange,yrange,zrange): |
|
200 | def plotImage(self,x,y,z,xrange,yrange,zrange): | |
201 | pass |
|
201 | pass | |
202 |
|
202 | |||
203 |
|
203 | |||
204 | class LinearPlot(): |
|
204 | class LinearPlot(): | |
205 | linearObjDic = {} |
|
205 | linearObjDic = {} | |
206 | __xpos = None |
|
206 | __xpos = None | |
207 | __ypos = None |
|
207 | __ypos = None | |
208 | isPlotIni = None |
|
208 | isPlotIni = None | |
209 |
|
209 | |||
210 | def __init__(self, indexFig,nsubplot,winTitle): |
|
210 | def __init__(self, indexFig,nsubplot,winTitle): | |
211 | self.width = 700 |
|
211 | self.width = 700 | |
212 | self.height = 150 |
|
212 | self.height = 150 | |
213 | self.indexFig = indexFig |
|
213 | self.indexFig = indexFig | |
214 | self.ncol = 1 |
|
214 | self.ncol = 1 | |
215 | self.nrow = nsubplot |
|
215 | self.nrow = nsubplot | |
216 | initMatplotlib(indexFig,self.ncol,self.nrow,winTitle,self.width,self.height) |
|
216 | initMatplotlib(indexFig,self.ncol,self.nrow,winTitle,self.width,self.height) | |
217 |
|
217 | |||
218 | self.isPlotIni = False |
|
218 | self.isPlotIni = False | |
219 |
|
219 | |||
220 |
|
220 | |||
221 | def setFigure(self,indexFig): |
|
221 | def setFigure(self,indexFig): | |
222 | setFigure(indexFig) |
|
222 | setFigure(indexFig) | |
223 |
|
223 | |||
224 | def setNewPage(self, pltitle='No title'): |
|
224 | def setNewPage(self, pltitle='No title'): | |
225 | szchar = 0.7 |
|
225 | szchar = 0.7 | |
226 | # setNewPage() |
|
226 | # setNewPage() | |
227 | setPlTitle(pltitle,'black', szchar=szchar) |
|
227 | setPlTitle(pltitle,'black', szchar=szchar) | |
228 | setSubpages(self.ncol, self.nrow) |
|
228 | setSubpages(self.ncol, self.nrow) | |
229 |
|
229 | |||
230 | def setPosition(self): |
|
230 | def setPosition(self): | |
231 | xi = 0.07; xf = 0.9 |
|
231 | xi = 0.07; xf = 0.9 | |
232 | yi = 0.15; yf = 0.8 |
|
232 | yi = 0.15; yf = 0.8 | |
233 |
|
233 | |||
234 | xpos = [xi,xf] |
|
234 | xpos = [xi,xf] | |
235 | ypos = [yi,yf] |
|
235 | ypos = [yi,yf] | |
236 |
|
236 | |||
237 | self.__xpos = xpos |
|
237 | self.__xpos = xpos | |
238 | self.__ypos = ypos |
|
238 | self.__ypos = ypos | |
239 |
|
239 | |||
240 | return xpos,ypos |
|
240 | return xpos,ypos | |
241 |
|
241 | |||
242 | def createObjects(self,subplot,xmin,xmax,ymin,ymax,title,xlabel,ylabel): |
|
242 | def createObjects(self,subplot,xmin,xmax,ymin,ymax,title,xlabel,ylabel): | |
243 | szchar = 0.7 |
|
243 | szchar = 0.7 | |
244 | name = 'linear' |
|
244 | name = 'linear' | |
245 | key = name + '%d'%subplot |
|
245 | key = name + '%d'%subplot | |
246 | xrange = [xmin,xmax] |
|
246 | xrange = [xmin,xmax] | |
247 | yrange = [ymin,ymax] |
|
247 | yrange = [ymin,ymax] | |
248 |
|
248 | |||
249 | xpos,ypos = self.setPosition() |
|
249 | xpos,ypos = self.setPosition() | |
250 | linearObj = BaseGraph(name,subplot,xpos,ypos,xlabel,ylabel,title,szchar,xrange,yrange) |
|
250 | linearObj = BaseGraph(name,subplot,xpos,ypos,xlabel,ylabel,title,szchar,xrange,yrange) | |
251 | self.linearObjDic[key] = linearObj |
|
251 | self.linearObjDic[key] = linearObj | |
252 |
|
252 | |||
253 | def iniPlot(self,subplot): |
|
253 | def iniPlot(self,subplot): | |
254 | name = 'linear' |
|
254 | name = 'linear' | |
255 | key = name + '%d'%subplot |
|
255 | key = name + '%d'%subplot | |
256 |
|
256 | |||
257 | linearObj = self.linearObjDic[key] |
|
257 | linearObj = self.linearObjDic[key] | |
258 | linearObj.makeAxes(self.indexFig,self.nrow,self.ncol,subplot) |
|
258 | linearObj.makeAxes(self.indexFig,self.nrow,self.ncol,subplot) | |
259 | linearObj.plotBox(linearObj.xrange[0], linearObj.xrange[1], linearObj.yrange[0], linearObj.yrange[1], 'bcnst', 'bcnstv') |
|
259 | linearObj.plotBox(linearObj.xrange[0], linearObj.xrange[1], linearObj.yrange[0], linearObj.yrange[1], 'bcnst', 'bcnstv') | |
260 |
|
260 | |||
261 |
|
261 | |||
262 | def plot(self,subplot,x,y,type='abs'): |
|
262 | def plot(self,subplot,x,y,type='abs'): | |
263 | name = 'linear' |
|
263 | name = 'linear' | |
264 | key = name + '%d'%subplot |
|
264 | key = name + '%d'%subplot | |
265 |
|
265 | |||
266 | linearObj = self.linearObjDic[key] |
|
266 | linearObj = self.linearObjDic[key] | |
267 |
|
267 | |||
268 | if type.lower() == 'simple': |
|
268 | if type.lower() == 'simple': | |
269 | colline = 9 |
|
269 | colline = 9 | |
270 | linearObj.basicLineTimePlot(x, y) |
|
270 | linearObj.basicLineTimePlot(x, y) | |
271 | linearObj.setXYData(x,y,'real') |
|
271 | linearObj.setXYData(x,y,'real') | |
272 |
|
272 | |||
273 | def refresh(self): |
|
273 | def refresh(self): | |
274 | refresh() |
|
274 | refresh() | |
275 |
|
275 | |||
276 | def show(self): |
|
276 | def show(self): | |
277 | show() |
|
277 | show() | |
278 |
|
278 | |||
279 | class PcolorPlot: |
|
279 | class PcolorPlot: | |
280 |
|
280 | |||
281 | pcolorObjDic = {} |
|
281 | pcolorObjDic = {} | |
282 | colorbarObjDic = {} |
|
282 | colorbarObjDic = {} | |
283 | pwprofileObjDic = {} |
|
283 | pwprofileObjDic = {} | |
284 | showColorbar = None |
|
284 | showColorbar = None | |
285 | showPowerProfile = None |
|
285 | showPowerProfile = None | |
286 | XAxisAsTime = None |
|
286 | XAxisAsTime = None | |
287 | width = None |
|
287 | width = None | |
288 | height = None |
|
288 | height = None | |
289 | __spcxpos = None |
|
289 | __spcxpos = None | |
290 | __spcypos = None |
|
290 | __spcypos = None | |
291 | __cmapxpos = None |
|
291 | __cmapxpos = None | |
292 | __cmapypos = None |
|
292 | __cmapypos = None | |
293 | __profxpos = None |
|
293 | __profxpos = None | |
294 | __profypos = None |
|
294 | __profypos = None | |
295 | __lastTitle = None |
|
295 | __lastTitle = None | |
296 |
|
296 | |||
297 | def __init__(self,indexFig,nsubplot,winTitle,colormap,showColorbar,showPowerProfile,XAxisAsTime): |
|
297 | def __init__(self,indexFig,nsubplot,winTitle,colormap,showColorbar,showPowerProfile,XAxisAsTime): | |
298 |
|
298 | |||
299 | self.width = 460 |
|
299 | self.width = 460 | |
300 | self.height = 300 |
|
300 | self.height = 300 | |
301 | self.showColorbar = showColorbar |
|
301 | self.showColorbar = showColorbar | |
302 | self.showPowerProfile = showPowerProfile |
|
302 | self.showPowerProfile = showPowerProfile | |
303 | self.XAxisAsTime = XAxisAsTime |
|
303 | self.XAxisAsTime = XAxisAsTime | |
304 |
|
304 | |||
305 | ncol = int(numpy.sqrt(nsubplot)+0.9) |
|
305 | ncol = int(numpy.sqrt(nsubplot)+0.9) | |
306 | nrow = int(nsubplot*1./ncol + 0.9) |
|
306 | nrow = int(nsubplot*1./ncol + 0.9) | |
307 |
|
307 | |||
308 | self.ncol = ncol |
|
308 | self.ncol = ncol | |
309 | self.nrow = nrow |
|
309 | self.nrow = nrow | |
310 | self.indexFig = indexFig |
|
310 | self.indexFig = indexFig | |
311 |
|
311 | |||
312 | initMatplotlib(indexFig,ncol,nrow,winTitle,self.width,self.height) |
|
312 | initMatplotlib(indexFig,ncol,nrow,winTitle,self.width,self.height) | |
313 | setColormap(colormap) |
|
313 | setColormap(colormap) | |
314 |
|
314 | |||
315 | def setFigure(self,indexFig): |
|
315 | def setFigure(self,indexFig): | |
316 | setFigure(indexFig) |
|
316 | setFigure(indexFig) | |
317 |
|
317 | |||
318 | def setSpectraPos(self): #modificar valores de acuerdo al colorbar y pwprofile |
|
318 | def setSpectraPos(self): #modificar valores de acuerdo al colorbar y pwprofile | |
319 | if self.showPowerProfile: xi = 0.09; xf = 0.6 #0.075 |
|
319 | if self.showPowerProfile: xi = 0.09; xf = 0.6 #0.075 | |
320 | else: xi = 0.15; xf = 0.8 #0.8,0.7,0.5 |
|
320 | else: xi = 0.15; xf = 0.8 #0.8,0.7,0.5 | |
321 | yi = 0.15; yf = 0.80 |
|
321 | yi = 0.15; yf = 0.80 | |
322 |
|
322 | |||
323 | xpos = [xi,xf] |
|
323 | xpos = [xi,xf] | |
324 | ypos = [yi,yf] |
|
324 | ypos = [yi,yf] | |
325 |
|
325 | |||
326 | self.__spcxpos = xpos |
|
326 | self.__spcxpos = xpos | |
327 | self.__spcypos = ypos |
|
327 | self.__spcypos = ypos | |
328 |
|
328 | |||
329 | return xpos,ypos |
|
329 | return xpos,ypos | |
330 |
|
330 | |||
331 | def setColorbarScreenPos(self): |
|
331 | def setColorbarScreenPos(self): | |
332 |
|
332 | |||
333 | xi = self.__spcxpos[1] + 0.03; xf = xi + 0.03 |
|
333 | xi = self.__spcxpos[1] + 0.03; xf = xi + 0.03 | |
334 | yi = self.__spcypos[0]; yf = self.__spcypos[1] |
|
334 | yi = self.__spcypos[0]; yf = self.__spcypos[1] | |
335 |
|
335 | |||
336 | xpos = [xi,xf] |
|
336 | xpos = [xi,xf] | |
337 | ypos = [yi,yf] |
|
337 | ypos = [yi,yf] | |
338 |
|
338 | |||
339 | self.__cmapxpos = xpos |
|
339 | self.__cmapxpos = xpos | |
340 | self.__cmapypos = ypos |
|
340 | self.__cmapypos = ypos | |
341 |
|
341 | |||
342 | return xpos,ypos |
|
342 | return xpos,ypos | |
343 |
|
343 | |||
344 | def setPowerprofileScreenPos(self): |
|
344 | def setPowerprofileScreenPos(self): | |
345 |
|
345 | |||
346 | xi = self.__cmapxpos[1] + 0.07; xf = xi + 0.25 |
|
346 | xi = self.__cmapxpos[1] + 0.07; xf = xi + 0.25 | |
347 | yi = self.__spcypos[0]; yf = self.__spcypos[1] |
|
347 | yi = self.__spcypos[0]; yf = self.__spcypos[1] | |
348 |
|
348 | |||
349 | xpos = [xi,xf] |
|
349 | xpos = [xi,xf] | |
350 | ypos = [yi,yf] |
|
350 | ypos = [yi,yf] | |
351 |
|
351 | |||
352 | self.__profxpos = [xi,xf] |
|
352 | self.__profxpos = [xi,xf] | |
353 | self.__profypos = [yi,yf] |
|
353 | self.__profypos = [yi,yf] | |
354 |
|
354 | |||
355 | return xpos,ypos |
|
355 | return xpos,ypos | |
356 |
|
356 | |||
357 | def createObjects(self,subplot,xmin,xmax,ymin,ymax,zmin,zmax,title,xlabel,ylabel): |
|
357 | def createObjects(self,subplot,xmin,xmax,ymin,ymax,zmin,zmax,title,xlabel,ylabel): | |
358 |
|
358 | |||
359 | ''' |
|
359 | ''' | |
360 | Crea los objetos necesarios para un subplot |
|
360 | Crea los objetos necesarios para un subplot | |
361 | ''' |
|
361 | ''' | |
362 |
|
362 | |||
363 | # Config Spectra plot |
|
363 | # Config Spectra plot | |
364 |
|
364 | |||
365 | szchar = 0.7 |
|
365 | szchar = 0.7 | |
366 | name = 'spc' |
|
366 | name = 'spc' | |
367 | key = name + '%d'%subplot |
|
367 | key = name + '%d'%subplot | |
368 | xrange = [xmin,xmax] |
|
368 | xrange = [xmin,xmax] | |
369 | yrange = [ymin,ymax] |
|
369 | yrange = [ymin,ymax] | |
370 | zrange = [zmin,zmax] |
|
370 | zrange = [zmin,zmax] | |
371 |
|
371 | |||
372 | xpos,ypos = self.setSpectraPos() |
|
372 | xpos,ypos = self.setSpectraPos() | |
373 | pcolorObj = BaseGraph(name,subplot,xpos,ypos,xlabel,ylabel,title,szchar,xrange,yrange,zrange) |
|
373 | pcolorObj = BaseGraph(name,subplot,xpos,ypos,xlabel,ylabel,title,szchar,xrange,yrange,zrange) | |
374 | #pcolorObj.makeAxes(self.indexFig,self.nrow,self.ncol,subplot) |
|
374 | #pcolorObj.makeAxes(self.indexFig,self.nrow,self.ncol,subplot) | |
375 | self.pcolorObjDic[key] = pcolorObj |
|
375 | self.pcolorObjDic[key] = pcolorObj | |
376 |
|
376 | |||
377 | # Config Colorbar |
|
377 | # Config Colorbar | |
378 | if self.showColorbar: |
|
378 | if self.showColorbar: | |
379 | szchar = 0.65 |
|
379 | szchar = 0.65 | |
380 | name = 'colorbar' |
|
380 | name = 'colorbar' | |
381 | key = name + '%d'%subplot |
|
381 | key = name + '%d'%subplot | |
382 |
|
382 | |||
383 | xpos,ypos = self.setColorbarScreenPos() |
|
383 | xpos,ypos = self.setColorbarScreenPos() | |
384 | xrange = [0.,1.] |
|
384 | xrange = [0.,1.] | |
385 | yrange = [zmin,zmax] |
|
385 | yrange = [zmin,zmax] | |
386 | cmapObj = BaseGraph(name,subplot,xpos,ypos,'','','dB',szchar,xrange,yrange) |
|
386 | cmapObj = BaseGraph(name,subplot,xpos,ypos,'','','dB',szchar,xrange,yrange) | |
387 | self.colorbarObjDic[key] = cmapObj |
|
387 | self.colorbarObjDic[key] = cmapObj | |
388 |
|
388 | |||
389 | # Config Power profile |
|
389 | # Config Power profile | |
390 | if self.showPowerProfile: |
|
390 | if self.showPowerProfile: | |
391 | szchar = 0.55 |
|
391 | szchar = 0.55 | |
392 | name = 'pwprofile' |
|
392 | name = 'pwprofile' | |
393 | key = name + '%d'%subplot |
|
393 | key = name + '%d'%subplot | |
394 |
|
394 | |||
395 | xpos,ypos = self.setPowerprofileScreenPos() |
|
395 | xpos,ypos = self.setPowerprofileScreenPos() | |
396 | xrange = [zmin,zmax] |
|
396 | xrange = [zmin,zmax] | |
397 | yrange = [ymin,ymax] |
|
397 | yrange = [ymin,ymax] | |
398 | powObj = BaseGraph(name,subplot,xpos,ypos,'dB','','Power Profile',szchar,xrange,yrange) |
|
398 | powObj = BaseGraph(name,subplot,xpos,ypos,'dB','','Power Profile',szchar,xrange,yrange) | |
399 | #powObj.makeAxes(self.indexFig,self.nrow,self.ncol,subplot) |
|
399 | #powObj.makeAxes(self.indexFig,self.nrow,self.ncol,subplot) | |
400 | self.pwprofileObjDic[key] = powObj |
|
400 | self.pwprofileObjDic[key] = powObj | |
401 |
|
401 | |||
402 | def setNewPage(self, pltitle='No title'): |
|
402 | def setNewPage(self, pltitle='No title'): | |
403 | szchar = 0.7 |
|
403 | szchar = 0.7 | |
404 | setNewPage() |
|
404 | setNewPage() | |
405 | setPlTitle(pltitle,'black', szchar=szchar) |
|
405 | setPlTitle(pltitle,'black', szchar=szchar) | |
406 | setSubpages(self.ncol, self.nrow) |
|
406 | setSubpages(self.ncol, self.nrow) | |
407 |
|
407 | |||
408 | def closePage(self): |
|
408 | def closePage(self): | |
409 | closePage() |
|
409 | closePage() | |
410 |
|
410 | |||
411 | def show(self): |
|
411 | def show(self): | |
412 | show() |
|
412 | show() | |
413 |
|
413 | |||
414 | def iniPlot(self,subplot): |
|
414 | def iniPlot(self,subplot): | |
415 | ''' |
|
415 | ''' | |
416 | Inicializa los subplots con su frame, titulo, etc |
|
416 | Inicializa los subplots con su frame, titulo, etc | |
417 | ''' |
|
417 | ''' | |
418 |
|
418 | |||
419 | # Config Spectra plot |
|
419 | # Config Spectra plot | |
420 | name = 'spc' |
|
420 | name = 'spc' | |
421 | key = name + '%d'%subplot |
|
421 | key = name + '%d'%subplot | |
422 |
|
422 | |||
423 | pcolorObj = self.pcolorObjDic[key] |
|
423 | pcolorObj = self.pcolorObjDic[key] | |
424 | pcolorObj.makeAxes(self.indexFig,self.nrow,self.ncol,subplot) |
|
424 | pcolorObj.makeAxes(self.indexFig,self.nrow,self.ncol,subplot) | |
425 | pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], 'bcnst', 'bcnstv') |
|
425 | pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], 'bcnst', 'bcnstv') | |
426 |
|
426 | |||
427 | # Config Colorbar |
|
427 | # Config Colorbar | |
428 | if self.showColorbar: |
|
428 | if self.showColorbar: | |
429 | name = 'colorbar' |
|
429 | name = 'colorbar' | |
430 | key = name + '%d'%subplot |
|
430 | key = name + '%d'%subplot | |
431 |
|
431 | |||
432 | cmapObj = self.colorbarObjDic[key] |
|
432 | cmapObj = self.colorbarObjDic[key] | |
433 | cmapObj.setParentAxesId(pcolorObj) |
|
433 | cmapObj.setParentAxesId(pcolorObj) | |
434 | # cmapObj.plotBox(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1], 'bc', 'bcmtsv') |
|
434 | # cmapObj.plotBox(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1], 'bc', 'bcmtsv') | |
435 | cmapObj.colorbarPlot(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1]) |
|
435 | cmapObj.colorbarPlot(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1]) | |
436 | # cmapObj.plotBox(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1], 'bc', 'bcmtsv') |
|
436 | # cmapObj.plotBox(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1], 'bc', 'bcmtsv') | |
437 |
|
437 | |||
438 | # Config Power profile |
|
438 | # Config Power profile | |
439 | if self.showPowerProfile: |
|
439 | if self.showPowerProfile: | |
440 | name = 'pwprofile' |
|
440 | name = 'pwprofile' | |
441 | key = name + '%d'%subplot |
|
441 | key = name + '%d'%subplot | |
442 |
|
442 | |||
443 | powObj = self.pwprofileObjDic[key] |
|
443 | powObj = self.pwprofileObjDic[key] | |
444 | powObj.setLineStyle(2) |
|
444 | powObj.setLineStyle(2) | |
445 | powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], 'bcntg', 'bc') |
|
445 | powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], 'bcntg', 'bc') | |
446 | powObj.setLineStyle(1) |
|
446 | powObj.setLineStyle(1) | |
447 | powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], 'bc', 'bc') |
|
447 | powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], 'bc', 'bc') | |
448 |
|
448 | |||
449 | def printTitle(self,pltitle): |
|
449 | def printTitle(self,pltitle): | |
450 |
|
450 | |||
451 | setPlTitle(pltitle,'black') |
|
451 | setPlTitle(pltitle,'black') | |
452 |
|
452 | |||
453 | def plot(self,subplot,x,y,z,subtitle=''): |
|
453 | def plot(self,subplot,x,y,z,subtitle=''): | |
454 | # Spectra plot |
|
454 | # Spectra plot | |
455 |
|
455 | |||
456 | name = 'spc' |
|
456 | name = 'spc' | |
457 | key = name + '%d'%subplot |
|
457 | key = name + '%d'%subplot | |
458 |
|
458 | |||
459 | # newx = [x[0],x[-1]] |
|
459 | # newx = [x[0],x[-1]] | |
460 | pcolorObj = self.pcolorObjDic[key] |
|
460 | pcolorObj = self.pcolorObjDic[key] | |
461 | # pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], 'bcst', 'bcst') |
|
461 | # pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], 'bcst', 'bcst') | |
462 |
|
462 | |||
463 | #pcolorObj.delLabels() |
|
463 | #pcolorObj.delLabels() | |
464 | pcolorObj.setLabels(title=subtitle) |
|
464 | pcolorObj.setLabels(title=subtitle) | |
465 |
|
465 | |||
466 | deltax = None; deltay = None |
|
466 | deltax = None; deltay = None | |
467 |
|
467 | |||
468 | pcolorObj.advPcolorPlot(z, |
|
468 | pcolorObj.advPcolorPlot(z, | |
469 | x, |
|
469 | x, | |
470 | y, |
|
470 | y, | |
471 | xmin=pcolorObj.xrange[0], |
|
471 | xmin=pcolorObj.xrange[0], | |
472 | xmax=pcolorObj.xrange[1], |
|
472 | xmax=pcolorObj.xrange[1], | |
473 | ymin=pcolorObj.yrange[0], |
|
473 | ymin=pcolorObj.yrange[0], | |
474 | ymax=pcolorObj.yrange[1], |
|
474 | ymax=pcolorObj.yrange[1], | |
475 | zmin=pcolorObj.zrange[0], |
|
475 | zmin=pcolorObj.zrange[0], | |
476 | zmax=pcolorObj.zrange[1], |
|
476 | zmax=pcolorObj.zrange[1], | |
477 | deltax=deltax, |
|
477 | deltax=deltax, | |
478 | deltay=deltay, |
|
478 | deltay=deltay, | |
479 | getGrid=pcolorObj.getGrid) |
|
479 | getGrid=pcolorObj.getGrid) | |
480 |
|
480 | |||
481 | #Solo se calcula la primera vez que se ingresa a la funcion |
|
481 | #Solo se calcula la primera vez que se ingresa a la funcion | |
482 | pcolorObj.getGrid = False |
|
482 | pcolorObj.getGrid = False | |
483 |
|
483 | |||
484 | #pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], 'bcst', 'bcst', nolabels=True) |
|
484 | #pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], 'bcst', 'bcst', nolabels=True) | |
485 |
|
485 | |||
486 | # Power Profile |
|
486 | # Power Profile | |
487 | if self.showPowerProfile: |
|
487 | if self.showPowerProfile: | |
488 | power = numpy.average(z, axis=0) |
|
488 | power = numpy.average(z, axis=0) | |
489 | name = 'pwprofile' |
|
489 | name = 'pwprofile' | |
490 | key = name + '%d'%subplot |
|
490 | key = name + '%d'%subplot | |
491 | powObj = self.pwprofileObjDic[key] |
|
491 | powObj = self.pwprofileObjDic[key] | |
492 |
|
492 | |||
493 | if powObj.setXYData() != None: |
|
493 | if powObj.setXYData() != None: | |
494 | #clearData(powObj) |
|
494 | #clearData(powObj) | |
495 | powObj.setLineStyle(2) |
|
495 | powObj.setLineStyle(2) | |
496 | powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], 'bcntg', 'bc') |
|
496 | powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], 'bcntg', 'bc') | |
497 | powObj.setLineStyle(1) |
|
497 | powObj.setLineStyle(1) | |
498 | else: |
|
498 | else: | |
499 | powObj.setXYData(power,y) |
|
499 | powObj.setXYData(power,y) | |
500 |
|
500 | |||
501 | powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], 'bc', 'bc') |
|
501 | powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], 'bc', 'bc') | |
502 | powObj.basicXYPlot(power,y) |
|
502 | powObj.basicXYPlot(power,y) | |
503 | powObj.setXYData(power,y) |
|
503 | powObj.setXYData(power,y) | |
504 |
|
504 | |||
505 | def savePlot(self,indexFig,filename): |
|
505 | def savePlot(self,indexFig,filename): | |
506 |
|
506 | |||
507 | width = self.width*self.ncol |
|
507 | width = self.width*self.ncol | |
508 | hei = self.height*self.nrow |
|
508 | hei = self.height*self.nrow | |
509 | savePlplot(filename,width,hei) |
|
509 | savePlplot(filename,width,hei) | |
510 |
|
510 | |||
511 | def refresh(self): |
|
511 | def refresh(self): | |
512 | refresh() |
|
512 | refresh() | |
513 |
|
513 | |||
514 | class RtiPlot: |
|
514 | class RtiPlot: | |
515 |
|
515 | |||
516 | pcolorObjDic = {} |
|
516 | pcolorObjDic = {} | |
517 | colorbarObjDic = {} |
|
517 | colorbarObjDic = {} | |
518 | pwprofileObjDic = {} |
|
518 | pwprofileObjDic = {} | |
519 | showColorbar = None |
|
519 | showColorbar = None | |
520 | showPowerProfile = None |
|
520 | showPowerProfile = None | |
521 | XAxisAsTime = None |
|
521 | XAxisAsTime = None | |
522 | widht = None |
|
522 | widht = None | |
523 | height = None |
|
523 | height = None | |
524 | __rtixpos = None |
|
524 | __rtixpos = None | |
525 | __rtiypos = None |
|
525 | __rtiypos = None | |
526 | __cmapxpos = None |
|
526 | __cmapxpos = None | |
527 | __cmapypos = None |
|
527 | __cmapypos = None | |
528 | __profxpos = None |
|
528 | __profxpos = None | |
529 | __profypos = None |
|
529 | __profypos = None | |
530 |
|
530 | |||
531 | def __init__(self,indexFig,nsubplot,winTitle,colormap,showColorbar,showPowerProfile,XAxisAsTime): |
|
531 | def __init__(self,indexFig,nsubplot,winTitle,colormap,showColorbar,showPowerProfile,XAxisAsTime): | |
532 | self.width = 700 |
|
532 | self.width = 700 | |
533 | self.height = 150 |
|
533 | self.height = 150 | |
534 | self.showColorbar = showColorbar |
|
534 | self.showColorbar = showColorbar | |
535 | self.showPowerProfile = showPowerProfile |
|
535 | self.showPowerProfile = showPowerProfile | |
536 | self.XAxisAsTime = XAxisAsTime |
|
536 | self.XAxisAsTime = XAxisAsTime | |
537 |
|
537 | |||
538 | ncol = 1 |
|
538 | ncol = 1 | |
539 | nrow = nsubplot |
|
539 | nrow = nsubplot | |
540 | initMatplotlib(indexFig,ncol,nrow,winTitle,self.width,self.height) |
|
540 | initMatplotlib(indexFig,ncol,nrow,winTitle,self.width,self.height) | |
541 | setColormap(colormap) |
|
541 | setColormap(colormap) | |
542 | self.ncol = ncol |
|
542 | self.ncol = ncol | |
543 | self.nrow = nrow |
|
543 | self.nrow = nrow | |
544 |
|
544 | |||
545 | def setFigure(self,indexFig): |
|
545 | def setFigure(self,indexFig): | |
546 | setFigure(indexFig) |
|
546 | setFigure(indexFig) | |
547 |
|
547 | |||
548 | def setRtiScreenPos(self): |
|
548 | def setRtiScreenPos(self): | |
549 |
|
549 | |||
550 | if self.showPowerProfile: xi = 0.07; xf = 0.65 |
|
550 | if self.showPowerProfile: xi = 0.07; xf = 0.65 | |
551 | else: xi = 0.07; xf = 0.9 |
|
551 | else: xi = 0.07; xf = 0.9 | |
552 | yi = 0.15; yf = 0.80 |
|
552 | yi = 0.15; yf = 0.80 | |
553 |
|
553 | |||
554 | xpos = [xi,xf] |
|
554 | xpos = [xi,xf] | |
555 | ypos = [yi,yf] |
|
555 | ypos = [yi,yf] | |
556 |
|
556 | |||
557 | self.__rtixpos = xpos |
|
557 | self.__rtixpos = xpos | |
558 | self.__rtiypos = ypos |
|
558 | self.__rtiypos = ypos | |
559 |
|
559 | |||
560 | return xpos,ypos |
|
560 | return xpos,ypos | |
561 |
|
561 | |||
562 | def setColorbarScreenPos(self): |
|
562 | def setColorbarScreenPos(self): | |
563 |
|
563 | |||
564 | xi = self.__rtixpos[1] + 0.03; xf = xi + 0.03 |
|
564 | xi = self.__rtixpos[1] + 0.03; xf = xi + 0.03 | |
565 |
|
565 | |||
566 | yi = self.__rtiypos[0]; yf = self.__rtiypos[1] |
|
566 | yi = self.__rtiypos[0]; yf = self.__rtiypos[1] | |
567 |
|
567 | |||
568 | xpos = [xi,xf] |
|
568 | xpos = [xi,xf] | |
569 | ypos = [yi,yf] |
|
569 | ypos = [yi,yf] | |
570 |
|
570 | |||
571 | self.__cmapxpos = xpos |
|
571 | self.__cmapxpos = xpos | |
572 | self.__cmapypos = ypos |
|
572 | self.__cmapypos = ypos | |
573 |
|
573 | |||
574 | return xpos,ypos |
|
574 | return xpos,ypos | |
575 |
|
575 | |||
576 | def setPowerprofileScreenPos(self): |
|
576 | def setPowerprofileScreenPos(self): | |
577 |
|
577 | |||
578 | xi = self.__cmapxpos[1] + 0.05; xf = xi + 0.20 |
|
578 | xi = self.__cmapxpos[1] + 0.05; xf = xi + 0.20 | |
579 |
|
579 | |||
580 | yi = self.__rtiypos[0]; yf = self.__rtiypos[1] |
|
580 | yi = self.__rtiypos[0]; yf = self.__rtiypos[1] | |
581 |
|
581 | |||
582 | xpos = [xi,xf] |
|
582 | xpos = [xi,xf] | |
583 | ypos = [yi,yf] |
|
583 | ypos = [yi,yf] | |
584 |
|
584 | |||
585 | self.__profxpos = [xi,xf] |
|
585 | self.__profxpos = [xi,xf] | |
586 | self.__profypos = [yi,yf] |
|
586 | self.__profypos = [yi,yf] | |
587 |
|
587 | |||
588 | return xpos,ypos |
|
588 | return xpos,ypos | |
589 |
|
589 | |||
590 | def setup(self,subplot,xmin,xmax,ymin,ymax,zmin,zmax,title,xlabel,ylabel,timedata,timezone='lt',npoints=100): |
|
590 | def setup(self,subplot,xmin,xmax,ymin,ymax,zmin,zmax,title,xlabel,ylabel,timedata,timezone='lt',npoints=100): | |
591 | # Config Rti plot |
|
591 | # Config Rti plot | |
592 | szchar = 1.10 |
|
592 | szchar = 1.10 | |
593 | name = 'rti' |
|
593 | name = 'rti' | |
594 | key = name + '%d'%subplot |
|
594 | key = name + '%d'%subplot | |
595 |
|
595 | |||
596 | # xmin, xmax --> minHour, max Hour : valores que definen el ejex x=[horaInicio,horaFinal] |
|
596 | # xmin, xmax --> minHour, max Hour : valores que definen el ejex x=[horaInicio,horaFinal] | |
597 | thisDateTime = datetime.datetime.fromtimestamp(timedata) |
|
597 | thisDateTime = datetime.datetime.fromtimestamp(timedata) | |
598 | startDateTime = datetime.datetime(thisDateTime.year,thisDateTime.month,thisDateTime.day,xmin,0,0) |
|
598 | startDateTime = datetime.datetime(thisDateTime.year,thisDateTime.month,thisDateTime.day,xmin,0,0) | |
599 | endDateTime = datetime.datetime(thisDateTime.year,thisDateTime.month,thisDateTime.day,xmax,59,59) |
|
599 | endDateTime = datetime.datetime(thisDateTime.year,thisDateTime.month,thisDateTime.day,xmax,59,59) | |
600 | deltaTime = 0 |
|
600 | deltaTime = 0 | |
601 | if timezone == 'lt': |
|
601 | if timezone == 'lt': | |
602 | deltaTime = time.timezone |
|
602 | deltaTime = time.timezone | |
603 | startTimeInSecs = time.mktime(startDateTime.timetuple()) - deltaTime |
|
603 | startTimeInSecs = time.mktime(startDateTime.timetuple()) - deltaTime | |
604 | endTimeInSecs = time.mktime(endDateTime.timetuple()) - deltaTime |
|
604 | endTimeInSecs = time.mktime(endDateTime.timetuple()) - deltaTime | |
605 |
|
605 | |||
606 | xrange = [startTimeInSecs,endTimeInSecs] |
|
606 | xrange = [startTimeInSecs,endTimeInSecs] | |
607 | totalTimeInXrange = endTimeInSecs - startTimeInSecs + 1. |
|
607 | totalTimeInXrange = endTimeInSecs - startTimeInSecs + 1. | |
608 | deltax = totalTimeInXrange / npoints |
|
608 | deltax = totalTimeInXrange / npoints | |
609 |
|
609 | |||
610 | yrange = [ymin,ymax] |
|
610 | yrange = [ymin,ymax] | |
611 | zrange = [zmin,zmax] |
|
611 | zrange = [zmin,zmax] | |
612 |
|
612 | |||
613 | xpos,ypos = self.setRtiScreenPos() |
|
613 | xpos,ypos = self.setRtiScreenPos() | |
614 | pcolorObj = BaseGraph(name,subplot,xpos,ypos,xlabel,ylabel,title,szchar,xrange,yrange,zrange,deltax) |
|
614 | pcolorObj = BaseGraph(name,subplot,xpos,ypos,xlabel,ylabel,title,szchar,xrange,yrange,zrange,deltax) | |
615 | if self.XAxisAsTime: |
|
615 | if self.XAxisAsTime: | |
616 | pcolorObj.setXAxisAsTime(self.XAxisAsTime) |
|
616 | pcolorObj.setXAxisAsTime(self.XAxisAsTime) | |
617 | xopt = 'bcnstd' |
|
617 | xopt = 'bcnstd' | |
618 | yopt = 'bcnstv' |
|
618 | yopt = 'bcnstv' | |
619 | else: |
|
619 | else: | |
620 | xopt = 'bcnst' |
|
620 | xopt = 'bcnst' | |
621 | yopt = 'bcnstv' |
|
621 | yopt = 'bcnstv' | |
622 |
|
622 | |||
623 | pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], xopt, yopt) |
|
623 | pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], xopt, yopt) | |
624 | self.pcolorObjDic[key] = pcolorObj |
|
624 | self.pcolorObjDic[key] = pcolorObj | |
625 |
|
625 | |||
626 |
|
626 | |||
627 | # Config Colorbar |
|
627 | # Config Colorbar | |
628 | if self.showColorbar: |
|
628 | if self.showColorbar: | |
629 | szchar = 0.9 |
|
629 | szchar = 0.9 | |
630 | name = 'colorbar' |
|
630 | name = 'colorbar' | |
631 | key = name + '%d'%subplot |
|
631 | key = name + '%d'%subplot | |
632 |
|
632 | |||
633 | xpos,ypos = self.setColorbarScreenPos() |
|
633 | xpos,ypos = self.setColorbarScreenPos() | |
634 | xrange = [0.,1.] |
|
634 | xrange = [0.,1.] | |
635 | yrange = [zmin,zmax] |
|
635 | yrange = [zmin,zmax] | |
636 | cmapObj = BaseGraph(name,subplot,xpos,ypos,'','','dB',szchar,xrange,yrange) |
|
636 | cmapObj = BaseGraph(name,subplot,xpos,ypos,'','','dB',szchar,xrange,yrange) | |
637 | cmapObj.plotBox(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1], 'bc', 'bcm') |
|
637 | cmapObj.plotBox(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1], 'bc', 'bcm') | |
638 | cmapObj.colorbarPlot(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1]) |
|
638 | cmapObj.colorbarPlot(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1]) | |
639 | cmapObj.plotBox(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1], 'bc', 'bcmtsv') |
|
639 | cmapObj.plotBox(cmapObj.xrange[0], cmapObj.xrange[1], cmapObj.yrange[0], cmapObj.yrange[1], 'bc', 'bcmtsv') | |
640 | self.colorbarObjDic[key] = cmapObj |
|
640 | self.colorbarObjDic[key] = cmapObj | |
641 |
|
641 | |||
642 |
|
642 | |||
643 | # Config Power profile |
|
643 | # Config Power profile | |
644 | if self.showPowerProfile: |
|
644 | if self.showPowerProfile: | |
645 | szchar = 0.8 |
|
645 | szchar = 0.8 | |
646 | name = 'pwprofile' |
|
646 | name = 'pwprofile' | |
647 | key = name + '%d'%subplot |
|
647 | key = name + '%d'%subplot | |
648 |
|
648 | |||
649 | xpos,ypos = self.setPowerprofileScreenPos() |
|
649 | xpos,ypos = self.setPowerprofileScreenPos() | |
650 | xrange = [zmin,zmax] |
|
650 | xrange = [zmin,zmax] | |
651 | yrange = [ymin,ymax] |
|
651 | yrange = [ymin,ymax] | |
652 | powObj = BaseGraph(name,subplot,xpos,ypos,'dB','','Power Profile',szchar,xrange,yrange) |
|
652 | powObj = BaseGraph(name,subplot,xpos,ypos,'dB','','Power Profile',szchar,xrange,yrange) | |
653 | powObj.setLineStyle(2) |
|
653 | powObj.setLineStyle(2) | |
654 | powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], 'bcntg', 'bc') |
|
654 | powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], 'bcntg', 'bc') | |
655 | powObj.setLineStyle(1) |
|
655 | powObj.setLineStyle(1) | |
656 | powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], 'bc', 'bc') |
|
656 | powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], 'bc', 'bc') | |
657 | self.pwprofileObjDic[key] = powObj |
|
657 | self.pwprofileObjDic[key] = powObj | |
658 |
|
658 | |||
659 |
|
659 | |||
660 | def plot(self,subplot,x,y,z): |
|
660 | def plot(self,subplot,x,y,z): | |
661 | # RTI plot |
|
661 | # RTI plot | |
662 | name = 'rti' |
|
662 | name = 'rti' | |
663 | key = name + '%d'%subplot |
|
663 | key = name + '%d'%subplot | |
664 |
|
664 | |||
665 | data = numpy.reshape(z, (1,-1)) |
|
665 | data = numpy.reshape(z, (1,-1)) | |
666 | data = numpy.abs(data) |
|
666 | data = numpy.abs(data) | |
667 | data = 10*numpy.log10(data) |
|
667 | data = 10*numpy.log10(data) | |
668 | newx = [x,x+1] |
|
668 | newx = [x,x+1] | |
669 |
|
669 | |||
670 | pcolorObj = self.pcolorObjDic[key] |
|
670 | pcolorObj = self.pcolorObjDic[key] | |
671 |
|
671 | |||
672 | if pcolorObj.xaxisIsTime: |
|
672 | if pcolorObj.xaxisIsTime: | |
673 | xopt = 'bcstd' |
|
673 | xopt = 'bcstd' | |
674 | yopt = 'bcst' |
|
674 | yopt = 'bcst' | |
675 | else: |
|
675 | else: | |
676 | xopt = 'bcst' |
|
676 | xopt = 'bcst' | |
677 | yopt = 'bcst' |
|
677 | yopt = 'bcst' | |
678 |
|
678 | |||
679 | pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], xopt, yopt) |
|
679 | pcolorObj.plotBox(pcolorObj.xrange[0], pcolorObj.xrange[1], pcolorObj.yrange[0], pcolorObj.yrange[1], xopt, yopt) | |
680 |
|
680 | |||
681 | deltax = pcolorObj.deltax |
|
681 | deltax = pcolorObj.deltax | |
682 | deltay = None |
|
682 | deltay = None | |
683 |
|
683 | |||
684 | if pcolorObj.xmin == None and pcolorObj.xmax == None: |
|
684 | if pcolorObj.xmin == None and pcolorObj.xmax == None: | |
685 | pcolorObj.xmin = x |
|
685 | pcolorObj.xmin = x | |
686 | pcolorObj.xmax = x |
|
686 | pcolorObj.xmax = x | |
687 |
|
687 | |||
688 | if x >= pcolorObj.xmax: |
|
688 | if x >= pcolorObj.xmax: | |
689 | xmin = x |
|
689 | xmin = x | |
690 | xmax = x + deltax |
|
690 | xmax = x + deltax | |
691 | x = [x] |
|
691 | x = [x] | |
692 | pcolorObj.advPcolorPlot(data, |
|
692 | pcolorObj.advPcolorPlot(data, | |
693 | x, |
|
693 | x, | |
694 | y, |
|
694 | y, | |
695 | xmin=xmin, |
|
695 | xmin=xmin, | |
696 | xmax=xmax, |
|
696 | xmax=xmax, | |
697 | ymin=pcolorObj.yrange[0], |
|
697 | ymin=pcolorObj.yrange[0], | |
698 | ymax=pcolorObj.yrange[1], |
|
698 | ymax=pcolorObj.yrange[1], | |
699 | zmin=pcolorObj.zrange[0], |
|
699 | zmin=pcolorObj.zrange[0], | |
700 | zmax=pcolorObj.zrange[1], |
|
700 | zmax=pcolorObj.zrange[1], | |
701 | deltax=deltax, |
|
701 | deltax=deltax, | |
702 | deltay=deltay, |
|
702 | deltay=deltay, | |
703 | getGrid=pcolorObj.getGrid) |
|
703 | getGrid=pcolorObj.getGrid) | |
704 |
|
704 | |||
705 | pcolorObj.xmin = xmin |
|
705 | pcolorObj.xmin = xmin | |
706 | pcolorObj.xmax = xmax |
|
706 | pcolorObj.xmax = xmax | |
707 |
|
707 | |||
708 |
|
708 | |||
709 | # Power Profile |
|
709 | # Power Profile | |
710 | if self.showPowerProfile: |
|
710 | if self.showPowerProfile: | |
711 | data = numpy.reshape(data,(numpy.size(data))) |
|
711 | data = numpy.reshape(data,(numpy.size(data))) | |
712 | name = 'pwprofile' |
|
712 | name = 'pwprofile' | |
713 | key = name + '%d'%subplot |
|
713 | key = name + '%d'%subplot | |
714 | powObj = self.pwprofileObjDic[key] |
|
714 | powObj = self.pwprofileObjDic[key] | |
715 |
|
715 | |||
716 | if powObj.setXYData() != None: |
|
716 | if powObj.setXYData() != None: | |
717 | clearData(powObj) |
|
717 | clearData(powObj) | |
718 | powObj.setLineStyle(2) |
|
718 | powObj.setLineStyle(2) | |
719 | powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], 'bcntg', 'bc') |
|
719 | powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], 'bcntg', 'bc') | |
720 | powObj.setLineStyle(1) |
|
720 | powObj.setLineStyle(1) | |
721 | else: |
|
721 | else: | |
722 | powObj.setXYData(data,y) |
|
722 | powObj.setXYData(data,y) | |
723 |
|
723 | |||
724 | powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], 'bc', 'bc') |
|
724 | powObj.plotBox(powObj.xrange[0], powObj.xrange[1], powObj.yrange[0], powObj.yrange[1], 'bc', 'bc') | |
725 | powObj.basicXYPlot(data,y) |
|
725 | powObj.basicXYPlot(data,y) | |
726 | powObj.setXYData(data,y) |
|
726 | powObj.setXYData(data,y) | |
727 |
|
727 | |||
728 | def savePlot(self,indexFig,filename): |
|
728 | def savePlot(self,indexFig,filename): | |
729 |
|
729 | |||
730 | width = self.width*self.ncol |
|
730 | width = self.width*self.ncol | |
731 | hei = self.height*self.nrow |
|
731 | hei = self.height*self.nrow | |
732 | savePlplot(filename,width,hei) |
|
732 | savePlplot(filename,width,hei) | |
733 |
|
733 | |||
734 | def refresh(self): |
|
734 | def refresh(self): | |
735 | refresh() |
|
735 | refresh() | |
736 |
|
736 | |||
737 |
|
737 | |||
738 | if __name__ == '__main__': |
|
738 | if __name__ == '__main__': | |
739 |
|
739 | |||
740 | """ |
|
740 | """ | |
741 | Ejemplo1 |
|
741 | Ejemplo1 | |
742 | """ |
|
742 | """ | |
743 | #Setting the signal |
|
743 | #Setting the signal | |
744 | fs = 8000 |
|
744 | fs = 8000 | |
745 | f0 = 200 |
|
745 | f0 = 200 | |
746 | f1 = 400 |
|
746 | f1 = 400 | |
747 | T = 1./fs |
|
747 | T = 1./fs | |
748 | x = numpy.arange(160) |
|
748 | x = numpy.arange(160) | |
749 | y1 = numpy.sin(2*numpy.pi*f0*x*T) |
|
749 | y1 = numpy.sin(2*numpy.pi*f0*x*T) | |
750 | y2 = numpy.sin(2*numpy.pi*f1*x*T) |
|
750 | y2 = numpy.sin(2*numpy.pi*f1*x*T) | |
751 | signalList = [y1,y2] |
|
751 | signalList = [y1,y2] | |
752 |
|
752 | |||
753 | xmin = numpy.min(x) |
|
753 | xmin = numpy.min(x) | |
754 | xmax = numpy.max(x) |
|
754 | xmax = numpy.max(x) | |
755 | ymin = numpy.min(y1) - 10 |
|
755 | ymin = numpy.min(y1) - 10 | |
756 | ymax = numpy.max(y1) + 10 |
|
756 | ymax = numpy.max(y1) + 10 | |
757 |
|
757 | |||
758 | subplotTitle = "subplot no. " |
|
758 | subplotTitle = "subplot no. " | |
759 | xlabel = "" |
|
759 | xlabel = "" | |
760 | ylabel = "" |
|
760 | ylabel = "" | |
761 |
|
761 | |||
762 | indexFig = 1 |
|
762 | indexFig = 1 | |
763 | nsubplot = 2 |
|
763 | nsubplot = 2 | |
764 | winTitle = "figura" |
|
764 | winTitle = "figura" | |
765 |
|
765 | |||
766 | isPlotIni = False |
|
766 | isPlotIni = False | |
767 | isPlotConfig = False |
|
767 | isPlotConfig = False | |
768 | ntimes = 10 |
|
768 | ntimes = 10 | |
769 |
|
769 | |||
770 |
|
770 | |||
771 | # Instancia del objeto |
|
771 | # Instancia del objeto | |
772 | linearObj = LinearPlot(indexFig,nsubplot,winTitle) |
|
772 | linearObj = LinearPlot(indexFig,nsubplot,winTitle) | |
773 |
|
773 | |||
774 |
|
774 | |||
775 | for i in range(ntimes): |
|
775 | for i in range(ntimes): | |
776 | # Crea los subplots |
|
776 | # Crea los subplots | |
777 | if not(linearObj.isPlotIni): |
|
777 | if not(linearObj.isPlotIni): | |
778 | for index in range(nsubplot): |
|
778 | for index in range(nsubplot): | |
779 | indexplot = index + 1 |
|
779 | indexplot = index + 1 | |
780 | title = subplotTitle + '%d'%indexplot |
|
780 | title = subplotTitle + '%d'%indexplot | |
781 | linearObj.createObjects(indexplot,xmin,xmax,ymin,ymax,title,xlabel,ylabel) |
|
781 | linearObj.createObjects(indexplot,xmin,xmax,ymin,ymax,title,xlabel,ylabel) | |
782 | linearObj.isPlotIni = True |
|
782 | linearObj.isPlotIni = True | |
783 |
|
783 | |||
784 | # Inicializa el grafico en cada iteracion |
|
784 | # Inicializa el grafico en cada iteracion | |
785 | linearObj.setFigure(indexFig) |
|
785 | linearObj.setFigure(indexFig) | |
786 | linearObj.setNewPage("") |
|
786 | linearObj.setNewPage("") | |
787 |
|
787 | |||
788 | for index in range(nsubplot): |
|
788 | for index in range(nsubplot): | |
789 | subplot = index |
|
789 | subplot = index | |
790 | linearObj.iniPlot(subplot+1) |
|
790 | linearObj.iniPlot(subplot+1) | |
791 |
|
791 | |||
792 | #plotea los datos |
|
792 | #plotea los datos | |
793 | for channel in range(nsubplot): |
|
793 | for channel in range(nsubplot): | |
794 | data = y1 + numpy.random.rand(len(y1)) |
|
794 | data = y1 + numpy.random.rand(len(y1)) | |
795 | linearObj.plot(channel+1, x, data, type='simple') |
|
795 | linearObj.plot(channel+1, x, data, type='simple') | |
796 |
|
796 | |||
797 | linearObj.refresh() |
|
797 | linearObj.refresh() | |
798 |
|
798 | |||
799 | # linearObj.closePage() #descomentar esta linea para mas iteraciones |
|
799 | # linearObj.closePage() #descomentar esta linea para mas iteraciones | |
800 |
|
800 | |||
801 | time.sleep(0.05) |
|
801 | time.sleep(0.05) | |
802 |
|
802 | |||
803 | linearObj.show() |
|
803 | linearObj.show() | |
804 |
|
804 | |||
805 | print "example 1 completed" |
|
805 | print "example 1 completed" | |
806 |
|
806 | |||
807 |
|
807 | |||
808 |
|
808 | |||
809 | """ |
|
809 | """ | |
810 | Ejemplo2 |
|
810 | Ejemplo2 | |
811 | """ |
|
811 | """ | |
812 |
|
812 | |||
813 | # make these smaller to increase the resolution |
|
813 | # make these smaller to increase the resolution | |
814 | dx, dy = 0.05, 0.05 |
|
814 | dx, dy = 0.05, 0.05 | |
815 | x = numpy.arange(-3.0, 3.0001, dx) |
|
815 | x = numpy.arange(-3.0, 3.0001, dx) | |
816 | y = numpy.arange(-2.0, 2.0001, dy) |
|
816 | y = numpy.arange(-2.0, 2.0001, dy) | |
817 | # X,Y = numpy.meshgrid(x, y) |
|
817 | # X,Y = numpy.meshgrid(x, y) | |
818 | X,Y = sn.ndgrid(x, y) |
|
818 | X,Y = sn.ndgrid(x, y) | |
819 | Z = (1- X/2 + X**5 + Y**3)*numpy.exp(-X**2-Y**2) |
|
819 | Z = (1- X/2 + X**5 + Y**3)*numpy.exp(-X**2-Y**2) | |
820 |
|
820 | |||
821 | # Creating Object |
|
821 | # Creating Object | |
822 | indexPlot = 2 |
|
822 | indexPlot = 2 | |
823 | nsubplot = 1 |
|
823 | nsubplot = 1 | |
824 | winTitle = "mi grafico pcolor" |
|
824 | winTitle = "mi grafico pcolor" | |
825 | colormap = "br_green" |
|
825 | colormap = "br_green" | |
826 | showColorbar = True |
|
826 | showColorbar = True | |
827 | showPowerProfile = False |
|
827 | showPowerProfile = False | |
828 | XAxisAsTime = False |
|
828 | XAxisAsTime = False | |
829 |
|
829 | |||
830 | subplotTitle = "subplot no. " |
|
830 | subplotTitle = "subplot no. " | |
831 | xlabel = "" |
|
831 | xlabel = "" | |
832 | ylabel = "" |
|
832 | ylabel = "" | |
833 |
|
833 | |||
834 | xmin = -3.0 |
|
834 | xmin = -3.0 | |
835 | xmax = 3.0 |
|
835 | xmax = 3.0 | |
836 | ymin = -2.0 |
|
836 | ymin = -2.0 | |
837 | ymax = 2.0 |
|
837 | ymax = 2.0 | |
838 | zmin = -0.3 |
|
838 | zmin = -0.3 | |
839 | zmax = 1.0 |
|
839 | zmax = 1.0 | |
840 |
|
840 | |||
841 | isPlotIni = False |
|
841 | isPlotIni = False | |
842 | isPlotConfig = False |
|
842 | isPlotConfig = False | |
843 | ntimes = 10 |
|
843 | ntimes = 10 | |
844 |
|
844 | |||
845 |
|
845 | |||
846 | for i in range(ntimes): |
|
846 | for i in range(ntimes): | |
847 |
|
847 | |||
848 | # Instancia del objeto |
|
848 | # Instancia del objeto | |
849 | if not(isPlotConfig): |
|
849 | if not(isPlotConfig): | |
850 | pcolorObj = PcolorPlot(indexPlot, nsubplot, winTitle, colormap, showColorbar, showPowerProfile, XAxisAsTime) |
|
850 | pcolorObj = PcolorPlot(indexPlot, nsubplot, winTitle, colormap, showColorbar, showPowerProfile, XAxisAsTime) | |
851 | isPlotConfig = True |
|
851 | isPlotConfig = True | |
852 |
|
852 | |||
853 | # Crea los subplots |
|
853 | # Crea los subplots | |
854 | if not(isPlotIni): |
|
854 | if not(isPlotIni): | |
855 | for index in range(nsubplot): |
|
855 | for index in range(nsubplot): | |
856 | indexplot = index + 1 |
|
856 | indexplot = index + 1 | |
857 | title = subplotTitle + '%d'%indexplot |
|
857 | title = subplotTitle + '%d'%indexplot | |
858 | subplot = index |
|
858 | subplot = index | |
859 | pcolorObj.createObjects(indexplot,xmin,xmax,ymin,ymax,zmin,zmax,title,xlabel,ylabel) |
|
859 | pcolorObj.createObjects(indexplot,xmin,xmax,ymin,ymax,zmin,zmax,title,xlabel,ylabel) | |
860 | isPlotIni = True |
|
860 | isPlotIni = True | |
861 |
|
861 | |||
862 | # Inicializa el grafico en cada iteracion |
|
862 | # Inicializa el grafico en cada iteracion | |
863 | pcolorObj.setFigure(indexPlot) |
|
863 | pcolorObj.setFigure(indexPlot) | |
864 | pcolorObj.setNewPage("") |
|
864 | pcolorObj.setNewPage("") | |
865 |
|
865 | |||
866 | for index in range(nsubplot): |
|
866 | for index in range(nsubplot): | |
867 | subplot = index |
|
867 | subplot = index | |
868 | pcolorObj.iniPlot(subplot+1) |
|
868 | pcolorObj.iniPlot(subplot+1) | |
869 |
|
869 | |||
870 | #plotea los datos |
|
870 | #plotea los datos | |
871 | for channel in range(nsubplot): |
|
871 | for channel in range(nsubplot): | |
872 | data = Z+0.1*numpy.random.randn(len(x),len(y)) |
|
872 | data = Z+0.1*numpy.random.randn(len(x),len(y)) | |
873 | pcolorObj.plot(channel+1, x, y, data) |
|
873 | pcolorObj.plot(channel+1, x, y, data) | |
874 |
|
874 | |||
875 | pcolorObj.refresh() |
|
875 | pcolorObj.refresh() | |
876 |
|
876 | |||
877 | # pcolorObj.closePage() #descomentar esta linea para mas iteraciones |
|
877 | # pcolorObj.closePage() #descomentar esta linea para mas iteraciones | |
878 |
|
878 | |||
879 | time.sleep(1) |
|
879 | time.sleep(1) | |
880 |
|
880 | |||
881 | pcolorObj.show() |
|
881 | pcolorObj.show() | |
882 |
|
882 | |||
883 | print "example 2 completed" No newline at end of file |
|
883 | print "example 2 completed" |
General Comments 0
You need to be logged in to leave comments.
Login now