##// END OF EJS Templates
Bug fixed
Ivan Valdez -
r797:4f6f55491fdc
parent child
Show More
@@ -1,1373 +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 if self.xmin is None and self.xmax is None:
303 if self.xmin is None and self.xmax is None:
304 self.xmin, self.xmax = self.getTimeLim(x1, tmin, tmax, timerange)
304 self.xmin, self.xmax = self.getTimeLim(x1, tmin, tmax, timerange)
305
305
306 if timerange != None:
306 if timerange != None:
307 self.timerange = timerange
307 self.timerange = timerange
308 else:
308 else:
309 self.timerange = self.xmax - self.xmin
309 self.timerange = self.xmax - self.xmin
310
310
311 self.FTP_WEI = ftp_wei
311 self.FTP_WEI = ftp_wei
312 self.EXP_CODE = exp_code
312 self.EXP_CODE = exp_code
313 self.SUB_EXP_CODE = sub_exp_code
313 self.SUB_EXP_CODE = sub_exp_code
314 self.PLOT_POS = plot_pos
314 self.PLOT_POS = plot_pos
315 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
315 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
316 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"))
317 self.isConfig = True
317 self.isConfig = True
318 update_figfile = True
318 update_figfile = True
319
319
320 self.setWinTitle(title)
320 self.setWinTitle(title)
321
321
322 i = 0
322 i = 0
323 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"))
324
324
325 axes = self.axesList[i*self.__nsubplots]
325 axes = self.axesList[i*self.__nsubplots]
326 nevents = axes.x_buffer.shape[0] + x.shape[0]
326 nevents = axes.x_buffer.shape[0] + x.shape[0]
327 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)
328 axes.polar(x, y,
328 axes.polar(x, y,
329 title=title, xlabel=xlabel, ylabel=ylabel,
329 title=title, xlabel=xlabel, ylabel=ylabel,
330 ticksize=9, cblabel='')
330 ticksize=9, cblabel='')
331
331
332 self.draw()
332 self.draw()
333
333
334 self.save(figpath=figpath,
334 self.save(figpath=figpath,
335 figfile=figfile,
335 figfile=figfile,
336 save=save,
336 save=save,
337 ftp=ftp,
337 ftp=ftp,
338 wr_period=wr_period,
338 wr_period=wr_period,
339 thisDatetime=thisDatetime,
339 thisDatetime=thisDatetime,
340 update_figfile=update_figfile)
340 update_figfile=update_figfile)
341
341
342 if dataOut.ltctime >= self.xmax:
342 if dataOut.ltctime >= self.xmax:
343 self.isConfigmagwr = wr_period
343 self.isConfigmagwr = wr_period
344 self.isConfig = False
344 self.isConfig = False
345 update_figfile = True
345 update_figfile = True
346 axes.__firsttime = True
346 axes.__firsttime = True
347 self.xmin += self.timerange
347 self.xmin += self.timerange
348 self.xmax += self.timerange
348 self.xmax += self.timerange
349
349
350
350
351
351
352
352
353 class WindProfilerPlot(Figure):
353 class WindProfilerPlot(Figure):
354
354
355 __isConfig = None
355 __isConfig = None
356 __nsubplots = None
356 __nsubplots = None
357
357
358 WIDTHPROF = None
358 WIDTHPROF = None
359 HEIGHTPROF = None
359 HEIGHTPROF = None
360 PREFIX = 'wind'
360 PREFIX = 'wind'
361
361
362 def __init__(self):
362 def __init__(self):
363
363
364 self.timerange = None
364 self.timerange = None
365 self.isConfig = False
365 self.isConfig = False
366 self.__nsubplots = 1
366 self.__nsubplots = 1
367
367
368 self.WIDTH = 800
368 self.WIDTH = 800
369 self.HEIGHT = 150
369 self.HEIGHT = 150
370 self.WIDTHPROF = 120
370 self.WIDTHPROF = 120
371 self.HEIGHTPROF = 0
371 self.HEIGHTPROF = 0
372 self.counter_imagwr = 0
372 self.counter_imagwr = 0
373
373
374 self.PLOT_CODE = WIND_CODE
374 self.PLOT_CODE = WIND_CODE
375
375
376 self.FTP_WEI = None
376 self.FTP_WEI = None
377 self.EXP_CODE = None
377 self.EXP_CODE = None
378 self.SUB_EXP_CODE = None
378 self.SUB_EXP_CODE = None
379 self.PLOT_POS = None
379 self.PLOT_POS = None
380 self.tmin = None
380 self.tmin = None
381 self.tmax = None
381 self.tmax = None
382
382
383 self.xmin = None
383 self.xmin = None
384 self.xmax = None
384 self.xmax = None
385
385
386 self.figfile = None
386 self.figfile = None
387
387
388 def getSubplots(self):
388 def getSubplots(self):
389
389
390 ncol = 1
390 ncol = 1
391 nrow = self.nplots
391 nrow = self.nplots
392
392
393 return nrow, ncol
393 return nrow, ncol
394
394
395 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
395 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
396
396
397 self.__showprofile = showprofile
397 self.__showprofile = showprofile
398 self.nplots = nplots
398 self.nplots = nplots
399
399
400 ncolspan = 1
400 ncolspan = 1
401 colspan = 1
401 colspan = 1
402
402
403 self.createFigure(id = id,
403 self.createFigure(id = id,
404 wintitle = wintitle,
404 wintitle = wintitle,
405 widthplot = self.WIDTH + self.WIDTHPROF,
405 widthplot = self.WIDTH + self.WIDTHPROF,
406 heightplot = self.HEIGHT + self.HEIGHTPROF,
406 heightplot = self.HEIGHT + self.HEIGHTPROF,
407 show=show)
407 show=show)
408
408
409 nrow, ncol = self.getSubplots()
409 nrow, ncol = self.getSubplots()
410
410
411 counter = 0
411 counter = 0
412 for y in range(nrow):
412 for y in range(nrow):
413 if counter >= self.nplots:
413 if counter >= self.nplots:
414 break
414 break
415
415
416 self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1)
416 self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1)
417 counter += 1
417 counter += 1
418
418
419 def run(self, dataOut, id, wintitle="", channelList=None, showprofile='False',
419 def run(self, dataOut, id, wintitle="", channelList=None, showprofile='False',
420 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,
421 zmax_ver = None, zmin_ver = None, SNRmin = None, SNRmax = None,
421 zmax_ver = None, zmin_ver = None, SNRmin = None, SNRmax = None,
422 timerange=None, SNRthresh = None,
422 timerange=None, SNRthresh = None,
423 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,
424 server=None, folder=None, username=None, password=None,
424 server=None, folder=None, username=None, password=None,
425 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):
426 """
426 """
427
427
428 Input:
428 Input:
429 dataOut :
429 dataOut :
430 id :
430 id :
431 wintitle :
431 wintitle :
432 channelList :
432 channelList :
433 showProfile :
433 showProfile :
434 xmin : None,
434 xmin : None,
435 xmax : None,
435 xmax : None,
436 ymin : None,
436 ymin : None,
437 ymax : None,
437 ymax : None,
438 zmin : None,
438 zmin : None,
439 zmax : None
439 zmax : None
440 """
440 """
441
441
442 if channelList == None:
442 if channelList == None:
443 channelIndexList = dataOut.channelIndexList
443 channelIndexList = dataOut.channelIndexList
444 else:
444 else:
445 channelIndexList = []
445 channelIndexList = []
446 for channel in channelList:
446 for channel in channelList:
447 if channel not in dataOut.channelList:
447 if channel not in dataOut.channelList:
448 raise ValueError, "Channel %d is not in dataOut.channelList"
448 raise ValueError, "Channel %d is not in dataOut.channelList"
449 channelIndexList.append(dataOut.channelList.index(channel))
449 channelIndexList.append(dataOut.channelList.index(channel))
450
450
451 # if timerange is not None:
451 # if timerange is not None:
452 # self.timerange = timerange
452 # self.timerange = timerange
453 #
453 #
454 # tmin = None
454 # tmin = None
455 # tmax = None
455 # tmax = None
456
456
457 x = dataOut.getTimeRange1()
457 x = dataOut.getTimeRange1()
458 # y = dataOut.heightList
458 # y = dataOut.heightList
459 y = dataOut.heightList
459 y = dataOut.heightList
460
460
461 z = dataOut.data_output.copy()
461 z = dataOut.data_output.copy()
462 nplots = z.shape[0] #Number of wind dimensions estimated
462 nplots = z.shape[0] #Number of wind dimensions estimated
463 nplotsw = nplots
463 nplotsw = nplots
464
464
465 #If there is a SNR function defined
465 #If there is a SNR function defined
466 if dataOut.data_SNR is not None:
466 if dataOut.data_SNR is not None:
467 nplots += 1
467 nplots += 1
468 SNR = dataOut.data_SNR
468 SNR = dataOut.data_SNR
469 SNRavg = numpy.average(SNR, axis=0)
469 SNRavg = numpy.average(SNR, axis=0)
470
470
471 SNRdB = 10*numpy.log10(SNR)
471 SNRdB = 10*numpy.log10(SNR)
472 SNRavgdB = 10*numpy.log10(SNRavg)
472 SNRavgdB = 10*numpy.log10(SNRavg)
473
473
474 if SNRthresh == None: SNRthresh = -5.0
474 if SNRthresh == None: SNRthresh = -5.0
475 ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0]
475 ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0]
476
476
477 for i in range(nplotsw):
477 for i in range(nplotsw):
478 z[i,ind] = numpy.nan
478 z[i,ind] = numpy.nan
479
479
480
480
481 # showprofile = False
481 # showprofile = False
482 # thisDatetime = dataOut.datatime
482 # thisDatetime = dataOut.datatime
483 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
483 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
484 title = wintitle + "Wind"
484 title = wintitle + "Wind"
485 xlabel = ""
485 xlabel = ""
486 ylabel = "Range (Km)"
486 ylabel = "Range (Km)"
487 update_figfile = False
487 update_figfile = False
488
488
489 if not self.isConfig:
489 if not self.isConfig:
490
490
491 self.setup(id=id,
491 self.setup(id=id,
492 nplots=nplots,
492 nplots=nplots,
493 wintitle=wintitle,
493 wintitle=wintitle,
494 showprofile=showprofile,
494 showprofile=showprofile,
495 show=show)
495 show=show)
496
496
497 if timerange is not None:
497 if timerange is not None:
498 self.timerange = timerange
498 self.timerange = timerange
499
499
500 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
500 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
501
501
502 if ymin == None: ymin = numpy.nanmin(y)
502 if ymin == None: ymin = numpy.nanmin(y)
503 if ymax == None: ymax = numpy.nanmax(y)
503 if ymax == None: ymax = numpy.nanmax(y)
504
504
505 if zmax == None: zmax = numpy.nanmax(abs(z[range(2),:]))
505 if zmax == None: zmax = numpy.nanmax(abs(z[range(2),:]))
506 #if numpy.isnan(zmax): zmax = 50
506 #if numpy.isnan(zmax): zmax = 50
507 if zmin == None: zmin = -zmax
507 if zmin == None: zmin = -zmax
508
508
509 if nplotsw == 3:
509 if nplotsw == 3:
510 if zmax_ver == None: zmax_ver = numpy.nanmax(abs(z[2,:]))
510 if zmax_ver == None: zmax_ver = numpy.nanmax(abs(z[2,:]))
511 if zmin_ver == None: zmin_ver = -zmax_ver
511 if zmin_ver == None: zmin_ver = -zmax_ver
512
512
513 if dataOut.data_SNR is not None:
513 if dataOut.data_SNR is not None:
514 if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB)
514 if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB)
515 if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB)
515 if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB)
516
516
517
517
518 self.FTP_WEI = ftp_wei
518 self.FTP_WEI = ftp_wei
519 self.EXP_CODE = exp_code
519 self.EXP_CODE = exp_code
520 self.SUB_EXP_CODE = sub_exp_code
520 self.SUB_EXP_CODE = sub_exp_code
521 self.PLOT_POS = plot_pos
521 self.PLOT_POS = plot_pos
522
522
523 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
523 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
524 self.isConfig = True
524 self.isConfig = True
525 self.figfile = figfile
525 self.figfile = figfile
526 update_figfile = True
526 update_figfile = True
527
527
528 self.setWinTitle(title)
528 self.setWinTitle(title)
529
529
530 if ((self.xmax - x[1]) < (x[1]-x[0])):
530 if ((self.xmax - x[1]) < (x[1]-x[0])):
531 x[1] = self.xmax
531 x[1] = self.xmax
532
532
533 strWind = ['Zonal', 'Meridional', 'Vertical']
533 strWind = ['Zonal', 'Meridional', 'Vertical']
534 strCb = ['Velocity (m/s)','Velocity (m/s)','Velocity (cm/s)']
534 strCb = ['Velocity (m/s)','Velocity (m/s)','Velocity (cm/s)']
535 zmaxVector = [zmax, zmax, zmax_ver]
535 zmaxVector = [zmax, zmax, zmax_ver]
536 zminVector = [zmin, zmin, zmin_ver]
536 zminVector = [zmin, zmin, zmin_ver]
537 windFactor = [1,1,100]
537 windFactor = [1,1,100]
538
538
539 for i in range(nplotsw):
539 for i in range(nplotsw):
540
540
541 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"))
542 axes = self.axesList[i*self.__nsubplots]
542 axes = self.axesList[i*self.__nsubplots]
543
543
544 z1 = z[i,:].reshape((1,-1))*windFactor[i]
544 z1 = z[i,:].reshape((1,-1))*windFactor[i]
545
545
546 axes.pcolorbuffer(x, y, z1,
546 axes.pcolorbuffer(x, y, z1,
547 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],
548 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
548 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
549 ticksize=9, cblabel=strCb[i], cbsize="1%", colormap="RdBu_r" )
549 ticksize=9, cblabel=strCb[i], cbsize="1%", colormap="RdBu_r" )
550
550
551 if dataOut.data_SNR is not None:
551 if dataOut.data_SNR is not None:
552 i += 1
552 i += 1
553 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"))
554 axes = self.axesList[i*self.__nsubplots]
554 axes = self.axesList[i*self.__nsubplots]
555
555
556 SNRavgdB = SNRavgdB.reshape((1,-1))
556 SNRavgdB = SNRavgdB.reshape((1,-1))
557
557
558 axes.pcolorbuffer(x, y, SNRavgdB,
558 axes.pcolorbuffer(x, y, SNRavgdB,
559 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,
560 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
560 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
561 ticksize=9, cblabel='', cbsize="1%", colormap="jet")
561 ticksize=9, cblabel='', cbsize="1%", colormap="jet")
562
562
563 self.draw()
563 self.draw()
564
564
565 if dataOut.ltctime >= self.xmax:
565 if dataOut.ltctime >= self.xmax:
566 self.counter_imagwr = wr_period
566 self.counter_imagwr = wr_period
567 self.isConfig = False
567 self.isConfig = False
568 update_figfile = True
568 update_figfile = True
569
569
570 self.save(figpath=figpath,
570 self.save(figpath=figpath,
571 figfile=figfile,
571 figfile=figfile,
572 save=save,
572 save=save,
573 ftp=ftp,
573 ftp=ftp,
574 wr_period=wr_period,
574 wr_period=wr_period,
575 thisDatetime=thisDatetime,
575 thisDatetime=thisDatetime,
576 update_figfile=update_figfile)
576 update_figfile=update_figfile)
577
577
578
578
579
579
580 class ParametersPlot(Figure):
580 class ParametersPlot(Figure):
581
581
582 __isConfig = None
582 __isConfig = None
583 __nsubplots = None
583 __nsubplots = None
584
584
585 WIDTHPROF = None
585 WIDTHPROF = None
586 HEIGHTPROF = None
586 HEIGHTPROF = None
587 PREFIX = 'prm'
587 PREFIX = 'prm'
588
588
589 def __init__(self):
589 def __init__(self):
590
590
591 self.timerange = 2*60*60
591 self.timerange = 2*60*60
592 self.isConfig = False
592 self.isConfig = False
593 self.__nsubplots = 1
593 self.__nsubplots = 1
594
594
595 self.WIDTH = 800
595 self.WIDTH = 800
596 self.HEIGHT = 150
596 self.HEIGHT = 150
597 self.WIDTHPROF = 120
597 self.WIDTHPROF = 120
598 self.HEIGHTPROF = 0
598 self.HEIGHTPROF = 0
599 self.counter_imagwr = 0
599 self.counter_imagwr = 0
600
600
601 self.PLOT_CODE = PARMS_CODE
601 self.PLOT_CODE = PARMS_CODE
602
602
603 self.FTP_WEI = None
603 self.FTP_WEI = None
604 self.EXP_CODE = None
604 self.EXP_CODE = None
605 self.SUB_EXP_CODE = None
605 self.SUB_EXP_CODE = None
606 self.PLOT_POS = None
606 self.PLOT_POS = None
607 self.tmin = None
607 self.tmin = None
608 self.tmax = None
608 self.tmax = None
609
609
610 self.xmin = None
610 self.xmin = None
611 self.xmax = None
611 self.xmax = None
612
612
613 self.figfile = None
613 self.figfile = None
614
614
615 def getSubplots(self):
615 def getSubplots(self):
616
616
617 ncol = 1
617 ncol = 1
618 nrow = self.nplots
618 nrow = self.nplots
619
619
620 return nrow, ncol
620 return nrow, ncol
621
621
622 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
622 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
623
623
624 self.__showprofile = showprofile
624 self.__showprofile = showprofile
625 self.nplots = nplots
625 self.nplots = nplots
626
626
627 ncolspan = 1
627 ncolspan = 1
628 colspan = 1
628 colspan = 1
629
629
630 self.createFigure(id = id,
630 self.createFigure(id = id,
631 wintitle = wintitle,
631 wintitle = wintitle,
632 widthplot = self.WIDTH + self.WIDTHPROF,
632 widthplot = self.WIDTH + self.WIDTHPROF,
633 heightplot = self.HEIGHT + self.HEIGHTPROF,
633 heightplot = self.HEIGHT + self.HEIGHTPROF,
634 show=show)
634 show=show)
635
635
636 nrow, ncol = self.getSubplots()
636 nrow, ncol = self.getSubplots()
637
637
638 counter = 0
638 counter = 0
639 for y in range(nrow):
639 for y in range(nrow):
640 for x in range(ncol):
640 for x in range(ncol):
641
641
642 if counter >= self.nplots:
642 if counter >= self.nplots:
643 break
643 break
644
644
645 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
645 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
646
646
647 if showprofile:
647 if showprofile:
648 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
648 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
649
649
650 counter += 1
650 counter += 1
651
651
652 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=False,
652 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=False,
653 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,
654 parameterIndex = None, onlyPositive = False,
654 parameterIndex = None, onlyPositive = False,
655 SNRthresh = -numpy.inf, SNR = True, SNRmin = None, SNRmax = None, onlySNR = False,
655 SNRthresh = -numpy.inf, SNR = True, SNRmin = None, SNRmax = None, onlySNR = False,
656 DOP = True,
656 DOP = True,
657 zlabel = "", parameterName = "", parameterObject = "data_param",
657 zlabel = "", parameterName = "", parameterObject = "data_param",
658 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,
659 server=None, folder=None, username=None, password=None,
659 server=None, folder=None, username=None, password=None,
660 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):
661
661
662 """
662 """
663
663
664 Input:
664 Input:
665 dataOut :
665 dataOut :
666 id :
666 id :
667 wintitle :
667 wintitle :
668 channelList :
668 channelList :
669 showProfile :
669 showProfile :
670 xmin : None,
670 xmin : None,
671 xmax : None,
671 xmax : None,
672 ymin : None,
672 ymin : None,
673 ymax : None,
673 ymax : None,
674 zmin : None,
674 zmin : None,
675 zmax : None
675 zmax : None
676 """
676 """
677
677
678 data_param = getattr(dataOut, parameterObject)
678 data_param = getattr(dataOut, parameterObject)
679
679
680 if channelList == None:
680 if channelList == None:
681 channelIndexList = numpy.arange(data_param.shape[0])
681 channelIndexList = numpy.arange(data_param.shape[0])
682 else:
682 else:
683 channelIndexList = numpy.array(channelList)
683 channelIndexList = numpy.array(channelList)
684
684
685 nchan = len(channelIndexList) #Number of channels being plotted
685 nchan = len(channelIndexList) #Number of channels being plotted
686
686
687 if nchan < 1:
687 if nchan < 1:
688 return
688 return
689
689
690 nGraphsByChannel = 0
690 nGraphsByChannel = 0
691
691
692 if SNR:
692 if SNR:
693 nGraphsByChannel += 1
693 nGraphsByChannel += 1
694 if DOP:
694 if DOP:
695 nGraphsByChannel += 1
695 nGraphsByChannel += 1
696
696
697 if nGraphsByChannel < 1:
697 if nGraphsByChannel < 1:
698 return
698 return
699
699
700 nplots = nGraphsByChannel*nchan
700 nplots = nGraphsByChannel*nchan
701
701
702 if timerange is not None:
702 if timerange is not None:
703 self.timerange = timerange
703 self.timerange = timerange
704
704
705 #tmin = None
705 #tmin = None
706 #tmax = None
706 #tmax = None
707 if parameterIndex == None:
707 if parameterIndex == None:
708 parameterIndex = 1
708 parameterIndex = 1
709
709
710 x = dataOut.getTimeRange1()
710 x = dataOut.getTimeRange1()
711 y = dataOut.heightList
711 y = dataOut.heightList
712 z = data_param[channelIndexList,parameterIndex,:].copy()
712 z = data_param[channelIndexList,parameterIndex,:].copy()
713
713
714 zRange = dataOut.abscissaList
714 zRange = dataOut.abscissaList
715 # nChannels = z.shape[0] #Number of wind dimensions estimated
715 # nChannels = z.shape[0] #Number of wind dimensions estimated
716 # thisDatetime = dataOut.datatime
716 # thisDatetime = dataOut.datatime
717
717
718 if dataOut.data_SNR is not None:
718 if dataOut.data_SNR is not None:
719 SNRarray = dataOut.data_SNR[channelIndexList,:]
719 SNRarray = dataOut.data_SNR[channelIndexList,:]
720 SNRdB = 10*numpy.log10(SNRarray)
720 SNRdB = 10*numpy.log10(SNRarray)
721 # SNRavgdB = 10*numpy.log10(SNRavg)
721 # SNRavgdB = 10*numpy.log10(SNRavg)
722 ind = numpy.where(SNRdB < 10**(SNRthresh/10))
722 ind = numpy.where(SNRdB < 10**(SNRthresh/10))
723 z[ind] = numpy.nan
723 z[ind] = numpy.nan
724
724
725 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
725 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
726 title = wintitle + " Parameters Plot" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
726 title = wintitle + " Parameters Plot" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
727 xlabel = ""
727 xlabel = ""
728 ylabel = "Range (Km)"
728 ylabel = "Range (Km)"
729
729
730 if (SNR and not onlySNR): nplots = 2*nplots
730 if (SNR and not onlySNR): nplots = 2*nplots
731
731
732 if onlyPositive:
732 if onlyPositive:
733 colormap = "jet"
733 colormap = "jet"
734 zmin = 0
734 zmin = 0
735 else: colormap = "RdBu_r"
735 else: colormap = "RdBu_r"
736
736
737 if not self.isConfig:
737 if not self.isConfig:
738
738
739 self.setup(id=id,
739 self.setup(id=id,
740 nplots=nplots,
740 nplots=nplots,
741 wintitle=wintitle,
741 wintitle=wintitle,
742 showprofile=showprofile,
742 showprofile=showprofile,
743 show=show)
743 show=show)
744
744
745 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
745 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
746
746
747 if ymin == None: ymin = numpy.nanmin(y)
747 if ymin == None: ymin = numpy.nanmin(y)
748 if ymax == None: ymax = numpy.nanmax(y)
748 if ymax == None: ymax = numpy.nanmax(y)
749 if zmin == None: zmin = numpy.nanmin(zRange)
749 if zmin == None: zmin = numpy.nanmin(zRange)
750 if zmax == None: zmax = numpy.nanmax(zRange)
750 if zmax == None: zmax = numpy.nanmax(zRange)
751
751
752 if SNR:
752 if SNR:
753 if SNRmin == None: SNRmin = numpy.nanmin(SNRdB)
753 if SNRmin == None: SNRmin = numpy.nanmin(SNRdB)
754 if SNRmax == None: SNRmax = numpy.nanmax(SNRdB)
754 if SNRmax == None: SNRmax = numpy.nanmax(SNRdB)
755
755
756 self.FTP_WEI = ftp_wei
756 self.FTP_WEI = ftp_wei
757 self.EXP_CODE = exp_code
757 self.EXP_CODE = exp_code
758 self.SUB_EXP_CODE = sub_exp_code
758 self.SUB_EXP_CODE = sub_exp_code
759 self.PLOT_POS = plot_pos
759 self.PLOT_POS = plot_pos
760
760
761 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
761 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
762 self.isConfig = True
762 self.isConfig = True
763 self.figfile = figfile
763 self.figfile = figfile
764
764
765 self.setWinTitle(title)
765 self.setWinTitle(title)
766
766
767 if ((self.xmax - x[1]) < (x[1]-x[0])):
767 if ((self.xmax - x[1]) < (x[1]-x[0])):
768 x[1] = self.xmax
768 x[1] = self.xmax
769
769
770 for i in range(nchan):
770 for i in range(nchan):
771
771
772 if (SNR and not onlySNR): j = 2*i
772 if (SNR and not onlySNR): j = 2*i
773 else: j = i
773 else: j = i
774
774
775 j = nGraphsByChannel*i
775 j = nGraphsByChannel*i
776
776
777 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
777 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
778 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)
779
779
780 if not onlySNR:
780 if not onlySNR:
781 axes = self.axesList[j*self.__nsubplots]
781 axes = self.axesList[j*self.__nsubplots]
782 z1 = z[i,:].reshape((1,-1))
782 z1 = z[i,:].reshape((1,-1))
783 axes.pcolorbuffer(x, y, z1,
783 axes.pcolorbuffer(x, y, z1,
784 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,
785 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,
786 ticksize=9, cblabel=zlabel, cbsize="1%")
786 ticksize=9, cblabel=zlabel, cbsize="1%")
787
787
788 if DOP:
788 if DOP:
789 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"))
790
790
791 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
791 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
792 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)
793 axes = self.axesList[j]
793 axes = self.axesList[j]
794 z1 = z[i,:].reshape((1,-1))
794 z1 = z[i,:].reshape((1,-1))
795 axes.pcolorbuffer(x, y, z1,
795 axes.pcolorbuffer(x, y, z1,
796 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,
797 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,
798 ticksize=9, cblabel=zlabel, cbsize="1%")
798 ticksize=9, cblabel=zlabel, cbsize="1%")
799
799
800 if SNR:
800 if SNR:
801 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"))
802 axes = self.axesList[(j)*self.__nsubplots]
802 axes = self.axesList[(j)*self.__nsubplots]
803 if not onlySNR:
803 if not onlySNR:
804 axes = self.axesList[(j + 1)*self.__nsubplots]
804 axes = self.axesList[(j + 1)*self.__nsubplots]
805
805
806 axes = self.axesList[(j + nGraphsByChannel-1)]
806 axes = self.axesList[(j + nGraphsByChannel-1)]
807
807
808 z1 = SNRdB[i,:].reshape((1,-1))
808 z1 = SNRdB[i,:].reshape((1,-1))
809 axes.pcolorbuffer(x, y, z1,
809 axes.pcolorbuffer(x, y, z1,
810 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,
811 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",
812 ticksize=9, cblabel=zlabel, cbsize="1%")
812 ticksize=9, cblabel=zlabel, cbsize="1%")
813
813
814
814
815
815
816 self.draw()
816 self.draw()
817
817
818 if x[1] >= self.axesList[0].xmax:
818 if x[1] >= self.axesList[0].xmax:
819 self.counter_imagwr = wr_period
819 self.counter_imagwr = wr_period
820 self.isConfig = False
820 self.isConfig = False
821 self.figfile = None
821 self.figfile = None
822
822
823 self.save(figpath=figpath,
823 self.save(figpath=figpath,
824 figfile=figfile,
824 figfile=figfile,
825 save=save,
825 save=save,
826 ftp=ftp,
826 ftp=ftp,
827 wr_period=wr_period,
827 wr_period=wr_period,
828 thisDatetime=thisDatetime,
828 thisDatetime=thisDatetime,
829 update_figfile=False)
829 update_figfile=False)
830
830
831 class SpectralFittingPlot(Figure):
831 class SpectralFittingPlot(Figure):
832
832
833 __isConfig = None
833 __isConfig = None
834 __nsubplots = None
834 __nsubplots = None
835
835
836 WIDTHPROF = None
836 WIDTHPROF = None
837 HEIGHTPROF = None
837 HEIGHTPROF = None
838 PREFIX = 'prm'
838 PREFIX = 'prm'
839
839
840
840
841 N = None
841 N = None
842 ippSeconds = None
842 ippSeconds = None
843
843
844 def __init__(self):
844 def __init__(self):
845 self.isConfig = False
845 self.isConfig = False
846 self.__nsubplots = 1
846 self.__nsubplots = 1
847
847
848 self.PLOT_CODE = SPECFIT_CODE
848 self.PLOT_CODE = SPECFIT_CODE
849
849
850 self.WIDTH = 450
850 self.WIDTH = 450
851 self.HEIGHT = 250
851 self.HEIGHT = 250
852 self.WIDTHPROF = 0
852 self.WIDTHPROF = 0
853 self.HEIGHTPROF = 0
853 self.HEIGHTPROF = 0
854
854
855 def getSubplots(self):
855 def getSubplots(self):
856
856
857 ncol = int(numpy.sqrt(self.nplots)+0.9)
857 ncol = int(numpy.sqrt(self.nplots)+0.9)
858 nrow = int(self.nplots*1./ncol + 0.9)
858 nrow = int(self.nplots*1./ncol + 0.9)
859
859
860 return nrow, ncol
860 return nrow, ncol
861
861
862 def setup(self, id, nplots, wintitle, showprofile=False, show=True):
862 def setup(self, id, nplots, wintitle, showprofile=False, show=True):
863
863
864 showprofile = False
864 showprofile = False
865 self.__showprofile = showprofile
865 self.__showprofile = showprofile
866 self.nplots = nplots
866 self.nplots = nplots
867
867
868 ncolspan = 5
868 ncolspan = 5
869 colspan = 4
869 colspan = 4
870 if showprofile:
870 if showprofile:
871 ncolspan = 5
871 ncolspan = 5
872 colspan = 4
872 colspan = 4
873 self.__nsubplots = 2
873 self.__nsubplots = 2
874
874
875 self.createFigure(id = id,
875 self.createFigure(id = id,
876 wintitle = wintitle,
876 wintitle = wintitle,
877 widthplot = self.WIDTH + self.WIDTHPROF,
877 widthplot = self.WIDTH + self.WIDTHPROF,
878 heightplot = self.HEIGHT + self.HEIGHTPROF,
878 heightplot = self.HEIGHT + self.HEIGHTPROF,
879 show=show)
879 show=show)
880
880
881 nrow, ncol = self.getSubplots()
881 nrow, ncol = self.getSubplots()
882
882
883 counter = 0
883 counter = 0
884 for y in range(nrow):
884 for y in range(nrow):
885 for x in range(ncol):
885 for x in range(ncol):
886
886
887 if counter >= self.nplots:
887 if counter >= self.nplots:
888 break
888 break
889
889
890 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
890 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
891
891
892 if showprofile:
892 if showprofile:
893 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
893 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
894
894
895 counter += 1
895 counter += 1
896
896
897 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,
898 xmin=None, xmax=None, ymin=None, ymax=None,
898 xmin=None, xmax=None, ymin=None, ymax=None,
899 save=False, figpath='./', figfile=None, show=True):
899 save=False, figpath='./', figfile=None, show=True):
900
900
901 """
901 """
902
902
903 Input:
903 Input:
904 dataOut :
904 dataOut :
905 id :
905 id :
906 wintitle :
906 wintitle :
907 channelList :
907 channelList :
908 showProfile :
908 showProfile :
909 xmin : None,
909 xmin : None,
910 xmax : None,
910 xmax : None,
911 zmin : None,
911 zmin : None,
912 zmax : None
912 zmax : None
913 """
913 """
914
914
915 if cutHeight==None:
915 if cutHeight==None:
916 h=270
916 h=270
917 heightindex = numpy.abs(cutHeight - dataOut.heightList).argmin()
917 heightindex = numpy.abs(cutHeight - dataOut.heightList).argmin()
918 cutHeight = dataOut.heightList[heightindex]
918 cutHeight = dataOut.heightList[heightindex]
919
919
920 factor = dataOut.normFactor
920 factor = dataOut.normFactor
921 x = dataOut.abscissaList[:-1]
921 x = dataOut.abscissaList[:-1]
922 #y = dataOut.getHeiRange()
922 #y = dataOut.getHeiRange()
923
923
924 z = dataOut.data_pre[:,:,heightindex]/factor
924 z = dataOut.data_pre[:,:,heightindex]/factor
925 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
925 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
926 avg = numpy.average(z, axis=1)
926 avg = numpy.average(z, axis=1)
927 listChannels = z.shape[0]
927 listChannels = z.shape[0]
928
928
929 #Reconstruct Function
929 #Reconstruct Function
930 if fit==True:
930 if fit==True:
931 groupArray = dataOut.groupList
931 groupArray = dataOut.groupList
932 listChannels = groupArray.reshape((groupArray.size))
932 listChannels = groupArray.reshape((groupArray.size))
933 listChannels.sort()
933 listChannels.sort()
934 spcFitLine = numpy.zeros(z.shape)
934 spcFitLine = numpy.zeros(z.shape)
935 constants = dataOut.constants
935 constants = dataOut.constants
936
936
937 nGroups = groupArray.shape[0]
937 nGroups = groupArray.shape[0]
938 nChannels = groupArray.shape[1]
938 nChannels = groupArray.shape[1]
939 nProfiles = z.shape[1]
939 nProfiles = z.shape[1]
940
940
941 for f in range(nGroups):
941 for f in range(nGroups):
942 groupChann = groupArray[f,:]
942 groupChann = groupArray[f,:]
943 p = dataOut.data_param[f,:,heightindex]
943 p = dataOut.data_param[f,:,heightindex]
944 # 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])
945 fitLineAux = dataOut.library.modelFunction(p, constants)*nProfiles
945 fitLineAux = dataOut.library.modelFunction(p, constants)*nProfiles
946 fitLineAux = fitLineAux.reshape((nChannels,nProfiles))
946 fitLineAux = fitLineAux.reshape((nChannels,nProfiles))
947 spcFitLine[groupChann,:] = fitLineAux
947 spcFitLine[groupChann,:] = fitLineAux
948 # spcFitLine = spcFitLine/factor
948 # spcFitLine = spcFitLine/factor
949
949
950 z = z[listChannels,:]
950 z = z[listChannels,:]
951 spcFitLine = spcFitLine[listChannels,:]
951 spcFitLine = spcFitLine[listChannels,:]
952 spcFitLinedB = 10*numpy.log10(spcFitLine)
952 spcFitLinedB = 10*numpy.log10(spcFitLine)
953
953
954 zdB = 10*numpy.log10(z)
954 zdB = 10*numpy.log10(z)
955 #thisDatetime = dataOut.datatime
955 #thisDatetime = dataOut.datatime
956 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
956 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
957 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"))
958 xlabel = "Velocity (m/s)"
958 xlabel = "Velocity (m/s)"
959 ylabel = "Spectrum"
959 ylabel = "Spectrum"
960
960
961 if not self.isConfig:
961 if not self.isConfig:
962
962
963 nplots = listChannels.size
963 nplots = listChannels.size
964
964
965 self.setup(id=id,
965 self.setup(id=id,
966 nplots=nplots,
966 nplots=nplots,
967 wintitle=wintitle,
967 wintitle=wintitle,
968 showprofile=showprofile,
968 showprofile=showprofile,
969 show=show)
969 show=show)
970
970
971 if xmin == None: xmin = numpy.nanmin(x)
971 if xmin == None: xmin = numpy.nanmin(x)
972 if xmax == None: xmax = numpy.nanmax(x)
972 if xmax == None: xmax = numpy.nanmax(x)
973 if ymin == None: ymin = numpy.nanmin(zdB)
973 if ymin == None: ymin = numpy.nanmin(zdB)
974 if ymax == None: ymax = numpy.nanmax(zdB)+2
974 if ymax == None: ymax = numpy.nanmax(zdB)+2
975
975
976 self.isConfig = True
976 self.isConfig = True
977
977
978 self.setWinTitle(title)
978 self.setWinTitle(title)
979 for i in range(self.nplots):
979 for i in range(self.nplots):
980 # title = "Channel %d: %4.2fdB" %(dataOut.channelList[i]+1, noisedB[i])
980 # title = "Channel %d: %4.2fdB" %(dataOut.channelList[i]+1, noisedB[i])
981 title = "Height %4.1f km\nChannel %d:" %(cutHeight, listChannels[i])
981 title = "Height %4.1f km\nChannel %d:" %(cutHeight, listChannels[i])
982 axes = self.axesList[i*self.__nsubplots]
982 axes = self.axesList[i*self.__nsubplots]
983 if fit == False:
983 if fit == False:
984 axes.pline(x, zdB[i,:],
984 axes.pline(x, zdB[i,:],
985 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
985 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
986 xlabel=xlabel, ylabel=ylabel, title=title
986 xlabel=xlabel, ylabel=ylabel, title=title
987 )
987 )
988 if fit == True:
988 if fit == True:
989 fitline=spcFitLinedB[i,:]
989 fitline=spcFitLinedB[i,:]
990 y=numpy.vstack([zdB[i,:],fitline] )
990 y=numpy.vstack([zdB[i,:],fitline] )
991 legendlabels=['Data','Fitting']
991 legendlabels=['Data','Fitting']
992 axes.pmultilineyaxis(x, y,
992 axes.pmultilineyaxis(x, y,
993 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
993 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
994 xlabel=xlabel, ylabel=ylabel, title=title,
994 xlabel=xlabel, ylabel=ylabel, title=title,
995 legendlabels=legendlabels, marker=None,
995 legendlabels=legendlabels, marker=None,
996 linestyle='solid', grid='both')
996 linestyle='solid', grid='both')
997
997
998 self.draw()
998 self.draw()
999
999
1000 self.save(figpath=figpath,
1000 self.save(figpath=figpath,
1001 figfile=figfile,
1001 figfile=figfile,
1002 save=save,
1002 save=save,
1003 ftp=ftp,
1003 ftp=ftp,
1004 wr_period=wr_period,
1004 wr_period=wr_period,
1005 thisDatetime=thisDatetime)
1005 thisDatetime=thisDatetime)
1006
1006
1007
1007
1008 class EWDriftsPlot(Figure):
1008 class EWDriftsPlot(Figure):
1009
1009
1010 __isConfig = None
1010 __isConfig = None
1011 __nsubplots = None
1011 __nsubplots = None
1012
1012
1013 WIDTHPROF = None
1013 WIDTHPROF = None
1014 HEIGHTPROF = None
1014 HEIGHTPROF = None
1015 PREFIX = 'drift'
1015 PREFIX = 'drift'
1016
1016
1017 def __init__(self):
1017 def __init__(self):
1018
1018
1019 self.timerange = 2*60*60
1019 self.timerange = 2*60*60
1020 self.isConfig = False
1020 self.isConfig = False
1021 self.__nsubplots = 1
1021 self.__nsubplots = 1
1022
1022
1023 self.WIDTH = 800
1023 self.WIDTH = 800
1024 self.HEIGHT = 150
1024 self.HEIGHT = 150
1025 self.WIDTHPROF = 120
1025 self.WIDTHPROF = 120
1026 self.HEIGHTPROF = 0
1026 self.HEIGHTPROF = 0
1027 self.counter_imagwr = 0
1027 self.counter_imagwr = 0
1028
1028
1029 self.PLOT_CODE = EWDRIFT_CODE
1029 self.PLOT_CODE = EWDRIFT_CODE
1030
1030
1031 self.FTP_WEI = None
1031 self.FTP_WEI = None
1032 self.EXP_CODE = None
1032 self.EXP_CODE = None
1033 self.SUB_EXP_CODE = None
1033 self.SUB_EXP_CODE = None
1034 self.PLOT_POS = None
1034 self.PLOT_POS = None
1035 self.tmin = None
1035 self.tmin = None
1036 self.tmax = None
1036 self.tmax = None
1037
1037
1038 self.xmin = None
1038 self.xmin = None
1039 self.xmax = None
1039 self.xmax = None
1040
1040
1041 self.figfile = None
1041 self.figfile = None
1042
1042
1043 def getSubplots(self):
1043 def getSubplots(self):
1044
1044
1045 ncol = 1
1045 ncol = 1
1046 nrow = self.nplots
1046 nrow = self.nplots
1047
1047
1048 return nrow, ncol
1048 return nrow, ncol
1049
1049
1050 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1050 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1051
1051
1052 self.__showprofile = showprofile
1052 self.__showprofile = showprofile
1053 self.nplots = nplots
1053 self.nplots = nplots
1054
1054
1055 ncolspan = 1
1055 ncolspan = 1
1056 colspan = 1
1056 colspan = 1
1057
1057
1058 self.createFigure(id = id,
1058 self.createFigure(id = id,
1059 wintitle = wintitle,
1059 wintitle = wintitle,
1060 widthplot = self.WIDTH + self.WIDTHPROF,
1060 widthplot = self.WIDTH + self.WIDTHPROF,
1061 heightplot = self.HEIGHT + self.HEIGHTPROF,
1061 heightplot = self.HEIGHT + self.HEIGHTPROF,
1062 show=show)
1062 show=show)
1063
1063
1064 nrow, ncol = self.getSubplots()
1064 nrow, ncol = self.getSubplots()
1065
1065
1066 counter = 0
1066 counter = 0
1067 for y in range(nrow):
1067 for y in range(nrow):
1068 if counter >= self.nplots:
1068 if counter >= self.nplots:
1069 break
1069 break
1070
1070
1071 self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1)
1071 self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1)
1072 counter += 1
1072 counter += 1
1073
1073
1074 def run(self, dataOut, id, wintitle="", channelList=None,
1074 def run(self, dataOut, id, wintitle="", channelList=None,
1075 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,
1076 zmaxVertical = None, zminVertical = None, zmaxZonal = None, zminZonal = None,
1076 zmaxVertical = None, zminVertical = None, zmaxZonal = None, zminZonal = None,
1077 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,
1078 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,
1079 server=None, folder=None, username=None, password=None,
1079 server=None, folder=None, username=None, password=None,
1080 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):
1081 """
1081 """
1082
1082
1083 Input:
1083 Input:
1084 dataOut :
1084 dataOut :
1085 id :
1085 id :
1086 wintitle :
1086 wintitle :
1087 channelList :
1087 channelList :
1088 showProfile :
1088 showProfile :
1089 xmin : None,
1089 xmin : None,
1090 xmax : None,
1090 xmax : None,
1091 ymin : None,
1091 ymin : None,
1092 ymax : None,
1092 ymax : None,
1093 zmin : None,
1093 zmin : None,
1094 zmax : None
1094 zmax : None
1095 """
1095 """
1096
1096
1097 if timerange is not None:
1097 if timerange is not None:
1098 self.timerange = timerange
1098 self.timerange = timerange
1099
1099
1100 tmin = None
1100 tmin = None
1101 tmax = None
1101 tmax = None
1102
1102
1103 x = dataOut.getTimeRange1()
1103 x = dataOut.getTimeRange1()
1104 # y = dataOut.heightList
1104 # y = dataOut.heightList
1105 y = dataOut.heightList
1105 y = dataOut.heightList
1106
1106
1107 z = dataOut.data_output
1107 z = dataOut.data_output
1108 nplots = z.shape[0] #Number of wind dimensions estimated
1108 nplots = z.shape[0] #Number of wind dimensions estimated
1109 nplotsw = nplots
1109 nplotsw = nplots
1110
1110
1111 #If there is a SNR function defined
1111 #If there is a SNR function defined
1112 if dataOut.data_SNR is not None:
1112 if dataOut.data_SNR is not None:
1113 nplots += 1
1113 nplots += 1
1114 SNR = dataOut.data_SNR
1114 SNR = dataOut.data_SNR
1115
1115
1116 if SNR_1:
1116 if SNR_1:
1117 SNR += 1
1117 SNR += 1
1118
1118
1119 SNRavg = numpy.average(SNR, axis=0)
1119 SNRavg = numpy.average(SNR, axis=0)
1120
1120
1121 SNRdB = 10*numpy.log10(SNR)
1121 SNRdB = 10*numpy.log10(SNR)
1122 SNRavgdB = 10*numpy.log10(SNRavg)
1122 SNRavgdB = 10*numpy.log10(SNRavg)
1123
1123
1124 ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0]
1124 ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0]
1125
1125
1126 for i in range(nplotsw):
1126 for i in range(nplotsw):
1127 z[i,ind] = numpy.nan
1127 z[i,ind] = numpy.nan
1128
1128
1129
1129
1130 showprofile = False
1130 showprofile = False
1131 # thisDatetime = dataOut.datatime
1131 # thisDatetime = dataOut.datatime
1132 thisDatetime = datetime.datetime.utcfromtimestamp(x[1])
1132 thisDatetime = datetime.datetime.utcfromtimestamp(x[1])
1133 title = wintitle + " EW Drifts"
1133 title = wintitle + " EW Drifts"
1134 xlabel = ""
1134 xlabel = ""
1135 ylabel = "Height (Km)"
1135 ylabel = "Height (Km)"
1136
1136
1137 if not self.isConfig:
1137 if not self.isConfig:
1138
1138
1139 self.setup(id=id,
1139 self.setup(id=id,
1140 nplots=nplots,
1140 nplots=nplots,
1141 wintitle=wintitle,
1141 wintitle=wintitle,
1142 showprofile=showprofile,
1142 showprofile=showprofile,
1143 show=show)
1143 show=show)
1144
1144
1145 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1145 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1146
1146
1147 if ymin == None: ymin = numpy.nanmin(y)
1147 if ymin == None: ymin = numpy.nanmin(y)
1148 if ymax == None: ymax = numpy.nanmax(y)
1148 if ymax == None: ymax = numpy.nanmax(y)
1149
1149
1150 if zmaxZonal == None: zmaxZonal = numpy.nanmax(abs(z[0,:]))
1150 if zmaxZonal == None: zmaxZonal = numpy.nanmax(abs(z[0,:]))
1151 if zminZonal == None: zminZonal = -zmaxZonal
1151 if zminZonal == None: zminZonal = -zmaxZonal
1152 if zmaxVertical == None: zmaxVertical = numpy.nanmax(abs(z[1,:]))
1152 if zmaxVertical == None: zmaxVertical = numpy.nanmax(abs(z[1,:]))
1153 if zminVertical == None: zminVertical = -zmaxVertical
1153 if zminVertical == None: zminVertical = -zmaxVertical
1154
1154
1155 if dataOut.data_SNR is not None:
1155 if dataOut.data_SNR is not None:
1156 if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB)
1156 if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB)
1157 if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB)
1157 if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB)
1158
1158
1159 self.FTP_WEI = ftp_wei
1159 self.FTP_WEI = ftp_wei
1160 self.EXP_CODE = exp_code
1160 self.EXP_CODE = exp_code
1161 self.SUB_EXP_CODE = sub_exp_code
1161 self.SUB_EXP_CODE = sub_exp_code
1162 self.PLOT_POS = plot_pos
1162 self.PLOT_POS = plot_pos
1163
1163
1164 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1164 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1165 self.isConfig = True
1165 self.isConfig = True
1166
1166
1167
1167
1168 self.setWinTitle(title)
1168 self.setWinTitle(title)
1169
1169
1170 if ((self.xmax - x[1]) < (x[1]-x[0])):
1170 if ((self.xmax - x[1]) < (x[1]-x[0])):
1171 x[1] = self.xmax
1171 x[1] = self.xmax
1172
1172
1173 strWind = ['Zonal','Vertical']
1173 strWind = ['Zonal','Vertical']
1174 strCb = 'Velocity (m/s)'
1174 strCb = 'Velocity (m/s)'
1175 zmaxVector = [zmaxZonal, zmaxVertical]
1175 zmaxVector = [zmaxZonal, zmaxVertical]
1176 zminVector = [zminZonal, zminVertical]
1176 zminVector = [zminZonal, zminVertical]
1177
1177
1178 for i in range(nplotsw):
1178 for i in range(nplotsw):
1179
1179
1180 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"))
1181 axes = self.axesList[i*self.__nsubplots]
1181 axes = self.axesList[i*self.__nsubplots]
1182
1182
1183 z1 = z[i,:].reshape((1,-1))
1183 z1 = z[i,:].reshape((1,-1))
1184
1184
1185 axes.pcolorbuffer(x, y, z1,
1185 axes.pcolorbuffer(x, y, z1,
1186 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],
1187 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1187 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1188 ticksize=9, cblabel=strCb, cbsize="1%", colormap="RdBu_r")
1188 ticksize=9, cblabel=strCb, cbsize="1%", colormap="RdBu_r")
1189
1189
1190 if dataOut.data_SNR is not None:
1190 if dataOut.data_SNR is not None:
1191 i += 1
1191 i += 1
1192 if SNR_1:
1192 if SNR_1:
1193 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"))
1194 else:
1194 else:
1195 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"))
1196 axes = self.axesList[i*self.__nsubplots]
1196 axes = self.axesList[i*self.__nsubplots]
1197 SNRavgdB = SNRavgdB.reshape((1,-1))
1197 SNRavgdB = SNRavgdB.reshape((1,-1))
1198
1198
1199 axes.pcolorbuffer(x, y, SNRavgdB,
1199 axes.pcolorbuffer(x, y, SNRavgdB,
1200 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,
1201 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1201 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1202 ticksize=9, cblabel='', cbsize="1%", colormap="jet")
1202 ticksize=9, cblabel='', cbsize="1%", colormap="jet")
1203
1203
1204 self.draw()
1204 self.draw()
1205
1205
1206 if x[1] >= self.axesList[0].xmax:
1206 if x[1] >= self.axesList[0].xmax:
1207 self.counter_imagwr = wr_period
1207 self.counter_imagwr = wr_period
1208 self.isConfig = False
1208 self.isConfig = False
1209 self.figfile = None
1209 self.figfile = None
1210
1210
1211
1211
1212
1212
1213
1213
1214 class PhasePlot(Figure):
1214 class PhasePlot(Figure):
1215
1215
1216 __isConfig = None
1216 __isConfig = None
1217 __nsubplots = None
1217 __nsubplots = None
1218
1218
1219 PREFIX = 'mphase'
1219 PREFIX = 'mphase'
1220
1220
1221 def __init__(self):
1221 def __init__(self):
1222
1222
1223 self.timerange = 24*60*60
1223 self.timerange = 24*60*60
1224 self.isConfig = False
1224 self.isConfig = False
1225 self.__nsubplots = 1
1225 self.__nsubplots = 1
1226 self.counter_imagwr = 0
1226 self.counter_imagwr = 0
1227 self.WIDTH = 600
1227 self.WIDTH = 600
1228 self.HEIGHT = 300
1228 self.HEIGHT = 300
1229 self.WIDTHPROF = 120
1229 self.WIDTHPROF = 120
1230 self.HEIGHTPROF = 0
1230 self.HEIGHTPROF = 0
1231 self.xdata = None
1231 self.xdata = None
1232 self.ydata = None
1232 self.ydata = None
1233
1233
1234 self.PLOT_CODE = MPHASE_CODE
1234 self.PLOT_CODE = MPHASE_CODE
1235
1235
1236 self.FTP_WEI = None
1236 self.FTP_WEI = None
1237 self.EXP_CODE = None
1237 self.EXP_CODE = None
1238 self.SUB_EXP_CODE = None
1238 self.SUB_EXP_CODE = None
1239 self.PLOT_POS = None
1239 self.PLOT_POS = None
1240
1240
1241
1241
1242 self.filename_phase = None
1242 self.filename_phase = None
1243
1243
1244 self.figfile = None
1244 self.figfile = None
1245
1245
1246 def getSubplots(self):
1246 def getSubplots(self):
1247
1247
1248 ncol = 1
1248 ncol = 1
1249 nrow = 1
1249 nrow = 1
1250
1250
1251 return nrow, ncol
1251 return nrow, ncol
1252
1252
1253 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1253 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1254
1254
1255 self.__showprofile = showprofile
1255 self.__showprofile = showprofile
1256 self.nplots = nplots
1256 self.nplots = nplots
1257
1257
1258 ncolspan = 7
1258 ncolspan = 7
1259 colspan = 6
1259 colspan = 6
1260 self.__nsubplots = 2
1260 self.__nsubplots = 2
1261
1261
1262 self.createFigure(id = id,
1262 self.createFigure(id = id,
1263 wintitle = wintitle,
1263 wintitle = wintitle,
1264 widthplot = self.WIDTH+self.WIDTHPROF,
1264 widthplot = self.WIDTH+self.WIDTHPROF,
1265 heightplot = self.HEIGHT+self.HEIGHTPROF,
1265 heightplot = self.HEIGHT+self.HEIGHTPROF,
1266 show=show)
1266 show=show)
1267
1267
1268 nrow, ncol = self.getSubplots()
1268 nrow, ncol = self.getSubplots()
1269
1269
1270 self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1)
1270 self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1)
1271
1271
1272
1272
1273 def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True',
1273 def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True',
1274 xmin=None, xmax=None, ymin=None, ymax=None,
1274 xmin=None, xmax=None, ymin=None, ymax=None,
1275 timerange=None,
1275 timerange=None,
1276 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,
1277 server=None, folder=None, username=None, password=None,
1277 server=None, folder=None, username=None, password=None,
1278 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):
1279
1279
1280
1280
1281 tmin = None
1281 tmin = None
1282 tmax = None
1282 tmax = None
1283 x = dataOut.getTimeRange1()
1283 x = dataOut.getTimeRange1()
1284 y = dataOut.getHeiRange()
1284 y = dataOut.getHeiRange()
1285
1285
1286
1286
1287 #thisDatetime = dataOut.datatime
1287 #thisDatetime = dataOut.datatime
1288 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1])
1288 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1])
1289 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"))
1290 xlabel = "Local Time"
1290 xlabel = "Local Time"
1291 ylabel = "Phase"
1291 ylabel = "Phase"
1292
1292
1293
1293
1294 #phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList)))
1294 #phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList)))
1295 phase_beacon = dataOut.data_output
1295 phase_beacon = dataOut.data_output
1296 update_figfile = False
1296 update_figfile = False
1297
1297
1298 if not self.isConfig:
1298 if not self.isConfig:
1299
1299
1300 self.nplots = phase_beacon.size
1300 self.nplots = phase_beacon.size
1301
1301
1302 self.setup(id=id,
1302 self.setup(id=id,
1303 nplots=self.nplots,
1303 nplots=self.nplots,
1304 wintitle=wintitle,
1304 wintitle=wintitle,
1305 showprofile=showprofile,
1305 showprofile=showprofile,
1306 show=show)
1306 show=show)
1307
1307
1308 if timerange is not None:
1308 if timerange is not None:
1309 self.timerange = timerange
1309 self.timerange = timerange
1310
1310
1311 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1311 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1312
1312
1313 if ymin == None: ymin = numpy.nanmin(phase_beacon) - 10.0
1313 if ymin == None: ymin = numpy.nanmin(phase_beacon) - 10.0
1314 if ymax == None: ymax = numpy.nanmax(phase_beacon) + 10.0
1314 if ymax == None: ymax = numpy.nanmax(phase_beacon) + 10.0
1315
1315
1316 self.FTP_WEI = ftp_wei
1316 self.FTP_WEI = ftp_wei
1317 self.EXP_CODE = exp_code
1317 self.EXP_CODE = exp_code
1318 self.SUB_EXP_CODE = sub_exp_code
1318 self.SUB_EXP_CODE = sub_exp_code
1319 self.PLOT_POS = plot_pos
1319 self.PLOT_POS = plot_pos
1320
1320
1321 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1321 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1322 self.isConfig = True
1322 self.isConfig = True
1323 self.figfile = figfile
1323 self.figfile = figfile
1324 self.xdata = numpy.array([])
1324 self.xdata = numpy.array([])
1325 self.ydata = numpy.array([])
1325 self.ydata = numpy.array([])
1326
1326
1327 #open file beacon phase
1327 #open file beacon phase
1328 path = '%s%03d' %(self.PREFIX, self.id)
1328 path = '%s%03d' %(self.PREFIX, self.id)
1329 beacon_file = os.path.join(path,'%s.txt'%self.name)
1329 beacon_file = os.path.join(path,'%s.txt'%self.name)
1330 self.filename_phase = os.path.join(figpath,beacon_file)
1330 self.filename_phase = os.path.join(figpath,beacon_file)
1331 update_figfile = True
1331 update_figfile = True
1332
1332
1333
1333
1334 #store data beacon phase
1334 #store data beacon phase
1335 #self.save_data(self.filename_phase, phase_beacon, thisDatetime)
1335 #self.save_data(self.filename_phase, phase_beacon, thisDatetime)
1336
1336
1337 self.setWinTitle(title)
1337 self.setWinTitle(title)
1338
1338
1339
1339
1340 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"))
1341
1341
1342 legendlabels = ["phase %d"%(chan) for chan in numpy.arange(self.nplots)]
1342 legendlabels = ["phase %d"%(chan) for chan in numpy.arange(self.nplots)]
1343
1343
1344 axes = self.axesList[0]
1344 axes = self.axesList[0]
1345
1345
1346 self.xdata = numpy.hstack((self.xdata, x[0:1]))
1346 self.xdata = numpy.hstack((self.xdata, x[0:1]))
1347
1347
1348 if len(self.ydata)==0:
1348 if len(self.ydata)==0:
1349 self.ydata = phase_beacon.reshape(-1,1)
1349 self.ydata = phase_beacon.reshape(-1,1)
1350 else:
1350 else:
1351 self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1)))
1351 self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1)))
1352
1352
1353
1353
1354 axes.pmultilineyaxis(x=self.xdata, y=self.ydata,
1354 axes.pmultilineyaxis(x=self.xdata, y=self.ydata,
1355 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax,
1355 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax,
1356 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",
1357 XAxisAsTime=True, grid='both'
1357 XAxisAsTime=True, grid='both'
1358 )
1358 )
1359
1359
1360 self.draw()
1360 self.draw()
1361
1361
1362 if dataOut.ltctime >= self.xmax:
1362 if dataOut.ltctime >= self.xmax:
1363 self.counter_imagwr = wr_period
1363 self.counter_imagwr = wr_period
1364 self.isConfig = False
1364 self.isConfig = False
1365 update_figfile = True
1365 update_figfile = True
1366
1366
1367 self.save(figpath=figpath,
1367 self.save(figpath=figpath,
1368 figfile=figfile,
1368 figfile=figfile,
1369 save=save,
1369 save=save,
1370 ftp=ftp,
1370 ftp=ftp,
1371 wr_period=wr_period,
1371 wr_period=wr_period,
1372 thisDatetime=thisDatetime,
1372 thisDatetime=thisDatetime,
1373 update_figfile=update_figfile)
1373 update_figfile=update_figfile)
General Comments 0
You need to be logged in to leave comments. Login now