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