@@ -1,1372 +1,1373 | |||||
1 | import os |
|
1 | import os | |
2 | import datetime |
|
2 | import datetime | |
3 | import numpy |
|
3 | import numpy | |
4 |
|
4 | |||
5 | from figure import Figure, isRealtime |
|
5 | from figure import Figure, isRealtime | |
6 | from plotting_codes import * |
|
6 | from plotting_codes import * | |
7 |
|
7 | |||
8 | class MomentsPlot(Figure): |
|
8 | class MomentsPlot(Figure): | |
9 |
|
9 | |||
10 | isConfig = None |
|
10 | isConfig = None | |
11 | __nsubplots = None |
|
11 | __nsubplots = None | |
12 |
|
12 | |||
13 | WIDTHPROF = None |
|
13 | WIDTHPROF = None | |
14 | HEIGHTPROF = None |
|
14 | HEIGHTPROF = None | |
15 | PREFIX = 'prm' |
|
15 | PREFIX = 'prm' | |
16 |
|
16 | |||
17 | def __init__(self): |
|
17 | def __init__(self): | |
18 |
|
18 | |||
19 | self.isConfig = False |
|
19 | self.isConfig = False | |
20 | self.__nsubplots = 1 |
|
20 | self.__nsubplots = 1 | |
21 |
|
21 | |||
22 | self.WIDTH = 280 |
|
22 | self.WIDTH = 280 | |
23 | self.HEIGHT = 250 |
|
23 | self.HEIGHT = 250 | |
24 | self.WIDTHPROF = 120 |
|
24 | self.WIDTHPROF = 120 | |
25 | self.HEIGHTPROF = 0 |
|
25 | self.HEIGHTPROF = 0 | |
26 | self.counter_imagwr = 0 |
|
26 | self.counter_imagwr = 0 | |
27 |
|
27 | |||
28 | self.PLOT_CODE = MOMENTS_CODE |
|
28 | self.PLOT_CODE = MOMENTS_CODE | |
29 |
|
29 | |||
30 | self.FTP_WEI = None |
|
30 | self.FTP_WEI = None | |
31 | self.EXP_CODE = None |
|
31 | self.EXP_CODE = None | |
32 | self.SUB_EXP_CODE = None |
|
32 | self.SUB_EXP_CODE = None | |
33 | self.PLOT_POS = None |
|
33 | self.PLOT_POS = None | |
34 |
|
34 | |||
35 | def getSubplots(self): |
|
35 | def getSubplots(self): | |
36 |
|
36 | |||
37 | ncol = int(numpy.sqrt(self.nplots)+0.9) |
|
37 | ncol = int(numpy.sqrt(self.nplots)+0.9) | |
38 | nrow = int(self.nplots*1./ncol + 0.9) |
|
38 | nrow = int(self.nplots*1./ncol + 0.9) | |
39 |
|
39 | |||
40 | return nrow, ncol |
|
40 | return nrow, ncol | |
41 |
|
41 | |||
42 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
42 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
43 |
|
43 | |||
44 | self.__showprofile = showprofile |
|
44 | self.__showprofile = showprofile | |
45 | self.nplots = nplots |
|
45 | self.nplots = nplots | |
46 |
|
46 | |||
47 | ncolspan = 1 |
|
47 | ncolspan = 1 | |
48 | colspan = 1 |
|
48 | colspan = 1 | |
49 | if showprofile: |
|
49 | if showprofile: | |
50 | ncolspan = 3 |
|
50 | ncolspan = 3 | |
51 | colspan = 2 |
|
51 | colspan = 2 | |
52 | self.__nsubplots = 2 |
|
52 | self.__nsubplots = 2 | |
53 |
|
53 | |||
54 | self.createFigure(id = id, |
|
54 | self.createFigure(id = id, | |
55 | wintitle = wintitle, |
|
55 | wintitle = wintitle, | |
56 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
56 | widthplot = self.WIDTH + self.WIDTHPROF, | |
57 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
57 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
58 | show=show) |
|
58 | show=show) | |
59 |
|
59 | |||
60 | nrow, ncol = self.getSubplots() |
|
60 | nrow, ncol = self.getSubplots() | |
61 |
|
61 | |||
62 | counter = 0 |
|
62 | counter = 0 | |
63 | for y in range(nrow): |
|
63 | for y in range(nrow): | |
64 | for x in range(ncol): |
|
64 | for x in range(ncol): | |
65 |
|
65 | |||
66 | if counter >= self.nplots: |
|
66 | if counter >= self.nplots: | |
67 | break |
|
67 | break | |
68 |
|
68 | |||
69 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
69 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
70 |
|
70 | |||
71 | if showprofile: |
|
71 | if showprofile: | |
72 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
72 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
73 |
|
73 | |||
74 | counter += 1 |
|
74 | counter += 1 | |
75 |
|
75 | |||
76 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True, |
|
76 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True, | |
77 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
77 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
78 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, |
|
78 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, | |
79 | server=None, folder=None, username=None, password=None, |
|
79 | server=None, folder=None, username=None, password=None, | |
80 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False): |
|
80 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False): | |
81 |
|
81 | |||
82 | """ |
|
82 | """ | |
83 |
|
83 | |||
84 | Input: |
|
84 | Input: | |
85 | dataOut : |
|
85 | dataOut : | |
86 | id : |
|
86 | id : | |
87 | wintitle : |
|
87 | wintitle : | |
88 | channelList : |
|
88 | channelList : | |
89 | showProfile : |
|
89 | showProfile : | |
90 | xmin : None, |
|
90 | xmin : None, | |
91 | xmax : None, |
|
91 | xmax : None, | |
92 | ymin : None, |
|
92 | ymin : None, | |
93 | ymax : None, |
|
93 | ymax : None, | |
94 | zmin : None, |
|
94 | zmin : None, | |
95 | zmax : None |
|
95 | zmax : None | |
96 | """ |
|
96 | """ | |
97 |
|
97 | |||
98 | if dataOut.flagNoData: |
|
98 | if dataOut.flagNoData: | |
99 | return None |
|
99 | return None | |
100 |
|
100 | |||
101 | if realtime: |
|
101 | if realtime: | |
102 | if not(isRealtime(utcdatatime = dataOut.utctime)): |
|
102 | if not(isRealtime(utcdatatime = dataOut.utctime)): | |
103 | print 'Skipping this plot function' |
|
103 | print 'Skipping this plot function' | |
104 | return |
|
104 | return | |
105 |
|
105 | |||
106 | if channelList == None: |
|
106 | if channelList == None: | |
107 | channelIndexList = dataOut.channelIndexList |
|
107 | channelIndexList = dataOut.channelIndexList | |
108 | else: |
|
108 | else: | |
109 | channelIndexList = [] |
|
109 | channelIndexList = [] | |
110 | for channel in channelList: |
|
110 | for channel in channelList: | |
111 | if channel not in dataOut.channelList: |
|
111 | if channel not in dataOut.channelList: | |
112 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
112 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
113 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
113 | channelIndexList.append(dataOut.channelList.index(channel)) | |
114 |
|
114 | |||
115 | factor = dataOut.normFactor |
|
115 | factor = dataOut.normFactor | |
116 | x = dataOut.abscissaList |
|
116 | x = dataOut.abscissaList | |
117 | y = dataOut.heightList |
|
117 | y = dataOut.heightList | |
118 |
|
118 | |||
119 | z = dataOut.data_pre[channelIndexList,:,:]/factor |
|
119 | z = dataOut.data_pre[channelIndexList,:,:]/factor | |
120 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
120 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
121 | avg = numpy.average(z, axis=1) |
|
121 | avg = numpy.average(z, axis=1) | |
122 | noise = dataOut.noise/factor |
|
122 | noise = dataOut.noise/factor | |
123 |
|
123 | |||
124 | zdB = 10*numpy.log10(z) |
|
124 | zdB = 10*numpy.log10(z) | |
125 | avgdB = 10*numpy.log10(avg) |
|
125 | avgdB = 10*numpy.log10(avg) | |
126 | noisedB = 10*numpy.log10(noise) |
|
126 | noisedB = 10*numpy.log10(noise) | |
127 |
|
127 | |||
128 | #thisDatetime = dataOut.datatime |
|
128 | #thisDatetime = dataOut.datatime | |
129 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) |
|
129 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) | |
130 | title = wintitle + " Parameters" |
|
130 | title = wintitle + " Parameters" | |
131 | xlabel = "Velocity (m/s)" |
|
131 | xlabel = "Velocity (m/s)" | |
132 | ylabel = "Range (Km)" |
|
132 | ylabel = "Range (Km)" | |
133 |
|
133 | |||
134 | update_figfile = False |
|
134 | update_figfile = False | |
135 |
|
135 | |||
136 | if not self.isConfig: |
|
136 | if not self.isConfig: | |
137 |
|
137 | |||
138 | nplots = len(channelIndexList) |
|
138 | nplots = len(channelIndexList) | |
139 |
|
139 | |||
140 | self.setup(id=id, |
|
140 | self.setup(id=id, | |
141 | nplots=nplots, |
|
141 | nplots=nplots, | |
142 | wintitle=wintitle, |
|
142 | wintitle=wintitle, | |
143 | showprofile=showprofile, |
|
143 | showprofile=showprofile, | |
144 | show=show) |
|
144 | show=show) | |
145 |
|
145 | |||
146 | if xmin == None: xmin = numpy.nanmin(x) |
|
146 | if xmin == None: xmin = numpy.nanmin(x) | |
147 | if xmax == None: xmax = numpy.nanmax(x) |
|
147 | if xmax == None: xmax = numpy.nanmax(x) | |
148 | if ymin == None: ymin = numpy.nanmin(y) |
|
148 | if ymin == None: ymin = numpy.nanmin(y) | |
149 | if ymax == None: ymax = numpy.nanmax(y) |
|
149 | if ymax == None: ymax = numpy.nanmax(y) | |
150 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 |
|
150 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 | |
151 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 |
|
151 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 | |
152 |
|
152 | |||
153 | self.FTP_WEI = ftp_wei |
|
153 | self.FTP_WEI = ftp_wei | |
154 | self.EXP_CODE = exp_code |
|
154 | self.EXP_CODE = exp_code | |
155 | self.SUB_EXP_CODE = sub_exp_code |
|
155 | self.SUB_EXP_CODE = sub_exp_code | |
156 | self.PLOT_POS = plot_pos |
|
156 | self.PLOT_POS = plot_pos | |
157 |
|
157 | |||
158 | self.isConfig = True |
|
158 | self.isConfig = True | |
159 | update_figfile = True |
|
159 | update_figfile = True | |
160 |
|
160 | |||
161 | self.setWinTitle(title) |
|
161 | self.setWinTitle(title) | |
162 |
|
162 | |||
163 | for i in range(self.nplots): |
|
163 | for i in range(self.nplots): | |
164 | str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) |
|
164 | str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) | |
165 | title = "Channel %d: %4.2fdB: %s" %(dataOut.channelList[i], noisedB[i], str_datetime) |
|
165 | title = "Channel %d: %4.2fdB: %s" %(dataOut.channelList[i], noisedB[i], str_datetime) | |
166 | axes = self.axesList[i*self.__nsubplots] |
|
166 | axes = self.axesList[i*self.__nsubplots] | |
167 | axes.pcolor(x, y, zdB[i,:,:], |
|
167 | axes.pcolor(x, y, zdB[i,:,:], | |
168 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
168 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
169 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
169 | xlabel=xlabel, ylabel=ylabel, title=title, | |
170 | ticksize=9, cblabel='') |
|
170 | ticksize=9, cblabel='') | |
171 | #Mean Line |
|
171 | #Mean Line | |
172 | mean = dataOut.data_param[i, 1, :] |
|
172 | mean = dataOut.data_param[i, 1, :] | |
173 | axes.addpline(mean, y, idline=0, color="black", linestyle="solid", lw=1) |
|
173 | axes.addpline(mean, y, idline=0, color="black", linestyle="solid", lw=1) | |
174 |
|
174 | |||
175 | if self.__showprofile: |
|
175 | if self.__showprofile: | |
176 | axes = self.axesList[i*self.__nsubplots +1] |
|
176 | axes = self.axesList[i*self.__nsubplots +1] | |
177 | axes.pline(avgdB[i], y, |
|
177 | axes.pline(avgdB[i], y, | |
178 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, |
|
178 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, | |
179 | xlabel='dB', ylabel='', title='', |
|
179 | xlabel='dB', ylabel='', title='', | |
180 | ytick_visible=False, |
|
180 | ytick_visible=False, | |
181 | grid='x') |
|
181 | grid='x') | |
182 |
|
182 | |||
183 | noiseline = numpy.repeat(noisedB[i], len(y)) |
|
183 | noiseline = numpy.repeat(noisedB[i], len(y)) | |
184 | axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2) |
|
184 | axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2) | |
185 |
|
185 | |||
186 | self.draw() |
|
186 | self.draw() | |
187 |
|
187 | |||
188 | self.save(figpath=figpath, |
|
188 | self.save(figpath=figpath, | |
189 | figfile=figfile, |
|
189 | figfile=figfile, | |
190 | save=save, |
|
190 | save=save, | |
191 | ftp=ftp, |
|
191 | ftp=ftp, | |
192 | wr_period=wr_period, |
|
192 | wr_period=wr_period, | |
193 | thisDatetime=thisDatetime) |
|
193 | thisDatetime=thisDatetime) | |
194 |
|
194 | |||
195 |
|
195 | |||
196 |
|
196 | |||
197 | class SkyMapPlot(Figure): |
|
197 | class SkyMapPlot(Figure): | |
198 |
|
198 | |||
199 | __isConfig = None |
|
199 | __isConfig = None | |
200 | __nsubplots = None |
|
200 | __nsubplots = None | |
201 |
|
201 | |||
202 | WIDTHPROF = None |
|
202 | WIDTHPROF = None | |
203 | HEIGHTPROF = None |
|
203 | HEIGHTPROF = None | |
204 | PREFIX = 'mmap' |
|
204 | PREFIX = 'mmap' | |
205 |
|
205 | |||
206 | def __init__(self): |
|
206 | def __init__(self): | |
207 |
|
207 | |||
208 | self.__isConfig = False |
|
208 | self.__isConfig = False | |
209 | self.__nsubplots = 1 |
|
209 | self.__nsubplots = 1 | |
210 |
|
210 | |||
211 | # self.WIDTH = 280 |
|
211 | # self.WIDTH = 280 | |
212 | # self.HEIGHT = 250 |
|
212 | # self.HEIGHT = 250 | |
213 | self.WIDTH = 600 |
|
213 | self.WIDTH = 600 | |
214 | self.HEIGHT = 600 |
|
214 | self.HEIGHT = 600 | |
215 | self.WIDTHPROF = 120 |
|
215 | self.WIDTHPROF = 120 | |
216 | self.HEIGHTPROF = 0 |
|
216 | self.HEIGHTPROF = 0 | |
217 | self.counter_imagwr = 0 |
|
217 | self.counter_imagwr = 0 | |
218 |
|
218 | |||
219 | self.PLOT_CODE = MSKYMAP_CODE |
|
219 | self.PLOT_CODE = MSKYMAP_CODE | |
220 |
|
220 | |||
221 | self.FTP_WEI = None |
|
221 | self.FTP_WEI = None | |
222 | self.EXP_CODE = None |
|
222 | self.EXP_CODE = None | |
223 | self.SUB_EXP_CODE = None |
|
223 | self.SUB_EXP_CODE = None | |
224 | self.PLOT_POS = None |
|
224 | self.PLOT_POS = None | |
225 |
|
225 | |||
226 | def getSubplots(self): |
|
226 | def getSubplots(self): | |
227 |
|
227 | |||
228 | ncol = int(numpy.sqrt(self.nplots)+0.9) |
|
228 | ncol = int(numpy.sqrt(self.nplots)+0.9) | |
229 | nrow = int(self.nplots*1./ncol + 0.9) |
|
229 | nrow = int(self.nplots*1./ncol + 0.9) | |
230 |
|
230 | |||
231 | return nrow, ncol |
|
231 | return nrow, ncol | |
232 |
|
232 | |||
233 | def setup(self, id, nplots, wintitle, showprofile=False, show=True): |
|
233 | def setup(self, id, nplots, wintitle, showprofile=False, show=True): | |
234 |
|
234 | |||
235 | self.__showprofile = showprofile |
|
235 | self.__showprofile = showprofile | |
236 | self.nplots = nplots |
|
236 | self.nplots = nplots | |
237 |
|
237 | |||
238 | ncolspan = 1 |
|
238 | ncolspan = 1 | |
239 | colspan = 1 |
|
239 | colspan = 1 | |
240 |
|
240 | |||
241 | self.createFigure(id = id, |
|
241 | self.createFigure(id = id, | |
242 | wintitle = wintitle, |
|
242 | wintitle = wintitle, | |
243 | widthplot = self.WIDTH, #+ self.WIDTHPROF, |
|
243 | widthplot = self.WIDTH, #+ self.WIDTHPROF, | |
244 | heightplot = self.HEIGHT,# + self.HEIGHTPROF, |
|
244 | heightplot = self.HEIGHT,# + self.HEIGHTPROF, | |
245 | show=show) |
|
245 | show=show) | |
246 |
|
246 | |||
247 | nrow, ncol = 1,1 |
|
247 | nrow, ncol = 1,1 | |
248 | counter = 0 |
|
248 | counter = 0 | |
249 | x = 0 |
|
249 | x = 0 | |
250 | y = 0 |
|
250 | y = 0 | |
251 | self.addAxes(1, 1, 0, 0, 1, 1, True) |
|
251 | self.addAxes(1, 1, 0, 0, 1, 1, True) | |
252 |
|
252 | |||
253 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=False, |
|
253 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=False, | |
254 | tmin=None, tmax=None, timerange=None, |
|
254 | tmin=None, tmax=None, timerange=None, | |
255 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, |
|
255 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, | |
256 | server=None, folder=None, username=None, password=None, |
|
256 | server=None, folder=None, username=None, password=None, | |
257 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False): |
|
257 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False): | |
258 |
|
258 | |||
259 | """ |
|
259 | """ | |
260 |
|
260 | |||
261 | Input: |
|
261 | Input: | |
262 | dataOut : |
|
262 | dataOut : | |
263 | id : |
|
263 | id : | |
264 | wintitle : |
|
264 | wintitle : | |
265 | channelList : |
|
265 | channelList : | |
266 | showProfile : |
|
266 | showProfile : | |
267 | xmin : None, |
|
267 | xmin : None, | |
268 | xmax : None, |
|
268 | xmax : None, | |
269 | ymin : None, |
|
269 | ymin : None, | |
270 | ymax : None, |
|
270 | ymax : None, | |
271 | zmin : None, |
|
271 | zmin : None, | |
272 | zmax : None |
|
272 | zmax : None | |
273 | """ |
|
273 | """ | |
274 |
|
274 | |||
275 | arrayParameters = dataOut.data_param[0,:] |
|
275 | arrayParameters = dataOut.data_param[0,:] | |
276 | error = arrayParameters[:,-1] |
|
276 | error = arrayParameters[:,-1] | |
277 | indValid = numpy.where(error == 0)[0] |
|
277 | indValid = numpy.where(error == 0)[0] | |
278 | finalMeteor = arrayParameters[indValid,:] |
|
278 | finalMeteor = arrayParameters[indValid,:] | |
279 | finalAzimuth = finalMeteor[:,4] |
|
279 | finalAzimuth = finalMeteor[:,4] | |
280 | finalZenith = finalMeteor[:,5] |
|
280 | finalZenith = finalMeteor[:,5] | |
281 |
|
281 | |||
282 | x = finalAzimuth*numpy.pi/180 |
|
282 | x = finalAzimuth*numpy.pi/180 | |
283 | y = finalZenith |
|
283 | y = finalZenith | |
284 | x1 = dataOut.getTimeRange() |
|
284 | x1 = dataOut.getTimeRange() | |
285 |
|
285 | |||
286 | #thisDatetime = dataOut.datatime |
|
286 | #thisDatetime = dataOut.datatime | |
287 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) |
|
287 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) | |
288 | title = wintitle + " Parameters" |
|
288 | title = wintitle + " Parameters" | |
289 | xlabel = "Zonal Zenith Angle (deg) " |
|
289 | xlabel = "Zonal Zenith Angle (deg) " | |
290 | ylabel = "Meridional Zenith Angle (deg)" |
|
290 | ylabel = "Meridional Zenith Angle (deg)" | |
291 | update_figfile = False |
|
291 | update_figfile = False | |
292 |
|
292 | |||
293 | if not self.__isConfig: |
|
293 | if not self.__isConfig: | |
294 |
|
294 | |||
295 | nplots = 1 |
|
295 | nplots = 1 | |
296 |
|
296 | |||
297 | self.setup(id=id, |
|
297 | self.setup(id=id, | |
298 | nplots=nplots, |
|
298 | nplots=nplots, | |
299 | wintitle=wintitle, |
|
299 | wintitle=wintitle, | |
300 | showprofile=showprofile, |
|
300 | showprofile=showprofile, | |
301 | show=show) |
|
301 | show=show) | |
302 |
|
302 | |||
303 | self.xmin, self.xmax = self.getTimeLim(x1, tmin, tmax, timerange) |
|
303 | if self.xmin is None and self.xmax is None: | |
|
304 | self.xmin, self.xmax = self.getTimeLim(x1, tmin, tmax, timerange) | |||
304 |
|
305 | |||
305 | if timerange != None: |
|
306 | if timerange != None: | |
306 | self.timerange = timerange |
|
307 | self.timerange = timerange | |
307 | else: |
|
308 | else: | |
308 | self.timerange = self.xmax - self.xmin |
|
309 | self.timerange = self.xmax - self.xmin | |
309 |
|
310 | |||
310 | self.FTP_WEI = ftp_wei |
|
311 | self.FTP_WEI = ftp_wei | |
311 | self.EXP_CODE = exp_code |
|
312 | self.EXP_CODE = exp_code | |
312 | self.SUB_EXP_CODE = sub_exp_code |
|
313 | self.SUB_EXP_CODE = sub_exp_code | |
313 | self.PLOT_POS = plot_pos |
|
314 | self.PLOT_POS = plot_pos | |
314 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
315 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
315 | self.firstdate = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) |
|
316 | self.firstdate = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) | |
316 | self.__isConfig = True |
|
317 | self.__isConfig = True | |
317 | update_figfile = True |
|
318 | update_figfile = True | |
318 |
|
319 | |||
319 | self.setWinTitle(title) |
|
320 | self.setWinTitle(title) | |
320 |
|
321 | |||
321 | i = 0 |
|
322 | i = 0 | |
322 | str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) |
|
323 | str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) | |
323 |
|
324 | |||
324 | axes = self.axesList[i*self.__nsubplots] |
|
325 | axes = self.axesList[i*self.__nsubplots] | |
325 | nevents = axes.x_buffer.shape[0] + x.shape[0] |
|
326 | nevents = axes.x_buffer.shape[0] + x.shape[0] | |
326 | title = "Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n" %(self.firstdate,str_datetime,nevents) |
|
327 | title = "Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n" %(self.firstdate,str_datetime,nevents) | |
327 | axes.polar(x, y, |
|
328 | axes.polar(x, y, | |
328 | title=title, xlabel=xlabel, ylabel=ylabel, |
|
329 | title=title, xlabel=xlabel, ylabel=ylabel, | |
329 | ticksize=9, cblabel='') |
|
330 | ticksize=9, cblabel='') | |
330 |
|
331 | |||
331 | self.draw() |
|
332 | self.draw() | |
332 |
|
333 | |||
333 | self.save(figpath=figpath, |
|
334 | self.save(figpath=figpath, | |
334 | figfile=figfile, |
|
335 | figfile=figfile, | |
335 | save=save, |
|
336 | save=save, | |
336 | ftp=ftp, |
|
337 | ftp=ftp, | |
337 | wr_period=wr_period, |
|
338 | wr_period=wr_period, | |
338 | thisDatetime=thisDatetime, |
|
339 | thisDatetime=thisDatetime, | |
339 | update_figfile=update_figfile) |
|
340 | update_figfile=update_figfile) | |
340 |
|
341 | |||
341 | if dataOut.ltctime >= self.xmax: |
|
342 | if dataOut.ltctime >= self.xmax: | |
342 | self.counter_imagwr = wr_period |
|
343 | self.counter_imagwr = wr_period | |
343 | self.__isConfig = False |
|
344 | self.__isConfig = False | |
344 | update_figfile = True |
|
345 | update_figfile = True | |
345 | axes.__firsttime = True |
|
346 | axes.__firsttime = True | |
346 | self.xmin += self.timerange |
|
347 | self.xmin += self.timerange | |
347 | self.xmax += self.timerange |
|
348 | self.xmax += self.timerange | |
348 |
|
349 | |||
349 |
|
350 | |||
350 |
|
351 | |||
351 |
|
352 | |||
352 | class WindProfilerPlot(Figure): |
|
353 | class WindProfilerPlot(Figure): | |
353 |
|
354 | |||
354 | __isConfig = None |
|
355 | __isConfig = None | |
355 | __nsubplots = None |
|
356 | __nsubplots = None | |
356 |
|
357 | |||
357 | WIDTHPROF = None |
|
358 | WIDTHPROF = None | |
358 | HEIGHTPROF = None |
|
359 | HEIGHTPROF = None | |
359 | PREFIX = 'wind' |
|
360 | PREFIX = 'wind' | |
360 |
|
361 | |||
361 | def __init__(self): |
|
362 | def __init__(self): | |
362 |
|
363 | |||
363 | self.timerange = None |
|
364 | self.timerange = None | |
364 | self.__isConfig = False |
|
365 | self.__isConfig = False | |
365 | self.__nsubplots = 1 |
|
366 | self.__nsubplots = 1 | |
366 |
|
367 | |||
367 | self.WIDTH = 800 |
|
368 | self.WIDTH = 800 | |
368 | self.HEIGHT = 150 |
|
369 | self.HEIGHT = 150 | |
369 | self.WIDTHPROF = 120 |
|
370 | self.WIDTHPROF = 120 | |
370 | self.HEIGHTPROF = 0 |
|
371 | self.HEIGHTPROF = 0 | |
371 | self.counter_imagwr = 0 |
|
372 | self.counter_imagwr = 0 | |
372 |
|
373 | |||
373 | self.PLOT_CODE = WIND_CODE |
|
374 | self.PLOT_CODE = WIND_CODE | |
374 |
|
375 | |||
375 | self.FTP_WEI = None |
|
376 | self.FTP_WEI = None | |
376 | self.EXP_CODE = None |
|
377 | self.EXP_CODE = None | |
377 | self.SUB_EXP_CODE = None |
|
378 | self.SUB_EXP_CODE = None | |
378 | self.PLOT_POS = None |
|
379 | self.PLOT_POS = None | |
379 | self.tmin = None |
|
380 | self.tmin = None | |
380 | self.tmax = None |
|
381 | self.tmax = None | |
381 |
|
382 | |||
382 | self.xmin = None |
|
383 | self.xmin = None | |
383 | self.xmax = None |
|
384 | self.xmax = None | |
384 |
|
385 | |||
385 | self.figfile = None |
|
386 | self.figfile = None | |
386 |
|
387 | |||
387 | def getSubplots(self): |
|
388 | def getSubplots(self): | |
388 |
|
389 | |||
389 | ncol = 1 |
|
390 | ncol = 1 | |
390 | nrow = self.nplots |
|
391 | nrow = self.nplots | |
391 |
|
392 | |||
392 | return nrow, ncol |
|
393 | return nrow, ncol | |
393 |
|
394 | |||
394 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
395 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
395 |
|
396 | |||
396 | self.__showprofile = showprofile |
|
397 | self.__showprofile = showprofile | |
397 | self.nplots = nplots |
|
398 | self.nplots = nplots | |
398 |
|
399 | |||
399 | ncolspan = 1 |
|
400 | ncolspan = 1 | |
400 | colspan = 1 |
|
401 | colspan = 1 | |
401 |
|
402 | |||
402 | self.createFigure(id = id, |
|
403 | self.createFigure(id = id, | |
403 | wintitle = wintitle, |
|
404 | wintitle = wintitle, | |
404 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
405 | widthplot = self.WIDTH + self.WIDTHPROF, | |
405 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
406 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
406 | show=show) |
|
407 | show=show) | |
407 |
|
408 | |||
408 | nrow, ncol = self.getSubplots() |
|
409 | nrow, ncol = self.getSubplots() | |
409 |
|
410 | |||
410 | counter = 0 |
|
411 | counter = 0 | |
411 | for y in range(nrow): |
|
412 | for y in range(nrow): | |
412 | if counter >= self.nplots: |
|
413 | if counter >= self.nplots: | |
413 | break |
|
414 | break | |
414 |
|
415 | |||
415 | self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1) |
|
416 | self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1) | |
416 | counter += 1 |
|
417 | counter += 1 | |
417 |
|
418 | |||
418 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile='False', |
|
419 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile='False', | |
419 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
420 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
420 | zmax_ver = None, zmin_ver = None, SNRmin = None, SNRmax = None, |
|
421 | zmax_ver = None, zmin_ver = None, SNRmin = None, SNRmax = None, | |
421 | timerange=None, SNRthresh = None, |
|
422 | timerange=None, SNRthresh = None, | |
422 | save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True, |
|
423 | save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True, | |
423 | server=None, folder=None, username=None, password=None, |
|
424 | server=None, folder=None, username=None, password=None, | |
424 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): |
|
425 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): | |
425 | """ |
|
426 | """ | |
426 |
|
427 | |||
427 | Input: |
|
428 | Input: | |
428 | dataOut : |
|
429 | dataOut : | |
429 | id : |
|
430 | id : | |
430 | wintitle : |
|
431 | wintitle : | |
431 | channelList : |
|
432 | channelList : | |
432 | showProfile : |
|
433 | showProfile : | |
433 | xmin : None, |
|
434 | xmin : None, | |
434 | xmax : None, |
|
435 | xmax : None, | |
435 | ymin : None, |
|
436 | ymin : None, | |
436 | ymax : None, |
|
437 | ymax : None, | |
437 | zmin : None, |
|
438 | zmin : None, | |
438 | zmax : None |
|
439 | zmax : None | |
439 | """ |
|
440 | """ | |
440 |
|
441 | |||
441 | if channelList == None: |
|
442 | if channelList == None: | |
442 | channelIndexList = dataOut.channelIndexList |
|
443 | channelIndexList = dataOut.channelIndexList | |
443 | else: |
|
444 | else: | |
444 | channelIndexList = [] |
|
445 | channelIndexList = [] | |
445 | for channel in channelList: |
|
446 | for channel in channelList: | |
446 | if channel not in dataOut.channelList: |
|
447 | if channel not in dataOut.channelList: | |
447 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
448 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
448 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
449 | channelIndexList.append(dataOut.channelList.index(channel)) | |
449 |
|
450 | |||
450 | # if timerange is not None: |
|
451 | # if timerange is not None: | |
451 | # self.timerange = timerange |
|
452 | # self.timerange = timerange | |
452 | # |
|
453 | # | |
453 | # tmin = None |
|
454 | # tmin = None | |
454 | # tmax = None |
|
455 | # tmax = None | |
455 |
|
456 | |||
456 | x = dataOut.getTimeRange1() |
|
457 | x = dataOut.getTimeRange1() | |
457 | # y = dataOut.heightList |
|
458 | # y = dataOut.heightList | |
458 | y = dataOut.heightList |
|
459 | y = dataOut.heightList | |
459 |
|
460 | |||
460 | z = dataOut.data_output.copy() |
|
461 | z = dataOut.data_output.copy() | |
461 | nplots = z.shape[0] #Number of wind dimensions estimated |
|
462 | nplots = z.shape[0] #Number of wind dimensions estimated | |
462 | nplotsw = nplots |
|
463 | nplotsw = nplots | |
463 |
|
464 | |||
464 | #If there is a SNR function defined |
|
465 | #If there is a SNR function defined | |
465 | if dataOut.data_SNR is not None: |
|
466 | if dataOut.data_SNR is not None: | |
466 | nplots += 1 |
|
467 | nplots += 1 | |
467 | SNR = dataOut.data_SNR |
|
468 | SNR = dataOut.data_SNR | |
468 | SNRavg = numpy.average(SNR, axis=0) |
|
469 | SNRavg = numpy.average(SNR, axis=0) | |
469 |
|
470 | |||
470 | SNRdB = 10*numpy.log10(SNR) |
|
471 | SNRdB = 10*numpy.log10(SNR) | |
471 | SNRavgdB = 10*numpy.log10(SNRavg) |
|
472 | SNRavgdB = 10*numpy.log10(SNRavg) | |
472 |
|
473 | |||
473 | if SNRthresh == None: SNRthresh = -5.0 |
|
474 | if SNRthresh == None: SNRthresh = -5.0 | |
474 | ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0] |
|
475 | ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0] | |
475 |
|
476 | |||
476 | for i in range(nplotsw): |
|
477 | for i in range(nplotsw): | |
477 | z[i,ind] = numpy.nan |
|
478 | z[i,ind] = numpy.nan | |
478 |
|
479 | |||
479 |
|
480 | |||
480 | # showprofile = False |
|
481 | # showprofile = False | |
481 | # thisDatetime = dataOut.datatime |
|
482 | # thisDatetime = dataOut.datatime | |
482 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) |
|
483 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) | |
483 | title = wintitle + "Wind" |
|
484 | title = wintitle + "Wind" | |
484 | xlabel = "" |
|
485 | xlabel = "" | |
485 | ylabel = "Range (Km)" |
|
486 | ylabel = "Range (Km)" | |
486 | update_figfile = False |
|
487 | update_figfile = False | |
487 |
|
488 | |||
488 | if not self.__isConfig: |
|
489 | if not self.__isConfig: | |
489 |
|
490 | |||
490 | self.setup(id=id, |
|
491 | self.setup(id=id, | |
491 | nplots=nplots, |
|
492 | nplots=nplots, | |
492 | wintitle=wintitle, |
|
493 | wintitle=wintitle, | |
493 | showprofile=showprofile, |
|
494 | showprofile=showprofile, | |
494 | show=show) |
|
495 | show=show) | |
495 |
|
496 | |||
496 | if timerange is not None: |
|
497 | if timerange is not None: | |
497 | self.timerange = timerange |
|
498 | self.timerange = timerange | |
498 |
|
499 | |||
499 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) |
|
500 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) | |
500 |
|
501 | |||
501 | if ymin == None: ymin = numpy.nanmin(y) |
|
502 | if ymin == None: ymin = numpy.nanmin(y) | |
502 | if ymax == None: ymax = numpy.nanmax(y) |
|
503 | if ymax == None: ymax = numpy.nanmax(y) | |
503 |
|
504 | |||
504 | if zmax == None: zmax = numpy.nanmax(abs(z[range(2),:])) |
|
505 | if zmax == None: zmax = numpy.nanmax(abs(z[range(2),:])) | |
505 | #if numpy.isnan(zmax): zmax = 50 |
|
506 | #if numpy.isnan(zmax): zmax = 50 | |
506 | if zmin == None: zmin = -zmax |
|
507 | if zmin == None: zmin = -zmax | |
507 |
|
508 | |||
508 | if nplotsw == 3: |
|
509 | if nplotsw == 3: | |
509 | if zmax_ver == None: zmax_ver = numpy.nanmax(abs(z[2,:])) |
|
510 | if zmax_ver == None: zmax_ver = numpy.nanmax(abs(z[2,:])) | |
510 | if zmin_ver == None: zmin_ver = -zmax_ver |
|
511 | if zmin_ver == None: zmin_ver = -zmax_ver | |
511 |
|
512 | |||
512 | if dataOut.data_SNR is not None: |
|
513 | if dataOut.data_SNR is not None: | |
513 | if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB) |
|
514 | if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB) | |
514 | if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB) |
|
515 | if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB) | |
515 |
|
516 | |||
516 |
|
517 | |||
517 | self.FTP_WEI = ftp_wei |
|
518 | self.FTP_WEI = ftp_wei | |
518 | self.EXP_CODE = exp_code |
|
519 | self.EXP_CODE = exp_code | |
519 | self.SUB_EXP_CODE = sub_exp_code |
|
520 | self.SUB_EXP_CODE = sub_exp_code | |
520 | self.PLOT_POS = plot_pos |
|
521 | self.PLOT_POS = plot_pos | |
521 |
|
522 | |||
522 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
523 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
523 | self.__isConfig = True |
|
524 | self.__isConfig = True | |
524 | self.figfile = figfile |
|
525 | self.figfile = figfile | |
525 | update_figfile = True |
|
526 | update_figfile = True | |
526 |
|
527 | |||
527 | self.setWinTitle(title) |
|
528 | self.setWinTitle(title) | |
528 |
|
529 | |||
529 | if ((self.xmax - x[1]) < (x[1]-x[0])): |
|
530 | if ((self.xmax - x[1]) < (x[1]-x[0])): | |
530 | x[1] = self.xmax |
|
531 | x[1] = self.xmax | |
531 |
|
532 | |||
532 | strWind = ['Zonal', 'Meridional', 'Vertical'] |
|
533 | strWind = ['Zonal', 'Meridional', 'Vertical'] | |
533 | strCb = ['Velocity (m/s)','Velocity (m/s)','Velocity (cm/s)'] |
|
534 | strCb = ['Velocity (m/s)','Velocity (m/s)','Velocity (cm/s)'] | |
534 | zmaxVector = [zmax, zmax, zmax_ver] |
|
535 | zmaxVector = [zmax, zmax, zmax_ver] | |
535 | zminVector = [zmin, zmin, zmin_ver] |
|
536 | zminVector = [zmin, zmin, zmin_ver] | |
536 | windFactor = [1,1,100] |
|
537 | windFactor = [1,1,100] | |
537 |
|
538 | |||
538 | for i in range(nplotsw): |
|
539 | for i in range(nplotsw): | |
539 |
|
540 | |||
540 | title = "%s Wind: %s" %(strWind[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
541 | title = "%s Wind: %s" %(strWind[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
541 | axes = self.axesList[i*self.__nsubplots] |
|
542 | axes = self.axesList[i*self.__nsubplots] | |
542 |
|
543 | |||
543 | z1 = z[i,:].reshape((1,-1))*windFactor[i] |
|
544 | z1 = z[i,:].reshape((1,-1))*windFactor[i] | |
544 |
|
545 | |||
545 | axes.pcolorbuffer(x, y, z1, |
|
546 | axes.pcolorbuffer(x, y, z1, | |
546 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zminVector[i], zmax=zmaxVector[i], |
|
547 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zminVector[i], zmax=zmaxVector[i], | |
547 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
548 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
548 | ticksize=9, cblabel=strCb[i], cbsize="1%", colormap="RdBu_r" ) |
|
549 | ticksize=9, cblabel=strCb[i], cbsize="1%", colormap="RdBu_r" ) | |
549 |
|
550 | |||
550 | if dataOut.data_SNR is not None: |
|
551 | if dataOut.data_SNR is not None: | |
551 | i += 1 |
|
552 | i += 1 | |
552 | title = "Signal Noise Ratio (SNR): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
553 | title = "Signal Noise Ratio (SNR): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
553 | axes = self.axesList[i*self.__nsubplots] |
|
554 | axes = self.axesList[i*self.__nsubplots] | |
554 |
|
555 | |||
555 | SNRavgdB = SNRavgdB.reshape((1,-1)) |
|
556 | SNRavgdB = SNRavgdB.reshape((1,-1)) | |
556 |
|
557 | |||
557 | axes.pcolorbuffer(x, y, SNRavgdB, |
|
558 | axes.pcolorbuffer(x, y, SNRavgdB, | |
558 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax, |
|
559 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax, | |
559 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
560 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
560 | ticksize=9, cblabel='', cbsize="1%", colormap="jet") |
|
561 | ticksize=9, cblabel='', cbsize="1%", colormap="jet") | |
561 |
|
562 | |||
562 | self.draw() |
|
563 | self.draw() | |
563 |
|
564 | |||
564 | if dataOut.ltctime >= self.xmax: |
|
565 | if dataOut.ltctime >= self.xmax: | |
565 | self.counter_imagwr = wr_period |
|
566 | self.counter_imagwr = wr_period | |
566 | self.__isConfig = False |
|
567 | self.__isConfig = False | |
567 | update_figfile = True |
|
568 | update_figfile = True | |
568 |
|
569 | |||
569 | self.save(figpath=figpath, |
|
570 | self.save(figpath=figpath, | |
570 | figfile=figfile, |
|
571 | figfile=figfile, | |
571 | save=save, |
|
572 | save=save, | |
572 | ftp=ftp, |
|
573 | ftp=ftp, | |
573 | wr_period=wr_period, |
|
574 | wr_period=wr_period, | |
574 | thisDatetime=thisDatetime, |
|
575 | thisDatetime=thisDatetime, | |
575 | update_figfile=update_figfile) |
|
576 | update_figfile=update_figfile) | |
576 |
|
577 | |||
577 |
|
578 | |||
578 |
|
579 | |||
579 | class ParametersPlot(Figure): |
|
580 | class ParametersPlot(Figure): | |
580 |
|
581 | |||
581 | __isConfig = None |
|
582 | __isConfig = None | |
582 | __nsubplots = None |
|
583 | __nsubplots = None | |
583 |
|
584 | |||
584 | WIDTHPROF = None |
|
585 | WIDTHPROF = None | |
585 | HEIGHTPROF = None |
|
586 | HEIGHTPROF = None | |
586 | PREFIX = 'prm' |
|
587 | PREFIX = 'prm' | |
587 |
|
588 | |||
588 | def __init__(self): |
|
589 | def __init__(self): | |
589 |
|
590 | |||
590 | self.timerange = 2*60*60 |
|
591 | self.timerange = 2*60*60 | |
591 | self.__isConfig = False |
|
592 | self.__isConfig = False | |
592 | self.__nsubplots = 1 |
|
593 | self.__nsubplots = 1 | |
593 |
|
594 | |||
594 | self.WIDTH = 800 |
|
595 | self.WIDTH = 800 | |
595 | self.HEIGHT = 150 |
|
596 | self.HEIGHT = 150 | |
596 | self.WIDTHPROF = 120 |
|
597 | self.WIDTHPROF = 120 | |
597 | self.HEIGHTPROF = 0 |
|
598 | self.HEIGHTPROF = 0 | |
598 | self.counter_imagwr = 0 |
|
599 | self.counter_imagwr = 0 | |
599 |
|
600 | |||
600 | self.PLOT_CODE = PARMS_CODE |
|
601 | self.PLOT_CODE = PARMS_CODE | |
601 |
|
602 | |||
602 | self.FTP_WEI = None |
|
603 | self.FTP_WEI = None | |
603 | self.EXP_CODE = None |
|
604 | self.EXP_CODE = None | |
604 | self.SUB_EXP_CODE = None |
|
605 | self.SUB_EXP_CODE = None | |
605 | self.PLOT_POS = None |
|
606 | self.PLOT_POS = None | |
606 | self.tmin = None |
|
607 | self.tmin = None | |
607 | self.tmax = None |
|
608 | self.tmax = None | |
608 |
|
609 | |||
609 | self.xmin = None |
|
610 | self.xmin = None | |
610 | self.xmax = None |
|
611 | self.xmax = None | |
611 |
|
612 | |||
612 | self.figfile = None |
|
613 | self.figfile = None | |
613 |
|
614 | |||
614 | def getSubplots(self): |
|
615 | def getSubplots(self): | |
615 |
|
616 | |||
616 | ncol = 1 |
|
617 | ncol = 1 | |
617 | nrow = self.nplots |
|
618 | nrow = self.nplots | |
618 |
|
619 | |||
619 | return nrow, ncol |
|
620 | return nrow, ncol | |
620 |
|
621 | |||
621 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
622 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
622 |
|
623 | |||
623 | self.__showprofile = showprofile |
|
624 | self.__showprofile = showprofile | |
624 | self.nplots = nplots |
|
625 | self.nplots = nplots | |
625 |
|
626 | |||
626 | ncolspan = 1 |
|
627 | ncolspan = 1 | |
627 | colspan = 1 |
|
628 | colspan = 1 | |
628 |
|
629 | |||
629 | self.createFigure(id = id, |
|
630 | self.createFigure(id = id, | |
630 | wintitle = wintitle, |
|
631 | wintitle = wintitle, | |
631 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
632 | widthplot = self.WIDTH + self.WIDTHPROF, | |
632 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
633 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
633 | show=show) |
|
634 | show=show) | |
634 |
|
635 | |||
635 | nrow, ncol = self.getSubplots() |
|
636 | nrow, ncol = self.getSubplots() | |
636 |
|
637 | |||
637 | counter = 0 |
|
638 | counter = 0 | |
638 | for y in range(nrow): |
|
639 | for y in range(nrow): | |
639 | for x in range(ncol): |
|
640 | for x in range(ncol): | |
640 |
|
641 | |||
641 | if counter >= self.nplots: |
|
642 | if counter >= self.nplots: | |
642 | break |
|
643 | break | |
643 |
|
644 | |||
644 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
645 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
645 |
|
646 | |||
646 | if showprofile: |
|
647 | if showprofile: | |
647 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
648 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
648 |
|
649 | |||
649 | counter += 1 |
|
650 | counter += 1 | |
650 |
|
651 | |||
651 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=False, |
|
652 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=False, | |
652 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,timerange=None, |
|
653 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,timerange=None, | |
653 | parameterIndex = None, onlyPositive = False, |
|
654 | parameterIndex = None, onlyPositive = False, | |
654 | SNRthresh = -numpy.inf, SNR = True, SNRmin = None, SNRmax = None, onlySNR = False, |
|
655 | SNRthresh = -numpy.inf, SNR = True, SNRmin = None, SNRmax = None, onlySNR = False, | |
655 | DOP = True, |
|
656 | DOP = True, | |
656 | zlabel = "", parameterName = "", parameterObject = "data_param", |
|
657 | zlabel = "", parameterName = "", parameterObject = "data_param", | |
657 | save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True, |
|
658 | save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True, | |
658 | server=None, folder=None, username=None, password=None, |
|
659 | server=None, folder=None, username=None, password=None, | |
659 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): |
|
660 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): | |
660 |
|
661 | |||
661 | """ |
|
662 | """ | |
662 |
|
663 | |||
663 | Input: |
|
664 | Input: | |
664 | dataOut : |
|
665 | dataOut : | |
665 | id : |
|
666 | id : | |
666 | wintitle : |
|
667 | wintitle : | |
667 | channelList : |
|
668 | channelList : | |
668 | showProfile : |
|
669 | showProfile : | |
669 | xmin : None, |
|
670 | xmin : None, | |
670 | xmax : None, |
|
671 | xmax : None, | |
671 | ymin : None, |
|
672 | ymin : None, | |
672 | ymax : None, |
|
673 | ymax : None, | |
673 | zmin : None, |
|
674 | zmin : None, | |
674 | zmax : None |
|
675 | zmax : None | |
675 | """ |
|
676 | """ | |
676 |
|
677 | |||
677 | data_param = getattr(dataOut, parameterObject) |
|
678 | data_param = getattr(dataOut, parameterObject) | |
678 |
|
679 | |||
679 | if channelList == None: |
|
680 | if channelList == None: | |
680 | channelIndexList = numpy.arange(data_param.shape[0]) |
|
681 | channelIndexList = numpy.arange(data_param.shape[0]) | |
681 | else: |
|
682 | else: | |
682 | channelIndexList = numpy.array(channelList) |
|
683 | channelIndexList = numpy.array(channelList) | |
683 |
|
684 | |||
684 | nchan = len(channelIndexList) #Number of channels being plotted |
|
685 | nchan = len(channelIndexList) #Number of channels being plotted | |
685 |
|
686 | |||
686 | if nchan < 1: |
|
687 | if nchan < 1: | |
687 | return |
|
688 | return | |
688 |
|
689 | |||
689 | nGraphsByChannel = 0 |
|
690 | nGraphsByChannel = 0 | |
690 |
|
691 | |||
691 | if SNR: |
|
692 | if SNR: | |
692 | nGraphsByChannel += 1 |
|
693 | nGraphsByChannel += 1 | |
693 | if DOP: |
|
694 | if DOP: | |
694 | nGraphsByChannel += 1 |
|
695 | nGraphsByChannel += 1 | |
695 |
|
696 | |||
696 | if nGraphsByChannel < 1: |
|
697 | if nGraphsByChannel < 1: | |
697 | return |
|
698 | return | |
698 |
|
699 | |||
699 | nplots = nGraphsByChannel*nchan |
|
700 | nplots = nGraphsByChannel*nchan | |
700 |
|
701 | |||
701 | if timerange is not None: |
|
702 | if timerange is not None: | |
702 | self.timerange = timerange |
|
703 | self.timerange = timerange | |
703 |
|
704 | |||
704 | #tmin = None |
|
705 | #tmin = None | |
705 | #tmax = None |
|
706 | #tmax = None | |
706 | if parameterIndex == None: |
|
707 | if parameterIndex == None: | |
707 | parameterIndex = 1 |
|
708 | parameterIndex = 1 | |
708 |
|
709 | |||
709 | x = dataOut.getTimeRange1() |
|
710 | x = dataOut.getTimeRange1() | |
710 | y = dataOut.heightList |
|
711 | y = dataOut.heightList | |
711 | z = data_param[channelIndexList,parameterIndex,:].copy() |
|
712 | z = data_param[channelIndexList,parameterIndex,:].copy() | |
712 |
|
713 | |||
713 | zRange = dataOut.abscissaList |
|
714 | zRange = dataOut.abscissaList | |
714 | # nChannels = z.shape[0] #Number of wind dimensions estimated |
|
715 | # nChannels = z.shape[0] #Number of wind dimensions estimated | |
715 | # thisDatetime = dataOut.datatime |
|
716 | # thisDatetime = dataOut.datatime | |
716 |
|
717 | |||
717 | if dataOut.data_SNR is not None: |
|
718 | if dataOut.data_SNR is not None: | |
718 | SNRarray = dataOut.data_SNR[channelIndexList,:] |
|
719 | SNRarray = dataOut.data_SNR[channelIndexList,:] | |
719 | SNRdB = 10*numpy.log10(SNRarray) |
|
720 | SNRdB = 10*numpy.log10(SNRarray) | |
720 | # SNRavgdB = 10*numpy.log10(SNRavg) |
|
721 | # SNRavgdB = 10*numpy.log10(SNRavg) | |
721 | ind = numpy.where(SNRdB < 10**(SNRthresh/10)) |
|
722 | ind = numpy.where(SNRdB < 10**(SNRthresh/10)) | |
722 | z[ind] = numpy.nan |
|
723 | z[ind] = numpy.nan | |
723 |
|
724 | |||
724 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) |
|
725 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) | |
725 | title = wintitle + " Parameters Plot" #: %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
726 | title = wintitle + " Parameters Plot" #: %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
726 | xlabel = "" |
|
727 | xlabel = "" | |
727 | ylabel = "Range (Km)" |
|
728 | ylabel = "Range (Km)" | |
728 |
|
729 | |||
729 | if (SNR and not onlySNR): nplots = 2*nplots |
|
730 | if (SNR and not onlySNR): nplots = 2*nplots | |
730 |
|
731 | |||
731 | if onlyPositive: |
|
732 | if onlyPositive: | |
732 | colormap = "jet" |
|
733 | colormap = "jet" | |
733 | zmin = 0 |
|
734 | zmin = 0 | |
734 | else: colormap = "RdBu_r" |
|
735 | else: colormap = "RdBu_r" | |
735 |
|
736 | |||
736 | if not self.__isConfig: |
|
737 | if not self.__isConfig: | |
737 |
|
738 | |||
738 | self.setup(id=id, |
|
739 | self.setup(id=id, | |
739 | nplots=nplots, |
|
740 | nplots=nplots, | |
740 | wintitle=wintitle, |
|
741 | wintitle=wintitle, | |
741 | showprofile=showprofile, |
|
742 | showprofile=showprofile, | |
742 | show=show) |
|
743 | show=show) | |
743 |
|
744 | |||
744 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) |
|
745 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) | |
745 |
|
746 | |||
746 | if ymin == None: ymin = numpy.nanmin(y) |
|
747 | if ymin == None: ymin = numpy.nanmin(y) | |
747 | if ymax == None: ymax = numpy.nanmax(y) |
|
748 | if ymax == None: ymax = numpy.nanmax(y) | |
748 | if zmin == None: zmin = numpy.nanmin(zRange) |
|
749 | if zmin == None: zmin = numpy.nanmin(zRange) | |
749 | if zmax == None: zmax = numpy.nanmax(zRange) |
|
750 | if zmax == None: zmax = numpy.nanmax(zRange) | |
750 |
|
751 | |||
751 | if SNR: |
|
752 | if SNR: | |
752 | if SNRmin == None: SNRmin = numpy.nanmin(SNRdB) |
|
753 | if SNRmin == None: SNRmin = numpy.nanmin(SNRdB) | |
753 | if SNRmax == None: SNRmax = numpy.nanmax(SNRdB) |
|
754 | if SNRmax == None: SNRmax = numpy.nanmax(SNRdB) | |
754 |
|
755 | |||
755 | self.FTP_WEI = ftp_wei |
|
756 | self.FTP_WEI = ftp_wei | |
756 | self.EXP_CODE = exp_code |
|
757 | self.EXP_CODE = exp_code | |
757 | self.SUB_EXP_CODE = sub_exp_code |
|
758 | self.SUB_EXP_CODE = sub_exp_code | |
758 | self.PLOT_POS = plot_pos |
|
759 | self.PLOT_POS = plot_pos | |
759 |
|
760 | |||
760 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
761 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
761 | self.__isConfig = True |
|
762 | self.__isConfig = True | |
762 | self.figfile = figfile |
|
763 | self.figfile = figfile | |
763 |
|
764 | |||
764 | self.setWinTitle(title) |
|
765 | self.setWinTitle(title) | |
765 |
|
766 | |||
766 | if ((self.xmax - x[1]) < (x[1]-x[0])): |
|
767 | if ((self.xmax - x[1]) < (x[1]-x[0])): | |
767 | x[1] = self.xmax |
|
768 | x[1] = self.xmax | |
768 |
|
769 | |||
769 | for i in range(nchan): |
|
770 | for i in range(nchan): | |
770 |
|
771 | |||
771 | if (SNR and not onlySNR): j = 2*i |
|
772 | if (SNR and not onlySNR): j = 2*i | |
772 | else: j = i |
|
773 | else: j = i | |
773 |
|
774 | |||
774 | j = nGraphsByChannel*i |
|
775 | j = nGraphsByChannel*i | |
775 |
|
776 | |||
776 | if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): |
|
777 | if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): | |
777 | title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith) |
|
778 | title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith) | |
778 |
|
779 | |||
779 | if not onlySNR: |
|
780 | if not onlySNR: | |
780 | axes = self.axesList[j*self.__nsubplots] |
|
781 | axes = self.axesList[j*self.__nsubplots] | |
781 | z1 = z[i,:].reshape((1,-1)) |
|
782 | z1 = z[i,:].reshape((1,-1)) | |
782 | axes.pcolorbuffer(x, y, z1, |
|
783 | axes.pcolorbuffer(x, y, z1, | |
783 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
784 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
784 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap=colormap, |
|
785 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap=colormap, | |
785 | ticksize=9, cblabel=zlabel, cbsize="1%") |
|
786 | ticksize=9, cblabel=zlabel, cbsize="1%") | |
786 |
|
787 | |||
787 | if DOP: |
|
788 | if DOP: | |
788 | title = "%s Channel %d: %s" %(parameterName, channelIndexList[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
789 | title = "%s Channel %d: %s" %(parameterName, channelIndexList[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
789 |
|
790 | |||
790 | if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): |
|
791 | if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): | |
791 | title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith) |
|
792 | title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith) | |
792 | axes = self.axesList[j] |
|
793 | axes = self.axesList[j] | |
793 | z1 = z[i,:].reshape((1,-1)) |
|
794 | z1 = z[i,:].reshape((1,-1)) | |
794 | axes.pcolorbuffer(x, y, z1, |
|
795 | axes.pcolorbuffer(x, y, z1, | |
795 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
796 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
796 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap=colormap, |
|
797 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap=colormap, | |
797 | ticksize=9, cblabel=zlabel, cbsize="1%") |
|
798 | ticksize=9, cblabel=zlabel, cbsize="1%") | |
798 |
|
799 | |||
799 | if SNR: |
|
800 | if SNR: | |
800 | title = "Channel %d Signal Noise Ratio (SNR): %s" %(channelIndexList[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
801 | title = "Channel %d Signal Noise Ratio (SNR): %s" %(channelIndexList[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
801 | axes = self.axesList[(j)*self.__nsubplots] |
|
802 | axes = self.axesList[(j)*self.__nsubplots] | |
802 | if not onlySNR: |
|
803 | if not onlySNR: | |
803 | axes = self.axesList[(j + 1)*self.__nsubplots] |
|
804 | axes = self.axesList[(j + 1)*self.__nsubplots] | |
804 |
|
805 | |||
805 | axes = self.axesList[(j + nGraphsByChannel-1)] |
|
806 | axes = self.axesList[(j + nGraphsByChannel-1)] | |
806 |
|
807 | |||
807 | z1 = SNRdB[i,:].reshape((1,-1)) |
|
808 | z1 = SNRdB[i,:].reshape((1,-1)) | |
808 | axes.pcolorbuffer(x, y, z1, |
|
809 | axes.pcolorbuffer(x, y, z1, | |
809 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax, |
|
810 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax, | |
810 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap="jet", |
|
811 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap="jet", | |
811 | ticksize=9, cblabel=zlabel, cbsize="1%") |
|
812 | ticksize=9, cblabel=zlabel, cbsize="1%") | |
812 |
|
813 | |||
813 |
|
814 | |||
814 |
|
815 | |||
815 | self.draw() |
|
816 | self.draw() | |
816 |
|
817 | |||
817 | if x[1] >= self.axesList[0].xmax: |
|
818 | if x[1] >= self.axesList[0].xmax: | |
818 | self.counter_imagwr = wr_period |
|
819 | self.counter_imagwr = wr_period | |
819 | self.__isConfig = False |
|
820 | self.__isConfig = False | |
820 | self.figfile = None |
|
821 | self.figfile = None | |
821 |
|
822 | |||
822 | self.save(figpath=figpath, |
|
823 | self.save(figpath=figpath, | |
823 | figfile=figfile, |
|
824 | figfile=figfile, | |
824 | save=save, |
|
825 | save=save, | |
825 | ftp=ftp, |
|
826 | ftp=ftp, | |
826 | wr_period=wr_period, |
|
827 | wr_period=wr_period, | |
827 | thisDatetime=thisDatetime, |
|
828 | thisDatetime=thisDatetime, | |
828 | update_figfile=False) |
|
829 | update_figfile=False) | |
829 |
|
830 | |||
830 | class SpectralFittingPlot(Figure): |
|
831 | class SpectralFittingPlot(Figure): | |
831 |
|
832 | |||
832 | __isConfig = None |
|
833 | __isConfig = None | |
833 | __nsubplots = None |
|
834 | __nsubplots = None | |
834 |
|
835 | |||
835 | WIDTHPROF = None |
|
836 | WIDTHPROF = None | |
836 | HEIGHTPROF = None |
|
837 | HEIGHTPROF = None | |
837 | PREFIX = 'prm' |
|
838 | PREFIX = 'prm' | |
838 |
|
839 | |||
839 |
|
840 | |||
840 | N = None |
|
841 | N = None | |
841 | ippSeconds = None |
|
842 | ippSeconds = None | |
842 |
|
843 | |||
843 | def __init__(self): |
|
844 | def __init__(self): | |
844 | self.__isConfig = False |
|
845 | self.__isConfig = False | |
845 | self.__nsubplots = 1 |
|
846 | self.__nsubplots = 1 | |
846 |
|
847 | |||
847 | self.PLOT_CODE = SPECFIT_CODE |
|
848 | self.PLOT_CODE = SPECFIT_CODE | |
848 |
|
849 | |||
849 | self.WIDTH = 450 |
|
850 | self.WIDTH = 450 | |
850 | self.HEIGHT = 250 |
|
851 | self.HEIGHT = 250 | |
851 | self.WIDTHPROF = 0 |
|
852 | self.WIDTHPROF = 0 | |
852 | self.HEIGHTPROF = 0 |
|
853 | self.HEIGHTPROF = 0 | |
853 |
|
854 | |||
854 | def getSubplots(self): |
|
855 | def getSubplots(self): | |
855 |
|
856 | |||
856 | ncol = int(numpy.sqrt(self.nplots)+0.9) |
|
857 | ncol = int(numpy.sqrt(self.nplots)+0.9) | |
857 | nrow = int(self.nplots*1./ncol + 0.9) |
|
858 | nrow = int(self.nplots*1./ncol + 0.9) | |
858 |
|
859 | |||
859 | return nrow, ncol |
|
860 | return nrow, ncol | |
860 |
|
861 | |||
861 | def setup(self, id, nplots, wintitle, showprofile=False, show=True): |
|
862 | def setup(self, id, nplots, wintitle, showprofile=False, show=True): | |
862 |
|
863 | |||
863 | showprofile = False |
|
864 | showprofile = False | |
864 | self.__showprofile = showprofile |
|
865 | self.__showprofile = showprofile | |
865 | self.nplots = nplots |
|
866 | self.nplots = nplots | |
866 |
|
867 | |||
867 | ncolspan = 5 |
|
868 | ncolspan = 5 | |
868 | colspan = 4 |
|
869 | colspan = 4 | |
869 | if showprofile: |
|
870 | if showprofile: | |
870 | ncolspan = 5 |
|
871 | ncolspan = 5 | |
871 | colspan = 4 |
|
872 | colspan = 4 | |
872 | self.__nsubplots = 2 |
|
873 | self.__nsubplots = 2 | |
873 |
|
874 | |||
874 | self.createFigure(id = id, |
|
875 | self.createFigure(id = id, | |
875 | wintitle = wintitle, |
|
876 | wintitle = wintitle, | |
876 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
877 | widthplot = self.WIDTH + self.WIDTHPROF, | |
877 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
878 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
878 | show=show) |
|
879 | show=show) | |
879 |
|
880 | |||
880 | nrow, ncol = self.getSubplots() |
|
881 | nrow, ncol = self.getSubplots() | |
881 |
|
882 | |||
882 | counter = 0 |
|
883 | counter = 0 | |
883 | for y in range(nrow): |
|
884 | for y in range(nrow): | |
884 | for x in range(ncol): |
|
885 | for x in range(ncol): | |
885 |
|
886 | |||
886 | if counter >= self.nplots: |
|
887 | if counter >= self.nplots: | |
887 | break |
|
888 | break | |
888 |
|
889 | |||
889 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
890 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
890 |
|
891 | |||
891 | if showprofile: |
|
892 | if showprofile: | |
892 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
893 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
893 |
|
894 | |||
894 | counter += 1 |
|
895 | counter += 1 | |
895 |
|
896 | |||
896 | def run(self, dataOut, id, cutHeight=None, fit=False, wintitle="", channelList=None, showprofile=True, |
|
897 | def run(self, dataOut, id, cutHeight=None, fit=False, wintitle="", channelList=None, showprofile=True, | |
897 | xmin=None, xmax=None, ymin=None, ymax=None, |
|
898 | xmin=None, xmax=None, ymin=None, ymax=None, | |
898 | save=False, figpath='./', figfile=None, show=True): |
|
899 | save=False, figpath='./', figfile=None, show=True): | |
899 |
|
900 | |||
900 | """ |
|
901 | """ | |
901 |
|
902 | |||
902 | Input: |
|
903 | Input: | |
903 | dataOut : |
|
904 | dataOut : | |
904 | id : |
|
905 | id : | |
905 | wintitle : |
|
906 | wintitle : | |
906 | channelList : |
|
907 | channelList : | |
907 | showProfile : |
|
908 | showProfile : | |
908 | xmin : None, |
|
909 | xmin : None, | |
909 | xmax : None, |
|
910 | xmax : None, | |
910 | zmin : None, |
|
911 | zmin : None, | |
911 | zmax : None |
|
912 | zmax : None | |
912 | """ |
|
913 | """ | |
913 |
|
914 | |||
914 | if cutHeight==None: |
|
915 | if cutHeight==None: | |
915 | h=270 |
|
916 | h=270 | |
916 | heightindex = numpy.abs(cutHeight - dataOut.heightList).argmin() |
|
917 | heightindex = numpy.abs(cutHeight - dataOut.heightList).argmin() | |
917 | cutHeight = dataOut.heightList[heightindex] |
|
918 | cutHeight = dataOut.heightList[heightindex] | |
918 |
|
919 | |||
919 | factor = dataOut.normFactor |
|
920 | factor = dataOut.normFactor | |
920 | x = dataOut.abscissaList[:-1] |
|
921 | x = dataOut.abscissaList[:-1] | |
921 | #y = dataOut.getHeiRange() |
|
922 | #y = dataOut.getHeiRange() | |
922 |
|
923 | |||
923 | z = dataOut.data_pre[:,:,heightindex]/factor |
|
924 | z = dataOut.data_pre[:,:,heightindex]/factor | |
924 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
925 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
925 | avg = numpy.average(z, axis=1) |
|
926 | avg = numpy.average(z, axis=1) | |
926 | listChannels = z.shape[0] |
|
927 | listChannels = z.shape[0] | |
927 |
|
928 | |||
928 | #Reconstruct Function |
|
929 | #Reconstruct Function | |
929 | if fit==True: |
|
930 | if fit==True: | |
930 | groupArray = dataOut.groupList |
|
931 | groupArray = dataOut.groupList | |
931 | listChannels = groupArray.reshape((groupArray.size)) |
|
932 | listChannels = groupArray.reshape((groupArray.size)) | |
932 | listChannels.sort() |
|
933 | listChannels.sort() | |
933 | spcFitLine = numpy.zeros(z.shape) |
|
934 | spcFitLine = numpy.zeros(z.shape) | |
934 | constants = dataOut.constants |
|
935 | constants = dataOut.constants | |
935 |
|
936 | |||
936 | nGroups = groupArray.shape[0] |
|
937 | nGroups = groupArray.shape[0] | |
937 | nChannels = groupArray.shape[1] |
|
938 | nChannels = groupArray.shape[1] | |
938 | nProfiles = z.shape[1] |
|
939 | nProfiles = z.shape[1] | |
939 |
|
940 | |||
940 | for f in range(nGroups): |
|
941 | for f in range(nGroups): | |
941 | groupChann = groupArray[f,:] |
|
942 | groupChann = groupArray[f,:] | |
942 | p = dataOut.data_param[f,:,heightindex] |
|
943 | p = dataOut.data_param[f,:,heightindex] | |
943 | # p = numpy.array([ 89.343967,0.14036615,0.17086219,18.89835291,1.58388365,1.55099167]) |
|
944 | # p = numpy.array([ 89.343967,0.14036615,0.17086219,18.89835291,1.58388365,1.55099167]) | |
944 | fitLineAux = dataOut.library.modelFunction(p, constants)*nProfiles |
|
945 | fitLineAux = dataOut.library.modelFunction(p, constants)*nProfiles | |
945 | fitLineAux = fitLineAux.reshape((nChannels,nProfiles)) |
|
946 | fitLineAux = fitLineAux.reshape((nChannels,nProfiles)) | |
946 | spcFitLine[groupChann,:] = fitLineAux |
|
947 | spcFitLine[groupChann,:] = fitLineAux | |
947 | # spcFitLine = spcFitLine/factor |
|
948 | # spcFitLine = spcFitLine/factor | |
948 |
|
949 | |||
949 | z = z[listChannels,:] |
|
950 | z = z[listChannels,:] | |
950 | spcFitLine = spcFitLine[listChannels,:] |
|
951 | spcFitLine = spcFitLine[listChannels,:] | |
951 | spcFitLinedB = 10*numpy.log10(spcFitLine) |
|
952 | spcFitLinedB = 10*numpy.log10(spcFitLine) | |
952 |
|
953 | |||
953 | zdB = 10*numpy.log10(z) |
|
954 | zdB = 10*numpy.log10(z) | |
954 | #thisDatetime = dataOut.datatime |
|
955 | #thisDatetime = dataOut.datatime | |
955 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) |
|
956 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) | |
956 | title = wintitle + " Doppler Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
957 | title = wintitle + " Doppler Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
957 | xlabel = "Velocity (m/s)" |
|
958 | xlabel = "Velocity (m/s)" | |
958 | ylabel = "Spectrum" |
|
959 | ylabel = "Spectrum" | |
959 |
|
960 | |||
960 | if not self.__isConfig: |
|
961 | if not self.__isConfig: | |
961 |
|
962 | |||
962 | nplots = listChannels.size |
|
963 | nplots = listChannels.size | |
963 |
|
964 | |||
964 | self.setup(id=id, |
|
965 | self.setup(id=id, | |
965 | nplots=nplots, |
|
966 | nplots=nplots, | |
966 | wintitle=wintitle, |
|
967 | wintitle=wintitle, | |
967 | showprofile=showprofile, |
|
968 | showprofile=showprofile, | |
968 | show=show) |
|
969 | show=show) | |
969 |
|
970 | |||
970 | if xmin == None: xmin = numpy.nanmin(x) |
|
971 | if xmin == None: xmin = numpy.nanmin(x) | |
971 | if xmax == None: xmax = numpy.nanmax(x) |
|
972 | if xmax == None: xmax = numpy.nanmax(x) | |
972 | if ymin == None: ymin = numpy.nanmin(zdB) |
|
973 | if ymin == None: ymin = numpy.nanmin(zdB) | |
973 | if ymax == None: ymax = numpy.nanmax(zdB)+2 |
|
974 | if ymax == None: ymax = numpy.nanmax(zdB)+2 | |
974 |
|
975 | |||
975 | self.__isConfig = True |
|
976 | self.__isConfig = True | |
976 |
|
977 | |||
977 | self.setWinTitle(title) |
|
978 | self.setWinTitle(title) | |
978 | for i in range(self.nplots): |
|
979 | for i in range(self.nplots): | |
979 | # title = "Channel %d: %4.2fdB" %(dataOut.channelList[i]+1, noisedB[i]) |
|
980 | # title = "Channel %d: %4.2fdB" %(dataOut.channelList[i]+1, noisedB[i]) | |
980 | title = "Height %4.1f km\nChannel %d:" %(cutHeight, listChannels[i]) |
|
981 | title = "Height %4.1f km\nChannel %d:" %(cutHeight, listChannels[i]) | |
981 | axes = self.axesList[i*self.__nsubplots] |
|
982 | axes = self.axesList[i*self.__nsubplots] | |
982 | if fit == False: |
|
983 | if fit == False: | |
983 | axes.pline(x, zdB[i,:], |
|
984 | axes.pline(x, zdB[i,:], | |
984 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, |
|
985 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, | |
985 | xlabel=xlabel, ylabel=ylabel, title=title |
|
986 | xlabel=xlabel, ylabel=ylabel, title=title | |
986 | ) |
|
987 | ) | |
987 | if fit == True: |
|
988 | if fit == True: | |
988 | fitline=spcFitLinedB[i,:] |
|
989 | fitline=spcFitLinedB[i,:] | |
989 | y=numpy.vstack([zdB[i,:],fitline] ) |
|
990 | y=numpy.vstack([zdB[i,:],fitline] ) | |
990 | legendlabels=['Data','Fitting'] |
|
991 | legendlabels=['Data','Fitting'] | |
991 | axes.pmultilineyaxis(x, y, |
|
992 | axes.pmultilineyaxis(x, y, | |
992 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, |
|
993 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, | |
993 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
994 | xlabel=xlabel, ylabel=ylabel, title=title, | |
994 | legendlabels=legendlabels, marker=None, |
|
995 | legendlabels=legendlabels, marker=None, | |
995 | linestyle='solid', grid='both') |
|
996 | linestyle='solid', grid='both') | |
996 |
|
997 | |||
997 | self.draw() |
|
998 | self.draw() | |
998 |
|
999 | |||
999 | self.save(figpath=figpath, |
|
1000 | self.save(figpath=figpath, | |
1000 | figfile=figfile, |
|
1001 | figfile=figfile, | |
1001 | save=save, |
|
1002 | save=save, | |
1002 | ftp=ftp, |
|
1003 | ftp=ftp, | |
1003 | wr_period=wr_period, |
|
1004 | wr_period=wr_period, | |
1004 | thisDatetime=thisDatetime) |
|
1005 | thisDatetime=thisDatetime) | |
1005 |
|
1006 | |||
1006 |
|
1007 | |||
1007 | class EWDriftsPlot(Figure): |
|
1008 | class EWDriftsPlot(Figure): | |
1008 |
|
1009 | |||
1009 | __isConfig = None |
|
1010 | __isConfig = None | |
1010 | __nsubplots = None |
|
1011 | __nsubplots = None | |
1011 |
|
1012 | |||
1012 | WIDTHPROF = None |
|
1013 | WIDTHPROF = None | |
1013 | HEIGHTPROF = None |
|
1014 | HEIGHTPROF = None | |
1014 | PREFIX = 'drift' |
|
1015 | PREFIX = 'drift' | |
1015 |
|
1016 | |||
1016 | def __init__(self): |
|
1017 | def __init__(self): | |
1017 |
|
1018 | |||
1018 | self.timerange = 2*60*60 |
|
1019 | self.timerange = 2*60*60 | |
1019 | self.isConfig = False |
|
1020 | self.isConfig = False | |
1020 | self.__nsubplots = 1 |
|
1021 | self.__nsubplots = 1 | |
1021 |
|
1022 | |||
1022 | self.WIDTH = 800 |
|
1023 | self.WIDTH = 800 | |
1023 | self.HEIGHT = 150 |
|
1024 | self.HEIGHT = 150 | |
1024 | self.WIDTHPROF = 120 |
|
1025 | self.WIDTHPROF = 120 | |
1025 | self.HEIGHTPROF = 0 |
|
1026 | self.HEIGHTPROF = 0 | |
1026 | self.counter_imagwr = 0 |
|
1027 | self.counter_imagwr = 0 | |
1027 |
|
1028 | |||
1028 | self.PLOT_CODE = EWDRIFT_CODE |
|
1029 | self.PLOT_CODE = EWDRIFT_CODE | |
1029 |
|
1030 | |||
1030 | self.FTP_WEI = None |
|
1031 | self.FTP_WEI = None | |
1031 | self.EXP_CODE = None |
|
1032 | self.EXP_CODE = None | |
1032 | self.SUB_EXP_CODE = None |
|
1033 | self.SUB_EXP_CODE = None | |
1033 | self.PLOT_POS = None |
|
1034 | self.PLOT_POS = None | |
1034 | self.tmin = None |
|
1035 | self.tmin = None | |
1035 | self.tmax = None |
|
1036 | self.tmax = None | |
1036 |
|
1037 | |||
1037 | self.xmin = None |
|
1038 | self.xmin = None | |
1038 | self.xmax = None |
|
1039 | self.xmax = None | |
1039 |
|
1040 | |||
1040 | self.figfile = None |
|
1041 | self.figfile = None | |
1041 |
|
1042 | |||
1042 | def getSubplots(self): |
|
1043 | def getSubplots(self): | |
1043 |
|
1044 | |||
1044 | ncol = 1 |
|
1045 | ncol = 1 | |
1045 | nrow = self.nplots |
|
1046 | nrow = self.nplots | |
1046 |
|
1047 | |||
1047 | return nrow, ncol |
|
1048 | return nrow, ncol | |
1048 |
|
1049 | |||
1049 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
1050 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
1050 |
|
1051 | |||
1051 | self.__showprofile = showprofile |
|
1052 | self.__showprofile = showprofile | |
1052 | self.nplots = nplots |
|
1053 | self.nplots = nplots | |
1053 |
|
1054 | |||
1054 | ncolspan = 1 |
|
1055 | ncolspan = 1 | |
1055 | colspan = 1 |
|
1056 | colspan = 1 | |
1056 |
|
1057 | |||
1057 | self.createFigure(id = id, |
|
1058 | self.createFigure(id = id, | |
1058 | wintitle = wintitle, |
|
1059 | wintitle = wintitle, | |
1059 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
1060 | widthplot = self.WIDTH + self.WIDTHPROF, | |
1060 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
1061 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
1061 | show=show) |
|
1062 | show=show) | |
1062 |
|
1063 | |||
1063 | nrow, ncol = self.getSubplots() |
|
1064 | nrow, ncol = self.getSubplots() | |
1064 |
|
1065 | |||
1065 | counter = 0 |
|
1066 | counter = 0 | |
1066 | for y in range(nrow): |
|
1067 | for y in range(nrow): | |
1067 | if counter >= self.nplots: |
|
1068 | if counter >= self.nplots: | |
1068 | break |
|
1069 | break | |
1069 |
|
1070 | |||
1070 | self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1) |
|
1071 | self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1) | |
1071 | counter += 1 |
|
1072 | counter += 1 | |
1072 |
|
1073 | |||
1073 | def run(self, dataOut, id, wintitle="", channelList=None, |
|
1074 | def run(self, dataOut, id, wintitle="", channelList=None, | |
1074 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
1075 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
1075 | zmaxVertical = None, zminVertical = None, zmaxZonal = None, zminZonal = None, |
|
1076 | zmaxVertical = None, zminVertical = None, zmaxZonal = None, zminZonal = None, | |
1076 | timerange=None, SNRthresh = -numpy.inf, SNRmin = None, SNRmax = None, SNR_1 = False, |
|
1077 | timerange=None, SNRthresh = -numpy.inf, SNRmin = None, SNRmax = None, SNR_1 = False, | |
1077 | save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True, |
|
1078 | save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True, | |
1078 | server=None, folder=None, username=None, password=None, |
|
1079 | server=None, folder=None, username=None, password=None, | |
1079 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): |
|
1080 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): | |
1080 | """ |
|
1081 | """ | |
1081 |
|
1082 | |||
1082 | Input: |
|
1083 | Input: | |
1083 | dataOut : |
|
1084 | dataOut : | |
1084 | id : |
|
1085 | id : | |
1085 | wintitle : |
|
1086 | wintitle : | |
1086 | channelList : |
|
1087 | channelList : | |
1087 | showProfile : |
|
1088 | showProfile : | |
1088 | xmin : None, |
|
1089 | xmin : None, | |
1089 | xmax : None, |
|
1090 | xmax : None, | |
1090 | ymin : None, |
|
1091 | ymin : None, | |
1091 | ymax : None, |
|
1092 | ymax : None, | |
1092 | zmin : None, |
|
1093 | zmin : None, | |
1093 | zmax : None |
|
1094 | zmax : None | |
1094 | """ |
|
1095 | """ | |
1095 |
|
1096 | |||
1096 | if timerange is not None: |
|
1097 | if timerange is not None: | |
1097 | self.timerange = timerange |
|
1098 | self.timerange = timerange | |
1098 |
|
1099 | |||
1099 | tmin = None |
|
1100 | tmin = None | |
1100 | tmax = None |
|
1101 | tmax = None | |
1101 |
|
1102 | |||
1102 | x = dataOut.getTimeRange1() |
|
1103 | x = dataOut.getTimeRange1() | |
1103 | # y = dataOut.heightList |
|
1104 | # y = dataOut.heightList | |
1104 | y = dataOut.heightList |
|
1105 | y = dataOut.heightList | |
1105 |
|
1106 | |||
1106 | z = dataOut.data_output |
|
1107 | z = dataOut.data_output | |
1107 | nplots = z.shape[0] #Number of wind dimensions estimated |
|
1108 | nplots = z.shape[0] #Number of wind dimensions estimated | |
1108 | nplotsw = nplots |
|
1109 | nplotsw = nplots | |
1109 |
|
1110 | |||
1110 | #If there is a SNR function defined |
|
1111 | #If there is a SNR function defined | |
1111 | if dataOut.data_SNR is not None: |
|
1112 | if dataOut.data_SNR is not None: | |
1112 | nplots += 1 |
|
1113 | nplots += 1 | |
1113 | SNR = dataOut.data_SNR |
|
1114 | SNR = dataOut.data_SNR | |
1114 |
|
1115 | |||
1115 | if SNR_1: |
|
1116 | if SNR_1: | |
1116 | SNR += 1 |
|
1117 | SNR += 1 | |
1117 |
|
1118 | |||
1118 | SNRavg = numpy.average(SNR, axis=0) |
|
1119 | SNRavg = numpy.average(SNR, axis=0) | |
1119 |
|
1120 | |||
1120 | SNRdB = 10*numpy.log10(SNR) |
|
1121 | SNRdB = 10*numpy.log10(SNR) | |
1121 | SNRavgdB = 10*numpy.log10(SNRavg) |
|
1122 | SNRavgdB = 10*numpy.log10(SNRavg) | |
1122 |
|
1123 | |||
1123 | ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0] |
|
1124 | ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0] | |
1124 |
|
1125 | |||
1125 | for i in range(nplotsw): |
|
1126 | for i in range(nplotsw): | |
1126 | z[i,ind] = numpy.nan |
|
1127 | z[i,ind] = numpy.nan | |
1127 |
|
1128 | |||
1128 |
|
1129 | |||
1129 | showprofile = False |
|
1130 | showprofile = False | |
1130 | # thisDatetime = dataOut.datatime |
|
1131 | # thisDatetime = dataOut.datatime | |
1131 | thisDatetime = datetime.datetime.utcfromtimestamp(x[1]) |
|
1132 | thisDatetime = datetime.datetime.utcfromtimestamp(x[1]) | |
1132 | title = wintitle + " EW Drifts" |
|
1133 | title = wintitle + " EW Drifts" | |
1133 | xlabel = "" |
|
1134 | xlabel = "" | |
1134 | ylabel = "Height (Km)" |
|
1135 | ylabel = "Height (Km)" | |
1135 |
|
1136 | |||
1136 | if not self.__isConfig: |
|
1137 | if not self.__isConfig: | |
1137 |
|
1138 | |||
1138 | self.setup(id=id, |
|
1139 | self.setup(id=id, | |
1139 | nplots=nplots, |
|
1140 | nplots=nplots, | |
1140 | wintitle=wintitle, |
|
1141 | wintitle=wintitle, | |
1141 | showprofile=showprofile, |
|
1142 | showprofile=showprofile, | |
1142 | show=show) |
|
1143 | show=show) | |
1143 |
|
1144 | |||
1144 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) |
|
1145 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) | |
1145 |
|
1146 | |||
1146 | if ymin == None: ymin = numpy.nanmin(y) |
|
1147 | if ymin == None: ymin = numpy.nanmin(y) | |
1147 | if ymax == None: ymax = numpy.nanmax(y) |
|
1148 | if ymax == None: ymax = numpy.nanmax(y) | |
1148 |
|
1149 | |||
1149 | if zmaxZonal == None: zmaxZonal = numpy.nanmax(abs(z[0,:])) |
|
1150 | if zmaxZonal == None: zmaxZonal = numpy.nanmax(abs(z[0,:])) | |
1150 | if zminZonal == None: zminZonal = -zmaxZonal |
|
1151 | if zminZonal == None: zminZonal = -zmaxZonal | |
1151 | if zmaxVertical == None: zmaxVertical = numpy.nanmax(abs(z[1,:])) |
|
1152 | if zmaxVertical == None: zmaxVertical = numpy.nanmax(abs(z[1,:])) | |
1152 | if zminVertical == None: zminVertical = -zmaxVertical |
|
1153 | if zminVertical == None: zminVertical = -zmaxVertical | |
1153 |
|
1154 | |||
1154 | if dataOut.data_SNR is not None: |
|
1155 | if dataOut.data_SNR is not None: | |
1155 | if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB) |
|
1156 | if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB) | |
1156 | if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB) |
|
1157 | if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB) | |
1157 |
|
1158 | |||
1158 | self.FTP_WEI = ftp_wei |
|
1159 | self.FTP_WEI = ftp_wei | |
1159 | self.EXP_CODE = exp_code |
|
1160 | self.EXP_CODE = exp_code | |
1160 | self.SUB_EXP_CODE = sub_exp_code |
|
1161 | self.SUB_EXP_CODE = sub_exp_code | |
1161 | self.PLOT_POS = plot_pos |
|
1162 | self.PLOT_POS = plot_pos | |
1162 |
|
1163 | |||
1163 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
1164 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
1164 | self.__isConfig = True |
|
1165 | self.__isConfig = True | |
1165 |
|
1166 | |||
1166 |
|
1167 | |||
1167 | self.setWinTitle(title) |
|
1168 | self.setWinTitle(title) | |
1168 |
|
1169 | |||
1169 | if ((self.xmax - x[1]) < (x[1]-x[0])): |
|
1170 | if ((self.xmax - x[1]) < (x[1]-x[0])): | |
1170 | x[1] = self.xmax |
|
1171 | x[1] = self.xmax | |
1171 |
|
1172 | |||
1172 | strWind = ['Zonal','Vertical'] |
|
1173 | strWind = ['Zonal','Vertical'] | |
1173 | strCb = 'Velocity (m/s)' |
|
1174 | strCb = 'Velocity (m/s)' | |
1174 | zmaxVector = [zmaxZonal, zmaxVertical] |
|
1175 | zmaxVector = [zmaxZonal, zmaxVertical] | |
1175 | zminVector = [zminZonal, zminVertical] |
|
1176 | zminVector = [zminZonal, zminVertical] | |
1176 |
|
1177 | |||
1177 | for i in range(nplotsw): |
|
1178 | for i in range(nplotsw): | |
1178 |
|
1179 | |||
1179 | title = "%s Drifts: %s" %(strWind[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
1180 | title = "%s Drifts: %s" %(strWind[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
1180 | axes = self.axesList[i*self.__nsubplots] |
|
1181 | axes = self.axesList[i*self.__nsubplots] | |
1181 |
|
1182 | |||
1182 | z1 = z[i,:].reshape((1,-1)) |
|
1183 | z1 = z[i,:].reshape((1,-1)) | |
1183 |
|
1184 | |||
1184 | axes.pcolorbuffer(x, y, z1, |
|
1185 | axes.pcolorbuffer(x, y, z1, | |
1185 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zminVector[i], zmax=zmaxVector[i], |
|
1186 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zminVector[i], zmax=zmaxVector[i], | |
1186 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
1187 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
1187 | ticksize=9, cblabel=strCb, cbsize="1%", colormap="RdBu_r") |
|
1188 | ticksize=9, cblabel=strCb, cbsize="1%", colormap="RdBu_r") | |
1188 |
|
1189 | |||
1189 | if dataOut.data_SNR is not None: |
|
1190 | if dataOut.data_SNR is not None: | |
1190 | i += 1 |
|
1191 | i += 1 | |
1191 | if SNR_1: |
|
1192 | if SNR_1: | |
1192 | title = "Signal Noise Ratio + 1 (SNR+1): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
1193 | title = "Signal Noise Ratio + 1 (SNR+1): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
1193 | else: |
|
1194 | else: | |
1194 | title = "Signal Noise Ratio (SNR): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
1195 | title = "Signal Noise Ratio (SNR): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
1195 | axes = self.axesList[i*self.__nsubplots] |
|
1196 | axes = self.axesList[i*self.__nsubplots] | |
1196 | SNRavgdB = SNRavgdB.reshape((1,-1)) |
|
1197 | SNRavgdB = SNRavgdB.reshape((1,-1)) | |
1197 |
|
1198 | |||
1198 | axes.pcolorbuffer(x, y, SNRavgdB, |
|
1199 | axes.pcolorbuffer(x, y, SNRavgdB, | |
1199 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax, |
|
1200 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax, | |
1200 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
1201 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
1201 | ticksize=9, cblabel='', cbsize="1%", colormap="jet") |
|
1202 | ticksize=9, cblabel='', cbsize="1%", colormap="jet") | |
1202 |
|
1203 | |||
1203 | self.draw() |
|
1204 | self.draw() | |
1204 |
|
1205 | |||
1205 | if x[1] >= self.axesList[0].xmax: |
|
1206 | if x[1] >= self.axesList[0].xmax: | |
1206 | self.counter_imagwr = wr_period |
|
1207 | self.counter_imagwr = wr_period | |
1207 | self.__isConfig = False |
|
1208 | self.__isConfig = False | |
1208 | self.figfile = None |
|
1209 | self.figfile = None | |
1209 |
|
1210 | |||
1210 |
|
1211 | |||
1211 |
|
1212 | |||
1212 |
|
1213 | |||
1213 | class PhasePlot(Figure): |
|
1214 | class PhasePlot(Figure): | |
1214 |
|
1215 | |||
1215 | __isConfig = None |
|
1216 | __isConfig = None | |
1216 | __nsubplots = None |
|
1217 | __nsubplots = None | |
1217 |
|
1218 | |||
1218 | PREFIX = 'mphase' |
|
1219 | PREFIX = 'mphase' | |
1219 |
|
1220 | |||
1220 | def __init__(self): |
|
1221 | def __init__(self): | |
1221 |
|
1222 | |||
1222 | self.timerange = 24*60*60 |
|
1223 | self.timerange = 24*60*60 | |
1223 | self.__isConfig = False |
|
1224 | self.__isConfig = False | |
1224 | self.__nsubplots = 1 |
|
1225 | self.__nsubplots = 1 | |
1225 | self.counter_imagwr = 0 |
|
1226 | self.counter_imagwr = 0 | |
1226 | self.WIDTH = 600 |
|
1227 | self.WIDTH = 600 | |
1227 | self.HEIGHT = 300 |
|
1228 | self.HEIGHT = 300 | |
1228 | self.WIDTHPROF = 120 |
|
1229 | self.WIDTHPROF = 120 | |
1229 | self.HEIGHTPROF = 0 |
|
1230 | self.HEIGHTPROF = 0 | |
1230 | self.xdata = None |
|
1231 | self.xdata = None | |
1231 | self.ydata = None |
|
1232 | self.ydata = None | |
1232 |
|
1233 | |||
1233 | self.PLOT_CODE = MPHASE_CODE |
|
1234 | self.PLOT_CODE = MPHASE_CODE | |
1234 |
|
1235 | |||
1235 | self.FTP_WEI = None |
|
1236 | self.FTP_WEI = None | |
1236 | self.EXP_CODE = None |
|
1237 | self.EXP_CODE = None | |
1237 | self.SUB_EXP_CODE = None |
|
1238 | self.SUB_EXP_CODE = None | |
1238 | self.PLOT_POS = None |
|
1239 | self.PLOT_POS = None | |
1239 |
|
1240 | |||
1240 |
|
1241 | |||
1241 | self.filename_phase = None |
|
1242 | self.filename_phase = None | |
1242 |
|
1243 | |||
1243 | self.figfile = None |
|
1244 | self.figfile = None | |
1244 |
|
1245 | |||
1245 | def getSubplots(self): |
|
1246 | def getSubplots(self): | |
1246 |
|
1247 | |||
1247 | ncol = 1 |
|
1248 | ncol = 1 | |
1248 | nrow = 1 |
|
1249 | nrow = 1 | |
1249 |
|
1250 | |||
1250 | return nrow, ncol |
|
1251 | return nrow, ncol | |
1251 |
|
1252 | |||
1252 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
1253 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
1253 |
|
1254 | |||
1254 | self.__showprofile = showprofile |
|
1255 | self.__showprofile = showprofile | |
1255 | self.nplots = nplots |
|
1256 | self.nplots = nplots | |
1256 |
|
1257 | |||
1257 | ncolspan = 7 |
|
1258 | ncolspan = 7 | |
1258 | colspan = 6 |
|
1259 | colspan = 6 | |
1259 | self.__nsubplots = 2 |
|
1260 | self.__nsubplots = 2 | |
1260 |
|
1261 | |||
1261 | self.createFigure(id = id, |
|
1262 | self.createFigure(id = id, | |
1262 | wintitle = wintitle, |
|
1263 | wintitle = wintitle, | |
1263 | widthplot = self.WIDTH+self.WIDTHPROF, |
|
1264 | widthplot = self.WIDTH+self.WIDTHPROF, | |
1264 | heightplot = self.HEIGHT+self.HEIGHTPROF, |
|
1265 | heightplot = self.HEIGHT+self.HEIGHTPROF, | |
1265 | show=show) |
|
1266 | show=show) | |
1266 |
|
1267 | |||
1267 | nrow, ncol = self.getSubplots() |
|
1268 | nrow, ncol = self.getSubplots() | |
1268 |
|
1269 | |||
1269 | self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1) |
|
1270 | self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1) | |
1270 |
|
1271 | |||
1271 |
|
1272 | |||
1272 | def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True', |
|
1273 | def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True', | |
1273 | xmin=None, xmax=None, ymin=None, ymax=None, |
|
1274 | xmin=None, xmax=None, ymin=None, ymax=None, | |
1274 | timerange=None, |
|
1275 | timerange=None, | |
1275 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, |
|
1276 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, | |
1276 | server=None, folder=None, username=None, password=None, |
|
1277 | server=None, folder=None, username=None, password=None, | |
1277 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): |
|
1278 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): | |
1278 |
|
1279 | |||
1279 |
|
1280 | |||
1280 | tmin = None |
|
1281 | tmin = None | |
1281 | tmax = None |
|
1282 | tmax = None | |
1282 | x = dataOut.getTimeRange1() |
|
1283 | x = dataOut.getTimeRange1() | |
1283 | y = dataOut.getHeiRange() |
|
1284 | y = dataOut.getHeiRange() | |
1284 |
|
1285 | |||
1285 |
|
1286 | |||
1286 | #thisDatetime = dataOut.datatime |
|
1287 | #thisDatetime = dataOut.datatime | |
1287 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) |
|
1288 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) | |
1288 | title = wintitle + " Phase of Beacon Signal" # : %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
1289 | title = wintitle + " Phase of Beacon Signal" # : %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
1289 | xlabel = "Local Time" |
|
1290 | xlabel = "Local Time" | |
1290 | ylabel = "Phase" |
|
1291 | ylabel = "Phase" | |
1291 |
|
1292 | |||
1292 |
|
1293 | |||
1293 | #phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList))) |
|
1294 | #phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList))) | |
1294 | phase_beacon = dataOut.data_output |
|
1295 | phase_beacon = dataOut.data_output | |
1295 | update_figfile = False |
|
1296 | update_figfile = False | |
1296 |
|
1297 | |||
1297 | if not self.__isConfig: |
|
1298 | if not self.__isConfig: | |
1298 |
|
1299 | |||
1299 | self.nplots = phase_beacon.size |
|
1300 | self.nplots = phase_beacon.size | |
1300 |
|
1301 | |||
1301 | self.setup(id=id, |
|
1302 | self.setup(id=id, | |
1302 | nplots=self.nplots, |
|
1303 | nplots=self.nplots, | |
1303 | wintitle=wintitle, |
|
1304 | wintitle=wintitle, | |
1304 | showprofile=showprofile, |
|
1305 | showprofile=showprofile, | |
1305 | show=show) |
|
1306 | show=show) | |
1306 |
|
1307 | |||
1307 | if timerange is not None: |
|
1308 | if timerange is not None: | |
1308 | self.timerange = timerange |
|
1309 | self.timerange = timerange | |
1309 |
|
1310 | |||
1310 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) |
|
1311 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) | |
1311 |
|
1312 | |||
1312 | if ymin == None: ymin = numpy.nanmin(phase_beacon) - 10.0 |
|
1313 | if ymin == None: ymin = numpy.nanmin(phase_beacon) - 10.0 | |
1313 | if ymax == None: ymax = numpy.nanmax(phase_beacon) + 10.0 |
|
1314 | if ymax == None: ymax = numpy.nanmax(phase_beacon) + 10.0 | |
1314 |
|
1315 | |||
1315 | self.FTP_WEI = ftp_wei |
|
1316 | self.FTP_WEI = ftp_wei | |
1316 | self.EXP_CODE = exp_code |
|
1317 | self.EXP_CODE = exp_code | |
1317 | self.SUB_EXP_CODE = sub_exp_code |
|
1318 | self.SUB_EXP_CODE = sub_exp_code | |
1318 | self.PLOT_POS = plot_pos |
|
1319 | self.PLOT_POS = plot_pos | |
1319 |
|
1320 | |||
1320 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
1321 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
1321 | self.__isConfig = True |
|
1322 | self.__isConfig = True | |
1322 | self.figfile = figfile |
|
1323 | self.figfile = figfile | |
1323 | self.xdata = numpy.array([]) |
|
1324 | self.xdata = numpy.array([]) | |
1324 | self.ydata = numpy.array([]) |
|
1325 | self.ydata = numpy.array([]) | |
1325 |
|
1326 | |||
1326 | #open file beacon phase |
|
1327 | #open file beacon phase | |
1327 | path = '%s%03d' %(self.PREFIX, self.id) |
|
1328 | path = '%s%03d' %(self.PREFIX, self.id) | |
1328 | beacon_file = os.path.join(path,'%s.txt'%self.name) |
|
1329 | beacon_file = os.path.join(path,'%s.txt'%self.name) | |
1329 | self.filename_phase = os.path.join(figpath,beacon_file) |
|
1330 | self.filename_phase = os.path.join(figpath,beacon_file) | |
1330 | update_figfile = True |
|
1331 | update_figfile = True | |
1331 |
|
1332 | |||
1332 |
|
1333 | |||
1333 | #store data beacon phase |
|
1334 | #store data beacon phase | |
1334 | #self.save_data(self.filename_phase, phase_beacon, thisDatetime) |
|
1335 | #self.save_data(self.filename_phase, phase_beacon, thisDatetime) | |
1335 |
|
1336 | |||
1336 | self.setWinTitle(title) |
|
1337 | self.setWinTitle(title) | |
1337 |
|
1338 | |||
1338 |
|
1339 | |||
1339 | title = "Phase Offset %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
1340 | title = "Phase Offset %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
1340 |
|
1341 | |||
1341 | legendlabels = ["phase %d"%(chan) for chan in numpy.arange(self.nplots)] |
|
1342 | legendlabels = ["phase %d"%(chan) for chan in numpy.arange(self.nplots)] | |
1342 |
|
1343 | |||
1343 | axes = self.axesList[0] |
|
1344 | axes = self.axesList[0] | |
1344 |
|
1345 | |||
1345 | self.xdata = numpy.hstack((self.xdata, x[0:1])) |
|
1346 | self.xdata = numpy.hstack((self.xdata, x[0:1])) | |
1346 |
|
1347 | |||
1347 | if len(self.ydata)==0: |
|
1348 | if len(self.ydata)==0: | |
1348 | self.ydata = phase_beacon.reshape(-1,1) |
|
1349 | self.ydata = phase_beacon.reshape(-1,1) | |
1349 | else: |
|
1350 | else: | |
1350 | self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1))) |
|
1351 | self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1))) | |
1351 |
|
1352 | |||
1352 |
|
1353 | |||
1353 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, |
|
1354 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, | |
1354 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, |
|
1355 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, | |
1355 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid", |
|
1356 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid", | |
1356 | XAxisAsTime=True, grid='both' |
|
1357 | XAxisAsTime=True, grid='both' | |
1357 | ) |
|
1358 | ) | |
1358 |
|
1359 | |||
1359 | self.draw() |
|
1360 | self.draw() | |
1360 |
|
1361 | |||
1361 | if dataOut.ltctime >= self.xmax: |
|
1362 | if dataOut.ltctime >= self.xmax: | |
1362 | self.counter_imagwr = wr_period |
|
1363 | self.counter_imagwr = wr_period | |
1363 | self.__isConfig = False |
|
1364 | self.__isConfig = False | |
1364 | update_figfile = True |
|
1365 | update_figfile = True | |
1365 |
|
1366 | |||
1366 | self.save(figpath=figpath, |
|
1367 | self.save(figpath=figpath, | |
1367 | figfile=figfile, |
|
1368 | figfile=figfile, | |
1368 | save=save, |
|
1369 | save=save, | |
1369 | ftp=ftp, |
|
1370 | ftp=ftp, | |
1370 | wr_period=wr_period, |
|
1371 | wr_period=wr_period, | |
1371 | thisDatetime=thisDatetime, |
|
1372 | thisDatetime=thisDatetime, | |
1372 | update_figfile=update_figfile) |
|
1373 | update_figfile=update_figfile) |
General Comments 0
You need to be logged in to leave comments.
Login now