@@ -1,529 +1,520 | |||||
1 | import numpy |
|
1 | import numpy | |
2 | import datetime |
|
2 | import datetime | |
3 | import time |
|
3 | import time | |
4 | from schainPlot import * |
|
4 | from schainPlot import * | |
5 |
|
5 | |||
6 | class SpcFigure(Figure): |
|
6 | class SpcFigure(Figure): | |
7 | overplot = 0 |
|
7 | overplot = 0 | |
8 | xw = 800 |
|
8 | xw = 800 | |
9 | yw = 650 |
|
9 | yw = 650 | |
10 | showprofile = False |
|
10 | showprofile = False | |
11 |
|
11 | |||
12 | def __init__(self, idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile): |
|
12 | def __init__(self, idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile): | |
13 | Figure.__init__(self,idfigure, nframes, wintitle, self.xw, self.yw, self.overplot, driver, colormap, colorbar) |
|
13 | Figure.__init__(self,idfigure, nframes, wintitle, self.xw, self.yw, self.overplot, driver, colormap, colorbar) | |
14 |
|
14 | |||
15 | self.showprofile = showprofile |
|
15 | self.showprofile = showprofile | |
16 |
|
16 | |||
17 | def getSubplots(self): |
|
17 | def getSubplots(self): | |
18 | ncolumns = int(numpy.sqrt(self.nframes)+0.9) |
|
18 | ncolumns = int(numpy.sqrt(self.nframes)+0.9) | |
19 | nrows = int(self.nframes*1./ncolumns + 0.9) |
|
19 | nrows = int(self.nframes*1./ncolumns + 0.9) | |
20 |
|
20 | |||
21 | return nrows, ncolumns |
|
21 | return nrows, ncolumns | |
22 |
|
22 | |||
23 | def setParms(self, data, x, y, xmin, xmax, ymin, ymax, minvalue, maxvalue, *args): |
|
23 | def setParms(self, data, x, y, xmin, xmax, ymin, ymax, minvalue, maxvalue, *args): | |
24 |
|
24 | |||
25 | if xmin == None: xmin = numpy.min(x) |
|
25 | if xmin == None: xmin = numpy.min(x) | |
26 | if xmax == None: xmax = numpy.max(x) |
|
26 | if xmax == None: xmax = numpy.max(x) | |
27 | if ymin == None: ymin = numpy.min(y) |
|
27 | if ymin == None: ymin = numpy.min(y) | |
28 | if ymax == None: ymax = numpy.max(y) |
|
28 | if ymax == None: ymax = numpy.max(y) | |
29 | if minvalue == None: minvalue = 20. |
|
29 | if minvalue == None: minvalue = 20. | |
30 | if maxvalue == None: maxvalue = 90. |
|
30 | if maxvalue == None: maxvalue = 90. | |
31 |
|
31 | |||
32 | self.xmin = xmin |
|
32 | self.xmin = xmin | |
33 | self.xmax = xmax |
|
33 | self.xmax = xmax | |
34 | self.minrange = ymin |
|
34 | self.minrange = ymin | |
35 | self.maxrange = ymax |
|
35 | self.maxrange = ymax | |
36 | self.ymin = ymin |
|
36 | self.ymin = ymin | |
37 | self.ymax = ymax |
|
37 | self.ymax = ymax | |
38 | self.minvalue = minvalue |
|
38 | self.minvalue = minvalue | |
39 | self.maxvalue = maxvalue |
|
39 | self.maxvalue = maxvalue | |
40 |
|
40 | |||
41 |
|
41 | |||
42 | def changeXRange(self, *args): |
|
42 | def changeXRange(self, *args): | |
43 | pass |
|
43 | pass | |
44 |
|
44 | |||
45 | def createFrames(self): |
|
45 | def createFrames(self): | |
46 | for frame in range(self.nframes): |
|
46 | for frame in range(self.nframes): | |
47 | frameObj = SpcFrame(self.drvObj,frame + 1, self.colorbar, self.showprofile) |
|
47 | frameObj = SpcFrame(self.drvObj,frame + 1, self.colorbar, self.showprofile) | |
48 | self.frameObjList.append(frameObj) |
|
48 | self.frameObjList.append(frameObj) | |
49 |
|
49 | |||
50 | class SpcFrame(Frame): |
|
50 | class SpcFrame(Frame): | |
51 | def __init__(self,drvObj,idframe,colorbar,showprofile): |
|
51 | def __init__(self,drvObj,idframe,colorbar,showprofile): | |
52 | self.drvObj = drvObj |
|
52 | self.drvObj = drvObj | |
53 | self.idframe = idframe |
|
53 | self.idframe = idframe | |
54 | self.nplots = 1 |
|
54 | self.nplots = 1 | |
55 |
|
55 | |||
56 | if showprofile: |
|
56 | if showprofile: | |
57 | self.nplots += 1 |
|
57 | self.nplots += 1 | |
58 |
|
58 | |||
59 | self.colorbar = colorbar |
|
59 | self.colorbar = colorbar | |
60 | self.showprofile = showprofile |
|
60 | self.showprofile = showprofile | |
61 | self.createPlots() |
|
61 | self.createPlots() | |
62 |
|
62 | |||
63 | def createPlots(self): |
|
63 | def createPlots(self): | |
64 | plotObjList = [] |
|
64 | plotObjList = [] | |
65 | idplot = 0 |
|
65 | idplot = 0 | |
66 | xi, yi, xw, yw = self.getScreenPos(idplot) |
|
66 | xi, yi, xw, yw = self.getScreenPos(idplot) | |
67 | plotObj = SpcPlot(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, self.colorbar) |
|
67 | plotObj = SpcPlot(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, self.colorbar) | |
68 | plotObjList.append(plotObj) |
|
68 | plotObjList.append(plotObj) | |
69 |
|
69 | |||
70 | if self.showprofile: |
|
70 | if self.showprofile: | |
71 | idplot = 1 |
|
71 | idplot = 1 | |
72 | xi, yi, xw, yw = self.getScreenPos(idplot) |
|
72 | xi, yi, xw, yw = self.getScreenPos(idplot) | |
73 | type = "pwbox" |
|
73 | type = "pwbox" | |
74 | title = "" |
|
74 | title = "" | |
75 | xlabel = "dB" |
|
75 | xlabel = "dB" | |
76 | ylabel = "" |
|
76 | ylabel = "" | |
77 | plotObj = Plot1D(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, type, title, xlabel, ylabel) |
|
77 | plotObj = Plot1D(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, type, title, xlabel, ylabel) | |
78 | plotObjList.append(plotObj) |
|
78 | plotObjList.append(plotObj) | |
79 |
|
79 | |||
80 | self.plotObjList = plotObjList |
|
80 | self.plotObjList = plotObjList | |
81 |
|
81 | |||
82 | def getScreenPosMainPlot(self): |
|
82 | def getScreenPosMainPlot(self): | |
83 | xi = 0.15 |
|
83 | xi = 0.15 | |
84 |
|
84 | |||
85 | if self.showprofile: |
|
85 | if self.showprofile: | |
86 | xw = 0.65 |
|
86 | xw = 0.65 | |
87 |
|
87 | |||
88 | else: |
|
88 | else: | |
89 | xw = 0.75 |
|
89 | xw = 0.75 | |
90 |
|
90 | |||
91 | if self.colorbar: |
|
91 | if self.colorbar: | |
92 | xw = xw - 0.06 |
|
92 | xw = xw - 0.06 | |
93 |
|
93 | |||
94 | yi = 0.20; yw = 0.75 |
|
94 | yi = 0.20; yw = 0.75 | |
95 |
|
95 | |||
96 | return xi, yi, xw, yw |
|
96 | return xi, yi, xw, yw | |
97 |
|
97 | |||
98 | def getScreenPosGraph1(self): |
|
98 | def getScreenPosGraph1(self): | |
99 | if self.colorbar: |
|
99 | if self.colorbar: | |
100 | xi = 0.65 + 0.08 |
|
100 | xi = 0.65 + 0.08 | |
101 | else: |
|
101 | else: | |
102 | xi = 0.75 + 0.05 |
|
102 | xi = 0.75 + 0.05 | |
103 |
|
103 | |||
104 | xw = xi + 0.2 |
|
104 | xw = xi + 0.2 | |
105 |
|
105 | |||
106 | yi = 0.2; yw = 0.75 |
|
106 | yi = 0.2; yw = 0.75 | |
107 |
|
107 | |||
108 | return xi, yi, xw, yw |
|
108 | return xi, yi, xw, yw | |
109 |
|
109 | |||
110 | def plot(self,x, y, data): |
|
110 | def plot(self,x, y, data): | |
111 | plotObj = self.plotObjList[0] |
|
111 | plotObj = self.plotObjList[0] | |
112 | plotObj.plot(x,y,data) |
|
112 | plotObj.plot(x,y,data) | |
113 |
|
113 | |||
114 | if self.showprofile: |
|
114 | if self.showprofile: | |
115 | plotObj = self.plotObjList[1] |
|
115 | plotObj = self.plotObjList[1] | |
116 | plotObj.plot(data,y) |
|
116 | plotObj.plot(data,y) | |
117 |
|
117 | |||
118 | class SpcPlot(Plot): |
|
118 | class SpcPlot(Plot): | |
119 |
|
119 | |||
120 | getGrid = True |
|
120 | getGrid = True | |
121 |
|
121 | |||
122 | def __init__(self, drvObj, idframe, idplot, xi, yi, xw, yw, colorbar): |
|
122 | def __init__(self, drvObj, idframe, idplot, xi, yi, xw, yw, colorbar): | |
123 | self.drvObj = drvObj |
|
123 | self.drvObj = drvObj | |
124 | self.idframe = idframe |
|
124 | self.idframe = idframe | |
125 | self.idplot = idplot |
|
125 | self.idplot = idplot | |
126 | self.xi = xi |
|
126 | self.xi = xi | |
127 | self.yi = yi |
|
127 | self.yi = yi | |
128 | self.xw = xw |
|
128 | self.xw = xw | |
129 | self.yw = yw |
|
129 | self.yw = yw | |
130 | self.colorbar = colorbar |
|
130 | self.colorbar = colorbar | |
131 |
|
131 | |||
132 | if self.colorbar: |
|
132 | if self.colorbar: | |
133 | cbxi = xw + 0.03 |
|
133 | cbxi = xw + 0.03 | |
134 | cbxw = cbxi + 0.03 |
|
134 | cbxw = cbxi + 0.03 | |
135 | cbyi = yi |
|
135 | cbyi = yi | |
136 | cbyw = yw |
|
136 | cbyw = yw | |
137 | self.cbxpos = [cbxi,cbxw] |
|
137 | self.cbxpos = [cbxi,cbxw] | |
138 | self.cbypos = [cbyi,cbyw] |
|
138 | self.cbypos = [cbyi,cbyw] | |
139 |
|
139 | |||
140 | self.xpos = [self.xi,self.xw] |
|
140 | self.xpos = [self.xi,self.xw] | |
141 | self.ypos = [self.yi,self.yw] |
|
141 | self.ypos = [self.yi,self.yw] | |
142 | self.xaxisastime = False |
|
142 | self.xaxisastime = False | |
143 | self.timefmt = None |
|
143 | self.timefmt = None | |
144 | self.xopt = "bcnst" |
|
144 | self.xopt = "bcnst" | |
145 | self.yopt = "bcnstv" |
|
145 | self.yopt = "bcnstv" | |
146 |
|
146 | |||
147 | self.szchar = 0.8 |
|
147 | self.szchar = 0.8 | |
148 | self.strforchannel = "Channel %d"%self.idframe |
|
148 | self.strforchannel = "Channel %d"%self.idframe | |
149 | self.xlabel = "m/s" |
|
149 | self.xlabel = "m/s" | |
150 | self.ylabel = "Range (Km)" |
|
150 | self.ylabel = "Range (Km)" | |
151 |
|
151 | |||
152 | def setBox(self, xmin, xmax, ymin, ymax, minvalue, maxvalue, *args): |
|
152 | def setBox(self, xmin, xmax, ymin, ymax, minvalue, maxvalue, *args): | |
153 | self.xmin = xmin |
|
153 | self.xmin = xmin | |
154 | self.xmax = xmax |
|
154 | self.xmax = xmax | |
155 | self.ymin = ymin |
|
155 | self.ymin = ymin | |
156 | self.ymax = ymax |
|
156 | self.ymax = ymax | |
157 | self.minvalue = minvalue |
|
157 | self.minvalue = minvalue | |
158 | self.maxvalue = maxvalue |
|
158 | self.maxvalue = maxvalue | |
159 | self.colorbar = args[2] |
|
159 | self.colorbar = args[2] | |
160 | self.title = "%s - %s"%(self.strforchannel,args[3]) |
|
160 | self.title = "%s - %s"%(self.strforchannel,args[3]) | |
161 |
|
161 | |||
162 |
|
162 | |||
163 |
|
163 | |||
164 | def plot(self, x, y, data): |
|
164 | def plot(self, x, y, data): | |
165 | z = data |
|
165 | z = data | |
166 | deltax = None |
|
166 | deltax = None | |
167 | deltay = None |
|
167 | deltay = None | |
168 | self.plotPcolor(x, y, z, deltax, deltay, self.getGrid) |
|
168 | self.plotPcolor(x, y, z, deltax, deltay, self.getGrid) | |
169 | self.getGrid = False |
|
169 | self.getGrid = False | |
170 |
|
170 | |||
171 |
|
171 | |||
172 | class RTIFigure(Figure): |
|
172 | class RTIFigure(Figure): | |
173 | overplot = 1 |
|
173 | overplot = 1 | |
174 | xw = 700 |
|
174 | xw = 700 | |
175 | yw = 650 |
|
175 | yw = 650 | |
176 | showprofile = False |
|
176 | showprofile = False | |
177 | starttime = None |
|
177 | starttime = None | |
178 | endtime = None |
|
178 | endtime = None | |
179 | minrange = None |
|
179 | minrange = None | |
180 | maxrange = None |
|
180 | maxrange = None | |
181 | minvalue = None |
|
181 | minvalue = None | |
182 | maxvalue = None |
|
182 | maxvalue = None | |
183 | xrangestepinsecs = None |
|
183 | xrangestepinsecs = None | |
184 |
|
184 | |||
185 |
|
185 | |||
186 | def __init__(self, idfigure, nframes, wintitle, driver, colormap="br_green", colorbar= True, showprofile=False): |
|
186 | def __init__(self, idfigure, nframes, wintitle, driver, colormap="br_green", colorbar= True, showprofile=False): | |
187 | Figure.__init__(self,idfigure, nframes, wintitle, self.xw, self.yw, self.overplot, driver, colormap, colorbar) |
|
187 | Figure.__init__(self,idfigure, nframes, wintitle, self.xw, self.yw, self.overplot, driver, colormap, colorbar) | |
188 |
|
188 | |||
189 | self.showprofile = showprofile |
|
189 | self.showprofile = showprofile | |
190 |
|
190 | |||
191 | def getSubplots(self): |
|
191 | def getSubplots(self): | |
192 | nrows = self.nframes |
|
192 | nrows = self.nframes | |
193 | ncolumns = 1 |
|
193 | ncolumns = 1 | |
194 | return nrows, ncolumns |
|
194 | return nrows, ncolumns | |
195 |
|
195 | |||
196 | def setParms(self, data, x, y, xmin, xmax, ymin, ymax, minvalue, maxvalue, xrangestep): |
|
196 | def setParms(self, data, x, y, xmin, xmax, ymin, ymax, minvalue, maxvalue, xrangestep): | |
197 |
|
197 | |||
198 | self.starttime = xmin |
|
198 | self.starttime = xmin | |
199 | self.endtime = xmax |
|
199 | self.endtime = xmax | |
200 |
|
200 | |||
201 | cdatetime = datetime.datetime.utcfromtimestamp(x) |
|
201 | cdatetime = datetime.datetime.utcfromtimestamp(x) | |
202 |
|
202 | |||
203 | mindatetime = datetime.datetime(cdatetime.year,cdatetime.month,cdatetime.day,self.starttime.hour,self.starttime.minute,self.starttime.second) |
|
203 | mindatetime = datetime.datetime(cdatetime.year,cdatetime.month,cdatetime.day,self.starttime.hour,self.starttime.minute,self.starttime.second) | |
204 | if ((xrangestep == 0) or (xrangestep == None)): |
|
204 | if ((xrangestep == 0) or (xrangestep == None)): | |
205 | maxdatetime = datetime.datetime(cdatetime.year,cdatetime.month,cdatetime.day,self.endtime.hour,self.endtime.minute,self.endtime.second) |
|
205 | maxdatetime = datetime.datetime(cdatetime.year,cdatetime.month,cdatetime.day,self.endtime.hour,self.endtime.minute,self.endtime.second) | |
206 | self.xrangestepinsecs = time.mktime(maxdatetime.timetuple()) - time.mktime(mindatetime.timetuple()) |
|
206 | self.xrangestepinsecs = time.mktime(maxdatetime.timetuple()) - time.mktime(mindatetime.timetuple()) | |
207 | npoints = 1000. |
|
207 | npoints = 1000. | |
208 | if xrangestep == 1: |
|
208 | if xrangestep == 1: | |
209 | maxdatetime = mindatetime + datetime.timedelta(hours=1) |
|
209 | maxdatetime = mindatetime + datetime.timedelta(hours=1) | |
210 | self.xrangestepinsecs = 60*60. |
|
210 | self.xrangestepinsecs = 60*60. | |
211 | npoints = 500. |
|
211 | npoints = 500. | |
212 | if xrangestep == 2: |
|
212 | if xrangestep == 2: | |
213 | maxdatetime = mindatetime + datetime.timedelta(minutes=1) |
|
213 | maxdatetime = mindatetime + datetime.timedelta(minutes=1) | |
214 | self.xrangestepinsecs = 60. |
|
214 | self.xrangestepinsecs = 60. | |
215 | npoints = 250. |
|
215 | npoints = 250. | |
216 | if xrangestep == 3: |
|
216 | if xrangestep == 3: | |
217 | maxdatetime = mindatetime + datetime.timedelta(seconds=1) |
|
217 | maxdatetime = mindatetime + datetime.timedelta(seconds=1) | |
218 | self.xrangestepinsecs = 1. |
|
218 | self.xrangestepinsecs = 1. | |
219 | npoints = 125. |
|
219 | npoints = 125. | |
220 |
|
220 | |||
221 | xmin = time.mktime(mindatetime.timetuple()) |
|
221 | xmin = time.mktime(mindatetime.timetuple()) | |
222 | xmax = time.mktime(maxdatetime.timetuple()) |
|
222 | xmax = time.mktime(maxdatetime.timetuple()) | |
223 |
|
223 | |||
224 | deltax = (xmax-xmin) / npoints |
|
224 | deltax = (xmax-xmin) / npoints | |
225 |
|
225 | |||
226 |
|
226 | |||
227 | if ymin == None: ymin = numpy.min(y) |
|
227 | if ymin == None: ymin = numpy.min(y) | |
228 | if ymax == None: ymax = numpy.max(y) |
|
228 | if ymax == None: ymax = numpy.max(y) | |
229 |
|
229 | |||
230 | if minvalue == None: minvalue = 0. |
|
230 | if minvalue == None: minvalue = 0. | |
231 | if maxvalue == None: maxvalue = 50. |
|
231 | if maxvalue == None: maxvalue = 50. | |
232 |
|
232 | |||
233 | self.xmin = xmin |
|
233 | self.xmin = xmin | |
234 | self.xmax = xmax |
|
234 | self.xmax = xmax | |
235 | self.minrange = ymin |
|
235 | self.minrange = ymin | |
236 | self.maxrange = ymax |
|
236 | self.maxrange = ymax | |
237 | self.ymin = ymin |
|
237 | self.ymin = ymin | |
238 | self.ymax = ymax |
|
238 | self.ymax = ymax | |
239 | self.minvalue = minvalue |
|
239 | self.minvalue = minvalue | |
240 | self.maxvalue = maxvalue |
|
240 | self.maxvalue = maxvalue | |
241 | self.xrangestep = xrangestep |
|
241 | self.xrangestep = xrangestep | |
242 | self.deltax = deltax |
|
242 | self.deltax = deltax | |
243 |
|
243 | |||
244 | def changeXRange(self,x): |
|
244 | def changeXRange(self,x): | |
245 |
|
245 | |||
246 | cdatetime = datetime.datetime.utcfromtimestamp(x) |
|
246 | cdatetime = datetime.datetime.utcfromtimestamp(x) | |
247 |
|
247 | |||
248 | if ((cdatetime.time()>=self.starttime) and (cdatetime.time()<self.endtime)): |
|
248 | if ((cdatetime.time()>=self.starttime) and (cdatetime.time()<self.endtime)): | |
249 | if self.xrangestep == 1: |
|
249 | if self.xrangestep == 1: | |
250 | mindatetime = datetime.datetime(cdatetime.year,cdatetime.month,cdatetime.day,cdatetime.hour,self.starttime.minute,self.starttime.second) |
|
250 | mindatetime = datetime.datetime(cdatetime.year,cdatetime.month,cdatetime.day,cdatetime.hour,self.starttime.minute,self.starttime.second) | |
251 |
|
251 | |||
252 | if self.xrangestep == 2: |
|
252 | if self.xrangestep == 2: | |
253 | mindatetime = datetime.datetime(cdatetime.year,cdatetime.month,cdatetime.day,cdatetime.hour,cdatetime.minute,self.starttime.second) |
|
253 | mindatetime = datetime.datetime(cdatetime.year,cdatetime.month,cdatetime.day,cdatetime.hour,cdatetime.minute,self.starttime.second) | |
254 |
|
254 | |||
255 | if self.xrangestep == 3: |
|
255 | if self.xrangestep == 3: | |
256 | mindatetime = datetime.datetime(cdatetime.year,cdatetime.month,cdatetime.day,cdatetime.hour,cdatetime.minute,cdatetime.second) |
|
256 | mindatetime = datetime.datetime(cdatetime.year,cdatetime.month,cdatetime.day,cdatetime.hour,cdatetime.minute,cdatetime.second) | |
257 |
|
257 | |||
258 | self.xmin = time.mktime(mindatetime.timetuple()) - time.timezone |
|
258 | self.xmin = time.mktime(mindatetime.timetuple()) - time.timezone | |
259 | self.xmax = self.xmin + self.xrangestepinsecs |
|
259 | self.xmax = self.xmin + self.xrangestepinsecs | |
260 |
|
260 | |||
261 | self.figuretitle = "%s %s : %s"%(self.figuretitle, |
|
261 | self.figuretitle = "%s %s : %s"%(self.figuretitle, | |
262 | datetime.datetime.utcfromtimestamp(self.xmin).strftime("%d-%b-%Y %H:%M:%S"), |
|
262 | datetime.datetime.utcfromtimestamp(self.xmin).strftime("%d-%b-%Y %H:%M:%S"), | |
263 | datetime.datetime.utcfromtimestamp(self.xmax).strftime("%d-%b-%Y %H:%M:%S")) |
|
263 | datetime.datetime.utcfromtimestamp(self.xmax).strftime("%d-%b-%Y %H:%M:%S")) | |
264 | return 1 |
|
264 | return 1 | |
265 |
|
265 | |||
266 | return 0 |
|
266 | return 0 | |
267 |
|
267 | |||
268 | def createFrames(self): |
|
268 | def createFrames(self): | |
269 | for frame in range(self.nframes): |
|
269 | for frame in range(self.nframes): | |
270 | frameObj = RTIFrame(self.drvObj,frame + 1, self.colorbar, self.showprofile) |
|
270 | frameObj = RTIFrame(self.drvObj,frame + 1, self.colorbar, self.showprofile) | |
271 | self.frameObjList.append(frameObj) |
|
271 | self.frameObjList.append(frameObj) | |
272 |
|
272 | |||
273 | class RTIFrame(Frame): |
|
273 | class RTIFrame(Frame): | |
274 | def __init__(self,drvObj,idframe,colorbar,showprofile): |
|
274 | def __init__(self,drvObj,idframe,colorbar,showprofile): | |
275 | self.drvObj = drvObj |
|
275 | self.drvObj = drvObj | |
276 | self.idframe = idframe |
|
276 | self.idframe = idframe | |
277 | self.nplots = 1 |
|
277 | self.nplots = 1 | |
278 |
|
278 | |||
279 | if showprofile: |
|
279 | if showprofile: | |
280 | self.nplots += 1 |
|
280 | self.nplots += 1 | |
281 |
|
281 | |||
282 | self.colorbar = colorbar |
|
282 | self.colorbar = colorbar | |
283 | self.showprofile = showprofile |
|
283 | self.showprofile = showprofile | |
284 | self.createPlots() |
|
284 | self.createPlots() | |
285 |
|
285 | |||
286 | def createPlots(self): |
|
286 | def createPlots(self): | |
287 | plotObjList = [] |
|
287 | plotObjList = [] | |
288 |
|
288 | |||
289 | idplot = 0 |
|
289 | idplot = 0 | |
290 | xi, yi, xw, yw = self.getScreenPos(idplot) |
|
290 | xi, yi, xw, yw = self.getScreenPos(idplot) | |
291 |
|
291 | |||
292 | plotObj = RTIPlot(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, self.colorbar) |
|
292 | plotObj = RTIPlot(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, self.colorbar) | |
293 | plotObjList.append(plotObj) |
|
293 | plotObjList.append(plotObj) | |
294 |
|
294 | |||
295 | if self.showprofile: |
|
295 | if self.showprofile: | |
296 | idplot = 1 |
|
296 | idplot = 1 | |
297 | xi, yi, xw, yw = self.getScreenPos(idplot) |
|
297 | xi, yi, xw, yw = self.getScreenPos(idplot) | |
298 | type = "pwbox" |
|
298 | type = "pwbox" | |
299 | title = "" |
|
299 | title = "" | |
300 | xlabel = "dB" |
|
300 | xlabel = "dB" | |
301 | ylabel = "" |
|
301 | ylabel = "" | |
302 | plotObj = Plot1D(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, type, title, xlabel, ylabel) |
|
302 | plotObj = Plot1D(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, type, title, xlabel, ylabel) | |
303 | plotObjList.append(plotObj) |
|
303 | plotObjList.append(plotObj) | |
304 |
|
304 | |||
305 | self.plotObjList = plotObjList |
|
305 | self.plotObjList = plotObjList | |
306 |
|
306 | |||
307 | def getScreenPosMainPlot(self): |
|
307 | def getScreenPosMainPlot(self): | |
308 | xi = 0.07 |
|
308 | xi = 0.07 | |
309 | if self.showprofile: |
|
309 | if self.showprofile: | |
310 | xw = 0.65 |
|
310 | xw = 0.65 | |
311 | else: |
|
311 | else: | |
312 | xw = 0.9 |
|
312 | xw = 0.9 | |
313 |
|
313 | |||
314 | if self.colorbar: |
|
314 | if self.colorbar: | |
315 | xw = xw - 0.06 |
|
315 | xw = xw - 0.06 | |
316 |
|
316 | |||
317 | yi = 0.20; yw = 0.75 |
|
317 | yi = 0.20; yw = 0.75 | |
318 |
|
318 | |||
319 | return xi, yi, xw, yw |
|
319 | return xi, yi, xw, yw | |
320 |
|
320 | |||
321 | def getScreenPosGraph1(self): |
|
321 | def getScreenPosGraph1(self): | |
322 | if self.colorbar: |
|
322 | if self.colorbar: | |
323 | xi = 0.65 + 0.08 |
|
323 | xi = 0.65 + 0.08 | |
324 | else: |
|
324 | else: | |
325 | xi = 0.9 + 0.05 |
|
325 | xi = 0.9 + 0.05 | |
326 |
|
326 | |||
327 | xw = xi + 0.2 |
|
327 | xw = xi + 0.2 | |
328 |
|
328 | |||
329 | yi = 0.2; yw = 0.75 |
|
329 | yi = 0.2; yw = 0.75 | |
330 |
|
330 | |||
331 | return xi, yi, xw, yw |
|
331 | return xi, yi, xw, yw | |
332 |
|
332 | |||
333 | def plot(self, currenttime, range, data): |
|
333 | def plot(self, currenttime, range, data): | |
334 | plotObj = self.plotObjList[0] |
|
334 | plotObj = self.plotObjList[0] | |
335 | plotObj.plot(currenttime,range,data) |
|
335 | plotObj.plot(currenttime,range,data) | |
336 |
|
336 | |||
337 | if self.showprofile: |
|
337 | if self.showprofile: | |
338 | plotObj = self.plotObjList[1] |
|
338 | plotObj = self.plotObjList[1] | |
339 | plotObj.plot(data,range) |
|
339 | plotObj.plot(data,range) | |
340 |
|
340 | |||
341 |
|
341 | |||
342 | class RTIPlot(Plot): |
|
342 | class RTIPlot(Plot): | |
343 | deltax = None |
|
343 | deltax = None | |
344 | deltay = None |
|
344 | deltay = None | |
345 | xrange = [None,None] |
|
345 | xrange = [None,None] | |
346 | xminpos = None |
|
346 | xminpos = None | |
347 | xmaxpos = None |
|
347 | xmaxpos = None | |
348 | xg = None |
|
348 | xg = None | |
349 | yg = None |
|
349 | yg = None | |
350 |
|
350 | |||
351 | def __init__(self,drvObj, idframe, idplot, xi, yi, xw, yw, colorbar): |
|
351 | def __init__(self,drvObj, idframe, idplot, xi, yi, xw, yw, colorbar): | |
352 | self.drvObj = drvObj |
|
352 | self.drvObj = drvObj | |
353 | self.idframe = idframe |
|
353 | self.idframe = idframe | |
354 | self.idplot = idplot |
|
354 | self.idplot = idplot | |
355 | self.xi = xi |
|
355 | self.xi = xi | |
356 | self.yi = yi |
|
356 | self.yi = yi | |
357 | self.xw = xw |
|
357 | self.xw = xw | |
358 | self.yw = yw |
|
358 | self.yw = yw | |
359 | self.colorbar = colorbar |
|
359 | self.colorbar = colorbar | |
360 |
|
360 | |||
361 | if self.colorbar: |
|
361 | if self.colorbar: | |
362 | cbxi = xw + 0.03 |
|
362 | cbxi = xw + 0.03 | |
363 | cbxw = cbxi + 0.03 |
|
363 | cbxw = cbxi + 0.03 | |
364 | cbyi = yi |
|
364 | cbyi = yi | |
365 | cbyw = yw |
|
365 | cbyw = yw | |
366 | self.cbxpos = [cbxi,cbxw] |
|
366 | self.cbxpos = [cbxi,cbxw] | |
367 | self.cbypos = [cbyi,cbyw] |
|
367 | self.cbypos = [cbyi,cbyw] | |
368 |
|
368 | |||
369 | self.xpos = [self.xi,self.xw] |
|
369 | self.xpos = [self.xi,self.xw] | |
370 | self.ypos = [self.yi,self.yw] |
|
370 | self.ypos = [self.yi,self.yw] | |
371 | self.xaxisastime = True |
|
371 | self.xaxisastime = True | |
372 | self.timefmt = "%H:%M" |
|
372 | self.timefmt = "%H:%M" | |
373 | self.xopt = "bcnstd" |
|
373 | self.xopt = "bcnstd" | |
374 | self.yopt = "bcnstv" |
|
374 | self.yopt = "bcnstv" | |
375 |
|
375 | |||
376 | self.szchar = 1.0 |
|
376 | self.szchar = 1.0 | |
377 | self.title = "Channel %d"%self.idframe |
|
377 | self.title = "Channel %d"%self.idframe | |
378 | self.xlabel = "Local Time" |
|
378 | self.xlabel = "Local Time" | |
379 | self.ylabel = "Range (Km)" |
|
379 | self.ylabel = "Range (Km)" | |
380 |
|
380 | |||
381 |
|
381 | |||
382 | def setBox(self, xmin, xmax, ymin, ymax, minvalue, maxvalue, deltax=None, deltay=None, colorbar=True, *args): |
|
382 | def setBox(self, xmin, xmax, ymin, ymax, minvalue, maxvalue, deltax=None, deltay=None, colorbar=True, *args): | |
383 | self.xmin = xmin |
|
383 | self.xmin = xmin | |
384 | self.xmax = xmax |
|
384 | self.xmax = xmax | |
385 | self.ymin = ymin |
|
385 | self.ymin = ymin | |
386 | self.ymax = ymax |
|
386 | self.ymax = ymax | |
387 | self.minvalue = minvalue |
|
387 | self.minvalue = minvalue | |
388 | self.maxvalue = maxvalue |
|
388 | self.maxvalue = maxvalue | |
389 | self.deltax = deltax |
|
389 | self.deltax = deltax | |
390 | self.deltay = deltay |
|
390 | self.deltay = deltay | |
391 | self.colorbar = colorbar |
|
391 | self.colorbar = colorbar | |
392 |
|
392 | |||
393 | def plot(self, currenttime, range, data): |
|
393 | def plot(self, currenttime, range, data): | |
394 |
|
394 | |||
395 | if self.xmaxpos == None: |
|
395 | if self.xmaxpos == None: | |
396 | self.xmaxpos = currenttime |
|
396 | self.xmaxpos = currenttime | |
397 |
|
397 | |||
398 | if currenttime >= self.xmaxpos: |
|
398 | if currenttime >= self.xmaxpos: | |
399 |
|
399 | |||
400 | self.xminpos = currenttime |
|
400 | self.xminpos = currenttime | |
401 | self.xmaxpos = currenttime + self.deltax |
|
401 | self.xmaxpos = currenttime + self.deltax | |
402 | x = [currenttime] |
|
402 | x = [currenttime] | |
403 | y = range |
|
403 | y = range | |
404 | z = numpy.reshape(data, (1,-1)) |
|
404 | z = numpy.reshape(data, (1,-1)) | |
405 | getGrid = True |
|
405 | getGrid = True | |
406 |
|
406 | |||
407 | self.plotPcolor(x, y, z, self.deltax, self.deltay, getGrid) |
|
407 | self.plotPcolor(x, y, z, self.deltax, self.deltay, getGrid) | |
408 |
|
408 | |||
409 |
|
409 | |||
410 | class ScopeFigure(Figure): |
|
410 | class ScopeFigure(Figure): | |
411 | overplot = 0 |
|
411 | overplot = 0 | |
412 | xw = 700 |
|
412 | xw = 700 | |
413 | yw = 650 |
|
413 | yw = 650 | |
414 | colorbar = None |
|
414 | colorbar = None | |
415 |
|
415 | |||
416 | def __init__(self,idfigure,nframes,wintitle,driver): |
|
416 | def __init__(self,idfigure,nframes,wintitle,driver): | |
417 | colormap = None |
|
417 | colormap = None | |
418 | colorbar = False |
|
418 | colorbar = False | |
419 |
|
419 | |||
420 | self.idfigure = idfigure |
|
420 | Figure.__init__(self,idfigure, nframes, wintitle, self.xw, self.yw, self.overplot, driver, colormap, colorbar) | |
421 | self.nframes = nframes |
|
421 | ||
422 | self.wintitle = wintitle |
|
|||
423 |
|
||||
424 | self.colormap = colormap |
|
|||
425 | self.colorbar = colorbar |
|
|||
426 | self.driver = driver |
|
|||
427 | self.drvObj = Driver(self.driver, self.idfigure, self.xw, self.yw, self.wintitle, self.overplot, self.colormap, self.colorbar) |
|
|||
428 | self.drvObj.driver.setFigure() |
|
|||
429 |
|
||||
430 | # Figure.__init__(self,idfigure,nframes,wintitle,self.xw,self.yw,self.overplot,driver,colorbar,colormap,*args) |
|
|||
431 |
|
422 | |||
432 | def getSubplots(self): |
|
423 | def getSubplots(self): | |
433 | nrows = self.nframes |
|
424 | nrows = self.nframes | |
434 | ncolumns = 1 |
|
425 | ncolumns = 1 | |
435 | return nrows, ncolumns |
|
426 | return nrows, ncolumns | |
436 |
|
427 | |||
437 | def createFrames(self): |
|
428 | def createFrames(self): | |
438 | for frame in range(self.nframes): |
|
429 | for frame in range(self.nframes): | |
439 | frameObj = ScopeFrame(self.drvObj,frame + 1) |
|
430 | frameObj = ScopeFrame(self.drvObj,frame + 1) | |
440 | self.frameObjList.append(frameObj) |
|
431 | self.frameObjList.append(frameObj) | |
441 |
|
432 | |||
442 |
|
433 | |||
443 | class ScopeFrame(Frame): |
|
434 | class ScopeFrame(Frame): | |
444 | # plotObjList = [] |
|
435 | # plotObjList = [] | |
445 | xlabel = "" |
|
436 | xlabel = "" | |
446 | ylabel = "" |
|
437 | ylabel = "" | |
447 | title = "" |
|
438 | title = "" | |
448 | def __init__(self,drvObj,idframe): |
|
439 | def __init__(self,drvObj,idframe): | |
449 | self.drvObj = drvObj |
|
440 | self.drvObj = drvObj | |
450 | self.idframe = idframe |
|
441 | self.idframe = idframe | |
451 | self.nplots = 1 #nplots/frame |
|
442 | self.nplots = 1 #nplots/frame | |
452 | self.createPlots() |
|
443 | self.createPlots() | |
453 | # Frame.__init__(self, drvObj, idframe) |
|
444 | # Frame.__init__(self, drvObj, idframe) | |
454 |
|
445 | |||
455 | def getScreenPosMainPlot(self):#cada Frame determina las coordenadas de los plots |
|
446 | def getScreenPosMainPlot(self):#cada Frame determina las coordenadas de los plots | |
456 | xi = 0.07; xw = 0.9 |
|
447 | xi = 0.07; xw = 0.9 | |
457 | yi = 0.20; yw = 0.75 |
|
448 | yi = 0.20; yw = 0.75 | |
458 | return xi,yi,xw,yw |
|
449 | return xi,yi,xw,yw | |
459 |
|
450 | |||
460 | def createPlots(self): |
|
451 | def createPlots(self): | |
461 | plotObjList = [] |
|
452 | plotObjList = [] | |
462 | for idplot in range(self.nplots): |
|
453 | for idplot in range(self.nplots): | |
463 | xi, yi, xw, yw = self.getScreenPos(idplot) |
|
454 | xi, yi, xw, yw = self.getScreenPos(idplot) | |
464 | type = "scopebox" |
|
455 | type = "scopebox" | |
465 | title = "Channel %d"%self.idframe |
|
456 | title = "Channel %d"%self.idframe | |
466 | xlabel = "range (Km)" |
|
457 | xlabel = "range (Km)" | |
467 | ylabel = "intensity" |
|
458 | ylabel = "intensity" | |
468 | plotObj = Plot1D(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, type, title, xlabel, ylabel) |
|
459 | plotObj = Plot1D(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, type, title, xlabel, ylabel) | |
469 | plotObjList.append(plotObj) |
|
460 | plotObjList.append(plotObj) | |
470 | self.plotObjList = plotObjList |
|
461 | self.plotObjList = plotObjList | |
471 | # self.plotObjList.append(plotObj) |
|
462 | # self.plotObjList.append(plotObj) | |
472 |
|
463 | |||
473 | def plot(self, x, y, z=None): |
|
464 | def plot(self, x, y, z=None): | |
474 | for plotObj in self.plotObjList: |
|
465 | for plotObj in self.plotObjList: | |
475 | plotObj.plot(x, y) |
|
466 | plotObj.plot(x, y) | |
476 |
|
467 | |||
477 |
|
468 | |||
478 | class Plot1D(Plot): |
|
469 | class Plot1D(Plot): | |
479 | # type, title, xlabel, ylabel |
|
470 | # type, title, xlabel, ylabel | |
480 | def __init__(self, drvObj, idframe, idplot, xi, yi, xw, yw, type, title, xlabel, ylabel): |
|
471 | def __init__(self, drvObj, idframe, idplot, xi, yi, xw, yw, type, title, xlabel, ylabel): | |
481 | self.drvObj = drvObj |
|
472 | self.drvObj = drvObj | |
482 | self.idframe = idframe |
|
473 | self.idframe = idframe | |
483 | self.idplot = idplot |
|
474 | self.idplot = idplot | |
484 | self.xi = xi |
|
475 | self.xi = xi | |
485 | self.yi = yi |
|
476 | self.yi = yi | |
486 | self.xw = xw |
|
477 | self.xw = xw | |
487 | self.yw = yw |
|
478 | self.yw = yw | |
488 | self.xpos = [self.xi,self.xw] |
|
479 | self.xpos = [self.xi,self.xw] | |
489 | self.ypos = [self.yi,self.yw] |
|
480 | self.ypos = [self.yi,self.yw] | |
490 | self.xaxisastime = False |
|
481 | self.xaxisastime = False | |
491 | self.timefmt = None |
|
482 | self.timefmt = None | |
492 | self.xopt = "bcnst" |
|
483 | self.xopt = "bcnst" | |
493 | self.yopt = "bcnstv" |
|
484 | self.yopt = "bcnstv" | |
494 | self.szchar = 1.0 |
|
485 | self.szchar = 1.0 | |
495 | self.type = type |
|
486 | self.type = type | |
496 | self.title = title |
|
487 | self.title = title | |
497 | self.xlabel = xlabel |
|
488 | self.xlabel = xlabel | |
498 | self.ylabel = ylabel |
|
489 | self.ylabel = ylabel | |
499 |
|
490 | |||
500 |
|
491 | |||
501 |
|
492 | |||
502 | def setBox(self, xmin, xmax, ymin, ymax, minvalue, maxvalue, *args): |
|
493 | def setBox(self, xmin, xmax, ymin, ymax, minvalue, maxvalue, *args): | |
503 | if self.type == "pwbox": |
|
494 | if self.type == "pwbox": | |
504 | self.xmin = minvalue |
|
495 | self.xmin = minvalue | |
505 | self.xmax = maxvalue |
|
496 | self.xmax = maxvalue | |
506 | self.ymin = ymin |
|
497 | self.ymin = ymin | |
507 | self.ymax = ymax |
|
498 | self.ymax = ymax | |
508 | self.minvalue = minvalue |
|
499 | self.minvalue = minvalue | |
509 | self.maxvalue = maxvalue |
|
500 | self.maxvalue = maxvalue | |
510 |
|
501 | |||
511 | else: |
|
502 | else: | |
512 | self.xmin = xmin |
|
503 | self.xmin = xmin | |
513 | self.xmax = xmax |
|
504 | self.xmax = xmax | |
514 | self.ymin = ymin |
|
505 | self.ymin = ymin | |
515 | self.ymax = ymax |
|
506 | self.ymax = ymax | |
516 | self.minvalue = minvalue |
|
507 | self.minvalue = minvalue | |
517 | self.maxvalue = maxvalue |
|
508 | self.maxvalue = maxvalue | |
518 |
|
509 | |||
519 | self.colorbar = False |
|
510 | self.colorbar = False | |
520 |
|
511 | |||
521 | def plot(self,x,y): |
|
512 | def plot(self,x,y): | |
522 | if y.dtype == "complex128": |
|
513 | if y.dtype == "complex128": | |
523 | color="blue" |
|
514 | color="blue" | |
524 | self.plotBasicLine(x, y.real, color) |
|
515 | self.plotBasicLine(x, y.real, color) | |
525 | color="red" |
|
516 | color="red" | |
526 | self.plotBasicLine(x, y.imag, color) |
|
517 | self.plotBasicLine(x, y.imag, color) | |
527 | else: |
|
518 | else: | |
528 | color="blue" |
|
519 | color="blue" | |
529 | self.plotBasicLine(x, y, color) |
|
520 | self.plotBasicLine(x, y, color) |
General Comments 0
You need to be logged in to leave comments.
Login now