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