@@ -1,852 +1,863 | |||||
1 | """ |
|
1 | """ | |
2 | Created on Feb 7, 2012 |
|
2 | Created on Feb 7, 2012 | |
3 |
|
3 | |||
4 | @autor $Author$ |
|
4 | @autor $Author$ | |
5 | @version $Id$ |
|
5 | @version $Id$ | |
6 |
|
6 | |||
7 | """ |
|
7 | """ | |
8 |
|
8 | |||
9 | import numpy |
|
9 | import numpy | |
10 | import plplot |
|
10 | import plplot | |
11 |
|
11 | |||
12 | def cmap1_init(colormap="gray"): |
|
12 | def cmap1_init(colormap="gray"): | |
13 |
|
13 | |||
14 | ncolor = None |
|
14 | ncolor = None | |
15 | rgb_lvl = None |
|
15 | rgb_lvl = None | |
16 |
|
16 | |||
17 | # Routine for defining a specific color map 1 in HLS space. |
|
17 | # Routine for defining a specific color map 1 in HLS space. | |
18 | # if gray is true, use basic grayscale variation from half-dark to light. |
|
18 | # if gray is true, use basic grayscale variation from half-dark to light. | |
19 | # otherwise use false color variation from blue (240 deg) to red (360 deg). |
|
19 | # otherwise use false color variation from blue (240 deg) to red (360 deg). | |
20 |
|
20 | |||
21 | # Independent variable of control points. |
|
21 | # Independent variable of control points. | |
22 | i = numpy.array((0., 1.)) |
|
22 | i = numpy.array((0., 1.)) | |
23 | if colormap=="gray": |
|
23 | if colormap=="gray": | |
24 | ncolor = 256 |
|
24 | ncolor = 256 | |
25 | # Hue for control points. Doesn't matter since saturation is zero. |
|
25 | # Hue for control points. Doesn't matter since saturation is zero. | |
26 | h = numpy.array((0., 0.)) |
|
26 | h = numpy.array((0., 0.)) | |
27 | # Lightness ranging from half-dark (for interest) to light. |
|
27 | # Lightness ranging from half-dark (for interest) to light. | |
28 | l = numpy.array((0.5, 1.)) |
|
28 | l = numpy.array((0.5, 1.)) | |
29 | # Gray scale has zero saturation |
|
29 | # Gray scale has zero saturation | |
30 | s = numpy.array((0., 0.)) |
|
30 | s = numpy.array((0., 0.)) | |
31 |
|
31 | |||
32 | # number of cmap1 colours is 256 in this case. |
|
32 | # number of cmap1 colours is 256 in this case. | |
33 | plplot.plscmap1n(ncolor) |
|
33 | plplot.plscmap1n(ncolor) | |
34 | # Interpolate between control points to set up cmap1. |
|
34 | # Interpolate between control points to set up cmap1. | |
35 | plplot.plscmap1l(0, i, h, l, s) |
|
35 | plplot.plscmap1l(0, i, h, l, s) | |
36 |
|
36 | |||
37 | return None |
|
37 | return None | |
38 |
|
38 | |||
39 | if colormap=="br_green": |
|
39 | if colormap=="br_green": | |
40 | ncolor = 256 |
|
40 | ncolor = 256 | |
41 | # Hue ranges from blue (240 deg) to red (0 or 360 deg) |
|
41 | # Hue ranges from blue (240 deg) to red (0 or 360 deg) | |
42 | h = numpy.array((240., 0.)) |
|
42 | h = numpy.array((240., 0.)) | |
43 | # Lightness and saturation are constant (values taken from C example). |
|
43 | # Lightness and saturation are constant (values taken from C example). | |
44 | l = numpy.array((0.6, 0.6)) |
|
44 | l = numpy.array((0.6, 0.6)) | |
45 | s = numpy.array((0.8, 0.8)) |
|
45 | s = numpy.array((0.8, 0.8)) | |
46 |
|
46 | |||
47 | # number of cmap1 colours is 256 in this case. |
|
47 | # number of cmap1 colours is 256 in this case. | |
48 | plplot.plscmap1n(ncolor) |
|
48 | plplot.plscmap1n(ncolor) | |
49 | # Interpolate between control points to set up cmap1. |
|
49 | # Interpolate between control points to set up cmap1. | |
50 | plplot.plscmap1l(0, i, h, l, s) |
|
50 | plplot.plscmap1l(0, i, h, l, s) | |
51 |
|
51 | |||
52 | return None |
|
52 | return None | |
53 |
|
53 | |||
54 | if colormap=="tricolor": |
|
54 | if colormap=="tricolor": | |
55 | ncolor = 3 |
|
55 | ncolor = 3 | |
56 | # Hue ranges from blue (240 deg) to red (0 or 360 deg) |
|
56 | # Hue ranges from blue (240 deg) to red (0 or 360 deg) | |
57 | h = numpy.array((240., 0.)) |
|
57 | h = numpy.array((240., 0.)) | |
58 | # Lightness and saturation are constant (values taken from C example). |
|
58 | # Lightness and saturation are constant (values taken from C example). | |
59 | l = numpy.array((0.6, 0.6)) |
|
59 | l = numpy.array((0.6, 0.6)) | |
60 | s = numpy.array((0.8, 0.8)) |
|
60 | s = numpy.array((0.8, 0.8)) | |
61 |
|
61 | |||
62 | # number of cmap1 colours is 256 in this case. |
|
62 | # number of cmap1 colours is 256 in this case. | |
63 | plplot.plscmap1n(ncolor) |
|
63 | plplot.plscmap1n(ncolor) | |
64 | # Interpolate between control points to set up cmap1. |
|
64 | # Interpolate between control points to set up cmap1. | |
65 | plplot.plscmap1l(0, i, h, l, s) |
|
65 | plplot.plscmap1l(0, i, h, l, s) | |
66 |
|
66 | |||
67 | return None |
|
67 | return None | |
68 |
|
68 | |||
69 | if colormap == 'rgb' or colormap == 'rgb666': |
|
69 | if colormap == 'rgb' or colormap == 'rgb666': | |
70 |
|
70 | |||
71 | color_sz = 6 |
|
71 | color_sz = 6 | |
72 | ncolor = color_sz*color_sz*color_sz |
|
72 | ncolor = color_sz*color_sz*color_sz | |
73 | pos = numpy.zeros((ncolor)) |
|
73 | pos = numpy.zeros((ncolor)) | |
74 | r = numpy.zeros((ncolor)) |
|
74 | r = numpy.zeros((ncolor)) | |
75 | g = numpy.zeros((ncolor)) |
|
75 | g = numpy.zeros((ncolor)) | |
76 | b = numpy.zeros((ncolor)) |
|
76 | b = numpy.zeros((ncolor)) | |
77 | ind = 0 |
|
77 | ind = 0 | |
78 | for ri in range(color_sz): |
|
78 | for ri in range(color_sz): | |
79 | for gi in range(color_sz): |
|
79 | for gi in range(color_sz): | |
80 | for bi in range(color_sz): |
|
80 | for bi in range(color_sz): | |
81 | r[ind] = ri/(color_sz-1.0) |
|
81 | r[ind] = ri/(color_sz-1.0) | |
82 | g[ind] = gi/(color_sz-1.0) |
|
82 | g[ind] = gi/(color_sz-1.0) | |
83 | b[ind] = bi/(color_sz-1.0) |
|
83 | b[ind] = bi/(color_sz-1.0) | |
84 | pos[ind] = ind/(ncolor-1.0) |
|
84 | pos[ind] = ind/(ncolor-1.0) | |
85 | ind += 1 |
|
85 | ind += 1 | |
86 | rgb_lvl = [6,6,6] #Levels for RGB colors |
|
86 | rgb_lvl = [6,6,6] #Levels for RGB colors | |
87 |
|
87 | |||
88 | if colormap == 'rgb676': |
|
88 | if colormap == 'rgb676': | |
89 | ncolor = 6*7*6 |
|
89 | ncolor = 6*7*6 | |
90 | pos = numpy.zeros((ncolor)) |
|
90 | pos = numpy.zeros((ncolor)) | |
91 | r = numpy.zeros((ncolor)) |
|
91 | r = numpy.zeros((ncolor)) | |
92 | g = numpy.zeros((ncolor)) |
|
92 | g = numpy.zeros((ncolor)) | |
93 | b = numpy.zeros((ncolor)) |
|
93 | b = numpy.zeros((ncolor)) | |
94 | ind = 0 |
|
94 | ind = 0 | |
95 | for ri in range(8): |
|
95 | for ri in range(8): | |
96 | for gi in range(8): |
|
96 | for gi in range(8): | |
97 | for bi in range(4): |
|
97 | for bi in range(4): | |
98 | r[ind] = ri/(6-1.0) |
|
98 | r[ind] = ri/(6-1.0) | |
99 | g[ind] = gi/(7-1.0) |
|
99 | g[ind] = gi/(7-1.0) | |
100 | b[ind] = bi/(6-1.0) |
|
100 | b[ind] = bi/(6-1.0) | |
101 | pos[ind] = ind/(ncolor-1.0) |
|
101 | pos[ind] = ind/(ncolor-1.0) | |
102 | ind += 1 |
|
102 | ind += 1 | |
103 | rgb_lvl = [6,7,6] #Levels for RGB colors |
|
103 | rgb_lvl = [6,7,6] #Levels for RGB colors | |
104 |
|
104 | |||
105 | if colormap == 'rgb685': |
|
105 | if colormap == 'rgb685': | |
106 | ncolor = 6*8*5 |
|
106 | ncolor = 6*8*5 | |
107 | pos = numpy.zeros((ncolor)) |
|
107 | pos = numpy.zeros((ncolor)) | |
108 | r = numpy.zeros((ncolor)) |
|
108 | r = numpy.zeros((ncolor)) | |
109 | g = numpy.zeros((ncolor)) |
|
109 | g = numpy.zeros((ncolor)) | |
110 | b = numpy.zeros((ncolor)) |
|
110 | b = numpy.zeros((ncolor)) | |
111 | ind = 0 |
|
111 | ind = 0 | |
112 | for ri in range(8): |
|
112 | for ri in range(8): | |
113 | for gi in range(8): |
|
113 | for gi in range(8): | |
114 | for bi in range(4): |
|
114 | for bi in range(4): | |
115 | r[ind] = ri/(6-1.0) |
|
115 | r[ind] = ri/(6-1.0) | |
116 | g[ind] = gi/(8-1.0) |
|
116 | g[ind] = gi/(8-1.0) | |
117 | b[ind] = bi/(5-1.0) |
|
117 | b[ind] = bi/(5-1.0) | |
118 | pos[ind] = ind/(ncolor-1.0) |
|
118 | pos[ind] = ind/(ncolor-1.0) | |
119 | ind += 1 |
|
119 | ind += 1 | |
120 | rgb_lvl = [6,8,5] #Levels for RGB colors |
|
120 | rgb_lvl = [6,8,5] #Levels for RGB colors | |
121 |
|
121 | |||
122 | if colormap == 'rgb884': |
|
122 | if colormap == 'rgb884': | |
123 | ncolor = 8*8*4 |
|
123 | ncolor = 8*8*4 | |
124 | pos = numpy.zeros((ncolor)) |
|
124 | pos = numpy.zeros((ncolor)) | |
125 | r = numpy.zeros((ncolor)) |
|
125 | r = numpy.zeros((ncolor)) | |
126 | g = numpy.zeros((ncolor)) |
|
126 | g = numpy.zeros((ncolor)) | |
127 | b = numpy.zeros((ncolor)) |
|
127 | b = numpy.zeros((ncolor)) | |
128 | ind = 0 |
|
128 | ind = 0 | |
129 | for ri in range(8): |
|
129 | for ri in range(8): | |
130 | for gi in range(8): |
|
130 | for gi in range(8): | |
131 | for bi in range(4): |
|
131 | for bi in range(4): | |
132 | r[ind] = ri/(8-1.0) |
|
132 | r[ind] = ri/(8-1.0) | |
133 | g[ind] = gi/(8-1.0) |
|
133 | g[ind] = gi/(8-1.0) | |
134 | b[ind] = bi/(4-1.0) |
|
134 | b[ind] = bi/(4-1.0) | |
135 | pos[ind] = ind/(ncolor-1.0) |
|
135 | pos[ind] = ind/(ncolor-1.0) | |
136 | ind += 1 |
|
136 | ind += 1 | |
137 | rgb_lvl = [8,8,4] #Levels for RGB colors |
|
137 | rgb_lvl = [8,8,4] #Levels for RGB colors | |
138 |
|
138 | |||
139 | if ncolor == None: |
|
139 | if ncolor == None: | |
140 | raise ValueError, "The colormap selected is not valid" |
|
140 | raise ValueError, "The colormap selected is not valid" | |
141 |
|
141 | |||
142 | plplot.plscmap1n(ncolor) |
|
142 | plplot.plscmap1n(ncolor) | |
143 | plplot.plscmap1l(1, pos, r, g, b) |
|
143 | plplot.plscmap1l(1, pos, r, g, b) | |
144 |
|
144 | |||
145 | return rgb_lvl |
|
145 | return rgb_lvl | |
146 |
|
146 | |||
147 | class BaseGraph: |
|
147 | class BaseGraph: | |
148 | """ |
|
148 | """ | |
149 |
|
149 | |||
150 | """ |
|
150 | """ | |
151 |
|
151 | |||
152 |
|
152 | |||
153 |
|
153 | |||
154 | def __init__(self): |
|
154 | def __init__(self): | |
155 | """ |
|
155 | """ | |
156 |
|
156 | |||
157 | """ |
|
157 | """ | |
158 | self.hasNotRange = True |
|
158 | self.hasNotRange = True | |
159 |
|
159 | |||
160 | self.xrange = None |
|
160 | self.xrange = None | |
161 | self.yrange = None |
|
161 | self.yrange = None | |
162 | self.zrange = None |
|
162 | self.zrange = None | |
163 |
|
163 | |||
164 | self.xlabel = None |
|
164 | self.xlabel = None | |
165 | self.ylabel = None |
|
165 | self.ylabel = None | |
166 | self.title = None |
|
166 | self.title = None | |
167 |
|
167 | |||
168 | self.legends = None |
|
168 | self.legends = None | |
169 |
|
169 | |||
170 | self.__name = None |
|
170 | self.__name = None | |
171 |
|
171 | |||
172 | self.__colormap = None |
|
172 | self.__colormap = None | |
173 | self.__colbox = None |
|
173 | self.__colbox = None | |
174 | self.__colleg = None |
|
174 | self.__colleg = None | |
175 |
|
175 | |||
176 | self.__xpos = None |
|
176 | self.__xpos = None | |
177 | self.__ypos = None |
|
177 | self.__ypos = None | |
178 |
|
178 | |||
179 | self.__xopt = None #"bcnst" |
|
179 | self.__xopt = None #"bcnst" | |
180 | self.__yopt = None #"bcnstv" |
|
180 | self.__yopt = None #"bcnstv" | |
181 |
|
181 | |||
182 | self.__xlpos = None |
|
182 | self.__xlpos = None | |
183 | self.__ylpos = None |
|
183 | self.__ylpos = None | |
184 |
|
184 | |||
185 | self.__xrangeIsTime = False |
|
185 | self.__xrangeIsTime = False | |
186 |
|
186 | |||
187 | #Advanced |
|
187 | #Advanced | |
188 | self.__xg = None |
|
188 | self.__xg = None | |
189 | self.__yg = None |
|
189 | self.__yg = None | |
190 |
|
190 | |||
191 | def setName(self, name): |
|
191 | def setName(self, name): | |
192 | self.__name = name |
|
192 | self.__name = name | |
193 |
|
193 | |||
194 | def setScreenPos(self, xpos, ypos): |
|
194 | def setScreenPos(self, xpos, ypos): | |
195 | self.__xpos = xpos |
|
195 | self.__xpos = xpos | |
196 | self.__ypos = ypos |
|
196 | self.__ypos = ypos | |
197 |
|
197 | |||
198 | def setOpt(self, xopt, yopt): |
|
198 | def setOpt(self, xopt, yopt): | |
199 | self.__xopt = xopt |
|
199 | self.__xopt = xopt | |
200 | self.__yopt = yopt |
|
200 | self.__yopt = yopt | |
201 |
|
201 | |||
202 | def setXAxisAsTime(self): |
|
202 | def setXAxisAsTime(self): | |
203 | self.__xrangeIsTime = True |
|
203 | self.__xrangeIsTime = True | |
204 |
|
204 | |||
205 |
|
205 | |||
206 | def setup(self, title=None, xlabel=None, ylabel=None, colormap=None): |
|
206 | def setup(self, title=None, xlabel=None, ylabel=None, colormap=None): | |
207 | """ |
|
207 | """ | |
208 | """ |
|
208 | """ | |
209 | self.title = title |
|
209 | self.title = title | |
210 | self.xlabel = xlabel |
|
210 | self.xlabel = xlabel | |
211 | self.ylabel = ylabel |
|
211 | self.ylabel = ylabel | |
212 | self.__colormap = colormap |
|
212 | self.__colormap = colormap | |
213 |
|
213 | |||
214 | def plotBox(self, xmin, xmax, ymin, ymax, xopt=None, yopt=None): |
|
214 | def plotBox(self, xmin, xmax, ymin, ymax, xopt=None, yopt=None, nolabels=False): | |
215 | """ |
|
215 | """ | |
216 |
|
216 | |||
217 | """ |
|
217 | """ | |
218 | if self.__xrangeIsTime: |
|
218 | if self.__xrangeIsTime: | |
219 | plplot.pltimefmt("%H:%M") |
|
219 | plplot.pltimefmt("%H:%M") | |
220 |
|
220 | |||
221 | plplot.plvpor(self.__xpos[0], self.__xpos[1], self.__ypos[0], self.__ypos[1]) |
|
221 | plplot.plvpor(self.__xpos[0], self.__xpos[1], self.__ypos[0], self.__ypos[1]) | |
222 | plplot.plwind(float(xmin), |
|
222 | plplot.plwind(float(xmin), | |
223 | float(xmax), |
|
223 | float(xmax), | |
224 | float(ymin), |
|
224 | float(ymin), | |
225 | float(ymax) |
|
225 | float(ymax) | |
226 | ) |
|
226 | ) | |
227 |
|
227 | |||
228 | if xopt == None: xopt = self.__xopt |
|
228 | if xopt == None: xopt = self.__xopt | |
229 | if yopt == None: yopt = self.__yopt |
|
229 | if yopt == None: yopt = self.__yopt | |
230 |
|
230 | |||
231 | plplot.plbox(xopt, 0.0, 0, yopt, 0.0, 0) |
|
231 | plplot.plbox(xopt, 0.0, 0, yopt, 0.0, 0) | |
232 |
|
232 | |||
233 | plplot.pllab(self.xlabel, self.ylabel, self.title) |
|
233 | if not(nolabels): | |
|
234 | plplot.pllab(self.xlabel, self.ylabel, self.title) | |||
234 |
|
235 | |||
235 |
|
236 | |||
236 | def colorbarPlot(self, xmin=0., xmax=1., ymin=0., ymax=1.): |
|
237 | def colorbarPlot(self, xmin=0., xmax=1., ymin=0., ymax=1.): | |
237 | data = numpy.arange(256) |
|
238 | data = numpy.arange(256) | |
238 | data = numpy.reshape(data, (1,-1)) |
|
239 | data = numpy.reshape(data, (1,-1)) | |
239 |
|
240 | |||
240 | plplot.plimage(data, |
|
241 | plplot.plimage(data, | |
241 | float(xmin), |
|
242 | float(xmin), | |
242 | float(xmax), |
|
243 | float(xmax), | |
243 | float(ymin), |
|
244 | float(ymin), | |
244 | float(ymax), |
|
245 | float(ymax), | |
245 | 0., |
|
246 | 0., | |
246 | 255., |
|
247 | 255., | |
247 | float(xmin), |
|
248 | float(xmin), | |
248 | float(xmax), |
|
249 | float(xmax), | |
249 | float(ymin), |
|
250 | float(ymin), | |
250 | float(ymax)) |
|
251 | float(ymax)) | |
251 |
|
252 | |||
252 | def basicXYPlot(self, x, y, xmin=None, xmax=None, ymin=None, ymax=None): |
|
253 | def basicXYPlot(self, x, y, xmin=None, xmax=None, ymin=None, ymax=None): | |
253 |
|
254 | |||
254 | if xmin == None: xmin = x[0] |
|
255 | if xmin == None: xmin = x[0] | |
255 | if xmax == None: xmax = x[-1] |
|
256 | if xmax == None: xmax = x[-1] | |
256 | if ymin == None: ymin = y[0] |
|
257 | if ymin == None: ymin = y[0] | |
257 | if ymax == None: ymax = y[-1] |
|
258 | if ymax == None: ymax = y[-1] | |
258 |
|
259 | |||
259 | plplot.plline(x, y) |
|
260 | plplot.plline(x, y) | |
260 |
|
261 | |||
261 | def basicXYwithErrorPlot(self): |
|
262 | def basicXYwithErrorPlot(self): | |
262 | pass |
|
263 | pass | |
263 |
|
264 | |||
264 | def basicLineTimePlot(self, x, y, xmin=None, xmax=None, ymin=None, ymax=None, colline=1): |
|
265 | def basicLineTimePlot(self, x, y, xmin=None, xmax=None, ymin=None, ymax=None, colline=1): | |
265 |
|
266 | |||
266 | if xmin == None: xmin = x[0] |
|
267 | if xmin == None: xmin = x[0] | |
267 | if xmax == None: xmax = x[-1] |
|
268 | if xmax == None: xmax = x[-1] | |
268 | if ymin == None: ymin = y[0] |
|
269 | if ymin == None: ymin = y[0] | |
269 | if ymax == None: ymax = y[-1] |
|
270 | if ymax == None: ymax = y[-1] | |
270 |
|
271 | |||
271 | plplot.plcol0(colline) |
|
272 | plplot.plcol0(colline) | |
272 | plplot.plline(x, y) |
|
273 | plplot.plline(x, y) | |
273 | plplot.plcol0(1) |
|
274 | plplot.plcol0(1) | |
274 |
|
275 | |||
275 | def basicPcolorPlot(self, data, x, y, xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None): |
|
276 | def basicPcolorPlot(self, data, x, y, xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None): | |
276 | """ |
|
277 | """ | |
277 | """ |
|
278 | """ | |
278 | if xmin == None: xmin = x[0] |
|
279 | if xmin == None: xmin = x[0] | |
279 | if xmax == None: xmax = x[-1] |
|
280 | if xmax == None: xmax = x[-1] | |
280 | if ymin == None: ymin = y[0] |
|
281 | if ymin == None: ymin = y[0] | |
281 | if ymax == None: ymax = y[-1] |
|
282 | if ymax == None: ymax = y[-1] | |
282 | if zmin == None: zmin = numpy.nanmin(data) |
|
283 | if zmin == None: zmin = numpy.nanmin(data) | |
283 | if zmax == None: zmax = numpy.nanmax(data) |
|
284 | if zmax == None: zmax = numpy.nanmax(data) | |
284 |
|
285 | |||
285 | plplot.plimage(data, |
|
286 | plplot.plimage(data, | |
286 | float(x[0]), |
|
287 | float(x[0]), | |
287 | float(x[-1]), |
|
288 | float(x[-1]), | |
288 | float(y[0]), |
|
289 | float(y[0]), | |
289 | float(y[-1]), |
|
290 | float(y[-1]), | |
290 | float(zmin), |
|
291 | float(zmin), | |
291 | float(zmax), |
|
292 | float(zmax), | |
292 | float(xmin), |
|
293 | float(xmin), | |
293 | float(xmax), |
|
294 | float(xmax), | |
294 | float(ymin), |
|
295 | float(ymin), | |
295 | float(ymax) |
|
296 | float(ymax) | |
296 | ) |
|
297 | ) | |
297 |
|
298 | |||
298 | def __getBoxpltr(self, x, y, deltax=None, deltay=None): |
|
299 | def __getBoxpltr(self, x, y, deltax=None, deltay=None): | |
299 |
|
300 | |||
300 | if not(len(x)>1 and len(y)>1): |
|
301 | if not(len(x)>1 and len(y)>1): | |
301 | raise ValueError, "x axis and y axis are empty" |
|
302 | raise ValueError, "x axis and y axis are empty" | |
302 |
|
303 | |||
303 | if deltax == None: deltax = x[-1] - x[-2] |
|
304 | if deltax == None: deltax = x[-1] - x[-2] | |
304 | if deltay == None: deltay = y[-1] - y[-2] |
|
305 | if deltay == None: deltay = y[-1] - y[-2] | |
305 |
|
306 | |||
306 | x1 = numpy.append(x, x[-1] + deltax) |
|
307 | x1 = numpy.append(x, x[-1] + deltax) | |
307 | y1 = numpy.append(y, y[-1] + deltay) |
|
308 | y1 = numpy.append(y, y[-1] + deltay) | |
308 |
|
309 | |||
309 | xg = (numpy.multiply.outer(x1, numpy.ones(len(y1)))) |
|
310 | xg = (numpy.multiply.outer(x1, numpy.ones(len(y1)))) | |
310 | yg = (numpy.multiply.outer(numpy.ones(len(x1)), y1)) |
|
311 | yg = (numpy.multiply.outer(numpy.ones(len(x1)), y1)) | |
311 |
|
312 | |||
312 | self.__xg = xg |
|
313 | self.__xg = xg | |
313 | self.__yg = yg |
|
314 | self.__yg = yg | |
314 |
|
315 | |||
315 | def advPcolorPlot(self, data, x, y, zmin=0., zmax=0.): |
|
316 | def advPcolorPlot(self, data, x, y, zmin=0., zmax=0.): | |
316 | """ |
|
317 | """ | |
317 | """ |
|
318 | """ | |
318 |
|
319 | |||
319 | if self.__xg == None and self.__yg == None: |
|
320 | if self.__xg == None and self.__yg == None: | |
320 | self.__getBoxpltr(x, y) |
|
321 | self.__getBoxpltr(x, y) | |
321 |
|
322 | |||
322 | plplot.plimagefr(data, x[0], x[-1], y[0], y[-1], 0., 0., zmin, zmax, plplot.pltr2, self.__xg, self.__yg) |
|
323 | plplot.plimagefr(data, x[0], x[-1], y[0], y[-1], 0., 0., zmin, zmax, plplot.pltr2, self.__xg, self.__yg) | |
323 |
|
324 | |||
324 |
|
325 | |||
325 | class LinearPlot(): |
|
326 | class LinearPlot(): | |
326 |
|
327 | |||
327 | __szchar = 1.0 |
|
328 | __szchar = 1.0 | |
328 | __xrange = None |
|
329 | __xrange = None | |
329 | __yrange = None |
|
330 | __yrange = None | |
330 |
|
331 | |||
331 | m_BaseGraph = None |
|
332 | m_BaseGraph = None | |
332 |
|
333 | |||
333 | def __init__(self): |
|
334 | def __init__(self): | |
334 |
|
335 | |||
335 |
|
336 | |||
336 | key = "linearplot" |
|
337 | key = "linearplot" | |
337 | self.m_BaseGraph = BaseGraph() |
|
338 | self.m_BaseGraph = BaseGraph() | |
338 | self.m_BaseGraph.setName(key) |
|
339 | self.m_BaseGraph.setName(key) | |
339 |
|
340 | |||
340 | self.__subpage = 0 |
|
341 | self.__subpage = 0 | |
341 |
|
342 | |||
342 | def setColormap(self, colormap="br_green"): |
|
343 | def setColormap(self, colormap="br_green"): | |
343 |
|
344 | |||
344 | if colormap == None: |
|
345 | if colormap == None: | |
345 | colormap = self.__colormap |
|
346 | colormap = self.__colormap | |
346 |
|
347 | |||
347 | cmap1_init(colormap) |
|
348 | cmap1_init(colormap) | |
348 |
|
349 | |||
349 | def iniSubpage(self): |
|
350 | def iniSubpage(self): | |
350 |
|
351 | |||
351 | if plplot.plgdev() == '': |
|
352 | if plplot.plgdev() == '': | |
352 | raise ValueError, "Plot device has not been initialize" |
|
353 | raise ValueError, "Plot device has not been initialize" | |
353 |
|
354 | |||
354 | plplot.pladv(self.__subpage) |
|
355 | plplot.pladv(self.__subpage) | |
355 | plplot.plschr(0.0, self.__szchar) |
|
356 | plplot.plschr(0.0, self.__szchar) | |
356 |
|
357 | |||
357 | self.setColormap() |
|
358 | self.setColormap() | |
358 |
|
359 | |||
359 | def setScreenPos(self, width='small'): |
|
360 | def setScreenPos(self, width='small'): | |
360 |
|
361 | |||
361 | if width == 'small': |
|
362 | if width == 'small': | |
362 | xi = 0.12; yi = 0.14; xw = 0.78; yw = 0.80 |
|
363 | xi = 0.12; yi = 0.14; xw = 0.78; yw = 0.80 | |
363 |
|
364 | |||
364 | if width == 'medium': |
|
365 | if width == 'medium': | |
365 | xi = 0.07; yi = 0.10; xw = 0.90; yw = 0.60 |
|
366 | xi = 0.07; yi = 0.10; xw = 0.90; yw = 0.60 | |
366 |
|
367 | |||
367 | xf = xi + xw |
|
368 | xf = xi + xw | |
368 | yf = yi + yw |
|
369 | yf = yi + yw | |
369 |
|
370 | |||
370 | self.m_BaseGraph.setScreenPos([xi, xf], [yi, yf]) |
|
371 | self.m_BaseGraph.setScreenPos([xi, xf], [yi, yf]) | |
371 |
|
372 | |||
372 | def setup(self, subpage, title="", xlabel="", ylabel="", XAxisAsTime=False): |
|
373 | def setup(self, subpage, title="", xlabel="", ylabel="", XAxisAsTime=False): | |
373 | """ |
|
374 | """ | |
374 | """ |
|
375 | """ | |
375 |
|
376 | |||
376 | self.m_BaseGraph.setOpt("bcnts","bcntsv") |
|
377 | self.m_BaseGraph.setOpt("bcnts","bcntsv") | |
377 | self.m_BaseGraph.setup(title, |
|
378 | self.m_BaseGraph.setup(title, | |
378 | xlabel, |
|
379 | xlabel, | |
379 | ylabel |
|
380 | ylabel | |
380 | ) |
|
381 | ) | |
381 |
|
382 | |||
382 | self.setScreenPos(width='medium') |
|
383 | self.setScreenPos(width='medium') | |
383 |
|
384 | |||
384 | if XAxisAsTime: |
|
385 | if XAxisAsTime: | |
385 | self.m_BaseGraph.setXAxisAsTime() |
|
386 | self.m_BaseGraph.setXAxisAsTime() | |
386 |
|
387 | |||
387 | self.__subpage = subpage |
|
388 | self.__subpage = subpage | |
388 | # def setRanges(self, xrange, yrange, zrange): |
|
389 | # def setRanges(self, xrange, yrange, zrange): | |
389 | # |
|
390 | # | |
390 | # self.m_BaseGraph.setRanges(xrange, yrange, zrange) |
|
391 | # self.m_BaseGraph.setRanges(xrange, yrange, zrange) | |
391 |
|
392 | |||
392 | def plotData(self, x, y=None, xmin=None, xmax=None, ymin=None, ymax=None, colline=1): |
|
393 | def plotData(self, x, y=None, xmin=None, xmax=None, ymin=None, ymax=None, colline=1): | |
393 | """ |
|
394 | """ | |
394 | Inputs: |
|
395 | Inputs: | |
395 |
|
396 | |||
396 | x : Numpy array of dimension 1 |
|
397 | x : Numpy array of dimension 1 | |
397 | y : Numpy array of dimension 1 |
|
398 | y : Numpy array of dimension 1 | |
398 |
|
399 | |||
399 | """ |
|
400 | """ | |
400 |
|
401 | |||
401 | try: |
|
402 | try: | |
402 | nX = numpy.shape(x) |
|
403 | nX = numpy.shape(x) | |
403 | except: |
|
404 | except: | |
404 | raise ValueError, "x is not a numpy array" |
|
405 | raise ValueError, "x is not a numpy array" | |
405 |
|
406 | |||
406 | if y == None: y = numpy.arange(nX) |
|
407 | if y == None: y = numpy.arange(nX) | |
407 |
|
408 | |||
408 | if xmin == None: xmin = x[0] |
|
409 | if xmin == None: xmin = x[0] | |
409 | if xmax == None: xmax = x[-1] |
|
410 | if xmax == None: xmax = x[-1] | |
410 | if ymin == None: ymin = y[0] |
|
411 | if ymin == None: ymin = y[0] | |
411 | if ymax == None: ymax = y[-1] |
|
412 | if ymax == None: ymax = y[-1] | |
412 |
|
413 | |||
413 | self.m_BaseGraph.plotBox(xmin, xmax, ymin, ymax) |
|
414 | self.m_BaseGraph.plotBox(xmin, xmax, ymin, ymax) | |
414 | self.m_BaseGraph.basicLineTimePlot(x, y, xmin, xmax, ymin, ymax, colline) |
|
415 | self.m_BaseGraph.basicLineTimePlot(x, y, xmin, xmax, ymin, ymax, colline) | |
415 |
|
416 | |||
416 | def plotComplexData(self, x, y, xmin=None, xmax=None, ymin=None, ymax=None, colline=1, type='power'): |
|
417 | def plotComplexData(self, x, y, xmin=None, xmax=None, ymin=None, ymax=None, colline=1, type='power'): | |
417 | """ |
|
418 | """ | |
418 | Inputs: |
|
419 | Inputs: | |
419 |
|
420 | |||
420 | x : Numpy array of dimension 1 |
|
421 | x : Numpy array of dimension 1 | |
421 | y : Complex numpy array of dimension 1 |
|
422 | y : Complex numpy array of dimension 1 | |
422 |
|
423 | |||
423 | """ |
|
424 | """ | |
424 |
|
425 | |||
425 | try: |
|
426 | try: | |
426 | nX = numpy.shape(x) |
|
427 | nX = numpy.shape(x) | |
427 | except: |
|
428 | except: | |
428 | raise ValueError, "x is not a numpy array" |
|
429 | raise ValueError, "x is not a numpy array" | |
429 |
|
430 | |||
430 | try: |
|
431 | try: | |
431 | nY = numpy.shape(y) |
|
432 | nY = numpy.shape(y) | |
432 | except: |
|
433 | except: | |
433 | raise ValueError, "y is not a numpy array" |
|
434 | raise ValueError, "y is not a numpy array" | |
434 |
|
435 | |||
435 | if xmin == None: xmin = x[0] |
|
436 | if xmin == None: xmin = x[0] | |
436 | if xmax == None: xmax = x[-1] |
|
437 | if xmax == None: xmax = x[-1] | |
437 | if ymin == None: ymin = y[0] |
|
438 | if ymin == None: ymin = y[0] | |
438 | if ymax == None: ymax = y[-1] |
|
439 | if ymax == None: ymax = y[-1] | |
439 |
|
440 | |||
440 | self.m_BaseGraph.plotBox(xmin, xmax, ymin, ymax) |
|
441 | self.m_BaseGraph.plotBox(xmin, xmax, ymin, ymax) | |
441 |
|
442 | |||
442 | if type.lower() == 'power': |
|
443 | if type.lower() == 'power': | |
443 | self.m_BaseGraph.basicLineTimePlot(x, abs(y), xmin, xmax, ymin, ymax, colline) |
|
444 | self.m_BaseGraph.basicLineTimePlot(x, abs(y), xmin, xmax, ymin, ymax, colline) | |
444 |
|
445 | |||
445 | if type.lower() == 'iq': |
|
446 | if type.lower() == 'iq': | |
446 |
|
447 | |||
447 | self.m_BaseGraph.basicLineTimePlot(x, y.real, xmin, xmax, ymin, ymax, colline) |
|
448 | self.m_BaseGraph.basicLineTimePlot(x, y.real, xmin, xmax, ymin, ymax, colline) | |
448 | self.m_BaseGraph.basicLineTimePlot(x, y.imag, xmin, xmax, ymin, ymax, colline+1) |
|
449 | self.m_BaseGraph.basicLineTimePlot(x, y.imag, xmin, xmax, ymin, ymax, colline+1) | |
449 |
|
450 | |||
450 | class ColorPlot(): |
|
451 | class ColorPlot(): | |
451 |
|
452 | |||
452 | def __init__(self): |
|
453 | def __init__(self): | |
453 |
|
454 | |||
454 | self.graphObjDict = {} |
|
455 | self.graphObjDict = {} | |
455 |
|
456 | |||
456 | self.__subpage = 0 |
|
457 | self.__subpage = 0 | |
457 | self.__showColorbar = False |
|
458 | self.__showColorbar = False | |
458 | self.__showPowerProfile = True |
|
459 | self.__showPowerProfile = True | |
459 |
|
460 | |||
460 |
self.__szchar = 0. |
|
461 | self.__szchar = 0.65 | |
461 | self.__xrange = None |
|
462 | self.__xrange = None | |
462 | self.__yrange = None |
|
463 | self.__yrange = None | |
463 | self.__zrange = None |
|
464 | self.__zrange = None | |
464 |
|
465 | |||
465 | key = "colorplot" |
|
466 | key = "colorplot" | |
466 | self.m_BaseGraph = BaseGraph() |
|
467 | self.m_BaseGraph = BaseGraph() | |
467 | self.m_BaseGraph.setName(key) |
|
468 | self.m_BaseGraph.setName(key) | |
468 |
|
469 | |||
469 | def setup(self, subpage, title="", xlabel="Frequency", ylabel="Range", colormap="jet", showColorbar=False, showPowerProfile=False, XAxisAsTime=False): |
|
470 | def setup(self, subpage, title="", xlabel="Frequency", ylabel="Range", colormap="jet", showColorbar=False, showPowerProfile=False, XAxisAsTime=False): | |
470 | """ |
|
471 | """ | |
471 | """ |
|
472 | """ | |
472 |
|
473 | |||
473 | self.m_BaseGraph.setOpt("bcnts","bcntsv") |
|
474 | self.m_BaseGraph.setOpt("bcnts","bcntsv") | |
474 | self.m_BaseGraph.setup(title, |
|
475 | self.m_BaseGraph.setup(title, | |
475 | xlabel, |
|
476 | xlabel, | |
476 | ylabel |
|
477 | ylabel | |
477 | ) |
|
478 | ) | |
478 |
|
479 | |||
479 | self.__subpage = subpage |
|
480 | self.__subpage = subpage | |
480 | self.__colormap = colormap |
|
481 | self.__colormap = colormap | |
481 | self.__showColorbar = showColorbar |
|
482 | self.__showColorbar = showColorbar | |
482 | self.__showPowerProfile = showPowerProfile |
|
483 | self.__showPowerProfile = showPowerProfile | |
483 |
|
484 | |||
484 | if showColorbar: |
|
485 | if showColorbar: | |
485 | key = "colorbar" |
|
486 | key = "colorbar" | |
486 |
|
487 | |||
487 | cmapObj = BaseGraph() |
|
488 | cmapObj = BaseGraph() | |
488 | cmapObj.setName(key) |
|
489 | cmapObj.setName(key) | |
489 | cmapObj.setOpt("bc","bcmt") |
|
490 | cmapObj.setOpt("bc","bcmtv") | |
490 | cmapObj.setup(title="dBs", |
|
491 | cmapObj.setup(title="dBs", | |
491 | xlabel="", |
|
492 | xlabel="", | |
492 | ylabel="", |
|
493 | ylabel="", | |
493 | colormap=colormap) |
|
494 | colormap=colormap) | |
494 |
|
495 | |||
495 | self.graphObjDict[key] = cmapObj |
|
496 | self.graphObjDict[key] = cmapObj | |
496 |
|
497 | |||
497 |
|
498 | |||
498 | if showPowerProfile: |
|
499 | if showPowerProfile: | |
499 | key = "powerprof" |
|
500 | key = "powerprof" | |
500 |
|
501 | |||
501 | powObj = BaseGraph() |
|
502 | powObj = BaseGraph() | |
502 | powObj.setName(key) |
|
503 | powObj.setName(key) | |
503 | powObj.setOpt("bcntg","bc") |
|
504 | powObj.setOpt("bcntg","bc") | |
504 | powObj.setup(title="Power Profile", |
|
505 | powObj.setup(title="Power Profile", | |
505 | xlabel="dB", |
|
506 | xlabel="dB", | |
506 | ylabel="") |
|
507 | ylabel="") | |
507 |
|
508 | |||
508 | self.graphObjDict[key] = powObj |
|
509 | self.graphObjDict[key] = powObj | |
509 |
|
510 | |||
510 | self.setScreenPos(width='small') |
|
511 | self.setScreenPos(width='small') | |
511 |
|
512 | |||
512 | if XAxisAsTime: |
|
513 | if XAxisAsTime: | |
513 | self.m_BaseGraph.setXAxisAsTime() |
|
514 | self.m_BaseGraph.setXAxisAsTime() | |
514 |
|
515 | |||
515 |
|
516 | |||
516 |
|
517 | |||
517 | def setColormap(self, colormap="br_green"): |
|
518 | def setColormap(self, colormap="br_green"): | |
518 |
|
519 | |||
519 | if colormap == None: |
|
520 | if colormap == None: | |
520 | colormap = self.__colormap |
|
521 | colormap = self.__colormap | |
521 |
|
522 | |||
522 | cmap1_init(colormap) |
|
523 | cmap1_init(colormap) | |
523 |
|
524 | |||
524 | def iniSubpage(self): |
|
525 | def iniSubpage(self): | |
525 |
|
526 | |||
526 | if plplot.plgdev() == '': |
|
527 | if plplot.plgdev() == '': | |
527 | raise ValueError, "Plot device has not been initialize" |
|
528 | raise ValueError, "Plot device has not been initialize" | |
528 |
|
529 | |||
529 | plplot.pladv(self.__subpage) |
|
530 | plplot.pladv(self.__subpage) | |
530 | plplot.plschr(0.0, self.__szchar) |
|
531 | plplot.plschr(0.0, self.__szchar) | |
531 |
|
532 | |||
532 | self.setColormap() |
|
533 | self.setColormap() | |
533 |
|
534 | |||
534 | def setScreenPos(self, width='small'): |
|
535 | def setScreenPos(self, width='small'): | |
535 |
|
536 | |||
536 | if width == 'small': |
|
537 | if width == 'small': | |
537 |
xi = 0.13; yi = 0.12; xw = 0.86; yw = 0.70; xcmapw = 0.0 |
|
538 | xi = 0.13; yi = 0.12; xw = 0.86; yw = 0.70; xcmapw = 0.04; xpoww = 0.25; deltaxcmap = 0.02; deltaxpow = 0.06 | |
538 |
|
539 | |||
539 | if width == 'medium': |
|
540 | if width == 'medium': | |
540 |
xi = 0.07; yi = 0.10; xw = 0.90; yw = 0.60; xcmapw = 0.0 |
|
541 | xi = 0.07; yi = 0.10; xw = 0.90; yw = 0.60; xcmapw = 0.04; xpoww = 0.24; deltaxcmap = 0.02; deltaxpow = 0.06 | |
541 |
|
542 | |||
542 | if self.__showColorbar: |
|
543 | if self.__showColorbar: | |
543 | xw -= xcmapw + deltaxcmap |
|
544 | xw -= xcmapw + deltaxcmap | |
544 |
|
545 | |||
545 | if self.__showPowerProfile: |
|
546 | if self.__showPowerProfile: | |
546 | xw -= xpoww + deltaxpow |
|
547 | xw -= xpoww + deltaxpow | |
547 |
|
548 | |||
548 | xf = xi + xw |
|
549 | xf = xi + xw | |
549 | yf = yi + yw |
|
550 | yf = yi + yw | |
550 | xcmapf = xf |
|
551 | xcmapf = xf | |
551 |
|
552 | |||
552 | self.m_BaseGraph.setScreenPos([xi, xf], [yi, yf]) |
|
553 | self.m_BaseGraph.setScreenPos([xi, xf], [yi, yf]) | |
553 |
|
554 | |||
554 | if self.__showColorbar: |
|
555 | if self.__showColorbar: | |
555 | xcmapi = xf + deltaxcmap |
|
556 | xcmapi = xf + deltaxcmap | |
556 | xcmapf = xcmapi + xcmapw |
|
557 | xcmapf = xcmapi + xcmapw | |
557 |
|
558 | |||
558 | key = "colorbar" |
|
559 | key = "colorbar" | |
559 | cmapObj = self.graphObjDict[key] |
|
560 | cmapObj = self.graphObjDict[key] | |
560 | cmapObj.setScreenPos([xcmapi, xcmapf], [yi, yf]) |
|
561 | cmapObj.setScreenPos([xcmapi, xcmapf], [yi, yf]) | |
561 |
|
562 | |||
562 | if self.__showPowerProfile: |
|
563 | if self.__showPowerProfile: | |
563 |
|
564 | |||
564 | xpowi = xcmapf + deltaxpow |
|
565 | xpowi = xcmapf + deltaxpow | |
565 | xpowf = xpowi + xpoww |
|
566 | xpowf = xpowi + xpoww | |
566 |
|
567 | |||
567 | key = "powerprof" |
|
568 | key = "powerprof" | |
568 | powObj = self.graphObjDict[key] |
|
569 | powObj = self.graphObjDict[key] | |
569 | powObj.setScreenPos([xpowi, xpowf], [yi, yf]) |
|
570 | powObj.setScreenPos([xpowi, xpowf], [yi, yf]) | |
570 |
|
571 | |||
571 |
|
572 | |||
572 |
|
573 | |||
573 | def plotData(self, data, x=None, y=None, xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None): |
|
574 | def plotData(self, data, x=None, y=None, xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None): | |
574 | """ |
|
575 | """ | |
575 | Inputs: |
|
576 | Inputs: | |
576 |
|
577 | |||
577 | x : Numpy array of dimension 1 |
|
578 | x : Numpy array of dimension 1 | |
578 | y : Numpy array of dimension 1 |
|
579 | y : Numpy array of dimension 1 | |
579 |
|
580 | |||
580 | """ |
|
581 | """ | |
581 |
|
582 | |||
582 | try: |
|
583 | try: | |
583 | nX, nY = numpy.shape(data) |
|
584 | nX, nY = numpy.shape(data) | |
584 | except: |
|
585 | except: | |
585 | raise ValueError, "data is not a numpy array" |
|
586 | raise ValueError, "data is not a numpy array" | |
586 |
|
587 | |||
587 | if x == None: x = numpy.arange(nX) |
|
588 | if x == None: x = numpy.arange(nX) | |
588 | if y == None: y = numpy.arange(nY) |
|
589 | if y == None: y = numpy.arange(nY) | |
589 |
|
590 | |||
590 | if xmin == None: xmin = x[0] |
|
591 | if xmin == None: xmin = x[0] | |
591 | if xmax == None: xmax = x[-1] |
|
592 | if xmax == None: xmax = x[-1] | |
592 | if ymin == None: ymin = y[0] |
|
593 | if ymin == None: ymin = y[0] | |
593 | if ymax == None: ymax = y[-1] |
|
594 | if ymax == None: ymax = y[-1] | |
594 | if zmin == None: zmin = numpy.nanmin(data) |
|
595 | if zmin == None: zmin = numpy.nanmin(data) | |
595 | if zmax == None: zmax = numpy.nanmax(data) |
|
596 | if zmax == None: zmax = numpy.nanmax(data) | |
596 |
|
597 | |||
|
598 | plplot.plschr(0.0, self.__szchar) | |||
|
599 | ||||
597 | self.m_BaseGraph.plotBox(xmin, xmax, ymin, ymax) |
|
600 | self.m_BaseGraph.plotBox(xmin, xmax, ymin, ymax) | |
598 | self.m_BaseGraph.basicPcolorPlot(data, x, y, xmin, xmax, ymin, ymax, zmin, zmax) |
|
601 | self.m_BaseGraph.basicPcolorPlot(data, x, y, xmin, xmax, ymin, ymax, zmin, zmax) | |
599 |
|
602 | |||
600 | if self.__showColorbar: |
|
603 | if self.__showColorbar: | |
|
604 | ||||
|
605 | ||||
601 | key = "colorbar" |
|
606 | key = "colorbar" | |
602 | cmapObj = self.graphObjDict[key] |
|
607 | cmapObj = self.graphObjDict[key] | |
|
608 | ||||
|
609 | plplot.plschr(0.0, self.__szchar-0.05) | |||
603 | cmapObj.plotBox(0., 1., zmin, zmax) |
|
610 | cmapObj.plotBox(0., 1., zmin, zmax) | |
604 | cmapObj.colorbarPlot(0., 1., zmin, zmax) |
|
611 | cmapObj.colorbarPlot(0., 1., zmin, zmax) | |
605 |
|
612 | |||
606 | if self.__showPowerProfile: |
|
613 | if self.__showPowerProfile: | |
607 | power = numpy.max(data, axis=0) |
|
614 | power = numpy.max(data, axis=0) | |
608 |
|
615 | |||
609 | step = (ymax - ymin)/(nY-1) |
|
616 | step = (ymax - ymin)/(nY-1) | |
610 | heis = numpy.arange(ymin, ymax + step, step) |
|
617 | heis = numpy.arange(ymin, ymax + step, step) | |
611 |
|
618 | |||
612 | key = "powerprof" |
|
619 | key = "powerprof" | |
613 | powObj = self.graphObjDict[key] |
|
620 | powObj = self.graphObjDict[key] | |
614 |
|
621 | |||
615 | plplot.pllsty(2) |
|
622 | plplot.pllsty(2) | |
616 | powObj.plotBox(zmin, zmax, ymin, ymax) |
|
623 | plplot.plschr(0.0, self.__szchar-0.05) | |
|
624 | powObj.plotBox(zmin, zmax, ymin, ymax, nolabels=True) | |||
|
625 | ||||
617 | plplot.pllsty(1) |
|
626 | plplot.pllsty(1) | |
|
627 | plplot.plschr(0.0, self.__szchar) | |||
618 | powObj.plotBox(zmin, zmax, ymin, ymax, xopt='bc', yopt='bc') |
|
628 | powObj.plotBox(zmin, zmax, ymin, ymax, xopt='bc', yopt='bc') | |
|
629 | ||||
619 | plplot.plcol0(9) |
|
630 | plplot.plcol0(9) | |
620 | powObj.basicXYPlot(power, heis) |
|
631 | powObj.basicXYPlot(power, heis) | |
621 | plplot.plcol0(1) |
|
632 | plplot.plcol0(1) | |
622 |
|
633 | |||
623 |
|
634 | |||
624 | class ColorPlotX(): |
|
635 | class ColorPlotX(): | |
625 |
|
636 | |||
626 |
|
637 | |||
627 | graphObjDict = {} |
|
638 | graphObjDict = {} | |
628 | showColorbar = False |
|
639 | showColorbar = False | |
629 | showPowerProfile = True |
|
640 | showPowerProfile = True | |
630 |
|
641 | |||
631 | __szchar = 0.7 |
|
642 | __szchar = 0.7 | |
632 | __xrange = None |
|
643 | __xrange = None | |
633 | __yrange = None |
|
644 | __yrange = None | |
634 | __zrange = None |
|
645 | __zrange = None | |
635 |
|
646 | |||
636 | m_BaseGraph = BaseGraph() |
|
647 | m_BaseGraph = BaseGraph() | |
637 |
|
648 | |||
638 | def __init__(self): |
|
649 | def __init__(self): | |
639 |
|
650 | |||
640 | key = "colorplot" |
|
651 | key = "colorplot" | |
641 | self.m_BaseGraph.setName(key) |
|
652 | self.m_BaseGraph.setName(key) | |
642 |
|
653 | |||
643 | self.__subpage = 0 |
|
654 | self.__subpage = 0 | |
644 |
|
655 | |||
645 | self.graphObjDict[key] = self.m_BaseGraph |
|
656 | self.graphObjDict[key] = self.m_BaseGraph | |
646 |
|
657 | |||
647 | def setColormap(self, colormap="br_green"): |
|
658 | def setColormap(self, colormap="br_green"): | |
648 |
|
659 | |||
649 | if colormap == None: |
|
660 | if colormap == None: | |
650 | colormap = self.__colormap |
|
661 | colormap = self.__colormap | |
651 |
|
662 | |||
652 | cmap1_init(colormap) |
|
663 | cmap1_init(colormap) | |
653 |
|
664 | |||
654 | def iniSubpage(self): |
|
665 | def iniSubpage(self): | |
655 |
|
666 | |||
656 | if plplot.plgdev() == '': |
|
667 | if plplot.plgdev() == '': | |
657 | raise ValueError, "Plot device has not been initialize" |
|
668 | raise ValueError, "Plot device has not been initialize" | |
658 |
|
669 | |||
659 | plplot.pladv(self.__subpage) |
|
670 | plplot.pladv(self.__subpage) | |
660 | plplot.plschr(0.0, self.__szchar) |
|
671 | plplot.plschr(0.0, self.__szchar) | |
661 |
|
672 | |||
662 | self.setColormap() |
|
673 | self.setColormap() | |
663 |
|
674 | |||
664 | def setup(self, subpage, title="", xlabel="", ylabel="", colormap="jet", showColorbar=False, showPowerProfile=False, XAxisAsTime=False): |
|
675 | def setup(self, subpage, title="", xlabel="", ylabel="", colormap="jet", showColorbar=False, showPowerProfile=False, XAxisAsTime=False): | |
665 | """ |
|
676 | """ | |
666 | """ |
|
677 | """ | |
667 |
|
678 | |||
668 | self.m_BaseGraph.setSubpage(subpage) |
|
679 | self.m_BaseGraph.setSubpage(subpage) | |
669 | self.m_BaseGraph.setSzchar(self.__szchar) |
|
680 | self.m_BaseGraph.setSzchar(self.__szchar) | |
670 | self.m_BaseGraph.setOpt("bcnts","bcntsv") |
|
681 | self.m_BaseGraph.setOpt("bcnts","bcntsv") | |
671 | self.m_BaseGraph.setup(title, |
|
682 | self.m_BaseGraph.setup(title, | |
672 | xlabel, |
|
683 | xlabel, | |
673 | ylabel, |
|
684 | ylabel, | |
674 | colormap) |
|
685 | colormap) | |
675 |
|
686 | |||
676 | if showColorbar: |
|
687 | if showColorbar: | |
677 | key = "colorbar" |
|
688 | key = "colorbar" | |
678 |
|
689 | |||
679 | cmapObj = BaseGraph() |
|
690 | cmapObj = BaseGraph() | |
680 | cmapObj.setName(key) |
|
691 | cmapObj.setName(key) | |
681 | cmapObj.setSubpage(subpage) |
|
692 | cmapObj.setSubpage(subpage) | |
682 | cmapObj.setSzchar(self.__szchar) |
|
693 | cmapObj.setSzchar(self.__szchar) | |
683 | cmapObj.setOpt("bc","bcmt") |
|
694 | cmapObj.setOpt("bc","bcmt") | |
684 | cmapObj.setup(title="dBs", |
|
695 | cmapObj.setup(title="dBs", | |
685 | xlabel="", |
|
696 | xlabel="", | |
686 | ylabel="", |
|
697 | ylabel="", | |
687 | colormap=colormap) |
|
698 | colormap=colormap) | |
688 |
|
699 | |||
689 | self.graphObjDict[key] = cmapObj |
|
700 | self.graphObjDict[key] = cmapObj | |
690 |
|
701 | |||
691 |
|
702 | |||
692 | if showPowerProfile: |
|
703 | if showPowerProfile: | |
693 | key = "powerprof" |
|
704 | key = "powerprof" | |
694 |
|
705 | |||
695 | powObj = BaseGraph() |
|
706 | powObj = BaseGraph() | |
696 | powObj.setName(key) |
|
707 | powObj.setName(key) | |
697 | powObj.setSubpage(subpage) |
|
708 | powObj.setSubpage(subpage) | |
698 | powObj.setSzchar(self.__szchar) |
|
709 | powObj.setSzchar(self.__szchar) | |
699 | plplot.pllsty(2) |
|
710 | plplot.pllsty(2) | |
700 | powObj.setOpt("bcntg","bc") |
|
711 | powObj.setOpt("bcntg","bc") | |
701 | plplot.pllsty(1) |
|
712 | plplot.pllsty(1) | |
702 | powObj.setup(title="Power Profile", |
|
713 | powObj.setup(title="Power Profile", | |
703 | xlabel="dBs", |
|
714 | xlabel="dBs", | |
704 | ylabel="") |
|
715 | ylabel="") | |
705 |
|
716 | |||
706 | self.graphObjDict[key] = powObj |
|
717 | self.graphObjDict[key] = powObj | |
707 |
|
718 | |||
708 | self.showColorbar = showColorbar |
|
719 | self.showColorbar = showColorbar | |
709 | self.showPowerProfile = showPowerProfile |
|
720 | self.showPowerProfile = showPowerProfile | |
710 | self.setScreenPos() |
|
721 | self.setScreenPos() | |
711 |
|
722 | |||
712 | if XAxisAsTime: |
|
723 | if XAxisAsTime: | |
713 | self.m_BaseGraph.setXAxisAsTime() |
|
724 | self.m_BaseGraph.setXAxisAsTime() | |
714 | #self.setScreenPos(xi = 0.05, yi = 0.18, xw = 0.92, yw = 0.74, xcmapw = 0.015, xpoww = 0.14, deltaxcmap = 0.01, deltaxpow = 0.02) |
|
725 | #self.setScreenPos(xi = 0.05, yi = 0.18, xw = 0.92, yw = 0.74, xcmapw = 0.015, xpoww = 0.14, deltaxcmap = 0.01, deltaxpow = 0.02) | |
715 |
|
726 | |||
716 |
|
727 | |||
717 | def setScreenPos(self, xi = 0.12, yi = 0.14, xw = 0.78, yw = 0.80, xcmapw = 0.05, xpoww = 0.24, deltaxcmap = 0.02, deltaxpow = 0.06): |
|
728 | def setScreenPos(self, xi = 0.12, yi = 0.14, xw = 0.78, yw = 0.80, xcmapw = 0.05, xpoww = 0.24, deltaxcmap = 0.02, deltaxpow = 0.06): | |
718 |
|
729 | |||
719 | if self.showColorbar: |
|
730 | if self.showColorbar: | |
720 | xw -= xcmapw + deltaxcmap |
|
731 | xw -= xcmapw + deltaxcmap | |
721 |
|
732 | |||
722 | if self.showPowerProfile: |
|
733 | if self.showPowerProfile: | |
723 | xw -= xpoww + deltaxpow |
|
734 | xw -= xpoww + deltaxpow | |
724 |
|
735 | |||
725 | xf = xi + xw |
|
736 | xf = xi + xw | |
726 | yf = yi + yw |
|
737 | yf = yi + yw | |
727 | xcmapf = xf |
|
738 | xcmapf = xf | |
728 |
|
739 | |||
729 | self.m_BaseGraph.setScreenPos([xi, xf], [yi, yf]) |
|
740 | self.m_BaseGraph.setScreenPos([xi, xf], [yi, yf]) | |
730 |
|
741 | |||
731 | if self.showColorbar: |
|
742 | if self.showColorbar: | |
732 | xcmapi = xf + deltaxcmap |
|
743 | xcmapi = xf + deltaxcmap | |
733 | xcmapf = xcmapi + xcmapw |
|
744 | xcmapf = xcmapi + xcmapw | |
734 |
|
745 | |||
735 | key = "colorbar" |
|
746 | key = "colorbar" | |
736 | cmapObj = self.graphObjDict[key] |
|
747 | cmapObj = self.graphObjDict[key] | |
737 | cmapObj.setScreenPos([xcmapi, xcmapf], [yi, yf]) |
|
748 | cmapObj.setScreenPos([xcmapi, xcmapf], [yi, yf]) | |
738 |
|
749 | |||
739 | if self.showPowerProfile: |
|
750 | if self.showPowerProfile: | |
740 |
|
751 | |||
741 | xpowi = xcmapf + deltaxpow |
|
752 | xpowi = xcmapf + deltaxpow | |
742 | xpowf = xpowi + xpoww |
|
753 | xpowf = xpowi + xpoww | |
743 |
|
754 | |||
744 | key = "powerprof" |
|
755 | key = "powerprof" | |
745 | powObj = self.graphObjDict[key] |
|
756 | powObj = self.graphObjDict[key] | |
746 | powObj.setScreenPos([xpowi, xpowf], [yi, yf]) |
|
757 | powObj.setScreenPos([xpowi, xpowf], [yi, yf]) | |
747 |
|
758 | |||
748 | def setRanges(self, xrange, yrange, zrange): |
|
759 | def setRanges(self, xrange, yrange, zrange): | |
749 |
|
760 | |||
750 | self.m_BaseGraph.setRanges(xrange, yrange, zrange) |
|
761 | self.m_BaseGraph.setRanges(xrange, yrange, zrange) | |
751 |
|
762 | |||
752 | keyList = self.graphObjDict.keys() |
|
763 | keyList = self.graphObjDict.keys() | |
753 |
|
764 | |||
754 | key = "colorbar" |
|
765 | key = "colorbar" | |
755 | if key in keyList: |
|
766 | if key in keyList: | |
756 | cmapObj = self.graphObjDict[key] |
|
767 | cmapObj = self.graphObjDict[key] | |
757 | cmapObj.setRanges([0., 1.], zrange) |
|
768 | cmapObj.setRanges([0., 1.], zrange) | |
758 |
|
769 | |||
759 | key = "powerprof" |
|
770 | key = "powerprof" | |
760 | if key in keyList: |
|
771 | if key in keyList: | |
761 | powObj = self.graphObjDict[key] |
|
772 | powObj = self.graphObjDict[key] | |
762 | powObj.setRanges(zrange, yrange) |
|
773 | powObj.setRanges(zrange, yrange) | |
763 |
|
774 | |||
764 | def plotData(self, data, x=None, y=None, xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None): |
|
775 | def plotData(self, data, x=None, y=None, xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None): | |
765 | """ |
|
776 | """ | |
766 | """ |
|
777 | """ | |
767 |
|
778 | |||
768 | try: |
|
779 | try: | |
769 | nX, nY = numpy.shape(data) |
|
780 | nX, nY = numpy.shape(data) | |
770 | except: |
|
781 | except: | |
771 | raise ValueError, "data is not a numpy array" |
|
782 | raise ValueError, "data is not a numpy array" | |
772 |
|
783 | |||
773 | if x == None: x = numpy.arange(nX) |
|
784 | if x == None: x = numpy.arange(nX) | |
774 | if y == None: y = numpy.arange(nY) |
|
785 | if y == None: y = numpy.arange(nY) | |
775 |
|
786 | |||
776 | if xmin == None: xmin = x[0] |
|
787 | if xmin == None: xmin = x[0] | |
777 | if xmax == None: xmax = x[-1] |
|
788 | if xmax == None: xmax = x[-1] | |
778 | if ymin == None: ymin = y[0] |
|
789 | if ymin == None: ymin = y[0] | |
779 | if ymax == None: ymax = y[-1] |
|
790 | if ymax == None: ymax = y[-1] | |
780 | if zmin == None: zmin = numpy.nanmin(data) |
|
791 | if zmin == None: zmin = numpy.nanmin(data) | |
781 | if zmax == None: zmax = numpy.nanmax(data) |
|
792 | if zmax == None: zmax = numpy.nanmax(data) | |
782 |
|
793 | |||
783 | if self.m_BaseGraph.hasNotRange: |
|
794 | if self.m_BaseGraph.hasNotRange: | |
784 | self.setRanges([xmin, xmax], [ymin,ymax], [zmin,zmax]) |
|
795 | self.setRanges([xmin, xmax], [ymin,ymax], [zmin,zmax]) | |
785 |
|
796 | |||
786 | self.m_BaseGraph.initSubpage() |
|
797 | self.m_BaseGraph.initSubpage() | |
787 | self.m_BaseGraph.basicPcolorPlot(data, x, y, xmin, xmax, ymin, ymax, self.m_BaseGraph.zrange[0], self.m_BaseGraph.zrange[1]) |
|
798 | self.m_BaseGraph.basicPcolorPlot(data, x, y, xmin, xmax, ymin, ymax, self.m_BaseGraph.zrange[0], self.m_BaseGraph.zrange[1]) | |
788 |
|
799 | |||
789 | if self.showColorbar: |
|
800 | if self.showColorbar: | |
790 | key = "colorbar" |
|
801 | key = "colorbar" | |
791 | cmapObj = self.graphObjDict[key] |
|
802 | cmapObj = self.graphObjDict[key] | |
792 | cmapObj.colorbarPlot() |
|
803 | cmapObj.colorbarPlot() | |
793 |
|
804 | |||
794 | if self.showPowerProfile: |
|
805 | if self.showPowerProfile: | |
795 | power = numpy.average(data, axis=1) |
|
806 | power = numpy.average(data, axis=1) | |
796 |
|
807 | |||
797 | step = (ymax - ymin)/(nY-1) |
|
808 | step = (ymax - ymin)/(nY-1) | |
798 | heis = numpy.arange(ymin, ymax + step, step) |
|
809 | heis = numpy.arange(ymin, ymax + step, step) | |
799 |
|
810 | |||
800 | key = "powerprof" |
|
811 | key = "powerprof" | |
801 | powObj = self.graphObjDict[key] |
|
812 | powObj = self.graphObjDict[key] | |
802 | powObj.basicXYPlot(power, heis) |
|
813 | powObj.basicXYPlot(power, heis) | |
803 |
|
814 | |||
804 | if __name__ == '__main__': |
|
815 | if __name__ == '__main__': | |
805 |
|
816 | |||
806 | import numpy |
|
817 | import numpy | |
807 | plplot.plsetopt("geometry", "%dx%d" %(350*2, 300*2)) |
|
818 | plplot.plsetopt("geometry", "%dx%d" %(350*2, 300*2)) | |
808 | plplot.plsdev("xwin") |
|
819 | plplot.plsdev("xwin") | |
809 | plplot.plscolbg(255,255,255) |
|
820 | plplot.plscolbg(255,255,255) | |
810 | plplot.plscol0(1,0,0,0) |
|
821 | plplot.plscol0(1,0,0,0) | |
811 | plplot.plspause(False) |
|
822 | plplot.plspause(False) | |
812 | plplot.plinit() |
|
823 | plplot.plinit() | |
813 | plplot.plssub(2, 2) |
|
824 | plplot.plssub(2, 2) | |
814 |
|
825 | |||
815 | nx = 64 |
|
826 | nx = 64 | |
816 | ny = 100 |
|
827 | ny = 100 | |
817 |
|
828 | |||
818 | data = numpy.random.uniform(-50,50,(nx,ny)) |
|
829 | data = numpy.random.uniform(-50,50,(nx,ny)) | |
819 |
|
830 | |||
820 | baseObj = ColorPlot() |
|
831 | baseObj = ColorPlot() | |
821 | specObj = ColorPlot() |
|
832 | specObj = ColorPlot() | |
822 | baseObj1 = ColorPlot() |
|
833 | baseObj1 = ColorPlot() | |
823 | specObj1 = ColorPlot() |
|
834 | specObj1 = ColorPlot() | |
824 |
|
835 | |||
825 | baseObj.setup(1, "Spectrum", "Frequency", "Range", "br_green", True, True) |
|
836 | baseObj.setup(1, "Spectrum", "Frequency", "Range", "br_green", True, True) | |
826 | specObj.setup(2, "Spectrum", "Frequency", "Range", "br_green", False, True) |
|
837 | specObj.setup(2, "Spectrum", "Frequency", "Range", "br_green", False, True) | |
827 |
|
838 | |||
828 | baseObj1.setup(3, "Spectrum", "Frequency", "Range", "br_green", False, True) |
|
839 | baseObj1.setup(3, "Spectrum", "Frequency", "Range", "br_green", False, True) | |
829 | specObj1.setup(4, "Spectrum", "Frequency", "Range", "br_green", False, True) |
|
840 | specObj1.setup(4, "Spectrum", "Frequency", "Range", "br_green", False, True) | |
830 |
|
841 | |||
831 | data = numpy.random.uniform(-50,50,(nx,ny)) |
|
842 | data = numpy.random.uniform(-50,50,(nx,ny)) | |
832 |
|
843 | |||
833 | plplot.plbop() |
|
844 | plplot.plbop() | |
834 | baseObj.iniSubpage() |
|
845 | baseObj.iniSubpage() | |
835 | baseObj.plotData(data) |
|
846 | baseObj.plotData(data) | |
836 |
|
847 | |||
837 | specObj.iniSubpage() |
|
848 | specObj.iniSubpage() | |
838 | specObj.plotData(data) |
|
849 | specObj.plotData(data) | |
839 |
|
850 | |||
840 | baseObj1.iniSubpage() |
|
851 | baseObj1.iniSubpage() | |
841 | baseObj1.plotData(data) |
|
852 | baseObj1.plotData(data) | |
842 |
|
853 | |||
843 | specObj1.iniSubpage() |
|
854 | specObj1.iniSubpage() | |
844 | specObj1.plotData(data) |
|
855 | specObj1.plotData(data) | |
845 |
|
856 | |||
846 | plplot.plflush() |
|
857 | plplot.plflush() | |
847 |
|
858 | |||
848 | plplot.plspause(1) |
|
859 | plplot.plspause(1) | |
849 | plplot.plend() |
|
860 | plplot.plend() | |
850 | exit(0) |
|
861 | exit(0) | |
851 |
|
862 | |||
852 |
|
863 |
@@ -1,156 +1,168 | |||||
1 | ''' |
|
1 | ''' | |
2 | Created on Feb 7, 2012 |
|
2 | Created on Feb 7, 2012 | |
3 |
|
3 | |||
4 | @author $Author$ |
|
4 | @author $Author$ | |
5 | @version $Id$ |
|
5 | @version $Id$ | |
6 | ''' |
|
6 | ''' | |
7 |
|
7 | |||
8 | import os, sys |
|
8 | import os, sys | |
9 | import numpy |
|
9 | import numpy | |
|
10 | import datetime | |||
10 | import plplot |
|
11 | import plplot | |
11 |
|
12 | |||
12 | path = os.path.split(os.getcwd())[0] |
|
13 | path = os.path.split(os.getcwd())[0] | |
13 | sys.path.append(path) |
|
14 | sys.path.append(path) | |
14 |
|
15 | |||
15 | from Graphics.BaseGraph import * |
|
16 | from Graphics.BaseGraph import * | |
16 | from Model.Spectra import Spectra |
|
17 | from Model.Spectra import Spectra | |
17 |
|
18 | |||
18 | class Spectrum(): |
|
19 | class Spectrum(): | |
19 |
|
20 | |||
20 | def __init__(self, Spectra): |
|
21 | def __init__(self, Spectra): | |
21 |
|
22 | |||
22 | """ |
|
23 | """ | |
23 |
|
24 | |||
24 | Inputs: |
|
25 | Inputs: | |
25 |
|
26 | |||
26 | type: "power" ->> Potencia |
|
27 | type: "power" ->> Potencia | |
27 | "iq" ->> Real + Imaginario |
|
28 | "iq" ->> Real + Imaginario | |
28 | """ |
|
29 | """ | |
29 |
|
30 | |||
30 | self.__isPlotConfig = False |
|
31 | self.__isPlotConfig = False | |
31 |
|
32 | |||
32 | self.__isPlotIni = False |
|
33 | self.__isPlotIni = False | |
33 |
|
34 | |||
34 | self.__xrange = None |
|
35 | self.__xrange = None | |
35 |
|
36 | |||
36 | self.__yrange = None |
|
37 | self.__yrange = None | |
37 |
|
38 | |||
38 | self.nGraphs = 0 |
|
39 | self.nGraphs = 0 | |
39 |
|
40 | |||
40 | self.graphObjList = [] |
|
41 | self.graphObjList = [] | |
41 |
|
42 | |||
42 | self.m_Spectra = Spectra |
|
43 | self.m_Spectra = Spectra | |
43 |
|
44 | |||
44 |
|
45 | |||
45 | def __addGraph(self, subpage, title="", xlabel="", ylabel="", showColorbar=False, showPowerProfile=True, XAxisAsTime=False): |
|
46 | def __addGraph(self, subpage, title="", xlabel="", ylabel="", showColorbar=False, showPowerProfile=True, XAxisAsTime=False): | |
46 |
|
47 | |||
47 | graphObj = ColorPlot() |
|
48 | graphObj = ColorPlot() | |
48 | graphObj.setup(subpage, |
|
49 | graphObj.setup(subpage, | |
49 | title, |
|
50 | title, | |
50 | xlabel, |
|
51 | xlabel, | |
51 | ylabel, |
|
52 | ylabel, | |
52 | showColorbar=showColorbar, |
|
53 | showColorbar=showColorbar, | |
53 | showPowerProfile=showPowerProfile, |
|
54 | showPowerProfile=showPowerProfile, | |
54 | XAxisAsTime=XAxisAsTime) |
|
55 | XAxisAsTime=XAxisAsTime) | |
55 |
|
56 | |||
56 | self.graphObjList.append(graphObj) |
|
57 | self.graphObjList.append(graphObj) | |
57 |
|
58 | |||
58 |
|
59 | |||
59 | def setup(self, titleList=None, xlabelList=None, ylabelList=None, showColorbar=False, showPowerProfile=True, XAxisAsTime=False): |
|
60 | def setup(self, titleList=None, xlabelList=None, ylabelList=None, showColorbar=False, showPowerProfile=True, XAxisAsTime=False): | |
60 |
|
61 | |||
61 | nChan = int(self.m_Spectra.m_SystemHeader.numChannels) |
|
62 | nChan = int(self.m_Spectra.m_SystemHeader.numChannels) | |
62 | channels = range(nChan) |
|
63 | channels = range(nChan) | |
63 |
|
64 | |||
64 | myXlabel = "Radial Velocity (m/s)" |
|
65 | myXlabel = "Radial Velocity (m/s)" | |
65 | myYlabel = "Range (km)" |
|
66 | myYlabel = "Range (km)" | |
66 |
|
67 | |||
67 | for i in channels: |
|
68 | for i in channels: | |
68 | if titleList != None: |
|
69 | if titleList != None: | |
69 | myTitle = titleList[i] |
|
70 | myTitle = titleList[i] | |
70 | myXlabel = xlabelList[i] |
|
71 | myXlabel = xlabelList[i] | |
71 | myYlabel = ylabelList[i] |
|
72 | myYlabel = ylabelList[i] | |
72 |
|
73 | |||
73 | if self.m_Spectra.noise != None: |
|
74 | if self.m_Spectra.noise != None: | |
74 | noise = '%4.2fdB' %(self.m_Spectra.noise[i]) |
|
75 | noise = '%4.2fdB' %(self.m_Spectra.noise[i]) | |
75 | else: |
|
76 | else: | |
76 | noise = '--' |
|
77 | noise = '--' | |
77 |
|
78 | |||
78 | myTitle = "Channel: %d - Noise: %s" %(i, noise) |
|
79 | myTitle = "Channel: %d - Noise: %s" %(i, noise) | |
79 |
|
80 | |||
80 | self.__addGraph(i+1, |
|
81 | self.__addGraph(i+1, | |
81 | title=myTitle, |
|
82 | title=myTitle, | |
82 | xlabel=myXlabel, |
|
83 | xlabel=myXlabel, | |
83 | ylabel=myYlabel, |
|
84 | ylabel=myYlabel, | |
84 | showColorbar=showColorbar, |
|
85 | showColorbar=showColorbar, | |
85 | showPowerProfile=showPowerProfile, |
|
86 | showPowerProfile=showPowerProfile, | |
86 | XAxisAsTime=XAxisAsTime) |
|
87 | XAxisAsTime=XAxisAsTime) | |
87 |
|
88 | |||
88 | self.nGraphs = nChan |
|
89 | self.nGraphs = nChan | |
89 | self.__isPlotConfig = True |
|
90 | self.__isPlotConfig = True | |
90 |
|
91 | |||
91 | def iniPlot(self): |
|
92 | def iniPlot(self): | |
92 |
|
93 | |||
93 | nx = int(numpy.sqrt(self.nGraphs)+1) |
|
94 | nx = int(numpy.sqrt(self.nGraphs)+1) | |
94 | #ny = int(self.nGraphs/nx) |
|
95 | #ny = int(self.nGraphs/nx) | |
95 |
|
96 | |||
96 | plplot.plsetopt("geometry", "%dx%d" %(300*nx, 240*nx)) |
|
97 | plplot.plsetopt("geometry", "%dx%d" %(300*nx, 240*nx)) | |
97 | plplot.plsdev("xcairo") |
|
98 | plplot.plsdev("xcairo") | |
98 | plplot.plscolbg(255,255,255) |
|
99 | plplot.plscolbg(255,255,255) | |
99 | plplot.plscol0(1,0,0,0) |
|
100 | plplot.plscol0(1,0,0,0) | |
100 | plplot.plinit() |
|
101 | plplot.plinit() | |
101 | plplot.plspause(False) |
|
102 | plplot.plspause(False) | |
102 | plplot.pladv(0) |
|
103 | plplot.pladv(0) | |
103 | plplot.plssub(nx, nx) |
|
104 | plplot.plssub(nx, nx) | |
104 |
|
105 | |||
105 |
self.__ |
|
106 | self.__nx = nx | |
|
107 | self.__ny = nx | |||
|
108 | self.__isPlotIni = True | |||
|
109 | ||||
106 |
|
110 | |||
107 | def plotData(self, xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, titleList=None, xlabelList=None, ylabelList=None, showColorbar=False, showPowerProfile=True, XAxisAsTime=False): |
|
111 | def plotData(self, xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, titleList=None, xlabelList=None, ylabelList=None, showColorbar=False, showPowerProfile=True, XAxisAsTime=False): | |
108 |
|
112 | |||
109 | if not(self.__isPlotConfig): |
|
113 | if not(self.__isPlotConfig): | |
110 | self.setup(titleList, |
|
114 | self.setup(titleList, | |
111 | xlabelList, |
|
115 | xlabelList, | |
112 | ylabelList, |
|
116 | ylabelList, | |
113 | showColorbar, |
|
117 | showColorbar, | |
114 | showPowerProfile, |
|
118 | showPowerProfile, | |
115 | XAxisAsTime) |
|
119 | XAxisAsTime) | |
116 |
|
120 | |||
117 | if not(self.__isPlotIni): |
|
121 | if not(self.__isPlotIni): | |
118 | self.iniPlot() |
|
122 | self.iniPlot() | |
119 |
|
123 | |||
120 | data = 10.*numpy.log10(self.m_Spectra.data_spc) |
|
124 | data = 10.*numpy.log10(self.m_Spectra.data_spc) | |
121 |
|
125 | |||
122 | nX, nY, nChan = numpy.shape(data) |
|
126 | nX, nY, nChan = numpy.shape(data) | |
123 |
|
127 | |||
124 | x = numpy.arange(nX) |
|
128 | x = numpy.arange(nX) | |
125 | y = self.m_Spectra.heights |
|
129 | y = self.m_Spectra.heights | |
126 |
|
130 | |||
|
131 | thisDatetime = datetime.datetime.fromtimestamp(self.m_Spectra.m_BasicHeader.utc) | |||
|
132 | txtDate = "Self Spectra - Date: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |||
|
133 | ||||
127 | if xmin == None: xmin = x[0] |
|
134 | if xmin == None: xmin = x[0] | |
128 | if xmax == None: xmax = x[-1] |
|
135 | if xmax == None: xmax = x[-1] | |
129 | if ymin == None: ymin = y[0] |
|
136 | if ymin == None: ymin = y[0] | |
130 | if ymax == None: ymax = y[-1] |
|
137 | if ymax == None: ymax = y[-1] | |
131 | if zmin == None: zmin = numpy.nanmin(abs(data)) |
|
138 | if zmin == None: zmin = numpy.nanmin(abs(data)) | |
132 | if zmax == None: zmax = numpy.nanmax(abs(data)) |
|
139 | if zmax == None: zmax = numpy.nanmax(abs(data)) | |
133 |
|
140 | |||
134 | plplot.plbop() |
|
141 | plplot.plbop() | |
|
142 | ||||
|
143 | plplot.plssub(self.__nx, self.__ny) | |||
135 | for i in range(self.nGraphs): |
|
144 | for i in range(self.nGraphs): | |
136 | self.graphObjList[i].iniSubpage() |
|
145 | self.graphObjList[i].iniSubpage() | |
137 | self.graphObjList[i].plotData(data[i,:,:], |
|
146 | self.graphObjList[i].plotData(data[i,:,:], | |
138 | x, |
|
147 | x, | |
139 | y, |
|
148 | y, | |
140 | xmin=xmin, |
|
149 | xmin=xmin, | |
141 | xmax=xmax, |
|
150 | xmax=xmax, | |
142 | ymin=ymin, |
|
151 | ymin=ymin, | |
143 | ymax=ymax, |
|
152 | ymax=ymax, | |
144 | zmin=zmin, |
|
153 | zmin=zmin, | |
145 | zmax=zmax) |
|
154 | zmax=zmax) | |
146 |
|
||||
147 |
|
155 | |||
|
156 | plplot.plssub(1,0) | |||
|
157 | plplot.pladv(0) | |||
|
158 | plplot.plvpor(0., 1., 0., 1.) | |||
|
159 | plplot.plmtex("t",-1., 0.5, 0.5, txtDate) | |||
148 | plplot.plflush() |
|
160 | plplot.plflush() | |
149 | plplot.pleop() |
|
161 | plplot.pleop() | |
150 |
|
162 | |||
151 | def end(self): |
|
163 | def end(self): | |
152 | plplot.plend() |
|
164 | plplot.plend() | |
153 |
|
165 | |||
154 |
|
166 | |||
155 | if __name__ == '__main__': |
|
167 | if __name__ == '__main__': | |
156 | pass No newline at end of file |
|
168 | pass |
General Comments 0
You need to be logged in to leave comments.
Login now