This diff has been collapsed as it changes many lines, (606 lines changed) Show them Hide them | |||||
@@ -0,0 +1,606 | |||||
|
1 | """ | |||
|
2 | Created on Feb 7, 2012 | |||
|
3 | ||||
|
4 | @autor $Author$ | |||
|
5 | @version $Id$ | |||
|
6 | ||||
|
7 | """ | |||
|
8 | ||||
|
9 | import numpy | |||
|
10 | import plplot | |||
|
11 | ||||
|
12 | class BaseGraph: | |||
|
13 | """ | |||
|
14 | ||||
|
15 | """ | |||
|
16 | ||||
|
17 | hasNotRange = True | |||
|
18 | ||||
|
19 | xrange = None | |||
|
20 | yrange = None | |||
|
21 | zrange = None | |||
|
22 | ||||
|
23 | xlabel = None | |||
|
24 | ylabel = None | |||
|
25 | title = None | |||
|
26 | ||||
|
27 | legends = None | |||
|
28 | ||||
|
29 | __name = None | |||
|
30 | __subpage = None | |||
|
31 | __szchar = None | |||
|
32 | ||||
|
33 | __colormap = None | |||
|
34 | __colbox = None | |||
|
35 | __colleg = None | |||
|
36 | ||||
|
37 | __xpos = None | |||
|
38 | __ypos = None | |||
|
39 | ||||
|
40 | __xopt = None #"bcnst" | |||
|
41 | __yopt = None #"bcnstv" | |||
|
42 | ||||
|
43 | __xlpos = None | |||
|
44 | __ylpos = None | |||
|
45 | ||||
|
46 | __xrangeIsTime = False | |||
|
47 | ||||
|
48 | #Advanced | |||
|
49 | __xg = None | |||
|
50 | __yg = None | |||
|
51 | ||||
|
52 | def __init__(self): | |||
|
53 | """ | |||
|
54 | ||||
|
55 | """ | |||
|
56 | pass | |||
|
57 | ||||
|
58 | def hasNotXrange(self): | |||
|
59 | ||||
|
60 | if self.xrange == None: | |||
|
61 | return 1 | |||
|
62 | ||||
|
63 | return 0 | |||
|
64 | ||||
|
65 | def hasNotYrange(self): | |||
|
66 | ||||
|
67 | if self.yrange == None: | |||
|
68 | return 1 | |||
|
69 | ||||
|
70 | return 0 | |||
|
71 | ||||
|
72 | def hasNotZrange(self): | |||
|
73 | ||||
|
74 | if self.zrange == None: | |||
|
75 | return 1 | |||
|
76 | ||||
|
77 | return 0 | |||
|
78 | def setName(self, name): | |||
|
79 | self.__name = name | |||
|
80 | ||||
|
81 | def setScreenPos(self, xpos, ypos): | |||
|
82 | self.__xpos = xpos | |||
|
83 | self.__ypos = ypos | |||
|
84 | ||||
|
85 | def setScreenPosbyWidth(self, xoff, yoff, xw, yw): | |||
|
86 | self.__xpos = [xoff, xoff + xw] | |||
|
87 | self.__ypos = [yoff, yoff + yw] | |||
|
88 | ||||
|
89 | def setSubpage(self, subpage): | |||
|
90 | self.__subpage = subpage | |||
|
91 | ||||
|
92 | def setSzchar(self, szchar): | |||
|
93 | self.__szchar = szchar | |||
|
94 | ||||
|
95 | def setOpt(self, xopt, yopt): | |||
|
96 | self.__xopt = xopt | |||
|
97 | self.__yopt = yopt | |||
|
98 | ||||
|
99 | def setRanges(self, xrange, yrange, zrange=None): | |||
|
100 | """ | |||
|
101 | """ | |||
|
102 | self.xrange = xrange | |||
|
103 | ||||
|
104 | self.yrange = yrange | |||
|
105 | ||||
|
106 | if zrange != None: | |||
|
107 | self.zrange = zrange | |||
|
108 | ||||
|
109 | self.hasNotRange = False | |||
|
110 | ||||
|
111 | def setColormap(self, colormap=None): | |||
|
112 | ||||
|
113 | if colormap == None: | |||
|
114 | colormap = self.__colormap | |||
|
115 | ||||
|
116 | cmap1_init(colormap) | |||
|
117 | ||||
|
118 | def setXAxisAsTime(self): | |||
|
119 | self.__xrangeIsTime = True | |||
|
120 | ||||
|
121 | def plotBox(self): | |||
|
122 | """ | |||
|
123 | ||||
|
124 | """ | |||
|
125 | plplot.plvpor(self.__xpos[0], self.__xpos[1], self.__ypos[0], self.__ypos[1]) | |||
|
126 | plplot.plwind(float(self.xrange[0]), | |||
|
127 | float(self.xrange[1]), | |||
|
128 | float(self.yrange[0]), | |||
|
129 | float(self.yrange[1]) | |||
|
130 | ) | |||
|
131 | plplot.plbox(self.__xopt, 0.0, 0, self.__yopt, 0.0, 0) | |||
|
132 | plplot.pllab(self.xlabel, self.ylabel, self.title) | |||
|
133 | ||||
|
134 | def setup(self, title=None, xlabel=None, ylabel=None, colormap=None): | |||
|
135 | """ | |||
|
136 | """ | |||
|
137 | self.title = title | |||
|
138 | self.xlabel = xlabel | |||
|
139 | self.ylabel = ylabel | |||
|
140 | self.__colormap = colormap | |||
|
141 | ||||
|
142 | def initSubpage(self): | |||
|
143 | ||||
|
144 | if plplot.plgdev() == '': | |||
|
145 | raise ValueError, "Plot device has not been initialize" | |||
|
146 | ||||
|
147 | plplot.pladv(self.__subpage) | |||
|
148 | plplot.plschr(0.0, self.__szchar) | |||
|
149 | ||||
|
150 | if self.__xrangeIsTime: | |||
|
151 | plplot.pltimefmt("%H:%M") | |||
|
152 | ||||
|
153 | self.setColormap() | |||
|
154 | self.initPlot() | |||
|
155 | ||||
|
156 | def initPlot(self): | |||
|
157 | """ | |||
|
158 | ||||
|
159 | """ | |||
|
160 | if plplot.plgdev() == '': | |||
|
161 | raise ValueError, "Plot device has not been initialize" | |||
|
162 | ||||
|
163 | xrange = self.xrange | |||
|
164 | if xrange == None: | |||
|
165 | xrange = [0., 1.] | |||
|
166 | ||||
|
167 | yrange = self.yrange | |||
|
168 | if yrange == None: | |||
|
169 | yrange = [0., 1.] | |||
|
170 | ||||
|
171 | self.plotBox() | |||
|
172 | ||||
|
173 | def colorbarPlot(self): | |||
|
174 | data = numpy.arange(256) | |||
|
175 | data = numpy.reshape(data, (1,-1)) | |||
|
176 | ||||
|
177 | self.plotBox() | |||
|
178 | plplot.plimage(data, | |||
|
179 | self.xrange[0], | |||
|
180 | self.xrange[1], | |||
|
181 | self.yrange[0], | |||
|
182 | self.yrange[1], | |||
|
183 | 0., | |||
|
184 | 255., | |||
|
185 | self.xrange[0], | |||
|
186 | self.xrange[1], | |||
|
187 | self.yrange[0], | |||
|
188 | self.yrange[1],) | |||
|
189 | ||||
|
190 | def basicXYPlot(self, x, y): | |||
|
191 | self.plotBox() | |||
|
192 | plplot.plline(x, y) | |||
|
193 | ||||
|
194 | def basicXYwithErrorPlot(self): | |||
|
195 | pass | |||
|
196 | ||||
|
197 | def basicLineTimePlot(self): | |||
|
198 | pass | |||
|
199 | ||||
|
200 | def basicPcolorPlot(self, data, x, y, xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None): | |||
|
201 | """ | |||
|
202 | """ | |||
|
203 | if xmin == None: xmin = x[0] | |||
|
204 | if xmax == None: xmax = x[-1] | |||
|
205 | if ymin == None: ymin = y[0] | |||
|
206 | if ymax == None: ymax = y[-1] | |||
|
207 | if zmin == None: zmin = numpy.nanmin(data) | |||
|
208 | if zmax == None: zmax = numpy.nanmax(data) | |||
|
209 | ||||
|
210 | self.plotBox() | |||
|
211 | plplot.plimage(data, | |||
|
212 | float(x[0]), | |||
|
213 | float(x[-1]), | |||
|
214 | float(y[0]), | |||
|
215 | float(y[-1]), | |||
|
216 | float(zmin), | |||
|
217 | float(zmax), | |||
|
218 | float(xmin), | |||
|
219 | float(xmax), | |||
|
220 | float(ymin), | |||
|
221 | float(ymax) | |||
|
222 | ) | |||
|
223 | ||||
|
224 | def __getBoxpltr(self, x, y, deltax=None, deltay=None): | |||
|
225 | ||||
|
226 | if not(len(x)>1 and len(y)>1): | |||
|
227 | raise ValueError, "x axis and y axis are empty" | |||
|
228 | ||||
|
229 | if deltax == None: deltax = x[-1] - x[-2] | |||
|
230 | if deltay == None: deltay = y[-1] - y[-2] | |||
|
231 | ||||
|
232 | x1 = numpy.append(x, x[-1] + deltax) | |||
|
233 | y1 = numpy.append(y, y[-1] + deltay) | |||
|
234 | ||||
|
235 | xg = (numpy.multiply.outer(x1, numpy.ones(len(y1)))) | |||
|
236 | yg = (numpy.multiply.outer(numpy.ones(len(x1)), y1)) | |||
|
237 | ||||
|
238 | self.__xg = xg | |||
|
239 | self.__yg = yg | |||
|
240 | ||||
|
241 | def advPcolorPlot(self, data, x, y, zmin=0., zmax=0.): | |||
|
242 | """ | |||
|
243 | """ | |||
|
244 | ||||
|
245 | if self.__xg == None and self.__yg == None: | |||
|
246 | self.__getBoxpltr(x, y) | |||
|
247 | ||||
|
248 | plplot.plimagefr(data, x[0], x[-1], y[0], y[-1], 0., 0., zmin, zmax, plplot.pltr2, self.__xg, self.__yg) | |||
|
249 | ||||
|
250 | ||||
|
251 | class ColorPlot(): | |||
|
252 | ||||
|
253 | ||||
|
254 | graphObjDict = {} | |||
|
255 | showColorbar = False | |||
|
256 | showPowerProfile = True | |||
|
257 | ||||
|
258 | __szchar = 0.7 | |||
|
259 | __xrange = None | |||
|
260 | __yrange = None | |||
|
261 | __zrange = None | |||
|
262 | ||||
|
263 | m_BaseGraph = BaseGraph() | |||
|
264 | ||||
|
265 | def __init__(self): | |||
|
266 | ||||
|
267 | key = "colorplot" | |||
|
268 | self.m_BaseGraph.setName(key) | |||
|
269 | ||||
|
270 | self.graphObjDict[key] = self.m_BaseGraph | |||
|
271 | ||||
|
272 | def setup(self, subpage, title="", xlabel="", ylabel="", colormap="jet", showColorbar=False, showPowerProfile=False, XAxisAsTime=False): | |||
|
273 | """ | |||
|
274 | """ | |||
|
275 | ||||
|
276 | self.m_BaseGraph.setSubpage(subpage) | |||
|
277 | self.m_BaseGraph.setSzchar(self.__szchar) | |||
|
278 | self.m_BaseGraph.setOpt("bcnts","bcnts") | |||
|
279 | self.m_BaseGraph.setup(title, | |||
|
280 | xlabel, | |||
|
281 | ylabel, | |||
|
282 | colormap) | |||
|
283 | ||||
|
284 | if showColorbar: | |||
|
285 | key = "colorbar" | |||
|
286 | ||||
|
287 | cmapObj = BaseGraph() | |||
|
288 | cmapObj.setName(key) | |||
|
289 | cmapObj.setSubpage(subpage) | |||
|
290 | cmapObj.setSzchar(self.__szchar) | |||
|
291 | cmapObj.setOpt("bc","bcmt") | |||
|
292 | cmapObj.setup(title="dBs", | |||
|
293 | xlabel="", | |||
|
294 | ylabel="", | |||
|
295 | colormap=colormap) | |||
|
296 | ||||
|
297 | self.graphObjDict[key] = cmapObj | |||
|
298 | ||||
|
299 | ||||
|
300 | if showPowerProfile: | |||
|
301 | key = "powerprof" | |||
|
302 | ||||
|
303 | powObj = BaseGraph() | |||
|
304 | powObj.setName(key) | |||
|
305 | powObj.setSubpage(subpage) | |||
|
306 | powObj.setSzchar(self.__szchar) | |||
|
307 | plplot.pllsty(2) | |||
|
308 | powObj.setOpt("bcntg","bc") | |||
|
309 | plplot.pllsty(1) | |||
|
310 | powObj.setup(title="Power Profile", | |||
|
311 | xlabel="dBs", | |||
|
312 | ylabel="") | |||
|
313 | ||||
|
314 | self.graphObjDict[key] = powObj | |||
|
315 | ||||
|
316 | self.showColorbar = showColorbar | |||
|
317 | self.showPowerProfile = showPowerProfile | |||
|
318 | self.setPos() | |||
|
319 | ||||
|
320 | if XAxisAsTime: | |||
|
321 | self.m_BaseGraph.setXAxisAsTime() | |||
|
322 | #self.setPos(xi = 0.05, yi = 0.18, xw = 0.92, yw = 0.74, xcmapw = 0.015, xpoww = 0.14, deltaxcmap = 0.01, deltaxpow = 0.02) | |||
|
323 | ||||
|
324 | ||||
|
325 | def setPos(self, xi = 0.12, yi = 0.14, xw = 0.78, yw = 0.80, xcmapw = 0.05, xpoww = 0.24, deltaxcmap = 0.02, deltaxpow = 0.06): | |||
|
326 | ||||
|
327 | if self.showColorbar: | |||
|
328 | xw -= xcmapw + deltaxcmap | |||
|
329 | ||||
|
330 | if self.showPowerProfile: | |||
|
331 | xw -= xpoww + deltaxpow | |||
|
332 | ||||
|
333 | xf = xi + xw | |||
|
334 | yf = yi + yw | |||
|
335 | xcmapf = xf | |||
|
336 | ||||
|
337 | self.m_BaseGraph.setScreenPos([xi, xf], [yi, yf]) | |||
|
338 | ||||
|
339 | if self.showColorbar: | |||
|
340 | xcmapi = xf + deltaxcmap | |||
|
341 | xcmapf = xcmapi + xcmapw | |||
|
342 | ||||
|
343 | key = "colorbar" | |||
|
344 | cmapObj = self.graphObjDict[key] | |||
|
345 | cmapObj.setScreenPos([xcmapi, xcmapf], [yi, yf]) | |||
|
346 | ||||
|
347 | if self.showPowerProfile: | |||
|
348 | ||||
|
349 | xpowi = xcmapf + deltaxpow | |||
|
350 | xpowf = xpowi + xpoww | |||
|
351 | ||||
|
352 | key = "powerprof" | |||
|
353 | powObj = self.graphObjDict[key] | |||
|
354 | powObj.setScreenPos([xpowi, xpowf], [yi, yf]) | |||
|
355 | ||||
|
356 | def setRanges(self, xrange, yrange, zrange): | |||
|
357 | ||||
|
358 | self.m_BaseGraph.setRanges(xrange, yrange, zrange) | |||
|
359 | ||||
|
360 | keyList = self.graphObjDict.keys() | |||
|
361 | ||||
|
362 | key = "colorbar" | |||
|
363 | if key in keyList: | |||
|
364 | cmapObj = self.graphObjDict[key] | |||
|
365 | cmapObj.setRanges([0., 1.], zrange) | |||
|
366 | ||||
|
367 | key = "powerprof" | |||
|
368 | if key in keyList: | |||
|
369 | powObj = self.graphObjDict[key] | |||
|
370 | powObj.setRanges(zrange, yrange) | |||
|
371 | ||||
|
372 | def plotData(self, data, x=None, y=None, xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None): | |||
|
373 | """ | |||
|
374 | """ | |||
|
375 | ||||
|
376 | try: | |||
|
377 | nX, nY = numpy.shape(data) | |||
|
378 | except: | |||
|
379 | raise ValueError, "data is not a numpy array" | |||
|
380 | ||||
|
381 | if x == None: x = numpy.arange(nX) | |||
|
382 | if y == None: y = numpy.arange(nY) | |||
|
383 | ||||
|
384 | if xmin == None: xmin = x[0] | |||
|
385 | if xmax == None: xmax = x[-1] | |||
|
386 | if ymin == None: ymin = y[0] | |||
|
387 | if ymax == None: ymax = y[-1] | |||
|
388 | if zmin == None: zmin = numpy.nanmin(data) | |||
|
389 | if zmax == None: zmax = numpy.nanmax(data) | |||
|
390 | ||||
|
391 | if self.m_BaseGraph.hasNotRange: | |||
|
392 | self.setRanges([xmin, xmax], [ymin,ymax], [zmin,zmax]) | |||
|
393 | ||||
|
394 | self.m_BaseGraph.initSubpage() | |||
|
395 | self.m_BaseGraph.basicPcolorPlot(data, x, y, xmin, xmax, ymin, ymax, self.m_BaseGraph.zrange[0], self.m_BaseGraph.zrange[1]) | |||
|
396 | ||||
|
397 | if self.showColorbar: | |||
|
398 | key = "colorbar" | |||
|
399 | cmapObj = self.graphObjDict[key] | |||
|
400 | cmapObj.colorbarPlot() | |||
|
401 | ||||
|
402 | if self.showPowerProfile: | |||
|
403 | power = numpy.average(data, axis=1) | |||
|
404 | ||||
|
405 | step = (ymax - ymin)/(nY-1) | |||
|
406 | heis = numpy.arange(ymin, ymax + step, step) | |||
|
407 | ||||
|
408 | key = "powerprof" | |||
|
409 | powObj = self.graphObjDict[key] | |||
|
410 | powObj.basicXYPlot(power, heis) | |||
|
411 | ||||
|
412 | class LinearPlot(): | |||
|
413 | ||||
|
414 | __szchar = 0.7 | |||
|
415 | __xrange = None | |||
|
416 | __yrange = None | |||
|
417 | ||||
|
418 | m_BaseGraph = BaseGraph() | |||
|
419 | ||||
|
420 | def __init__(self): | |||
|
421 | ||||
|
422 | key = "linearplot" | |||
|
423 | self.m_BaseGraph.setName(key) | |||
|
424 | ||||
|
425 | self.graphObjDict[key] = self.m_BaseGraph | |||
|
426 | ||||
|
427 | def setup(self, subpage, title="", xlabel="", ylabel="", colormap="jet", XAxisAsTime=False): | |||
|
428 | """ | |||
|
429 | """ | |||
|
430 | ||||
|
431 | self.m_BaseGraph.setSubpage(subpage) | |||
|
432 | self.m_BaseGraph.setSzchar(self.__szchar) | |||
|
433 | self.m_BaseGraph.setOpt("bcnts","bcnts") | |||
|
434 | self.m_BaseGraph.setup(title, | |||
|
435 | xlabel, | |||
|
436 | ylabel, | |||
|
437 | colormap) | |||
|
438 | ||||
|
439 | self.setPos() | |||
|
440 | ||||
|
441 | if XAxisAsTime: | |||
|
442 | self.m_BaseGraph.setXAxisAsTime() | |||
|
443 | #self.setPos(xi = 0.05, yi = 0.18, xw = 0.92, yw = 0.74, xcmapw = 0.015, xpoww = 0.14, deltaxcmap = 0.01, deltaxpow = 0.02) | |||
|
444 | ||||
|
445 | ||||
|
446 | def setPos(self, xi = 0.12, yi = 0.14, xw = 0.78, yw = 0.80): | |||
|
447 | ||||
|
448 | xf = xi + xw | |||
|
449 | yf = yi + yw | |||
|
450 | ||||
|
451 | self.m_BaseGraph.setScreenPos([xi, xf], [yi, yf]) | |||
|
452 | ||||
|
453 | def setRanges(self, xrange, yrange, zrange): | |||
|
454 | ||||
|
455 | self.m_BaseGraph.setRanges(xrange, yrange, zrange) | |||
|
456 | ||||
|
457 | def plotData(self, x, y): | |||
|
458 | """ | |||
|
459 | """ | |||
|
460 | xmin = x[0] | |||
|
461 | xmax = x[-1] | |||
|
462 | ||||
|
463 | ymin = y[0] | |||
|
464 | ymax = y[-1] | |||
|
465 | ||||
|
466 | if self.m_BaseGraph.hasNotRange: | |||
|
467 | self.setRanges([xmin, xmax], [ymin,ymax]) | |||
|
468 | ||||
|
469 | self.m_BaseGraph.initSubpage() | |||
|
470 | self.m_BaseGraph.basicLineTimePlot(x, y) | |||
|
471 | ||||
|
472 | ||||
|
473 | def cmap1_init(colormap="gray"): | |||
|
474 | ||||
|
475 | ncolor = None | |||
|
476 | rgb_lvl = None | |||
|
477 | ||||
|
478 | # Routine for defining a specific color map 1 in HLS space. | |||
|
479 | # if gray is true, use basic grayscale variation from half-dark to light. | |||
|
480 | # otherwise use false color variation from blue (240 deg) to red (360 deg). | |||
|
481 | ||||
|
482 | # Independent variable of control points. | |||
|
483 | i = numpy.array((0., 1.)) | |||
|
484 | if colormap=="gray": | |||
|
485 | ncolor = 256 | |||
|
486 | # Hue for control points. Doesn't matter since saturation is zero. | |||
|
487 | h = numpy.array((0., 0.)) | |||
|
488 | # Lightness ranging from half-dark (for interest) to light. | |||
|
489 | l = numpy.array((0.5, 1.)) | |||
|
490 | # Gray scale has zero saturation | |||
|
491 | s = numpy.array((0., 0.)) | |||
|
492 | ||||
|
493 | # number of cmap1 colours is 256 in this case. | |||
|
494 | plplot.plscmap1n(ncolor) | |||
|
495 | # Interpolate between control points to set up cmap1. | |||
|
496 | plplot.plscmap1l(0, i, h, l, s) | |||
|
497 | ||||
|
498 | return None | |||
|
499 | ||||
|
500 | if colormap=="br_green": | |||
|
501 | ncolor = 256 | |||
|
502 | # Hue ranges from blue (240 deg) to red (0 or 360 deg) | |||
|
503 | h = numpy.array((240., 0.)) | |||
|
504 | # Lightness and saturation are constant (values taken from C example). | |||
|
505 | l = numpy.array((0.6, 0.6)) | |||
|
506 | s = numpy.array((0.8, 0.8)) | |||
|
507 | ||||
|
508 | # number of cmap1 colours is 256 in this case. | |||
|
509 | plplot.plscmap1n(ncolor) | |||
|
510 | # Interpolate between control points to set up cmap1. | |||
|
511 | plplot.plscmap1l(0, i, h, l, s) | |||
|
512 | ||||
|
513 | return None | |||
|
514 | ||||
|
515 | if colormap=="tricolor": | |||
|
516 | ncolor = 3 | |||
|
517 | # Hue ranges from blue (240 deg) to red (0 or 360 deg) | |||
|
518 | h = numpy.array((240., 0.)) | |||
|
519 | # Lightness and saturation are constant (values taken from C example). | |||
|
520 | l = numpy.array((0.6, 0.6)) | |||
|
521 | s = numpy.array((0.8, 0.8)) | |||
|
522 | ||||
|
523 | # number of cmap1 colours is 256 in this case. | |||
|
524 | plplot.plscmap1n(ncolor) | |||
|
525 | # Interpolate between control points to set up cmap1. | |||
|
526 | plplot.plscmap1l(0, i, h, l, s) | |||
|
527 | ||||
|
528 | return None | |||
|
529 | ||||
|
530 | if colormap == 'rgb' or colormap == 'rgb666': | |||
|
531 | ||||
|
532 | color_sz = 6 | |||
|
533 | ncolor = color_sz*color_sz*color_sz | |||
|
534 | pos = numpy.zeros((ncolor)) | |||
|
535 | r = numpy.zeros((ncolor)) | |||
|
536 | g = numpy.zeros((ncolor)) | |||
|
537 | b = numpy.zeros((ncolor)) | |||
|
538 | ind = 0 | |||
|
539 | for ri in range(color_sz): | |||
|
540 | for gi in range(color_sz): | |||
|
541 | for bi in range(color_sz): | |||
|
542 | r[ind] = ri/(color_sz-1.0) | |||
|
543 | g[ind] = gi/(color_sz-1.0) | |||
|
544 | b[ind] = bi/(color_sz-1.0) | |||
|
545 | pos[ind] = ind/(ncolor-1.0) | |||
|
546 | ind += 1 | |||
|
547 | rgb_lvl = [6,6,6] #Levels for RGB colors | |||
|
548 | ||||
|
549 | if colormap == 'rgb676': | |||
|
550 | ncolor = 6*7*6 | |||
|
551 | pos = numpy.zeros((ncolor)) | |||
|
552 | r = numpy.zeros((ncolor)) | |||
|
553 | g = numpy.zeros((ncolor)) | |||
|
554 | b = numpy.zeros((ncolor)) | |||
|
555 | ind = 0 | |||
|
556 | for ri in range(8): | |||
|
557 | for gi in range(8): | |||
|
558 | for bi in range(4): | |||
|
559 | r[ind] = ri/(6-1.0) | |||
|
560 | g[ind] = gi/(7-1.0) | |||
|
561 | b[ind] = bi/(6-1.0) | |||
|
562 | pos[ind] = ind/(ncolor-1.0) | |||
|
563 | ind += 1 | |||
|
564 | rgb_lvl = [6,7,6] #Levels for RGB colors | |||
|
565 | ||||
|
566 | if colormap == 'rgb685': | |||
|
567 | ncolor = 6*8*5 | |||
|
568 | pos = numpy.zeros((ncolor)) | |||
|
569 | r = numpy.zeros((ncolor)) | |||
|
570 | g = numpy.zeros((ncolor)) | |||
|
571 | b = numpy.zeros((ncolor)) | |||
|
572 | ind = 0 | |||
|
573 | for ri in range(8): | |||
|
574 | for gi in range(8): | |||
|
575 | for bi in range(4): | |||
|
576 | r[ind] = ri/(6-1.0) | |||
|
577 | g[ind] = gi/(8-1.0) | |||
|
578 | b[ind] = bi/(5-1.0) | |||
|
579 | pos[ind] = ind/(ncolor-1.0) | |||
|
580 | ind += 1 | |||
|
581 | rgb_lvl = [6,8,5] #Levels for RGB colors | |||
|
582 | ||||
|
583 | if colormap == 'rgb884': | |||
|
584 | ncolor = 8*8*4 | |||
|
585 | pos = numpy.zeros((ncolor)) | |||
|
586 | r = numpy.zeros((ncolor)) | |||
|
587 | g = numpy.zeros((ncolor)) | |||
|
588 | b = numpy.zeros((ncolor)) | |||
|
589 | ind = 0 | |||
|
590 | for ri in range(8): | |||
|
591 | for gi in range(8): | |||
|
592 | for bi in range(4): | |||
|
593 | r[ind] = ri/(8-1.0) | |||
|
594 | g[ind] = gi/(8-1.0) | |||
|
595 | b[ind] = bi/(4-1.0) | |||
|
596 | pos[ind] = ind/(ncolor-1.0) | |||
|
597 | ind += 1 | |||
|
598 | rgb_lvl = [8,8,4] #Levels for RGB colors | |||
|
599 | ||||
|
600 | if ncolor == None: | |||
|
601 | raise ValueError, "The colormap selected is not valid" | |||
|
602 | ||||
|
603 | plplot.plscmap1n(ncolor) | |||
|
604 | plplot.plscmap1l(1, pos, r, g, b) | |||
|
605 | ||||
|
606 | return rgb_lvl No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now