@@ -1,421 +1,427 | |||||
1 | import numpy |
|
1 | import numpy | |
2 | import time, datetime |
|
2 | import time, datetime | |
3 | from graphics.figure import * |
|
3 | from graphics.figure import * | |
4 |
|
4 | |||
5 | class RTIPlot(Figure): |
|
5 | class RTIPlot(Figure): | |
6 |
|
6 | |||
7 | __isConfig = None |
|
7 | __isConfig = None | |
8 | __nsubplots = None |
|
8 | __nsubplots = None | |
9 |
|
9 | |||
10 | WIDTHPROF = None |
|
10 | WIDTHPROF = None | |
11 | HEIGHTPROF = None |
|
11 | HEIGHTPROF = None | |
12 | PREFIX = 'rti' |
|
12 | PREFIX = 'rti' | |
13 |
|
13 | |||
14 | def __init__(self): |
|
14 | def __init__(self): | |
15 |
|
15 | |||
16 | self.__timerange = 24*60*60 |
|
16 | self.__timerange = 24*60*60 | |
17 | self.__isConfig = False |
|
17 | self.__isConfig = False | |
18 | self.__nsubplots = 1 |
|
18 | self.__nsubplots = 1 | |
19 |
|
19 | |||
20 | self.WIDTH = 800 |
|
20 | self.WIDTH = 800 | |
21 | self.HEIGHT = 200 |
|
21 | self.HEIGHT = 200 | |
22 | self.WIDTHPROF = 120 |
|
22 | self.WIDTHPROF = 120 | |
23 | self.HEIGHTPROF = 0 |
|
23 | self.HEIGHTPROF = 0 | |
24 |
|
24 | |||
25 | def getSubplots(self): |
|
25 | def getSubplots(self): | |
26 |
|
26 | |||
27 | ncol = 1 |
|
27 | ncol = 1 | |
28 | nrow = self.nplots |
|
28 | nrow = self.nplots | |
29 |
|
29 | |||
30 | return nrow, ncol |
|
30 | return nrow, ncol | |
31 |
|
31 | |||
32 | def setup(self, idfigure, nplots, wintitle, showprofile=True): |
|
32 | def setup(self, idfigure, nplots, wintitle, showprofile=True): | |
33 |
|
33 | |||
34 | self.__showprofile = showprofile |
|
34 | self.__showprofile = showprofile | |
35 | self.nplots = nplots |
|
35 | self.nplots = nplots | |
36 |
|
36 | |||
37 | ncolspan = 1 |
|
37 | ncolspan = 1 | |
38 | colspan = 1 |
|
38 | colspan = 1 | |
39 | if showprofile: |
|
39 | if showprofile: | |
40 | ncolspan = 7 |
|
40 | ncolspan = 7 | |
41 | colspan = 6 |
|
41 | colspan = 6 | |
42 | self.__nsubplots = 2 |
|
42 | self.__nsubplots = 2 | |
43 |
|
43 | |||
44 | self.createFigure(idfigure = idfigure, |
|
44 | self.createFigure(idfigure = idfigure, | |
45 | wintitle = wintitle, |
|
45 | wintitle = wintitle, | |
46 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
46 | widthplot = self.WIDTH + self.WIDTHPROF, | |
47 | heightplot = self.HEIGHT + self.HEIGHTPROF) |
|
47 | heightplot = self.HEIGHT + self.HEIGHTPROF) | |
48 |
|
48 | |||
49 | nrow, ncol = self.getSubplots() |
|
49 | nrow, ncol = self.getSubplots() | |
50 |
|
50 | |||
51 | counter = 0 |
|
51 | counter = 0 | |
52 | for y in range(nrow): |
|
52 | for y in range(nrow): | |
53 | for x in range(ncol): |
|
53 | for x in range(ncol): | |
54 |
|
54 | |||
55 | if counter >= self.nplots: |
|
55 | if counter >= self.nplots: | |
56 | break |
|
56 | break | |
57 |
|
57 | |||
58 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
58 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
59 |
|
59 | |||
60 | if showprofile: |
|
60 | if showprofile: | |
61 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
61 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
62 |
|
62 | |||
63 | counter += 1 |
|
63 | counter += 1 | |
64 |
|
64 | |||
65 | def __getTimeLim(self, x, xmin, xmax): |
|
65 | def __getTimeLim(self, x, xmin, xmax): | |
66 |
|
66 | |||
67 | thisdatetime = datetime.datetime.fromtimestamp(numpy.min(x)) |
|
67 | thisdatetime = datetime.datetime.fromtimestamp(numpy.min(x)) | |
68 | thisdate = datetime.datetime.combine(thisdatetime.date(), datetime.time(0,0,0)) |
|
68 | thisdate = datetime.datetime.combine(thisdatetime.date(), datetime.time(0,0,0)) | |
69 |
|
69 | |||
70 | #################################################### |
|
70 | #################################################### | |
71 | #If the x is out of xrange |
|
71 | #If the x is out of xrange | |
72 | if xmax < (thisdatetime - thisdate).seconds/(60*60.): |
|
72 | if xmax < (thisdatetime - thisdate).seconds/(60*60.): | |
73 | xmin = None |
|
73 | xmin = None | |
74 | xmax = None |
|
74 | xmax = None | |
75 |
|
75 | |||
76 | if xmin == None: |
|
76 | if xmin == None: | |
77 | td = thisdatetime - thisdate |
|
77 | td = thisdatetime - thisdate | |
78 | xmin = td.seconds/(60*60.) |
|
78 | xmin = td.seconds/(60*60.) | |
79 |
|
79 | |||
80 | if xmax == None: |
|
80 | if xmax == None: | |
81 | xmax = xmin + self.__timerange/(60*60.) |
|
81 | xmax = xmin + self.__timerange/(60*60.) | |
82 |
|
82 | |||
83 | mindt = thisdate + datetime.timedelta(0,0,0,0,0, xmin) |
|
83 | mindt = thisdate + datetime.timedelta(0,0,0,0,0, xmin) | |
84 | tmin = time.mktime(mindt.timetuple()) |
|
84 | tmin = time.mktime(mindt.timetuple()) | |
85 |
|
85 | |||
86 | maxdt = thisdate + datetime.timedelta(0,0,0,0,0, xmax) |
|
86 | maxdt = thisdate + datetime.timedelta(0,0,0,0,0, xmax) | |
87 | tmax = time.mktime(maxdt.timetuple()) |
|
87 | tmax = time.mktime(maxdt.timetuple()) | |
88 |
|
88 | |||
89 | self.__timerange = tmax - tmin |
|
89 | self.__timerange = tmax - tmin | |
90 |
|
90 | |||
91 | return tmin, tmax |
|
91 | return tmin, tmax | |
92 |
|
92 | |||
93 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', |
|
93 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', | |
94 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
94 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
95 | timerange=None, |
|
95 | timerange=None, | |
96 | save=False, figpath='./', figfile=None): |
|
96 | save=False, figpath='./', figfile=None): | |
97 |
|
97 | |||
98 | """ |
|
98 | """ | |
99 |
|
99 | |||
100 | Input: |
|
100 | Input: | |
101 | dataOut : |
|
101 | dataOut : | |
102 | idfigure : |
|
102 | idfigure : | |
103 | wintitle : |
|
103 | wintitle : | |
104 | channelList : |
|
104 | channelList : | |
105 | showProfile : |
|
105 | showProfile : | |
106 | xmin : None, |
|
106 | xmin : None, | |
107 | xmax : None, |
|
107 | xmax : None, | |
108 | ymin : None, |
|
108 | ymin : None, | |
109 | ymax : None, |
|
109 | ymax : None, | |
110 | zmin : None, |
|
110 | zmin : None, | |
111 | zmax : None |
|
111 | zmax : None | |
112 | """ |
|
112 | """ | |
113 |
|
113 | |||
114 | if channelList == None: |
|
114 | if channelList == None: | |
115 | channelIndexList = dataOut.channelIndexList |
|
115 | channelIndexList = dataOut.channelIndexList | |
116 | else: |
|
116 | else: | |
117 | channelIndexList = [] |
|
117 | channelIndexList = [] | |
118 | for channel in channelList: |
|
118 | for channel in channelList: | |
119 | if channel not in dataOut.channelList: |
|
119 | if channel not in dataOut.channelList: | |
120 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
120 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
121 | channelIndexList.append(channel) |
|
121 | channelIndexList.append(dataOut.channelList.index(chachannel)) | |
122 |
|
122 | |||
123 | if timerange != None: |
|
123 | if timerange != None: | |
124 | self.__timerange = timerange |
|
124 | self.__timerange = timerange | |
125 |
|
125 | |||
126 | tmin = None |
|
126 | tmin = None | |
127 | tmax = None |
|
127 | tmax = None | |
128 | x = dataOut.getDatatime() |
|
128 | x = dataOut.getDatatime() | |
129 | y = dataOut.getHeiRange() |
|
129 | y = dataOut.getHeiRange() | |
130 | z = 10.*numpy.log10(dataOut.data_spc[channelIndexList,:,:]) |
|
130 | z = 10.*numpy.log10(dataOut.data_spc[channelIndexList,:,:]) | |
131 | avg = numpy.average(z, axis=1) |
|
131 | avg = numpy.average(z, axis=1) | |
132 |
|
132 | |||
133 | noise = dataOut.getNoise() |
|
133 | noise = dataOut.getNoise() | |
134 |
|
134 | |||
135 | if not self.__isConfig: |
|
135 | if not self.__isConfig: | |
136 |
|
136 | |||
137 | nplots = len(channelIndexList) |
|
137 | nplots = len(channelIndexList) | |
138 |
|
138 | |||
139 | self.setup(idfigure=idfigure, |
|
139 | self.setup(idfigure=idfigure, | |
140 | nplots=nplots, |
|
140 | nplots=nplots, | |
141 | wintitle=wintitle, |
|
141 | wintitle=wintitle, | |
142 | showprofile=showprofile) |
|
142 | showprofile=showprofile) | |
143 |
|
143 | |||
144 | tmin, tmax = self.__getTimeLim(x, xmin, xmax) |
|
144 | tmin, tmax = self.__getTimeLim(x, xmin, xmax) | |
145 | if ymin == None: ymin = numpy.nanmin(y) |
|
145 | if ymin == None: ymin = numpy.nanmin(y) | |
146 | if ymax == None: ymax = numpy.nanmax(y) |
|
146 | if ymax == None: ymax = numpy.nanmax(y) | |
147 | if zmin == None: zmin = numpy.nanmin(avg)*0.9 |
|
147 | if zmin == None: zmin = numpy.nanmin(avg)*0.9 | |
148 | if zmax == None: zmax = numpy.nanmax(avg)*0.9 |
|
148 | if zmax == None: zmax = numpy.nanmax(avg)*0.9 | |
149 |
|
149 | |||
150 | self.__isConfig = True |
|
150 | self.__isConfig = True | |
151 |
|
151 | |||
152 | thisDatetime = datetime.datetime.fromtimestamp(dataOut.utctime) |
|
152 | thisDatetime = datetime.datetime.fromtimestamp(dataOut.utctime) | |
153 | title = "RTI: %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
153 | title = "RTI: %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
154 | xlabel = "Velocity (m/s)" |
|
154 | xlabel = "Velocity (m/s)" | |
155 | ylabel = "Range (Km)" |
|
155 | ylabel = "Range (Km)" | |
156 |
|
156 | |||
157 | self.setWinTitle(title) |
|
157 | self.setWinTitle(title) | |
158 |
|
158 | |||
159 | for i in range(self.nplots): |
|
159 | for i in range(self.nplots): | |
160 | title = "Channel %d: %s" %(dataOut.channelList[i], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
160 | title = "Channel %d: %s" %(dataOut.channelList[i], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
161 | axes = self.axesList[i*self.__nsubplots] |
|
161 | axes = self.axesList[i*self.__nsubplots] | |
162 | z = avg[i].reshape((1,-1)) |
|
162 | z = avg[i].reshape((1,-1)) | |
163 | axes.pcolor(x, y, z, |
|
163 | axes.pcolor(x, y, z, | |
164 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
164 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
165 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
165 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
166 | ticksize=9, cblabel='', cbsize="1%") |
|
166 | ticksize=9, cblabel='', cbsize="1%") | |
167 |
|
167 | |||
168 | if self.__showprofile: |
|
168 | if self.__showprofile: | |
169 | axes = self.axesList[i*self.__nsubplots +1] |
|
169 | axes = self.axesList[i*self.__nsubplots +1] | |
170 | axes.pline(avg[i], y, |
|
170 | axes.pline(avg[i], y, | |
171 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, |
|
171 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, | |
172 | xlabel='dB', ylabel='', title='', |
|
172 | xlabel='dB', ylabel='', title='', | |
173 | ytick_visible=False, |
|
173 | ytick_visible=False, | |
174 | grid='x') |
|
174 | grid='x') | |
175 |
|
175 | |||
176 | self.draw() |
|
176 | self.draw() | |
177 |
|
177 | |||
178 | if save: |
|
178 | if save: | |
179 | date = thisDatetime.strftime("%Y%m%d") |
|
179 | date = thisDatetime.strftime("%Y%m%d") | |
180 | if figfile == None: |
|
180 | if figfile == None: | |
181 | figfile = self.getFilename(name = date) |
|
181 | figfile = self.getFilename(name = date) | |
182 |
|
182 | |||
183 | self.saveFigure(figpath, figfile) |
|
183 | self.saveFigure(figpath, figfile) | |
184 |
|
184 | |||
185 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: |
|
185 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: | |
186 | self.__isConfig = False |
|
186 | self.__isConfig = False | |
187 |
|
187 | |||
188 | class SpectraPlot(Figure): |
|
188 | class SpectraPlot(Figure): | |
189 |
|
189 | |||
190 | __isConfig = None |
|
190 | __isConfig = None | |
191 | __nsubplots = None |
|
191 | __nsubplots = None | |
192 |
|
192 | |||
193 | WIDTHPROF = None |
|
193 | WIDTHPROF = None | |
194 | HEIGHTPROF = None |
|
194 | HEIGHTPROF = None | |
195 | PREFIX = 'spc' |
|
195 | PREFIX = 'spc' | |
196 |
|
196 | |||
197 | def __init__(self): |
|
197 | def __init__(self): | |
198 |
|
198 | |||
199 | self.__isConfig = False |
|
199 | self.__isConfig = False | |
200 | self.__nsubplots = 1 |
|
200 | self.__nsubplots = 1 | |
201 |
|
201 | |||
202 | self.WIDTH = 300 |
|
202 | self.WIDTH = 300 | |
203 | self.HEIGHT = 400 |
|
203 | self.HEIGHT = 400 | |
204 | self.WIDTHPROF = 120 |
|
204 | self.WIDTHPROF = 120 | |
205 | self.HEIGHTPROF = 0 |
|
205 | self.HEIGHTPROF = 0 | |
206 |
|
206 | |||
207 | def getSubplots(self): |
|
207 | def getSubplots(self): | |
208 |
|
208 | |||
209 | ncol = int(numpy.sqrt(self.nplots)+0.9) |
|
209 | ncol = int(numpy.sqrt(self.nplots)+0.9) | |
210 | nrow = int(self.nplots*1./ncol + 0.9) |
|
210 | nrow = int(self.nplots*1./ncol + 0.9) | |
211 |
|
211 | |||
212 | return nrow, ncol |
|
212 | return nrow, ncol | |
213 |
|
213 | |||
214 | def setup(self, idfigure, nplots, wintitle, showprofile=True): |
|
214 | def setup(self, idfigure, nplots, wintitle, showprofile=True): | |
215 |
|
215 | |||
216 | self.__showprofile = showprofile |
|
216 | self.__showprofile = showprofile | |
217 | self.nplots = nplots |
|
217 | self.nplots = nplots | |
218 |
|
218 | |||
219 | ncolspan = 1 |
|
219 | ncolspan = 1 | |
220 | colspan = 1 |
|
220 | colspan = 1 | |
221 | if showprofile: |
|
221 | if showprofile: | |
222 | ncolspan = 3 |
|
222 | ncolspan = 3 | |
223 | colspan = 2 |
|
223 | colspan = 2 | |
224 | self.__nsubplots = 2 |
|
224 | self.__nsubplots = 2 | |
225 |
|
225 | |||
226 | self.createFigure(idfigure = idfigure, |
|
226 | self.createFigure(idfigure = idfigure, | |
227 | wintitle = wintitle, |
|
227 | wintitle = wintitle, | |
228 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
228 | widthplot = self.WIDTH + self.WIDTHPROF, | |
229 | heightplot = self.HEIGHT + self.HEIGHTPROF) |
|
229 | heightplot = self.HEIGHT + self.HEIGHTPROF) | |
230 |
|
230 | |||
231 | nrow, ncol = self.getSubplots() |
|
231 | nrow, ncol = self.getSubplots() | |
232 |
|
232 | |||
233 | counter = 0 |
|
233 | counter = 0 | |
234 | for y in range(nrow): |
|
234 | for y in range(nrow): | |
235 | for x in range(ncol): |
|
235 | for x in range(ncol): | |
236 |
|
236 | |||
237 | if counter >= self.nplots: |
|
237 | if counter >= self.nplots: | |
238 | break |
|
238 | break | |
239 |
|
239 | |||
240 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
240 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
241 |
|
241 | |||
242 | if showprofile: |
|
242 | if showprofile: | |
243 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
243 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
244 |
|
244 | |||
245 | counter += 1 |
|
245 | counter += 1 | |
246 |
|
246 | |||
247 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', |
|
247 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', | |
248 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
248 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
249 | save=False, figpath='./', figfile=None): |
|
249 | save=False, figpath='./', figfile=None): | |
250 |
|
250 | |||
251 | """ |
|
251 | """ | |
252 |
|
252 | |||
253 | Input: |
|
253 | Input: | |
254 | dataOut : |
|
254 | dataOut : | |
255 | idfigure : |
|
255 | idfigure : | |
256 | wintitle : |
|
256 | wintitle : | |
257 | channelList : |
|
257 | channelList : | |
258 | showProfile : |
|
258 | showProfile : | |
259 | xmin : None, |
|
259 | xmin : None, | |
260 | xmax : None, |
|
260 | xmax : None, | |
261 | ymin : None, |
|
261 | ymin : None, | |
262 | ymax : None, |
|
262 | ymax : None, | |
263 | zmin : None, |
|
263 | zmin : None, | |
264 | zmax : None |
|
264 | zmax : None | |
265 | """ |
|
265 | """ | |
266 |
|
266 | |||
267 | if channelList == None: |
|
267 | if channelList == None: | |
268 | channelIndexList = dataOut.channelIndexList |
|
268 | channelIndexList = dataOut.channelIndexList | |
269 | else: |
|
269 | else: | |
270 | channelIndexList = [] |
|
270 | channelIndexList = [] | |
271 | for channel in channelList: |
|
271 | for channel in channelList: | |
272 | if channel not in dataOut.channelList: |
|
272 | if channel not in dataOut.channelList: | |
273 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
273 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
274 | channelIndexList.append(channelList.index(channel)) |
|
274 | channelIndexList.append(dataOut.channelList.index(channel)) | |
275 |
|
275 | |||
276 | x = dataOut.getVelRange(1) |
|
276 | x = dataOut.getVelRange(1) | |
277 | y = dataOut.getHeiRange() |
|
277 | y = dataOut.getHeiRange() | |
278 | z = 10.*numpy.log10(dataOut.data_spc[channelIndexList,:,:]) |
|
278 | z = 10.*numpy.log10(dataOut.data_spc[channelIndexList,:,:]) | |
279 | avg = numpy.average(z, axis=1) |
|
279 | avg = numpy.average(z, axis=1) | |
280 |
|
280 | |||
281 | noise = dataOut.getNoise() |
|
281 | noise = dataOut.getNoise() | |
282 |
|
282 | |||
283 | if not self.__isConfig: |
|
283 | if not self.__isConfig: | |
284 |
|
284 | |||
285 | nplots = len(channelIndexList) |
|
285 | nplots = len(channelIndexList) | |
286 |
|
286 | |||
287 | self.setup(idfigure=idfigure, |
|
287 | self.setup(idfigure=idfigure, | |
288 | nplots=nplots, |
|
288 | nplots=nplots, | |
289 | wintitle=wintitle, |
|
289 | wintitle=wintitle, | |
290 | showprofile=showprofile) |
|
290 | showprofile=showprofile) | |
291 |
|
291 | |||
292 | if xmin == None: xmin = numpy.nanmin(x) |
|
292 | if xmin == None: xmin = numpy.nanmin(x) | |
293 | if xmax == None: xmax = numpy.nanmax(x) |
|
293 | if xmax == None: xmax = numpy.nanmax(x) | |
294 | if ymin == None: ymin = numpy.nanmin(y) |
|
294 | if ymin == None: ymin = numpy.nanmin(y) | |
295 | if ymax == None: ymax = numpy.nanmax(y) |
|
295 | if ymax == None: ymax = numpy.nanmax(y) | |
296 | if zmin == None: zmin = numpy.nanmin(avg)*0.9 |
|
296 | if zmin == None: zmin = numpy.nanmin(avg)*0.9 | |
297 | if zmax == None: zmax = numpy.nanmax(avg)*0.9 |
|
297 | if zmax == None: zmax = numpy.nanmax(avg)*0.9 | |
298 |
|
298 | |||
299 | self.__isConfig = True |
|
299 | self.__isConfig = True | |
300 |
|
300 | |||
301 | thisDatetime = datetime.datetime.fromtimestamp(dataOut.utctime) |
|
301 | thisDatetime = datetime.datetime.fromtimestamp(dataOut.utctime) | |
302 | title = "Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
302 | title = "Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
303 | xlabel = "Velocity (m/s)" |
|
303 | xlabel = "Velocity (m/s)" | |
304 | ylabel = "Range (Km)" |
|
304 | ylabel = "Range (Km)" | |
305 |
|
305 | |||
306 | self.setWinTitle(title) |
|
306 | self.setWinTitle(title) | |
307 |
|
307 | |||
308 | for i in range(self.nplots): |
|
308 | for i in range(self.nplots): | |
309 | title = "Channel %d: %4.2fdB" %(dataOut.channelList[i], noise[i]) |
|
309 | title = "Channel %d: %4.2fdB" %(dataOut.channelList[i], noise[i]) | |
310 | axes = self.axesList[i*self.__nsubplots] |
|
310 | axes = self.axesList[i*self.__nsubplots] | |
311 | axes.pcolor(x, y, z[i,:,:], |
|
311 | axes.pcolor(x, y, z[i,:,:], | |
312 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
312 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
313 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
313 | xlabel=xlabel, ylabel=ylabel, title=title, | |
314 | ticksize=9, cblabel='') |
|
314 | ticksize=9, cblabel='') | |
315 |
|
315 | |||
316 | if self.__showprofile: |
|
316 | if self.__showprofile: | |
317 | axes = self.axesList[i*self.__nsubplots +1] |
|
317 | axes = self.axesList[i*self.__nsubplots +1] | |
318 | axes.pline(avg[i], y, |
|
318 | axes.pline(avg[i], y, | |
319 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, |
|
319 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, | |
320 | xlabel='dB', ylabel='', title='', |
|
320 | xlabel='dB', ylabel='', title='', | |
321 | ytick_visible=False, |
|
321 | ytick_visible=False, | |
322 | grid='x') |
|
322 | grid='x') | |
323 |
|
323 | |||
324 | self.draw() |
|
324 | self.draw() | |
325 |
|
325 | |||
326 | if save: |
|
326 | if save: | |
327 | date = thisDatetime.strftime("%Y%m%d") |
|
327 | date = thisDatetime.strftime("%Y%m%d") | |
328 | if figfile == None: |
|
328 | if figfile == None: | |
329 | figfile = self.getFilename(name = date) |
|
329 | figfile = self.getFilename(name = date) | |
330 |
|
330 | |||
331 | self.saveFigure(figpath, figfile) |
|
331 | self.saveFigure(figpath, figfile) | |
332 |
|
332 | |||
333 | class Scope(Figure): |
|
333 | class Scope(Figure): | |
334 |
|
334 | |||
335 | __isConfig = None |
|
335 | __isConfig = None | |
336 |
|
336 | |||
337 | def __init__(self): |
|
337 | def __init__(self): | |
338 |
|
338 | |||
339 | self.__isConfig = False |
|
339 | self.__isConfig = False | |
340 | self.WIDTH = 600 |
|
340 | self.WIDTH = 600 | |
341 | self.HEIGHT = 200 |
|
341 | self.HEIGHT = 200 | |
342 |
|
342 | |||
343 | def getSubplots(self): |
|
343 | def getSubplots(self): | |
344 |
|
344 | |||
345 | nrow = self.nplots |
|
345 | nrow = self.nplots | |
346 | ncol = 3 |
|
346 | ncol = 3 | |
347 | return nrow, ncol |
|
347 | return nrow, ncol | |
348 |
|
348 | |||
349 | def setup(self, idfigure, nplots, wintitle): |
|
349 | def setup(self, idfigure, nplots, wintitle): | |
350 |
|
350 | |||
351 | self.createFigure(idfigure, wintitle) |
|
351 | self.createFigure(idfigure, wintitle) | |
352 |
|
352 | |||
353 | nrow,ncol = self.getSubplots() |
|
353 | nrow,ncol = self.getSubplots() | |
354 | colspan = 3 |
|
354 | colspan = 3 | |
355 | rowspan = 1 |
|
355 | rowspan = 1 | |
356 |
|
356 | |||
357 | for i in range(nplots): |
|
357 | for i in range(nplots): | |
358 | self.addAxes(nrow, ncol, i, 0, colspan, rowspan) |
|
358 | self.addAxes(nrow, ncol, i, 0, colspan, rowspan) | |
359 |
|
359 | |||
360 | self.nplots = nplots |
|
360 | self.nplots = nplots | |
361 |
|
361 | |||
362 | def run(self, dataOut, idfigure, wintitle="", channelList=None, |
|
362 | def run(self, dataOut, idfigure, wintitle="", channelList=None, | |
363 | xmin=None, xmax=None, ymin=None, ymax=None, save=False, filename=None): |
|
363 | xmin=None, xmax=None, ymin=None, ymax=None, save=False, filename=None): | |
364 |
|
364 | |||
365 | """ |
|
365 | """ | |
366 |
|
366 | |||
367 | Input: |
|
367 | Input: | |
368 | dataOut : |
|
368 | dataOut : | |
369 | idfigure : |
|
369 | idfigure : | |
370 | wintitle : |
|
370 | wintitle : | |
371 | channelList : |
|
371 | channelList : | |
372 | xmin : None, |
|
372 | xmin : None, | |
373 | xmax : None, |
|
373 | xmax : None, | |
374 | ymin : None, |
|
374 | ymin : None, | |
375 | ymax : None, |
|
375 | ymax : None, | |
376 | """ |
|
376 | """ | |
377 |
|
377 | |||
378 | if channelList == None: |
|
378 | if channelList == None: | |
379 | channelList = dataOut.channelList |
|
379 | channelIndexList = dataOut.channelIndexList | |
|
380 | else: | |||
|
381 | channelIndexList = [] | |||
|
382 | for channel in channelList: | |||
|
383 | if channel not in dataOut.channelList: | |||
|
384 | raise ValueError, "Channel %d is not in dataOut.channelList" | |||
|
385 | channelIndexList.append(dataOut.channelList.index(chachannel)) | |||
380 |
|
386 | |||
381 | x = dataOut.heightList |
|
387 | x = dataOut.heightList | |
382 | y = dataOut.data[channelList,:] * numpy.conjugate(dataOut.data[channelList,:]) |
|
388 | y = dataOut.data[channelList,:] * numpy.conjugate(dataOut.data[channelList,:]) | |
383 | y = y.real |
|
389 | y = y.real | |
384 |
|
390 | |||
385 | noise = dataOut.getNoise() |
|
391 | noise = dataOut.getNoise() | |
386 |
|
392 | |||
387 | if not self.__isConfig: |
|
393 | if not self.__isConfig: | |
388 | nplots = len(channelList) |
|
394 | nplots = len(channelList) | |
389 |
|
395 | |||
390 | self.setup(idfigure=idfigure, |
|
396 | self.setup(idfigure=idfigure, | |
391 | nplots=nplots, |
|
397 | nplots=nplots, | |
392 | wintitle=wintitle) |
|
398 | wintitle=wintitle) | |
393 |
|
399 | |||
394 | if xmin == None: xmin = numpy.nanmin(x) |
|
400 | if xmin == None: xmin = numpy.nanmin(x) | |
395 | if xmax == None: xmax = numpy.nanmax(x) |
|
401 | if xmax == None: xmax = numpy.nanmax(x) | |
396 | if ymin == None: ymin = numpy.nanmin(y) |
|
402 | if ymin == None: ymin = numpy.nanmin(y) | |
397 | if ymax == None: ymax = numpy.nanmax(y) |
|
403 | if ymax == None: ymax = numpy.nanmax(y) | |
398 |
|
404 | |||
399 | self.__isConfig = True |
|
405 | self.__isConfig = True | |
400 |
|
406 | |||
401 |
|
407 | |||
402 | thisDatetime = datetime.datetime.fromtimestamp(dataOut.utctime) |
|
408 | thisDatetime = datetime.datetime.fromtimestamp(dataOut.utctime) | |
403 | title = "Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
409 | title = "Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
404 | xlabel = "Range (Km)" |
|
410 | xlabel = "Range (Km)" | |
405 | ylabel = "Intensity" |
|
411 | ylabel = "Intensity" | |
406 |
|
412 | |||
407 | self.setWinTitle(title) |
|
413 | self.setWinTitle(title) | |
408 |
|
414 | |||
409 | for i in range(len(self.axesList)): |
|
415 | for i in range(len(self.axesList)): | |
410 | title = "Channel %d: %4.2fdB" %(i, noise[i]) |
|
416 | title = "Channel %d: %4.2fdB" %(i, noise[i]) | |
411 | axes = self.axesList[i] |
|
417 | axes = self.axesList[i] | |
412 | ychannel = y[i,:] |
|
418 | ychannel = y[i,:] | |
413 | axes.pline(x, ychannel, |
|
419 | axes.pline(x, ychannel, | |
414 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, |
|
420 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, | |
415 | xlabel=xlabel, ylabel=ylabel, title=title) |
|
421 | xlabel=xlabel, ylabel=ylabel, title=title) | |
416 |
|
422 | |||
417 | self.draw() |
|
423 | self.draw() | |
418 |
|
424 | |||
419 | if save: |
|
425 | if save: | |
420 | self.saveFigure(filename) |
|
426 | self.saveFigure(filename) | |
421 | No newline at end of file |
|
427 |
General Comments 0
You need to be logged in to leave comments.
Login now