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