##// END OF EJS Templates
parametrs plotting: SNR and DOP arguments have been added
Miguel Valdez -
r588:c1c257c97d52
parent child
Show More
@@ -1,1148 +1,1164
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]+1, noisedB[i], str_datetime)
162 title = "Channel %d: %4.2fdB: %s" %(dataOut.channelList[i]+1, 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 = 'prm'
201 PREFIX = 'prm'
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 = SKYMAP_CODE
216 self.PLOT_CODE = SKYMAP_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
272 arrayParameters = dataOut.data_param
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
327
328 class WindProfilerPlot(Figure):
328 class WindProfilerPlot(Figure):
329
329
330 __isConfig = None
330 __isConfig = None
331 __nsubplots = None
331 __nsubplots = None
332
332
333 WIDTHPROF = None
333 WIDTHPROF = None
334 HEIGHTPROF = None
334 HEIGHTPROF = None
335 PREFIX = 'wind'
335 PREFIX = 'wind'
336
336
337 def __init__(self):
337 def __init__(self):
338
338
339 self.timerange = 2*60*60
339 self.timerange = 2*60*60
340 self.__isConfig = False
340 self.__isConfig = False
341 self.__nsubplots = 1
341 self.__nsubplots = 1
342
342
343 self.WIDTH = 800
343 self.WIDTH = 800
344 self.HEIGHT = 150
344 self.HEIGHT = 150
345 self.WIDTHPROF = 120
345 self.WIDTHPROF = 120
346 self.HEIGHTPROF = 0
346 self.HEIGHTPROF = 0
347 self.counter_imagwr = 0
347 self.counter_imagwr = 0
348
348
349 self.PLOT_CODE = WIND_CODE
349 self.PLOT_CODE = WIND_CODE
350
350
351 self.FTP_WEI = None
351 self.FTP_WEI = None
352 self.EXP_CODE = None
352 self.EXP_CODE = None
353 self.SUB_EXP_CODE = None
353 self.SUB_EXP_CODE = None
354 self.PLOT_POS = None
354 self.PLOT_POS = None
355 self.tmin = None
355 self.tmin = None
356 self.tmax = None
356 self.tmax = None
357
357
358 self.xmin = None
358 self.xmin = None
359 self.xmax = None
359 self.xmax = None
360
360
361 self.figfile = None
361 self.figfile = None
362
362
363 def getSubplots(self):
363 def getSubplots(self):
364
364
365 ncol = 1
365 ncol = 1
366 nrow = self.nplots
366 nrow = self.nplots
367
367
368 return nrow, ncol
368 return nrow, ncol
369
369
370 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
370 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
371
371
372 self.__showprofile = showprofile
372 self.__showprofile = showprofile
373 self.nplots = nplots
373 self.nplots = nplots
374
374
375 ncolspan = 1
375 ncolspan = 1
376 colspan = 1
376 colspan = 1
377
377
378 self.createFigure(id = id,
378 self.createFigure(id = id,
379 wintitle = wintitle,
379 wintitle = wintitle,
380 widthplot = self.WIDTH + self.WIDTHPROF,
380 widthplot = self.WIDTH + self.WIDTHPROF,
381 heightplot = self.HEIGHT + self.HEIGHTPROF,
381 heightplot = self.HEIGHT + self.HEIGHTPROF,
382 show=show)
382 show=show)
383
383
384 nrow, ncol = self.getSubplots()
384 nrow, ncol = self.getSubplots()
385
385
386 counter = 0
386 counter = 0
387 for y in range(nrow):
387 for y in range(nrow):
388 if counter >= self.nplots:
388 if counter >= self.nplots:
389 break
389 break
390
390
391 self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1)
391 self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1)
392 counter += 1
392 counter += 1
393
393
394 def run(self, dataOut, id, wintitle="", channelList=None,
394 def run(self, dataOut, id, wintitle="", channelList=None,
395 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
395 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
396 zmax_ver = None, zmin_ver = None, SNRmin = None, SNRmax = None,
396 zmax_ver = None, zmin_ver = None, SNRmin = None, SNRmax = None,
397 timerange=None, SNRthresh = None,
397 timerange=None, SNRthresh = None,
398 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
398 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
399 server=None, folder=None, username=None, password=None,
399 server=None, folder=None, username=None, password=None,
400 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
400 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
401 """
401 """
402
402
403 Input:
403 Input:
404 dataOut :
404 dataOut :
405 id :
405 id :
406 wintitle :
406 wintitle :
407 channelList :
407 channelList :
408 showProfile :
408 showProfile :
409 xmin : None,
409 xmin : None,
410 xmax : None,
410 xmax : None,
411 ymin : None,
411 ymin : None,
412 ymax : None,
412 ymax : None,
413 zmin : None,
413 zmin : None,
414 zmax : None
414 zmax : None
415 """
415 """
416
416
417 if channelList == None:
417 if channelList == None:
418 channelIndexList = dataOut.channelIndexList
418 channelIndexList = dataOut.channelIndexList
419 else:
419 else:
420 channelIndexList = []
420 channelIndexList = []
421 for channel in channelList:
421 for channel in channelList:
422 if channel not in dataOut.channelList:
422 if channel not in dataOut.channelList:
423 raise ValueError, "Channel %d is not in dataOut.channelList"
423 raise ValueError, "Channel %d is not in dataOut.channelList"
424 channelIndexList.append(dataOut.channelList.index(channel))
424 channelIndexList.append(dataOut.channelList.index(channel))
425
425
426 if timerange != None:
426 if timerange != None:
427 self.timerange = timerange
427 self.timerange = timerange
428
428
429 tmin = None
429 tmin = None
430 tmax = None
430 tmax = None
431
431
432 x = dataOut.getTimeRange1()
432 x = dataOut.getTimeRange1()
433 # y = dataOut.heightList
433 # y = dataOut.heightList
434 y = dataOut.heightList
434 y = dataOut.heightList
435
435
436 z = dataOut.data_output.copy()
436 z = dataOut.data_output.copy()
437 nplots = z.shape[0] #Number of wind dimensions estimated
437 nplots = z.shape[0] #Number of wind dimensions estimated
438 nplotsw = nplots
438 nplotsw = nplots
439
439
440 #If there is a SNR function defined
440 #If there is a SNR function defined
441 if dataOut.data_SNR != None:
441 if dataOut.data_SNR != None:
442 nplots += 1
442 nplots += 1
443 SNR = dataOut.data_SNR
443 SNR = dataOut.data_SNR
444 SNRavg = numpy.average(SNR, axis=0)
444 SNRavg = numpy.average(SNR, axis=0)
445
445
446 SNRdB = 10*numpy.log10(SNR)
446 SNRdB = 10*numpy.log10(SNR)
447 SNRavgdB = 10*numpy.log10(SNRavg)
447 SNRavgdB = 10*numpy.log10(SNRavg)
448
448
449 if SNRthresh == None: SNRthresh = -5.0
449 if SNRthresh == None: SNRthresh = -5.0
450 ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0]
450 ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0]
451
451
452 for i in range(nplotsw):
452 for i in range(nplotsw):
453 z[i,ind] = numpy.nan
453 z[i,ind] = numpy.nan
454
454
455
455
456 showprofile = False
456 showprofile = False
457 # thisDatetime = dataOut.datatime
457 # thisDatetime = dataOut.datatime
458 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
458 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
459 title = wintitle + "Wind"
459 title = wintitle + "Wind"
460 xlabel = ""
460 xlabel = ""
461 ylabel = "Range (Km)"
461 ylabel = "Range (Km)"
462
462
463 if not self.__isConfig:
463 if not self.__isConfig:
464
464
465 self.setup(id=id,
465 self.setup(id=id,
466 nplots=nplots,
466 nplots=nplots,
467 wintitle=wintitle,
467 wintitle=wintitle,
468 showprofile=showprofile,
468 showprofile=showprofile,
469 show=show)
469 show=show)
470
470
471 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
471 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
472
472
473 if ymin == None: ymin = numpy.nanmin(y)
473 if ymin == None: ymin = numpy.nanmin(y)
474 if ymax == None: ymax = numpy.nanmax(y)
474 if ymax == None: ymax = numpy.nanmax(y)
475
475
476 if zmax == None: zmax = numpy.nanmax(abs(z[range(2),:]))
476 if zmax == None: zmax = numpy.nanmax(abs(z[range(2),:]))
477 #if numpy.isnan(zmax): zmax = 50
477 #if numpy.isnan(zmax): zmax = 50
478 if zmin == None: zmin = -zmax
478 if zmin == None: zmin = -zmax
479
479
480 if nplotsw == 3:
480 if nplotsw == 3:
481 if zmax_ver == None: zmax_ver = numpy.nanmax(abs(z[2,:]))
481 if zmax_ver == None: zmax_ver = numpy.nanmax(abs(z[2,:]))
482 if zmin_ver == None: zmin_ver = -zmax_ver
482 if zmin_ver == None: zmin_ver = -zmax_ver
483
483
484 if dataOut.data_SNR != None:
484 if dataOut.data_SNR != None:
485 if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB)
485 if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB)
486 if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB)
486 if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB)
487
487
488 self.FTP_WEI = ftp_wei
488 self.FTP_WEI = ftp_wei
489 self.EXP_CODE = exp_code
489 self.EXP_CODE = exp_code
490 self.SUB_EXP_CODE = sub_exp_code
490 self.SUB_EXP_CODE = sub_exp_code
491 self.PLOT_POS = plot_pos
491 self.PLOT_POS = plot_pos
492
492
493 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
493 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
494 self.__isConfig = True
494 self.__isConfig = True
495
495
496
496
497 self.setWinTitle(title)
497 self.setWinTitle(title)
498
498
499 if ((self.xmax - x[1]) < (x[1]-x[0])):
499 if ((self.xmax - x[1]) < (x[1]-x[0])):
500 x[1] = self.xmax
500 x[1] = self.xmax
501
501
502 strWind = ['Zonal', 'Meridional', 'Vertical']
502 strWind = ['Zonal', 'Meridional', 'Vertical']
503 strCb = ['Velocity (m/s)','Velocity (m/s)','Velocity (cm/s)']
503 strCb = ['Velocity (m/s)','Velocity (m/s)','Velocity (cm/s)']
504 zmaxVector = [zmax, zmax, zmax_ver]
504 zmaxVector = [zmax, zmax, zmax_ver]
505 zminVector = [zmin, zmin, zmin_ver]
505 zminVector = [zmin, zmin, zmin_ver]
506 windFactor = [1,1,100]
506 windFactor = [1,1,100]
507
507
508 for i in range(nplotsw):
508 for i in range(nplotsw):
509
509
510 title = "%s Wind: %s" %(strWind[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
510 title = "%s Wind: %s" %(strWind[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
511 axes = self.axesList[i*self.__nsubplots]
511 axes = self.axesList[i*self.__nsubplots]
512
512
513 z1 = z[i,:].reshape((1,-1))*windFactor[i]
513 z1 = z[i,:].reshape((1,-1))*windFactor[i]
514
514
515 axes.pcolorbuffer(x, y, z1,
515 axes.pcolorbuffer(x, y, z1,
516 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zminVector[i], zmax=zmaxVector[i],
516 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zminVector[i], zmax=zmaxVector[i],
517 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
517 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
518 ticksize=9, cblabel=strCb[i], cbsize="1%", colormap="RdBu_r" )
518 ticksize=9, cblabel=strCb[i], cbsize="1%", colormap="RdBu_r" )
519
519
520 if dataOut.data_SNR != None:
520 if dataOut.data_SNR != None:
521 i += 1
521 i += 1
522 title = "Signal Noise Ratio (SNR): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
522 title = "Signal Noise Ratio (SNR): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
523 axes = self.axesList[i*self.__nsubplots]
523 axes = self.axesList[i*self.__nsubplots]
524
524
525 SNRavgdB = SNRavgdB.reshape((1,-1))
525 SNRavgdB = SNRavgdB.reshape((1,-1))
526
526
527 axes.pcolorbuffer(x, y, SNRavgdB,
527 axes.pcolorbuffer(x, y, SNRavgdB,
528 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
528 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
529 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
529 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
530 ticksize=9, cblabel='', cbsize="1%", colormap="jet")
530 ticksize=9, cblabel='', cbsize="1%", colormap="jet")
531
531
532 self.draw()
532 self.draw()
533
533
534 if x[1] >= self.axesList[0].xmax:
534 if x[1] >= self.axesList[0].xmax:
535 self.counter_imagwr = wr_period
535 self.counter_imagwr = wr_period
536 self.__isConfig = False
536 self.__isConfig = False
537 self.figfile = None
537 self.figfile = None
538
538
539 self.save(figpath=figpath,
539 self.save(figpath=figpath,
540 figfile=figfile,
540 figfile=figfile,
541 save=save,
541 save=save,
542 ftp=ftp,
542 ftp=ftp,
543 wr_period=wr_period,
543 wr_period=wr_period,
544 thisDatetime=thisDatetime,
544 thisDatetime=thisDatetime,
545 update_figfile=False)
545 update_figfile=False)
546
546
547
547
548 class ParametersPlot(Figure):
548 class ParametersPlot(Figure):
549
549
550 __isConfig = None
550 __isConfig = None
551 __nsubplots = None
551 __nsubplots = None
552
552
553 WIDTHPROF = None
553 WIDTHPROF = None
554 HEIGHTPROF = None
554 HEIGHTPROF = None
555 PREFIX = 'prm'
555 PREFIX = 'prm'
556
556
557 def __init__(self):
557 def __init__(self):
558
558
559 self.timerange = 2*60*60
559 self.timerange = 2*60*60
560 self.__isConfig = False
560 self.__isConfig = False
561 self.__nsubplots = 1
561 self.__nsubplots = 1
562
562
563 self.WIDTH = 800
563 self.WIDTH = 800
564 self.HEIGHT = 150
564 self.HEIGHT = 150
565 self.WIDTHPROF = 120
565 self.WIDTHPROF = 120
566 self.HEIGHTPROF = 0
566 self.HEIGHTPROF = 0
567 self.counter_imagwr = 0
567 self.counter_imagwr = 0
568
568
569 self.PLOT_CODE = PARMS_CODE
569 self.PLOT_CODE = PARMS_CODE
570
570
571 self.FTP_WEI = None
571 self.FTP_WEI = None
572 self.EXP_CODE = None
572 self.EXP_CODE = None
573 self.SUB_EXP_CODE = None
573 self.SUB_EXP_CODE = None
574 self.PLOT_POS = None
574 self.PLOT_POS = None
575 self.tmin = None
575 self.tmin = None
576 self.tmax = None
576 self.tmax = None
577
577
578 self.xmin = None
578 self.xmin = None
579 self.xmax = None
579 self.xmax = None
580
580
581 self.figfile = None
581 self.figfile = None
582
582
583 def getSubplots(self):
583 def getSubplots(self):
584
584
585 ncol = 1
585 ncol = 1
586 nrow = self.nplots
586 nrow = self.nplots
587
587
588 return nrow, ncol
588 return nrow, ncol
589
589
590 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
590 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
591
591
592 self.__showprofile = showprofile
592 self.__showprofile = showprofile
593 self.nplots = nplots
593 self.nplots = nplots
594
594
595 ncolspan = 1
595 ncolspan = 1
596 colspan = 1
596 colspan = 1
597
597
598 self.createFigure(id = id,
598 self.createFigure(id = id,
599 wintitle = wintitle,
599 wintitle = wintitle,
600 widthplot = self.WIDTH + self.WIDTHPROF,
600 widthplot = self.WIDTH + self.WIDTHPROF,
601 heightplot = self.HEIGHT + self.HEIGHTPROF,
601 heightplot = self.HEIGHT + self.HEIGHTPROF,
602 show=show)
602 show=show)
603
603
604 nrow, ncol = self.getSubplots()
604 nrow, ncol = self.getSubplots()
605
605
606 counter = 0
606 counter = 0
607 for y in range(nrow):
607 for y in range(nrow):
608 for x in range(ncol):
608 for x in range(ncol):
609
609
610 if counter >= self.nplots:
610 if counter >= self.nplots:
611 break
611 break
612
612
613 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
613 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
614
614
615 if showprofile:
615 if showprofile:
616 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
616 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
617
617
618 counter += 1
618 counter += 1
619
619
620 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=False,
620 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=False,
621 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,timerange=None,
621 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,timerange=None,
622 parameterIndex = None, onlyPositive = False,
622 parameterIndex = None, onlyPositive = False,
623 SNRthresh = -numpy.inf, SNR = True, SNRmin = None, SNRmax = None,
623 SNRthresh = -numpy.inf, SNR = True, SNRmin = None, SNRmax = None,
624 DOP = True,
624 zlabel = "", parameterName = "", parameterObject = "data_param",
625 zlabel = "", parameterName = "", parameterObject = "data_param",
625 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
626 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
626 server=None, folder=None, username=None, password=None,
627 server=None, folder=None, username=None, password=None,
627 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
628 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
628
629
629 """
630 """
630
631
631 Input:
632 Input:
632 dataOut :
633 dataOut :
633 id :
634 id :
634 wintitle :
635 wintitle :
635 channelList :
636 channelList :
636 showProfile :
637 showProfile :
637 xmin : None,
638 xmin : None,
638 xmax : None,
639 xmax : None,
639 ymin : None,
640 ymin : None,
640 ymax : None,
641 ymax : None,
641 zmin : None,
642 zmin : None,
642 zmax : None
643 zmax : None
643 """
644 """
644
645
645 data_param = getattr(dataOut, parameterObject)
646 data_param = getattr(dataOut, parameterObject)
646
647
647 if channelList == None:
648 if channelList == None:
648 channelIndexList = numpy.arange(data_param.shape[0])
649 channelIndexList = numpy.arange(data_param.shape[0])
649 else:
650 else:
650 channelIndexList = numpy.array(channelList)
651 channelIndexList = numpy.array(channelList)
651
652
652 nchan = len(channelIndexList) #Number of channels being plotted
653 nchan = len(channelIndexList) #Number of channels being plotted
653
654
655 if nchan < 1:
656 return
657
658 nGraphsByChannel = 0
659
660 if SNR:
661 nGraphsByChannel += 1
662 if DOP:
663 nGraphsByChannel += 1
664
665 if nGraphsByChannel < 1:
666 return
667
668 nplots = nGraphsByChannel*nchan
669
654 if timerange != None:
670 if timerange != None:
655 self.timerange = timerange
671 self.timerange = timerange
656
672
657 #tmin = None
673 #tmin = None
658 #tmax = None
674 #tmax = None
659 if parameterIndex == None:
675 if parameterIndex == None:
660 parameterIndex = 1
676 parameterIndex = 1
677
661 x = dataOut.getTimeRange1()
678 x = dataOut.getTimeRange1()
662 y = dataOut.heightList
679 y = dataOut.heightList
663 z = data_param[channelIndexList,parameterIndex,:].copy()
680 z = data_param[channelIndexList,parameterIndex,:].copy()
664
681
665 zRange = dataOut.abscissaList
682 zRange = dataOut.abscissaList
666 nplots = z.shape[0] #Number of wind dimensions estimated
683 # nChannels = z.shape[0] #Number of wind dimensions estimated
667 # thisDatetime = dataOut.datatime
684 # thisDatetime = dataOut.datatime
668
685
669 if dataOut.data_SNR != None:
686 if dataOut.data_SNR != None:
670 SNRarray = dataOut.data_SNR[channelIndexList,:]
687 SNRarray = dataOut.data_SNR[channelIndexList,:]
671 SNRdB = 10*numpy.log10(SNRarray)
688 SNRdB = 10*numpy.log10(SNRarray)
672 # SNRavgdB = 10*numpy.log10(SNRavg)
689 # SNRavgdB = 10*numpy.log10(SNRavg)
673 ind = numpy.where(SNRdB < 10**(SNRthresh/10))
690 ind = numpy.where(SNRdB < 10**(SNRthresh/10))
674 z[ind] = numpy.nan
691 z[ind] = numpy.nan
675
692
676 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
693 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
677 title = wintitle + " Parameters Plot" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
694 title = wintitle + " Parameters Plot" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
678 xlabel = ""
695 xlabel = ""
679 ylabel = "Range (Km)"
696 ylabel = "Range (Km)"
680
697
681 if SNR: nplots = 2*nplots
682
683 if onlyPositive:
698 if onlyPositive:
684 colormap = "jet"
699 colormap = "jet"
685 zmin = 0
700 zmin = 0
686 else: colormap = "RdBu_r"
701 else: colormap = "RdBu_r"
687
702
688 if not self.__isConfig:
703 if not self.__isConfig:
689
704
690 self.setup(id=id,
705 self.setup(id=id,
691 nplots=nplots,
706 nplots=nplots,
692 wintitle=wintitle,
707 wintitle=wintitle,
693 showprofile=showprofile,
708 showprofile=showprofile,
694 show=show)
709 show=show)
695
710
696 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
711 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
697
712
698 if ymin == None: ymin = numpy.nanmin(y)
713 if ymin == None: ymin = numpy.nanmin(y)
699 if ymax == None: ymax = numpy.nanmax(y)
714 if ymax == None: ymax = numpy.nanmax(y)
700 if zmin == None: zmin = numpy.nanmin(zRange)
715 if zmin == None: zmin = numpy.nanmin(zRange)
701 if zmax == None: zmax = numpy.nanmax(zRange)
716 if zmax == None: zmax = numpy.nanmax(zRange)
702
717
703 if SNR != None:
718 if SNR:
704 if SNRmin == None: SNRmin = numpy.nanmin(SNRdB)
719 if SNRmin == None: SNRmin = numpy.nanmin(SNRdB)
705 if SNRmax == None: SNRmax = numpy.nanmax(SNRdB)
720 if SNRmax == None: SNRmax = numpy.nanmax(SNRdB)
706
721
707 self.FTP_WEI = ftp_wei
722 self.FTP_WEI = ftp_wei
708 self.EXP_CODE = exp_code
723 self.EXP_CODE = exp_code
709 self.SUB_EXP_CODE = sub_exp_code
724 self.SUB_EXP_CODE = sub_exp_code
710 self.PLOT_POS = plot_pos
725 self.PLOT_POS = plot_pos
711
726
712 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
727 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
713 self.__isConfig = True
728 self.__isConfig = True
714 self.figfile = figfile
729 self.figfile = figfile
715
730
716 self.setWinTitle(title)
731 self.setWinTitle(title)
717
732
718 if ((self.xmax - x[1]) < (x[1]-x[0])):
733 if ((self.xmax - x[1]) < (x[1]-x[0])):
719 x[1] = self.xmax
734 x[1] = self.xmax
720
735
721 for i in range(nchan):
736 for i in range(nchan):
722 if SNR: j = 2*i
723 else: j = i
724
737
725 title = "%s Channel %d: %s" %(parameterName, channelIndexList[i]+1, thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
738 j = nGraphsByChannel*i
726
739
727 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
740 if DOP:
728 title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith)
741 title = "%s Channel %d: %s" %(parameterName, channelIndexList[i]+1, thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
729 axes = self.axesList[j*self.__nsubplots]
742
730 z1 = z[i,:].reshape((1,-1))
743 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
731 axes.pcolorbuffer(x, y, z1,
744 title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith)
732 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
745 axes = self.axesList[j]
733 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap=colormap,
746 z1 = z[i,:].reshape((1,-1))
734 ticksize=9, cblabel=zlabel, cbsize="1%")
747 axes.pcolorbuffer(x, y, z1,
748 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
749 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap=colormap,
750 ticksize=9, cblabel=zlabel, cbsize="1%")
735
751
736 if SNR:
752 if SNR:
737 title = "Channel %d Signal Noise Ratio (SNR): %s" %(channelIndexList[i]+1, thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
753 title = "Channel %d Signal Noise Ratio (SNR): %s" %(channelIndexList[i]+1, thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
738 axes = self.axesList[(j + 1)*self.__nsubplots]
754 axes = self.axesList[(j + nGraphsByChannel-1)]
739 z1 = SNRdB[i,:].reshape((1,-1))
755 z1 = SNRdB[i,:].reshape((1,-1))
740 axes.pcolorbuffer(x, y, z1,
756 axes.pcolorbuffer(x, y, z1,
741 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
757 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
742 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap="jet",
758 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap="jet",
743 ticksize=9, cblabel=zlabel, cbsize="1%")
759 ticksize=9, cblabel=zlabel, cbsize="1%")
744
760
745
761
746
762
747 self.draw()
763 self.draw()
748
764
749 if x[1] >= self.axesList[0].xmax:
765 if x[1] >= self.axesList[0].xmax:
750 self.counter_imagwr = wr_period
766 self.counter_imagwr = wr_period
751 self.__isConfig = False
767 self.__isConfig = False
752 self.figfile = None
768 self.figfile = None
753
769
754 self.save(figpath=figpath,
770 self.save(figpath=figpath,
755 figfile=figfile,
771 figfile=figfile,
756 save=save,
772 save=save,
757 ftp=ftp,
773 ftp=ftp,
758 wr_period=wr_period,
774 wr_period=wr_period,
759 thisDatetime=thisDatetime,
775 thisDatetime=thisDatetime,
760 update_figfile=False)
776 update_figfile=False)
761
777
762 class SpectralFittingPlot(Figure):
778 class SpectralFittingPlot(Figure):
763
779
764 __isConfig = None
780 __isConfig = None
765 __nsubplots = None
781 __nsubplots = None
766
782
767 WIDTHPROF = None
783 WIDTHPROF = None
768 HEIGHTPROF = None
784 HEIGHTPROF = None
769 PREFIX = 'prm'
785 PREFIX = 'prm'
770
786
771
787
772 N = None
788 N = None
773 ippSeconds = None
789 ippSeconds = None
774
790
775 def __init__(self):
791 def __init__(self):
776 self.__isConfig = False
792 self.__isConfig = False
777 self.__nsubplots = 1
793 self.__nsubplots = 1
778
794
779 self.PLOT_CODE = SPECFIT_CODE
795 self.PLOT_CODE = SPECFIT_CODE
780
796
781 self.WIDTH = 450
797 self.WIDTH = 450
782 self.HEIGHT = 250
798 self.HEIGHT = 250
783 self.WIDTHPROF = 0
799 self.WIDTHPROF = 0
784 self.HEIGHTPROF = 0
800 self.HEIGHTPROF = 0
785
801
786 def getSubplots(self):
802 def getSubplots(self):
787
803
788 ncol = int(numpy.sqrt(self.nplots)+0.9)
804 ncol = int(numpy.sqrt(self.nplots)+0.9)
789 nrow = int(self.nplots*1./ncol + 0.9)
805 nrow = int(self.nplots*1./ncol + 0.9)
790
806
791 return nrow, ncol
807 return nrow, ncol
792
808
793 def setup(self, id, nplots, wintitle, showprofile=False, show=True):
809 def setup(self, id, nplots, wintitle, showprofile=False, show=True):
794
810
795 showprofile = False
811 showprofile = False
796 self.__showprofile = showprofile
812 self.__showprofile = showprofile
797 self.nplots = nplots
813 self.nplots = nplots
798
814
799 ncolspan = 5
815 ncolspan = 5
800 colspan = 4
816 colspan = 4
801 if showprofile:
817 if showprofile:
802 ncolspan = 5
818 ncolspan = 5
803 colspan = 4
819 colspan = 4
804 self.__nsubplots = 2
820 self.__nsubplots = 2
805
821
806 self.createFigure(id = id,
822 self.createFigure(id = id,
807 wintitle = wintitle,
823 wintitle = wintitle,
808 widthplot = self.WIDTH + self.WIDTHPROF,
824 widthplot = self.WIDTH + self.WIDTHPROF,
809 heightplot = self.HEIGHT + self.HEIGHTPROF,
825 heightplot = self.HEIGHT + self.HEIGHTPROF,
810 show=show)
826 show=show)
811
827
812 nrow, ncol = self.getSubplots()
828 nrow, ncol = self.getSubplots()
813
829
814 counter = 0
830 counter = 0
815 for y in range(nrow):
831 for y in range(nrow):
816 for x in range(ncol):
832 for x in range(ncol):
817
833
818 if counter >= self.nplots:
834 if counter >= self.nplots:
819 break
835 break
820
836
821 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
837 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
822
838
823 if showprofile:
839 if showprofile:
824 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
840 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
825
841
826 counter += 1
842 counter += 1
827
843
828 def run(self, dataOut, id, cutHeight=None, fit=False, wintitle="", channelList=None, showprofile=True,
844 def run(self, dataOut, id, cutHeight=None, fit=False, wintitle="", channelList=None, showprofile=True,
829 xmin=None, xmax=None, ymin=None, ymax=None,
845 xmin=None, xmax=None, ymin=None, ymax=None,
830 save=False, figpath='./', figfile=None, show=True):
846 save=False, figpath='./', figfile=None, show=True):
831
847
832 """
848 """
833
849
834 Input:
850 Input:
835 dataOut :
851 dataOut :
836 id :
852 id :
837 wintitle :
853 wintitle :
838 channelList :
854 channelList :
839 showProfile :
855 showProfile :
840 xmin : None,
856 xmin : None,
841 xmax : None,
857 xmax : None,
842 zmin : None,
858 zmin : None,
843 zmax : None
859 zmax : None
844 """
860 """
845
861
846 if cutHeight==None:
862 if cutHeight==None:
847 h=270
863 h=270
848 heightindex = numpy.abs(cutHeight - dataOut.heightList).argmin()
864 heightindex = numpy.abs(cutHeight - dataOut.heightList).argmin()
849 cutHeight = dataOut.heightList[heightindex]
865 cutHeight = dataOut.heightList[heightindex]
850
866
851 factor = dataOut.normFactor
867 factor = dataOut.normFactor
852 x = dataOut.abscissaList[:-1]
868 x = dataOut.abscissaList[:-1]
853 #y = dataOut.getHeiRange()
869 #y = dataOut.getHeiRange()
854
870
855 z = dataOut.data_pre[:,:,heightindex]/factor
871 z = dataOut.data_pre[:,:,heightindex]/factor
856 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
872 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
857 avg = numpy.average(z, axis=1)
873 avg = numpy.average(z, axis=1)
858 listChannels = z.shape[0]
874 listChannels = z.shape[0]
859
875
860 #Reconstruct Function
876 #Reconstruct Function
861 if fit==True:
877 if fit==True:
862 groupArray = dataOut.groupList
878 groupArray = dataOut.groupList
863 listChannels = groupArray.reshape((groupArray.size))
879 listChannels = groupArray.reshape((groupArray.size))
864 listChannels.sort()
880 listChannels.sort()
865 spcFitLine = numpy.zeros(z.shape)
881 spcFitLine = numpy.zeros(z.shape)
866 constants = dataOut.constants
882 constants = dataOut.constants
867
883
868 nGroups = groupArray.shape[0]
884 nGroups = groupArray.shape[0]
869 nChannels = groupArray.shape[1]
885 nChannels = groupArray.shape[1]
870 nProfiles = z.shape[1]
886 nProfiles = z.shape[1]
871
887
872 for f in range(nGroups):
888 for f in range(nGroups):
873 groupChann = groupArray[f,:]
889 groupChann = groupArray[f,:]
874 p = dataOut.data_param[f,:,heightindex]
890 p = dataOut.data_param[f,:,heightindex]
875 # p = numpy.array([ 89.343967,0.14036615,0.17086219,18.89835291,1.58388365,1.55099167])
891 # p = numpy.array([ 89.343967,0.14036615,0.17086219,18.89835291,1.58388365,1.55099167])
876 fitLineAux = dataOut.library.modelFunction(p, constants)*nProfiles
892 fitLineAux = dataOut.library.modelFunction(p, constants)*nProfiles
877 fitLineAux = fitLineAux.reshape((nChannels,nProfiles))
893 fitLineAux = fitLineAux.reshape((nChannels,nProfiles))
878 spcFitLine[groupChann,:] = fitLineAux
894 spcFitLine[groupChann,:] = fitLineAux
879 # spcFitLine = spcFitLine/factor
895 # spcFitLine = spcFitLine/factor
880
896
881 z = z[listChannels,:]
897 z = z[listChannels,:]
882 spcFitLine = spcFitLine[listChannels,:]
898 spcFitLine = spcFitLine[listChannels,:]
883 spcFitLinedB = 10*numpy.log10(spcFitLine)
899 spcFitLinedB = 10*numpy.log10(spcFitLine)
884
900
885 zdB = 10*numpy.log10(z)
901 zdB = 10*numpy.log10(z)
886 #thisDatetime = dataOut.datatime
902 #thisDatetime = dataOut.datatime
887 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
903 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
888 title = wintitle + " Doppler Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
904 title = wintitle + " Doppler Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
889 xlabel = "Velocity (m/s)"
905 xlabel = "Velocity (m/s)"
890 ylabel = "Spectrum"
906 ylabel = "Spectrum"
891
907
892 if not self.__isConfig:
908 if not self.__isConfig:
893
909
894 nplots = listChannels.size
910 nplots = listChannels.size
895
911
896 self.setup(id=id,
912 self.setup(id=id,
897 nplots=nplots,
913 nplots=nplots,
898 wintitle=wintitle,
914 wintitle=wintitle,
899 showprofile=showprofile,
915 showprofile=showprofile,
900 show=show)
916 show=show)
901
917
902 if xmin == None: xmin = numpy.nanmin(x)
918 if xmin == None: xmin = numpy.nanmin(x)
903 if xmax == None: xmax = numpy.nanmax(x)
919 if xmax == None: xmax = numpy.nanmax(x)
904 if ymin == None: ymin = numpy.nanmin(zdB)
920 if ymin == None: ymin = numpy.nanmin(zdB)
905 if ymax == None: ymax = numpy.nanmax(zdB)+2
921 if ymax == None: ymax = numpy.nanmax(zdB)+2
906
922
907 self.__isConfig = True
923 self.__isConfig = True
908
924
909 self.setWinTitle(title)
925 self.setWinTitle(title)
910 for i in range(self.nplots):
926 for i in range(self.nplots):
911 # title = "Channel %d: %4.2fdB" %(dataOut.channelList[i]+1, noisedB[i])
927 # title = "Channel %d: %4.2fdB" %(dataOut.channelList[i]+1, noisedB[i])
912 title = "Height %4.1f km\nChannel %d:" %(cutHeight, listChannels[i]+1)
928 title = "Height %4.1f km\nChannel %d:" %(cutHeight, listChannels[i]+1)
913 axes = self.axesList[i*self.__nsubplots]
929 axes = self.axesList[i*self.__nsubplots]
914 if fit == False:
930 if fit == False:
915 axes.pline(x, zdB[i,:],
931 axes.pline(x, zdB[i,:],
916 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
932 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
917 xlabel=xlabel, ylabel=ylabel, title=title
933 xlabel=xlabel, ylabel=ylabel, title=title
918 )
934 )
919 if fit == True:
935 if fit == True:
920 fitline=spcFitLinedB[i,:]
936 fitline=spcFitLinedB[i,:]
921 y=numpy.vstack([zdB[i,:],fitline] )
937 y=numpy.vstack([zdB[i,:],fitline] )
922 legendlabels=['Data','Fitting']
938 legendlabels=['Data','Fitting']
923 axes.pmultilineyaxis(x, y,
939 axes.pmultilineyaxis(x, y,
924 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
940 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
925 xlabel=xlabel, ylabel=ylabel, title=title,
941 xlabel=xlabel, ylabel=ylabel, title=title,
926 legendlabels=legendlabels, marker=None,
942 legendlabels=legendlabels, marker=None,
927 linestyle='solid', grid='both')
943 linestyle='solid', grid='both')
928
944
929 self.draw()
945 self.draw()
930
946
931 self.save(figpath=figpath,
947 self.save(figpath=figpath,
932 figfile=figfile,
948 figfile=figfile,
933 save=save,
949 save=save,
934 ftp=ftp,
950 ftp=ftp,
935 wr_period=wr_period,
951 wr_period=wr_period,
936 thisDatetime=thisDatetime)
952 thisDatetime=thisDatetime)
937
953
938
954
939 class EWDriftsPlot(Figure):
955 class EWDriftsPlot(Figure):
940
956
941 __isConfig = None
957 __isConfig = None
942 __nsubplots = None
958 __nsubplots = None
943
959
944 WIDTHPROF = None
960 WIDTHPROF = None
945 HEIGHTPROF = None
961 HEIGHTPROF = None
946 PREFIX = 'drift'
962 PREFIX = 'drift'
947
963
948 def __init__(self):
964 def __init__(self):
949
965
950 self.timerange = 2*60*60
966 self.timerange = 2*60*60
951 self.isConfig = False
967 self.isConfig = False
952 self.__nsubplots = 1
968 self.__nsubplots = 1
953
969
954 self.WIDTH = 800
970 self.WIDTH = 800
955 self.HEIGHT = 150
971 self.HEIGHT = 150
956 self.WIDTHPROF = 120
972 self.WIDTHPROF = 120
957 self.HEIGHTPROF = 0
973 self.HEIGHTPROF = 0
958 self.counter_imagwr = 0
974 self.counter_imagwr = 0
959
975
960 self.PLOT_CODE = EWDRIFT_CODE
976 self.PLOT_CODE = EWDRIFT_CODE
961
977
962 self.FTP_WEI = None
978 self.FTP_WEI = None
963 self.EXP_CODE = None
979 self.EXP_CODE = None
964 self.SUB_EXP_CODE = None
980 self.SUB_EXP_CODE = None
965 self.PLOT_POS = None
981 self.PLOT_POS = None
966 self.tmin = None
982 self.tmin = None
967 self.tmax = None
983 self.tmax = None
968
984
969 self.xmin = None
985 self.xmin = None
970 self.xmax = None
986 self.xmax = None
971
987
972 self.figfile = None
988 self.figfile = None
973
989
974 def getSubplots(self):
990 def getSubplots(self):
975
991
976 ncol = 1
992 ncol = 1
977 nrow = self.nplots
993 nrow = self.nplots
978
994
979 return nrow, ncol
995 return nrow, ncol
980
996
981 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
997 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
982
998
983 self.__showprofile = showprofile
999 self.__showprofile = showprofile
984 self.nplots = nplots
1000 self.nplots = nplots
985
1001
986 ncolspan = 1
1002 ncolspan = 1
987 colspan = 1
1003 colspan = 1
988
1004
989 self.createFigure(id = id,
1005 self.createFigure(id = id,
990 wintitle = wintitle,
1006 wintitle = wintitle,
991 widthplot = self.WIDTH + self.WIDTHPROF,
1007 widthplot = self.WIDTH + self.WIDTHPROF,
992 heightplot = self.HEIGHT + self.HEIGHTPROF,
1008 heightplot = self.HEIGHT + self.HEIGHTPROF,
993 show=show)
1009 show=show)
994
1010
995 nrow, ncol = self.getSubplots()
1011 nrow, ncol = self.getSubplots()
996
1012
997 counter = 0
1013 counter = 0
998 for y in range(nrow):
1014 for y in range(nrow):
999 if counter >= self.nplots:
1015 if counter >= self.nplots:
1000 break
1016 break
1001
1017
1002 self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1)
1018 self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1)
1003 counter += 1
1019 counter += 1
1004
1020
1005 def run(self, dataOut, id, wintitle="", channelList=None,
1021 def run(self, dataOut, id, wintitle="", channelList=None,
1006 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
1022 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
1007 zmaxVertical = None, zminVertical = None, zmaxZonal = None, zminZonal = None,
1023 zmaxVertical = None, zminVertical = None, zmaxZonal = None, zminZonal = None,
1008 timerange=None, SNRthresh = -numpy.inf, SNRmin = None, SNRmax = None, SNR_1 = False,
1024 timerange=None, SNRthresh = -numpy.inf, SNRmin = None, SNRmax = None, SNR_1 = False,
1009 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
1025 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
1010 server=None, folder=None, username=None, password=None,
1026 server=None, folder=None, username=None, password=None,
1011 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1027 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1012 """
1028 """
1013
1029
1014 Input:
1030 Input:
1015 dataOut :
1031 dataOut :
1016 id :
1032 id :
1017 wintitle :
1033 wintitle :
1018 channelList :
1034 channelList :
1019 showProfile :
1035 showProfile :
1020 xmin : None,
1036 xmin : None,
1021 xmax : None,
1037 xmax : None,
1022 ymin : None,
1038 ymin : None,
1023 ymax : None,
1039 ymax : None,
1024 zmin : None,
1040 zmin : None,
1025 zmax : None
1041 zmax : None
1026 """
1042 """
1027
1043
1028 if timerange != None:
1044 if timerange != None:
1029 self.timerange = timerange
1045 self.timerange = timerange
1030
1046
1031 tmin = None
1047 tmin = None
1032 tmax = None
1048 tmax = None
1033
1049
1034 x = dataOut.getTimeRange1()
1050 x = dataOut.getTimeRange1()
1035 # y = dataOut.heightList
1051 # y = dataOut.heightList
1036 y = dataOut.heightList
1052 y = dataOut.heightList
1037
1053
1038 z = dataOut.data_output
1054 z = dataOut.data_output
1039 nplots = z.shape[0] #Number of wind dimensions estimated
1055 nplots = z.shape[0] #Number of wind dimensions estimated
1040 nplotsw = nplots
1056 nplotsw = nplots
1041
1057
1042 #If there is a SNR function defined
1058 #If there is a SNR function defined
1043 if dataOut.data_SNR != None:
1059 if dataOut.data_SNR != None:
1044 nplots += 1
1060 nplots += 1
1045 SNR = dataOut.data_SNR
1061 SNR = dataOut.data_SNR
1046
1062
1047 if SNR_1:
1063 if SNR_1:
1048 SNR += 1
1064 SNR += 1
1049
1065
1050 SNRavg = numpy.average(SNR, axis=0)
1066 SNRavg = numpy.average(SNR, axis=0)
1051
1067
1052 SNRdB = 10*numpy.log10(SNR)
1068 SNRdB = 10*numpy.log10(SNR)
1053 SNRavgdB = 10*numpy.log10(SNRavg)
1069 SNRavgdB = 10*numpy.log10(SNRavg)
1054
1070
1055 ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0]
1071 ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0]
1056
1072
1057 for i in range(nplotsw):
1073 for i in range(nplotsw):
1058 z[i,ind] = numpy.nan
1074 z[i,ind] = numpy.nan
1059
1075
1060
1076
1061 showprofile = False
1077 showprofile = False
1062 # thisDatetime = dataOut.datatime
1078 # thisDatetime = dataOut.datatime
1063 thisDatetime = datetime.datetime.utcfromtimestamp(x[1])
1079 thisDatetime = datetime.datetime.utcfromtimestamp(x[1])
1064 title = wintitle + " EW Drifts"
1080 title = wintitle + " EW Drifts"
1065 xlabel = ""
1081 xlabel = ""
1066 ylabel = "Height (Km)"
1082 ylabel = "Height (Km)"
1067
1083
1068 if not self.__isConfig:
1084 if not self.__isConfig:
1069
1085
1070 self.setup(id=id,
1086 self.setup(id=id,
1071 nplots=nplots,
1087 nplots=nplots,
1072 wintitle=wintitle,
1088 wintitle=wintitle,
1073 showprofile=showprofile,
1089 showprofile=showprofile,
1074 show=show)
1090 show=show)
1075
1091
1076 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1092 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1077
1093
1078 if ymin == None: ymin = numpy.nanmin(y)
1094 if ymin == None: ymin = numpy.nanmin(y)
1079 if ymax == None: ymax = numpy.nanmax(y)
1095 if ymax == None: ymax = numpy.nanmax(y)
1080
1096
1081 if zmaxZonal == None: zmaxZonal = numpy.nanmax(abs(z[0,:]))
1097 if zmaxZonal == None: zmaxZonal = numpy.nanmax(abs(z[0,:]))
1082 if zminZonal == None: zminZonal = -zmaxZonal
1098 if zminZonal == None: zminZonal = -zmaxZonal
1083 if zmaxVertical == None: zmaxVertical = numpy.nanmax(abs(z[1,:]))
1099 if zmaxVertical == None: zmaxVertical = numpy.nanmax(abs(z[1,:]))
1084 if zminVertical == None: zminVertical = -zmaxVertical
1100 if zminVertical == None: zminVertical = -zmaxVertical
1085
1101
1086 if dataOut.data_SNR != None:
1102 if dataOut.data_SNR != None:
1087 if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB)
1103 if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB)
1088 if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB)
1104 if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB)
1089
1105
1090 self.FTP_WEI = ftp_wei
1106 self.FTP_WEI = ftp_wei
1091 self.EXP_CODE = exp_code
1107 self.EXP_CODE = exp_code
1092 self.SUB_EXP_CODE = sub_exp_code
1108 self.SUB_EXP_CODE = sub_exp_code
1093 self.PLOT_POS = plot_pos
1109 self.PLOT_POS = plot_pos
1094
1110
1095 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1111 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1096 self.__isConfig = True
1112 self.__isConfig = True
1097
1113
1098
1114
1099 self.setWinTitle(title)
1115 self.setWinTitle(title)
1100
1116
1101 if ((self.xmax - x[1]) < (x[1]-x[0])):
1117 if ((self.xmax - x[1]) < (x[1]-x[0])):
1102 x[1] = self.xmax
1118 x[1] = self.xmax
1103
1119
1104 strWind = ['Zonal','Vertical']
1120 strWind = ['Zonal','Vertical']
1105 strCb = 'Velocity (m/s)'
1121 strCb = 'Velocity (m/s)'
1106 zmaxVector = [zmaxZonal, zmaxVertical]
1122 zmaxVector = [zmaxZonal, zmaxVertical]
1107 zminVector = [zminZonal, zminVertical]
1123 zminVector = [zminZonal, zminVertical]
1108
1124
1109 for i in range(nplotsw):
1125 for i in range(nplotsw):
1110
1126
1111 title = "%s Drifts: %s" %(strWind[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1127 title = "%s Drifts: %s" %(strWind[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1112 axes = self.axesList[i*self.__nsubplots]
1128 axes = self.axesList[i*self.__nsubplots]
1113
1129
1114 z1 = z[i,:].reshape((1,-1))
1130 z1 = z[i,:].reshape((1,-1))
1115
1131
1116 axes.pcolorbuffer(x, y, z1,
1132 axes.pcolorbuffer(x, y, z1,
1117 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zminVector[i], zmax=zmaxVector[i],
1133 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zminVector[i], zmax=zmaxVector[i],
1118 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1134 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1119 ticksize=9, cblabel=strCb, cbsize="1%", colormap="RdBu_r")
1135 ticksize=9, cblabel=strCb, cbsize="1%", colormap="RdBu_r")
1120
1136
1121 if dataOut.data_SNR != None:
1137 if dataOut.data_SNR != None:
1122 i += 1
1138 i += 1
1123 if SNR_1:
1139 if SNR_1:
1124 title = "Signal Noise Ratio + 1 (SNR+1): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1140 title = "Signal Noise Ratio + 1 (SNR+1): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1125 else:
1141 else:
1126 title = "Signal Noise Ratio (SNR): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1142 title = "Signal Noise Ratio (SNR): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1127 axes = self.axesList[i*self.__nsubplots]
1143 axes = self.axesList[i*self.__nsubplots]
1128 SNRavgdB = SNRavgdB.reshape((1,-1))
1144 SNRavgdB = SNRavgdB.reshape((1,-1))
1129
1145
1130 axes.pcolorbuffer(x, y, SNRavgdB,
1146 axes.pcolorbuffer(x, y, SNRavgdB,
1131 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
1147 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
1132 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1148 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1133 ticksize=9, cblabel='', cbsize="1%", colormap="jet")
1149 ticksize=9, cblabel='', cbsize="1%", colormap="jet")
1134
1150
1135 self.draw()
1151 self.draw()
1136
1152
1137 if x[1] >= self.axesList[0].xmax:
1153 if x[1] >= self.axesList[0].xmax:
1138 self.counter_imagwr = wr_period
1154 self.counter_imagwr = wr_period
1139 self.__isConfig = False
1155 self.__isConfig = False
1140 self.figfile = None
1156 self.figfile = None
1141
1157
1142 self.save(figpath=figpath,
1158 self.save(figpath=figpath,
1143 figfile=figfile,
1159 figfile=figfile,
1144 save=save,
1160 save=save,
1145 ftp=ftp,
1161 ftp=ftp,
1146 wr_period=wr_period,
1162 wr_period=wr_period,
1147 thisDatetime=thisDatetime,
1163 thisDatetime=thisDatetime,
1148 update_figfile=False) No newline at end of file
1164 update_figfile=False)
General Comments 0
You need to be logged in to leave comments. Login now