##// END OF EJS Templates
Adicion de directorios de procesamiento y utilitarios
Miguel Valdez -
r10:9523c526b618
parent child
Show More
This diff has been collapsed as it changes many lines, (710 lines changed) Show them Hide them
@@ -1,355 +1,355
1 import numpy
1 import numpy
2 import plplot
2 import plplot
3
3
4 def cmap1_init(colormap="gray"):
4 def cmap1_init(colormap="gray"):
5
5
6 ncolor = None
6 ncolor = None
7 rgb_lvl = None
7 rgb_lvl = None
8
8
9 # Routine for defining a specific color map 1 in HLS space.
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.
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).
11 # otherwise use false color variation from blue (240 deg) to red (360 deg).
12
12
13 # Independent variable of control points.
13 # Independent variable of control points.
14 i = numpy.array((0., 1.))
14 i = numpy.array((0., 1.))
15 if colormap=="gray":
15 if colormap=="gray":
16 ncolor = 256
16 ncolor = 256
17 # Hue for control points. Doesn't matter since saturation is zero.
17 # Hue for control points. Doesn't matter since saturation is zero.
18 h = numpy.array((0., 0.))
18 h = numpy.array((0., 0.))
19 # Lightness ranging from half-dark (for interest) to light.
19 # Lightness ranging from half-dark (for interest) to light.
20 l = numpy.array((0.5, 1.))
20 l = numpy.array((0.5, 1.))
21 # Gray scale has zero saturation
21 # Gray scale has zero saturation
22 s = numpy.array((0., 0.))
22 s = numpy.array((0., 0.))
23
23
24 # number of cmap1 colours is 256 in this case.
24 # number of cmap1 colours is 256 in this case.
25 plplot.plscmap1n(ncolor)
25 plplot.plscmap1n(ncolor)
26 # Interpolate between control points to set up cmap1.
26 # Interpolate between control points to set up cmap1.
27 plplot.plscmap1l(0, i, h, l, s)
27 plplot.plscmap1l(0, i, h, l, s)
28
28
29 return None
29 return None
30
30
31 if colormap=="br_green":
31 if colormap=="br_green":
32 ncolor = 256
32 ncolor = 256
33 # Hue ranges from blue (240 deg) to red (0 or 360 deg)
33 # Hue ranges from blue (240 deg) to red (0 or 360 deg)
34 h = numpy.array((240., 0.))
34 h = numpy.array((240., 0.))
35 # Lightness and saturation are constant (values taken from C example).
35 # Lightness and saturation are constant (values taken from C example).
36 l = numpy.array((0.6, 0.6))
36 l = numpy.array((0.6, 0.6))
37 s = numpy.array((0.8, 0.8))
37 s = numpy.array((0.8, 0.8))
38
38
39 # number of cmap1 colours is 256 in this case.
39 # number of cmap1 colours is 256 in this case.
40 plplot.plscmap1n(ncolor)
40 plplot.plscmap1n(ncolor)
41 # Interpolate between control points to set up cmap1.
41 # Interpolate between control points to set up cmap1.
42 plplot.plscmap1l(0, i, h, l, s)
42 plplot.plscmap1l(0, i, h, l, s)
43
43
44 return None
44 return None
45
45
46 if colormap=="tricolor":
46 if colormap=="tricolor":
47 ncolor = 3
47 ncolor = 3
48 # Hue ranges from blue (240 deg) to red (0 or 360 deg)
48 # Hue ranges from blue (240 deg) to red (0 or 360 deg)
49 h = numpy.array((240., 0.))
49 h = numpy.array((240., 0.))
50 # Lightness and saturation are constant (values taken from C example).
50 # Lightness and saturation are constant (values taken from C example).
51 l = numpy.array((0.6, 0.6))
51 l = numpy.array((0.6, 0.6))
52 s = numpy.array((0.8, 0.8))
52 s = numpy.array((0.8, 0.8))
53
53
54 # number of cmap1 colours is 256 in this case.
54 # number of cmap1 colours is 256 in this case.
55 plplot.plscmap1n(ncolor)
55 plplot.plscmap1n(ncolor)
56 # Interpolate between control points to set up cmap1.
56 # Interpolate between control points to set up cmap1.
57 plplot.plscmap1l(0, i, h, l, s)
57 plplot.plscmap1l(0, i, h, l, s)
58
58
59 return None
59 return None
60
60
61 if colormap == 'rgb' or colormap == 'rgb666':
61 if colormap == 'rgb' or colormap == 'rgb666':
62
62
63 color_sz = 6
63 color_sz = 6
64 ncolor = color_sz*color_sz*color_sz
64 ncolor = color_sz*color_sz*color_sz
65 pos = numpy.zeros((ncolor))
65 pos = numpy.zeros((ncolor))
66 r = numpy.zeros((ncolor))
66 r = numpy.zeros((ncolor))
67 g = numpy.zeros((ncolor))
67 g = numpy.zeros((ncolor))
68 b = numpy.zeros((ncolor))
68 b = numpy.zeros((ncolor))
69 ind = 0
69 ind = 0
70 for ri in range(color_sz):
70 for ri in range(color_sz):
71 for gi in range(color_sz):
71 for gi in range(color_sz):
72 for bi in range(color_sz):
72 for bi in range(color_sz):
73 r[ind] = ri/(color_sz-1.0)
73 r[ind] = ri/(color_sz-1.0)
74 g[ind] = gi/(color_sz-1.0)
74 g[ind] = gi/(color_sz-1.0)
75 b[ind] = bi/(color_sz-1.0)
75 b[ind] = bi/(color_sz-1.0)
76 pos[ind] = ind/(ncolor-1.0)
76 pos[ind] = ind/(ncolor-1.0)
77 ind += 1
77 ind += 1
78 rgb_lvl = [6,6,6] #Levels for RGB colors
78 rgb_lvl = [6,6,6] #Levels for RGB colors
79
79
80 if colormap == 'rgb676':
80 if colormap == 'rgb676':
81 ncolor = 6*7*6
81 ncolor = 6*7*6
82 pos = numpy.zeros((ncolor))
82 pos = numpy.zeros((ncolor))
83 r = numpy.zeros((ncolor))
83 r = numpy.zeros((ncolor))
84 g = numpy.zeros((ncolor))
84 g = numpy.zeros((ncolor))
85 b = numpy.zeros((ncolor))
85 b = numpy.zeros((ncolor))
86 ind = 0
86 ind = 0
87 for ri in range(8):
87 for ri in range(8):
88 for gi in range(8):
88 for gi in range(8):
89 for bi in range(4):
89 for bi in range(4):
90 r[ind] = ri/(6-1.0)
90 r[ind] = ri/(6-1.0)
91 g[ind] = gi/(7-1.0)
91 g[ind] = gi/(7-1.0)
92 b[ind] = bi/(6-1.0)
92 b[ind] = bi/(6-1.0)
93 pos[ind] = ind/(ncolor-1.0)
93 pos[ind] = ind/(ncolor-1.0)
94 ind += 1
94 ind += 1
95 rgb_lvl = [6,7,6] #Levels for RGB colors
95 rgb_lvl = [6,7,6] #Levels for RGB colors
96
96
97 if colormap == 'rgb685':
97 if colormap == 'rgb685':
98 ncolor = 6*8*5
98 ncolor = 6*8*5
99 pos = numpy.zeros((ncolor))
99 pos = numpy.zeros((ncolor))
100 r = numpy.zeros((ncolor))
100 r = numpy.zeros((ncolor))
101 g = numpy.zeros((ncolor))
101 g = numpy.zeros((ncolor))
102 b = numpy.zeros((ncolor))
102 b = numpy.zeros((ncolor))
103 ind = 0
103 ind = 0
104 for ri in range(8):
104 for ri in range(8):
105 for gi in range(8):
105 for gi in range(8):
106 for bi in range(4):
106 for bi in range(4):
107 r[ind] = ri/(6-1.0)
107 r[ind] = ri/(6-1.0)
108 g[ind] = gi/(8-1.0)
108 g[ind] = gi/(8-1.0)
109 b[ind] = bi/(5-1.0)
109 b[ind] = bi/(5-1.0)
110 pos[ind] = ind/(ncolor-1.0)
110 pos[ind] = ind/(ncolor-1.0)
111 ind += 1
111 ind += 1
112 rgb_lvl = [6,8,5] #Levels for RGB colors
112 rgb_lvl = [6,8,5] #Levels for RGB colors
113
113
114 if colormap == 'rgb884':
114 if colormap == 'rgb884':
115 ncolor = 8*8*4
115 ncolor = 8*8*4
116 pos = numpy.zeros((ncolor))
116 pos = numpy.zeros((ncolor))
117 r = numpy.zeros((ncolor))
117 r = numpy.zeros((ncolor))
118 g = numpy.zeros((ncolor))
118 g = numpy.zeros((ncolor))
119 b = numpy.zeros((ncolor))
119 b = numpy.zeros((ncolor))
120 ind = 0
120 ind = 0
121 for ri in range(8):
121 for ri in range(8):
122 for gi in range(8):
122 for gi in range(8):
123 for bi in range(4):
123 for bi in range(4):
124 r[ind] = ri/(8-1.0)
124 r[ind] = ri/(8-1.0)
125 g[ind] = gi/(8-1.0)
125 g[ind] = gi/(8-1.0)
126 b[ind] = bi/(4-1.0)
126 b[ind] = bi/(4-1.0)
127 pos[ind] = ind/(ncolor-1.0)
127 pos[ind] = ind/(ncolor-1.0)
128 ind += 1
128 ind += 1
129 rgb_lvl = [8,8,4] #Levels for RGB colors
129 rgb_lvl = [8,8,4] #Levels for RGB colors
130
130
131 if ncolor == None:
131 if ncolor == None:
132 raise ValueError, "The colormap selected is not valid"
132 raise ValueError, "The colormap selected is not valid"
133
133
134 plplot.plscmap1n(ncolor)
134 plplot.plscmap1n(ncolor)
135 plplot.plscmap1l(1, pos, r, g, b)
135 plplot.plscmap1l(1, pos, r, g, b)
136
136
137 return rgb_lvl
137 return rgb_lvl
138
138
139 class BasicGraph:
139 class BasicGraph:
140 """
140 """
141
141
142 """
142 """
143
143
144 hasRange = False
144 hasRange = False
145
145
146 xrange = None
146 xrange = None
147 yrange = None
147 yrange = None
148 zrange = None
148 zrange = None
149
149
150 xlabel = None
150 xlabel = None
151 ylabel = None
151 ylabel = None
152 title = None
152 title = None
153
153
154 legends = None
154 legends = None
155
155
156 __name = None
156 __name = None
157 __subpage = None
157 __subpage = None
158 __szchar = None
158 __szchar = None
159
159
160 __colormap = None
160 __colormap = None
161 __colbox = None
161 __colbox = None
162 __colleg = None
162 __colleg = None
163
163
164 __xpos = None
164 __xpos = None
165 __ypos = None
165 __ypos = None
166
166
167 __xopt = None #"bcnst"
167 __xopt = None #"bcnst"
168 __yopt = None #"bcnstv"
168 __yopt = None #"bcnstv"
169
169
170 __xlpos = None
170 __xlpos = None
171 __ylpos = None
171 __ylpos = None
172
172
173 __xrangeIsTime = None
173 __xrangeIsTime = None
174
174
175 #Advanced
175 #Advanced
176 __xg = None
176 __xg = None
177 __yg = None
177 __yg = None
178
178
179 def __init__(self):
179 def __init__(self):
180 """
180 """
181
181
182 """
182 """
183 pass
183 pass
184
184
185 def hasNotXrange(self):
185 def hasNotXrange(self):
186
186
187 if self.xrange == None:
187 if self.xrange == None:
188 return 1
188 return 1
189
189
190 return 0
190 return 0
191
191
192 def hasNotYrange(self):
192 def hasNotYrange(self):
193
193
194 if self.yrange == None:
194 if self.yrange == None:
195 return 1
195 return 1
196
196
197 return 0
197 return 0
198
198
199 def hasNotZrange(self):
199 def hasNotZrange(self):
200
200
201 if self.zrange == None:
201 if self.zrange == None:
202 return 1
202 return 1
203
203
204 return 0
204 return 0
205 def setName(self, name):
205 def setName(self, name):
206 self.__name = name
206 self.__name = name
207
207
208 def setScreenPos(self, xpos, ypos):
208 def setScreenPos(self, xpos, ypos):
209 self.__xpos = xpos
209 self.__xpos = xpos
210 self.__ypos = ypos
210 self.__ypos = ypos
211
211
212 def setScreenPosbyWidth(self, xoff, yoff, xw, yw):
212 def setScreenPosbyWidth(self, xoff, yoff, xw, yw):
213 self.__xpos = [xoff, xoff + xw]
213 self.__xpos = [xoff, xoff + xw]
214 self.__ypos = [yoff, yoff + yw]
214 self.__ypos = [yoff, yoff + yw]
215
215
216 def setSubpage(self, subpage):
216 def setSubpage(self, subpage):
217 self.__subpage = subpage
217 self.__subpage = subpage
218
218
219 def setSzchar(self, szchar):
219 def setSzchar(self, szchar):
220 self.__szchar = szchar
220 self.__szchar = szchar
221
221
222 def setOpt(self, xopt, yopt):
222 def setOpt(self, xopt, yopt):
223 self.__xopt = xopt
223 self.__xopt = xopt
224 self.__yopt = yopt
224 self.__yopt = yopt
225
225
226 def setRanges(self, xrange, yrange, zrange=None):
226 def setRanges(self, xrange, yrange, zrange=None):
227 """
227 """
228 """
228 """
229 self.xrange = xrange
229 self.xrange = xrange
230
230
231 self.yrange = yrange
231 self.yrange = yrange
232
232
233 if zrange != None:
233 if zrange != None:
234 self.zrange = zrange
234 self.zrange = zrange
235
235
236 def setColormap(self, colormap=None):
236 def setColormap(self, colormap=None):
237
237
238 if colormap == None:
238 if colormap == None:
239 colormap = self.__colormap
239 colormap = self.__colormap
240
240
241 cmap1_init(colormap)
241 cmap1_init(colormap)
242
242
243 def plotBox(self):
243 def plotBox(self):
244 """
244 """
245
245
246 """
246 """
247 plplot.plvpor(self.__xpos[0], self.__xpos[1], self.__ypos[0], self.__ypos[1])
247 plplot.plvpor(self.__xpos[0], self.__xpos[1], self.__ypos[0], self.__ypos[1])
248 plplot.plwind(self.xrange[0], self.xrange[1], self.yrange[0], self.yrange[1])
248 plplot.plwind(self.xrange[0], self.xrange[1], self.yrange[0], self.yrange[1])
249 plplot.plbox(self.__xopt, 0.0, 0, self.__yopt, 0.0, 0)
249 plplot.plbox(self.__xopt, 0.0, 0, self.__yopt, 0.0, 0)
250 plplot.pllab(self.xlabel, self.ylabel, self.title)
250 plplot.pllab(self.xlabel, self.ylabel, self.title)
251
251
252 def setup(self, title=None, xlabel=None, ylabel=None, colormap=None):
252 def setup(self, title=None, xlabel=None, ylabel=None, colormap=None):
253 """
253 """
254 """
254 """
255 self.title = title
255 self.title = title
256 self.xlabel = xlabel
256 self.xlabel = xlabel
257 self.ylabel = ylabel
257 self.ylabel = ylabel
258 self.__colormap = colormap
258 self.__colormap = colormap
259
259
260 def initSubpage(self):
260 def initSubpage(self):
261
261
262 if plplot.plgdev() == '':
262 if plplot.plgdev() == '':
263 raise ValueError, "Plot device has not been initialize"
263 raise ValueError, "Plot device has not been initialize"
264
264
265 plplot.pladv(self.__subpage)
265 plplot.pladv(self.__subpage)
266 plplot.plschr(0.0, self.__szchar)
266 plplot.plschr(0.0, self.__szchar)
267
267
268 if self.__xrangeIsTime:
268 if self.__xrangeIsTime:
269 plplot.pltimefmt("%H:%M")
269 plplot.pltimefmt("%H:%M")
270
270
271 self.setColormap()
271 self.setColormap()
272 self.initPlot()
272 self.initPlot()
273
273
274 def initPlot(self):
274 def initPlot(self):
275 """
275 """
276
276
277 """
277 """
278 if plplot.plgdev() == '':
278 if plplot.plgdev() == '':
279 raise ValueError, "Plot device has not been initialize"
279 raise ValueError, "Plot device has not been initialize"
280
280
281 xrange = self.xrange
281 xrange = self.xrange
282 if xrange == None:
282 if xrange == None:
283 xrange = [0., 1.]
283 xrange = [0., 1.]
284
284
285 yrange = self.yrange
285 yrange = self.yrange
286 if yrange == None:
286 if yrange == None:
287 yrange = [0., 1.]
287 yrange = [0., 1.]
288
288
289 plplot.plvpor(self.__xpos[0], self.__xpos[1], self.__ypos[0], self.__ypos[1])
289 plplot.plvpor(self.__xpos[0], self.__xpos[1], self.__ypos[0], self.__ypos[1])
290 plplot.plwind(xrange[0], xrange[1], yrange[0], yrange[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)
291 plplot.plbox(self.__xopt, 0.0, 0, self.__yopt, 0.0, 0)
292 plplot.pllab(self.xlabel, self.ylabel, self.title)
292 plplot.pllab(self.xlabel, self.ylabel, self.title)
293
293
294 def colorbarPlot(self):
294 def colorbarPlot(self):
295 data = numpy.arange(256)
295 data = numpy.arange(256)
296 data = numpy.reshape(data, (1,-1))
296 data = numpy.reshape(data, (1,-1))
297
297
298 self.plotBox()
298 self.plotBox()
299 plplot.plimage(data,
299 plplot.plimage(data,
300 self.xrange[0],
300 self.xrange[0],
301 self.xrange[1],
301 self.xrange[1],
302 self.yrange[0],
302 self.yrange[0],
303 self.yrange[1],
303 self.yrange[1],
304 0.,
304 0.,
305 255.,
305 255.,
306 self.xrange[0],
306 self.xrange[0],
307 self.xrange[1],
307 self.xrange[1],
308 self.yrange[0],
308 self.yrange[0],
309 self.yrange[1],)
309 self.yrange[1],)
310
310
311 def basicXYPlot(self, x, y):
311 def basicXYPlot(self, x, y):
312 self.plotBox()
312 self.plotBox()
313 plplot.plline(x, y)
313 plplot.plline(x, y)
314
314
315 def basicXYwithErrorPlot(self):
315 def basicXYwithErrorPlot(self):
316 pass
316 pass
317
317
318 def basicLineTimePlot(self):
318 def basicLineTimePlot(self):
319 pass
319 pass
320
320
321 def basicPcolorPlot(self, data, xmin, xmax, ymin, ymax, zmin, zmax):
321 def basicPcolorPlot(self, data, xmin, xmax, ymin, ymax, zmin, zmax):
322 """
322 """
323 """
323 """
324
324
325 self.plotBox()
325 self.plotBox()
326 plplot.plimage(data, xmin, xmax, ymin, ymax, zmin, zmax, xmin, xmax, ymin, ymax)
326 plplot.plimage(data, xmin, xmax, ymin, ymax, zmin, zmax, xmin, xmax, ymin, ymax)
327
327
328
328
329 def __getBoxpltr(self, x, y, deltax=None, deltay=None):
329 def __getBoxpltr(self, x, y, deltax=None, deltay=None):
330
330
331 if not(len(x)>1 and len(y)>1):
331 if not(len(x)>1 and len(y)>1):
332 raise ValueError, "x axis and y axis are empty"
332 raise ValueError, "x axis and y axis are empty"
333
333
334 if deltax == None: deltax = x[-1] - x[-2]
334 if deltax == None: deltax = x[-1] - x[-2]
335 if deltay == None: deltay = y[-1] - y[-2]
335 if deltay == None: deltay = y[-1] - y[-2]
336
336
337 x1 = numpy.append(x, x[-1] + deltax)
337 x1 = numpy.append(x, x[-1] + deltax)
338 y1 = numpy.append(y, y[-1] + deltay)
338 y1 = numpy.append(y, y[-1] + deltay)
339
339
340 xg = (numpy.multiply.outer(x1, numpy.ones(len(y1))))
340 xg = (numpy.multiply.outer(x1, numpy.ones(len(y1))))
341 yg = (numpy.multiply.outer(numpy.ones(len(x1)), y1))
341 yg = (numpy.multiply.outer(numpy.ones(len(x1)), y1))
342
342
343 self.__xg = xg
343 self.__xg = xg
344 self.__yg = yg
344 self.__yg = yg
345
345
346 def advPcolorPlot(self, data, x, y, zmin=0., zmax=0.):
346 def advPcolorPlot(self, data, x, y, zmin=0., zmax=0.):
347 """
347 """
348 """
348 """
349
349
350 if self.__xg == None and self.__yg == None:
350 if self.__xg == None and self.__yg == None:
351 self.__getBoxpltr(x, y)
351 self.__getBoxpltr(x, y)
352
352
353 plplot.plimagefr(data, x[0], x[-1], y[0], y[-1], 0., 0., zmin, zmax, plplot.pltr2, self.__xg, self.__yg)
353 plplot.plimagefr(data, x[0], x[-1], y[0], y[-1], 0., 0., zmin, zmax, plplot.pltr2, self.__xg, self.__yg)
354
354
355
355
@@ -1,213 +1,213
1 import numpy
1 import numpy
2 import plplot
2 import plplot
3
3
4 from BasicGraph import *
4 from BasicGraph import *
5
5
6 class Spectrum():
6 class Spectrum:
7
7
8 graphObjDict = {}
8 graphObjDict = {}
9 showColorbar = False
9 showColorbar = False
10 showPowerProfile = True
10 showPowerProfile = True
11
11
12 __szchar = 0.7
12 __szchar = 0.7
13
13
14 def __init__(self):
14 def __init__(self):
15
15
16 key = "spec"
16 key = "spec"
17
17
18 specObj = BasicGraph()
18 specObj = BasicGraph()
19 specObj.setName(key)
19 specObj.setName(key)
20
20
21 self.graphObjDict[key] = specObj
21 self.graphObjDict[key] = specObj
22
22
23
23
24 def setup(self, subpage, title="", xlabel="", ylabel="", colormap="jet", showColorbar=False, showPowerProfile=False):
24 def setup(self, subpage, title="", xlabel="", ylabel="", colormap="jet", showColorbar=False, showPowerProfile=False):
25 """
25 """
26 """
26 """
27
27
28 xi = 0.12; xw = 0.78; xf = xi + xw
28 xi = 0.12; xw = 0.78; xf = xi + xw
29 yi = 0.14; yw = 0.80; yf = yi + yw
29 yi = 0.14; yw = 0.80; yf = yi + yw
30
30
31 xcmapi = xcmapf = 0.; xpowi = xpowf = 0.
31 xcmapi = xcmapf = 0.; xpowi = xpowf = 0.
32
32
33 key = "spec"
33 key = "spec"
34 specObj = self.graphObjDict[key]
34 specObj = self.graphObjDict[key]
35 specObj.setSubpage(subpage)
35 specObj.setSubpage(subpage)
36 specObj.setSzchar(self.__szchar)
36 specObj.setSzchar(self.__szchar)
37 specObj.setOpt("bcnts","bcnts")
37 specObj.setOpt("bcnts","bcnts")
38 specObj.setup(title,
38 specObj.setup(title,
39 xlabel,
39 xlabel,
40 ylabel,
40 ylabel,
41 colormap)
41 colormap)
42
42
43 if showColorbar:
43 if showColorbar:
44 key = "colorbar"
44 key = "colorbar"
45
45
46 cmapObj = BasicGraph()
46 cmapObj = BasicGraph()
47 cmapObj.setName(key)
47 cmapObj.setName(key)
48 cmapObj.setSubpage(subpage)
48 cmapObj.setSubpage(subpage)
49 cmapObj.setSzchar(self.__szchar)
49 cmapObj.setSzchar(self.__szchar)
50 cmapObj.setOpt("bc","bcmt")
50 cmapObj.setOpt("bc","bcmt")
51 cmapObj.setup(title="dBs",
51 cmapObj.setup(title="dBs",
52 xlabel="",
52 xlabel="",
53 ylabel="",
53 ylabel="",
54 colormap=colormap)
54 colormap=colormap)
55
55
56 self.graphObjDict[key] = cmapObj
56 self.graphObjDict[key] = cmapObj
57
57
58 xcmapi = 0.
58 xcmapi = 0.
59 xcmapw = 0.05
59 xcmapw = 0.05
60 xw -= xcmapw
60 xw -= xcmapw
61
61
62 if showPowerProfile:
62 if showPowerProfile:
63 key = "powerprof"
63 key = "powerprof"
64
64
65 powObj = BasicGraph()
65 powObj = BasicGraph()
66 powObj.setName(key)
66 powObj.setName(key)
67 powObj.setSubpage(subpage)
67 powObj.setSubpage(subpage)
68 powObj.setSzchar(self.__szchar)
68 powObj.setSzchar(self.__szchar)
69 plplot.pllsty(2)
69 plplot.pllsty(2)
70 powObj.setOpt("bcntg","bc")
70 powObj.setOpt("bcntg","bc")
71 plplot.pllsty(1)
71 plplot.pllsty(1)
72 powObj.setup(title="Power Profile",
72 powObj.setup(title="Power Profile",
73 xlabel="dBs",
73 xlabel="dBs",
74 ylabel="")
74 ylabel="")
75
75
76 self.graphObjDict[key] = powObj
76 self.graphObjDict[key] = powObj
77
77
78 xpowi = 0.
78 xpowi = 0.
79 xpoww = 0.24
79 xpoww = 0.24
80 xw -= xpoww
80 xw -= xpoww
81
81
82 xf = xi + xw
82 xf = xi + xw
83 yf = yi + yw
83 yf = yi + yw
84 xcmapf = xf
84 xcmapf = xf
85
85
86 specObj.setScreenPos([xi, xf], [yi, yf])
86 specObj.setScreenPos([xi, xf], [yi, yf])
87
87
88 if showColorbar:
88 if showColorbar:
89 xcmapi = xf + 0.02
89 xcmapi = xf + 0.02
90 xcmapf = xcmapi + xcmapw
90 xcmapf = xcmapi + xcmapw
91 cmapObj.setScreenPos([xcmapi, xcmapf], [yi, yf])
91 cmapObj.setScreenPos([xcmapi, xcmapf], [yi, yf])
92
92
93 if showPowerProfile:
93 if showPowerProfile:
94 xpowi = xcmapf + 0.06
94 xpowi = xcmapf + 0.06
95 xpowf = xpowi + xpoww
95 xpowf = xpowi + xpoww
96 powObj.setScreenPos([xpowi, xpowf], [yi, yf])
96 powObj.setScreenPos([xpowi, xpowf], [yi, yf])
97
97
98
98
99 # specObj.initSubpage()
99 # specObj.initSubpage()
100 #
100 #
101 # if showColorbar:
101 # if showColorbar:
102 # cmapObj.initPlot()
102 # cmapObj.initPlot()
103 #
103 #
104 # if showPowerProfile:
104 # if showPowerProfile:
105 # powObj.initPlot()
105 # powObj.initPlot()
106
106
107 self.showColorbar = showColorbar
107 self.showColorbar = showColorbar
108 self.showPowerProfile = showPowerProfile
108 self.showPowerProfile = showPowerProfile
109
109
110 def setRanges(self, xrange, yrange, zrange):
110 def setRanges(self, xrange, yrange, zrange):
111
111
112 key = "spec"
112 key = "spec"
113 specObj = self.graphObjDict[key]
113 specObj = self.graphObjDict[key]
114 specObj.setRanges(xrange, yrange, zrange)
114 specObj.setRanges(xrange, yrange, zrange)
115
115
116 keyList = self.graphObjDict.keys()
116 keyList = self.graphObjDict.keys()
117
117
118 key = "colorbar"
118 key = "colorbar"
119 if key in keyList:
119 if key in keyList:
120 cmapObj = self.graphObjDict[key]
120 cmapObj = self.graphObjDict[key]
121 cmapObj.setRanges([0., 1.], zrange)
121 cmapObj.setRanges([0., 1.], zrange)
122
122
123 key = "powerprof"
123 key = "powerprof"
124 if key in keyList:
124 if key in keyList:
125 powObj = self.graphObjDict[key]
125 powObj = self.graphObjDict[key]
126 powObj.setRanges(zrange, yrange)
126 powObj.setRanges(zrange, yrange)
127
127
128 def plotData(self, data , xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None):
128 def plotData(self, data , xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None):
129
129
130 key = "spec"
130 key = "spec"
131 specObj = self.graphObjDict[key]
131 specObj = self.graphObjDict[key]
132 specObj.initSubpage()
132 specObj.initSubpage()
133
133
134 if xmin == None:
134 if xmin == None:
135 xmin = 0.
135 xmin = 0.
136
136
137 if xmax == None:
137 if xmax == None:
138 xmax = 1.
138 xmax = 1.
139
139
140 if ymin == None:
140 if ymin == None:
141 ymin = 0.
141 ymin = 0.
142
142
143 if ymax == None:
143 if ymax == None:
144 ymax = 1.
144 ymax = 1.
145
145
146 if zmin == None:
146 if zmin == None:
147 zmin = numpy.nanmin(data)
147 zmin = numpy.nanmin(data)
148
148
149 if zmax == None:
149 if zmax == None:
150 zmax = numpy.nanmax(data)
150 zmax = numpy.nanmax(data)
151
151
152 if not(specObj.hasRange):
152 if not(specObj.hasRange):
153 self.setRanges([xmin, xmax], [ymin,ymax], [zmin,zmax])
153 self.setRanges([xmin, xmax], [ymin,ymax], [zmin,zmax])
154
154
155 specObj.basicPcolorPlot(data, xmin, xmax, ymin, ymax, specObj.zrange[0], specObj.zrange[1])
155 specObj.basicPcolorPlot(data, xmin, xmax, ymin, ymax, specObj.zrange[0], specObj.zrange[1])
156
156
157 if self.showColorbar:
157 if self.showColorbar:
158 key = "colorbar"
158 key = "colorbar"
159 cmapObj = self.graphObjDict[key]
159 cmapObj = self.graphObjDict[key]
160 cmapObj.colorbarPlot()
160 cmapObj.colorbarPlot()
161
161
162 if self.showPowerProfile:
162 if self.showPowerProfile:
163 power = numpy.average(data, axis=1)
163 power = numpy.average(data, axis=1)
164
164
165 step = (ymax - ymin)/(power.shape[0]-1)
165 step = (ymax - ymin)/(power.shape[0]-1)
166 heis = numpy.arange(ymin, ymax + step, step)
166 heis = numpy.arange(ymin, ymax + step, step)
167
167
168 key = "powerprof"
168 key = "powerprof"
169 powObj = self.graphObjDict[key]
169 powObj = self.graphObjDict[key]
170 powObj.basicXYPlot(power, heis)
170 powObj.basicXYPlot(power, heis)
171
171
172 class CrossSpectrum():
172 class CrossSpectrum:
173 graphObjDict = {}
173 graphObjDict = {}
174 showColorbar = False
174 showColorbar = False
175 showPowerProfile = True
175 showPowerProfile = True
176
176
177 __szchar = 0.7
177 __szchar = 0.7
178 def __init__(self):
178 def __init__(self):
179 pass
179 pass
180
180
181 def setup(self):
181 def setup(self):
182 pass
182 pass
183
183
184 def plotData(self):
184 def plotData(self):
185 pass
185 pass
186
186
187 if __name__ == '__main__':
187 if __name__ == '__main__':
188
188
189 import numpy
189 import numpy
190 plplot.plsetopt("geometry", "%dx%d" %(350*2, 300*2))
190 plplot.plsetopt("geometry", "%dx%d" %(350*2, 300*2))
191 plplot.plsdev("xcairo")
191 plplot.plsdev("xcairo")
192 plplot.plscolbg(255,255,255)
192 plplot.plscolbg(255,255,255)
193 plplot.plscol0(1,0,0,0)
193 plplot.plscol0(1,0,0,0)
194 plplot.plinit()
194 plplot.plinit()
195 plplot.plssub(2, 2)
195 plplot.plssub(2, 2)
196
196
197 nx = 64
197 nx = 64
198 ny = 100
198 ny = 100
199
199
200 data = numpy.random.uniform(-50,50,(nx,ny))
200 data = numpy.random.uniform(-50,50,(nx,ny))
201
201
202 specObj = Spectrum()
202 specObj = Spectrum()
203 specObj.setup(1, "Spectrum", "Frequency", "Range", "br_green", False, False)
203 specObj.setup(1, "Spectrum", "Frequency", "Range", "br_green", False, False)
204 specObj.plotData(data)
204 specObj.plotData(data)
205
205
206 data = numpy.random.uniform(-50,50,(nx,ny))
206 data = numpy.random.uniform(-50,50,(nx,ny))
207
207
208 spec2Obj = Spectrum()
208 spec2Obj = Spectrum()
209 spec2Obj.setup(2, "Spectrum", "Frequency", "Range", "br_green", True, True)
209 spec2Obj.setup(2, "Spectrum", "Frequency", "Range", "br_green", True, True)
210 spec2Obj.plotData(data)
210 spec2Obj.plotData(data)
211
211
212 plplot.plend()
212 plplot.plend()
213 exit(0) No newline at end of file
213 exit(0)
@@ -113,6 +113,14 class SystemHeader:
113
113
114
114
115 return 1
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 class RadarControllerHeader:
125 class RadarControllerHeader:
118 size = 0
126 size = 0
@@ -181,6 +189,14 class RadarControllerHeader:
181
189
182 return 1
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 class ProcessingHeader:
200 class ProcessingHeader:
185 size = 0
201 size = 0
186 dataType = 0
202 dataType = 0
@@ -242,4 +258,12 class ProcessingHeader:
242 self.codes = numpy.fromfile(fp,'<f4',self.numCode*self.numBaud).reshape(self.numBaud,self.numCode)
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
@@ -14,4 +14,7 class Correlation(Data):
14 '''
14 '''
15 Constructor
15 Constructor
16 '''
16 '''
17 pass
18
19 def copy(self):
17 pass No newline at end of file
20 pass
@@ -15,4 +15,7 class Data:
15 Constructor
15 Constructor
16 '''
16 '''
17 pass
17 pass
18
19 def copy(self):
20 pass
18 No newline at end of file
21
@@ -15,4 +15,7 class Spectra(Data):
15 Constructor
15 Constructor
16 '''
16 '''
17 pass
17 pass
18
19 def copy(self):
20 pass
18 No newline at end of file
21
@@ -10,9 +10,21 class Voltage(Data):
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 def __init__(self):
22 def __init__(self):
14 '''
23 '''
15 Constructor
24 Constructor
16 '''
25 '''
17 pass
26 pass
27
28 def copy(self):
29 pass
18 No newline at end of file
30
@@ -1,17 +1,17
1 '''
1 '''
2 Created on Feb 7, 2012
2 Created on Feb 7, 2012
3
3
4 @author: roj-idl71
4 @author: roj-idl71
5 '''
5 '''
6
6
7 class CorrelationProcessor():
7 class CorrelationProcessor:
8 '''
8 '''
9 classdocs
9 classdocs
10 '''
10 '''
11
11
12
12
13 def __init__(self):
13 def __init__(self):
14 '''
14 '''
15 Constructor
15 Constructor
16 '''
16 '''
17 pass No newline at end of file
17 pass
@@ -1,17 +1,17
1 '''
1 '''
2 Created on Feb 7, 2012
2 Created on Feb 7, 2012
3
3
4 @author: roj-idl71
4 @author: roj-idl71
5 '''
5 '''
6
6
7 class SpectraProcessor():
7 class SpectraProcessor:
8 '''
8 '''
9 classdocs
9 classdocs
10 '''
10 '''
11
11
12
12
13 def __init__(self):
13 def __init__(self):
14 '''
14 '''
15 Constructor
15 Constructor
16 '''
16 '''
17 pass No newline at end of file
17 pass
@@ -1,17 +1,17
1 '''
1 '''
2 Created on Feb 7, 2012
2 Created on Feb 7, 2012
3
3
4 @author: roj-idl71
4 @author: roj-idl71
5 '''
5 '''
6
6
7 class VoltageProcessor():
7 class VoltageProcessor:
8 '''
8 '''
9 classdocs
9 classdocs
10 '''
10 '''
11
11
12
12
13 def __init__(self):
13 def __init__(self):
14 '''
14 '''
15 Constructor
15 Constructor
16 '''
16 '''
17 pass No newline at end of file
17 pass
@@ -1,18 +1,18
1 '''
1 '''
2 Created on Feb 7, 2012
2 Created on Feb 7, 2012
3
3
4 @author: roj-idl71
4 @author: roj-idl71
5 '''
5 '''
6
6
7 class FtpServer():
7 class FtpServer:
8 '''
8 '''
9 classdocs
9 classdocs
10 '''
10 '''
11
11
12
12
13 def __init__(self):
13 def __init__(self):
14 '''
14 '''
15 Constructor
15 Constructor
16 '''
16 '''
17 pass
17 pass
18 No newline at end of file
18
@@ -1,17 +1,19
1 '''
1 '''
2 Created on Feb 7, 2012
2 Created on Feb 7, 2012
3
3
4 @author: roj-idl71
4 @author: roj-idl71
5 '''
5 '''
6
6
7 class FtpServerList():
7 class FtpServerList:
8 '''
8 '''
9 classdocs
9 classdocs
10 '''
10 '''
11
11
12
12
13 def __init__(self):
13 def __init__(self):
14 '''
14 '''
15 Constructor
15 Constructor
16 '''
16 '''
17 pass No newline at end of file
17 pass
18 m_FtpServer= FtpServer()
19
General Comments 0
You need to be logged in to leave comments. Login now