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