##// END OF EJS Templates
Miguel Valdez -
r130:acfc7ad401e5
parent child
Show More
@@ -0,0 +1,167
1 import numpy
2 import schainPlot
3
4 class RTIFigure(schainPlot.Figure):
5
6 __driverObj = None
7 __isDriverOpen = False
8 __isFigureOpen = False
9 __isConfig = False
10 __xw = None
11 __yw = None
12
13 xmin = None
14 xmax = None
15 minvalue = None
16 maxvalue = None
17
18 idfigure = None
19 nframes = None
20 wintitle = wintitle
21 colormap = None
22 driver = None
23 overplot = None
24
25 frameObjList = []
26
27 def __init__(self, idfigure, wintitle, xw=600, yw=800, overplot=0, driver='xwin', colormap='br_green', *showGraphs):
28
29 self.idfigure = idfigure
30 self.wintitle = wintitle
31 self.colormap = colormap
32 self.driver = driver
33 self.overplot = overplot
34
35 self.showGraphs = showGraphs
36
37 self.__driverObj = Driver(driver)
38
39 def __openDriver(self):
40
41 self.__driverObj.openDriver(self.idfigure, self.wintitle, self.xw, self.yw)
42
43 def __openFigure(self):
44
45 nrows, ncolumns = self.getSubplots()
46
47 self.__driverObj.openFigure()
48 self.__driverObj.setSubPlots(nrows, ncolumns)
49
50
51 def __isOutOfXRange(self, x):
52 pass
53
54 def __changeXRange(self, x):
55 pass
56
57 def __createFrames(self):
58
59 for frame in range(self.nframes):
60 frameObj = Frame(idframe = frame,
61 showGraph1 = self.showGraph1,
62 showGraph2 = self.showGraph2
63 )
64
65 self.frameObjList.append(frameObj)
66
67 def plot1DArray(self, data1D, x=None, channelList=None, xmin=None, xmax=None, minvalue=None, maxvlaue=None, save=False, gpath='./'):
68
69 nx, ny = data1D.shape
70
71 if channelList == None:
72 chanellList = range(nx)
73
74 if x == None:
75 x = numpy.arange(data1D.size)
76
77
78
79
80 if not(self.__isDriverOpen):
81 self.__openDriver()
82 self.__isDriverOpen = True
83
84 if not(self.__isConfig):
85 if self.xmin == None: xmin = numpy.min(x)
86 if self.xmax == None: xmax = numpy.max(x)
87 if self.minvalue == None: minvalue = numpy.min(data1D)
88 if self.maxvalue == None: maxvalue = numpy.max(data1D)
89
90 self.__createFrames()
91 self.__isConfig = True
92
93
94 if not(self.__isOutOfXRange(x)):
95 self.__changeXRange(x)
96
97 if self.__isFigureOpen:
98 self.__driverObj.closePage()
99 self.__isFigureOpen = False
100
101 if not(self.__isFigureOpen):
102 self.__openFigure()
103
104 for channel in channelList:
105 frameObj = self.frameObjList[channel]
106 frameObj.init(xmin=xmin,
107 xmax=xmax,
108 minvalue=minvalue,
109 maxvalue=maxvalue)
110
111 self.__isFigureOpen = True
112
113
114 for channel in channelList:
115 dataCh = data1D[channel]
116 frameObj = self.frameObjList[channel]
117
118 frameObj.clearData()
119 frameObj.plot(dataCh)
120
121 frameObj.refresh()
122
123 if not(self.overplot):
124 self.__driverObj.closeFigure()
125 self.__isFigureOpen = False
126
127
128 def plot2DArray(self, x, y, data2D, xmin=None, xmax=None, ymin=None, ymax=None, minvalue=None, maxvalue=None, save=False, gpath='./'):
129
130 if not(self.__isCOpen):
131 self.__createFrames()
132 self.__openFigure()
133 self.__isOpen = True
134
135 if not(self.__isConfig):
136 self.setRange(xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, minvalue=minvalue, maxvalue=maxvalue)
137
138 self.__isConfig = True
139
140 for channel in channelList:
141 dataCh = dataArray[channel]
142 frameObj = frameObjList[channel]
143 frameObj.plot(dataCh)
144
145 def saveFigure(self, filename):
146 pass
147
148
149 def getSubplots(self):
150
151 raise ValueError, ''
152
153 class RTIFrame(schainPlot.Frame):
154
155 def __init__(self):
156 pass
157
158 def setup(self):
159 pass
160
161 class RTIPlot(schainPlot.Plot):
162
163 def __init__(self):
164 pass
165
166 def setup(self):
167 pass No newline at end of file
@@ -8,8 +8,13 class Figure:
8 __isDriverOpen = False
8 __isDriverOpen = False
9 __isFigureOpen = False
9 __isFigureOpen = False
10 __isConfig = False
10 __isConfig = False
11 __width = None
11 __xw = None
12 __height = None
12 __yw = None
13
14 xmin = None
15 xmax = None
16 minvalue = None
17 maxvalue = None
13
18
14 idfigure = None
19 idfigure = None
15 nframes = None
20 nframes = None
@@ -20,10 +25,9 class Figure:
20
25
21 frameObjList = []
26 frameObjList = []
22
27
23 def __init__(self, idfigure, nframes, wintitle, width=600, height=800, overplot=0, driver='xwin', colormap='br_green', *showGraphs):
28 def __init__(self, idfigure, wintitle, xw=600, yw=800, overplot=0, driver='xwin', colormap='br_green', *showGraphs):
24
29
25 self.idfigure = idfigure
30 self.idfigure = idfigure
26 self.nframes = nframes
27 self.wintitle = wintitle
31 self.wintitle = wintitle
28 self.colormap = colormap
32 self.colormap = colormap
29 self.driver = driver
33 self.driver = driver
@@ -32,74 +36,93 class Figure:
32 self.showGraphs = showGraphs
36 self.showGraphs = showGraphs
33
37
34 self.__driverObj = Driver(driver)
38 self.__driverObj = Driver(driver)
35
36 def __createFrames(self):
37
38 for frame in range(self.nframes):
39 frameObj = Frame(idFrame = frame,
40 showGraph1 = self.showGraph1,
41 showGraph2 = self.showGraph2
42 )
43
44 self.frameObjList.append(frameObj)
45
39
46 def __openDriver(self):
40 def __openDriver(self):
47
41
48 self.__driverObj.openDriver(self.idfigure, self.wintitle, self.width, self.height)
42 self.__driverObj.openDriver(self.idfigure, self.wintitle, self.xw, self.yw)
49
43
50 def __openFigure(self):
44 def __openFigure(self):
51
45
52 self.__createFrames()
53 nrows, ncolumns = self.getSubplots()
46 nrows, ncolumns = self.getSubplots()
54
47
55 self.__driverObj.openFigure()
48 self.__driverObj.openFigure()
56 self.__driverObj.setSubPlots(nrows, ncolumns)
49 self.__driverObj.setSubPlots(nrows, ncolumns)
57
50
58
51
59 def __verifyXRange(self, x):
52 def __isOutOfXRange(self, x):
60 pass
53 pass
61
54
62 def __updateXRange(self, x):
55 def __changeXRange(self, x):
63 pass
56 pass
64
57
65 def plot1DArray(self, data1D, x=None, xmin=None, xmax=None, minvalue=None, maxvlaue=None, save=False, gpath='./'):
58 def __createFrames(self):
66
59
60 for frame in range(self.nframes):
61 frameObj = Frame(idframe = frame,
62 showGraph1 = self.showGraph1,
63 showGraph2 = self.showGraph2
64 )
65
66 self.frameObjList.append(frameObj)
67
68 def plot1DArray(self, data1D, x=None, channelList=None, xmin=None, xmax=None, minvalue=None, maxvlaue=None, save=False, gpath='./'):
69
70 nx, ny = data1D.shape
71
72 if channelList == None:
73 chanellList = range(nx)
74
75 if x == None:
76 x = numpy.arange(data1D.size)
77
78
79
80
67 if not(self.__isDriverOpen):
81 if not(self.__isDriverOpen):
68 self.__openDriver()
82 self.__openDriver()
69 self.__isDriverOpen = True
83 self.__isDriverOpen = True
70
84
71 if not(self.__isConfig):
85 if not(self.__isConfig):
72 if x == None: x = numpy.arange(data1D.size)
86 if self.xmin == None: xmin = numpy.min(x)
73 if xmin == None: xmin = numpy.min(x)
87 if self.xmax == None: xmax = numpy.max(x)
74 if xmax == None: xmax = numpy.max(x)
88 if self.minvalue == None: minvalue = numpy.min(data1D)
75 if minvalue == None: minvalue = numpy.min(data1D)
89 if self.maxvalue == None: maxvalue = numpy.max(data1D)
76 if maxvalue == None: maxvalue = numpy.max(data1D)
77
90
78 self.setRange(xmin=xmin, xmax=xmax, minvalue=minvalue, maxvalue=maxvalue)
91 self.__createFrames()
79 self.__isConfig = True
92 self.__isConfig = True
80
93
81 if not(self.__verifyXRange(x)):
94
82 self.__updateXRange(x)
95 if not(self.__isOutOfXRange(x)):
96 self.__changeXRange(x)
97
83 if self.__isFigureOpen:
98 if self.__isFigureOpen:
84 close_figure()
99 self.__driverObj.closePage()
85 self.__isFigureOpen = False
100 self.__isFigureOpen = False
86
101
87 if not(self.__isFigureOpen):
102 if not(self.__isFigureOpen):
88 self.__openFigure()
103 self.__openFigure()
104
105 for channel in channelList:
106 frameObj = self.frameObjList[channel]
107 frameObj.init(xmin=xmin,
108 xmax=xmax,
109 minvalue=minvalue,
110 maxvalue=maxvalue)
111
89 self.__isFigureOpen = True
112 self.__isFigureOpen = True
90
113
91 for frame in channelList:
92 dataCh = data1D[channel]
93 frameObj = frameObjList[channel]
94 frameObj.plotBox()
95
114
96 for channel in channelList:
115 for channel in channelList:
97 dataCh = dataArray[channel]
116 dataCh = data1D[channel]
98 frameObj = frameObjList[channel]
117 frameObj = self.frameObjList[channel]
118
119 frameObj.clearData()
99 frameObj.plot(dataCh)
120 frameObj.plot(dataCh)
121
122 frameObj.refresh()
100
123
101 if not(self.overplot):
124 if not(self.overplot):
102 close_figure()
125 self.__driverObj.closeFigure()
103 self.__isFigureOpen = False
126 self.__isFigureOpen = False
104
127
105
128
@@ -130,84 +153,111 class Figure:
130
153
131 class Frame:
154 class Frame:
132
155
156 """
157 subplots
158 """
159
133 plotObjList = []
160 plotObjList = []
134
161
135 def __init__(self, idFrame, showGraph1=False, showGraph2=False):
162 def __init__(self, idframe, showGraph1=False, showGraph2=False):
136
163
137 self.idFrame = idFrame
164 self.idframe = idframe
138 self.showGraph1 = showGraph1
165 self.showGraph1 = showGraph1
139 self.showGraph2 = showGraph2
166 self.showGraph2 = showGraph2
140
167
141 self.nPlots = 2
168 self.nplots = 1 + showGraph1 + showGraph2
142 self.createPlots()
169 self.__createPlots()
143
170
144 def __getScreenPosMain(self):
171 def __createPlots(self):
145 left = 1.2
146 bottom = 2.3
147 width = 2.0
148 height = 1.4
149
172
150 return left, bottom, width, height
173 for nplot in range(self.nplots):
174 xi, yi, xw, yw = self.__getScreenPos(nplot)
175 plotObj = Plot(xi, yi, xw, yw)
176
177 self.plotObjList.append(plotObj)
178
179 def __getScreenPosMainPlot(self):
180
181 """
182 Calcula las coordenadas asociadas al plot principal.
183 """
184
185 xi = 1.2
186 yi = 2.3
187 xw = 2.0
188 yw = 1.4
189
190 return xi, yi, xw, yw
151
191
152 def __getScreenPosGraph1(self):
192 def __getScreenPosGraph1(self):
153 left = 1.2
193 xi = 1.2
154 bottom = 2.3
194 yi = 2.3
155 width = 2.0
195 xw = 2.0
156 height = 1.4
196 yw = 1.4
157
197
158 return left, bottom, width, height
198 return xi, yi, xw, yw
159
199
160 def __getScreenPosGraph2(self):
200 def __getScreenPosGraph2(self):
161 left = 1.2
201 xi = 1.2
162 bottom = 2.3
202 yi = 2.3
163 width = 2.0
203 xw = 2.0
164 height = 1.4
204 yw = 1.4
165
205
166 return left, bottom, width, height
206 return xi, yi, xw, yw
167
207
168 def __getScreenPos(self, nplot):
208 def __getScreenPos(self, nplot):
169
209
170 if nplot == 0:
210 if nplot == 0:
171 left, bottom, width, height = self.__getScreenPosMain()
211 xi, yi, xw, yw = self.__getScreenPosMain()
172 if nplot == 1:
212 if nplot == 1:
173 left, bottom, width, height = self.__getScreenPosMain()
213 xi, yi, xw, yw = self.__getScreenPosMain()
174 if nplot == 2:
214 if nplot == 2:
175 left, bottom, width, height = self.__getScreenPosMain()
215 xi, yi, xw, yw = self.__getScreenPosMain()
176
216
177 return left, bottom, width, height
217 return xi, yi, xw, yw
178
218
179 def createPlots(self):
219
220 def init(self, xmin, xmax, ymin, yamx, minvalue, maxvalue):
180
221
181 for nplot in range(self.nPlots):
222 """
182 left, bottom, width, height = self.__getScreenPos(nplot)
223 """
183 plotObj = Plot(left, bottom, width, height)
224
184
225 for plotObj in self.plotObjList:
185 self.plotObjList.append(plotObj)
226 plotObj.plotBox(xmin, xmax, ymin, yamx, minvalue, maxvalue)
186
227
187 def setup(self):
228 def clearData(self):
188 pass
229 pass
189
230
190 def plot(self, data):
231 def plot(self, data):
191 pass
232
233 for plotObj in self.plotObjList:
234 plotObj.plotData(data)
235
236 def refresh(self):
237 pass
238
239
192
240
193 class Plot:
241 class Plot:
194
242
195 def __init__(self, left, bottom, width, height):
243 def __init__(self, xi, yi, xw, yw):
196
244
197 self.left = left
245 self.xi = xi
198 self.bottom = bottom
246 self.yi = yi
199 self.width = width
247 self.xw = xw
200 self.height = height
248 self.yw = yw
201
249
202 def setRange(self, xrange, yrange, zrange):
250 def __setRange(self, xrange, yrange, zrange):
203 pass
251 pass
204
252
205 def setLabels(self, xlabel, ylabel, zlabel):
253 def __setLabels(self, xlabel, ylabel, zlabel):
206 pass
254 pass
255
207
256
208 def plotBox(self):
257 def plotBox(self,xmin, xmax, ymin, yamx, minvalue, maxvalue):
209 pass
258 pass
210
259
211 def plotData(self):
260 def plotData(self):
212 pass
261
262 raise ValueError, ""
213
263
@@ -39,8 +39,8 class RTIFrame(Frame):
39 self.showGraph1 = showColorbar
39 self.showGraph1 = showColorbar
40 self.showGraph2 = showPowerProfile
40 self.showGraph2 = showPowerProfile
41
41
42 def setXYPos
42 def setXYPos(self):
43
43 pass
44
44
45 class SelfSpcFigure(Figure):
45 class SelfSpcFigure(Figure):
46 def __init__(self):
46 def __init__(self):
General Comments 0
You need to be logged in to leave comments. Login now