This diff has been collapsed as it changes many lines, (710 lines changed) Show them Hide them | |||
@@ -1,355 +1,355 | |||
|
1 | import numpy | |
|
2 | import plplot | |
|
3 | ||
|
4 | def cmap1_init(colormap="gray"): | |
|
5 | ||
|
6 | ncolor = None | |
|
7 | rgb_lvl = None | |
|
8 | ||
|
9 | # Routine for defining a specific color map 1 in HLS space. | |
|
10 | # if gray is true, use basic grayscale variation from half-dark to light. | |
|
11 | # otherwise use false color variation from blue (240 deg) to red (360 deg). | |
|
12 | ||
|
13 | # Independent variable of control points. | |
|
14 | i = numpy.array((0., 1.)) | |
|
15 | if colormap=="gray": | |
|
16 | ncolor = 256 | |
|
17 | # Hue for control points. Doesn't matter since saturation is zero. | |
|
18 | h = numpy.array((0., 0.)) | |
|
19 | # Lightness ranging from half-dark (for interest) to light. | |
|
20 | l = numpy.array((0.5, 1.)) | |
|
21 | # Gray scale has zero saturation | |
|
22 | s = numpy.array((0., 0.)) | |
|
23 | ||
|
24 | # number of cmap1 colours is 256 in this case. | |
|
25 | plplot.plscmap1n(ncolor) | |
|
26 | # Interpolate between control points to set up cmap1. | |
|
27 | plplot.plscmap1l(0, i, h, l, s) | |
|
28 | ||
|
29 | return None | |
|
30 | ||
|
31 | if colormap=="br_green": | |
|
32 | ncolor = 256 | |
|
33 | # Hue ranges from blue (240 deg) to red (0 or 360 deg) | |
|
34 | h = numpy.array((240., 0.)) | |
|
35 | # Lightness and saturation are constant (values taken from C example). | |
|
36 | l = numpy.array((0.6, 0.6)) | |
|
37 | s = numpy.array((0.8, 0.8)) | |
|
38 | ||
|
39 | # number of cmap1 colours is 256 in this case. | |
|
40 | plplot.plscmap1n(ncolor) | |
|
41 | # Interpolate between control points to set up cmap1. | |
|
42 | plplot.plscmap1l(0, i, h, l, s) | |
|
43 | ||
|
44 | return None | |
|
45 | ||
|
46 | if colormap=="tricolor": | |
|
47 | ncolor = 3 | |
|
48 | # Hue ranges from blue (240 deg) to red (0 or 360 deg) | |
|
49 | h = numpy.array((240., 0.)) | |
|
50 | # Lightness and saturation are constant (values taken from C example). | |
|
51 | l = numpy.array((0.6, 0.6)) | |
|
52 | s = numpy.array((0.8, 0.8)) | |
|
53 | ||
|
54 | # number of cmap1 colours is 256 in this case. | |
|
55 | plplot.plscmap1n(ncolor) | |
|
56 | # Interpolate between control points to set up cmap1. | |
|
57 | plplot.plscmap1l(0, i, h, l, s) | |
|
58 | ||
|
59 | return None | |
|
60 | ||
|
61 | if colormap == 'rgb' or colormap == 'rgb666': | |
|
62 | ||
|
63 | color_sz = 6 | |
|
64 | ncolor = color_sz*color_sz*color_sz | |
|
65 | pos = numpy.zeros((ncolor)) | |
|
66 | r = numpy.zeros((ncolor)) | |
|
67 | g = numpy.zeros((ncolor)) | |
|
68 | b = numpy.zeros((ncolor)) | |
|
69 | ind = 0 | |
|
70 | for ri in range(color_sz): | |
|
71 | for gi in range(color_sz): | |
|
72 | for bi in range(color_sz): | |
|
73 | r[ind] = ri/(color_sz-1.0) | |
|
74 | g[ind] = gi/(color_sz-1.0) | |
|
75 | b[ind] = bi/(color_sz-1.0) | |
|
76 | pos[ind] = ind/(ncolor-1.0) | |
|
77 | ind += 1 | |
|
78 | rgb_lvl = [6,6,6] #Levels for RGB colors | |
|
79 | ||
|
80 | if colormap == 'rgb676': | |
|
81 | ncolor = 6*7*6 | |
|
82 | pos = numpy.zeros((ncolor)) | |
|
83 | r = numpy.zeros((ncolor)) | |
|
84 | g = numpy.zeros((ncolor)) | |
|
85 | b = numpy.zeros((ncolor)) | |
|
86 | ind = 0 | |
|
87 | for ri in range(8): | |
|
88 | for gi in range(8): | |
|
89 | for bi in range(4): | |
|
90 | r[ind] = ri/(6-1.0) | |
|
91 | g[ind] = gi/(7-1.0) | |
|
92 | b[ind] = bi/(6-1.0) | |
|
93 | pos[ind] = ind/(ncolor-1.0) | |
|
94 | ind += 1 | |
|
95 | rgb_lvl = [6,7,6] #Levels for RGB colors | |
|
96 | ||
|
97 | if colormap == 'rgb685': | |
|
98 | ncolor = 6*8*5 | |
|
99 | pos = numpy.zeros((ncolor)) | |
|
100 | r = numpy.zeros((ncolor)) | |
|
101 | g = numpy.zeros((ncolor)) | |
|
102 | b = numpy.zeros((ncolor)) | |
|
103 | ind = 0 | |
|
104 | for ri in range(8): | |
|
105 | for gi in range(8): | |
|
106 | for bi in range(4): | |
|
107 | r[ind] = ri/(6-1.0) | |
|
108 | g[ind] = gi/(8-1.0) | |
|
109 | b[ind] = bi/(5-1.0) | |
|
110 | pos[ind] = ind/(ncolor-1.0) | |
|
111 | ind += 1 | |
|
112 | rgb_lvl = [6,8,5] #Levels for RGB colors | |
|
113 | ||
|
114 | if colormap == 'rgb884': | |
|
115 | ncolor = 8*8*4 | |
|
116 | pos = numpy.zeros((ncolor)) | |
|
117 | r = numpy.zeros((ncolor)) | |
|
118 | g = numpy.zeros((ncolor)) | |
|
119 | b = numpy.zeros((ncolor)) | |
|
120 | ind = 0 | |
|
121 | for ri in range(8): | |
|
122 | for gi in range(8): | |
|
123 | for bi in range(4): | |
|
124 | r[ind] = ri/(8-1.0) | |
|
125 | g[ind] = gi/(8-1.0) | |
|
126 | b[ind] = bi/(4-1.0) | |
|
127 | pos[ind] = ind/(ncolor-1.0) | |
|
128 | ind += 1 | |
|
129 | rgb_lvl = [8,8,4] #Levels for RGB colors | |
|
130 | ||
|
131 | if ncolor == None: | |
|
132 | raise ValueError, "The colormap selected is not valid" | |
|
133 | ||
|
134 | plplot.plscmap1n(ncolor) | |
|
135 | plplot.plscmap1l(1, pos, r, g, b) | |
|
136 | ||
|
137 | return rgb_lvl | |
|
138 | ||
|
139 | class BasicGraph: | |
|
140 | """ | |
|
141 | ||
|
142 | """ | |
|
143 | ||
|
144 | hasRange = False | |
|
145 | ||
|
146 | xrange = None | |
|
147 | yrange = None | |
|
148 | zrange = None | |
|
149 | ||
|
150 | xlabel = None | |
|
151 | ylabel = None | |
|
152 | title = None | |
|
153 | ||
|
154 | legends = None | |
|
155 | ||
|
156 | __name = None | |
|
157 | __subpage = None | |
|
158 | __szchar = None | |
|
159 | ||
|
160 | __colormap = None | |
|
161 | __colbox = None | |
|
162 | __colleg = None | |
|
163 | ||
|
164 | __xpos = None | |
|
165 | __ypos = None | |
|
166 | ||
|
167 | __xopt = None #"bcnst" | |
|
168 | __yopt = None #"bcnstv" | |
|
169 | ||
|
170 | __xlpos = None | |
|
171 | __ylpos = None | |
|
172 | ||
|
173 | __xrangeIsTime = None | |
|
174 | ||
|
175 | #Advanced | |
|
176 | __xg = None | |
|
177 | __yg = None | |
|
178 | ||
|
179 | def __init__(self): | |
|
180 | """ | |
|
181 | ||
|
182 | """ | |
|
183 | pass | |
|
184 | ||
|
185 | def hasNotXrange(self): | |
|
186 | ||
|
187 | if self.xrange == None: | |
|
188 | return 1 | |
|
189 | ||
|
190 | return 0 | |
|
191 | ||
|
192 | def hasNotYrange(self): | |
|
193 | ||
|
194 | if self.yrange == None: | |
|
195 | return 1 | |
|
196 | ||
|
197 | return 0 | |
|
198 | ||
|
199 | def hasNotZrange(self): | |
|
200 | ||
|
201 | if self.zrange == None: | |
|
202 | return 1 | |
|
203 | ||
|
204 | return 0 | |
|
205 | def setName(self, name): | |
|
206 | self.__name = name | |
|
207 | ||
|
208 | def setScreenPos(self, xpos, ypos): | |
|
209 | self.__xpos = xpos | |
|
210 | self.__ypos = ypos | |
|
211 | ||
|
212 | def setScreenPosbyWidth(self, xoff, yoff, xw, yw): | |
|
213 | self.__xpos = [xoff, xoff + xw] | |
|
214 | self.__ypos = [yoff, yoff + yw] | |
|
215 | ||
|
216 | def setSubpage(self, subpage): | |
|
217 | self.__subpage = subpage | |
|
218 | ||
|
219 | def setSzchar(self, szchar): | |
|
220 | self.__szchar = szchar | |
|
221 | ||
|
222 | def setOpt(self, xopt, yopt): | |
|
223 | self.__xopt = xopt | |
|
224 | self.__yopt = yopt | |
|
225 | ||
|
226 | def setRanges(self, xrange, yrange, zrange=None): | |
|
227 | """ | |
|
228 | """ | |
|
229 | self.xrange = xrange | |
|
230 | ||
|
231 | self.yrange = yrange | |
|
232 | ||
|
233 | if zrange != None: | |
|
234 | self.zrange = zrange | |
|
235 | ||
|
236 | def setColormap(self, colormap=None): | |
|
237 | ||
|
238 | if colormap == None: | |
|
239 | colormap = self.__colormap | |
|
240 | ||
|
241 | cmap1_init(colormap) | |
|
242 | ||
|
243 | def plotBox(self): | |
|
244 | """ | |
|
245 | ||
|
246 | """ | |
|
247 | plplot.plvpor(self.__xpos[0], self.__xpos[1], self.__ypos[0], self.__ypos[1]) | |
|
248 | plplot.plwind(self.xrange[0], self.xrange[1], self.yrange[0], self.yrange[1]) | |
|
249 | plplot.plbox(self.__xopt, 0.0, 0, self.__yopt, 0.0, 0) | |
|
250 | plplot.pllab(self.xlabel, self.ylabel, self.title) | |
|
251 | ||
|
252 | def setup(self, title=None, xlabel=None, ylabel=None, colormap=None): | |
|
253 | """ | |
|
254 | """ | |
|
255 | self.title = title | |
|
256 | self.xlabel = xlabel | |
|
257 | self.ylabel = ylabel | |
|
258 | self.__colormap = colormap | |
|
259 | ||
|
260 | def initSubpage(self): | |
|
261 | ||
|
262 | if plplot.plgdev() == '': | |
|
263 | raise ValueError, "Plot device has not been initialize" | |
|
264 | ||
|
265 | plplot.pladv(self.__subpage) | |
|
266 | plplot.plschr(0.0, self.__szchar) | |
|
267 | ||
|
268 | if self.__xrangeIsTime: | |
|
269 | plplot.pltimefmt("%H:%M") | |
|
270 | ||
|
271 | self.setColormap() | |
|
272 | self.initPlot() | |
|
273 | ||
|
274 | def initPlot(self): | |
|
275 | """ | |
|
276 | ||
|
277 | """ | |
|
278 | if plplot.plgdev() == '': | |
|
279 | raise ValueError, "Plot device has not been initialize" | |
|
280 | ||
|
281 | xrange = self.xrange | |
|
282 | if xrange == None: | |
|
283 | xrange = [0., 1.] | |
|
284 | ||
|
285 | yrange = self.yrange | |
|
286 | if yrange == None: | |
|
287 | yrange = [0., 1.] | |
|
288 | ||
|
289 | plplot.plvpor(self.__xpos[0], self.__xpos[1], self.__ypos[0], self.__ypos[1]) | |
|
290 | plplot.plwind(xrange[0], xrange[1], yrange[0], yrange[1]) | |
|
291 | plplot.plbox(self.__xopt, 0.0, 0, self.__yopt, 0.0, 0) | |
|
292 | plplot.pllab(self.xlabel, self.ylabel, self.title) | |
|
293 | ||
|
294 | def colorbarPlot(self): | |
|
295 | data = numpy.arange(256) | |
|
296 | data = numpy.reshape(data, (1,-1)) | |
|
297 | ||
|
298 | self.plotBox() | |
|
299 | plplot.plimage(data, | |
|
300 | self.xrange[0], | |
|
301 | self.xrange[1], | |
|
302 | self.yrange[0], | |
|
303 | self.yrange[1], | |
|
304 | 0., | |
|
305 | 255., | |
|
306 | self.xrange[0], | |
|
307 | self.xrange[1], | |
|
308 | self.yrange[0], | |
|
309 | self.yrange[1],) | |
|
310 | ||
|
311 | def basicXYPlot(self, x, y): | |
|
312 | self.plotBox() | |
|
313 | plplot.plline(x, y) | |
|
314 | ||
|
315 | def basicXYwithErrorPlot(self): | |
|
316 | pass | |
|
317 | ||
|
318 | def basicLineTimePlot(self): | |
|
319 | pass | |
|
320 | ||
|
321 | def basicPcolorPlot(self, data, xmin, xmax, ymin, ymax, zmin, zmax): | |
|
322 | """ | |
|
323 | """ | |
|
324 | ||
|
325 | self.plotBox() | |
|
326 | plplot.plimage(data, xmin, xmax, ymin, ymax, zmin, zmax, xmin, xmax, ymin, ymax) | |
|
327 | ||
|
328 | ||
|
329 | def __getBoxpltr(self, x, y, deltax=None, deltay=None): | |
|
330 | ||
|
331 | if not(len(x)>1 and len(y)>1): | |
|
332 | raise ValueError, "x axis and y axis are empty" | |
|
333 | ||
|
334 | if deltax == None: deltax = x[-1] - x[-2] | |
|
335 | if deltay == None: deltay = y[-1] - y[-2] | |
|
336 | ||
|
337 | x1 = numpy.append(x, x[-1] + deltax) | |
|
338 | y1 = numpy.append(y, y[-1] + deltay) | |
|
339 | ||
|
340 | xg = (numpy.multiply.outer(x1, numpy.ones(len(y1)))) | |
|
341 | yg = (numpy.multiply.outer(numpy.ones(len(x1)), y1)) | |
|
342 | ||
|
343 | self.__xg = xg | |
|
344 | self.__yg = yg | |
|
345 | ||
|
346 | def advPcolorPlot(self, data, x, y, zmin=0., zmax=0.): | |
|
347 | """ | |
|
348 | """ | |
|
349 | ||
|
350 | if self.__xg == None and self.__yg == None: | |
|
351 | self.__getBoxpltr(x, y) | |
|
352 | ||
|
353 | plplot.plimagefr(data, x[0], x[-1], y[0], y[-1], 0., 0., zmin, zmax, plplot.pltr2, self.__xg, self.__yg) | |
|
354 | ||
|
355 | ||
|
1 | import numpy | |
|
2 | import plplot | |
|
3 | ||
|
4 | def cmap1_init(colormap="gray"): | |
|
5 | ||
|
6 | ncolor = None | |
|
7 | rgb_lvl = None | |
|
8 | ||
|
9 | # Routine for defining a specific color map 1 in HLS space. | |
|
10 | # if gray is true, use basic grayscale variation from half-dark to light. | |
|
11 | # otherwise use false color variation from blue (240 deg) to red (360 deg). | |
|
12 | ||
|
13 | # Independent variable of control points. | |
|
14 | i = numpy.array((0., 1.)) | |
|
15 | if colormap=="gray": | |
|
16 | ncolor = 256 | |
|
17 | # Hue for control points. Doesn't matter since saturation is zero. | |
|
18 | h = numpy.array((0., 0.)) | |
|
19 | # Lightness ranging from half-dark (for interest) to light. | |
|
20 | l = numpy.array((0.5, 1.)) | |
|
21 | # Gray scale has zero saturation | |
|
22 | s = numpy.array((0., 0.)) | |
|
23 | ||
|
24 | # number of cmap1 colours is 256 in this case. | |
|
25 | plplot.plscmap1n(ncolor) | |
|
26 | # Interpolate between control points to set up cmap1. | |
|
27 | plplot.plscmap1l(0, i, h, l, s) | |
|
28 | ||
|
29 | return None | |
|
30 | ||
|
31 | if colormap=="br_green": | |
|
32 | ncolor = 256 | |
|
33 | # Hue ranges from blue (240 deg) to red (0 or 360 deg) | |
|
34 | h = numpy.array((240., 0.)) | |
|
35 | # Lightness and saturation are constant (values taken from C example). | |
|
36 | l = numpy.array((0.6, 0.6)) | |
|
37 | s = numpy.array((0.8, 0.8)) | |
|
38 | ||
|
39 | # number of cmap1 colours is 256 in this case. | |
|
40 | plplot.plscmap1n(ncolor) | |
|
41 | # Interpolate between control points to set up cmap1. | |
|
42 | plplot.plscmap1l(0, i, h, l, s) | |
|
43 | ||
|
44 | return None | |
|
45 | ||
|
46 | if colormap=="tricolor": | |
|
47 | ncolor = 3 | |
|
48 | # Hue ranges from blue (240 deg) to red (0 or 360 deg) | |
|
49 | h = numpy.array((240., 0.)) | |
|
50 | # Lightness and saturation are constant (values taken from C example). | |
|
51 | l = numpy.array((0.6, 0.6)) | |
|
52 | s = numpy.array((0.8, 0.8)) | |
|
53 | ||
|
54 | # number of cmap1 colours is 256 in this case. | |
|
55 | plplot.plscmap1n(ncolor) | |
|
56 | # Interpolate between control points to set up cmap1. | |
|
57 | plplot.plscmap1l(0, i, h, l, s) | |
|
58 | ||
|
59 | return None | |
|
60 | ||
|
61 | if colormap == 'rgb' or colormap == 'rgb666': | |
|
62 | ||
|
63 | color_sz = 6 | |
|
64 | ncolor = color_sz*color_sz*color_sz | |
|
65 | pos = numpy.zeros((ncolor)) | |
|
66 | r = numpy.zeros((ncolor)) | |
|
67 | g = numpy.zeros((ncolor)) | |
|
68 | b = numpy.zeros((ncolor)) | |
|
69 | ind = 0 | |
|
70 | for ri in range(color_sz): | |
|
71 | for gi in range(color_sz): | |
|
72 | for bi in range(color_sz): | |
|
73 | r[ind] = ri/(color_sz-1.0) | |
|
74 | g[ind] = gi/(color_sz-1.0) | |
|
75 | b[ind] = bi/(color_sz-1.0) | |
|
76 | pos[ind] = ind/(ncolor-1.0) | |
|
77 | ind += 1 | |
|
78 | rgb_lvl = [6,6,6] #Levels for RGB colors | |
|
79 | ||
|
80 | if colormap == 'rgb676': | |
|
81 | ncolor = 6*7*6 | |
|
82 | pos = numpy.zeros((ncolor)) | |
|
83 | r = numpy.zeros((ncolor)) | |
|
84 | g = numpy.zeros((ncolor)) | |
|
85 | b = numpy.zeros((ncolor)) | |
|
86 | ind = 0 | |
|
87 | for ri in range(8): | |
|
88 | for gi in range(8): | |
|
89 | for bi in range(4): | |
|
90 | r[ind] = ri/(6-1.0) | |
|
91 | g[ind] = gi/(7-1.0) | |
|
92 | b[ind] = bi/(6-1.0) | |
|
93 | pos[ind] = ind/(ncolor-1.0) | |
|
94 | ind += 1 | |
|
95 | rgb_lvl = [6,7,6] #Levels for RGB colors | |
|
96 | ||
|
97 | if colormap == 'rgb685': | |
|
98 | ncolor = 6*8*5 | |
|
99 | pos = numpy.zeros((ncolor)) | |
|
100 | r = numpy.zeros((ncolor)) | |
|
101 | g = numpy.zeros((ncolor)) | |
|
102 | b = numpy.zeros((ncolor)) | |
|
103 | ind = 0 | |
|
104 | for ri in range(8): | |
|
105 | for gi in range(8): | |
|
106 | for bi in range(4): | |
|
107 | r[ind] = ri/(6-1.0) | |
|
108 | g[ind] = gi/(8-1.0) | |
|
109 | b[ind] = bi/(5-1.0) | |
|
110 | pos[ind] = ind/(ncolor-1.0) | |
|
111 | ind += 1 | |
|
112 | rgb_lvl = [6,8,5] #Levels for RGB colors | |
|
113 | ||
|
114 | if colormap == 'rgb884': | |
|
115 | ncolor = 8*8*4 | |
|
116 | pos = numpy.zeros((ncolor)) | |
|
117 | r = numpy.zeros((ncolor)) | |
|
118 | g = numpy.zeros((ncolor)) | |
|
119 | b = numpy.zeros((ncolor)) | |
|
120 | ind = 0 | |
|
121 | for ri in range(8): | |
|
122 | for gi in range(8): | |
|
123 | for bi in range(4): | |
|
124 | r[ind] = ri/(8-1.0) | |
|
125 | g[ind] = gi/(8-1.0) | |
|
126 | b[ind] = bi/(4-1.0) | |
|
127 | pos[ind] = ind/(ncolor-1.0) | |
|
128 | ind += 1 | |
|
129 | rgb_lvl = [8,8,4] #Levels for RGB colors | |
|
130 | ||
|
131 | if ncolor == None: | |
|
132 | raise ValueError, "The colormap selected is not valid" | |
|
133 | ||
|
134 | plplot.plscmap1n(ncolor) | |
|
135 | plplot.plscmap1l(1, pos, r, g, b) | |
|
136 | ||
|
137 | return rgb_lvl | |
|
138 | ||
|
139 | class BasicGraph: | |
|
140 | """ | |
|
141 | ||
|
142 | """ | |
|
143 | ||
|
144 | hasRange = False | |
|
145 | ||
|
146 | xrange = None | |
|
147 | yrange = None | |
|
148 | zrange = None | |
|
149 | ||
|
150 | xlabel = None | |
|
151 | ylabel = None | |
|
152 | title = None | |
|
153 | ||
|
154 | legends = None | |
|
155 | ||
|
156 | __name = None | |
|
157 | __subpage = None | |
|
158 | __szchar = None | |
|
159 | ||
|
160 | __colormap = None | |
|
161 | __colbox = None | |
|
162 | __colleg = None | |
|
163 | ||
|
164 | __xpos = None | |
|
165 | __ypos = None | |
|
166 | ||
|
167 | __xopt = None #"bcnst" | |
|
168 | __yopt = None #"bcnstv" | |
|
169 | ||
|
170 | __xlpos = None | |
|
171 | __ylpos = None | |
|
172 | ||
|
173 | __xrangeIsTime = None | |
|
174 | ||
|
175 | #Advanced | |
|
176 | __xg = None | |
|
177 | __yg = None | |
|
178 | ||
|
179 | def __init__(self): | |
|
180 | """ | |
|
181 | ||
|
182 | """ | |
|
183 | pass | |
|
184 | ||
|
185 | def hasNotXrange(self): | |
|
186 | ||
|
187 | if self.xrange == None: | |
|
188 | return 1 | |
|
189 | ||
|
190 | return 0 | |
|
191 | ||
|
192 | def hasNotYrange(self): | |
|
193 | ||
|
194 | if self.yrange == None: | |
|
195 | return 1 | |
|
196 | ||
|
197 | return 0 | |
|
198 | ||
|
199 | def hasNotZrange(self): | |
|
200 | ||
|
201 | if self.zrange == None: | |
|
202 | return 1 | |
|
203 | ||
|
204 | return 0 | |
|
205 | def setName(self, name): | |
|
206 | self.__name = name | |
|
207 | ||
|
208 | def setScreenPos(self, xpos, ypos): | |
|
209 | self.__xpos = xpos | |
|
210 | self.__ypos = ypos | |
|
211 | ||
|
212 | def setScreenPosbyWidth(self, xoff, yoff, xw, yw): | |
|
213 | self.__xpos = [xoff, xoff + xw] | |
|
214 | self.__ypos = [yoff, yoff + yw] | |
|
215 | ||
|
216 | def setSubpage(self, subpage): | |
|
217 | self.__subpage = subpage | |
|
218 | ||
|
219 | def setSzchar(self, szchar): | |
|
220 | self.__szchar = szchar | |
|
221 | ||
|
222 | def setOpt(self, xopt, yopt): | |
|
223 | self.__xopt = xopt | |
|
224 | self.__yopt = yopt | |
|
225 | ||
|
226 | def setRanges(self, xrange, yrange, zrange=None): | |
|
227 | """ | |
|
228 | """ | |
|
229 | self.xrange = xrange | |
|
230 | ||
|
231 | self.yrange = yrange | |
|
232 | ||
|
233 | if zrange != None: | |
|
234 | self.zrange = zrange | |
|
235 | ||
|
236 | def setColormap(self, colormap=None): | |
|
237 | ||
|
238 | if colormap == None: | |
|
239 | colormap = self.__colormap | |
|
240 | ||
|
241 | cmap1_init(colormap) | |
|
242 | ||
|
243 | def plotBox(self): | |
|
244 | """ | |
|
245 | ||
|
246 | """ | |
|
247 | plplot.plvpor(self.__xpos[0], self.__xpos[1], self.__ypos[0], self.__ypos[1]) | |
|
248 | plplot.plwind(self.xrange[0], self.xrange[1], self.yrange[0], self.yrange[1]) | |
|
249 | plplot.plbox(self.__xopt, 0.0, 0, self.__yopt, 0.0, 0) | |
|
250 | plplot.pllab(self.xlabel, self.ylabel, self.title) | |
|
251 | ||
|
252 | def setup(self, title=None, xlabel=None, ylabel=None, colormap=None): | |
|
253 | """ | |
|
254 | """ | |
|
255 | self.title = title | |
|
256 | self.xlabel = xlabel | |
|
257 | self.ylabel = ylabel | |
|
258 | self.__colormap = colormap | |
|
259 | ||
|
260 | def initSubpage(self): | |
|
261 | ||
|
262 | if plplot.plgdev() == '': | |
|
263 | raise ValueError, "Plot device has not been initialize" | |
|
264 | ||
|
265 | plplot.pladv(self.__subpage) | |
|
266 | plplot.plschr(0.0, self.__szchar) | |
|
267 | ||
|
268 | if self.__xrangeIsTime: | |
|
269 | plplot.pltimefmt("%H:%M") | |
|
270 | ||
|
271 | self.setColormap() | |
|
272 | self.initPlot() | |
|
273 | ||
|
274 | def initPlot(self): | |
|
275 | """ | |
|
276 | ||
|
277 | """ | |
|
278 | if plplot.plgdev() == '': | |
|
279 | raise ValueError, "Plot device has not been initialize" | |
|
280 | ||
|
281 | xrange = self.xrange | |
|
282 | if xrange == None: | |
|
283 | xrange = [0., 1.] | |
|
284 | ||
|
285 | yrange = self.yrange | |
|
286 | if yrange == None: | |
|
287 | yrange = [0., 1.] | |
|
288 | ||
|
289 | plplot.plvpor(self.__xpos[0], self.__xpos[1], self.__ypos[0], self.__ypos[1]) | |
|
290 | plplot.plwind(xrange[0], xrange[1], yrange[0], yrange[1]) | |
|
291 | plplot.plbox(self.__xopt, 0.0, 0, self.__yopt, 0.0, 0) | |
|
292 | plplot.pllab(self.xlabel, self.ylabel, self.title) | |
|
293 | ||
|
294 | def colorbarPlot(self): | |
|
295 | data = numpy.arange(256) | |
|
296 | data = numpy.reshape(data, (1,-1)) | |
|
297 | ||
|
298 | self.plotBox() | |
|
299 | plplot.plimage(data, | |
|
300 | self.xrange[0], | |
|
301 | self.xrange[1], | |
|
302 | self.yrange[0], | |
|
303 | self.yrange[1], | |
|
304 | 0., | |
|
305 | 255., | |
|
306 | self.xrange[0], | |
|
307 | self.xrange[1], | |
|
308 | self.yrange[0], | |
|
309 | self.yrange[1],) | |
|
310 | ||
|
311 | def basicXYPlot(self, x, y): | |
|
312 | self.plotBox() | |
|
313 | plplot.plline(x, y) | |
|
314 | ||
|
315 | def basicXYwithErrorPlot(self): | |
|
316 | pass | |
|
317 | ||
|
318 | def basicLineTimePlot(self): | |
|
319 | pass | |
|
320 | ||
|
321 | def basicPcolorPlot(self, data, xmin, xmax, ymin, ymax, zmin, zmax): | |
|
322 | """ | |
|
323 | """ | |
|
324 | ||
|
325 | self.plotBox() | |
|
326 | plplot.plimage(data, xmin, xmax, ymin, ymax, zmin, zmax, xmin, xmax, ymin, ymax) | |
|
327 | ||
|
328 | ||
|
329 | def __getBoxpltr(self, x, y, deltax=None, deltay=None): | |
|
330 | ||
|
331 | if not(len(x)>1 and len(y)>1): | |
|
332 | raise ValueError, "x axis and y axis are empty" | |
|
333 | ||
|
334 | if deltax == None: deltax = x[-1] - x[-2] | |
|
335 | if deltay == None: deltay = y[-1] - y[-2] | |
|
336 | ||
|
337 | x1 = numpy.append(x, x[-1] + deltax) | |
|
338 | y1 = numpy.append(y, y[-1] + deltay) | |
|
339 | ||
|
340 | xg = (numpy.multiply.outer(x1, numpy.ones(len(y1)))) | |
|
341 | yg = (numpy.multiply.outer(numpy.ones(len(x1)), y1)) | |
|
342 | ||
|
343 | self.__xg = xg | |
|
344 | self.__yg = yg | |
|
345 | ||
|
346 | def advPcolorPlot(self, data, x, y, zmin=0., zmax=0.): | |
|
347 | """ | |
|
348 | """ | |
|
349 | ||
|
350 | if self.__xg == None and self.__yg == None: | |
|
351 | self.__getBoxpltr(x, y) | |
|
352 | ||
|
353 | plplot.plimagefr(data, x[0], x[-1], y[0], y[-1], 0., 0., zmin, zmax, plplot.pltr2, self.__xg, self.__yg) | |
|
354 | ||
|
355 |
@@ -1,213 +1,213 | |||
|
1 | import numpy | |
|
2 | import plplot | |
|
3 | ||
|
4 | from BasicGraph import * | |
|
5 | ||
|
6 |
class Spectrum |
|
|
7 | ||
|
8 | graphObjDict = {} | |
|
9 | showColorbar = False | |
|
10 | showPowerProfile = True | |
|
11 | ||
|
12 | __szchar = 0.7 | |
|
13 | ||
|
14 | def __init__(self): | |
|
15 | ||
|
16 | key = "spec" | |
|
17 | ||
|
18 | specObj = BasicGraph() | |
|
19 | specObj.setName(key) | |
|
20 | ||
|
21 | self.graphObjDict[key] = specObj | |
|
22 | ||
|
23 | ||
|
24 | def setup(self, subpage, title="", xlabel="", ylabel="", colormap="jet", showColorbar=False, showPowerProfile=False): | |
|
25 | """ | |
|
26 | """ | |
|
27 | ||
|
28 | xi = 0.12; xw = 0.78; xf = xi + xw | |
|
29 | yi = 0.14; yw = 0.80; yf = yi + yw | |
|
30 | ||
|
31 | xcmapi = xcmapf = 0.; xpowi = xpowf = 0. | |
|
32 | ||
|
33 | key = "spec" | |
|
34 | specObj = self.graphObjDict[key] | |
|
35 | specObj.setSubpage(subpage) | |
|
36 | specObj.setSzchar(self.__szchar) | |
|
37 | specObj.setOpt("bcnts","bcnts") | |
|
38 | specObj.setup(title, | |
|
39 | xlabel, | |
|
40 | ylabel, | |
|
41 | colormap) | |
|
42 | ||
|
43 | if showColorbar: | |
|
44 | key = "colorbar" | |
|
45 | ||
|
46 | cmapObj = BasicGraph() | |
|
47 | cmapObj.setName(key) | |
|
48 | cmapObj.setSubpage(subpage) | |
|
49 | cmapObj.setSzchar(self.__szchar) | |
|
50 | cmapObj.setOpt("bc","bcmt") | |
|
51 | cmapObj.setup(title="dBs", | |
|
52 | xlabel="", | |
|
53 | ylabel="", | |
|
54 | colormap=colormap) | |
|
55 | ||
|
56 | self.graphObjDict[key] = cmapObj | |
|
57 | ||
|
58 | xcmapi = 0. | |
|
59 | xcmapw = 0.05 | |
|
60 | xw -= xcmapw | |
|
61 | ||
|
62 | if showPowerProfile: | |
|
63 | key = "powerprof" | |
|
64 | ||
|
65 | powObj = BasicGraph() | |
|
66 | powObj.setName(key) | |
|
67 | powObj.setSubpage(subpage) | |
|
68 | powObj.setSzchar(self.__szchar) | |
|
69 | plplot.pllsty(2) | |
|
70 | powObj.setOpt("bcntg","bc") | |
|
71 | plplot.pllsty(1) | |
|
72 | powObj.setup(title="Power Profile", | |
|
73 | xlabel="dBs", | |
|
74 | ylabel="") | |
|
75 | ||
|
76 | self.graphObjDict[key] = powObj | |
|
77 | ||
|
78 | xpowi = 0. | |
|
79 | xpoww = 0.24 | |
|
80 | xw -= xpoww | |
|
81 | ||
|
82 | xf = xi + xw | |
|
83 | yf = yi + yw | |
|
84 | xcmapf = xf | |
|
85 | ||
|
86 | specObj.setScreenPos([xi, xf], [yi, yf]) | |
|
87 | ||
|
88 | if showColorbar: | |
|
89 | xcmapi = xf + 0.02 | |
|
90 | xcmapf = xcmapi + xcmapw | |
|
91 | cmapObj.setScreenPos([xcmapi, xcmapf], [yi, yf]) | |
|
92 | ||
|
93 | if showPowerProfile: | |
|
94 | xpowi = xcmapf + 0.06 | |
|
95 | xpowf = xpowi + xpoww | |
|
96 | powObj.setScreenPos([xpowi, xpowf], [yi, yf]) | |
|
97 | ||
|
98 | ||
|
99 | # specObj.initSubpage() | |
|
100 | # | |
|
101 | # if showColorbar: | |
|
102 | # cmapObj.initPlot() | |
|
103 | # | |
|
104 | # if showPowerProfile: | |
|
105 | # powObj.initPlot() | |
|
106 | ||
|
107 | self.showColorbar = showColorbar | |
|
108 | self.showPowerProfile = showPowerProfile | |
|
109 | ||
|
110 | def setRanges(self, xrange, yrange, zrange): | |
|
111 | ||
|
112 | key = "spec" | |
|
113 | specObj = self.graphObjDict[key] | |
|
114 | specObj.setRanges(xrange, yrange, zrange) | |
|
115 | ||
|
116 | keyList = self.graphObjDict.keys() | |
|
117 | ||
|
118 | key = "colorbar" | |
|
119 | if key in keyList: | |
|
120 | cmapObj = self.graphObjDict[key] | |
|
121 | cmapObj.setRanges([0., 1.], zrange) | |
|
122 | ||
|
123 | key = "powerprof" | |
|
124 | if key in keyList: | |
|
125 | powObj = self.graphObjDict[key] | |
|
126 | powObj.setRanges(zrange, yrange) | |
|
127 | ||
|
128 | def plotData(self, data , xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None): | |
|
129 | ||
|
130 | key = "spec" | |
|
131 | specObj = self.graphObjDict[key] | |
|
132 | specObj.initSubpage() | |
|
133 | ||
|
134 | if xmin == None: | |
|
135 | xmin = 0. | |
|
136 | ||
|
137 | if xmax == None: | |
|
138 | xmax = 1. | |
|
139 | ||
|
140 | if ymin == None: | |
|
141 | ymin = 0. | |
|
142 | ||
|
143 | if ymax == None: | |
|
144 | ymax = 1. | |
|
145 | ||
|
146 | if zmin == None: | |
|
147 | zmin = numpy.nanmin(data) | |
|
148 | ||
|
149 | if zmax == None: | |
|
150 | zmax = numpy.nanmax(data) | |
|
151 | ||
|
152 | if not(specObj.hasRange): | |
|
153 | self.setRanges([xmin, xmax], [ymin,ymax], [zmin,zmax]) | |
|
154 | ||
|
155 | specObj.basicPcolorPlot(data, xmin, xmax, ymin, ymax, specObj.zrange[0], specObj.zrange[1]) | |
|
156 | ||
|
157 | if self.showColorbar: | |
|
158 | key = "colorbar" | |
|
159 | cmapObj = self.graphObjDict[key] | |
|
160 | cmapObj.colorbarPlot() | |
|
161 | ||
|
162 | if self.showPowerProfile: | |
|
163 | power = numpy.average(data, axis=1) | |
|
164 | ||
|
165 | step = (ymax - ymin)/(power.shape[0]-1) | |
|
166 | heis = numpy.arange(ymin, ymax + step, step) | |
|
167 | ||
|
168 | key = "powerprof" | |
|
169 | powObj = self.graphObjDict[key] | |
|
170 | powObj.basicXYPlot(power, heis) | |
|
171 | ||
|
172 |
class CrossSpectrum |
|
|
173 | graphObjDict = {} | |
|
174 | showColorbar = False | |
|
175 | showPowerProfile = True | |
|
176 | ||
|
177 | __szchar = 0.7 | |
|
178 | def __init__(self): | |
|
179 | pass | |
|
180 | ||
|
181 | def setup(self): | |
|
182 | pass | |
|
183 | ||
|
184 | def plotData(self): | |
|
185 | pass | |
|
186 | ||
|
187 | if __name__ == '__main__': | |
|
188 | ||
|
189 | import numpy | |
|
190 | plplot.plsetopt("geometry", "%dx%d" %(350*2, 300*2)) | |
|
191 | plplot.plsdev("xcairo") | |
|
192 | plplot.plscolbg(255,255,255) | |
|
193 | plplot.plscol0(1,0,0,0) | |
|
194 | plplot.plinit() | |
|
195 | plplot.plssub(2, 2) | |
|
196 | ||
|
197 | nx = 64 | |
|
198 | ny = 100 | |
|
199 | ||
|
200 | data = numpy.random.uniform(-50,50,(nx,ny)) | |
|
201 | ||
|
202 | specObj = Spectrum() | |
|
203 | specObj.setup(1, "Spectrum", "Frequency", "Range", "br_green", False, False) | |
|
204 | specObj.plotData(data) | |
|
205 | ||
|
206 | data = numpy.random.uniform(-50,50,(nx,ny)) | |
|
207 | ||
|
208 | spec2Obj = Spectrum() | |
|
209 | spec2Obj.setup(2, "Spectrum", "Frequency", "Range", "br_green", True, True) | |
|
210 | spec2Obj.plotData(data) | |
|
211 | ||
|
212 | plplot.plend() | |
|
1 | import numpy | |
|
2 | import plplot | |
|
3 | ||
|
4 | from BasicGraph import * | |
|
5 | ||
|
6 | class Spectrum: | |
|
7 | ||
|
8 | graphObjDict = {} | |
|
9 | showColorbar = False | |
|
10 | showPowerProfile = True | |
|
11 | ||
|
12 | __szchar = 0.7 | |
|
13 | ||
|
14 | def __init__(self): | |
|
15 | ||
|
16 | key = "spec" | |
|
17 | ||
|
18 | specObj = BasicGraph() | |
|
19 | specObj.setName(key) | |
|
20 | ||
|
21 | self.graphObjDict[key] = specObj | |
|
22 | ||
|
23 | ||
|
24 | def setup(self, subpage, title="", xlabel="", ylabel="", colormap="jet", showColorbar=False, showPowerProfile=False): | |
|
25 | """ | |
|
26 | """ | |
|
27 | ||
|
28 | xi = 0.12; xw = 0.78; xf = xi + xw | |
|
29 | yi = 0.14; yw = 0.80; yf = yi + yw | |
|
30 | ||
|
31 | xcmapi = xcmapf = 0.; xpowi = xpowf = 0. | |
|
32 | ||
|
33 | key = "spec" | |
|
34 | specObj = self.graphObjDict[key] | |
|
35 | specObj.setSubpage(subpage) | |
|
36 | specObj.setSzchar(self.__szchar) | |
|
37 | specObj.setOpt("bcnts","bcnts") | |
|
38 | specObj.setup(title, | |
|
39 | xlabel, | |
|
40 | ylabel, | |
|
41 | colormap) | |
|
42 | ||
|
43 | if showColorbar: | |
|
44 | key = "colorbar" | |
|
45 | ||
|
46 | cmapObj = BasicGraph() | |
|
47 | cmapObj.setName(key) | |
|
48 | cmapObj.setSubpage(subpage) | |
|
49 | cmapObj.setSzchar(self.__szchar) | |
|
50 | cmapObj.setOpt("bc","bcmt") | |
|
51 | cmapObj.setup(title="dBs", | |
|
52 | xlabel="", | |
|
53 | ylabel="", | |
|
54 | colormap=colormap) | |
|
55 | ||
|
56 | self.graphObjDict[key] = cmapObj | |
|
57 | ||
|
58 | xcmapi = 0. | |
|
59 | xcmapw = 0.05 | |
|
60 | xw -= xcmapw | |
|
61 | ||
|
62 | if showPowerProfile: | |
|
63 | key = "powerprof" | |
|
64 | ||
|
65 | powObj = BasicGraph() | |
|
66 | powObj.setName(key) | |
|
67 | powObj.setSubpage(subpage) | |
|
68 | powObj.setSzchar(self.__szchar) | |
|
69 | plplot.pllsty(2) | |
|
70 | powObj.setOpt("bcntg","bc") | |
|
71 | plplot.pllsty(1) | |
|
72 | powObj.setup(title="Power Profile", | |
|
73 | xlabel="dBs", | |
|
74 | ylabel="") | |
|
75 | ||
|
76 | self.graphObjDict[key] = powObj | |
|
77 | ||
|
78 | xpowi = 0. | |
|
79 | xpoww = 0.24 | |
|
80 | xw -= xpoww | |
|
81 | ||
|
82 | xf = xi + xw | |
|
83 | yf = yi + yw | |
|
84 | xcmapf = xf | |
|
85 | ||
|
86 | specObj.setScreenPos([xi, xf], [yi, yf]) | |
|
87 | ||
|
88 | if showColorbar: | |
|
89 | xcmapi = xf + 0.02 | |
|
90 | xcmapf = xcmapi + xcmapw | |
|
91 | cmapObj.setScreenPos([xcmapi, xcmapf], [yi, yf]) | |
|
92 | ||
|
93 | if showPowerProfile: | |
|
94 | xpowi = xcmapf + 0.06 | |
|
95 | xpowf = xpowi + xpoww | |
|
96 | powObj.setScreenPos([xpowi, xpowf], [yi, yf]) | |
|
97 | ||
|
98 | ||
|
99 | # specObj.initSubpage() | |
|
100 | # | |
|
101 | # if showColorbar: | |
|
102 | # cmapObj.initPlot() | |
|
103 | # | |
|
104 | # if showPowerProfile: | |
|
105 | # powObj.initPlot() | |
|
106 | ||
|
107 | self.showColorbar = showColorbar | |
|
108 | self.showPowerProfile = showPowerProfile | |
|
109 | ||
|
110 | def setRanges(self, xrange, yrange, zrange): | |
|
111 | ||
|
112 | key = "spec" | |
|
113 | specObj = self.graphObjDict[key] | |
|
114 | specObj.setRanges(xrange, yrange, zrange) | |
|
115 | ||
|
116 | keyList = self.graphObjDict.keys() | |
|
117 | ||
|
118 | key = "colorbar" | |
|
119 | if key in keyList: | |
|
120 | cmapObj = self.graphObjDict[key] | |
|
121 | cmapObj.setRanges([0., 1.], zrange) | |
|
122 | ||
|
123 | key = "powerprof" | |
|
124 | if key in keyList: | |
|
125 | powObj = self.graphObjDict[key] | |
|
126 | powObj.setRanges(zrange, yrange) | |
|
127 | ||
|
128 | def plotData(self, data , xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None): | |
|
129 | ||
|
130 | key = "spec" | |
|
131 | specObj = self.graphObjDict[key] | |
|
132 | specObj.initSubpage() | |
|
133 | ||
|
134 | if xmin == None: | |
|
135 | xmin = 0. | |
|
136 | ||
|
137 | if xmax == None: | |
|
138 | xmax = 1. | |
|
139 | ||
|
140 | if ymin == None: | |
|
141 | ymin = 0. | |
|
142 | ||
|
143 | if ymax == None: | |
|
144 | ymax = 1. | |
|
145 | ||
|
146 | if zmin == None: | |
|
147 | zmin = numpy.nanmin(data) | |
|
148 | ||
|
149 | if zmax == None: | |
|
150 | zmax = numpy.nanmax(data) | |
|
151 | ||
|
152 | if not(specObj.hasRange): | |
|
153 | self.setRanges([xmin, xmax], [ymin,ymax], [zmin,zmax]) | |
|
154 | ||
|
155 | specObj.basicPcolorPlot(data, xmin, xmax, ymin, ymax, specObj.zrange[0], specObj.zrange[1]) | |
|
156 | ||
|
157 | if self.showColorbar: | |
|
158 | key = "colorbar" | |
|
159 | cmapObj = self.graphObjDict[key] | |
|
160 | cmapObj.colorbarPlot() | |
|
161 | ||
|
162 | if self.showPowerProfile: | |
|
163 | power = numpy.average(data, axis=1) | |
|
164 | ||
|
165 | step = (ymax - ymin)/(power.shape[0]-1) | |
|
166 | heis = numpy.arange(ymin, ymax + step, step) | |
|
167 | ||
|
168 | key = "powerprof" | |
|
169 | powObj = self.graphObjDict[key] | |
|
170 | powObj.basicXYPlot(power, heis) | |
|
171 | ||
|
172 | class CrossSpectrum: | |
|
173 | graphObjDict = {} | |
|
174 | showColorbar = False | |
|
175 | showPowerProfile = True | |
|
176 | ||
|
177 | __szchar = 0.7 | |
|
178 | def __init__(self): | |
|
179 | pass | |
|
180 | ||
|
181 | def setup(self): | |
|
182 | pass | |
|
183 | ||
|
184 | def plotData(self): | |
|
185 | pass | |
|
186 | ||
|
187 | if __name__ == '__main__': | |
|
188 | ||
|
189 | import numpy | |
|
190 | plplot.plsetopt("geometry", "%dx%d" %(350*2, 300*2)) | |
|
191 | plplot.plsdev("xcairo") | |
|
192 | plplot.plscolbg(255,255,255) | |
|
193 | plplot.plscol0(1,0,0,0) | |
|
194 | plplot.plinit() | |
|
195 | plplot.plssub(2, 2) | |
|
196 | ||
|
197 | nx = 64 | |
|
198 | ny = 100 | |
|
199 | ||
|
200 | data = numpy.random.uniform(-50,50,(nx,ny)) | |
|
201 | ||
|
202 | specObj = Spectrum() | |
|
203 | specObj.setup(1, "Spectrum", "Frequency", "Range", "br_green", False, False) | |
|
204 | specObj.plotData(data) | |
|
205 | ||
|
206 | data = numpy.random.uniform(-50,50,(nx,ny)) | |
|
207 | ||
|
208 | spec2Obj = Spectrum() | |
|
209 | spec2Obj.setup(2, "Spectrum", "Frequency", "Range", "br_green", True, True) | |
|
210 | spec2Obj.plotData(data) | |
|
211 | ||
|
212 | plplot.plend() | |
|
213 | 213 | exit(0) No newline at end of file |
@@ -1,245 +1,269 | |||
|
1 | 1 | import numpy |
|
2 | 2 | |
|
3 | 3 | class PROCFLAG: |
|
4 | 4 | COHERENT_INTEGRATION = numpy.uint32(0x00000001) |
|
5 | 5 | DECODE_DATA = numpy.uint32(0x00000002) |
|
6 | 6 | SPECTRA_CALC = numpy.uint32(0x00000004) |
|
7 | 7 | INCOHERENT_INTEGRATION = numpy.uint32(0x00000008) |
|
8 | 8 | POST_COHERENT_INTEGRATION = numpy.uint32(0x00000010) |
|
9 | 9 | SHIFT_FFT_DATA = numpy.uint32(0x00000020) |
|
10 | 10 | |
|
11 | 11 | DATATYPE_CHAR = numpy.uint32(0x00000040) |
|
12 | 12 | DATATYPE_SHORT = numpy.uint32(0x00000080) |
|
13 | 13 | DATATYPE_LONG = numpy.uint32(0x00000100) |
|
14 | 14 | DATATYPE_INT64 = numpy.uint32(0x00000200) |
|
15 | 15 | DATATYPE_FLOAT = numpy.uint32(0x00000400) |
|
16 | 16 | DATATYPE_DOUBLE = numpy.uint32(0x00000800) |
|
17 | 17 | |
|
18 | 18 | DATAARRANGE_CONTIGUOUS_CH = numpy.uint32(0x00001000) |
|
19 | 19 | DATAARRANGE_CONTIGUOUS_H = numpy.uint32(0x00002000) |
|
20 | 20 | DATAARRANGE_CONTIGUOUS_P = numpy.uint32(0x00004000) |
|
21 | 21 | |
|
22 | 22 | SAVE_CHANNELS_DC = numpy.uint32(0x00008000) |
|
23 | 23 | DEFLIP_DATA = numpy.uint32(0x00010000) |
|
24 | 24 | DEFINE_PROCESS_CODE = numpy.uint32(0x00020000) |
|
25 | 25 | |
|
26 | 26 | ACQ_SYS_NATALIA = numpy.uint32(0x00040000) |
|
27 | 27 | ACQ_SYS_ECHOTEK = numpy.uint32(0x00080000) |
|
28 | 28 | ACQ_SYS_ADRXD = numpy.uint32(0x000C0000) |
|
29 | 29 | ACQ_SYS_JULIA = numpy.uint32(0x00100000) |
|
30 | 30 | ACQ_SYS_XXXXXX = numpy.uint32(0x00140000) |
|
31 | 31 | |
|
32 | 32 | EXP_NAME_ESP = numpy.uint32(0x00200000) |
|
33 | 33 | CHANNEL_NAMES_ESP = numpy.uint32(0x00400000) |
|
34 | 34 | |
|
35 | 35 | OPERATION_MASK = numpy.uint32(0x0000003F) |
|
36 | 36 | DATATYPE_MASK = numpy.uint32(0x00000FC0) |
|
37 | 37 | DATAARRANGE_MASK = numpy.uint32(0x00007000) |
|
38 | 38 | ACQ_SYS_MASK = numpy.uint32(0x001C0000) |
|
39 | 39 | |
|
40 | 40 | class BasicHeader: |
|
41 | 41 | |
|
42 | 42 | size = 0 |
|
43 | 43 | version = 0 |
|
44 | 44 | dataBlock = 0 |
|
45 | 45 | utc = 0 |
|
46 | 46 | miliSecond = 0 |
|
47 | 47 | timeZone = 0 |
|
48 | 48 | dstFlag = 0 |
|
49 | 49 | errorCount = 0 |
|
50 | 50 | struct = numpy.dtype([ |
|
51 | 51 | ('nSize','<u4'), |
|
52 | 52 | ('nVersion','<u2'), |
|
53 | 53 | ('nDataBlockId','<u4'), |
|
54 | 54 | ('nUtime','<u4'), |
|
55 | 55 | ('nMilsec','<u2'), |
|
56 | 56 | ('nTimezone','<i2'), |
|
57 | 57 | ('nDstflag','<i2'), |
|
58 | 58 | ('nErrorCount','<u4') |
|
59 | 59 | ]) |
|
60 | 60 | |
|
61 | 61 | def __init__(self): |
|
62 | 62 | pass |
|
63 | 63 | |
|
64 | 64 | def read(self, fp): |
|
65 | 65 | |
|
66 | 66 | header = numpy.fromfile(fp, self.struct,1) |
|
67 | 67 | self.size = header['nSize'][0] |
|
68 | 68 | self.version = header['nVersion'][0] |
|
69 | 69 | self.dataBlock = header['nDataBlockId'][0] |
|
70 | 70 | self.utc = header['nUtime'][0] |
|
71 | 71 | self.miliSecond = header['nMilsec'][0] |
|
72 | 72 | self.timeZone = header['nTimezone'][0] |
|
73 | 73 | self.dstFlag = header['nDstflag'][0] |
|
74 | 74 | self.errorCount = header['nErrorCount'][0] |
|
75 | 75 | |
|
76 | 76 | return 1 |
|
77 | 77 | |
|
78 | 78 | def copy(self): |
|
79 | 79 | |
|
80 | 80 | obj = BasicHeader() |
|
81 | 81 | obj.size = self.size |
|
82 | 82 | |
|
83 | 83 | |
|
84 | 84 | return obj |
|
85 | 85 | |
|
86 | 86 | class SystemHeader: |
|
87 | 87 | size = 0 |
|
88 | 88 | numSamples = 0 |
|
89 | 89 | numProfiles = 0 |
|
90 | 90 | numChannels = 0 |
|
91 | 91 | adcResolution = 0 |
|
92 | 92 | pciDioBusWidth = 0 |
|
93 | 93 | struct = numpy.dtype([ |
|
94 | 94 | ('nSize','<u4'), |
|
95 | 95 | ('nNumSamples','<u4'), |
|
96 | 96 | ('nNumProfiles','<u4'), |
|
97 | 97 | ('nNumChannels','<u4'), |
|
98 | 98 | ('nADCResolution','<u4'), |
|
99 | 99 | ('nPCDIOBusWidth','<u4'), |
|
100 | 100 | ]) |
|
101 | 101 | |
|
102 | 102 | def __init__(self): |
|
103 | 103 | pass |
|
104 | 104 | |
|
105 | 105 | def read(self, fp): |
|
106 | 106 | header = numpy.fromfile(fp,self.struct,1) |
|
107 | 107 | self.size = header['nSize'][0] |
|
108 | 108 | self.numSamples = header['nNumSamples'][0] |
|
109 | 109 | self.numProfiles = header['nNumProfiles'][0] |
|
110 | 110 | self.numChannels = header['nNumChannels'][0] |
|
111 | 111 | self.adcResolution = header['nADCResolution'][0] |
|
112 | 112 | self.pciDioBusWidth = header['nPCDIOBusWidth'][0] |
|
113 | 113 | |
|
114 | 114 | |
|
115 | 115 | return 1 |
|
116 | ||
|
117 | def copy(self): | |
|
118 | ||
|
119 | obj = SystemHeader() | |
|
120 | obj.size = self.size | |
|
121 | ||
|
122 | ||
|
123 | return obj | |
|
116 | 124 | |
|
117 | 125 | class RadarControllerHeader: |
|
118 | 126 | size = 0 |
|
119 | 127 | expType = 0 |
|
120 | 128 | nTx = 0 |
|
121 | 129 | ipp = 0 |
|
122 | 130 | txA = 0 |
|
123 | 131 | txB = 0 |
|
124 | 132 | numWindows = 0 |
|
125 | 133 | numTaus = 0 |
|
126 | 134 | codeType = 0 |
|
127 | 135 | line6Function = 0 |
|
128 | 136 | line5Fuction = 0 |
|
129 | 137 | fClock = 0 |
|
130 | 138 | prePulseBefore = 0 |
|
131 | 139 | prePulserAfter = 0 |
|
132 | 140 | rangeIpp = 0 |
|
133 | 141 | rangeTxA = 0 |
|
134 | 142 | rangeTxB = 0 |
|
135 | 143 | struct = numpy.dtype([ |
|
136 | 144 | ('nSize','<u4'), |
|
137 | 145 | ('nExpType','<u4'), |
|
138 | 146 | ('nNTx','<u4'), |
|
139 | 147 | ('fIpp','<f4'), |
|
140 | 148 | ('fTxA','<f4'), |
|
141 | 149 | ('fTxB','<f4'), |
|
142 | 150 | ('nNumWindows','<u4'), |
|
143 | 151 | ('nNumTaus','<u4'), |
|
144 | 152 | ('nCodeType','<u4'), |
|
145 | 153 | ('nLine6Function','<u4'), |
|
146 | 154 | ('nLine5Function','<u4'), |
|
147 | 155 | ('fClock','<f4'), |
|
148 | 156 | ('nPrePulseBefore','<u4'), |
|
149 | 157 | ('nPrePulseAfter','<u4'), |
|
150 | 158 | ('sRangeIPP','<a20'), |
|
151 | 159 | ('sRangeTxA','<a20'), |
|
152 | 160 | ('sRangeTxB','<a20'), |
|
153 | 161 | ]) |
|
154 | 162 | |
|
155 | 163 | |
|
156 | 164 | def __init__(self): |
|
157 | 165 | pass |
|
158 | 166 | |
|
159 | 167 | def read(self, fp): |
|
160 | 168 | header = numpy.fromfile(fp,self.struct,1) |
|
161 | 169 | self.size = header['nSize'][0] |
|
162 | 170 | self.expType = header['nExpType'][0] |
|
163 | 171 | self.nTx = header['nNTx'][0] |
|
164 | 172 | self.ipp = header['fIpp'][0] |
|
165 | 173 | self.txA = header['fTxA'][0] |
|
166 | 174 | self.txB = header['fTxB'][0] |
|
167 | 175 | self.numWindows = header['nNumWindows'][0] |
|
168 | 176 | self.numTaus = header['nNumTaus'][0] |
|
169 | 177 | self.codeType = header['nCodeType'][0] |
|
170 | 178 | self.line6Function = header['nLine6Function'][0] |
|
171 | 179 | self.line5Fuction = header['nLine5Function'][0] |
|
172 | 180 | self.fClock = header['fClock'][0] |
|
173 | 181 | self.prePulseBefore = header['nPrePulseBefore'][0] |
|
174 | 182 | self.prePulserAfter = header['nPrePulseAfter'][0] |
|
175 | 183 | self.rangeIpp = header['sRangeIPP'][0] |
|
176 | 184 | self.rangeTxA = header['sRangeTxA'][0] |
|
177 | 185 | self.rangeTxB = header['sRangeTxB'][0] |
|
178 | 186 | # jump Dynamic Radar Controller Header |
|
179 | 187 | jumpHeader = self.size - 116 |
|
180 | 188 | fp.seek(fp.tell() + jumpHeader) |
|
181 | 189 | |
|
182 | 190 | return 1 |
|
183 | 191 | |
|
192 | def copy(self): | |
|
193 | ||
|
194 | obj = RadarControllerHeader() | |
|
195 | obj.size = self.size | |
|
196 | ||
|
197 | ||
|
198 | return obj | |
|
199 | ||
|
184 | 200 | class ProcessingHeader: |
|
185 | 201 | size = 0 |
|
186 | 202 | dataType = 0 |
|
187 | 203 | blockSize = 0 |
|
188 | 204 | profilesPerBlock = 0 |
|
189 | 205 | dataBlocksPerFile = 0 |
|
190 | 206 | numWindows = 0 |
|
191 | 207 | processFlags = 0 |
|
192 | 208 | coherentInt = 0 |
|
193 | 209 | incoherentInt = 0 |
|
194 | 210 | totalSpectra = 0 |
|
195 | 211 | struct = numpy.dtype([ |
|
196 | 212 | ('nSize','<u4'), |
|
197 | 213 | ('nDataType','<u4'), |
|
198 | 214 | ('nSizeOfDataBlock','<u4'), |
|
199 | 215 | ('nProfilesperBlock','<u4'), |
|
200 | 216 | ('nDataBlocksperFile','<u4'), |
|
201 | 217 | ('nNumWindows','<u4'), |
|
202 | 218 | ('nProcessFlags','<u4'), |
|
203 | 219 | ('nCoherentIntegrations','<u4'), |
|
204 | 220 | ('nIncoherentIntegrations','<u4'), |
|
205 | 221 | ('nTotalSpectra','<u4') |
|
206 | 222 | ]) |
|
207 | 223 | samplingWindow = 0 |
|
208 | 224 | structSamplingWindow = numpy.dtype([('h0','<f4'),('dh','<f4'),('nsa','<u4')]) |
|
209 | 225 | numHeights = 0 |
|
210 | 226 | firstHeight = 0 |
|
211 | 227 | deltaHeight = 0 |
|
212 | 228 | samplesWin = 0 |
|
213 | 229 | spectraComb = 0 |
|
214 | 230 | numCode = 0 |
|
215 | 231 | codes = 0 |
|
216 | 232 | numBaud = 0 |
|
217 | 233 | |
|
218 | 234 | def __init__(self): |
|
219 | 235 | pass |
|
220 | 236 | |
|
221 | 237 | def read(self, fp): |
|
222 | 238 | header = numpy.fromfile(fp,self.struct,1) |
|
223 | 239 | self.size = header['nSize'][0] |
|
224 | 240 | self.dataType = header['nDataType'][0] |
|
225 | 241 | self.blockSize = header['nSizeOfDataBlock'][0] |
|
226 | 242 | self.profilesPerBlock = header['nProfilesperBlock'][0] |
|
227 | 243 | self.dataBlocksPerFile = header['nDataBlocksperFile'][0] |
|
228 | 244 | self.numWindows = header['nNumWindows'][0] |
|
229 | 245 | self.processFlags = header['nProcessFlags'] |
|
230 | 246 | self.coherentInt = header['nCoherentIntegrations'][0] |
|
231 | 247 | self.incoherentInt = header['nIncoherentIntegrations'][0] |
|
232 | 248 | self.totalSpectra = header['nTotalSpectra'][0] |
|
233 | 249 | self.samplingWindow = numpy.fromfile(fp,self.structSamplingWindow,self.numWindows) |
|
234 | 250 | self.numHeights = numpy.sum(self.samplingWindow['nsa']) |
|
235 | 251 | self.firstHeight = self.samplingWindow['h0'] |
|
236 | 252 | self.deltaHeight = self.samplingWindow['dh'] |
|
237 | 253 | self.samplesWin = self.samplingWindow['nsa'] |
|
238 | 254 | self.spectraComb = numpy.fromfile(fp,'u1',2*self.totalSpectra) |
|
239 | 255 | if self.processFlags & PROCFLAG.DEFINE_PROCESS_CODE == PROCFLAG.DEFINE_PROCESS_CODE: |
|
240 | 256 | self.numCode = numpy.fromfile(fp,'<u4',1) |
|
241 | 257 | self.numBaud = numpy.fromfile(fp,'<u4',1) |
|
242 | 258 | self.codes = numpy.fromfile(fp,'<f4',self.numCode*self.numBaud).reshape(self.numBaud,self.numCode) |
|
243 | 259 | |
|
244 | 260 | |
|
245 | return 1 No newline at end of file | |
|
261 | return 1 | |
|
262 | ||
|
263 | def copy(self): | |
|
264 | ||
|
265 | obj = ProcessingHeader() | |
|
266 | obj.size = self.size | |
|
267 | ||
|
268 | ||
|
269 | return obj No newline at end of file |
@@ -1,17 +1,20 | |||
|
1 | 1 | ''' |
|
2 | 2 | Created on Feb 7, 2012 |
|
3 | 3 | |
|
4 | 4 | @author: roj-idl71 |
|
5 | 5 | ''' |
|
6 | 6 | |
|
7 | 7 | class Correlation(Data): |
|
8 | 8 | ''' |
|
9 | 9 | classdocs |
|
10 | 10 | ''' |
|
11 | 11 | |
|
12 | 12 | |
|
13 | 13 | def __init__(self): |
|
14 | 14 | ''' |
|
15 | 15 | Constructor |
|
16 | 16 | ''' |
|
17 | pass | |
|
18 | ||
|
19 | def copy(self): | |
|
17 | 20 | pass No newline at end of file |
@@ -1,18 +1,21 | |||
|
1 | 1 | ''' |
|
2 | 2 | Created on Feb 7, 2012 |
|
3 | 3 | |
|
4 | 4 | @author: roj-idl71 |
|
5 | 5 | ''' |
|
6 | 6 | |
|
7 | 7 | class Data: |
|
8 | 8 | ''' |
|
9 | 9 | classdocs |
|
10 | 10 | ''' |
|
11 | 11 | |
|
12 | 12 | |
|
13 | 13 | def __init__(self): |
|
14 | 14 | ''' |
|
15 | 15 | Constructor |
|
16 | 16 | ''' |
|
17 | 17 | pass |
|
18 | ||
|
19 | def copy(self): | |
|
20 | pass | |
|
18 | 21 | No newline at end of file |
@@ -1,18 +1,21 | |||
|
1 | 1 | ''' |
|
2 | 2 | Created on Feb 7, 2012 |
|
3 | 3 | |
|
4 | 4 | @author: roj-idl71 |
|
5 | 5 | ''' |
|
6 | 6 | |
|
7 | 7 | class Spectra(Data): |
|
8 | 8 | ''' |
|
9 | 9 | classdocs |
|
10 | 10 | ''' |
|
11 | 11 | |
|
12 | 12 | |
|
13 | 13 | def __init__(self): |
|
14 | 14 | ''' |
|
15 | 15 | Constructor |
|
16 | 16 | ''' |
|
17 | 17 | pass |
|
18 | ||
|
19 | def copy(self): | |
|
20 | pass | |
|
18 | 21 | No newline at end of file |
@@ -1,18 +1,30 | |||
|
1 | 1 | ''' |
|
2 | 2 | Created on Feb 7, 2012 |
|
3 | 3 | |
|
4 | 4 | @author: roj-idl71 |
|
5 | 5 | ''' |
|
6 | 6 | |
|
7 | 7 | class Voltage(Data): |
|
8 | 8 | ''' |
|
9 | 9 | classdocs |
|
10 | 10 | ''' |
|
11 | 11 | |
|
12 | 12 | |
|
13 | m_RadarControllerHeader= RadarControllerHeader() | |
|
14 | ||
|
15 | m_ProcessingHeader= ProcessingHeader() | |
|
16 | ||
|
17 | m_SystemHeader= SystemHeader() | |
|
18 | ||
|
19 | m_BasicHeader= BasicHeader() | |
|
20 | ||
|
21 | ||
|
13 | 22 | def __init__(self): |
|
14 | 23 | ''' |
|
15 | 24 | Constructor |
|
16 | 25 | ''' |
|
17 | 26 | pass |
|
27 | ||
|
28 | def copy(self): | |
|
29 | pass | |
|
18 | 30 | No newline at end of file |
@@ -1,17 +1,17 | |||
|
1 | ''' | |
|
2 | Created on Feb 7, 2012 | |
|
3 | ||
|
4 | @author: roj-idl71 | |
|
5 | ''' | |
|
6 | ||
|
7 |
class CorrelationProcessor |
|
|
8 | ''' | |
|
9 | classdocs | |
|
10 | ''' | |
|
11 | ||
|
12 | ||
|
13 | def __init__(self): | |
|
14 | ''' | |
|
15 | Constructor | |
|
16 | ''' | |
|
1 | ''' | |
|
2 | Created on Feb 7, 2012 | |
|
3 | ||
|
4 | @author: roj-idl71 | |
|
5 | ''' | |
|
6 | ||
|
7 | class CorrelationProcessor: | |
|
8 | ''' | |
|
9 | classdocs | |
|
10 | ''' | |
|
11 | ||
|
12 | ||
|
13 | def __init__(self): | |
|
14 | ''' | |
|
15 | Constructor | |
|
16 | ''' | |
|
17 | 17 | pass No newline at end of file |
@@ -1,17 +1,17 | |||
|
1 | ''' | |
|
2 | Created on Feb 7, 2012 | |
|
3 | ||
|
4 | @author: roj-idl71 | |
|
5 | ''' | |
|
6 | ||
|
7 |
class SpectraProcessor |
|
|
8 | ''' | |
|
9 | classdocs | |
|
10 | ''' | |
|
11 | ||
|
12 | ||
|
13 | def __init__(self): | |
|
14 | ''' | |
|
15 | Constructor | |
|
16 | ''' | |
|
1 | ''' | |
|
2 | Created on Feb 7, 2012 | |
|
3 | ||
|
4 | @author: roj-idl71 | |
|
5 | ''' | |
|
6 | ||
|
7 | class SpectraProcessor: | |
|
8 | ''' | |
|
9 | classdocs | |
|
10 | ''' | |
|
11 | ||
|
12 | ||
|
13 | def __init__(self): | |
|
14 | ''' | |
|
15 | Constructor | |
|
16 | ''' | |
|
17 | 17 | pass No newline at end of file |
@@ -1,17 +1,17 | |||
|
1 | ''' | |
|
2 | Created on Feb 7, 2012 | |
|
3 | ||
|
4 | @author: roj-idl71 | |
|
5 | ''' | |
|
6 | ||
|
7 |
class VoltageProcessor |
|
|
8 | ''' | |
|
9 | classdocs | |
|
10 | ''' | |
|
11 | ||
|
12 | ||
|
13 | def __init__(self): | |
|
14 | ''' | |
|
15 | Constructor | |
|
16 | ''' | |
|
1 | ''' | |
|
2 | Created on Feb 7, 2012 | |
|
3 | ||
|
4 | @author: roj-idl71 | |
|
5 | ''' | |
|
6 | ||
|
7 | class VoltageProcessor: | |
|
8 | ''' | |
|
9 | classdocs | |
|
10 | ''' | |
|
11 | ||
|
12 | ||
|
13 | def __init__(self): | |
|
14 | ''' | |
|
15 | Constructor | |
|
16 | ''' | |
|
17 | 17 | pass No newline at end of file |
@@ -1,18 +1,18 | |||
|
1 | ''' | |
|
2 | Created on Feb 7, 2012 | |
|
3 | ||
|
4 | @author: roj-idl71 | |
|
5 | ''' | |
|
6 | ||
|
7 |
class FtpServer |
|
|
8 | ''' | |
|
9 | classdocs | |
|
10 | ''' | |
|
11 | ||
|
12 | ||
|
13 | def __init__(self): | |
|
14 | ''' | |
|
15 | Constructor | |
|
16 | ''' | |
|
17 | pass | |
|
1 | ''' | |
|
2 | Created on Feb 7, 2012 | |
|
3 | ||
|
4 | @author: roj-idl71 | |
|
5 | ''' | |
|
6 | ||
|
7 | class FtpServer: | |
|
8 | ''' | |
|
9 | classdocs | |
|
10 | ''' | |
|
11 | ||
|
12 | ||
|
13 | def __init__(self): | |
|
14 | ''' | |
|
15 | Constructor | |
|
16 | ''' | |
|
17 | pass | |
|
18 | 18 | No newline at end of file |
@@ -1,17 +1,19 | |||
|
1 | ''' | |
|
2 | Created on Feb 7, 2012 | |
|
3 | ||
|
4 | @author: roj-idl71 | |
|
5 | ''' | |
|
6 | ||
|
7 |
class FtpServerList |
|
|
8 | ''' | |
|
9 | classdocs | |
|
10 | ''' | |
|
11 | ||
|
12 | ||
|
13 | def __init__(self): | |
|
14 | ''' | |
|
15 | Constructor | |
|
16 | ''' | |
|
17 | pass No newline at end of file | |
|
1 | ''' | |
|
2 | Created on Feb 7, 2012 | |
|
3 | ||
|
4 | @author: roj-idl71 | |
|
5 | ''' | |
|
6 | ||
|
7 | class FtpServerList: | |
|
8 | ''' | |
|
9 | classdocs | |
|
10 | ''' | |
|
11 | ||
|
12 | ||
|
13 | def __init__(self): | |
|
14 | ''' | |
|
15 | Constructor | |
|
16 | ''' | |
|
17 | pass | |
|
18 | m_FtpServer= FtpServer() | |
|
19 |
General Comments 0
You need to be logged in to leave comments.
Login now