@@ -1,990 +1,1129 | |||||
1 | ''' |
|
1 | ''' | |
2 | Created on Jan 25, 2012 |
|
2 | Created on Jan 25, 2012 | |
3 |
|
3 | |||
4 | @author: Miguel Urco |
|
4 | @author: Miguel Urco | |
5 | ''' |
|
5 | ''' | |
6 |
|
6 | |||
7 | import plplot |
|
7 | import plplot | |
8 | import numpy |
|
8 | import numpy | |
9 |
|
9 | |||
10 | def cmap1_init(colormap="gray"): |
|
10 | def cmap1_init(colormap="gray"): | |
11 |
|
11 | |||
|
12 | ncolor = None | |||
12 | rgb_lvl = None |
|
13 | rgb_lvl = None | |
13 |
|
14 | |||
14 | # Routine for defining a specific color map 1 in HLS space. |
|
15 | # Routine for defining a specific color map 1 in HLS space. | |
15 | # if gray is true, use basic grayscale variation from half-dark to light. |
|
16 | # if gray is true, use basic grayscale variation from half-dark to light. | |
16 | # otherwise use false color variation from blue (240 deg) to red (360 deg). |
|
17 | # otherwise use false color variation from blue (240 deg) to red (360 deg). | |
17 |
|
18 | |||
18 | # Independent variable of control points. |
|
19 | # Independent variable of control points. | |
19 | i = numpy.array((0., 1.)) |
|
20 | i = numpy.array((0., 1.)) | |
20 | if colormap=="gray": |
|
21 | if colormap=="gray": | |
|
22 | ncolor = 256 | |||
21 | # Hue for control points. Doesn't matter since saturation is zero. |
|
23 | # Hue for control points. Doesn't matter since saturation is zero. | |
22 | h = numpy.array((0., 0.)) |
|
24 | h = numpy.array((0., 0.)) | |
23 | # Lightness ranging from half-dark (for interest) to light. |
|
25 | # Lightness ranging from half-dark (for interest) to light. | |
24 | l = numpy.array((0.5, 1.)) |
|
26 | l = numpy.array((0.5, 1.)) | |
25 | # Gray scale has zero saturation |
|
27 | # Gray scale has zero saturation | |
26 | s = numpy.array((0., 0.)) |
|
28 | s = numpy.array((0., 0.)) | |
27 |
|
29 | |||
28 | # number of cmap1 colours is 256 in this case. |
|
30 | # number of cmap1 colours is 256 in this case. | |
29 |
plplot.plscmap1n( |
|
31 | plplot.plscmap1n(ncolor) | |
30 | # Interpolate between control points to set up cmap1. |
|
32 | # Interpolate between control points to set up cmap1. | |
31 | plplot.plscmap1l(0, i, h, l, s) |
|
33 | plplot.plscmap1l(0, i, h, l, s) | |
32 |
|
34 | |||
33 | return None |
|
35 | return None | |
34 |
|
36 | |||
35 | if colormap=="br_black": |
|
37 | if colormap=="br_black": | |
|
38 | ncolor = 256 | |||
36 | # Hue ranges from blue (240 deg) to red (0 or 360 deg) |
|
39 | # Hue ranges from blue (240 deg) to red (0 or 360 deg) | |
37 | h = numpy.array((240., 0.)) |
|
40 | h = numpy.array((240., 0.)) | |
38 | # Lightness and saturation are constant (values taken from C example). |
|
41 | # Lightness and saturation are constant (values taken from C example). | |
39 | l = numpy.array((0.6, 0.6)) |
|
42 | l = numpy.array((0.6, 0.6)) | |
40 | s = numpy.array((0.8, 0.8)) |
|
43 | s = numpy.array((0.8, 0.8)) | |
41 |
|
44 | |||
42 | # number of cmap1 colours is 256 in this case. |
|
45 | # number of cmap1 colours is 256 in this case. | |
43 |
plplot.plscmap1n( |
|
46 | plplot.plscmap1n(ncolor) | |
44 | # Interpolate between control points to set up cmap1. |
|
47 | # Interpolate between control points to set up cmap1. | |
45 | plplot.plscmap1l(0, i, h, l, s) |
|
48 | plplot.plscmap1l(0, i, h, l, s) | |
46 |
|
49 | |||
47 | return None |
|
50 | return None | |
48 |
|
51 | |||
49 | if colormap=="tricolor": |
|
52 | if colormap=="tricolor": | |
|
53 | ncolor = 3 | |||
50 | # Hue ranges from blue (240 deg) to red (0 or 360 deg) |
|
54 | # Hue ranges from blue (240 deg) to red (0 or 360 deg) | |
51 | h = numpy.array((240., 0.)) |
|
55 | h = numpy.array((240., 0.)) | |
52 | # Lightness and saturation are constant (values taken from C example). |
|
56 | # Lightness and saturation are constant (values taken from C example). | |
53 | l = numpy.array((0.6, 0.6)) |
|
57 | l = numpy.array((0.6, 0.6)) | |
54 | s = numpy.array((0.8, 0.8)) |
|
58 | s = numpy.array((0.8, 0.8)) | |
55 |
|
59 | |||
56 | # number of cmap1 colours is 256 in this case. |
|
60 | # number of cmap1 colours is 256 in this case. | |
57 |
plplot.plscmap1n( |
|
61 | plplot.plscmap1n(ncolor) | |
58 | # Interpolate between control points to set up cmap1. |
|
62 | # Interpolate between control points to set up cmap1. | |
59 | plplot.plscmap1l(0, i, h, l, s) |
|
63 | plplot.plscmap1l(0, i, h, l, s) | |
60 |
|
64 | |||
61 | return None |
|
65 | return None | |
62 |
|
66 | |||
63 | if colormap == 'rgb' or colormap == 'rgb666': |
|
67 | if colormap == 'rgb' or colormap == 'rgb666': | |
64 |
|
68 | |||
65 | color_sz = 6 |
|
69 | color_sz = 6 | |
66 | ncolor = color_sz*color_sz*color_sz |
|
70 | ncolor = color_sz*color_sz*color_sz | |
67 | pos = numpy.zeros((ncolor)) |
|
71 | pos = numpy.zeros((ncolor)) | |
68 | r = numpy.zeros((ncolor)) |
|
72 | r = numpy.zeros((ncolor)) | |
69 | g = numpy.zeros((ncolor)) |
|
73 | g = numpy.zeros((ncolor)) | |
70 | b = numpy.zeros((ncolor)) |
|
74 | b = numpy.zeros((ncolor)) | |
71 | ind = 0 |
|
75 | ind = 0 | |
72 | for ri in range(color_sz): |
|
76 | for ri in range(color_sz): | |
73 | for gi in range(color_sz): |
|
77 | for gi in range(color_sz): | |
74 | for bi in range(color_sz): |
|
78 | for bi in range(color_sz): | |
75 | r[ind] = ri/(color_sz-1.0) |
|
79 | r[ind] = ri/(color_sz-1.0) | |
76 | g[ind] = gi/(color_sz-1.0) |
|
80 | g[ind] = gi/(color_sz-1.0) | |
77 | b[ind] = bi/(color_sz-1.0) |
|
81 | b[ind] = bi/(color_sz-1.0) | |
78 | pos[ind] = ind/(ncolor-1.0) |
|
82 | pos[ind] = ind/(ncolor-1.0) | |
79 | ind += 1 |
|
83 | ind += 1 | |
80 | rgb_lvl = [6,6,6] #Levels for RGB colors |
|
84 | rgb_lvl = [6,6,6] #Levels for RGB colors | |
81 |
|
85 | |||
82 | if colormap == 'rgb676': |
|
86 | if colormap == 'rgb676': | |
83 | ncolor = 6*7*6 |
|
87 | ncolor = 6*7*6 | |
84 | pos = numpy.zeros((ncolor)) |
|
88 | pos = numpy.zeros((ncolor)) | |
85 | r = numpy.zeros((ncolor)) |
|
89 | r = numpy.zeros((ncolor)) | |
86 | g = numpy.zeros((ncolor)) |
|
90 | g = numpy.zeros((ncolor)) | |
87 | b = numpy.zeros((ncolor)) |
|
91 | b = numpy.zeros((ncolor)) | |
88 | ind = 0 |
|
92 | ind = 0 | |
89 | for ri in range(8): |
|
93 | for ri in range(8): | |
90 | for gi in range(8): |
|
94 | for gi in range(8): | |
91 | for bi in range(4): |
|
95 | for bi in range(4): | |
92 | r[ind] = ri/(6-1.0) |
|
96 | r[ind] = ri/(6-1.0) | |
93 | g[ind] = gi/(7-1.0) |
|
97 | g[ind] = gi/(7-1.0) | |
94 | b[ind] = bi/(6-1.0) |
|
98 | b[ind] = bi/(6-1.0) | |
95 | pos[ind] = ind/(ncolor-1.0) |
|
99 | pos[ind] = ind/(ncolor-1.0) | |
96 | ind += 1 |
|
100 | ind += 1 | |
97 | rgb_lvl = [6,7,6] #Levels for RGB colors |
|
101 | rgb_lvl = [6,7,6] #Levels for RGB colors | |
98 |
|
102 | |||
99 | if colormap == 'rgb685': |
|
103 | if colormap == 'rgb685': | |
100 | ncolor = 6*8*5 |
|
104 | ncolor = 6*8*5 | |
101 | pos = numpy.zeros((ncolor)) |
|
105 | pos = numpy.zeros((ncolor)) | |
102 | r = numpy.zeros((ncolor)) |
|
106 | r = numpy.zeros((ncolor)) | |
103 | g = numpy.zeros((ncolor)) |
|
107 | g = numpy.zeros((ncolor)) | |
104 | b = numpy.zeros((ncolor)) |
|
108 | b = numpy.zeros((ncolor)) | |
105 | ind = 0 |
|
109 | ind = 0 | |
106 | for ri in range(8): |
|
110 | for ri in range(8): | |
107 | for gi in range(8): |
|
111 | for gi in range(8): | |
108 | for bi in range(4): |
|
112 | for bi in range(4): | |
109 | r[ind] = ri/(6-1.0) |
|
113 | r[ind] = ri/(6-1.0) | |
110 | g[ind] = gi/(8-1.0) |
|
114 | g[ind] = gi/(8-1.0) | |
111 | b[ind] = bi/(5-1.0) |
|
115 | b[ind] = bi/(5-1.0) | |
112 | pos[ind] = ind/(ncolor-1.0) |
|
116 | pos[ind] = ind/(ncolor-1.0) | |
113 | ind += 1 |
|
117 | ind += 1 | |
114 | rgb_lvl = [6,8,5] #Levels for RGB colors |
|
118 | rgb_lvl = [6,8,5] #Levels for RGB colors | |
115 |
|
119 | |||
116 | if colormap == 'rgb884': |
|
120 | if colormap == 'rgb884': | |
117 | ncolor = 8*8*4 |
|
121 | ncolor = 8*8*4 | |
118 | pos = numpy.zeros((ncolor)) |
|
122 | pos = numpy.zeros((ncolor)) | |
119 | r = numpy.zeros((ncolor)) |
|
123 | r = numpy.zeros((ncolor)) | |
120 | g = numpy.zeros((ncolor)) |
|
124 | g = numpy.zeros((ncolor)) | |
121 | b = numpy.zeros((ncolor)) |
|
125 | b = numpy.zeros((ncolor)) | |
122 | ind = 0 |
|
126 | ind = 0 | |
123 | for ri in range(8): |
|
127 | for ri in range(8): | |
124 | for gi in range(8): |
|
128 | for gi in range(8): | |
125 | for bi in range(4): |
|
129 | for bi in range(4): | |
126 | r[ind] = ri/(8-1.0) |
|
130 | r[ind] = ri/(8-1.0) | |
127 | g[ind] = gi/(8-1.0) |
|
131 | g[ind] = gi/(8-1.0) | |
128 | b[ind] = bi/(4-1.0) |
|
132 | b[ind] = bi/(4-1.0) | |
129 | pos[ind] = ind/(ncolor-1.0) |
|
133 | pos[ind] = ind/(ncolor-1.0) | |
130 | ind += 1 |
|
134 | ind += 1 | |
131 | rgb_lvl = [8,8,4] #Levels for RGB colors |
|
135 | rgb_lvl = [8,8,4] #Levels for RGB colors | |
132 |
|
|
136 | ||
|
137 | if ncolor == None: | |||
|
138 | raise ValueError, "The colormap selected is not valid" | |||
|
139 | ||||
133 | plplot.plscmap1n(ncolor) |
|
140 | plplot.plscmap1n(ncolor) | |
134 | plplot.plscmap1l(1, pos, r, g, b) |
|
141 | plplot.plscmap1l(1, pos, r, g, b) | |
135 |
|
142 | |||
136 | return rgb_lvl |
|
143 | return rgb_lvl | |
137 |
|
144 | |||
138 | class BasicGraph(): |
|
145 | class BasicGraph(): | |
139 | """ |
|
146 | """ | |
140 |
|
147 | |||
141 | """ |
|
148 | """ | |
|
149 | ||||
|
150 | hasRange = False | |||
|
151 | ||||
142 | xrange = None |
|
152 | xrange = None | |
143 | yrange = None |
|
153 | yrange = None | |
144 | zrange = None |
|
154 | zrange = None | |
145 |
|
155 | |||
146 | xlabel = None |
|
156 | xlabel = None | |
147 | ylabel = None |
|
157 | ylabel = None | |
148 | title = None |
|
158 | title = None | |
149 |
|
159 | |||
150 | legends = None |
|
160 | legends = None | |
151 |
|
161 | |||
152 | __name = None |
|
162 | __name = None | |
153 | __subpage = None |
|
163 | __subpage = None | |
154 | __szchar = None |
|
164 | __szchar = None | |
155 |
|
165 | |||
156 | __colormap = None |
|
166 | __colormap = None | |
157 | __colbox = None |
|
167 | __colbox = None | |
158 | __colleg = None |
|
168 | __colleg = None | |
159 |
|
169 | |||
160 | __xpos = None |
|
170 | __xpos = None | |
161 | __ypos = None |
|
171 | __ypos = None | |
162 |
|
172 | |||
163 | __xopt = None #"bcnst" |
|
173 | __xopt = None #"bcnst" | |
164 | __yopt = None #"bcnstv" |
|
174 | __yopt = None #"bcnstv" | |
165 |
|
175 | |||
166 | __xlpos = None |
|
176 | __xlpos = None | |
167 | __ylpos = None |
|
177 | __ylpos = None | |
168 |
|
178 | |||
169 | __xrangeIsTime = None |
|
179 | __xrangeIsTime = None | |
170 |
|
180 | |||
171 | #Advanced |
|
181 | #Advanced | |
172 | __xg = None |
|
182 | __xg = None | |
173 | __yg = None |
|
183 | __yg = None | |
174 |
|
184 | |||
175 | def __init__(self): |
|
185 | def __init__(self): | |
176 | """ |
|
186 | """ | |
177 |
|
187 | |||
178 | """ |
|
188 | """ | |
179 | pass |
|
189 | pass | |
180 |
|
190 | |||
|
191 | def hasNotXrange(self): | |||
|
192 | ||||
|
193 | if self.xrange == None: | |||
|
194 | return 1 | |||
|
195 | ||||
|
196 | return 0 | |||
|
197 | ||||
|
198 | def hasNotYrange(self): | |||
|
199 | ||||
|
200 | if self.yrange == None: | |||
|
201 | return 1 | |||
|
202 | ||||
|
203 | return 0 | |||
|
204 | ||||
|
205 | def hasNotZrange(self): | |||
|
206 | ||||
|
207 | if self.zrange == None: | |||
|
208 | return 1 | |||
|
209 | ||||
|
210 | return 0 | |||
181 | def setName(self, name): |
|
211 | def setName(self, name): | |
182 | self.__name = name |
|
212 | self.__name = name | |
183 |
|
213 | |||
184 | def setScreenPos(self, xpos, ypos): |
|
214 | def setScreenPos(self, xpos, ypos): | |
185 | self.__xpos = xpos |
|
215 | self.__xpos = xpos | |
186 | self.__ypos = ypos |
|
216 | self.__ypos = ypos | |
187 |
|
217 | |||
188 | def setScreenPos(self, xoff, yoff, xw, yw): |
|
218 | def setScreenPosbyWidth(self, xoff, yoff, xw, yw): | |
189 | self.__xpos = [xoff, xoff + xw] |
|
219 | self.__xpos = [xoff, xoff + xw] | |
190 | self.__ypos = [yoff, yoff + yw] |
|
220 | self.__ypos = [yoff, yoff + yw] | |
191 |
|
221 | |||
192 | def setSubpage(self, subpage): |
|
222 | def setSubpage(self, subpage): | |
193 | self.__subpage = subpage |
|
223 | self.__subpage = subpage | |
|
224 | ||||
|
225 | def setSzchar(self, szchar): | |||
|
226 | self.__szchar = szchar | |||
|
227 | ||||
|
228 | def setOpt(self, xopt, yopt): | |||
|
229 | self.__xopt = xopt | |||
|
230 | self.__yopt = yopt | |||
194 |
|
231 | |||
195 | def setRanges(self, xrange, yrange, zrange): |
|
232 | def setRanges(self, xrange, yrange, zrange=None): | |
196 | """ |
|
233 | """ | |
197 | """ |
|
234 | """ | |
198 | self.xrange = xrange |
|
235 | self.xrange = xrange | |
|
236 | ||||
199 | self.yrange = yrange |
|
237 | self.yrange = yrange | |
200 | self.zrange = zrange |
|
238 | ||
|
239 | if zrange != None: | |||
|
240 | self.zrange = zrange | |||
201 |
|
241 | |||
202 |
def |
|
242 | def setColormap(self, colormap=None): | |
203 |
|
243 | |||
204 | if colormap == None: |
|
244 | if colormap == None: | |
205 | colormap = self.__colormap |
|
245 | colormap = self.__colormap | |
206 |
|
246 | |||
207 | cmap1_init(colormap) |
|
247 | cmap1_init(colormap) | |
208 |
|
248 | |||
209 |
def |
|
249 | def plotBox(self): | |
210 | """ |
|
250 | """ | |
211 |
|
251 | |||
212 | """ |
|
252 | """ | |
213 | plplot.plvpor(self.__xpos[0], self.__xpos[1], self.__ypos[0], self.__ypos[1]) |
|
253 | plplot.plvpor(self.__xpos[0], self.__xpos[1], self.__ypos[0], self.__ypos[1]) | |
214 | plplot.plwind(self.xrange[0], self.xrange[1], self.yrange[0], self.yrange[1]) |
|
254 | plplot.plwind(self.xrange[0], self.xrange[1], self.yrange[0], self.yrange[1]) | |
215 | plplot.plbox(self.__xopt, 0.0, 0, self.__yopt, 0.0, 0) |
|
255 | plplot.plbox(self.__xopt, 0.0, 0, self.__yopt, 0.0, 0) | |
216 | plplot.pllab(self.xlabel, self.ylabel, self.title) |
|
256 | plplot.pllab(self.xlabel, self.ylabel, self.title) | |
217 |
|
257 | |||
218 | def setup(self, title=None, xlabel=None, ylabel=None, colormap=None): |
|
258 | def setup(self, title=None, xlabel=None, ylabel=None, colormap=None): | |
219 | """ |
|
259 | """ | |
220 | """ |
|
260 | """ | |
221 | self.title = title |
|
261 | self.title = title | |
222 | self.xlabel = xlabel |
|
262 | self.xlabel = xlabel | |
223 | self.ylabel = ylabel |
|
263 | self.ylabel = ylabel | |
224 | self.colormap = colormap |
|
264 | self.__colormap = colormap | |
225 |
|
265 | |||
226 | def initSubpage(self): |
|
266 | def initSubpage(self): | |
|
267 | ||||
|
268 | if plplot.plgdev() == '': | |||
|
269 | raise ValueError, "Plot device has not been initialize" | |||
|
270 | ||||
227 | plplot.pladv(self.__subpage) |
|
271 | plplot.pladv(self.__subpage) | |
228 | plplot.plschr(0.0, self.__szchar) |
|
272 | plplot.plschr(0.0, self.__szchar) | |
229 |
|
273 | |||
230 | if self.__xrangeIsTime: |
|
274 | if self.__xrangeIsTime: | |
231 | plplot.pltimefmt("%H:%M") |
|
275 | plplot.pltimefmt("%H:%M") | |
232 |
|
276 | |||
233 |
self. |
|
277 | self.setColormap() | |
234 | self.initPlot() |
|
278 | self.initPlot() | |
235 |
|
279 | |||
236 | def initPlot(self): |
|
280 | def initPlot(self): | |
237 | """ |
|
281 | """ | |
238 |
|
282 | |||
239 | """ |
|
283 | """ | |
|
284 | if plplot.plgdev() == '': | |||
|
285 | raise ValueError, "Plot device has not been initialize" | |||
|
286 | ||||
|
287 | xrange = self.xrange | |||
|
288 | if xrange == None: | |||
|
289 | xrange = [0., 1.] | |||
|
290 | ||||
|
291 | yrange = self.yrange | |||
|
292 | if yrange == None: | |||
|
293 | yrange = [0., 1.] | |||
|
294 | ||||
240 | plplot.plvpor(self.__xpos[0], self.__xpos[1], self.__ypos[0], self.__ypos[1]) |
|
295 | plplot.plvpor(self.__xpos[0], self.__xpos[1], self.__ypos[0], self.__ypos[1]) | |
241 |
plplot.plwind( |
|
296 | plplot.plwind(xrange[0], xrange[1], yrange[0], yrange[1]) | |
242 | plplot.plbox(self.__xopt, 0.0, 0, self.__yopt, 0.0, 0) |
|
297 | plplot.plbox(self.__xopt, 0.0, 0, self.__yopt, 0.0, 0) | |
243 | plplot.pllab(self.xlabel, self.ylabel, self.title) |
|
298 | plplot.pllab(self.xlabel, self.ylabel, self.title) | |
244 |
|
|
299 | ||
245 |
|
300 | def colorbarPlot(self): | ||
246 | def basicXYPlot(self): |
|
301 | data = numpy.arange(256) | |
247 | pass |
|
302 | data = numpy.reshape(data, (1,-1)) | |
|
303 | ||||
|
304 | self.plotBox() | |||
|
305 | plplot.plimage(data, | |||
|
306 | self.xrange[0], | |||
|
307 | self.xrange[1], | |||
|
308 | self.yrange[0], | |||
|
309 | self.yrange[1], | |||
|
310 | 0., | |||
|
311 | 255., | |||
|
312 | self.xrange[0], | |||
|
313 | self.xrange[1], | |||
|
314 | self.yrange[0], | |||
|
315 | self.yrange[1],) | |||
|
316 | ||||
|
317 | def basicXYPlot(self, x, y): | |||
|
318 | self.plotBox() | |||
|
319 | plplot.plline(x, y) | |||
248 |
|
320 | |||
249 | def basicXYwithErrorPlot(self): |
|
321 | def basicXYwithErrorPlot(self): | |
250 | pass |
|
322 | pass | |
251 |
|
323 | |||
252 | def basicLineTimePlot(self): |
|
324 | def basicLineTimePlot(self): | |
253 | pass |
|
325 | pass | |
254 |
|
326 | |||
255 | def basicPcolorPlot(self, data, xmin, xmax, ymin, ymax, zmin, zmax): |
|
327 | def basicPcolorPlot(self, data, xmin, xmax, ymin, ymax, zmin, zmax): | |
256 | """ |
|
328 | """ | |
257 | """ |
|
329 | """ | |
258 |
|
330 | |||
259 |
self. |
|
331 | self.plotBox() | |
260 | plplot.plimage(data, xmin, xmax, ymin, ymax, zmin, zmax, xmin, xmax, ymin, ymax) |
|
332 | plplot.plimage(data, xmin, xmax, ymin, ymax, zmin, zmax, xmin, xmax, ymin, ymax) | |
261 |
|
333 | |||
262 |
|
334 | |||
263 | def __getBoxpltr(self, x, y, deltax=None, deltay=None): |
|
335 | def __getBoxpltr(self, x, y, deltax=None, deltay=None): | |
264 |
|
336 | |||
265 | if not(len(x)>1 and len(y)>1): |
|
337 | if not(len(x)>1 and len(y)>1): | |
266 | raise ValueError, "x axis and y axis are empty" |
|
338 | raise ValueError, "x axis and y axis are empty" | |
267 |
|
339 | |||
268 | if deltax == None: deltax = x[-1] - x[-2] |
|
340 | if deltax == None: deltax = x[-1] - x[-2] | |
269 | if deltay == None: deltay = y[-1] - y[-2] |
|
341 | if deltay == None: deltay = y[-1] - y[-2] | |
270 |
|
342 | |||
271 | x1 = numpy.append(x, x[-1] + deltax) |
|
343 | x1 = numpy.append(x, x[-1] + deltax) | |
272 | y1 = numpy.append(y, y[-1] + deltay) |
|
344 | y1 = numpy.append(y, y[-1] + deltay) | |
273 |
|
345 | |||
274 | xg = (numpy.multiply.outer(x1, numpy.ones(len(y1)))) |
|
346 | xg = (numpy.multiply.outer(x1, numpy.ones(len(y1)))) | |
275 | yg = (numpy.multiply.outer(numpy.ones(len(x1)), y1)) |
|
347 | yg = (numpy.multiply.outer(numpy.ones(len(x1)), y1)) | |
276 |
|
348 | |||
277 | self.__xg = xg |
|
349 | self.__xg = xg | |
278 | self.__yg = yg |
|
350 | self.__yg = yg | |
279 |
|
351 | |||
280 | def advPcolorPlot(self, data, x, y, zmin=0., zmax=0.): |
|
352 | def advPcolorPlot(self, data, x, y, zmin=0., zmax=0.): | |
281 | """ |
|
353 | """ | |
282 | """ |
|
354 | """ | |
283 |
|
355 | |||
284 | if self.__xg == None and self.__yg == None: |
|
356 | if self.__xg == None and self.__yg == None: | |
285 | self.__getBoxpltr(x, y) |
|
357 | self.__getBoxpltr(x, y) | |
286 |
|
358 | |||
287 | plplot.plimagefr(data, x[0], x[-1], y[0], y[-1], 0., 0., zmin, zmax, plplot.pltr2, self.__xg, self.__yg) |
|
359 | plplot.plimagefr(data, x[0], x[-1], y[0], y[-1], 0., 0., zmin, zmax, plplot.pltr2, self.__xg, self.__yg) | |
288 |
|
360 | |||
289 |
|
361 | |||
290 | class Graph(): |
|
362 | class Graph(): | |
291 | """ |
|
363 | """ | |
292 | """ |
|
364 | """ | |
293 |
|
365 | |||
294 | graphObjDict = {} |
|
366 | graphObjDict = {} | |
295 |
|
367 | |||
296 | def __init__(self): |
|
368 | def __init__(self): | |
297 | raise |
|
369 | raise | |
298 |
|
||||
299 | def setup(self): |
|
|||
300 | raise |
|
|||
301 |
|
||||
302 | def plotData(self): |
|
|||
303 | raise |
|
|||
304 |
|
370 | |||
305 | class Spectrum(Graph): |
|
371 | class Spectrum(Graph): | |
306 |
|
372 | |||
|
373 | ||||
307 | showColorbar = False |
|
374 | showColorbar = False | |
308 | showPowerProfile = True |
|
375 | showPowerProfile = True | |
309 |
|
376 | |||
|
377 | __szchar = 0.7 | |||
310 |
|
378 | |||
311 | def __init__(self): |
|
379 | def __init__(self): | |
312 |
|
380 | |||
313 | key = "spec" |
|
381 | key = "spec" | |
314 |
|
382 | |||
315 | specObj = BasicGraph() |
|
383 | specObj = BasicGraph() | |
316 | specObj.setName(key) |
|
384 | specObj.setName(key) | |
317 |
|
385 | |||
318 | self.graphObjDict[key] = specObj |
|
386 | self.graphObjDict[key] = specObj | |
319 |
|
387 | |||
320 |
|
388 | |||
321 | def setup(self, title="", xlabel="", ylabel="", colormap="jet", showColorbar=False, showPowerProfile=False): |
|
389 | def setup(self, subpage, title="", xlabel="", ylabel="", colormap="jet", showColorbar=False, showPowerProfile=False): | |
322 |
|
390 | """ | ||
323 | xi = 0.12 |
|
391 | """ | |
324 | xw = 0.86 |
|
|||
325 | xf = xi + xw |
|
|||
326 |
|
392 | |||
327 | yi = 0.14 |
|
393 | xi = 0.12; xw = 0.78; xf = xi + xw | |
328 | yw = 0.80 |
|
394 | yi = 0.14; yw = 0.80; yf = yi + yw | |
329 | yf = yi + yw |
|
|||
330 |
|
395 | |||
331 | xcmapi = xcmapf = 0. |
|
396 | xcmapi = xcmapf = 0.; xpowi = xpowf = 0. | |
332 | xpowi = xpowf = 0. |
|
|||
333 |
|
397 | |||
334 | specObj = self.graphObjDict[0] |
|
398 | key = "spec" | |
|
399 | specObj = self.graphObjDict[key] | |||
|
400 | specObj.setSubpage(subpage) | |||
|
401 | specObj.setSzchar(self.__szchar) | |||
|
402 | specObj.setOpt("bcnts","bcnts") | |||
335 | specObj.setup(title, |
|
403 | specObj.setup(title, | |
336 | xlabel, |
|
404 | xlabel, | |
337 | ylabel, |
|
405 | ylabel, | |
338 | colormap) |
|
406 | colormap) | |
339 |
|
407 | |||
340 | if showColorbar: |
|
408 | if showColorbar: | |
341 | key = "colorbar" |
|
409 | key = "colorbar" | |
342 |
|
410 | |||
343 | cmapObj = BasicGraph() |
|
411 | cmapObj = BasicGraph() | |
344 | cmapObj.setName(key) |
|
412 | cmapObj.setName(key) | |
|
413 | cmapObj.setSubpage(subpage) | |||
|
414 | cmapObj.setSzchar(self.__szchar) | |||
|
415 | cmapObj.setOpt("bc","bcmt") | |||
345 | cmapObj.setup(title="dBs", |
|
416 | cmapObj.setup(title="dBs", | |
346 | xlabel="", |
|
417 | xlabel="", | |
347 | ylabel="", |
|
418 | ylabel="", | |
348 | colormap=colormap) |
|
419 | colormap=colormap) | |
349 |
|
420 | |||
350 |
self.graphObjDict[key] = cmapObj |
|
421 | self.graphObjDict[key] = cmapObj | |
351 |
|
422 | |||
352 | xcmapi = 0. |
|
423 | xcmapi = 0. | |
353 |
xcmapw = 0. |
|
424 | xcmapw = 0.05 | |
354 | xw -= xcmapw |
|
425 | xw -= xcmapw | |
355 |
|
426 | |||
356 | if showPowerProfile: |
|
427 | if showPowerProfile: | |
357 | key = "powerprof" |
|
428 | key = "powerprof" | |
358 |
|
429 | |||
359 | powObj = BasicGraph() |
|
430 | powObj = BasicGraph() | |
360 | powObj.setName(key) |
|
431 | powObj.setName(key) | |
|
432 | powObj.setSubpage(subpage) | |||
|
433 | powObj.setSzchar(self.__szchar) | |||
|
434 | plplot.pllsty(2) | |||
|
435 | powObj.setOpt("bcntg","bc") | |||
|
436 | plplot.pllsty(1) | |||
361 | powObj.setup(title="Power Profile", |
|
437 | powObj.setup(title="Power Profile", | |
362 | xlabel="dBs", |
|
438 | xlabel="dBs", | |
363 | ylabel="") |
|
439 | ylabel="") | |
364 |
|
440 | |||
365 |
self.graphObjDict[key] = powObj |
|
441 | self.graphObjDict[key] = powObj | |
366 |
|
442 | |||
367 | xpowi = 0. |
|
443 | xpowi = 0. | |
368 |
xpoww = 0.2 |
|
444 | xpoww = 0.24 | |
369 | xw -= xpoww |
|
445 | xw -= xpoww | |
370 |
|
446 | |||
371 | xf = xi + xw |
|
447 | xf = xi + xw | |
372 | yf = yi + yw |
|
448 | yf = yi + yw | |
373 | xcmapf = xf |
|
449 | xcmapf = xf | |
374 |
|
450 | |||
375 |
specObj.setScreenPos([xi, |
|
451 | specObj.setScreenPos([xi, xf], [yi, yf]) | |
376 |
|
452 | |||
377 | if showColorbar: |
|
453 | if showColorbar: | |
378 | xcmapi = xf + 0.2 |
|
454 | xcmapi = xf + 0.02 | |
379 | xcmapf = xcmapi + xcmapw |
|
455 | xcmapf = xcmapi + xcmapw | |
380 |
cmapObj.setScreenPos([xcmapi, |
|
456 | cmapObj.setScreenPos([xcmapi, xcmapf], [yi, yf]) | |
381 |
|
457 | |||
382 | if showPowerProfile: |
|
458 | if showPowerProfile: | |
383 |
xpowi = xcmapf + 0. |
|
459 | xpowi = xcmapf + 0.06 | |
384 | xpowf = xpowi + xpoww |
|
460 | xpowf = xpowi + xpoww | |
385 |
powObj.setScreenPos([xpowi, |
|
461 | powObj.setScreenPos([xpowi, xpowf], [yi, yf]) | |
386 |
|
462 | |||
387 |
|
463 | |||
388 | specObj.initSubpage() |
|
464 | # specObj.initSubpage() | |
389 |
|
465 | # | ||
390 | if showColorbar: |
|
466 | # if showColorbar: | |
391 | cmapObj.initPlot() |
|
467 | # cmapObj.initPlot() | |
392 |
|
468 | # | ||
393 | if showPowerProfile: |
|
469 | # if showPowerProfile: | |
394 | powObj.initPlot() |
|
470 | # powObj.initPlot() | |
395 |
|
471 | |||
396 | self.showColorbar = showColorbar |
|
472 | self.showColorbar = showColorbar | |
397 | self.showPowerProfile = showPowerProfile |
|
473 | self.showPowerProfile = showPowerProfile | |
398 |
|
474 | |||
399 |
def setRanges(self, xrange |
|
475 | def setRanges(self, xrange, yrange, zrange): | |
400 |
|
476 | |||
401 | key = "spec" |
|
477 | key = "spec" | |
402 | specObj = self.graphObjDict[key] |
|
478 | specObj = self.graphObjDict[key] | |
403 | specObj.setRanges(xrange, yrange, zrange) |
|
479 | specObj.setRanges(xrange, yrange, zrange) | |
404 |
|
480 | |||
405 | keyList = self.graphObjDict.keys() |
|
481 | keyList = self.graphObjDict.keys() | |
406 |
|
482 | |||
407 | key = "colorbar" |
|
483 | key = "colorbar" | |
408 | if key in keyList: |
|
484 | if key in keyList: | |
409 | cmapObj = self.graphObjDict[key] |
|
485 | cmapObj = self.graphObjDict[key] | |
410 |
cmapObj.setRanges([0., 1.], zrange |
|
486 | cmapObj.setRanges([0., 1.], zrange) | |
411 |
|
487 | |||
412 | key = "powerprof" |
|
488 | key = "powerprof" | |
413 | if key in keyList: |
|
489 | if key in keyList: | |
414 | powObj = self.graphObjDict[key] |
|
490 | powObj = self.graphObjDict[key] | |
415 | powObj.setRanges(zrange, yrange) |
|
491 | powObj.setRanges(zrange, yrange) | |
416 |
|
492 | |||
417 | def plotData(self, data , xmin, xmax, ymin, ymax): |
|
493 | def plotData(self, data , xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None): | |
418 |
|
494 | |||
419 | pass |
|
495 | key = "spec" | |
|
496 | specObj = self.graphObjDict[key] | |||
|
497 | specObj.initSubpage() | |||
|
498 | ||||
|
499 | if xmin == None: | |||
|
500 | xmin = 0. | |||
|
501 | ||||
|
502 | if xmax == None: | |||
|
503 | xmax = 1. | |||
420 |
|
504 | |||
|
505 | if ymin == None: | |||
|
506 | ymin = 0. | |||
|
507 | ||||
|
508 | if ymax == None: | |||
|
509 | ymax = 1. | |||
|
510 | ||||
|
511 | if zmin == None: | |||
|
512 | zmin = numpy.nanmin(data) | |||
|
513 | ||||
|
514 | if zmax == None: | |||
|
515 | zmax = numpy.nanmax(data) | |||
|
516 | ||||
|
517 | if not(specObj.hasRange): | |||
|
518 | self.setRanges([xmin, xmax], [ymin,ymax], [zmin,zmax]) | |||
|
519 | ||||
|
520 | specObj.basicPcolorPlot(data, xmin, xmax, ymin, ymax, specObj.zrange[0], specObj.zrange[1]) | |||
|
521 | ||||
|
522 | if self.showColorbar: | |||
|
523 | key = "colorbar" | |||
|
524 | cmapObj = self.graphObjDict[key] | |||
|
525 | cmapObj.colorbarPlot() | |||
|
526 | ||||
|
527 | if self.showPowerProfile: | |||
|
528 | power = numpy.average(data, axis=1) | |||
|
529 | ||||
|
530 | step = (ymax - ymin)/(power.shape[0]-1) | |||
|
531 | heis = numpy.arange(ymin, ymax + step, step) | |||
|
532 | ||||
|
533 | key = "powerprof" | |||
|
534 | powObj = self.graphObjDict[key] | |||
|
535 | powObj.basicXYPlot(power, heis) | |||
|
536 | ||||
421 | class CrossSpectrum(Graph): |
|
537 | class CrossSpectrum(Graph): | |
422 |
|
538 | |||
423 | def __init__(self): |
|
539 | def __init__(self): | |
424 | pass |
|
540 | pass | |
425 |
|
541 | |||
426 | def setup(self): |
|
542 | def setup(self): | |
427 | pass |
|
543 | pass | |
428 |
|
544 | |||
429 | def plotData(self): |
|
545 | def plotData(self): | |
430 | pass |
|
546 | pass | |
431 |
|
547 | |||
432 | class Graph2(): |
|
548 | class Graph2(): | |
433 |
|
549 | |||
434 | def __init__(self): |
|
550 | def __init__(self): | |
435 | """ |
|
551 | """ | |
436 | Initiation of variables |
|
552 | Initiation of variables | |
437 |
|
553 | |||
438 | Variables: |
|
554 | Variables: | |
439 |
|
555 | |||
440 | type: |
|
556 | type: | |
441 | windowsize: |
|
557 | windowsize: | |
442 | cmap: colormap |
|
558 | cmap: colormap | |
443 | showcmap: show the colormap selected on the graphic |
|
559 | showcmap: show the colormap selected on the graphic | |
444 |
|
560 | |||
445 | """ |
|
561 | """ | |
446 |
|
562 | |||
447 | self.id = None |
|
563 | self.id = None | |
448 | self.subpage = None |
|
564 | self.subpage = None | |
449 | self.type = None |
|
565 | self.type = None | |
450 | self.windowsize = None |
|
566 | self.windowsize = None | |
451 |
|
567 | |||
452 | self.szchar = 0.6 |
|
568 | self.szchar = 0.6 | |
453 | self.title = None |
|
569 | self.title = None | |
454 | self.xlabel = None |
|
570 | self.xlabel = None | |
455 | self.ylabel = None |
|
571 | self.ylabel = None | |
456 |
|
572 | |||
457 | self.showGraph2 = None |
|
573 | self.showGraph2 = None | |
458 | self.cmap = None |
|
574 | self.cmap = None | |
459 | self.showcmap = None |
|
575 | self.showcmap = None | |
460 |
|
576 | |||
461 | self.xrangeIsTime = False |
|
577 | self.xrangeIsTime = False | |
462 |
|
578 | |||
463 | self.xrange = () |
|
579 | self.xrange = () | |
464 | self.yrange = () |
|
580 | self.yrange = () | |
465 | self.zrange = () |
|
581 | self.zrange = () | |
466 |
|
582 | |||
467 | self.xscreen = () |
|
583 | self.xscreen = () | |
468 | self.yscreen = () |
|
584 | self.yscreen = () | |
469 |
|
585 | |||
470 | self.xcmapscreen = () |
|
586 | self.xcmapscreen = () | |
471 | self.ycmapscreen = () |
|
587 | self.ycmapscreen = () | |
472 |
|
588 | |||
473 | self.x2screen = () |
|
589 | self.x2screen = () | |
474 | self.y2screen = () |
|
590 | self.y2screen = () | |
475 |
|
591 | |||
476 |
|
592 | |||
477 | def setup(self, id, type=0, windowsize=1., title="", xlabel="", ylabel="", showGraph2=None, cmap="jet", showcmap=False, xrangeIsTime=False): |
|
593 | def setup(self, id, type=0, windowsize=1., title="", xlabel="", ylabel="", showGraph2=None, cmap="jet", showcmap=False, xrangeIsTime=False): | |
478 | """ |
|
594 | """ | |
479 | Inputs: |
|
595 | Inputs: | |
480 | type: This variable indicates the kind of graphic. Instantaneous data or background data |
|
596 | type: This variable indicates the kind of graphic. Instantaneous data or background data | |
481 |
|
597 | |||
482 | 0: real instantaneous data, like spectrum |
|
598 | 0: real instantaneous data, like spectrum | |
483 | 1: background data, like spectrogram (RTI) |
|
599 | 1: background data, like spectrogram (RTI) | |
484 | 2: complex instantaneous data, like cross-spectrum |
|
600 | 2: complex instantaneous data, like cross-spectrum | |
485 |
|
601 | |||
486 | windowsize : Float. Size of window. It can be full window (1), half window (0.5) or 1 1/2 window (1.5) |
|
602 | windowsize : Float. Size of window. It can be full window (1), half window (0.5) or 1 1/2 window (1.5) | |
487 | cmap : Set the colormap to use |
|
603 | cmap : Set the colormap to use | |
488 | showcmap : Show the colormap used on the graphic. |
|
604 | showcmap : Show the colormap used on the graphic. | |
489 |
|
605 | |||
490 |
|
606 | |||
491 | Variables affected: |
|
607 | Variables affected: | |
492 |
|
608 | |||
493 | """ |
|
609 | """ | |
494 |
|
610 | |||
495 | # if windowsize == 1.: |
|
611 | # if windowsize == 1.: | |
496 | # self.xscreen = (0.12, 0.96) |
|
612 | # self.xscreen = (0.12, 0.96) | |
497 | # self.yscreen = (0.14, 0.94) |
|
613 | # self.yscreen = (0.14, 0.94) | |
498 | # |
|
614 | # | |
499 | # elif windowsize == 0.5: |
|
615 | # elif windowsize == 0.5: | |
500 | # self.xscreen = (0.12, 0.52) |
|
616 | # self.xscreen = (0.12, 0.52) | |
501 | # self.yscreen = (0.14, 0.94) |
|
617 | # self.yscreen = (0.14, 0.94) | |
502 | # |
|
618 | # | |
503 | # elif windowsize == 1.5: |
|
619 | # elif windowsize == 1.5: | |
504 | # self.xscreen = (-0.44, 0.96) |
|
620 | # self.xscreen = (-0.44, 0.96) | |
505 | # self.yscreen = (0.14, 0.94) |
|
621 | # self.yscreen = (0.14, 0.94) | |
506 | # |
|
622 | # | |
507 | # else: |
|
623 | # else: | |
508 | # raise ValueError, "type of graphic has not been properly set" |
|
624 | # raise ValueError, "type of graphic has not been properly set" | |
509 |
|
625 | |||
510 | if showGraph2 == None: |
|
626 | if showGraph2 == None: | |
511 | if type == 0: |
|
627 | if type == 0: | |
512 | showGraph2 = True |
|
628 | showGraph2 = True | |
513 |
|
629 | |||
514 | if type == 1: |
|
630 | if type == 1: | |
515 | showGraph2 = True |
|
631 | showGraph2 = True | |
516 |
|
632 | |||
517 | if type == 2: |
|
633 | if type == 2: | |
518 | showGraph2 = True |
|
634 | showGraph2 = True | |
519 |
|
635 | |||
520 | xscreen = (0.12, 0.98) |
|
636 | xscreen = (0.12, 0.98) | |
521 | yscreen = (0.14, 0.94) |
|
637 | yscreen = (0.14, 0.94) | |
522 | xcmapscreen = (0., 0.) |
|
638 | xcmapscreen = (0., 0.) | |
523 | ycmapscreen = (0.14, 0.94) |
|
639 | ycmapscreen = (0.14, 0.94) | |
524 | x2screen = (0., 0.) |
|
640 | x2screen = (0., 0.) | |
525 | y2screen = (0.14, 0.94) |
|
641 | y2screen = (0.14, 0.94) | |
526 |
|
642 | |||
527 | if type == 0: |
|
643 | if type == 0: | |
528 |
|
644 | |||
529 | #showGraph2 <> PowerProfile |
|
645 | #showGraph2 <> PowerProfile | |
530 | if showGraph2 and showcmap: |
|
646 | if showGraph2 and showcmap: | |
531 | xscreen = (0.12, 0.62) |
|
647 | xscreen = (0.12, 0.62) | |
532 | xcmapscreen = (0.64, 0.70) |
|
648 | xcmapscreen = (0.64, 0.70) | |
533 | x2screen = (0.75, 0.98) |
|
649 | x2screen = (0.75, 0.98) | |
534 |
|
650 | |||
535 | elif showGraph2: |
|
651 | elif showGraph2: | |
536 | xscreen = (0.12, 0.67) |
|
652 | xscreen = (0.12, 0.67) | |
537 | xcmapscreen = (0., 0.) |
|
653 | xcmapscreen = (0., 0.) | |
538 | x2screen = (0.7, 0.98) |
|
654 | x2screen = (0.7, 0.98) | |
539 |
|
655 | |||
540 | elif showcmap: |
|
656 | elif showcmap: | |
541 | xscreen = (0.12, 0.85) |
|
657 | xscreen = (0.12, 0.85) | |
542 | xcmapscreen = (0.87, 0.93) |
|
658 | xcmapscreen = (0.87, 0.93) | |
543 | x2screen = (0., 0.) |
|
659 | x2screen = (0., 0.) | |
544 |
|
660 | |||
545 | if type == 1: |
|
661 | if type == 1: | |
546 | xscreen = (0.06, 0.98) |
|
662 | xscreen = (0.06, 0.98) | |
547 | yscreen = (0.16, 0.84) |
|
663 | yscreen = (0.16, 0.84) | |
548 | #showGraph2 <> Phase |
|
664 | #showGraph2 <> Phase | |
549 | if showGraph2 and showcmap: |
|
665 | if showGraph2 and showcmap: | |
550 | xscreen = (0.06, 0.75) |
|
666 | xscreen = (0.06, 0.75) | |
551 | xcmapscreen = (0.76, 0.80) |
|
667 | xcmapscreen = (0.76, 0.80) | |
552 | x2screen = (0.82, 0.98) |
|
668 | x2screen = (0.82, 0.98) | |
553 |
|
669 | |||
554 | elif showGraph2: |
|
670 | elif showGraph2: | |
555 | xscreen = (0.06, 0.80) |
|
671 | xscreen = (0.06, 0.80) | |
556 | xcmapscreen = (0., 0.) |
|
672 | xcmapscreen = (0., 0.) | |
557 | x2screen = (0.82, 0.98) |
|
673 | x2screen = (0.82, 0.98) | |
558 |
|
674 | |||
559 | elif showcmap: |
|
675 | elif showcmap: | |
560 | xscreen = (0.06, 0.92) |
|
676 | xscreen = (0.06, 0.92) | |
561 | xcmapscreen = (0.93, 0.96) |
|
677 | xcmapscreen = (0.93, 0.96) | |
562 | x2screen = (0., 0.) |
|
678 | x2screen = (0., 0.) | |
563 |
|
679 | |||
564 | if type == 2: |
|
680 | if type == 2: | |
565 | if showGraph2 and showcmap: |
|
681 | if showGraph2 and showcmap: | |
566 | xscreen = (0.12, 0.46) |
|
682 | xscreen = (0.12, 0.46) | |
567 | xcmapscreen = (0.48, 0.54) |
|
683 | xcmapscreen = (0.48, 0.54) | |
568 | x2screen = (0.56, 0.98) |
|
684 | x2screen = (0.56, 0.98) | |
569 |
|
685 | |||
570 | elif showGraph2: |
|
686 | elif showGraph2: | |
571 | xscreen = (0.12, 0.54) |
|
687 | xscreen = (0.12, 0.54) | |
572 | xcmapscreen = (0., 0.) |
|
688 | xcmapscreen = (0., 0.) | |
573 | x2screen = (0.56, 0.98) |
|
689 | x2screen = (0.56, 0.98) | |
574 |
|
690 | |||
575 | elif showcmap: |
|
691 | elif showcmap: | |
576 | xscreen = (0.12, 0.85) |
|
692 | xscreen = (0.12, 0.85) | |
577 | xcmapscreen = (0.87, 0.93) |
|
693 | xcmapscreen = (0.87, 0.93) | |
578 | x2screen = (0., 0.) |
|
694 | x2screen = (0., 0.) | |
579 |
|
695 | |||
580 | if type == 3: |
|
696 | if type == 3: | |
581 | xscreen = (0.12, 0.52) |
|
697 | xscreen = (0.12, 0.52) | |
582 | x2screen = (0.76, 0.96) |
|
698 | x2screen = (0.76, 0.96) | |
583 |
|
699 | |||
584 | if type == 4: |
|
700 | if type == 4: | |
585 | xscreen = (-0.44, 0.96) |
|
701 | xscreen = (-0.44, 0.96) | |
586 | x2screen = (0.76, 0.96) |
|
702 | x2screen = (0.76, 0.96) | |
587 |
|
703 | |||
588 |
|
704 | |||
589 | self.id = id |
|
705 | self.id = id | |
590 | self.subpage = id + 1 |
|
706 | self.subpage = id + 1 | |
591 | self.type = type |
|
707 | self.type = type | |
592 | self.windowsize = windowsize |
|
708 | self.windowsize = windowsize | |
593 | self.title = title |
|
709 | self.title = title | |
594 | self.xlabel = xlabel |
|
710 | self.xlabel = xlabel | |
595 | self.ylabel = ylabel |
|
711 | self.ylabel = ylabel | |
596 | self.showGraph2 = showGraph2 |
|
712 | self.showGraph2 = showGraph2 | |
597 | self.cmap = cmap |
|
713 | self.cmap = cmap | |
598 | self.showcmap = showcmap |
|
714 | self.showcmap = showcmap | |
599 | self.xrangeIsTime = xrangeIsTime |
|
715 | self.xrangeIsTime = xrangeIsTime | |
600 |
|
716 | |||
601 | self.xscreen = xscreen |
|
717 | self.xscreen = xscreen | |
602 | self.yscreen = yscreen |
|
718 | self.yscreen = yscreen | |
603 | self.x2screen = x2screen |
|
719 | self.x2screen = x2screen | |
604 | self.y2screen = y2screen |
|
720 | self.y2screen = y2screen | |
605 | self.xcmapscreen = xcmapscreen |
|
721 | self.xcmapscreen = xcmapscreen | |
606 | self.ycmapscreen = ycmapscreen |
|
722 | self.ycmapscreen = ycmapscreen | |
607 |
|
723 | |||
608 | def setRanges(self, xrange=(), yrange=(), zrange=()): |
|
724 | def setRanges(self, xrange=(), yrange=(), zrange=()): | |
609 | """ |
|
725 | """ | |
610 | Inputs: |
|
726 | Inputs: | |
611 | xrange |
|
727 | xrange | |
612 | yrange |
|
728 | yrange | |
613 | zrange |
|
729 | zrange | |
614 |
|
730 | |||
615 | Variables affected: |
|
731 | Variables affected: | |
616 | self.xrange |
|
732 | self.xrange | |
617 | self.yrange |
|
733 | self.yrange | |
618 | self.zrange |
|
734 | self.zrange | |
619 |
|
735 | |||
620 | """ |
|
736 | """ | |
621 |
|
737 | |||
622 | self.xrange = xrange |
|
738 | self.xrange = xrange | |
623 | self.yrange = yrange |
|
739 | self.yrange = yrange | |
624 | self.zrange = zrange |
|
740 | self.zrange = zrange | |
625 |
|
741 | |||
626 | def setsubPage(self, subpage): |
|
742 | def setsubPage(self, subpage): | |
627 | """ |
|
743 | """ | |
628 | """ |
|
744 | """ | |
629 | self.subpage = subpage |
|
745 | self.subpage = subpage | |
630 |
|
746 | |||
631 | def plotColorbar(self): |
|
747 | def plotColorbar(self): | |
632 |
|
748 | |||
633 | if not(self.showcmap): |
|
749 | if not(self.showcmap): | |
634 | return 0 |
|
750 | return 0 | |
635 |
|
751 | |||
636 | colors = numpy.arange(255) |
|
752 | colors = numpy.arange(255) | |
637 | colors = numpy.reshape(colors, (1,255)) |
|
753 | colors = numpy.reshape(colors, (1,255)) | |
638 |
|
754 | |||
639 | plplot.plvpor(self.xcmapscreen[0], self.xcmapscreen[1], self.ycmapscreen[0], self.ycmapscreen[1]) |
|
755 | plplot.plvpor(self.xcmapscreen[0], self.xcmapscreen[1], self.ycmapscreen[0], self.ycmapscreen[1]) | |
640 | plplot.plwind(0., 1., self.zrange[0], self.zrange[1]) |
|
756 | plplot.plwind(0., 1., self.zrange[0], self.zrange[1]) | |
641 | plplot.plbox("bc",0.0,0,"bc",0.0,0) |
|
757 | plplot.plbox("bc",0.0,0,"bc",0.0,0) | |
642 | plplot.pllab("", "", "dBs") |
|
758 | plplot.pllab("", "", "dBs") | |
643 | plplot.plimage(colors, 0., 1., self.zrange[0], self.zrange[1], 0., 255., 0., 1., self.zrange[0], self.zrange[1]) |
|
759 | plplot.plimage(colors, 0., 1., self.zrange[0], self.zrange[1], 0., 255., 0., 1., self.zrange[0], self.zrange[1]) | |
644 |
|
760 | |||
645 | return 1 |
|
761 | return 1 | |
646 |
|
762 | |||
647 | def plotPowerProfile(self, power, ymin, ymax): |
|
763 | def plotPowerProfile(self, power, ymin, ymax): | |
648 |
|
764 | |||
649 | if not(self.showGraph2): |
|
765 | if not(self.showGraph2): | |
650 | return 0 |
|
766 | return 0 | |
651 |
|
767 | |||
652 | ny = power.shape[0] |
|
768 | ny = power.shape[0] | |
653 | yscale = (ymax - ymin) / ny |
|
769 | yscale = (ymax - ymin) / ny | |
654 | y = ymin + yscale*numpy.arange(ny) |
|
770 | y = ymin + yscale*numpy.arange(ny) | |
655 |
|
771 | |||
656 | plplot.plvpor(self.x2screen[0], self.x2screen[1], self.y2screen[0], self.y2screen[1]) |
|
772 | plplot.plvpor(self.x2screen[0], self.x2screen[1], self.y2screen[0], self.y2screen[1]) | |
657 | plplot.plwind(self.zrange[0], self.zrange[1], self.yrange[0], self.yrange[1]) |
|
773 | plplot.plwind(self.zrange[0], self.zrange[1], self.yrange[0], self.yrange[1]) | |
658 | plplot.plbox("bcnst",0.0,0,"bc",0.0,0) |
|
774 | plplot.plbox("bcnst",0.0,0,"bc",0.0,0) | |
659 | plplot.pllsty(2) |
|
775 | plplot.pllsty(2) | |
660 | plplot.plbox("bcnstg",0.0,0,"bc",0.0,0) |
|
776 | plplot.plbox("bcnstg",0.0,0,"bc",0.0,0) | |
661 | plplot.pllsty(1) |
|
777 | plplot.pllsty(1) | |
662 | plplot.pllab("dB", "", "Power Profile") |
|
778 | plplot.pllab("dB", "", "Power Profile") | |
663 | plplot.plline(power, y) |
|
779 | plplot.plline(power, y) | |
664 | #plplot.plflush() |
|
780 | #plplot.plflush() | |
665 |
|
781 | |||
666 | return 1 |
|
782 | return 1 | |
667 |
|
783 | |||
668 | def plotSpectrum(self, data, xmin=0.0, xmax=1.0, ymin=0.0, ymax=1.0, zmin=None, zmax=None): |
|
784 | def plotSpectrum(self, data, xmin=0.0, xmax=1.0, ymin=0.0, ymax=1.0, zmin=None, zmax=None): | |
669 | """ |
|
785 | """ | |
670 |
|
786 | |||
671 | """ |
|
787 | """ | |
672 | if zmin == None: zmin = numpy.nanmin(data) |
|
788 | if zmin == None: zmin = numpy.nanmin(data) | |
673 | if zmax == None: zmax = numpy.nanmax(data) |
|
789 | if zmax == None: zmax = numpy.nanmax(data) | |
674 |
|
790 | |||
675 | if self.xrange == (): self.xrange = (xmin, xmax) |
|
791 | if self.xrange == (): self.xrange = (xmin, xmax) | |
676 | if self.yrange == (): self.yrange = (ymin, ymax) |
|
792 | if self.yrange == (): self.yrange = (ymin, ymax) | |
677 | if self.zrange == (): self.zrange = (zmin, zmax) |
|
793 | if self.zrange == (): self.zrange = (zmin, zmax) | |
678 |
|
794 | |||
679 | plplot.pladv(self.subpage) |
|
795 | plplot.pladv(self.subpage) | |
680 | plplot.plschr(0.0,self.szchar) |
|
796 | plplot.plschr(0.0,self.szchar) | |
681 |
|
797 | |||
682 | power = numpy.average(data, axis=0) |
|
798 | power = numpy.average(data, axis=0) | |
683 |
|
799 | |||
684 | self.plotPowerProfile(power, ymin, ymax) |
|
800 | self.plotPowerProfile(power, ymin, ymax) | |
685 | self.plotColorbar() |
|
801 | self.plotColorbar() | |
686 |
|
802 | |||
687 | if self.xrangeIsTime: |
|
803 | if self.xrangeIsTime: | |
688 | plplot.pltimefmt("%H:%M") |
|
804 | plplot.pltimefmt("%H:%M") | |
689 |
|
805 | |||
690 | plplot.plvpor(self.xscreen[0], self.xscreen[1], self.yscreen[0], self.yscreen[1]) |
|
806 | plplot.plvpor(self.xscreen[0], self.xscreen[1], self.yscreen[0], self.yscreen[1]) | |
691 | plplot.plwind(self.xrange[0], self.xrange[1], self.yrange[0], self.yrange[1]) |
|
807 | plplot.plwind(self.xrange[0], self.xrange[1], self.yrange[0], self.yrange[1]) | |
692 | plplot.plbox("bcnst",0.0,0,"bcnstv",0.0,0) |
|
808 | plplot.plbox("bcnst",0.0,0,"bcnstv",0.0,0) | |
693 | plplot.pllab(self.xlabel, self.ylabel, self.title) |
|
809 | plplot.pllab(self.xlabel, self.ylabel, self.title) | |
694 | plplot.plimage(data, xmin, xmax, ymin, ymax, zmin, zmax, xmin, xmax, ymin, ymax) |
|
810 | plplot.plimage(data, xmin, xmax, ymin, ymax, zmin, zmax, xmin, xmax, ymin, ymax) | |
695 | #plplot.plflush() |
|
811 | #plplot.plflush() | |
696 |
|
812 | |||
697 | def plotSpectrogram(self, data, xmin=0.0, xmax=1.0, ymin=0.0, ymax=1.0, zmin=0.0, zmax=1.0): |
|
813 | def plotSpectrogram(self, data, xmin=0.0, xmax=1.0, ymin=0.0, ymax=1.0, zmin=0.0, zmax=1.0): | |
698 | """ |
|
814 | """ | |
699 |
|
815 | |||
700 | """ |
|
816 | """ | |
701 |
|
817 | |||
702 | if zmin == None: zmin = numpy.nanmin(data) |
|
818 | if zmin == None: zmin = numpy.nanmin(data) | |
703 | if zmax == None: zmax = numpy.nanmax(data) |
|
819 | if zmax == None: zmax = numpy.nanmax(data) | |
704 |
|
820 | |||
705 | if self.xrange == (): self.xrange = (xmin, xmax) |
|
821 | if self.xrange == (): self.xrange = (xmin, xmax) | |
706 | if self.yrange == (): self.yrange = (ymin, ymax) |
|
822 | if self.yrange == (): self.yrange = (ymin, ymax) | |
707 | if self.zrange == (): self.zrange = (zmin, zmax) |
|
823 | if self.zrange == (): self.zrange = (zmin, zmax) | |
708 |
|
824 | |||
709 | plplot.pladv(self.subpage) |
|
825 | plplot.pladv(self.subpage) | |
710 |
|
826 | |||
711 | plplot.plschr(0.0,self.szchar+0.3) |
|
827 | plplot.plschr(0.0,self.szchar+0.3) | |
712 |
|
828 | |||
713 | power = numpy.average(data, axis=0) |
|
829 | power = numpy.average(data, axis=0) | |
714 |
|
830 | |||
715 | self.plotPowerProfile(power, ymin, ymax) |
|
831 | self.plotPowerProfile(power, ymin, ymax) | |
716 | self.plotColorbar() |
|
832 | self.plotColorbar() | |
717 |
|
833 | |||
718 | if self.xrangeIsTime: |
|
834 | if self.xrangeIsTime: | |
719 | plplot.pltimefmt("%H:%M") |
|
835 | plplot.pltimefmt("%H:%M") | |
720 |
|
836 | |||
721 | plplot.plvpor(self.xscreen[0], self.xscreen[1], self.yscreen[0], self.yscreen[1]) |
|
837 | plplot.plvpor(self.xscreen[0], self.xscreen[1], self.yscreen[0], self.yscreen[1]) | |
722 | plplot.plwind(self.xrange[0], self.xrange[1], self.yrange[0], self.yrange[1]) |
|
838 | plplot.plwind(self.xrange[0], self.xrange[1], self.yrange[0], self.yrange[1]) | |
723 | plplot.plbox("bcnst", 0.0, 0, "bcnstv", 0.0, 0) |
|
839 | plplot.plbox("bcnst", 0.0, 0, "bcnstv", 0.0, 0) | |
724 |
|
840 | |||
725 | plplot.pllab(self.xlabel, self.ylabel, self.title) |
|
841 | plplot.pllab(self.xlabel, self.ylabel, self.title) | |
726 | plplot.plimage(data, xmin, xmax, ymin, ymax, zmin, zmax, xmin, xmax, ymin, ymax) |
|
842 | plplot.plimage(data, xmin, xmax, ymin, ymax, zmin, zmax, xmin, xmax, ymin, ymax) | |
727 | #plplot.plflush() |
|
843 | #plplot.plflush() | |
728 |
|
844 | |||
729 |
|
845 | |||
730 | class PlotData(): |
|
846 | class PlotData(): | |
731 | ''' |
|
847 | ''' | |
732 | classdocs |
|
848 | classdocs | |
733 | ''' |
|
849 | ''' | |
734 |
|
850 | |||
735 | __INST_XSIZE = 300 |
|
851 | __INST_XSIZE = 300 | |
736 | __INST_YSIZE = 280 |
|
852 | __INST_YSIZE = 280 | |
737 | __BACKGR_XSIZE = 900 |
|
853 | __BACKGR_XSIZE = 900 | |
738 | __BACKGR_YSIZE = 150 |
|
854 | __BACKGR_YSIZE = 150 | |
739 | __SPACE = 100 |
|
855 | __SPACE = 100 | |
740 |
|
856 | |||
741 | def __init__(self): |
|
857 | def __init__(self): | |
742 | ''' |
|
858 | ''' | |
743 | Constructor |
|
859 | Constructor | |
744 | ''' |
|
860 | ''' | |
745 |
|
861 | |||
746 | self.nx = None |
|
862 | self.nx = None | |
747 | self.ny = None |
|
863 | self.ny = None | |
748 | self.xsize = None |
|
864 | self.xsize = None | |
749 | self.ysize = None |
|
865 | self.ysize = None | |
750 |
|
866 | |||
751 | self.objGraphList = [] |
|
867 | self.objGraphList = [] | |
752 |
|
868 | |||
753 | def getNumSubPages(self): |
|
869 | def getNumSubPages(self): | |
754 |
|
870 | |||
755 | nT0 = 0 |
|
871 | nT0 = 0 | |
756 | nT1 = 0 |
|
872 | nT1 = 0 | |
757 | nT2 = 0 |
|
873 | nT2 = 0 | |
758 | nT10 = 0 |
|
874 | nT10 = 0 | |
759 | nT11 = 0 |
|
875 | nT11 = 0 | |
760 |
|
876 | |||
761 | for thisObj in self.objGraphList: |
|
877 | for thisObj in self.objGraphList: | |
762 | if thisObj.type == 0: |
|
878 | if thisObj.type == 0: | |
763 | nT0 += 1 |
|
879 | nT0 += 1 | |
764 | continue |
|
880 | continue | |
765 |
|
881 | |||
766 | if thisObj.type == 1: |
|
882 | if thisObj.type == 1: | |
767 | nT1 += 1 |
|
883 | nT1 += 1 | |
768 | continue |
|
884 | continue | |
769 |
|
885 | |||
770 | if thisObj.type == 2: |
|
886 | if thisObj.type == 2: | |
771 | nT2 += 1 |
|
887 | nT2 += 1 | |
772 | continue |
|
888 | continue | |
773 |
|
889 | |||
774 | if thisObj.type == 10: |
|
890 | if thisObj.type == 10: | |
775 | nT10 += 1 |
|
891 | nT10 += 1 | |
776 | continue |
|
892 | continue | |
777 |
|
893 | |||
778 | if thisObj.type == 11: |
|
894 | if thisObj.type == 11: | |
779 | nT11 += 1 |
|
895 | nT11 += 1 | |
780 | continue |
|
896 | continue | |
781 |
|
897 | |||
782 | nSpectrum = nT0 + nT2 |
|
898 | nSpectrum = nT0 + nT2 | |
783 |
|
899 | |||
784 | if (nSpectrum > 0) and nT1*nT10*nT11 == 0: |
|
900 | if (nSpectrum > 0) and nT1*nT10*nT11 == 0: | |
785 |
|
901 | |||
786 | if nSpectrum in [1,2]: nx = 1 |
|
902 | if nSpectrum in [1,2]: nx = 1 | |
787 | elif nSpectrum in [3,4,5,6]: nx = 2 |
|
903 | elif nSpectrum in [3,4,5,6]: nx = 2 | |
788 | else: nx = 3 |
|
904 | else: nx = 3 | |
789 |
|
905 | |||
790 | if nSpectrum in [1]: ny = 1 |
|
906 | if nSpectrum in [1]: ny = 1 | |
791 | elif nSpectrum in [2,3,4]: ny = 2 |
|
907 | elif nSpectrum in [2,3,4]: ny = 2 | |
792 | else: ny = 3 |
|
908 | else: ny = 3 | |
793 |
|
909 | |||
794 | elif nT1 > 0 and nT0*nT10*nT11 == 0: |
|
910 | elif nT1 > 0 and nT0*nT10*nT11 == 0: | |
795 | nx = 1 |
|
911 | nx = 1 | |
796 | ny = nT1 |
|
912 | ny = nT1 | |
797 |
|
913 | |||
798 | elif nT10 == nT11 and nT0*nT1 == 0: |
|
914 | elif nT10 == nT11 and nT0*nT1 == 0: | |
799 | nx = nT10 |
|
915 | nx = nT10 | |
800 | ny = 2 |
|
916 | ny = 2 | |
801 |
|
917 | |||
802 | else: |
|
918 | else: | |
803 | raise ValueError, "number of instantaneous and background graphics are not consistent" |
|
919 | raise ValueError, "number of instantaneous and background graphics are not consistent" | |
804 |
|
920 | |||
805 | self.nx = nx |
|
921 | self.nx = nx | |
806 | self.ny = ny |
|
922 | self.ny = ny | |
807 |
|
923 | |||
808 | return nx, ny |
|
924 | return nx, ny | |
809 |
|
925 | |||
810 | def getSizeScreen(self): |
|
926 | def getSizeScreen(self): | |
811 |
|
927 | |||
812 | nx, ny = self.nx, self.ny |
|
928 | nx, ny = self.nx, self.ny | |
813 |
|
929 | |||
814 | if nx == None or ny == None: |
|
930 | if nx == None or ny == None: | |
815 | raise ValueError, "The number of subpages have been set yet, please use the getNumSubPages method for this." |
|
931 | raise ValueError, "The number of subpages have been set yet, please use the getNumSubPages method for this." | |
816 |
|
932 | |||
817 | nT0 = 0 |
|
933 | nT0 = 0 | |
818 | nT1 = 0 |
|
934 | nT1 = 0 | |
819 | nT2 = 0 |
|
935 | nT2 = 0 | |
820 | nT10 = 0 |
|
936 | nT10 = 0 | |
821 | nT11 = 0 |
|
937 | nT11 = 0 | |
822 |
|
938 | |||
823 | for thisObj in self.objGraphList: |
|
939 | for thisObj in self.objGraphList: | |
824 | if thisObj.type == 0: |
|
940 | if thisObj.type == 0: | |
825 | nT0 += 1 |
|
941 | nT0 += 1 | |
826 | continue |
|
942 | continue | |
827 |
|
943 | |||
828 | if thisObj.type == 1: |
|
944 | if thisObj.type == 1: | |
829 | nT1 += 1 |
|
945 | nT1 += 1 | |
830 | continue |
|
946 | continue | |
831 |
|
947 | |||
832 | if thisObj.type == 2: |
|
948 | if thisObj.type == 2: | |
833 | nT2 += 1 |
|
949 | nT2 += 1 | |
834 | continue |
|
950 | continue | |
835 |
|
951 | |||
836 | if thisObj.type == 10: |
|
952 | if thisObj.type == 10: | |
837 | nT10 += 1 |
|
953 | nT10 += 1 | |
838 | continue |
|
954 | continue | |
839 |
|
955 | |||
840 | if thisObj.type == 11: |
|
956 | if thisObj.type == 11: | |
841 | nT11 += 1 |
|
957 | nT11 += 1 | |
842 | continue |
|
958 | continue | |
843 |
|
959 | |||
844 | if (nT0 > 0 or nT2 > 0) and nT1 > 0: |
|
960 | if (nT0 > 0 or nT2 > 0) and nT1 > 0: | |
845 | raise ValueError, "Different type of graphics have been selected" |
|
961 | raise ValueError, "Different type of graphics have been selected" | |
846 |
|
962 | |||
847 | if nT0 > 0 or nT2 > 0: |
|
963 | if nT0 > 0 or nT2 > 0: | |
848 | xsize = ny*self.__INST_XSIZE |
|
964 | xsize = ny*self.__INST_XSIZE | |
849 | ysize = nx*self.__INST_YSIZE |
|
965 | ysize = nx*self.__INST_YSIZE | |
850 |
|
966 | |||
851 | elif nT1 > 0: |
|
967 | elif nT1 > 0: | |
852 | xsize = nx*self.__BACKGR_XSIZE |
|
968 | xsize = nx*self.__BACKGR_XSIZE | |
853 | ysize = ny*self.__BACKGR_YSIZE |
|
969 | ysize = ny*self.__BACKGR_YSIZE | |
854 |
|
970 | |||
855 | elif nT10 == nT11: |
|
971 | elif nT10 == nT11: | |
856 | xsize = self.__INST_XSIZE + self.__BACKGR_XSIZE + self.__SPACE |
|
972 | xsize = self.__INST_XSIZE + self.__BACKGR_XSIZE + self.__SPACE | |
857 | ysize = nx*self.__BACKGR_YSIZE |
|
973 | ysize = nx*self.__BACKGR_YSIZE | |
858 | else: |
|
974 | else: | |
859 | raise ValueError, "number of instantaneous and background graphics are not consistent" |
|
975 | raise ValueError, "number of instantaneous and background graphics are not consistent" | |
860 |
|
976 | |||
861 | self.xsize = xsize |
|
977 | self.xsize = xsize | |
862 | self.ysize = ysize |
|
978 | self.ysize = ysize | |
863 |
|
979 | |||
864 | return xsize, ysize |
|
980 | return xsize, ysize | |
865 |
|
981 | |||
866 | def setup(self, sizescreen="800x600", save=False, gpath="", filename=""): |
|
982 | def setup(self, sizescreen="800x600", save=False, gpath="", filename=""): | |
867 | """ |
|
983 | """ | |
868 | """ |
|
984 | """ | |
869 |
|
985 | |||
870 | self.sizecreen = sizescreen |
|
986 | self.sizecreen = sizescreen | |
871 | self.save = save |
|
987 | self.save = save | |
872 | self.gpath = gpath |
|
988 | self.gpath = gpath | |
873 | self.filename = filename |
|
989 | self.filename = filename | |
874 |
|
990 | |||
875 | def addGraph(self, type=0, xlabel="", ylabel="", title="", showGraph2=False, showcmap=False, cmap="jet", windowsize=1.): |
|
991 | def addGraph(self, type=0, xlabel="", ylabel="", title="", showGraph2=False, showcmap=False, cmap="jet", windowsize=1.): | |
876 | """ |
|
992 | """ | |
877 | type: This variable indicates the kind of graphics. Instantaneous data or background data |
|
993 | type: This variable indicates the kind of graphics. Instantaneous data or background data | |
878 |
|
994 | |||
879 | 0: real instantaneous data, like a spectrum |
|
995 | 0: real instantaneous data, like a spectrum | |
880 | 1: background data, like a spectrogram (RTI) |
|
996 | 1: background data, like a spectrogram (RTI) | |
881 | 2: complex instantaneous data, like cross-spectrum |
|
997 | 2: complex instantaneous data, like cross-spectrum | |
882 |
|
998 | |||
883 |
|
999 | |||
884 | windowsize: Float. Size of window. It can be:: |
|
1000 | windowsize: Float. Size of window. It can be:: | |
885 | 1.0: full window (1) |
|
1001 | 1.0: full window (1) | |
886 | 0.5: half window |
|
1002 | 0.5: half window | |
887 | 1.5: 1 1/2 window (1.5) |
|
1003 | 1.5: 1 1/2 window (1.5) | |
888 |
|
1004 | |||
889 | If some graps have already been set with one graphic type the next ones should be of the same type |
|
1005 | If some graps have already been set with one graphic type the next ones should be of the same type | |
890 | """ |
|
1006 | """ | |
891 |
|
1007 | |||
892 | id = len(self.objGraphList) |
|
1008 | id = len(self.objGraphList) | |
893 |
|
1009 | |||
894 | objGraph = Graph2() |
|
1010 | objGraph = Graph2() | |
895 | objGraph.setup(id, type, windowsize, title, xlabel, ylabel, showGraph2, cmap, showcmap) |
|
1011 | objGraph.setup(id, type, windowsize, title, xlabel, ylabel, showGraph2, cmap, showcmap) | |
896 |
|
1012 | |||
897 | self.objGraphList.append(objGraph) |
|
1013 | self.objGraphList.append(objGraph) | |
898 |
|
1014 | |||
899 | return id |
|
1015 | return id | |
900 |
|
1016 | |||
901 | def getGraphFromId(self, id): |
|
1017 | def getGraphFromId(self, id): | |
902 | """ |
|
1018 | """ | |
903 |
|
1019 | |||
904 | """ |
|
1020 | """ | |
905 | if id >= len(self.objGraphList): |
|
1021 | if id >= len(self.objGraphList): | |
906 | return None |
|
1022 | return None | |
907 |
|
1023 | |||
908 | return self.objGraphList[id] |
|
1024 | return self.objGraphList[id] | |
909 |
|
1025 | |||
910 | def setRanges(self, id=0, xrange=(), yrange=(), zrange=()): |
|
1026 | def setRanges(self, id=0, xrange=(), yrange=(), zrange=()): | |
911 | """ |
|
1027 | """ | |
912 |
|
1028 | |||
913 | """ |
|
1029 | """ | |
914 | thisGraphObj = self.getGraphFromId(id) |
|
1030 | thisGraphObj = self.getGraphFromId(id) | |
915 | thisGraphObj.setmargins(xrange, yrange, zrange) |
|
1031 | thisGraphObj.setmargins(xrange, yrange, zrange) | |
916 |
|
1032 | |||
917 |
|
1033 | |||
918 | def addText(self, id, xpos=0, ypos=0, text=""): |
|
1034 | def addText(self, id, xpos=0, ypos=0, text=""): | |
919 | """ |
|
1035 | """ | |
920 |
|
1036 | |||
921 | """ |
|
1037 | """ | |
922 | thisGraphObj = self.getGraphFromId(id) |
|
1038 | thisGraphObj = self.getGraphFromId(id) | |
923 |
|
1039 | |||
924 | plplot.pladv(thisGraphObj.subpage) |
|
1040 | plplot.pladv(thisGraphObj.subpage) | |
925 | plplot.plmtex("b", 5, xpos, ypos, text) |
|
1041 | plplot.plmtex("b", 5, xpos, ypos, text) | |
926 |
|
1042 | |||
927 | def plotData(self, id, data, xmin=0.0, xmax=1.0, ymin=0.0, ymax=1.0, zmin=None, zmax=None): |
|
1043 | def plotData(self, id, data, xmin=0.0, xmax=1.0, ymin=0.0, ymax=1.0, zmin=None, zmax=None): | |
928 |
|
1044 | |||
929 | thisGraphObj = self.getGraphFromId(id) |
|
1045 | thisGraphObj = self.getGraphFromId(id) | |
930 |
|
1046 | |||
931 | if thisGraphObj == None: |
|
1047 | if thisGraphObj == None: | |
932 | return 0 |
|
1048 | return 0 | |
933 |
|
1049 | |||
934 | plplot.plcol0(1) |
|
1050 | plplot.plcol0(1) | |
935 | if thisGraphObj.type in [0,2]: |
|
1051 | if thisGraphObj.type in [0,2]: | |
936 | thisGraphObj.plotSpectrum(data, xmin, xmax, ymin, ymax, zmin, zmax) |
|
1052 | thisGraphObj.plotSpectrum(data, xmin, xmax, ymin, ymax, zmin, zmax) | |
937 | return 1 |
|
1053 | return 1 | |
938 |
|
1054 | |||
939 | if thisGraphObj.type in [1]: |
|
1055 | if thisGraphObj.type in [1]: | |
940 | thisGraphObj.plotSpectrogram(data, xmin, xmax, ymin, ymax, zmin, zmax) |
|
1056 | thisGraphObj.plotSpectrogram(data, xmin, xmax, ymin, ymax, zmin, zmax) | |
941 | return 1 |
|
1057 | return 1 | |
942 |
|
1058 | |||
943 | return 0 |
|
1059 | return 0 | |
944 |
|
1060 | |||
945 | def iniPlot(self, nx=None, ny=None): |
|
1061 | def iniPlot(self, nx=None, ny=None): | |
946 | """ |
|
1062 | """ | |
947 |
|
1063 | |||
948 | """ |
|
1064 | """ | |
949 | if nx == None or ny == None: |
|
1065 | if nx == None or ny == None: | |
950 | nx, ny = self.getNumSubPages() |
|
1066 | nx, ny = self.getNumSubPages() | |
951 |
|
1067 | |||
952 | self.getSizeScreen() |
|
1068 | self.getSizeScreen() | |
953 |
|
1069 | |||
954 | plplot.plsetopt("geometry", "%dx%d" %(self.xsize, self.ysize)) |
|
1070 | plplot.plsetopt("geometry", "%dx%d" %(self.xsize, self.ysize)) | |
955 | plplot.plsdev("xcairo") |
|
1071 | plplot.plsdev("xcairo") | |
956 | plplot.plscolbg(255,255,255) |
|
1072 | plplot.plscolbg(255,255,255) | |
957 | plplot.plscol0(1,0,0,0) |
|
1073 | plplot.plscol0(1,0,0,0) | |
958 | plplot.plinit() |
|
1074 | plplot.plinit() | |
959 | plplot.plssub(nx, ny) |
|
1075 | plplot.plssub(nx, ny) | |
960 | plplot.pladv(0) |
|
1076 | plplot.pladv(0) | |
961 |
|
1077 | |||
962 | #plplot.plspause(0) |
|
1078 | #plplot.plspause(0) | |
963 |
|
1079 | |||
964 | def end(self): |
|
1080 | def end(self): | |
965 | plplot.plflush() |
|
1081 | plplot.plflush() | |
966 | plplot.plend() |
|
1082 | plplot.plend() | |
967 |
|
1083 | |||
968 | if __name__ == '__main__': |
|
1084 | if __name__ == '__main__': | |
969 |
|
1085 | |||
970 | import numpy |
|
1086 | import numpy | |
971 | data = numpy.random.uniform(-50,50,(150,250)) |
|
1087 | plplot.plsetopt("geometry", "%dx%d" %(350*2, 300*2)) | |
|
1088 | plplot.plsdev("xcairo") | |||
|
1089 | plplot.plscolbg(255,255,255) | |||
|
1090 | plplot.plscol0(1,0,0,0) | |||
|
1091 | plplot.plinit() | |||
|
1092 | plplot.plssub(2, 2) | |||
|
1093 | ||||
|
1094 | nx = 64 | |||
|
1095 | ny = 100 | |||
|
1096 | ||||
|
1097 | data = numpy.random.uniform(-50,50,(nx,ny)) | |||
|
1098 | ||||
|
1099 | specObj = Spectrum() | |||
|
1100 | specObj.setup(1, "Spectrum", "Frequency", "Range", "br_black", True, True) | |||
|
1101 | specObj.plotData(data) | |||
|
1102 | ||||
|
1103 | data = numpy.random.uniform(-50,50,(nx,ny)) | |||
|
1104 | ||||
|
1105 | spec2Obj = Spectrum() | |||
|
1106 | spec2Obj.setup(2, "Spectrum", "Frequency", "Range", "br_black", True, True) | |||
|
1107 | spec2Obj.plotData(data) | |||
|
1108 | ||||
|
1109 | plplot.plend() | |||
|
1110 | exit(0) | |||
972 |
|
1111 | |||
973 | objPlot = PlotData() |
|
1112 | objPlot = PlotData() | |
974 | objPlot.addGraph(1, "Frequency", "Height", "Channel A") |
|
1113 | objPlot.addGraph(1, "Frequency", "Height", "Channel A") | |
975 | objPlot.addGraph(1, "Frequency", "Height", "Channel B", showGraph2=True) |
|
1114 | objPlot.addGraph(1, "Frequency", "Height", "Channel B", showGraph2=True) | |
976 | objPlot.addGraph(1, "Frequency", "Height", "Channel C", showcmap=True) |
|
1115 | objPlot.addGraph(1, "Frequency", "Height", "Channel C", showcmap=True) | |
977 | # |
|
1116 | # | |
978 | # objPlot.addGraph(1, "Frequency", "Height", "Cross A-B") |
|
1117 | # objPlot.addGraph(1, "Frequency", "Height", "Cross A-B") | |
979 | # objPlot.addGraph(1, "Frequency", "Height", "Cross A-C", showGraph2=True) |
|
1118 | # objPlot.addGraph(1, "Frequency", "Height", "Cross A-C", showGraph2=True) | |
980 | # objPlot.addGraph(1, "Frequency", "Height", "Cross A-D", showcmap=True) |
|
1119 | # objPlot.addGraph(1, "Frequency", "Height", "Cross A-D", showcmap=True) | |
981 | # |
|
1120 | # | |
982 | objPlot.addGraph(1, "Frequency", "Height", "Channel D", showcmap=True, showGraph2=True) |
|
1121 | objPlot.addGraph(1, "Frequency", "Height", "Channel D", showcmap=True, showGraph2=True) | |
983 | objPlot.addGraph(1, "Frequency", "Height", "Cross A-E", showcmap=True, showGraph2=True) |
|
1122 | objPlot.addGraph(1, "Frequency", "Height", "Cross A-E", showcmap=True, showGraph2=True) | |
984 |
|
1123 | |||
985 | objPlot.iniPlot() |
|
1124 | objPlot.iniPlot() | |
986 |
|
1125 | |||
987 | for id in range(10): |
|
1126 | for id in range(10): | |
988 | objPlot.plotData(id, data) |
|
1127 | objPlot.plotData(id, data) | |
989 |
|
1128 | |||
990 | objPlot.end() No newline at end of file |
|
1129 | objPlot.end() |
General Comments 0
You need to be logged in to leave comments.
Login now