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