@@ -1,78 +1,67 | |||
|
1 | ||
|
2 | 1 |
|
|
3 | 2 | from schainPlotLib import Driver |
|
4 | 3 | |
|
5 | 4 | class Figure: |
|
6 | ||
|
7 | __driverObj = None | |
|
8 | 5 | __isDriverOpen = False |
|
9 | 6 | __isFigureOpen = False |
|
10 | 7 | __isConfig = False |
|
11 |
|
|
|
12 | __yw = None | |
|
13 | ||
|
14 | xmin = None | |
|
15 | xmax = None | |
|
16 | minvalue = None | |
|
17 | maxvalue = None | |
|
18 | ||
|
8 | drvObj = None | |
|
19 | 9 | idfigure = None |
|
20 | 10 | nframes = None |
|
21 | 11 | wintitle = None |
|
22 | 12 | colormap = None |
|
23 | 13 | driver = None |
|
24 | 14 | overplot = None |
|
25 | ||
|
15 | xmin = None | |
|
16 | xmax = None | |
|
17 | minvalue = None | |
|
18 | maxvalue = None | |
|
26 | 19 | frameObjList = [] |
|
20 | figtitle = "" | |
|
27 | 21 | |
|
28 |
def __init__(self, |
|
|
29 | ||
|
30 | self.driver = driver | |
|
22 | def __init__(self,idfigure, nframes, wintitle, xw=600, yw=800, overplot=0, driver='plplot', colorbar= True, colormap=None, *args): | |
|
31 | 23 | self.idfigure = idfigure |
|
32 | 24 | self.nframes = nframes |
|
33 | 25 | self.wintitle = wintitle |
|
26 | self.xw = xw | |
|
27 | self.yw = yw | |
|
34 | 28 | self.overplot = overplot |
|
29 | self.colorbar = colorbar | |
|
35 | 30 | self.colormap = colormap |
|
36 | ||
|
37 |
self.showGraph1 = |
|
|
38 |
self.showGraph2 = |
|
|
39 | self.__xw = xw | |
|
40 | self.__yw = yw | |
|
31 | #esta seccion deberia ser dinamica de acuerdo a len(args) | |
|
32 | self.showGraph1 = args[0] | |
|
33 | self.showGraph2 = args[1] | |
|
41 | 34 | |
|
42 |
self. |
|
|
35 | self.drvObj = Driver(driver, idfigure, xw, yw, wintitle, overplot, colorbar, colormap) | |
|
43 | 36 | |
|
44 |
self. |
|
|
37 | self.drvObj.driver.setFigure() | |
|
45 | 38 | |
|
46 | ||
|
39 | ||
|
47 | 40 | def __openDriver(self): |
|
48 | ||
|
49 | self.__driverObj.driver.openDriver() | |
|
41 | self.drvObj.driver.openDriver() | |
|
50 | 42 | |
|
51 | def __openFigure(self): | |
|
43 | # def __openFigure(self): | |
|
44 | # nrows, ncolumns = self.getSubplots() | |
|
45 | # self.drvObj.driver.openFigure() | |
|
46 | # self.drvObj.driver.setTitleFig(title) | |
|
47 | # self.drvObj.driver.setSubPlots(nrows, ncolumns) | |
|
52 | 48 | |
|
49 | def __initFigure(self): | |
|
53 | 50 | nrows, ncolumns = self.getSubplots() |
|
54 | ||
|
55 |
self. |
|
|
56 |
self. |
|
|
57 | ||
|
58 | ||
|
59 | def __isOutOfXRange(self, x): | |
|
60 | pass | |
|
51 | self.drvObj.driver.openFigure() | |
|
52 | self.drvObj.driver.setFigTitle(self.figtitle) | |
|
53 | self.drvObj.driver.setSubPlots(nrows, ncolumns) | |
|
61 | 54 | |
|
62 |
def __ |
|
|
63 | pass | |
|
64 | ||
|
65 |
def __ |
|
|
66 | ||
|
67 | for frame in range(self.nframes): | |
|
68 | frameObj = Frame(idframe = frame, | |
|
69 | showGraph1 = self.showGraph1, | |
|
70 | showGraph2 = self.showGraph2 | |
|
71 | ) | |
|
72 | ||
|
73 | self.frameObjList.append(frameObj) | |
|
74 | ||
|
75 | def plot1DArray(self, data1D, x=None, channelList=None, xmin=None, xmax=None, minvalue=None, maxvlaue=None, save=False, gpath='./'): | |
|
55 | def __isOutOfXRange(self,x): | |
|
56 | return 1 | |
|
57 | ||
|
58 | def __refresh(self): | |
|
59 | self.drvObj.driver.refresh() | |
|
60 | ||
|
61 | def createFrames(self): | |
|
62 | raise ValueError, "No implemented" | |
|
63 | ||
|
64 | def plot1DArray(self, data1D, x=None, channelList=None, xmin=None, xmax=None, minvalue=None, maxvalue=None, figtitle=None, save=False, gpath='./'): | |
|
76 | 65 | |
|
77 | 66 | nx, ny = data1D.shape |
|
78 | 67 | |
@@ -81,186 +70,163 class Figure: | |||
|
81 | 70 | |
|
82 | 71 | if x == None: |
|
83 | 72 | x = numpy.arange(data1D.size) |
|
84 |
|
|
|
73 | ||
|
74 | if figtitle == None: | |
|
75 | self.figtitle = "" | |
|
76 | else: | |
|
77 | self.figtitle = figtitle | |
|
78 | ||
|
85 | 79 | if not(self.__isDriverOpen): |
|
86 | 80 | self.__openDriver() |
|
87 | 81 | self.__isDriverOpen = True |
|
88 | 82 | |
|
89 | 83 | if not(self.__isConfig): |
|
90 |
|
|
|
91 |
|
|
|
92 |
|
|
|
93 |
|
|
|
84 | self.xmin = xmin | |
|
85 | self.xmax = xmax | |
|
86 | self.minvalue = minvalue | |
|
87 | self.maxvalue = maxvalue | |
|
88 | ||
|
89 | if self.xmin == None: self.xmin = numpy.min(x) | |
|
90 | if self.xmax == None: self.xmax = numpy.max(x) | |
|
91 | if self.minvalue == None: self.minvalue = numpy.min(data1D) | |
|
92 | if self.maxvalue == None: self.maxvalue = numpy.max(data1D) | |
|
94 | 93 | |
|
95 |
self. |
|
|
94 | self.createFrames() | |
|
96 | 95 | self.__isConfig = True |
|
97 | 96 | |
|
98 | 97 | if not(self.__isOutOfXRange(x)): |
|
99 | 98 | self.__changeXRange(x) |
|
100 | 99 | |
|
101 | 100 | if self.__isFigureOpen: |
|
102 |
self. |
|
|
101 | self.driverObj.closePage() | |
|
103 | 102 | self.__isFigureOpen = False |
|
104 | 103 | |
|
105 |
|
|
|
106 | self.__openFigure() | |
|
107 | ||
|
108 | for channel in channelList: | |
|
109 | frameObj = self.frameObjList[channel] | |
|
110 | frameObj.init(xmin=xmin, | |
|
111 | xmax=xmax, | |
|
112 | minvalue=minvalue, | |
|
113 | maxvalue=maxvalue) | |
|
114 | ||
|
115 | self.__isFigureOpen = True | |
|
104 | self.__initFigure() | |
|
116 | 105 | |
|
117 | 106 | for channel in channelList: |
|
118 |
|
|
|
107 | # frametitle = self.plotTitleDict[channel] | |
|
119 | 108 | frameObj = self.frameObjList[channel] |
|
120 | ||
|
121 | frameObj.clearData() | |
|
122 | frameObj.plot(dataCh) | |
|
123 | ||
|
124 | frameObj.refresh() | |
|
125 | ||
|
126 | if not(self.overplot): | |
|
127 | self.__driverObj.closeFigure() | |
|
128 | self.__isFigureOpen = False | |
|
129 | ||
|
130 | ||
|
131 | def plot2DArray(self, x, y, data2D, xmin=None, xmax=None, ymin=None, ymax=None, minvalue=None, maxvalue=None, save=False, gpath='./'): | |
|
132 | ||
|
133 | if not(self.__isCOpen): | |
|
134 | self.__createFrames() | |
|
135 | self.__openFigure() | |
|
136 | self.__isOpen = True | |
|
137 | ||
|
138 | if not(self.__isConfig): | |
|
139 | self.setRange(xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, minvalue=minvalue, maxvalue=maxvalue) | |
|
140 | self.__isConfig = True | |
|
109 | frameObj.init(xmin=self.xmin, | |
|
110 | xmax=self.xmax, | |
|
111 | ymin=self.minvalue, | |
|
112 | ymax=self.maxvalue, | |
|
113 | minvalue=self.minvalue, | |
|
114 | maxvalue=self.maxvalue) | |
|
141 | 115 | |
|
142 | 116 | for channel in channelList: |
|
143 |
dataCh = data |
|
|
144 | frameObj = frameObjList[channel] | |
|
145 |
frameObj. |
|
|
146 | ||
|
147 | def saveFigure(self, filename): | |
|
148 | pass | |
|
149 | ||
|
117 | dataCh = data1D[channel,:] | |
|
118 | frameObj = self.frameObjList[channel] | |
|
119 | # frameObj.clearData() | |
|
120 | frameObj.plot(x, dataCh) | |
|
121 | ||
|
122 | # frameObj.refresh() | |
|
123 | self.__refresh() | |
|
150 | 124 | |
|
151 | def getSubplots(self): | |
|
152 | 125 | |
|
153 | raise ValueError, "No implemented" | |
|
154 | ||
|
155 | class Frame: | |
|
156 | ||
|
157 | """ | |
|
158 | subplots | |
|
159 | """ | |
|
126 | # | |
|
127 | # if save: | |
|
128 | # self.colorplotObj.setFigure(indexPlot) | |
|
129 | # path = "/home/roj-idl71/tmp/" | |
|
130 | # now = datetime.datetime.now().timetuple() | |
|
131 | # file = "spc_img%02d_%03d_%02d%02d%02d.png"%(indexPlot,now[7],now[3],now[4],now[5]) | |
|
132 | # filename = os.path.join(path,file) | |
|
133 | # self.colorplotObj.savePlot(indexPlot, filename) | |
|
134 | # | |
|
135 | # self.colorplotObj.closePage() | |
|
160 | 136 | |
|
137 | class Frame: | |
|
138 | nplots = None | |
|
161 | 139 | plotObjList = [] |
|
162 | 140 | title = "" |
|
163 | def __init__(self, idframe, showGraph1=False, showGraph2=False): | |
|
164 | ||
|
141 | def __init__(self,drvObj, idframe): | |
|
142 | self.drvObj = drvObj | |
|
165 | 143 | self.idframe = idframe |
|
166 | self.showGraph1 = showGraph1 | |
|
167 | self.showGraph2 = showGraph2 | |
|
168 | ||
|
169 | self.nplots = 1 + showGraph1 + showGraph2#para el caso de RTI showGrap1 deberia indicar colorbar como propiedad, no como plot | |
|
170 | self.__createPlots() | |
|
144 | self.createPlots() | |
|
171 | 145 | |
|
172 |
def |
|
|
173 | ||
|
174 | for nplot in range(self.nplots): | |
|
175 | xi, yi, xw, yw = self.__getScreenPos(nplot) | |
|
176 | plotObj = Plot(xi, yi, xw, yw) | |
|
177 | ||
|
178 | self.plotObjList.append(plotObj) | |
|
179 | ||
|
180 | def __getScreenPosMainPlot(self): | |
|
181 | ||
|
182 | """ | |
|
183 | Calcula las coordenadas asociadas al plot principal. | |
|
184 | """ | |
|
185 | ||
|
186 | xi = 1.2 | |
|
187 | yi = 2.3 | |
|
188 | xw = 2.0 | |
|
189 | yw = 1.4 | |
|
190 | ||
|
191 | return xi, yi, xw, yw | |
|
192 | ||
|
193 | def __getScreenPosGraph1(self): | |
|
194 | xi = 1.2 | |
|
195 | yi = 2.3 | |
|
196 | xw = 2.0 | |
|
197 | yw = 1.4 | |
|
198 | ||
|
199 | return xi, yi, xw, yw | |
|
146 | def createPlots(self): | |
|
147 | raise ValueError, "No implemented" | |
|
200 | 148 | |
|
201 |
def |
|
|
202 | xi = 1.2 | |
|
203 | yi = 2.3 | |
|
204 | xw = 2.0 | |
|
205 | yw = 1.4 | |
|
206 | ||
|
207 | return xi, yi, xw, yw | |
|
208 | ||
|
209 | def __getScreenPos(self, nplot): | |
|
149 | def getScreenPosMainPlot(self): | |
|
150 | raise ValueError, "No implemented" | |
|
151 | ||
|
152 | def getScreenPos(self, nplot): | |
|
210 | 153 | |
|
211 | 154 | if nplot == 0: |
|
212 |
xi, yi, xw, yw = self. |
|
|
213 | if nplot == 1: | |
|
214 | xi, yi, xw, yw = self.__getScreenPosMain() | |
|
215 | if nplot == 2: | |
|
216 | xi, yi, xw, yw = self.__getScreenPosMain() | |
|
217 | ||
|
155 | xi, yi, xw, yw = self.getScreenPosMainPlot() | |
|
218 | 156 | return xi, yi, xw, yw |
|
219 | ||
|
220 | ||
|
221 | def init(self, xmin, xmax, ymin, yamx, minvalue, maxvalue): | |
|
222 | ||
|
223 | """ | |
|
224 | """ | |
|
225 | ||
|
226 | for plotObj in self.plotObjList: | |
|
227 | plotObj.plotBox(xmin, xmax, ymin, yamx, minvalue, maxvalue) | |
|
228 | 157 | |
|
229 | def clearData(self): | |
|
230 | pass | |
|
231 | ||
|
232 | def plot(self, data): | |
|
233 | ||
|
158 | ||
|
159 | def init(self, xmin, xmax, ymin, ymax, minvalue, maxvalue): | |
|
160 | ||
|
234 | 161 | for plotObj in self.plotObjList: |
|
235 | plotObj.plotData(data) | |
|
236 | ||
|
237 | def refresh(self): | |
|
238 | pass | |
|
162 | plotObj.plotBox(xmin, xmax, ymin, ymax, minvalue, maxvalue) | |
|
163 | # plotObj.setLabels() # ? evaluar si conviene colocarlo dentro del plotbox | |
|
239 | 164 | |
|
240 | ||
|
165 | def refresh(self): | |
|
166 | for plotObj in self.plotObjList: | |
|
167 | plotObj.refresh() | |
|
241 | 168 | |
|
242 | 169 | class Plot: |
|
243 | ||
|
244 | 170 | title = "" |
|
245 | ||
|
246 | def __init__(self, xi, yi, xw, yw): | |
|
247 | ||
|
171 | xlabel = "" | |
|
172 | ylabel = "" | |
|
173 | xaxisastime = None | |
|
174 | timefmt = None | |
|
175 | xopt = "" | |
|
176 | yopt = "" | |
|
177 | xpos = None | |
|
178 | ypos = None | |
|
179 | szchar = None | |
|
180 | idframe = None | |
|
181 | idplot = None | |
|
182 | ||
|
183 | def __init__(self, drvObj, idframe, idplot, xi, yi, xw, yw): | |
|
184 | self.drvObj = drvObj | |
|
185 | self.idframe = idframe | |
|
186 | self.idplot = idplot | |
|
248 | 187 | self.xi = xi |
|
249 | 188 | self.yi = yi |
|
250 | 189 | self.xw = xw |
|
251 | 190 | self.yw = yw |
|
252 | ||
|
253 | def __setRange(self, xrange, yrange, zrange): | |
|
254 | pass | |
|
255 | ||
|
256 | def __setLabels(self, xlabel, ylabel, zlabel): | |
|
257 | pass | |
|
258 | 191 | |
|
259 | ||
|
260 | def plotBox(self,xmin, xmax, ymin, yamx, minvalue, maxvalue): | |
|
261 | pass | |
|
262 | ||
|
263 | def plotData(self): | |
|
192 | # def setLabels(self): | |
|
193 | # self.drvObj.driver.setPlotLabels(self.xlabel, self.ylabel, self.title) | |
|
194 | ||
|
195 | def plotBox(self, xmin, xmax, ymin, ymax, minvalue, maxvalue): | |
|
196 | self.xmin = xmin | |
|
197 | self.xmax = xmax | |
|
198 | self.ymin = ymin | |
|
199 | self.ymax = ymax | |
|
200 | self.minvalue = minvalue | |
|
201 | self.maxvalue = maxvalue | |
|
202 | ||
|
203 | self.drvObj.driver.plotBox(self.idframe, | |
|
204 | self.xpos, | |
|
205 | self.ypos, | |
|
206 | self.xmin, | |
|
207 | self.xmax, | |
|
208 | self.ymin, | |
|
209 | self.ymax, | |
|
210 | self.minvalue, | |
|
211 | self.maxvalue, | |
|
212 | self.xopt, | |
|
213 | self.yopt, | |
|
214 | self.szchar, | |
|
215 | self.xaxisastime, | |
|
216 | self.timefmt) | |
|
217 | ||
|
218 | self.drvObj.driver.setPlotLabels(self.xlabel, self.ylabel, self.title) | |
|
219 | ||
|
220 | def plotBasicLine(self,x, y, color): | |
|
221 | """ | |
|
222 | Inputs: | |
|
223 | x: | |
|
224 | ||
|
225 | y: | |
|
226 | ||
|
227 | color: | |
|
228 | """ | |
|
229 | self.drvObj.driver.basicLine(x, y, self.xmin, self.xmax, self.ymin, self.ymax, color, self.idframe, self.xpos, self.ypos) | |
|
230 | ||
|
264 | 231 | |
|
265 | raise ValueError, "" | |
|
266 | ||
|
232 | No newline at end of file |
This diff has been collapsed as it changes many lines, (652 lines changed) Show them Hide them | |||
@@ -4,11 +4,11 import sys | |||
|
4 | 4 | import plplot #condicional |
|
5 | 5 | |
|
6 | 6 | class Driver: |
|
7 |
def __init__(self,driver, idfigure, xw, yw, wintitle, overplot, color |
|
|
7 | def __init__(self,driver, idfigure, xw, yw, wintitle, overplot, colorbar, colormap): | |
|
8 | 8 | if driver == "plplot": |
|
9 |
self.driver = PlplotDriver(idfigure, xw, yw, wintitle, overplot, color |
|
|
9 | self.driver = PlplotDriver(idfigure, xw, yw, wintitle, overplot, colorbar, colormap) | |
|
10 | 10 | elif driver == "mpl": |
|
11 |
self.driver = MplDriver(idfigure, xw, yw, wintitle, overplot, colormap |
|
|
11 | self.driver = MplDriver(idfigure, xw, yw, wintitle, overplot, colormap) | |
|
12 | 12 | else: |
|
13 | 13 | raise ValueError, "The driver: %s is not defined"%driver |
|
14 | 14 | |
@@ -17,7 +17,7 class PlplotDriver: | |||
|
17 | 17 | __isDriverOpen = False |
|
18 | 18 | pldriver = None |
|
19 | 19 | |
|
20 |
def __init__(self, idfigure, xw, yw, wintitle, overplot, color |
|
|
20 | def __init__(self, idfigure, xw, yw, wintitle, overplot, colorbar, colormap): | |
|
21 | 21 | |
|
22 | 22 | if idfigure == None: |
|
23 | 23 | raise ValueError, 'idfigure input must be defined' |
@@ -27,11 +27,12 class PlplotDriver: | |||
|
27 | 27 | self.yw = yw |
|
28 | 28 | self.wintitle = wintitle |
|
29 | 29 | self.overplot = overplot |
|
30 | self.colorbar = colorbar | |
|
30 | 31 | self.colormap = colormap |
|
31 | self.showGraph1 = showGraphs[0] | |
|
32 | self.showGraph2 = showGraphs[1] | |
|
32 | ||
|
33 | ||
|
33 | 34 | |
|
34 |
def |
|
|
35 | def setFigure(self): | |
|
35 | 36 | """ |
|
36 | 37 | previous configuration to open(init) the plplot driver |
|
37 | 38 | """ |
@@ -80,604 +81,73 class PlplotDriver: | |||
|
80 | 81 | plplot.pleop() |
|
81 | 82 | |
|
82 | 83 | def setSubPlots(self,nrows, ncolumns): |
|
83 |
plplot.plssub(nrows |
|
|
84 | plplot.plssub(ncolumns,nrows) | |
|
84 | 85 | |
|
85 | def setColorMap(self,colormap): | |
|
86 | ||
|
87 | if colormap == None: | |
|
88 | return | |
|
89 | ||
|
90 | ncolor = None | |
|
91 | rgb_lvl = None | |
|
92 | ||
|
93 | # Routine for defining a specific color map 1 in HLS space. | |
|
94 | # if gray is true, use basic grayscale variation from half-dark to light. | |
|
95 | # otherwise use false color variation from blue (240 deg) to red (360 deg). | |
|
86 | def setPlotLabels(self, xlabel, ylabel, title): | |
|
87 | plplot.pllab(xlabel, ylabel, title) | |
|
96 | 88 | |
|
97 | # Independent variable of control points. | |
|
89 | def setFigTitle(self, title,color="black", szchar=0.55): | |
|
90 | self.setSubPlots(1, 0) | |
|
91 | plplot.pladv(0) | |
|
92 | plplot.plvpor(0., 1., 0., 1.) | |
|
98 | 93 | |
|
99 | i = numpy.array((0., 1.)) | |
|
94 | if color == "black": | |
|
95 | plplot.plcol0(1) | |
|
96 | if color == "white": | |
|
97 | plplot.plcol0(15) | |
|
100 | 98 | |
|
101 | if colormap=="gray": | |
|
102 | ncolor = 256 | |
|
103 | # Hue for control points. Doesn't matter since saturation is zero. | |
|
104 | h = numpy.array((0., 0.)) | |
|
105 | # Lightness ranging from half-dark (for interest) to light. | |
|
106 | l = numpy.array((0.5, 1.)) | |
|
107 | # Gray scale has zero saturation | |
|
108 | s = numpy.array((0., 0.)) | |
|
109 | ||
|
110 | # number of cmap1 colours is 256 in this case. | |
|
111 | plplot.plscmap1n(ncolor) | |
|
112 | # Interpolate between control points to set up cmap1. | |
|
113 |
plplot.pl |
|
|
114 | ||
|
115 | return None | |
|
116 | ||
|
117 | if colormap == 'jet': | |
|
118 | ncolor = 256 | |
|
119 | pos = numpy.zeros((ncolor)) | |
|
120 | r = numpy.zeros((ncolor)) | |
|
121 | g = numpy.zeros((ncolor)) | |
|
122 | b = numpy.zeros((ncolor)) | |
|
99 | plplot.plschr(0.0,szchar) | |
|
100 | plplot.plmtex("t",-1., 0.5, 0.5, title) | |
|
101 | ||
|
102 | def plotBox(self, id, xpos, ypos, xmin, xmax, ymin, ymax, minvalue, maxvalue, xopt, yopt, szchar=0.6, xaxisastime = False, timefmt="%H:%M"): | |
|
103 | """ | |
|
104 | xopt, yopt: entradas que no se aplican en MPL | |
|
105 | """ | |
|
106 | plplot.pladv(id) | |
|
107 | plplot.plschr(0.0,szchar-0.05) | |
|
108 | plplot.plvpor(xpos[0], xpos[1], ypos[0], ypos[1]) | |
|
109 | plplot.plwind(float(xmin), float(xmax), float(ymin), float(ymax)) | |
|
110 | if xaxisastime: | |
|
111 | plplot.pltimefmt(timefmt) | |
|
112 | timedelta = (xmax - xmin + 1)/8. | |
|
113 | plplot.plbox(xopt, timedelta, 3, yopt, 0.0, 0) | |
|
114 | else: | |
|
115 | plplot.plbox(xopt, 0.0, 0, yopt, 0.0, 0) | |
|
123 | 116 | |
|
124 | for i in range(ncolor): | |
|
125 | if(i <= 35.0/100*(ncolor-1)): rf = 0.0 | |
|
126 | elif (i <= 66.0/100*(ncolor-1)): rf = (100.0/31)*i/(ncolor-1) - 35.0/31 | |
|
127 | elif (i <= 89.0/100*(ncolor-1)): rf = 1.0 | |
|
128 | else: rf = (-100.0/22)*i/(ncolor-1) + 111.0/22 | |
|
117 | def refresh(self): | |
|
118 | plplot.plflush() | |
|
129 | 119 | |
|
130 | if(i <= 12.0/100*(ncolor-1)): gf = 0.0 | |
|
131 | elif(i <= 38.0/100*(ncolor-1)): gf = (100.0/26)*i/(ncolor-1) - 12.0/26 | |
|
132 | elif(i <= 64.0/100*(ncolor-1)): gf = 1.0 | |
|
133 | elif(i <= 91.0/100*(ncolor-1)): gf = (-100.0/27)*i/(ncolor-1) + 91.0/27 | |
|
134 | else: gf = 0.0 | |
|
120 | def basicLine(self, x, y, xmin, xmax, ymin, ymax, color, id, xpos, ypos): | |
|
135 | 121 |
|
|
136 | if(i <= 11.0/100*(ncolor-1)): bf = (50.0/11)*i/(ncolor-1) + 0.5 | |
|
137 | elif(i <= 34.0/100*(ncolor-1)): bf = 1.0 | |
|
138 | elif(i <= 65.0/100*(ncolor-1)): bf = (-100.0/31)*i/(ncolor-1) + 65.0/31 | |
|
139 | else: bf = 0 | |
|
140 | ||
|
141 | r[i] = rf | |
|
142 | g[i] = gf | |
|
143 | b[i] = bf | |
|
122 | """ | |
|
123 | Inputs: | |
|
124 | x: datos en el eje x | |
|
144 | 125 |
|
|
145 | pos[i] = float(i)/float(ncolor-1) | |
|
126 | y: datos en el eje y | |
|
146 | 127 |
|
|
147 | ||
|
148 | plplot.plscmap1n(ncolor) | |
|
149 | plplot.plscmap1l(1, pos, r, g, b) | |
|
150 | ||
|
151 | ||
|
152 | ||
|
153 | if colormap=="br_green": | |
|
154 | ncolor = 256 | |
|
155 | # Hue ranges from blue (240 deg) to red (0 or 360 deg) | |
|
156 | h = numpy.array((240., 0.)) | |
|
157 | # Lightness and saturation are constant (values taken from C example). | |
|
158 | l = numpy.array((0.6, 0.6)) | |
|
159 | s = numpy.array((0.8, 0.8)) | |
|
160 | ||
|
161 | # number of cmap1 colours is 256 in this case. | |
|
162 | plplot.plscmap1n(ncolor) | |
|
163 | # Interpolate between control points to set up cmap1. | |
|
164 | plplot.plscmap1l(0, i, h, l, s) | |
|
128 | xmin, xmax: intervalo de datos en el eje x | |
|
165 | 129 |
|
|
166 | return None | |
|
167 | ||
|
168 | if colormap=="tricolor": | |
|
169 | ncolor = 3 | |
|
170 | # Hue ranges from blue (240 deg) to red (0 or 360 deg) | |
|
171 | h = numpy.array((240., 0.)) | |
|
172 | # Lightness and saturation are constant (values taken from C example). | |
|
173 | l = numpy.array((0.6, 0.6)) | |
|
174 | s = numpy.array((0.8, 0.8)) | |
|
175 | ||
|
176 | # number of cmap1 colours is 256 in this case. | |
|
177 | plplot.plscmap1n(ncolor) | |
|
178 | # Interpolate between control points to set up cmap1. | |
|
179 | plplot.plscmap1l(0, i, h, l, s) | |
|
130 | ymin, ymax: intervalo de datos en el eje y | |
|
180 | 131 |
|
|
181 | return None | |
|
182 | ||
|
183 | if colormap == 'rgb' or colormap == 'rgb666': | |
|
132 | color: color de la linea a dibujarse | |
|
184 | 133 |
|
|
185 | color_sz = 6 | |
|
186 | ncolor = color_sz*color_sz*color_sz | |
|
187 | pos = numpy.zeros((ncolor)) | |
|
188 | r = numpy.zeros((ncolor)) | |
|
189 | g = numpy.zeros((ncolor)) | |
|
190 | b = numpy.zeros((ncolor)) | |
|
191 | ind = 0 | |
|
192 | for ri in range(color_sz): | |
|
193 | for gi in range(color_sz): | |
|
194 | for bi in range(color_sz): | |
|
195 | r[ind] = ri/(color_sz-1.0) | |
|
196 | g[ind] = gi/(color_sz-1.0) | |
|
197 | b[ind] = bi/(color_sz-1.0) | |
|
198 | pos[ind] = ind/(ncolor-1.0) | |
|
199 | ind += 1 | |
|
200 | rgb_lvl = [6,6,6] #Levels for RGB colors | |
|
134 | id: identificador del plot, en este caso indica al frame que pertenece, la posicion de cada | |
|
135 | plot esta definido por xpos, ypos. | |
|
201 | 136 |
|
|
202 | if colormap == 'rgb676': | |
|
203 | ncolor = 6*7*6 | |
|
204 | pos = numpy.zeros((ncolor)) | |
|
205 | r = numpy.zeros((ncolor)) | |
|
206 | g = numpy.zeros((ncolor)) | |
|
207 | b = numpy.zeros((ncolor)) | |
|
208 | ind = 0 | |
|
209 | for ri in range(8): | |
|
210 | for gi in range(8): | |
|
211 | for bi in range(4): | |
|
212 | r[ind] = ri/(6-1.0) | |
|
213 | g[ind] = gi/(7-1.0) | |
|
214 | b[ind] = bi/(6-1.0) | |
|
215 | pos[ind] = ind/(ncolor-1.0) | |
|
216 | ind += 1 | |
|
217 | rgb_lvl = [6,7,6] #Levels for RGB colors | |
|
218 | ||
|
219 | if colormap == 'rgb685': | |
|
220 | ncolor = 6*8*5 | |
|
221 | pos = numpy.zeros((ncolor)) | |
|
222 | r = numpy.zeros((ncolor)) | |
|
223 | g = numpy.zeros((ncolor)) | |
|
224 | b = numpy.zeros((ncolor)) | |
|
225 | ind = 0 | |
|
226 | for ri in range(8): | |
|
227 | for gi in range(8): | |
|
228 | for bi in range(4): | |
|
229 | r[ind] = ri/(6-1.0) | |
|
230 | g[ind] = gi/(8-1.0) | |
|
231 | b[ind] = bi/(5-1.0) | |
|
232 | pos[ind] = ind/(ncolor-1.0) | |
|
233 | ind += 1 | |
|
234 | rgb_lvl = [6,8,5] #Levels for RGB colors | |
|
235 | ||
|
236 | if colormap == 'rgb884': | |
|
237 | ncolor = 8*8*4 | |
|
238 | pos = numpy.zeros((ncolor)) | |
|
239 | r = numpy.zeros((ncolor)) | |
|
240 | g = numpy.zeros((ncolor)) | |
|
241 | b = numpy.zeros((ncolor)) | |
|
242 | ind = 0 | |
|
243 | for ri in range(8): | |
|
244 | for gi in range(8): | |
|
245 | for bi in range(4): | |
|
246 | r[ind] = ri/(8-1.0) | |
|
247 | g[ind] = gi/(8-1.0) | |
|
248 | b[ind] = bi/(4-1.0) | |
|
249 | pos[ind] = ind/(ncolor-1.0) | |
|
250 | ind += 1 | |
|
251 | rgb_lvl = [8,8,4] #Levels for RGB colors | |
|
252 | ||
|
253 | if ncolor == None: | |
|
254 | raise ValueError, "The colormap selected is not valid" | |
|
255 | ||
|
256 | plplot.plscmap1n(ncolor) | |
|
257 | plplot.plscmap1l(1, pos, r, g, b) | |
|
258 | ||
|
259 | return rgb_lvl | |
|
260 | ||
|
261 | def setBox(self): | |
|
262 | ||
|
263 | pass | |
|
264 | ||
|
265 | def refreshBox(self): | |
|
266 | ||
|
267 | pass | |
|
268 | ||
|
269 | def save(self): | |
|
270 | ||
|
271 | pass | |
|
272 | ||
|
273 | def show(self): | |
|
274 | ||
|
275 | pass | |
|
276 | ||
|
277 | def colorbarPlot(self): | |
|
278 | ||
|
279 | pass | |
|
280 | ||
|
281 | def linePlot(self): | |
|
282 | ||
|
283 | pass | |
|
284 | ||
|
285 | def pcolorPlot(self): | |
|
286 | ||
|
287 | pass | |
|
288 | ||
|
289 | def setLabels(self): | |
|
290 | ||
|
291 | pass | |
|
292 | ||
|
293 | ||
|
294 | ||
|
295 | ||
|
296 | ||
|
297 | class MplDriver: | |
|
298 | def __init__(self): | |
|
299 | pass | |
|
300 | ||
|
301 | def config_driver(idfigure, wintitle, width, height): | |
|
302 | plplot.plsstrm(idfigure) | |
|
303 | plplot.plparseopts([wintitle],plplot.PL_PARSE_FULL) | |
|
304 | plplot.plsetopt("geometry", "%dx%d"%(width,height)) | |
|
305 | ||
|
306 | def ini_driver(driver): | |
|
307 | if sys.platform == "darwin": | |
|
308 | plplot.plsdev("xwin") | |
|
309 | if sys.platform == "linux": | |
|
310 | plplot.plsdev("xcairo") | |
|
311 | plplot.plscolbg(255,255,255) | |
|
312 | plplot.plscol0(1,0,0,0) | |
|
313 | plplot.plinit() | |
|
314 | plplot.plspause(False) | |
|
315 | ||
|
316 | def set_subpages(ncol,nrow): | |
|
317 | plplot.plssub(ncol,nrow) | |
|
318 | ||
|
319 | def cmap1_init(colormap="gray"): | |
|
320 | ||
|
321 | if colormap == None: | |
|
322 | return | |
|
323 | ||
|
324 | ncolor = None | |
|
325 | rgb_lvl = None | |
|
326 | ||
|
327 | # Routine for defining a specific color map 1 in HLS space. | |
|
328 | # if gray is true, use basic grayscale variation from half-dark to light. | |
|
329 | # otherwise use false color variation from blue (240 deg) to red (360 deg). | |
|
330 | ||
|
331 | # Independent variable of control points. | |
|
332 | i = numpy.array((0., 1.)) | |
|
333 | if colormap=="gray": | |
|
334 | ncolor = 256 | |
|
335 | # Hue for control points. Doesn't matter since saturation is zero. | |
|
336 | h = numpy.array((0., 0.)) | |
|
337 | # Lightness ranging from half-dark (for interest) to light. | |
|
338 | l = numpy.array((0.5, 1.)) | |
|
339 | # Gray scale has zero saturation | |
|
340 | s = numpy.array((0., 0.)) | |
|
341 | ||
|
342 | # number of cmap1 colours is 256 in this case. | |
|
343 | plplot.plscmap1n(ncolor) | |
|
344 | # Interpolate between control points to set up cmap1. | |
|
345 | plplot.plscmap1l(0, i, h, l, s) | |
|
346 | ||
|
347 | return None | |
|
348 | ||
|
349 | if colormap == 'jet': | |
|
350 | ncolor = 256 | |
|
351 | pos = numpy.zeros((ncolor)) | |
|
352 | r = numpy.zeros((ncolor)) | |
|
353 | g = numpy.zeros((ncolor)) | |
|
354 | b = numpy.zeros((ncolor)) | |
|
355 | ||
|
356 | for i in range(ncolor): | |
|
357 | if(i <= 35.0/100*(ncolor-1)): rf = 0.0 | |
|
358 | elif (i <= 66.0/100*(ncolor-1)): rf = (100.0/31)*i/(ncolor-1) - 35.0/31 | |
|
359 | elif (i <= 89.0/100*(ncolor-1)): rf = 1.0 | |
|
360 | else: rf = (-100.0/22)*i/(ncolor-1) + 111.0/22 | |
|
361 | ||
|
362 | if(i <= 12.0/100*(ncolor-1)): gf = 0.0 | |
|
363 | elif(i <= 38.0/100*(ncolor-1)): gf = (100.0/26)*i/(ncolor-1) - 12.0/26 | |
|
364 | elif(i <= 64.0/100*(ncolor-1)): gf = 1.0 | |
|
365 | elif(i <= 91.0/100*(ncolor-1)): gf = (-100.0/27)*i/(ncolor-1) + 91.0/27 | |
|
366 | else: gf = 0.0 | |
|
367 | ||
|
368 | if(i <= 11.0/100*(ncolor-1)): bf = (50.0/11)*i/(ncolor-1) + 0.5 | |
|
369 | elif(i <= 34.0/100*(ncolor-1)): bf = 1.0 | |
|
370 | elif(i <= 65.0/100*(ncolor-1)): bf = (-100.0/31)*i/(ncolor-1) + 65.0/31 | |
|
371 | else: bf = 0 | |
|
137 | xpos,ypos: coordenadas que indican la posicion del plot en el frame | |
|
372 | 138 |
|
|
373 | r[i] = rf | |
|
374 | g[i] = gf | |
|
375 | b[i] = bf | |
|
376 | ||
|
377 | pos[i] = float(i)/float(ncolor-1) | |
|
378 | ||
|
379 | ||
|
380 | plplot.plscmap1n(ncolor) | |
|
381 | plplot.plscmap1l(1, pos, r, g, b) | |
|
382 | ||
|
383 | ||
|
384 | ||
|
385 | if colormap=="br_green": | |
|
386 | ncolor = 256 | |
|
387 | # Hue ranges from blue (240 deg) to red (0 or 360 deg) | |
|
388 | h = numpy.array((240., 0.)) | |
|
389 | # Lightness and saturation are constant (values taken from C example). | |
|
390 | l = numpy.array((0.6, 0.6)) | |
|
391 | s = numpy.array((0.8, 0.8)) | |
|
392 | ||
|
393 | # number of cmap1 colours is 256 in this case. | |
|
394 | plplot.plscmap1n(ncolor) | |
|
395 | # Interpolate between control points to set up cmap1. | |
|
396 | plplot.plscmap1l(0, i, h, l, s) | |
|
397 | ||
|
398 | return None | |
|
399 | ||
|
400 | if colormap=="tricolor": | |
|
401 | ncolor = 3 | |
|
402 | # Hue ranges from blue (240 deg) to red (0 or 360 deg) | |
|
403 | h = numpy.array((240., 0.)) | |
|
404 | # Lightness and saturation are constant (values taken from C example). | |
|
405 | l = numpy.array((0.6, 0.6)) | |
|
406 | s = numpy.array((0.8, 0.8)) | |
|
407 | ||
|
408 | # number of cmap1 colours is 256 in this case. | |
|
409 | plplot.plscmap1n(ncolor) | |
|
410 | # Interpolate between control points to set up cmap1. | |
|
411 | plplot.plscmap1l(0, i, h, l, s) | |
|
412 | ||
|
413 | return None | |
|
414 | ||
|
415 | if colormap == 'rgb' or colormap == 'rgb666': | |
|
139 | """ | |
|
416 | 140 | |
|
417 | color_sz = 6 | |
|
418 | ncolor = color_sz*color_sz*color_sz | |
|
419 | pos = numpy.zeros((ncolor)) | |
|
420 | r = numpy.zeros((ncolor)) | |
|
421 | g = numpy.zeros((ncolor)) | |
|
422 | b = numpy.zeros((ncolor)) | |
|
423 | ind = 0 | |
|
424 | for ri in range(color_sz): | |
|
425 | for gi in range(color_sz): | |
|
426 | for bi in range(color_sz): | |
|
427 | r[ind] = ri/(color_sz-1.0) | |
|
428 | g[ind] = gi/(color_sz-1.0) | |
|
429 | b[ind] = bi/(color_sz-1.0) | |
|
430 | pos[ind] = ind/(ncolor-1.0) | |
|
431 | ind += 1 | |
|
432 | rgb_lvl = [6,6,6] #Levels for RGB colors | |
|
141 | plplot.pladv(id) | |
|
142 | plplot.plvpor(xpos[0], xpos[1], ypos[0], ypos[1]) | |
|
143 | plplot.plwind(float(xmin),float(xmax), float(ymin), float(ymax)) | |
|
433 | 144 | |
|
434 |
if color |
|
|
435 |
|
|
|
436 | pos = numpy.zeros((ncolor)) | |
|
437 | r = numpy.zeros((ncolor)) | |
|
438 | g = numpy.zeros((ncolor)) | |
|
439 | b = numpy.zeros((ncolor)) | |
|
440 | ind = 0 | |
|
441 | for ri in range(8): | |
|
442 | for gi in range(8): | |
|
443 | for bi in range(4): | |
|
444 | r[ind] = ri/(6-1.0) | |
|
445 | g[ind] = gi/(7-1.0) | |
|
446 | b[ind] = bi/(6-1.0) | |
|
447 | pos[ind] = ind/(ncolor-1.0) | |
|
448 | ind += 1 | |
|
449 | rgb_lvl = [6,7,6] #Levels for RGB colors | |
|
450 | ||
|
451 | if colormap == 'rgb685': | |
|
452 | ncolor = 6*8*5 | |
|
453 | pos = numpy.zeros((ncolor)) | |
|
454 | r = numpy.zeros((ncolor)) | |
|
455 | g = numpy.zeros((ncolor)) | |
|
456 | b = numpy.zeros((ncolor)) | |
|
457 | ind = 0 | |
|
458 | for ri in range(8): | |
|
459 | for gi in range(8): | |
|
460 | for bi in range(4): | |
|
461 | r[ind] = ri/(6-1.0) | |
|
462 | g[ind] = gi/(8-1.0) | |
|
463 | b[ind] = bi/(5-1.0) | |
|
464 | pos[ind] = ind/(ncolor-1.0) | |
|
465 | ind += 1 | |
|
466 | rgb_lvl = [6,8,5] #Levels for RGB colors | |
|
467 | ||
|
468 | if colormap == 'rgb884': | |
|
469 | ncolor = 8*8*4 | |
|
470 | pos = numpy.zeros((ncolor)) | |
|
471 | r = numpy.zeros((ncolor)) | |
|
472 | g = numpy.zeros((ncolor)) | |
|
473 | b = numpy.zeros((ncolor)) | |
|
474 | ind = 0 | |
|
475 | for ri in range(8): | |
|
476 | for gi in range(8): | |
|
477 | for bi in range(4): | |
|
478 | r[ind] = ri/(8-1.0) | |
|
479 | g[ind] = gi/(8-1.0) | |
|
480 | b[ind] = bi/(4-1.0) | |
|
481 | pos[ind] = ind/(ncolor-1.0) | |
|
482 | ind += 1 | |
|
483 | rgb_lvl = [8,8,4] #Levels for RGB colors | |
|
484 | ||
|
485 | if ncolor == None: | |
|
486 | raise ValueError, "The colormap selected is not valid" | |
|
487 | ||
|
488 | plplot.plscmap1n(ncolor) | |
|
489 | plplot.plscmap1l(1, pos, r, g, b) | |
|
490 | ||
|
491 | return rgb_lvl | |
|
492 | ||
|
493 | def set_colormap(colormap="jet"): | |
|
494 | cmap1_init(colormap) | |
|
495 | ||
|
496 | def save_figure(filename,width,height): | |
|
497 | curr_strm = plplot.plgstrm() | |
|
498 | save_strm = plplot.plmkstrm() | |
|
499 | plplot.plsetopt("geometry", "%dx%d"%(width,height)) | |
|
500 | if sys.platform == "darwin": | |
|
501 | plplot.plsdev("png") | |
|
502 | if sys.platform == "linux": | |
|
503 | plplot.plsdev("pngcairo") | |
|
504 | plplot.plsfnam(filename) | |
|
505 | plplot.plcpstrm(curr_strm,0) | |
|
506 | plplot.plreplot() | |
|
507 | plplot.plend1() | |
|
508 | plplot.plsstrm(curr_strm) | |
|
509 | ||
|
510 | def set_new_figure(): | |
|
511 | plplot.plbop() | |
|
512 | plplot.pladv(0) | |
|
513 | ||
|
514 | def close_figure(): | |
|
515 | plplot.pleop() | |
|
516 | ||
|
517 | def set_strm(indexPlot): | |
|
518 | plplot.plsstrm(indexPlot) | |
|
519 | ||
|
520 | def refresh(): | |
|
521 | plplot.plflush() | |
|
522 | ||
|
523 | def show(): | |
|
524 | plplot.plspause(True) | |
|
525 | plplot.plend() | |
|
526 | ||
|
527 | def set_title(pltitle,color, szchar=0.7): | |
|
528 | setSubpages(1, 0) | |
|
529 | plplot.pladv(0) | |
|
530 | plplot.plvpor(0., 1., 0., 1.) | |
|
531 | ||
|
532 | if color == "black": | |
|
145 | if color == "blue": | |
|
146 | colline = 9 | |
|
147 | if color == "green": | |
|
148 | colline = 3 | |
|
149 | ||
|
150 | plplot.plcol0(colline) | |
|
151 | plplot.plline(x, y) | |
|
533 | 152 | plplot.plcol0(1) |
|
534 | if color == "white": | |
|
535 | plplot.plcol0(15) | |
|
536 | ||
|
537 | plplot.plschr(0.0,szchar) | |
|
538 | plplot.plmtex("t",-1., 0.5, 0.5, pltitle) | |
|
539 | ||
|
540 | def set_line_style(style): | |
|
541 | plplot.pllsty(style) | |
|
542 | ||
|
543 | def set_color(color): | |
|
544 | plplot.plcol0(color) | |
|
545 | ||
|
546 | def set_labels(xlabel, ylabel, title): | |
|
547 | plplot.pllab(xlabel, ylabel, title) | |
|
548 | ||
|
549 | def box(subplot, xpos, ypos, xmin, xmax, ymin, ymax, xopt, yopt, szchar, xaxisastime, timefmt="%H:%M"): | |
|
550 | plplot.pladv(subplot) | |
|
551 | plplot.plschr(0.0,szchar-0.05) | |
|
552 | plplot.plvpor(xpos[0], xpos[1], ypos[0], ypos[1]) | |
|
553 | plplot.plwind(float(xmin), | |
|
554 | float(xmax), | |
|
555 | float(ymin), | |
|
556 | float(ymax) | |
|
557 | ) | |
|
558 | if xaxisastime: | |
|
559 | plplot.pltimefmt(timefmt) | |
|
560 | timedelta = (xmax - xmin + 1)/8. | |
|
561 | plplot.plbox(xopt, timedelta, 3, yopt, 0.0, 0) | |
|
562 | else: | |
|
563 | plplot.plbox(xopt, 0.0, 0, yopt, 0.0, 0) | |
|
564 | ||
|
565 | def colorbar(xmin=0., xmax=1., ymin=0., ymax=1.): | |
|
566 | data = numpy.arange(256) | |
|
567 | data = numpy.reshape(data, (1,-1)) | |
|
568 | ||
|
569 | plplot.plimage(data, | |
|
570 | float(xmin), | |
|
571 | float(xmax), | |
|
572 | float(ymin), | |
|
573 | float(ymax), | |
|
574 | 0., | |
|
575 | 255., | |
|
576 | float(xmin), | |
|
577 | float(xmax), | |
|
578 | float(ymin), | |
|
579 | float(ymax)) | |
|
580 | ||
|
581 | def basicline_timeplot(x, y,colline=1): | |
|
582 | plplot.plcol0(colline) | |
|
583 | plplot.plline(x, y) | |
|
584 | plplot.plcol0(1) | |
|
585 | ||
|
586 | def basic_xy_plot(x, y): | |
|
587 | plplot.plline(x, y) | |
|
588 | ||
|
589 | def basic_pcolor_plot(data, x, y, xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None): | |
|
590 | """ | |
|
591 | """ | |
|
592 | if xmin == None: xmin = x[0] | |
|
593 | if xmax == None: xmax = x[-1] | |
|
594 | if ymin == None: ymin = y[0] | |
|
595 | if ymax == None: ymax = y[-1] | |
|
596 | if zmin == None: zmin = numpy.nanmin(data) | |
|
597 | if zmax == None: zmax = numpy.nanmax(data) | |
|
598 | ||
|
599 | plplot.plimage(data, | |
|
600 | float(x[0]), | |
|
601 | float(x[-1]), | |
|
602 | float(y[0]), | |
|
603 | float(y[-1]), | |
|
604 | float(zmin), | |
|
605 | float(zmax), | |
|
606 | float(xmin), | |
|
607 | float(xmax), | |
|
608 | float(ymin), | |
|
609 | float(ymax) | |
|
610 | ) | |
|
611 | ||
|
612 | def image_plot(self,x,y,z,xrange,yrange,zrange): | |
|
613 | xi = x[0] | |
|
614 | xf = x[-1] | |
|
615 | yi = y[0] | |
|
616 | yf = y[-1] | |
|
617 | ||
|
618 | plplot.plimage(z, | |
|
619 | float(xi), | |
|
620 | float(xf), | |
|
621 | float(yi), | |
|
622 | float(yf), | |
|
623 | float(zrange[0]), | |
|
624 | float(zrange[1]), | |
|
625 | float(xi), | |
|
626 | float(xf), | |
|
627 | float(yrange[0]), | |
|
628 | yrange[1]) | |
|
629 | ||
|
630 | def adv_pcolor_plot(data, x, y, xg, yg, xmin=None, xmax=None, ymin=None, ymax=None, zmin=0., zmax=0.): | |
|
631 | plplot.plimagefr(data, | |
|
632 | float(xmin), | |
|
633 | float(xmax), | |
|
634 | float(ymin), | |
|
635 | float(ymax), | |
|
636 | 0., | |
|
637 | 0., | |
|
638 | float(zmin), | |
|
639 | float(zmax), | |
|
640 | plplot.pltr2, | |
|
641 | xg, | |
|
642 | yg) | |
|
643 | ||
|
644 | #------------------------------------ | |
|
645 | ||
|
646 | #def get_grid(x, y, deltax=None, deltay=None): | |
|
647 | # | |
|
648 | # if not(len(x)>0 and len(y)>0): | |
|
649 | # raise ValueError, "x axis and y axis are empty" | |
|
650 | # | |
|
651 | # if deltax == None: deltax = x[-1] - x[-2] | |
|
652 | # if deltay == None: deltay = y[-1] - y[-2] | |
|
653 | # | |
|
654 | # x1 = numpy.append(x, x[-1] + deltax) | |
|
655 | # y1 = numpy.append(y, y[-1] + deltay) | |
|
656 | # | |
|
657 | # xg = (numpy.multiply.outer(x1, numpy.ones(len(y1)))) | |
|
658 | # yg = (numpy.multiply.outer(numpy.ones(len(x1)), y1)) | |
|
659 | # | |
|
660 | # self.__xg = xg | |
|
661 | # self.__yg = yg | |
|
662 | # | |
|
663 | # return xg, yg | |
|
664 | # | |
|
665 | #def advPcolorPlot(data, x, y, xmin=None, xmax=None, ymin=None, ymax=None, zmin=0., zmax=0., deltax=1.0, deltay=None, getGrid = True): | |
|
666 | # if getGrid: | |
|
667 | # xg, yg = self.__getBoxpltr(x, y, deltax, deltay) | |
|
668 | # else: | |
|
669 | # xg = self.__xg | |
|
670 | # yg = self.__yg | |
|
671 | # | |
|
672 | # plplot.plimagefr(data, | |
|
673 | # float(xmin), | |
|
674 | # float(xmax), | |
|
675 | # float(ymin), | |
|
676 | # float(ymax), | |
|
677 | # 0., | |
|
678 | # 0., | |
|
679 | # float(zmin), | |
|
680 | # float(zmax), | |
|
681 | # plplot.pltr2, | |
|
682 | # xg, | |
|
683 | # yg) | |
|
153 | plplot.plbox("bcst", 0.0, 0, "bcst", 0.0, 0) |
@@ -1,116 +1,106 | |||
|
1 | 1 | import numpy |
|
2 | 2 | from schainPlot import * |
|
3 | #from schainPlotLib import Driver | |
|
3 | 4 | |
|
4 | 5 | class ScopeFigure(Figure): |
|
5 | 6 | overplot = 0 |
|
6 | 7 | xw = 700 |
|
7 |
yw = 6 |
|
|
8 | yw = 650 | |
|
9 | colorbar = None | |
|
10 | # frameObjList = [] | |
|
8 | 11 | |
|
9 | 12 | def __init__(self,idfigure,nframes,wintitle,driver): |
|
10 | ||
|
11 | args = (0, 0) | |
|
12 | 13 | colormap = None |
|
13 | Figure.__init__(self,idfigure,nframes,wintitle,self.xw,self.yw,self.overplot,driver,colormap,*args) | |
|
14 | colorbar = False | |
|
15 | addGraph = 0 | |
|
16 | args=(addGraph, addGraph) | |
|
17 | ||
|
14 | 18 | |
|
19 | self.idfigure = idfigure | |
|
15 | 20 | self.nframes = nframes |
|
16 | self.showColorbar = 0 | |
|
17 |
self. |
|
|
18 | ||
|
19 | def getSubplots(self): | |
|
20 | nrows = self.nframes | |
|
21 | ncolumns = 1 | |
|
21 | self.wintitle = wintitle | |
|
22 | # self.xw = | |
|
23 | # self.yw = | |
|
24 | # self.overplot = | |
|
25 | self.driver = driver | |
|
26 | self.colorbar = colorbar | |
|
27 | self.colormap = colormap | |
|
22 | 28 | |
|
23 | return nrows, ncolumns | |
|
24 | ||
|
25 | def __createFrames(self): | |
|
26 | for frame in range(self.nframes): | |
|
27 | frameObj = ScopeFrame(idFrame = frame) | |
|
28 | ||
|
29 | self.frameObjList.append(frameObj) | |
|
30 | ||
|
29 | self.drvObj = Driver(self.driver, self.idfigure, self.xw, self.yw, self.wintitle, self.overplot, self.colorbar, self.colormap) | |
|
30 | self.drvObj.driver.setFigure() | |
|
31 | 31 | |
|
32 | ||
|
33 | class ScopeFrame(Frame): | |
|
34 | def __init__(self,idFrame): | |
|
35 | self.idFrame = idFrame | |
|
36 | self.showGraph1 = 0 | |
|
37 | self.showGraph2 = 0 | |
|
38 | ||
|
39 | def setXYPos(self): | |
|
40 | pass | |
|
41 | ||
|
42 | class RTIFigure(Figure): | |
|
43 | ||
|
44 | overplot = 1 # igual a 1 porque el grafico es RTI, para el caso de Spectra(Spc,CrossSpc) overplot = 0 | |
|
45 | xw = 700 | |
|
46 | yw = 150 | |
|
47 | ||
|
48 | ||
|
49 | def __init__(self, idfigure, nframes, wintitle, driver, colormap, showColorbar, showPowerProfile): | |
|
50 | ||
|
51 | showGraphs = (showColorbar, showPowerProfile) | |
|
52 | ||
|
53 | Figure.__init__(self, | |
|
54 | idfigure=idfigure, | |
|
55 | nframes = nframes, | |
|
56 | wintitle=wintitle, | |
|
57 | xw=self.xw, | |
|
58 | yw=self.yw, | |
|
59 | overplot=self.overplot, | |
|
60 | driver=driver, | |
|
61 | colormap=colormap, | |
|
62 | *showGraphs) | |
|
63 | ||
|
64 | self.nframes = nframes | |
|
65 | self.showColorbar = showColorbar | |
|
66 | self.showPowerProfile = showPowerProfile | |
|
32 | # Figure.__init__(self,idfigure,nframes,wintitle,self.xw,self.yw,self.overplot,driver,colorbar,colormap,*args) | |
|
67 | 33 | |
|
68 | 34 | def getSubplots(self): |
|
69 | 35 | nrows = self.nframes |
|
70 | 36 | ncolumns = 1 |
|
71 | ||
|
72 | 37 | return nrows, ncolumns |
|
73 | ||
|
74 |
def |
|
|
38 | ||
|
39 | def createFrames(self): | |
|
75 | 40 | for frame in range(self.nframes): |
|
76 |
frameObj = |
|
|
77 | showGraph1 = self.showColorbar, | |
|
78 | showGraph2 = self.showPowerProfile | |
|
79 | ) | |
|
80 | ||
|
41 | frameObj = ScopeFrame(self.drvObj,frame + 1) | |
|
81 | 42 | self.frameObjList.append(frameObj) |
|
82 | ||
|
83 | class RTIFrame(Frame): | |
|
84 | def __init__(self,idFrame, showColorbar, showPowerProfile): | |
|
85 | self.idFrame = idFrame | |
|
86 | self.showGraph1 = showColorbar | |
|
87 | self.showGraph2 = showPowerProfile | |
|
43 | ||
|
88 | 44 | |
|
89 | def setXYPos(self): | |
|
90 | pass | |
|
45 | class ScopeFrame(Frame): | |
|
46 | # plotObjList = [] | |
|
47 | xlabel = "" | |
|
48 | ylabel = "" | |
|
49 | title = "" | |
|
50 | def __init__(self,drvObj,idframe): | |
|
51 | self.drvObj = drvObj | |
|
52 | self.idframe = idframe | |
|
53 | self.nplots = 1 #nplots/frame | |
|
54 | self.createPlots() | |
|
55 | # Frame.__init__(self, drvObj, idframe) | |
|
91 | 56 | |
|
92 | class SelfSpcFigure(Figure): | |
|
93 | def __init__(self): | |
|
94 | pass | |
|
95 | ||
|
96 | class SelfSpcFrame(Frame): | |
|
97 | def __init__(self): | |
|
98 | pass | |
|
57 | def getScreenPosMainPlot(self):#cada Frame determina las coordenadas de los plots | |
|
58 | xi = 0.07; xw = 0.9 | |
|
59 | yi = 0.20; yw = 0.75 | |
|
60 | return xi,yi,xw,yw | |
|
99 | 61 | |
|
100 | class CrossSpcFigure(Figure): | |
|
101 | def __init__(self): | |
|
102 | pass | |
|
62 | def createPlots(self): | |
|
63 | plotObjList = [] | |
|
64 | for idplot in range(self.nplots): | |
|
65 | xi, yi, xw, yw = self.getScreenPos(idplot) | |
|
66 | plotObj = Plot1D(self.drvObj, self.idframe, idplot, xi, yi, xw, yw) | |
|
67 | plotObjList.append(plotObj) | |
|
68 | self.plotObjList = plotObjList | |
|
69 | # self.plotObjList.append(plotObj) | |
|
103 | 70 | |
|
104 | class CrossSpcFrame(Frame): | |
|
105 | def __init__(self): | |
|
106 | pass | |
|
71 | def plot(self, x, y, z=None): | |
|
72 | for plotObj in self.plotObjList: | |
|
73 | plotObj.plot(x, y) | |
|
74 | ||
|
107 | 75 | |
|
76 | class Plot1D(Plot): | |
|
77 | ||
|
78 | def __init__(self, drvObj, idframe, idplot, xi, yi, xw, yw): | |
|
79 | self.drvObj = drvObj | |
|
80 | self.idframe = idframe | |
|
81 | self.idplot = idplot | |
|
82 | self.xi = xi | |
|
83 | self.yi = yi | |
|
84 | self.xw = xw | |
|
85 | self.yw = yw | |
|
86 | self.xpos = [self.xi,self.xw] | |
|
87 | self.ypos = [self.yi,self.yw] | |
|
88 | self.xaxisastime = False | |
|
89 | self.timefmt = None | |
|
90 | self.xopt = "bcnst" | |
|
91 | self.yopt = "bcnstv" | |
|
92 | self.szchar = 1.0 | |
|
93 | self.title = "Channel %d"%self.idframe | |
|
94 | self.xlabel = "x-axis" | |
|
95 | self.ylabel = "y-axis" | |
|
108 | 96 | |
|
109 | if __name__ == '__main__': | |
|
110 | idfigure=0 | |
|
111 | nframes=2 | |
|
112 | wintitle='' | |
|
113 | driver='plplot' | |
|
114 | scopeObj = ScopeFigure(idfigure,nframes,wintitle,driver) | |
|
115 | 97 | |
|
116 | ||
|
98 | def plot(self,x,y): | |
|
99 | if y.dtype == "complex128": | |
|
100 | color="blue" | |
|
101 | self.plotBasicLine(x, y.real, color) | |
|
102 | color="red" | |
|
103 | self.plotBasicLine(x, y.imag, color) | |
|
104 | else: | |
|
105 | color="blue" | |
|
106 | self.plotBasicLine(x, y, color) |
General Comments 0
You need to be logged in to leave comments.
Login now