@@ -1,220 +1,355 | |||
|
1 | 1 | import numpy |
|
2 | 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 | 139 | class BasicGraph: |
|
5 | 140 | """ |
|
6 | 141 | |
|
7 | 142 | """ |
|
8 | 143 | |
|
9 | 144 | hasRange = False |
|
10 | 145 | |
|
11 | 146 | xrange = None |
|
12 | 147 | yrange = None |
|
13 | 148 | zrange = None |
|
14 | 149 | |
|
15 | 150 | xlabel = None |
|
16 | 151 | ylabel = None |
|
17 | 152 | title = None |
|
18 | 153 | |
|
19 | 154 | legends = None |
|
20 | 155 | |
|
21 | 156 | __name = None |
|
22 | 157 | __subpage = None |
|
23 | 158 | __szchar = None |
|
24 | 159 | |
|
25 | 160 | __colormap = None |
|
26 | 161 | __colbox = None |
|
27 | 162 | __colleg = None |
|
28 | 163 | |
|
29 | 164 | __xpos = None |
|
30 | 165 | __ypos = None |
|
31 | 166 | |
|
32 | 167 | __xopt = None #"bcnst" |
|
33 | 168 | __yopt = None #"bcnstv" |
|
34 | 169 | |
|
35 | 170 | __xlpos = None |
|
36 | 171 | __ylpos = None |
|
37 | 172 | |
|
38 | 173 | __xrangeIsTime = None |
|
39 | 174 | |
|
40 | 175 | #Advanced |
|
41 | 176 | __xg = None |
|
42 | 177 | __yg = None |
|
43 | 178 | |
|
44 | 179 | def __init__(self): |
|
45 | 180 | """ |
|
46 | 181 | |
|
47 | 182 | """ |
|
48 | 183 | pass |
|
49 | 184 | |
|
50 | 185 | def hasNotXrange(self): |
|
51 | 186 | |
|
52 | 187 | if self.xrange == None: |
|
53 | 188 | return 1 |
|
54 | 189 | |
|
55 | 190 | return 0 |
|
56 | 191 | |
|
57 | 192 | def hasNotYrange(self): |
|
58 | 193 | |
|
59 | 194 | if self.yrange == None: |
|
60 | 195 | return 1 |
|
61 | 196 | |
|
62 | 197 | return 0 |
|
63 | 198 | |
|
64 | 199 | def hasNotZrange(self): |
|
65 | 200 | |
|
66 | 201 | if self.zrange == None: |
|
67 | 202 | return 1 |
|
68 | 203 | |
|
69 | 204 | return 0 |
|
70 | 205 | def setName(self, name): |
|
71 | 206 | self.__name = name |
|
72 | 207 | |
|
73 | 208 | def setScreenPos(self, xpos, ypos): |
|
74 | 209 | self.__xpos = xpos |
|
75 | 210 | self.__ypos = ypos |
|
76 | 211 | |
|
77 | 212 | def setScreenPosbyWidth(self, xoff, yoff, xw, yw): |
|
78 | 213 | self.__xpos = [xoff, xoff + xw] |
|
79 | 214 | self.__ypos = [yoff, yoff + yw] |
|
80 | 215 | |
|
81 | 216 | def setSubpage(self, subpage): |
|
82 | 217 | self.__subpage = subpage |
|
83 | 218 | |
|
84 | 219 | def setSzchar(self, szchar): |
|
85 | 220 | self.__szchar = szchar |
|
86 | 221 | |
|
87 | 222 | def setOpt(self, xopt, yopt): |
|
88 | 223 | self.__xopt = xopt |
|
89 | 224 | self.__yopt = yopt |
|
90 | 225 | |
|
91 | 226 | def setRanges(self, xrange, yrange, zrange=None): |
|
92 | 227 | """ |
|
93 | 228 | """ |
|
94 | 229 | self.xrange = xrange |
|
95 | 230 | |
|
96 | 231 | self.yrange = yrange |
|
97 | 232 | |
|
98 | 233 | if zrange != None: |
|
99 | 234 | self.zrange = zrange |
|
100 | 235 | |
|
101 | 236 | def setColormap(self, colormap=None): |
|
102 | 237 | |
|
103 | 238 | if colormap == None: |
|
104 | 239 | colormap = self.__colormap |
|
105 | 240 | |
|
106 | 241 | cmap1_init(colormap) |
|
107 | 242 | |
|
108 | 243 | def plotBox(self): |
|
109 | 244 | """ |
|
110 | 245 | |
|
111 | 246 | """ |
|
112 | 247 | plplot.plvpor(self.__xpos[0], self.__xpos[1], self.__ypos[0], self.__ypos[1]) |
|
113 | 248 | plplot.plwind(self.xrange[0], self.xrange[1], self.yrange[0], self.yrange[1]) |
|
114 | 249 | plplot.plbox(self.__xopt, 0.0, 0, self.__yopt, 0.0, 0) |
|
115 | 250 | plplot.pllab(self.xlabel, self.ylabel, self.title) |
|
116 | 251 | |
|
117 | 252 | def setup(self, title=None, xlabel=None, ylabel=None, colormap=None): |
|
118 | 253 | """ |
|
119 | 254 | """ |
|
120 | 255 | self.title = title |
|
121 | 256 | self.xlabel = xlabel |
|
122 | 257 | self.ylabel = ylabel |
|
123 | 258 | self.__colormap = colormap |
|
124 | 259 | |
|
125 | 260 | def initSubpage(self): |
|
126 | 261 | |
|
127 | 262 | if plplot.plgdev() == '': |
|
128 | 263 | raise ValueError, "Plot device has not been initialize" |
|
129 | 264 | |
|
130 | 265 | plplot.pladv(self.__subpage) |
|
131 | 266 | plplot.plschr(0.0, self.__szchar) |
|
132 | 267 | |
|
133 | 268 | if self.__xrangeIsTime: |
|
134 | 269 | plplot.pltimefmt("%H:%M") |
|
135 | 270 | |
|
136 | 271 | self.setColormap() |
|
137 | 272 | self.initPlot() |
|
138 | 273 | |
|
139 | 274 | def initPlot(self): |
|
140 | 275 | """ |
|
141 | 276 | |
|
142 | 277 | """ |
|
143 | 278 | if plplot.plgdev() == '': |
|
144 | 279 | raise ValueError, "Plot device has not been initialize" |
|
145 | 280 | |
|
146 | 281 | xrange = self.xrange |
|
147 | 282 | if xrange == None: |
|
148 | 283 | xrange = [0., 1.] |
|
149 | 284 | |
|
150 | 285 | yrange = self.yrange |
|
151 | 286 | if yrange == None: |
|
152 | 287 | yrange = [0., 1.] |
|
153 | 288 | |
|
154 | 289 | plplot.plvpor(self.__xpos[0], self.__xpos[1], self.__ypos[0], self.__ypos[1]) |
|
155 | 290 | plplot.plwind(xrange[0], xrange[1], yrange[0], yrange[1]) |
|
156 | 291 | plplot.plbox(self.__xopt, 0.0, 0, self.__yopt, 0.0, 0) |
|
157 | 292 | plplot.pllab(self.xlabel, self.ylabel, self.title) |
|
158 | 293 | |
|
159 | 294 | def colorbarPlot(self): |
|
160 | 295 | data = numpy.arange(256) |
|
161 | 296 | data = numpy.reshape(data, (1,-1)) |
|
162 | 297 | |
|
163 | 298 | self.plotBox() |
|
164 | 299 | plplot.plimage(data, |
|
165 | 300 | self.xrange[0], |
|
166 | 301 | self.xrange[1], |
|
167 | 302 | self.yrange[0], |
|
168 | 303 | self.yrange[1], |
|
169 | 304 | 0., |
|
170 | 305 | 255., |
|
171 | 306 | self.xrange[0], |
|
172 | 307 | self.xrange[1], |
|
173 | 308 | self.yrange[0], |
|
174 | 309 | self.yrange[1],) |
|
175 | 310 | |
|
176 | 311 | def basicXYPlot(self, x, y): |
|
177 | 312 | self.plotBox() |
|
178 | 313 | plplot.plline(x, y) |
|
179 | 314 | |
|
180 | 315 | def basicXYwithErrorPlot(self): |
|
181 | 316 | pass |
|
182 | 317 | |
|
183 | 318 | def basicLineTimePlot(self): |
|
184 | 319 | pass |
|
185 | 320 | |
|
186 | 321 | def basicPcolorPlot(self, data, xmin, xmax, ymin, ymax, zmin, zmax): |
|
187 | 322 | """ |
|
188 | 323 | """ |
|
189 | 324 | |
|
190 | 325 | self.plotBox() |
|
191 | 326 | plplot.plimage(data, xmin, xmax, ymin, ymax, zmin, zmax, xmin, xmax, ymin, ymax) |
|
192 | 327 | |
|
193 | 328 | |
|
194 | 329 | def __getBoxpltr(self, x, y, deltax=None, deltay=None): |
|
195 | 330 | |
|
196 | 331 | if not(len(x)>1 and len(y)>1): |
|
197 | 332 | raise ValueError, "x axis and y axis are empty" |
|
198 | 333 | |
|
199 | 334 | if deltax == None: deltax = x[-1] - x[-2] |
|
200 | 335 | if deltay == None: deltay = y[-1] - y[-2] |
|
201 | 336 | |
|
202 | 337 | x1 = numpy.append(x, x[-1] + deltax) |
|
203 | 338 | y1 = numpy.append(y, y[-1] + deltay) |
|
204 | 339 | |
|
205 | 340 | xg = (numpy.multiply.outer(x1, numpy.ones(len(y1)))) |
|
206 | 341 | yg = (numpy.multiply.outer(numpy.ones(len(x1)), y1)) |
|
207 | 342 | |
|
208 | 343 | self.__xg = xg |
|
209 | 344 | self.__yg = yg |
|
210 | 345 | |
|
211 | 346 | def advPcolorPlot(self, data, x, y, zmin=0., zmax=0.): |
|
212 | 347 | """ |
|
213 | 348 | """ |
|
214 | 349 | |
|
215 | 350 | if self.__xg == None and self.__yg == None: |
|
216 | 351 | self.__getBoxpltr(x, y) |
|
217 | 352 | |
|
218 | 353 | plplot.plimagefr(data, x[0], x[-1], y[0], y[-1], 0., 0., zmin, zmax, plplot.pltr2, self.__xg, self.__yg) |
|
219 | 354 | |
|
220 | 355 |
@@ -1,182 +1,213 | |||
|
1 | 1 | import numpy |
|
2 | 2 | import plplot |
|
3 | 3 | |
|
4 | 4 | from BasicGraph import * |
|
5 | 5 | |
|
6 | 6 | class Spectrum(): |
|
7 | 7 | |
|
8 | 8 | graphObjDict = {} |
|
9 | 9 | showColorbar = False |
|
10 | 10 | showPowerProfile = True |
|
11 | 11 | |
|
12 | 12 | __szchar = 0.7 |
|
13 | 13 | |
|
14 | 14 | def __init__(self): |
|
15 | 15 | |
|
16 | 16 | key = "spec" |
|
17 | 17 | |
|
18 | 18 | specObj = BasicGraph() |
|
19 | 19 | specObj.setName(key) |
|
20 | 20 | |
|
21 | 21 | self.graphObjDict[key] = specObj |
|
22 | 22 | |
|
23 | 23 | |
|
24 | 24 | def setup(self, subpage, title="", xlabel="", ylabel="", colormap="jet", showColorbar=False, showPowerProfile=False): |
|
25 | 25 | """ |
|
26 | 26 | """ |
|
27 | 27 | |
|
28 | 28 | xi = 0.12; xw = 0.78; xf = xi + xw |
|
29 | 29 | yi = 0.14; yw = 0.80; yf = yi + yw |
|
30 | 30 | |
|
31 | 31 | xcmapi = xcmapf = 0.; xpowi = xpowf = 0. |
|
32 | 32 | |
|
33 | 33 | key = "spec" |
|
34 | 34 | specObj = self.graphObjDict[key] |
|
35 | 35 | specObj.setSubpage(subpage) |
|
36 | 36 | specObj.setSzchar(self.__szchar) |
|
37 | 37 | specObj.setOpt("bcnts","bcnts") |
|
38 | 38 | specObj.setup(title, |
|
39 | 39 | xlabel, |
|
40 | 40 | ylabel, |
|
41 | 41 | colormap) |
|
42 | 42 | |
|
43 | 43 | if showColorbar: |
|
44 | 44 | key = "colorbar" |
|
45 | 45 | |
|
46 | 46 | cmapObj = BasicGraph() |
|
47 | 47 | cmapObj.setName(key) |
|
48 | 48 | cmapObj.setSubpage(subpage) |
|
49 | 49 | cmapObj.setSzchar(self.__szchar) |
|
50 | 50 | cmapObj.setOpt("bc","bcmt") |
|
51 | 51 | cmapObj.setup(title="dBs", |
|
52 | 52 | xlabel="", |
|
53 | 53 | ylabel="", |
|
54 | 54 | colormap=colormap) |
|
55 | 55 | |
|
56 | 56 | self.graphObjDict[key] = cmapObj |
|
57 | 57 | |
|
58 | 58 | xcmapi = 0. |
|
59 | 59 | xcmapw = 0.05 |
|
60 | 60 | xw -= xcmapw |
|
61 | 61 | |
|
62 | 62 | if showPowerProfile: |
|
63 | 63 | key = "powerprof" |
|
64 | 64 | |
|
65 | 65 | powObj = BasicGraph() |
|
66 | 66 | powObj.setName(key) |
|
67 | 67 | powObj.setSubpage(subpage) |
|
68 | 68 | powObj.setSzchar(self.__szchar) |
|
69 | 69 | plplot.pllsty(2) |
|
70 | 70 | powObj.setOpt("bcntg","bc") |
|
71 | 71 | plplot.pllsty(1) |
|
72 | 72 | powObj.setup(title="Power Profile", |
|
73 | 73 | xlabel="dBs", |
|
74 | 74 | ylabel="") |
|
75 | 75 | |
|
76 | 76 | self.graphObjDict[key] = powObj |
|
77 | 77 | |
|
78 | 78 | xpowi = 0. |
|
79 | 79 | xpoww = 0.24 |
|
80 | 80 | xw -= xpoww |
|
81 | 81 | |
|
82 | 82 | xf = xi + xw |
|
83 | 83 | yf = yi + yw |
|
84 | 84 | xcmapf = xf |
|
85 | 85 | |
|
86 | 86 | specObj.setScreenPos([xi, xf], [yi, yf]) |
|
87 | 87 | |
|
88 | 88 | if showColorbar: |
|
89 | 89 | xcmapi = xf + 0.02 |
|
90 | 90 | xcmapf = xcmapi + xcmapw |
|
91 | 91 | cmapObj.setScreenPos([xcmapi, xcmapf], [yi, yf]) |
|
92 | 92 | |
|
93 | 93 | if showPowerProfile: |
|
94 | 94 | xpowi = xcmapf + 0.06 |
|
95 | 95 | xpowf = xpowi + xpoww |
|
96 | 96 | powObj.setScreenPos([xpowi, xpowf], [yi, yf]) |
|
97 | 97 | |
|
98 | 98 | |
|
99 | 99 | # specObj.initSubpage() |
|
100 | 100 | # |
|
101 | 101 | # if showColorbar: |
|
102 | 102 | # cmapObj.initPlot() |
|
103 | 103 | # |
|
104 | 104 | # if showPowerProfile: |
|
105 | 105 | # powObj.initPlot() |
|
106 | 106 | |
|
107 | 107 | self.showColorbar = showColorbar |
|
108 | 108 | self.showPowerProfile = showPowerProfile |
|
109 | 109 | |
|
110 | 110 | def setRanges(self, xrange, yrange, zrange): |
|
111 | 111 | |
|
112 | 112 | key = "spec" |
|
113 | 113 | specObj = self.graphObjDict[key] |
|
114 | 114 | specObj.setRanges(xrange, yrange, zrange) |
|
115 | 115 | |
|
116 | 116 | keyList = self.graphObjDict.keys() |
|
117 | 117 | |
|
118 | 118 | key = "colorbar" |
|
119 | 119 | if key in keyList: |
|
120 | 120 | cmapObj = self.graphObjDict[key] |
|
121 | 121 | cmapObj.setRanges([0., 1.], zrange) |
|
122 | 122 | |
|
123 | 123 | key = "powerprof" |
|
124 | 124 | if key in keyList: |
|
125 | 125 | powObj = self.graphObjDict[key] |
|
126 | 126 | powObj.setRanges(zrange, yrange) |
|
127 | 127 | |
|
128 | 128 | def plotData(self, data , xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None): |
|
129 | 129 | |
|
130 | 130 | key = "spec" |
|
131 | 131 | specObj = self.graphObjDict[key] |
|
132 | 132 | specObj.initSubpage() |
|
133 | 133 | |
|
134 | 134 | if xmin == None: |
|
135 | 135 | xmin = 0. |
|
136 | 136 | |
|
137 | 137 | if xmax == None: |
|
138 | 138 | xmax = 1. |
|
139 | 139 | |
|
140 | 140 | if ymin == None: |
|
141 | 141 | ymin = 0. |
|
142 | 142 | |
|
143 | 143 | if ymax == None: |
|
144 | 144 | ymax = 1. |
|
145 | 145 | |
|
146 | 146 | if zmin == None: |
|
147 | 147 | zmin = numpy.nanmin(data) |
|
148 | 148 | |
|
149 | 149 | if zmax == None: |
|
150 | 150 | zmax = numpy.nanmax(data) |
|
151 | 151 | |
|
152 | 152 | if not(specObj.hasRange): |
|
153 | 153 | self.setRanges([xmin, xmax], [ymin,ymax], [zmin,zmax]) |
|
154 | 154 | |
|
155 | 155 | specObj.basicPcolorPlot(data, xmin, xmax, ymin, ymax, specObj.zrange[0], specObj.zrange[1]) |
|
156 | 156 | |
|
157 | 157 | if self.showColorbar: |
|
158 | 158 | key = "colorbar" |
|
159 | 159 | cmapObj = self.graphObjDict[key] |
|
160 | 160 | cmapObj.colorbarPlot() |
|
161 | 161 | |
|
162 | 162 | if self.showPowerProfile: |
|
163 | 163 | power = numpy.average(data, axis=1) |
|
164 | 164 | |
|
165 | 165 | step = (ymax - ymin)/(power.shape[0]-1) |
|
166 | 166 | heis = numpy.arange(ymin, ymax + step, step) |
|
167 | 167 | |
|
168 | 168 | key = "powerprof" |
|
169 | 169 | powObj = self.graphObjDict[key] |
|
170 | 170 | powObj.basicXYPlot(power, heis) |
|
171 | 171 | |
|
172 | 172 | class CrossSpectrum(): |
|
173 | graphObjDict = {} | |
|
174 | showColorbar = False | |
|
175 | showPowerProfile = True | |
|
173 | 176 | |
|
177 | __szchar = 0.7 | |
|
174 | 178 | def __init__(self): |
|
175 | 179 | pass |
|
176 | 180 | |
|
177 | 181 | def setup(self): |
|
178 | 182 | pass |
|
179 | 183 | |
|
180 | 184 | def plotData(self): |
|
181 | 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