##// END OF EJS Templates
Miguel Valdez -
r7:22fd15995f88
parent child
Show More
@@ -1,6 +1,141
1 import numpy
1 import numpy
2 import plplot
2 import plplot
3
3
4 def cmap1_init(colormap="gray"):
5
6 ncolor = None
7 rgb_lvl = None
8
9 # Routine for defining a specific color map 1 in HLS space.
10 # if gray is true, use basic grayscale variation from half-dark to light.
11 # otherwise use false color variation from blue (240 deg) to red (360 deg).
12
13 # Independent variable of control points.
14 i = numpy.array((0., 1.))
15 if colormap=="gray":
16 ncolor = 256
17 # Hue for control points. Doesn't matter since saturation is zero.
18 h = numpy.array((0., 0.))
19 # Lightness ranging from half-dark (for interest) to light.
20 l = numpy.array((0.5, 1.))
21 # Gray scale has zero saturation
22 s = numpy.array((0., 0.))
23
24 # number of cmap1 colours is 256 in this case.
25 plplot.plscmap1n(ncolor)
26 # Interpolate between control points to set up cmap1.
27 plplot.plscmap1l(0, i, h, l, s)
28
29 return None
30
31 if colormap=="br_green":
32 ncolor = 256
33 # Hue ranges from blue (240 deg) to red (0 or 360 deg)
34 h = numpy.array((240., 0.))
35 # Lightness and saturation are constant (values taken from C example).
36 l = numpy.array((0.6, 0.6))
37 s = numpy.array((0.8, 0.8))
38
39 # number of cmap1 colours is 256 in this case.
40 plplot.plscmap1n(ncolor)
41 # Interpolate between control points to set up cmap1.
42 plplot.plscmap1l(0, i, h, l, s)
43
44 return None
45
46 if colormap=="tricolor":
47 ncolor = 3
48 # Hue ranges from blue (240 deg) to red (0 or 360 deg)
49 h = numpy.array((240., 0.))
50 # Lightness and saturation are constant (values taken from C example).
51 l = numpy.array((0.6, 0.6))
52 s = numpy.array((0.8, 0.8))
53
54 # number of cmap1 colours is 256 in this case.
55 plplot.plscmap1n(ncolor)
56 # Interpolate between control points to set up cmap1.
57 plplot.plscmap1l(0, i, h, l, s)
58
59 return None
60
61 if colormap == 'rgb' or colormap == 'rgb666':
62
63 color_sz = 6
64 ncolor = color_sz*color_sz*color_sz
65 pos = numpy.zeros((ncolor))
66 r = numpy.zeros((ncolor))
67 g = numpy.zeros((ncolor))
68 b = numpy.zeros((ncolor))
69 ind = 0
70 for ri in range(color_sz):
71 for gi in range(color_sz):
72 for bi in range(color_sz):
73 r[ind] = ri/(color_sz-1.0)
74 g[ind] = gi/(color_sz-1.0)
75 b[ind] = bi/(color_sz-1.0)
76 pos[ind] = ind/(ncolor-1.0)
77 ind += 1
78 rgb_lvl = [6,6,6] #Levels for RGB colors
79
80 if colormap == 'rgb676':
81 ncolor = 6*7*6
82 pos = numpy.zeros((ncolor))
83 r = numpy.zeros((ncolor))
84 g = numpy.zeros((ncolor))
85 b = numpy.zeros((ncolor))
86 ind = 0
87 for ri in range(8):
88 for gi in range(8):
89 for bi in range(4):
90 r[ind] = ri/(6-1.0)
91 g[ind] = gi/(7-1.0)
92 b[ind] = bi/(6-1.0)
93 pos[ind] = ind/(ncolor-1.0)
94 ind += 1
95 rgb_lvl = [6,7,6] #Levels for RGB colors
96
97 if colormap == 'rgb685':
98 ncolor = 6*8*5
99 pos = numpy.zeros((ncolor))
100 r = numpy.zeros((ncolor))
101 g = numpy.zeros((ncolor))
102 b = numpy.zeros((ncolor))
103 ind = 0
104 for ri in range(8):
105 for gi in range(8):
106 for bi in range(4):
107 r[ind] = ri/(6-1.0)
108 g[ind] = gi/(8-1.0)
109 b[ind] = bi/(5-1.0)
110 pos[ind] = ind/(ncolor-1.0)
111 ind += 1
112 rgb_lvl = [6,8,5] #Levels for RGB colors
113
114 if colormap == 'rgb884':
115 ncolor = 8*8*4
116 pos = numpy.zeros((ncolor))
117 r = numpy.zeros((ncolor))
118 g = numpy.zeros((ncolor))
119 b = numpy.zeros((ncolor))
120 ind = 0
121 for ri in range(8):
122 for gi in range(8):
123 for bi in range(4):
124 r[ind] = ri/(8-1.0)
125 g[ind] = gi/(8-1.0)
126 b[ind] = bi/(4-1.0)
127 pos[ind] = ind/(ncolor-1.0)
128 ind += 1
129 rgb_lvl = [8,8,4] #Levels for RGB colors
130
131 if ncolor == None:
132 raise ValueError, "The colormap selected is not valid"
133
134 plplot.plscmap1n(ncolor)
135 plplot.plscmap1l(1, pos, r, g, b)
136
137 return rgb_lvl
138
4 class BasicGraph:
139 class BasicGraph:
5 """
140 """
6
141
@@ -170,7 +170,11 class Spectrum():
170 powObj.basicXYPlot(power, heis)
170 powObj.basicXYPlot(power, heis)
171
171
172 class CrossSpectrum():
172 class CrossSpectrum():
173 graphObjDict = {}
174 showColorbar = False
175 showPowerProfile = True
173
176
177 __szchar = 0.7
174 def __init__(self):
178 def __init__(self):
175 pass
179 pass
176
180
@@ -179,4 +183,31 class CrossSpectrum():
179
183
180 def plotData(self):
184 def plotData(self):
181 pass
185 pass
182 No newline at end of file
186
187 if __name__ == '__main__':
188
189 import numpy
190 plplot.plsetopt("geometry", "%dx%d" %(350*2, 300*2))
191 plplot.plsdev("xcairo")
192 plplot.plscolbg(255,255,255)
193 plplot.plscol0(1,0,0,0)
194 plplot.plinit()
195 plplot.plssub(2, 2)
196
197 nx = 64
198 ny = 100
199
200 data = numpy.random.uniform(-50,50,(nx,ny))
201
202 specObj = Spectrum()
203 specObj.setup(1, "Spectrum", "Frequency", "Range", "br_green", False, False)
204 specObj.plotData(data)
205
206 data = numpy.random.uniform(-50,50,(nx,ny))
207
208 spec2Obj = Spectrum()
209 spec2Obj.setup(2, "Spectrum", "Frequency", "Range", "br_green", True, True)
210 spec2Obj.plotData(data)
211
212 plplot.plend()
213 exit(0) No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now