@@ -1,167 +1,172 | |||
|
1 | 1 | import numpy |
|
2 | import sys | |
|
2 | 3 | import schainPlot |
|
3 | 4 | |
|
4 | 5 | class RTIFigure(schainPlot.Figure): |
|
5 | 6 | |
|
6 | 7 | __driverObj = None |
|
7 | 8 | __isDriverOpen = False |
|
8 | 9 | __isFigureOpen = False |
|
9 | 10 | __isConfig = False |
|
10 | 11 | __xw = None |
|
11 | 12 | __yw = None |
|
12 | 13 | |
|
13 | 14 | xmin = None |
|
14 | 15 | xmax = None |
|
15 | 16 | minvalue = None |
|
16 | 17 | maxvalue = None |
|
17 | 18 | |
|
18 |
id |
|
|
19 | id = None | |
|
19 | 20 | nframes = None |
|
20 | 21 | wintitle = wintitle |
|
21 | 22 | colormap = None |
|
22 | 23 | driver = None |
|
23 | 24 | overplot = None |
|
24 | 25 | |
|
25 | 26 | frameObjList = [] |
|
26 | 27 | |
|
27 |
def __init__(self, id |
|
|
28 | def __init__(self, id, wintitle, xw=600, yw=800, overplot=0, driver=None, colormap='br_green', *showGraphs): | |
|
28 | 29 | |
|
29 |
self.id |
|
|
30 | self.id = id | |
|
30 | 31 | self.wintitle = wintitle |
|
31 | 32 | self.colormap = colormap |
|
32 | 33 | self.driver = driver |
|
33 | 34 | self.overplot = overplot |
|
34 | 35 | |
|
35 | 36 | self.showGraphs = showGraphs |
|
36 | 37 | |
|
37 | self.__driverObj = Driver(driver) | |
|
38 | showColorbar = showGraphs[0] | |
|
39 | showPowerprofile = showGraphs[1] | |
|
40 | self.__driverObj = Driver(id, wintitle,xw,yw,overplot,driver,colormap,showColorbar,showPowerprofile) | |
|
41 | ||
|
42 | ||
|
38 | 43 | |
|
39 | 44 | def __openDriver(self): |
|
40 | 45 | |
|
41 |
self.__driverObj.openDriver(self.id |
|
|
46 | self.__driverObj.openDriver(self.id, self.wintitle, self.xw, self.yw) | |
|
42 | 47 | |
|
43 | 48 | def __openFigure(self): |
|
44 | 49 | |
|
45 | 50 | nrows, ncolumns = self.getSubplots() |
|
46 | 51 | |
|
47 | 52 | self.__driverObj.openFigure() |
|
48 | 53 | self.__driverObj.setSubPlots(nrows, ncolumns) |
|
49 | 54 | |
|
50 | 55 | |
|
51 | 56 | def __isOutOfXRange(self, x): |
|
52 | 57 | pass |
|
53 | 58 | |
|
54 | 59 | def __changeXRange(self, x): |
|
55 | 60 | pass |
|
56 | 61 | |
|
57 | 62 | def __createFrames(self): |
|
58 | 63 | |
|
59 | 64 | for frame in range(self.nframes): |
|
60 | 65 | frameObj = Frame(idframe = frame, |
|
61 | 66 | showGraph1 = self.showGraph1, |
|
62 | 67 | showGraph2 = self.showGraph2 |
|
63 | 68 | ) |
|
64 | 69 | |
|
65 | 70 | self.frameObjList.append(frameObj) |
|
66 | 71 | |
|
67 | 72 | def plot1DArray(self, data1D, x=None, channelList=None, xmin=None, xmax=None, minvalue=None, maxvlaue=None, save=False, gpath='./'): |
|
68 | 73 | |
|
69 | 74 | nx, ny = data1D.shape |
|
70 | 75 | |
|
71 | 76 | if channelList == None: |
|
72 | 77 | chanellList = range(nx) |
|
73 | 78 | |
|
74 | 79 | if x == None: |
|
75 | 80 | x = numpy.arange(data1D.size) |
|
76 | 81 | |
|
77 | 82 | |
|
78 | 83 | |
|
79 | 84 | |
|
80 | 85 | if not(self.__isDriverOpen): |
|
81 | 86 | self.__openDriver() |
|
82 | 87 | self.__isDriverOpen = True |
|
83 | 88 | |
|
84 | 89 | if not(self.__isConfig): |
|
85 | 90 | if self.xmin == None: xmin = numpy.min(x) |
|
86 | 91 | if self.xmax == None: xmax = numpy.max(x) |
|
87 | 92 | if self.minvalue == None: minvalue = numpy.min(data1D) |
|
88 | 93 | if self.maxvalue == None: maxvalue = numpy.max(data1D) |
|
89 | 94 | |
|
90 | 95 | self.__createFrames() |
|
91 | 96 | self.__isConfig = True |
|
92 | 97 | |
|
93 | 98 | |
|
94 | 99 | if not(self.__isOutOfXRange(x)): |
|
95 | 100 | self.__changeXRange(x) |
|
96 | 101 | |
|
97 | 102 | if self.__isFigureOpen: |
|
98 | 103 | self.__driverObj.closePage() |
|
99 | 104 | self.__isFigureOpen = False |
|
100 | 105 | |
|
101 | 106 | if not(self.__isFigureOpen): |
|
102 | 107 | self.__openFigure() |
|
103 | 108 | |
|
104 | 109 | for channel in channelList: |
|
105 | 110 | frameObj = self.frameObjList[channel] |
|
106 | 111 | frameObj.init(xmin=xmin, |
|
107 | 112 | xmax=xmax, |
|
108 | 113 | minvalue=minvalue, |
|
109 | 114 | maxvalue=maxvalue) |
|
110 | 115 | |
|
111 | 116 | self.__isFigureOpen = True |
|
112 | 117 | |
|
113 | 118 | |
|
114 | 119 | for channel in channelList: |
|
115 | 120 | dataCh = data1D[channel] |
|
116 | 121 | frameObj = self.frameObjList[channel] |
|
117 | 122 | |
|
118 | 123 | frameObj.clearData() |
|
119 | 124 | frameObj.plot(dataCh) |
|
120 | 125 | |
|
121 | 126 | frameObj.refresh() |
|
122 | 127 | |
|
123 | 128 | if not(self.overplot): |
|
124 | 129 | self.__driverObj.closeFigure() |
|
125 | 130 | self.__isFigureOpen = False |
|
126 | 131 | |
|
127 | 132 | |
|
128 | 133 | def plot2DArray(self, x, y, data2D, xmin=None, xmax=None, ymin=None, ymax=None, minvalue=None, maxvalue=None, save=False, gpath='./'): |
|
129 | 134 | |
|
130 | 135 | if not(self.__isCOpen): |
|
131 | 136 | self.__createFrames() |
|
132 | 137 | self.__openFigure() |
|
133 | 138 | self.__isOpen = True |
|
134 | 139 | |
|
135 | 140 | if not(self.__isConfig): |
|
136 | 141 | self.setRange(xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, minvalue=minvalue, maxvalue=maxvalue) |
|
137 | 142 | |
|
138 | 143 | self.__isConfig = True |
|
139 | 144 | |
|
140 | 145 | for channel in channelList: |
|
141 | 146 | dataCh = dataArray[channel] |
|
142 | 147 | frameObj = frameObjList[channel] |
|
143 | 148 | frameObj.plot(dataCh) |
|
144 | 149 | |
|
145 | 150 | def saveFigure(self, filename): |
|
146 | 151 | pass |
|
147 | 152 | |
|
148 | 153 | |
|
149 | 154 | def getSubplots(self): |
|
150 | 155 | |
|
151 | 156 | raise ValueError, '' |
|
152 | 157 | |
|
153 | 158 | class RTIFrame(schainPlot.Frame): |
|
154 | 159 | |
|
155 | 160 | def __init__(self): |
|
156 | 161 | pass |
|
157 | 162 | |
|
158 | 163 | def setup(self): |
|
159 | 164 | pass |
|
160 | 165 | |
|
161 | 166 | class RTIPlot(schainPlot.Plot): |
|
162 | 167 | |
|
163 | 168 | def __init__(self): |
|
164 | 169 | pass |
|
165 | 170 | |
|
166 | 171 | def setup(self): |
|
167 | 172 | pass No newline at end of file |
@@ -1,468 +1,487 | |||
|
1 | 1 | import plplot |
|
2 | 2 | import numpy |
|
3 | 3 | import sys |
|
4 | 4 | |
|
5 | class Driver: | |
|
5 | class PlplotDriver: | |
|
6 | 6 | |
|
7 | 7 | __isDriverOpen = False |
|
8 | ||
|
9 | def __init__(self, driver=plplot): | |
|
8 | ||
|
9 | def __init__(self, id=None, driver=None, wintitle, overplot, colormap, showGraph1, showGraph2): | |
|
10 | 10 | |
|
11 | self.idStream = idStream | |
|
12 | self.nFrames = nFrames | |
|
13 | self.winTitle = winTitle | |
|
14 | self.colormap = colormap | |
|
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 | |
|
15 | 23 | self.driver = driver |
|
16 | 24 | |
|
25 | ||
|
26 | self.nFrames = nFrames | |
|
27 | self.wintitle = wintitle | |
|
28 | self.colormap = colormap | |
|
17 | 29 | self.showGraph1 = showGraph1 |
|
18 | 30 | self.showGraph2 = showGraph2 |
|
19 | 31 | |
|
20 | 32 | self.overplot = overplot |
|
21 | 33 | |
|
22 | 34 | def configDriver(self): |
|
23 | ||
|
35 | if self.driver == "": | |
|
36 | import plplot | |
|
37 | ||
|
24 | 38 | pass |
|
25 | 39 | |
|
26 | 40 | def openDriver(self): |
|
27 | 41 | |
|
28 | 42 | pass |
|
29 | 43 | |
|
30 | 44 | def closeDriver(self): |
|
31 | 45 | |
|
32 | 46 | pass |
|
33 | 47 | |
|
34 | 48 | def openPage(self): |
|
35 | 49 | pass |
|
36 | 50 | |
|
37 | 51 | def closePage(self): |
|
38 | 52 | |
|
39 | 53 | pass |
|
40 | 54 | |
|
41 | 55 | def setColorMap(self): |
|
42 | 56 | |
|
43 | 57 | pass |
|
44 | 58 | |
|
45 | 59 | def setBox(self): |
|
46 | 60 | |
|
47 | 61 | pass |
|
48 | 62 | |
|
49 | 63 | def refreshBox(self): |
|
50 | 64 | |
|
51 | 65 | pass |
|
52 | 66 | |
|
53 | 67 | def save(self): |
|
54 | 68 | |
|
55 | 69 | pass |
|
56 | 70 | |
|
57 | 71 | def show(self): |
|
58 | 72 | |
|
59 | 73 | pass |
|
60 | 74 | |
|
61 | 75 | def colorbarPlot(self): |
|
62 | 76 | |
|
63 | 77 | pass |
|
64 | 78 | |
|
65 | 79 | def linePlot(self): |
|
66 | 80 | |
|
67 | 81 | pass |
|
68 | 82 | |
|
69 | 83 | def pcolorPlot(self): |
|
70 | 84 | |
|
71 | 85 | pass |
|
72 | 86 | |
|
73 | 87 | def setLabels(self): |
|
74 | 88 | |
|
75 | 89 | pass |
|
76 | 90 | |
|
77 | 91 | def figure(self): |
|
78 | 92 | |
|
79 | 93 | pass |
|
80 | 94 | |
|
81 | 95 | def setSubPlots(self): |
|
82 | 96 | |
|
83 | 97 | pass |
|
84 | 98 | |
|
85 | 99 | |
|
86 | def config_driver(idStream, wintitle, width, height): | |
|
87 | plplot.plsstrm(idStream) | |
|
100 | ||
|
101 | class MplDriver: | |
|
102 | def __init__(self): | |
|
103 | pass | |
|
104 | ||
|
105 | def config_driver(id, wintitle, width, height): | |
|
106 | plplot.plsstrm(id) | |
|
88 | 107 | plplot.plparseopts([wintitle],plplot.PL_PARSE_FULL) |
|
89 | 108 | plplot.plsetopt("geometry", "%dx%d"%(width,height)) |
|
90 | 109 | |
|
91 | 110 | def ini_driver(driver): |
|
92 | 111 | if sys.platform == "darwin": |
|
93 | 112 | plplot.plsdev("xwin") |
|
94 | 113 | if sys.platform == "linux": |
|
95 | 114 | plplot.plsdev("xcairo") |
|
96 | 115 | plplot.plscolbg(255,255,255) |
|
97 | 116 | plplot.plscol0(1,0,0,0) |
|
98 | 117 | plplot.plinit() |
|
99 | 118 | plplot.plspause(False) |
|
100 | 119 | |
|
101 | 120 | def set_subpages(ncol,nrow): |
|
102 | 121 | plplot.plssub(ncol,nrow) |
|
103 | 122 | |
|
104 | 123 | def cmap1_init(colormap="gray"): |
|
105 | 124 | |
|
106 | 125 | if colormap == None: |
|
107 | 126 | return |
|
108 | 127 | |
|
109 | 128 | ncolor = None |
|
110 | 129 | rgb_lvl = None |
|
111 | 130 | |
|
112 | 131 | # Routine for defining a specific color map 1 in HLS space. |
|
113 | 132 | # if gray is true, use basic grayscale variation from half-dark to light. |
|
114 | 133 | # otherwise use false color variation from blue (240 deg) to red (360 deg). |
|
115 | 134 | |
|
116 | 135 | # Independent variable of control points. |
|
117 | 136 | i = numpy.array((0., 1.)) |
|
118 | 137 | if colormap=="gray": |
|
119 | 138 | ncolor = 256 |
|
120 | 139 | # Hue for control points. Doesn't matter since saturation is zero. |
|
121 | 140 | h = numpy.array((0., 0.)) |
|
122 | 141 | # Lightness ranging from half-dark (for interest) to light. |
|
123 | 142 | l = numpy.array((0.5, 1.)) |
|
124 | 143 | # Gray scale has zero saturation |
|
125 | 144 | s = numpy.array((0., 0.)) |
|
126 | 145 | |
|
127 | 146 | # number of cmap1 colours is 256 in this case. |
|
128 | 147 | plplot.plscmap1n(ncolor) |
|
129 | 148 | # Interpolate between control points to set up cmap1. |
|
130 | 149 | plplot.plscmap1l(0, i, h, l, s) |
|
131 | 150 | |
|
132 | 151 | return None |
|
133 | 152 | |
|
134 | 153 | if colormap == 'jet': |
|
135 | 154 | ncolor = 256 |
|
136 | 155 | pos = numpy.zeros((ncolor)) |
|
137 | 156 | r = numpy.zeros((ncolor)) |
|
138 | 157 | g = numpy.zeros((ncolor)) |
|
139 | 158 | b = numpy.zeros((ncolor)) |
|
140 | 159 | |
|
141 | 160 | for i in range(ncolor): |
|
142 | 161 | if(i <= 35.0/100*(ncolor-1)): rf = 0.0 |
|
143 | 162 | elif (i <= 66.0/100*(ncolor-1)): rf = (100.0/31)*i/(ncolor-1) - 35.0/31 |
|
144 | 163 | elif (i <= 89.0/100*(ncolor-1)): rf = 1.0 |
|
145 | 164 | else: rf = (-100.0/22)*i/(ncolor-1) + 111.0/22 |
|
146 | 165 | |
|
147 | 166 | if(i <= 12.0/100*(ncolor-1)): gf = 0.0 |
|
148 | 167 | elif(i <= 38.0/100*(ncolor-1)): gf = (100.0/26)*i/(ncolor-1) - 12.0/26 |
|
149 | 168 | elif(i <= 64.0/100*(ncolor-1)): gf = 1.0 |
|
150 | 169 | elif(i <= 91.0/100*(ncolor-1)): gf = (-100.0/27)*i/(ncolor-1) + 91.0/27 |
|
151 | 170 | else: gf = 0.0 |
|
152 | 171 | |
|
153 | 172 | if(i <= 11.0/100*(ncolor-1)): bf = (50.0/11)*i/(ncolor-1) + 0.5 |
|
154 | 173 | elif(i <= 34.0/100*(ncolor-1)): bf = 1.0 |
|
155 | 174 | elif(i <= 65.0/100*(ncolor-1)): bf = (-100.0/31)*i/(ncolor-1) + 65.0/31 |
|
156 | 175 | else: bf = 0 |
|
157 | 176 | |
|
158 | 177 | r[i] = rf |
|
159 | 178 | g[i] = gf |
|
160 | 179 | b[i] = bf |
|
161 | 180 | |
|
162 | 181 | pos[i] = float(i)/float(ncolor-1) |
|
163 | 182 | |
|
164 | 183 | |
|
165 | 184 | plplot.plscmap1n(ncolor) |
|
166 | 185 | plplot.plscmap1l(1, pos, r, g, b) |
|
167 | 186 | |
|
168 | 187 | |
|
169 | 188 | |
|
170 | 189 | if colormap=="br_green": |
|
171 | 190 | ncolor = 256 |
|
172 | 191 | # Hue ranges from blue (240 deg) to red (0 or 360 deg) |
|
173 | 192 | h = numpy.array((240., 0.)) |
|
174 | 193 | # Lightness and saturation are constant (values taken from C example). |
|
175 | 194 | l = numpy.array((0.6, 0.6)) |
|
176 | 195 | s = numpy.array((0.8, 0.8)) |
|
177 | 196 | |
|
178 | 197 | # number of cmap1 colours is 256 in this case. |
|
179 | 198 | plplot.plscmap1n(ncolor) |
|
180 | 199 | # Interpolate between control points to set up cmap1. |
|
181 | 200 | plplot.plscmap1l(0, i, h, l, s) |
|
182 | 201 | |
|
183 | 202 | return None |
|
184 | 203 | |
|
185 | 204 | if colormap=="tricolor": |
|
186 | 205 | ncolor = 3 |
|
187 | 206 | # Hue ranges from blue (240 deg) to red (0 or 360 deg) |
|
188 | 207 | h = numpy.array((240., 0.)) |
|
189 | 208 | # Lightness and saturation are constant (values taken from C example). |
|
190 | 209 | l = numpy.array((0.6, 0.6)) |
|
191 | 210 | s = numpy.array((0.8, 0.8)) |
|
192 | 211 | |
|
193 | 212 | # number of cmap1 colours is 256 in this case. |
|
194 | 213 | plplot.plscmap1n(ncolor) |
|
195 | 214 | # Interpolate between control points to set up cmap1. |
|
196 | 215 | plplot.plscmap1l(0, i, h, l, s) |
|
197 | 216 | |
|
198 | 217 | return None |
|
199 | 218 | |
|
200 | 219 | if colormap == 'rgb' or colormap == 'rgb666': |
|
201 | 220 | |
|
202 | 221 | color_sz = 6 |
|
203 | 222 | ncolor = color_sz*color_sz*color_sz |
|
204 | 223 | pos = numpy.zeros((ncolor)) |
|
205 | 224 | r = numpy.zeros((ncolor)) |
|
206 | 225 | g = numpy.zeros((ncolor)) |
|
207 | 226 | b = numpy.zeros((ncolor)) |
|
208 | 227 | ind = 0 |
|
209 | 228 | for ri in range(color_sz): |
|
210 | 229 | for gi in range(color_sz): |
|
211 | 230 | for bi in range(color_sz): |
|
212 | 231 | r[ind] = ri/(color_sz-1.0) |
|
213 | 232 | g[ind] = gi/(color_sz-1.0) |
|
214 | 233 | b[ind] = bi/(color_sz-1.0) |
|
215 | 234 | pos[ind] = ind/(ncolor-1.0) |
|
216 | 235 | ind += 1 |
|
217 | 236 | rgb_lvl = [6,6,6] #Levels for RGB colors |
|
218 | 237 | |
|
219 | 238 | if colormap == 'rgb676': |
|
220 | 239 | ncolor = 6*7*6 |
|
221 | 240 | pos = numpy.zeros((ncolor)) |
|
222 | 241 | r = numpy.zeros((ncolor)) |
|
223 | 242 | g = numpy.zeros((ncolor)) |
|
224 | 243 | b = numpy.zeros((ncolor)) |
|
225 | 244 | ind = 0 |
|
226 | 245 | for ri in range(8): |
|
227 | 246 | for gi in range(8): |
|
228 | 247 | for bi in range(4): |
|
229 | 248 | r[ind] = ri/(6-1.0) |
|
230 | 249 | g[ind] = gi/(7-1.0) |
|
231 | 250 | b[ind] = bi/(6-1.0) |
|
232 | 251 | pos[ind] = ind/(ncolor-1.0) |
|
233 | 252 | ind += 1 |
|
234 | 253 | rgb_lvl = [6,7,6] #Levels for RGB colors |
|
235 | 254 | |
|
236 | 255 | if colormap == 'rgb685': |
|
237 | 256 | ncolor = 6*8*5 |
|
238 | 257 | pos = numpy.zeros((ncolor)) |
|
239 | 258 | r = numpy.zeros((ncolor)) |
|
240 | 259 | g = numpy.zeros((ncolor)) |
|
241 | 260 | b = numpy.zeros((ncolor)) |
|
242 | 261 | ind = 0 |
|
243 | 262 | for ri in range(8): |
|
244 | 263 | for gi in range(8): |
|
245 | 264 | for bi in range(4): |
|
246 | 265 | r[ind] = ri/(6-1.0) |
|
247 | 266 | g[ind] = gi/(8-1.0) |
|
248 | 267 | b[ind] = bi/(5-1.0) |
|
249 | 268 | pos[ind] = ind/(ncolor-1.0) |
|
250 | 269 | ind += 1 |
|
251 | 270 | rgb_lvl = [6,8,5] #Levels for RGB colors |
|
252 | 271 | |
|
253 | 272 | if colormap == 'rgb884': |
|
254 | 273 | ncolor = 8*8*4 |
|
255 | 274 | pos = numpy.zeros((ncolor)) |
|
256 | 275 | r = numpy.zeros((ncolor)) |
|
257 | 276 | g = numpy.zeros((ncolor)) |
|
258 | 277 | b = numpy.zeros((ncolor)) |
|
259 | 278 | ind = 0 |
|
260 | 279 | for ri in range(8): |
|
261 | 280 | for gi in range(8): |
|
262 | 281 | for bi in range(4): |
|
263 | 282 | r[ind] = ri/(8-1.0) |
|
264 | 283 | g[ind] = gi/(8-1.0) |
|
265 | 284 | b[ind] = bi/(4-1.0) |
|
266 | 285 | pos[ind] = ind/(ncolor-1.0) |
|
267 | 286 | ind += 1 |
|
268 | 287 | rgb_lvl = [8,8,4] #Levels for RGB colors |
|
269 | 288 | |
|
270 | 289 | if ncolor == None: |
|
271 | 290 | raise ValueError, "The colormap selected is not valid" |
|
272 | 291 | |
|
273 | 292 | plplot.plscmap1n(ncolor) |
|
274 | 293 | plplot.plscmap1l(1, pos, r, g, b) |
|
275 | 294 | |
|
276 | 295 | return rgb_lvl |
|
277 | 296 | |
|
278 | 297 | def set_colormap(colormap="jet"): |
|
279 | 298 | cmap1_init(colormap) |
|
280 | 299 | |
|
281 | 300 | def save_figure(filename,width,height): |
|
282 | 301 | curr_strm = plplot.plgstrm() |
|
283 | 302 | save_strm = plplot.plmkstrm() |
|
284 | 303 | plplot.plsetopt("geometry", "%dx%d"%(width,height)) |
|
285 | 304 | if sys.platform == "darwin": |
|
286 | 305 | plplot.plsdev("png") |
|
287 | 306 | if sys.platform == "linux": |
|
288 | 307 | plplot.plsdev("pngcairo") |
|
289 | 308 | plplot.plsfnam(filename) |
|
290 | 309 | plplot.plcpstrm(curr_strm,0) |
|
291 | 310 | plplot.plreplot() |
|
292 | 311 | plplot.plend1() |
|
293 | 312 | plplot.plsstrm(curr_strm) |
|
294 | 313 | |
|
295 | 314 | def set_new_figure(): |
|
296 | 315 | plplot.plbop() |
|
297 | 316 | plplot.pladv(0) |
|
298 | 317 | |
|
299 | 318 | def close_figure(): |
|
300 | 319 | plplot.pleop() |
|
301 | 320 | |
|
302 | 321 | def set_strm(indexPlot): |
|
303 | 322 | plplot.plsstrm(indexPlot) |
|
304 | 323 | |
|
305 | 324 | def refresh(): |
|
306 | 325 | plplot.plflush() |
|
307 | 326 | |
|
308 | 327 | def show(): |
|
309 | 328 | plplot.plspause(True) |
|
310 | 329 | plplot.plend() |
|
311 | 330 | |
|
312 | 331 | def set_title(pltitle,color, szchar=0.7): |
|
313 | 332 | setSubpages(1, 0) |
|
314 | 333 | plplot.pladv(0) |
|
315 | 334 | plplot.plvpor(0., 1., 0., 1.) |
|
316 | 335 | |
|
317 | 336 | if color == "black": |
|
318 | 337 | plplot.plcol0(1) |
|
319 | 338 | if color == "white": |
|
320 | 339 | plplot.plcol0(15) |
|
321 | 340 | |
|
322 | 341 | plplot.plschr(0.0,szchar) |
|
323 | 342 | plplot.plmtex("t",-1., 0.5, 0.5, pltitle) |
|
324 | 343 | |
|
325 | 344 | def set_line_style(style): |
|
326 | 345 | plplot.pllsty(style) |
|
327 | 346 | |
|
328 | 347 | def set_color(color): |
|
329 | 348 | plplot.plcol0(color) |
|
330 | 349 | |
|
331 | 350 | def set_labels(xlabel, ylabel, title): |
|
332 | 351 | plplot.pllab(xlabel, ylabel, title) |
|
333 | 352 | |
|
334 | 353 | def box(subplot, xpos, ypos, xmin, xmax, ymin, ymax, xopt, yopt, szchar, xaxisastime, timefmt="%H:%M"): |
|
335 | 354 | plplot.pladv(subplot) |
|
336 | 355 | plplot.plschr(0.0,szchar-0.05) |
|
337 | 356 | plplot.plvpor(xpos[0], xpos[1], ypos[0], ypos[1]) |
|
338 | 357 | plplot.plwind(float(xmin), |
|
339 | 358 | float(xmax), |
|
340 | 359 | float(ymin), |
|
341 | 360 | float(ymax) |
|
342 | 361 | ) |
|
343 | 362 | if xaxisastime: |
|
344 | 363 | plplot.pltimefmt(timefmt) |
|
345 | 364 | timedelta = (xmax - xmin + 1)/8. |
|
346 | 365 | plplot.plbox(xopt, timedelta, 3, yopt, 0.0, 0) |
|
347 | 366 | else: |
|
348 | 367 | plplot.plbox(xopt, 0.0, 0, yopt, 0.0, 0) |
|
349 | 368 | |
|
350 | 369 | def colorbar(xmin=0., xmax=1., ymin=0., ymax=1.): |
|
351 | 370 | data = numpy.arange(256) |
|
352 | 371 | data = numpy.reshape(data, (1,-1)) |
|
353 | 372 | |
|
354 | 373 | plplot.plimage(data, |
|
355 | 374 | float(xmin), |
|
356 | 375 | float(xmax), |
|
357 | 376 | float(ymin), |
|
358 | 377 | float(ymax), |
|
359 | 378 | 0., |
|
360 | 379 | 255., |
|
361 | 380 | float(xmin), |
|
362 | 381 | float(xmax), |
|
363 | 382 | float(ymin), |
|
364 | 383 | float(ymax)) |
|
365 | 384 | |
|
366 | 385 | def basicline_timeplot(x, y,colline=1): |
|
367 | 386 | plplot.plcol0(colline) |
|
368 | 387 | plplot.plline(x, y) |
|
369 | 388 | plplot.plcol0(1) |
|
370 | 389 | |
|
371 | 390 | def basic_xy_plot(x, y): |
|
372 | 391 | plplot.plline(x, y) |
|
373 | 392 | |
|
374 | 393 | def basic_pcolor_plot(data, x, y, xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None): |
|
375 | 394 | """ |
|
376 | 395 | """ |
|
377 | 396 | if xmin == None: xmin = x[0] |
|
378 | 397 | if xmax == None: xmax = x[-1] |
|
379 | 398 | if ymin == None: ymin = y[0] |
|
380 | 399 | if ymax == None: ymax = y[-1] |
|
381 | 400 | if zmin == None: zmin = numpy.nanmin(data) |
|
382 | 401 | if zmax == None: zmax = numpy.nanmax(data) |
|
383 | 402 | |
|
384 | 403 | plplot.plimage(data, |
|
385 | 404 | float(x[0]), |
|
386 | 405 | float(x[-1]), |
|
387 | 406 | float(y[0]), |
|
388 | 407 | float(y[-1]), |
|
389 | 408 | float(zmin), |
|
390 | 409 | float(zmax), |
|
391 | 410 | float(xmin), |
|
392 | 411 | float(xmax), |
|
393 | 412 | float(ymin), |
|
394 | 413 | float(ymax) |
|
395 | 414 | ) |
|
396 | 415 | |
|
397 | 416 | def image_plot(self,x,y,z,xrange,yrange,zrange): |
|
398 | 417 | xi = x[0] |
|
399 | 418 | xf = x[-1] |
|
400 | 419 | yi = y[0] |
|
401 | 420 | yf = y[-1] |
|
402 | 421 | |
|
403 | 422 | plplot.plimage(z, |
|
404 | 423 | float(xi), |
|
405 | 424 | float(xf), |
|
406 | 425 | float(yi), |
|
407 | 426 | float(yf), |
|
408 | 427 | float(zrange[0]), |
|
409 | 428 | float(zrange[1]), |
|
410 | 429 | float(xi), |
|
411 | 430 | float(xf), |
|
412 | 431 | float(yrange[0]), |
|
413 | 432 | yrange[1]) |
|
414 | 433 | |
|
415 | 434 | def adv_pcolor_plot(data, x, y, xg, yg, xmin=None, xmax=None, ymin=None, ymax=None, zmin=0., zmax=0.): |
|
416 | 435 | plplot.plimagefr(data, |
|
417 | 436 | float(xmin), |
|
418 | 437 | float(xmax), |
|
419 | 438 | float(ymin), |
|
420 | 439 | float(ymax), |
|
421 | 440 | 0., |
|
422 | 441 | 0., |
|
423 | 442 | float(zmin), |
|
424 | 443 | float(zmax), |
|
425 | 444 | plplot.pltr2, |
|
426 | 445 | xg, |
|
427 | 446 | yg) |
|
428 | 447 | |
|
429 | 448 | #------------------------------------ |
|
430 | 449 | |
|
431 | 450 | #def get_grid(x, y, deltax=None, deltay=None): |
|
432 | 451 | # |
|
433 | 452 | # if not(len(x)>0 and len(y)>0): |
|
434 | 453 | # raise ValueError, "x axis and y axis are empty" |
|
435 | 454 | # |
|
436 | 455 | # if deltax == None: deltax = x[-1] - x[-2] |
|
437 | 456 | # if deltay == None: deltay = y[-1] - y[-2] |
|
438 | 457 | # |
|
439 | 458 | # x1 = numpy.append(x, x[-1] + deltax) |
|
440 | 459 | # y1 = numpy.append(y, y[-1] + deltay) |
|
441 | 460 | # |
|
442 | 461 | # xg = (numpy.multiply.outer(x1, numpy.ones(len(y1)))) |
|
443 | 462 | # yg = (numpy.multiply.outer(numpy.ones(len(x1)), y1)) |
|
444 | 463 | # |
|
445 | 464 | # self.__xg = xg |
|
446 | 465 | # self.__yg = yg |
|
447 | 466 | # |
|
448 | 467 | # return xg, yg |
|
449 | 468 | # |
|
450 | 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): |
|
451 | 470 | # if getGrid: |
|
452 | 471 | # xg, yg = self.__getBoxpltr(x, y, deltax, deltay) |
|
453 | 472 | # else: |
|
454 | 473 | # xg = self.__xg |
|
455 | 474 | # yg = self.__yg |
|
456 | 475 | # |
|
457 | 476 | # plplot.plimagefr(data, |
|
458 | 477 | # float(xmin), |
|
459 | 478 | # float(xmax), |
|
460 | 479 | # float(ymin), |
|
461 | 480 | # float(ymax), |
|
462 | 481 | # 0., |
|
463 | 482 | # 0., |
|
464 | 483 | # float(zmin), |
|
465 | 484 | # float(zmax), |
|
466 | 485 | # plplot.pltr2, |
|
467 | 486 | # xg, |
|
468 | 487 | # yg) |
General Comments 0
You need to be logged in to leave comments.
Login now