##// END OF EJS Templates
Parameters libraries reorganized, now each operation is a separated class
Julio Valdez -
r841:c38d03dda608
parent child
Show More
@@ -1,1569 +1,1947
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, isTimeInHourRange
5 from figure import Figure, isRealtime, isTimeInHourRange
6 from plotting_codes import *
6 from plotting_codes import *
7
7
8 class MomentsPlot(Figure):
8 class MomentsPlot(Figure):
9
9
10 isConfig = None
10 isConfig = None
11 __nsubplots = None
11 __nsubplots = None
12
12
13 WIDTHPROF = None
13 WIDTHPROF = None
14 HEIGHTPROF = None
14 HEIGHTPROF = None
15 PREFIX = 'prm'
15 PREFIX = 'prm'
16
16
17 def __init__(self):
17 def __init__(self):
18
18
19 self.isConfig = False
19 self.isConfig = False
20 self.__nsubplots = 1
20 self.__nsubplots = 1
21
21
22 self.WIDTH = 280
22 self.WIDTH = 280
23 self.HEIGHT = 250
23 self.HEIGHT = 250
24 self.WIDTHPROF = 120
24 self.WIDTHPROF = 120
25 self.HEIGHTPROF = 0
25 self.HEIGHTPROF = 0
26 self.counter_imagwr = 0
26 self.counter_imagwr = 0
27
27
28 self.PLOT_CODE = MOMENTS_CODE
28 self.PLOT_CODE = MOMENTS_CODE
29
29
30 self.FTP_WEI = None
30 self.FTP_WEI = None
31 self.EXP_CODE = None
31 self.EXP_CODE = None
32 self.SUB_EXP_CODE = None
32 self.SUB_EXP_CODE = None
33 self.PLOT_POS = None
33 self.PLOT_POS = None
34
34
35 def getSubplots(self):
35 def getSubplots(self):
36
36
37 ncol = int(numpy.sqrt(self.nplots)+0.9)
37 ncol = int(numpy.sqrt(self.nplots)+0.9)
38 nrow = int(self.nplots*1./ncol + 0.9)
38 nrow = int(self.nplots*1./ncol + 0.9)
39
39
40 return nrow, ncol
40 return nrow, ncol
41
41
42 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
42 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
43
43
44 self.__showprofile = showprofile
44 self.__showprofile = showprofile
45 self.nplots = nplots
45 self.nplots = nplots
46
46
47 ncolspan = 1
47 ncolspan = 1
48 colspan = 1
48 colspan = 1
49 if showprofile:
49 if showprofile:
50 ncolspan = 3
50 ncolspan = 3
51 colspan = 2
51 colspan = 2
52 self.__nsubplots = 2
52 self.__nsubplots = 2
53
53
54 self.createFigure(id = id,
54 self.createFigure(id = id,
55 wintitle = wintitle,
55 wintitle = wintitle,
56 widthplot = self.WIDTH + self.WIDTHPROF,
56 widthplot = self.WIDTH + self.WIDTHPROF,
57 heightplot = self.HEIGHT + self.HEIGHTPROF,
57 heightplot = self.HEIGHT + self.HEIGHTPROF,
58 show=show)
58 show=show)
59
59
60 nrow, ncol = self.getSubplots()
60 nrow, ncol = self.getSubplots()
61
61
62 counter = 0
62 counter = 0
63 for y in range(nrow):
63 for y in range(nrow):
64 for x in range(ncol):
64 for x in range(ncol):
65
65
66 if counter >= self.nplots:
66 if counter >= self.nplots:
67 break
67 break
68
68
69 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
69 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
70
70
71 if showprofile:
71 if showprofile:
72 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
72 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
73
73
74 counter += 1
74 counter += 1
75
75
76 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True,
76 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True,
77 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
77 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
78 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
78 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
79 server=None, folder=None, username=None, password=None,
79 server=None, folder=None, username=None, password=None,
80 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False):
80 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False):
81
81
82 """
82 """
83
83
84 Input:
84 Input:
85 dataOut :
85 dataOut :
86 id :
86 id :
87 wintitle :
87 wintitle :
88 channelList :
88 channelList :
89 showProfile :
89 showProfile :
90 xmin : None,
90 xmin : None,
91 xmax : None,
91 xmax : None,
92 ymin : None,
92 ymin : None,
93 ymax : None,
93 ymax : None,
94 zmin : None,
94 zmin : None,
95 zmax : None
95 zmax : None
96 """
96 """
97
97
98 if dataOut.flagNoData:
98 if dataOut.flagNoData:
99 return None
99 return None
100
100
101 if realtime:
101 if realtime:
102 if not(isRealtime(utcdatatime = dataOut.utctime)):
102 if not(isRealtime(utcdatatime = dataOut.utctime)):
103 print 'Skipping this plot function'
103 print 'Skipping this plot function'
104 return
104 return
105
105
106 if channelList == None:
106 if channelList == None:
107 channelIndexList = dataOut.channelIndexList
107 channelIndexList = dataOut.channelIndexList
108 else:
108 else:
109 channelIndexList = []
109 channelIndexList = []
110 for channel in channelList:
110 for channel in channelList:
111 if channel not in dataOut.channelList:
111 if channel not in dataOut.channelList:
112 raise ValueError, "Channel %d is not in dataOut.channelList"
112 raise ValueError, "Channel %d is not in dataOut.channelList"
113 channelIndexList.append(dataOut.channelList.index(channel))
113 channelIndexList.append(dataOut.channelList.index(channel))
114
114
115 factor = dataOut.normFactor
115 factor = dataOut.normFactor
116 x = dataOut.abscissaList
116 x = dataOut.abscissaList
117 y = dataOut.heightList
117 y = dataOut.heightList
118
118
119 z = dataOut.data_pre[channelIndexList,:,:]/factor
119 z = dataOut.data_pre[channelIndexList,:,:]/factor
120 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
120 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
121 avg = numpy.average(z, axis=1)
121 avg = numpy.average(z, axis=1)
122 noise = dataOut.noise/factor
122 noise = dataOut.noise/factor
123
123
124 zdB = 10*numpy.log10(z)
124 zdB = 10*numpy.log10(z)
125 avgdB = 10*numpy.log10(avg)
125 avgdB = 10*numpy.log10(avg)
126 noisedB = 10*numpy.log10(noise)
126 noisedB = 10*numpy.log10(noise)
127
127
128 #thisDatetime = dataOut.datatime
128 #thisDatetime = dataOut.datatime
129 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
129 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
130 title = wintitle + " Parameters"
130 title = wintitle + " Parameters"
131 xlabel = "Velocity (m/s)"
131 xlabel = "Velocity (m/s)"
132 ylabel = "Range (Km)"
132 ylabel = "Range (Km)"
133
133
134 update_figfile = False
134 update_figfile = False
135
135
136 if not self.isConfig:
136 if not self.isConfig:
137
137
138 nplots = len(channelIndexList)
138 nplots = len(channelIndexList)
139
139
140 self.setup(id=id,
140 self.setup(id=id,
141 nplots=nplots,
141 nplots=nplots,
142 wintitle=wintitle,
142 wintitle=wintitle,
143 showprofile=showprofile,
143 showprofile=showprofile,
144 show=show)
144 show=show)
145
145
146 if xmin == None: xmin = numpy.nanmin(x)
146 if xmin == None: xmin = numpy.nanmin(x)
147 if xmax == None: xmax = numpy.nanmax(x)
147 if xmax == None: xmax = numpy.nanmax(x)
148 if ymin == None: ymin = numpy.nanmin(y)
148 if ymin == None: ymin = numpy.nanmin(y)
149 if ymax == None: ymax = numpy.nanmax(y)
149 if ymax == None: ymax = numpy.nanmax(y)
150 if zmin == None: zmin = numpy.nanmin(avgdB)*0.9
150 if zmin == None: zmin = numpy.nanmin(avgdB)*0.9
151 if zmax == None: zmax = numpy.nanmax(avgdB)*0.9
151 if zmax == None: zmax = numpy.nanmax(avgdB)*0.9
152
152
153 self.FTP_WEI = ftp_wei
153 self.FTP_WEI = ftp_wei
154 self.EXP_CODE = exp_code
154 self.EXP_CODE = exp_code
155 self.SUB_EXP_CODE = sub_exp_code
155 self.SUB_EXP_CODE = sub_exp_code
156 self.PLOT_POS = plot_pos
156 self.PLOT_POS = plot_pos
157
157
158 self.isConfig = True
158 self.isConfig = True
159 update_figfile = True
159 update_figfile = True
160
160
161 self.setWinTitle(title)
161 self.setWinTitle(title)
162
162
163 for i in range(self.nplots):
163 for i in range(self.nplots):
164 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
164 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
165 title = "Channel %d: %4.2fdB: %s" %(dataOut.channelList[i], noisedB[i], str_datetime)
165 title = "Channel %d: %4.2fdB: %s" %(dataOut.channelList[i], noisedB[i], str_datetime)
166 axes = self.axesList[i*self.__nsubplots]
166 axes = self.axesList[i*self.__nsubplots]
167 axes.pcolor(x, y, zdB[i,:,:],
167 axes.pcolor(x, y, zdB[i,:,:],
168 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
168 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
169 xlabel=xlabel, ylabel=ylabel, title=title,
169 xlabel=xlabel, ylabel=ylabel, title=title,
170 ticksize=9, cblabel='')
170 ticksize=9, cblabel='')
171 #Mean Line
171 #Mean Line
172 mean = dataOut.data_param[i, 1, :]
172 mean = dataOut.data_param[i, 1, :]
173 axes.addpline(mean, y, idline=0, color="black", linestyle="solid", lw=1)
173 axes.addpline(mean, y, idline=0, color="black", linestyle="solid", lw=1)
174
174
175 if self.__showprofile:
175 if self.__showprofile:
176 axes = self.axesList[i*self.__nsubplots +1]
176 axes = self.axesList[i*self.__nsubplots +1]
177 axes.pline(avgdB[i], y,
177 axes.pline(avgdB[i], y,
178 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
178 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
179 xlabel='dB', ylabel='', title='',
179 xlabel='dB', ylabel='', title='',
180 ytick_visible=False,
180 ytick_visible=False,
181 grid='x')
181 grid='x')
182
182
183 noiseline = numpy.repeat(noisedB[i], len(y))
183 noiseline = numpy.repeat(noisedB[i], len(y))
184 axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2)
184 axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2)
185
185
186 self.draw()
186 self.draw()
187
187
188 self.save(figpath=figpath,
188 self.save(figpath=figpath,
189 figfile=figfile,
189 figfile=figfile,
190 save=save,
190 save=save,
191 ftp=ftp,
191 ftp=ftp,
192 wr_period=wr_period,
192 wr_period=wr_period,
193 thisDatetime=thisDatetime)
193 thisDatetime=thisDatetime)
194
194
195
195
196
196
197 class SkyMapPlot(Figure):
197 class SkyMapPlot(Figure):
198
198
199 __isConfig = None
199 __isConfig = None
200 __nsubplots = None
200 __nsubplots = None
201
201
202 WIDTHPROF = None
202 WIDTHPROF = None
203 HEIGHTPROF = None
203 HEIGHTPROF = None
204 PREFIX = 'mmap'
204 PREFIX = 'mmap'
205
205
206 def __init__(self):
206 def __init__(self):
207
207
208 self.isConfig = False
208 self.isConfig = False
209 self.__nsubplots = 1
209 self.__nsubplots = 1
210
210
211 # self.WIDTH = 280
211 # self.WIDTH = 280
212 # self.HEIGHT = 250
212 # self.HEIGHT = 250
213 self.WIDTH = 600
213 self.WIDTH = 600
214 self.HEIGHT = 600
214 self.HEIGHT = 600
215 self.WIDTHPROF = 120
215 self.WIDTHPROF = 120
216 self.HEIGHTPROF = 0
216 self.HEIGHTPROF = 0
217 self.counter_imagwr = 0
217 self.counter_imagwr = 0
218
218
219 self.PLOT_CODE = MSKYMAP_CODE
219 self.PLOT_CODE = MSKYMAP_CODE
220
220
221 self.FTP_WEI = None
221 self.FTP_WEI = None
222 self.EXP_CODE = None
222 self.EXP_CODE = None
223 self.SUB_EXP_CODE = None
223 self.SUB_EXP_CODE = None
224 self.PLOT_POS = None
224 self.PLOT_POS = None
225
225
226 def getSubplots(self):
226 def getSubplots(self):
227
227
228 ncol = int(numpy.sqrt(self.nplots)+0.9)
228 ncol = int(numpy.sqrt(self.nplots)+0.9)
229 nrow = int(self.nplots*1./ncol + 0.9)
229 nrow = int(self.nplots*1./ncol + 0.9)
230
230
231 return nrow, ncol
231 return nrow, ncol
232
232
233 def setup(self, id, nplots, wintitle, showprofile=False, show=True):
233 def setup(self, id, nplots, wintitle, showprofile=False, show=True):
234
234
235 self.__showprofile = showprofile
235 self.__showprofile = showprofile
236 self.nplots = nplots
236 self.nplots = nplots
237
237
238 ncolspan = 1
238 ncolspan = 1
239 colspan = 1
239 colspan = 1
240
240
241 self.createFigure(id = id,
241 self.createFigure(id = id,
242 wintitle = wintitle,
242 wintitle = wintitle,
243 widthplot = self.WIDTH, #+ self.WIDTHPROF,
243 widthplot = self.WIDTH, #+ self.WIDTHPROF,
244 heightplot = self.HEIGHT,# + self.HEIGHTPROF,
244 heightplot = self.HEIGHT,# + self.HEIGHTPROF,
245 show=show)
245 show=show)
246
246
247 nrow, ncol = 1,1
247 nrow, ncol = 1,1
248 counter = 0
248 counter = 0
249 x = 0
249 x = 0
250 y = 0
250 y = 0
251 self.addAxes(1, 1, 0, 0, 1, 1, True)
251 self.addAxes(1, 1, 0, 0, 1, 1, True)
252
252
253 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=False,
253 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=False,
254 tmin=0, tmax=24, timerange=None,
254 tmin=0, tmax=24, timerange=None,
255 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
255 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
256 server=None, folder=None, username=None, password=None,
256 server=None, folder=None, username=None, password=None,
257 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False):
257 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False):
258
258
259 """
259 """
260
260
261 Input:
261 Input:
262 dataOut :
262 dataOut :
263 id :
263 id :
264 wintitle :
264 wintitle :
265 channelList :
265 channelList :
266 showProfile :
266 showProfile :
267 xmin : None,
267 xmin : None,
268 xmax : None,
268 xmax : None,
269 ymin : None,
269 ymin : None,
270 ymax : None,
270 ymax : None,
271 zmin : None,
271 zmin : None,
272 zmax : None
272 zmax : None
273 """
273 """
274
274
275 arrayParameters = dataOut.data_param
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[:,3]
279 finalAzimuth = finalMeteor[:,3]
280 finalZenith = finalMeteor[:,4]
280 finalZenith = finalMeteor[:,4]
281
281
282 x = finalAzimuth*numpy.pi/180
282 x = finalAzimuth*numpy.pi/180
283 y = finalZenith
283 y = finalZenith
284 x1 = [dataOut.ltctime, dataOut.ltctime]
284 x1 = [dataOut.ltctime, dataOut.ltctime]
285
285
286 #thisDatetime = dataOut.datatime
286 #thisDatetime = dataOut.datatime
287 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime)
287 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime)
288 title = wintitle + " Parameters"
288 title = wintitle + " Parameters"
289 xlabel = "Zonal Zenith Angle (deg) "
289 xlabel = "Zonal Zenith Angle (deg) "
290 ylabel = "Meridional Zenith Angle (deg)"
290 ylabel = "Meridional Zenith Angle (deg)"
291 update_figfile = False
291 update_figfile = False
292
292
293 if not self.isConfig:
293 if not self.isConfig:
294
294
295 nplots = 1
295 nplots = 1
296
296
297 self.setup(id=id,
297 self.setup(id=id,
298 nplots=nplots,
298 nplots=nplots,
299 wintitle=wintitle,
299 wintitle=wintitle,
300 showprofile=showprofile,
300 showprofile=showprofile,
301 show=show)
301 show=show)
302
302
303 if self.xmin is None and self.xmax is None:
303 if self.xmin is None and self.xmax is None:
304 self.xmin, self.xmax = self.getTimeLim(x1, tmin, tmax, timerange)
304 self.xmin, self.xmax = self.getTimeLim(x1, tmin, tmax, timerange)
305
305
306 if timerange != None:
306 if timerange != None:
307 self.timerange = timerange
307 self.timerange = timerange
308 else:
308 else:
309 self.timerange = self.xmax - self.xmin
309 self.timerange = self.xmax - self.xmin
310
310
311 self.FTP_WEI = ftp_wei
311 self.FTP_WEI = ftp_wei
312 self.EXP_CODE = exp_code
312 self.EXP_CODE = exp_code
313 self.SUB_EXP_CODE = sub_exp_code
313 self.SUB_EXP_CODE = sub_exp_code
314 self.PLOT_POS = plot_pos
314 self.PLOT_POS = plot_pos
315 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
315 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
316 self.firstdate = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
316 self.firstdate = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
317 self.isConfig = True
317 self.isConfig = True
318 update_figfile = True
318 update_figfile = True
319
319
320 self.setWinTitle(title)
320 self.setWinTitle(title)
321
321
322 i = 0
322 i = 0
323 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
323 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
324
324
325 axes = self.axesList[i*self.__nsubplots]
325 axes = self.axesList[i*self.__nsubplots]
326 nevents = axes.x_buffer.shape[0] + x.shape[0]
326 nevents = axes.x_buffer.shape[0] + x.shape[0]
327 title = "Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n" %(self.firstdate,str_datetime,nevents)
327 title = "Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n" %(self.firstdate,str_datetime,nevents)
328 axes.polar(x, y,
328 axes.polar(x, y,
329 title=title, xlabel=xlabel, ylabel=ylabel,
329 title=title, xlabel=xlabel, ylabel=ylabel,
330 ticksize=9, cblabel='')
330 ticksize=9, cblabel='')
331
331
332 self.draw()
332 self.draw()
333
333
334 self.save(figpath=figpath,
334 self.save(figpath=figpath,
335 figfile=figfile,
335 figfile=figfile,
336 save=save,
336 save=save,
337 ftp=ftp,
337 ftp=ftp,
338 wr_period=wr_period,
338 wr_period=wr_period,
339 thisDatetime=thisDatetime,
339 thisDatetime=thisDatetime,
340 update_figfile=update_figfile)
340 update_figfile=update_figfile)
341
341
342 if dataOut.ltctime >= self.xmax:
342 if dataOut.ltctime >= self.xmax:
343 self.isConfigmagwr = wr_period
343 self.isConfigmagwr = wr_period
344 self.isConfig = False
344 self.isConfig = False
345 update_figfile = True
345 update_figfile = True
346 axes.__firsttime = True
346 axes.__firsttime = True
347 self.xmin += self.timerange
347 self.xmin += self.timerange
348 self.xmax += self.timerange
348 self.xmax += self.timerange
349
349
350
350
351
351
352
352
353 class WindProfilerPlot(Figure):
353 class WindProfilerPlot(Figure):
354
354
355 __isConfig = None
355 __isConfig = None
356 __nsubplots = None
356 __nsubplots = None
357
357
358 WIDTHPROF = None
358 WIDTHPROF = None
359 HEIGHTPROF = None
359 HEIGHTPROF = None
360 PREFIX = 'wind'
360 PREFIX = 'wind'
361
361
362 def __init__(self):
362 def __init__(self):
363
363
364 self.timerange = None
364 self.timerange = None
365 self.isConfig = False
365 self.isConfig = False
366 self.__nsubplots = 1
366 self.__nsubplots = 1
367
367
368 self.WIDTH = 800
368 self.WIDTH = 800
369 self.HEIGHT = 150
369 self.HEIGHT = 300
370 self.WIDTHPROF = 120
370 self.WIDTHPROF = 120
371 self.HEIGHTPROF = 0
371 self.HEIGHTPROF = 0
372 self.counter_imagwr = 0
372 self.counter_imagwr = 0
373
373
374 self.PLOT_CODE = WIND_CODE
374 self.PLOT_CODE = WIND_CODE
375
375
376 self.FTP_WEI = None
376 self.FTP_WEI = None
377 self.EXP_CODE = None
377 self.EXP_CODE = None
378 self.SUB_EXP_CODE = None
378 self.SUB_EXP_CODE = None
379 self.PLOT_POS = None
379 self.PLOT_POS = None
380 self.tmin = None
380 self.tmin = None
381 self.tmax = None
381 self.tmax = None
382
382
383 self.xmin = None
383 self.xmin = None
384 self.xmax = None
384 self.xmax = None
385
385
386 self.figfile = None
386 self.figfile = None
387
387
388 def getSubplots(self):
388 def getSubplots(self):
389
389
390 ncol = 1
390 ncol = 1
391 nrow = self.nplots
391 nrow = self.nplots
392
392
393 return nrow, ncol
393 return nrow, ncol
394
394
395 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
395 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
396
396
397 self.__showprofile = showprofile
397 self.__showprofile = showprofile
398 self.nplots = nplots
398 self.nplots = nplots
399
399
400 ncolspan = 1
400 ncolspan = 1
401 colspan = 1
401 colspan = 1
402
402
403 self.createFigure(id = id,
403 self.createFigure(id = id,
404 wintitle = wintitle,
404 wintitle = wintitle,
405 widthplot = self.WIDTH + self.WIDTHPROF,
405 widthplot = self.WIDTH + self.WIDTHPROF,
406 heightplot = self.HEIGHT + self.HEIGHTPROF,
406 heightplot = self.HEIGHT + self.HEIGHTPROF,
407 show=show)
407 show=show)
408
408
409 nrow, ncol = self.getSubplots()
409 nrow, ncol = self.getSubplots()
410
410
411 counter = 0
411 counter = 0
412 for y in range(nrow):
412 for y in range(nrow):
413 if counter >= self.nplots:
413 if counter >= self.nplots:
414 break
414 break
415
415
416 self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1)
416 self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1)
417 counter += 1
417 counter += 1
418
418
419 def run(self, dataOut, id, wintitle="", channelList=None, showprofile='False',
419 def run(self, dataOut, id, wintitle="", channelList=None, showprofile='False',
420 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
420 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
421 zmax_ver = None, zmin_ver = None, SNRmin = None, SNRmax = None,
421 zmax_ver = None, zmin_ver = None, SNRmin = None, SNRmax = None,
422 timerange=None, SNRthresh = None,
422 timerange=None, SNRthresh = None,
423 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
423 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
424 server=None, folder=None, username=None, password=None,
424 server=None, folder=None, username=None, password=None,
425 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
425 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
426 """
426 """
427
427
428 Input:
428 Input:
429 dataOut :
429 dataOut :
430 id :
430 id :
431 wintitle :
431 wintitle :
432 channelList :
432 channelList :
433 showProfile :
433 showProfile :
434 xmin : None,
434 xmin : None,
435 xmax : None,
435 xmax : None,
436 ymin : None,
436 ymin : None,
437 ymax : None,
437 ymax : None,
438 zmin : None,
438 zmin : None,
439 zmax : None
439 zmax : None
440 """
440 """
441
441
442 # if timerange is not None:
442 # if timerange is not None:
443 # self.timerange = timerange
443 # self.timerange = timerange
444 #
444 #
445 # tmin = None
445 # tmin = None
446 # tmax = None
446 # tmax = None
447
447
448 x = dataOut.getTimeRange1(dataOut.outputInterval)
448 x = dataOut.getTimeRange1(dataOut.outputInterval)
449 # y = dataOut.heightList
449 # y = dataOut.heightList
450 y = dataOut.heightList
450 y = dataOut.heightList
451
451
452 z = dataOut.data_output.copy()
452 z = dataOut.data_output.copy()
453 nplots = z.shape[0] #Number of wind dimensions estimated
453 nplots = z.shape[0] #Number of wind dimensions estimated
454 nplotsw = nplots
454 nplotsw = nplots
455
455
456 #If there is a SNR function defined
456 #If there is a SNR function defined
457 if dataOut.data_SNR is not None:
457 if dataOut.data_SNR is not None:
458 nplots += 1
458 nplots += 1
459 SNR = dataOut.data_SNR
459 SNR = dataOut.data_SNR
460 SNRavg = numpy.average(SNR, axis=0)
460 SNRavg = numpy.average(SNR, axis=0)
461
461
462 SNRdB = 10*numpy.log10(SNR)
462 SNRdB = 10*numpy.log10(SNR)
463 SNRavgdB = 10*numpy.log10(SNRavg)
463 SNRavgdB = 10*numpy.log10(SNRavg)
464
464
465 if SNRthresh == None: SNRthresh = -5.0
465 if SNRthresh == None: SNRthresh = -5.0
466 ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0]
466 ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0]
467
467
468 for i in range(nplotsw):
468 for i in range(nplotsw):
469 z[i,ind] = numpy.nan
469 z[i,ind] = numpy.nan
470
470
471
471
472 # showprofile = False
472 # showprofile = False
473 # thisDatetime = dataOut.datatime
473 # thisDatetime = dataOut.datatime
474 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime)
474 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime)
475 title = wintitle + "Wind"
475 title = wintitle + "Wind"
476 xlabel = ""
476 xlabel = ""
477 ylabel = "Range (Km)"
477 ylabel = "Height (km)"
478 update_figfile = False
478 update_figfile = False
479
479
480 if not self.isConfig:
480 if not self.isConfig:
481
481
482 self.setup(id=id,
482 self.setup(id=id,
483 nplots=nplots,
483 nplots=nplots,
484 wintitle=wintitle,
484 wintitle=wintitle,
485 showprofile=showprofile,
485 showprofile=showprofile,
486 show=show)
486 show=show)
487
487
488 if timerange is not None:
488 if timerange is not None:
489 self.timerange = timerange
489 self.timerange = timerange
490
490
491 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
491 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
492
492
493 if ymin == None: ymin = numpy.nanmin(y)
493 if ymin == None: ymin = numpy.nanmin(y)
494 if ymax == None: ymax = numpy.nanmax(y)
494 if ymax == None: ymax = numpy.nanmax(y)
495
495
496 if zmax == None: zmax = numpy.nanmax(abs(z[range(2),:]))
496 if zmax == None: zmax = numpy.nanmax(abs(z[range(2),:]))
497 #if numpy.isnan(zmax): zmax = 50
497 #if numpy.isnan(zmax): zmax = 50
498 if zmin == None: zmin = -zmax
498 if zmin == None: zmin = -zmax
499
499
500 if nplotsw == 3:
500 if nplotsw == 3:
501 if zmax_ver == None: zmax_ver = numpy.nanmax(abs(z[2,:]))
501 if zmax_ver == None: zmax_ver = numpy.nanmax(abs(z[2,:]))
502 if zmin_ver == None: zmin_ver = -zmax_ver
502 if zmin_ver == None: zmin_ver = -zmax_ver
503
503
504 if dataOut.data_SNR is not None:
504 if dataOut.data_SNR is not None:
505 if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB)
505 if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB)
506 if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB)
506 if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB)
507
507
508
508
509 self.FTP_WEI = ftp_wei
509 self.FTP_WEI = ftp_wei
510 self.EXP_CODE = exp_code
510 self.EXP_CODE = exp_code
511 self.SUB_EXP_CODE = sub_exp_code
511 self.SUB_EXP_CODE = sub_exp_code
512 self.PLOT_POS = plot_pos
512 self.PLOT_POS = plot_pos
513
513
514 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
514 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
515 self.isConfig = True
515 self.isConfig = True
516 self.figfile = figfile
516 self.figfile = figfile
517 update_figfile = True
517 update_figfile = True
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 is not None:
542 if dataOut.data_SNR is not 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 dataOut.ltctime >= self.xmax:
556 if dataOut.ltctime >= self.xmax:
557 self.counter_imagwr = wr_period
557 self.counter_imagwr = wr_period
558 self.isConfig = False
558 self.isConfig = False
559 update_figfile = True
559 update_figfile = True
560
560
561 self.save(figpath=figpath,
561 self.save(figpath=figpath,
562 figfile=figfile,
562 figfile=figfile,
563 save=save,
563 save=save,
564 ftp=ftp,
564 ftp=ftp,
565 wr_period=wr_period,
565 wr_period=wr_period,
566 thisDatetime=thisDatetime,
566 thisDatetime=thisDatetime,
567 update_figfile=update_figfile)
567 update_figfile=update_figfile)
568
568
569 class ParametersPlot(Figure):
569 class ParametersPlot(Figure):
570
570
571 __isConfig = None
571 __isConfig = None
572 __nsubplots = None
572 __nsubplots = None
573
573
574 WIDTHPROF = None
574 WIDTHPROF = None
575 HEIGHTPROF = None
575 HEIGHTPROF = None
576 PREFIX = 'param'
576 PREFIX = 'param'
577
577
578 nplots = None
578 nplots = None
579 nchan = None
579 nchan = None
580
580
581 def __init__(self):
581 def __init__(self):
582
582
583 self.timerange = None
583 self.timerange = None
584 self.isConfig = False
584 self.isConfig = False
585 self.__nsubplots = 1
585 self.__nsubplots = 1
586
586
587 self.WIDTH = 800
587 self.WIDTH = 800
588 self.HEIGHT = 180
588 self.HEIGHT = 180
589 self.WIDTHPROF = 120
589 self.WIDTHPROF = 120
590 self.HEIGHTPROF = 0
590 self.HEIGHTPROF = 0
591 self.counter_imagwr = 0
591 self.counter_imagwr = 0
592
592
593 self.PLOT_CODE = RTI_CODE
593 self.PLOT_CODE = RTI_CODE
594
594
595 self.FTP_WEI = None
595 self.FTP_WEI = None
596 self.EXP_CODE = None
596 self.EXP_CODE = None
597 self.SUB_EXP_CODE = None
597 self.SUB_EXP_CODE = None
598 self.PLOT_POS = None
598 self.PLOT_POS = None
599 self.tmin = None
599 self.tmin = None
600 self.tmax = None
600 self.tmax = None
601
601
602 self.xmin = None
602 self.xmin = None
603 self.xmax = None
603 self.xmax = None
604
604
605 self.figfile = None
605 self.figfile = None
606
606
607 def getSubplots(self):
607 def getSubplots(self):
608
608
609 ncol = 1
609 ncol = 1
610 nrow = self.nplots
610 nrow = self.nplots
611
611
612 return nrow, ncol
612 return nrow, ncol
613
613
614 def setup(self, id, nplots, wintitle, show=True):
614 def setup(self, id, nplots, wintitle, show=True):
615
615
616 self.nplots = nplots
616 self.nplots = nplots
617
617
618 ncolspan = 1
618 ncolspan = 1
619 colspan = 1
619 colspan = 1
620
620
621 self.createFigure(id = id,
621 self.createFigure(id = id,
622 wintitle = wintitle,
622 wintitle = wintitle,
623 widthplot = self.WIDTH + self.WIDTHPROF,
623 widthplot = self.WIDTH + self.WIDTHPROF,
624 heightplot = self.HEIGHT + self.HEIGHTPROF,
624 heightplot = self.HEIGHT + self.HEIGHTPROF,
625 show=show)
625 show=show)
626
626
627 nrow, ncol = self.getSubplots()
627 nrow, ncol = self.getSubplots()
628
628
629 counter = 0
629 counter = 0
630 for y in range(nrow):
630 for y in range(nrow):
631 for x in range(ncol):
631 for x in range(ncol):
632
632
633 if counter >= self.nplots:
633 if counter >= self.nplots:
634 break
634 break
635
635
636 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
636 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
637
637
638 counter += 1
638 counter += 1
639
639
640 def run(self, dataOut, id, wintitle="", channelList=None, paramIndex = 0, colormap=True,
640 def run(self, dataOut, id, wintitle="", channelList=None, paramIndex = 0, colormap=True,
641 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, timerange=None,
641 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, timerange=None,
642 showSNR=False, SNRthresh = -numpy.inf, SNRmin=None, SNRmax=None,
642 showSNR=False, SNRthresh = -numpy.inf, SNRmin=None, SNRmax=None,
643 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
643 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
644 server=None, folder=None, username=None, password=None,
644 server=None, folder=None, username=None, password=None,
645 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
645 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
646
646
647 """
647 """
648
648
649 Input:
649 Input:
650 dataOut :
650 dataOut :
651 id :
651 id :
652 wintitle :
652 wintitle :
653 channelList :
653 channelList :
654 showProfile :
654 showProfile :
655 xmin : None,
655 xmin : None,
656 xmax : None,
656 xmax : None,
657 ymin : None,
657 ymin : None,
658 ymax : None,
658 ymax : None,
659 zmin : None,
659 zmin : None,
660 zmax : None
660 zmax : None
661 """
661 """
662
662
663 if colormap:
663 if colormap:
664 colormap="jet"
664 colormap="jet"
665 else:
665 else:
666 colormap="RdBu_r"
666 colormap="RdBu_r"
667
667
668 if not isTimeInHourRange(dataOut.datatime, xmin, xmax):
668 if not isTimeInHourRange(dataOut.datatime, xmin, xmax):
669 return
669 return
670
670
671 if channelList == None:
671 if channelList == None:
672 channelIndexList = dataOut.channelIndexList
672 channelIndexList = range(dataOut.data_param.shape[0])
673 else:
673 else:
674 channelIndexList = []
674 channelIndexList = []
675 for channel in channelList:
675 for channel in channelList:
676 if channel not in dataOut.channelList:
676 if channel not in dataOut.channelList:
677 raise ValueError, "Channel %d is not in dataOut.channelList"
677 raise ValueError, "Channel %d is not in dataOut.channelList"
678 channelIndexList.append(dataOut.channelList.index(channel))
678 channelIndexList.append(dataOut.channelList.index(channel))
679
679
680 x = dataOut.getTimeRange1(dataOut.paramInterval)
680 x = dataOut.getTimeRange1(dataOut.paramInterval)
681 y = dataOut.getHeiRange()
681 y = dataOut.getHeiRange()
682 z = dataOut.data_param[channelIndexList,paramIndex,:]
683
682
683 if dataOut.data_param.ndim == 3:
684 z = dataOut.data_param[channelIndexList,paramIndex,:]
685 else:
686 z = dataOut.data_param[channelIndexList,:]
687
684 if showSNR:
688 if showSNR:
685 #SNR data
689 #SNR data
686 SNRarray = dataOut.data_SNR[channelIndexList,:]
690 SNRarray = dataOut.data_SNR[channelIndexList,:]
687 SNRdB = 10*numpy.log10(SNRarray)
691 SNRdB = 10*numpy.log10(SNRarray)
688 ind = numpy.where(SNRdB < SNRthresh)
692 ind = numpy.where(SNRdB < SNRthresh)
689 z[ind] = numpy.nan
693 z[ind] = numpy.nan
690
694
691 thisDatetime = dataOut.datatime
695 thisDatetime = dataOut.datatime
692 # thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
696 # thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
693 title = wintitle + " Parameters Plot" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
697 title = wintitle + " Parameters Plot" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
694 xlabel = ""
698 xlabel = ""
695 ylabel = "Range (Km)"
699 ylabel = "Range (Km)"
696
700
697 update_figfile = False
701 update_figfile = False
698
702
699 if not self.isConfig:
703 if not self.isConfig:
700
704
701 nchan = len(channelIndexList)
705 nchan = len(channelIndexList)
702 self.nchan = nchan
706 self.nchan = nchan
703 self.plotFact = 1
707 self.plotFact = 1
704 nplots = nchan
708 nplots = nchan
705
709
706 if showSNR:
710 if showSNR:
707 nplots = nchan*2
711 nplots = nchan*2
708 self.plotFact = 2
712 self.plotFact = 2
709 if SNRmin == None: SNRmin = numpy.nanmin(SNRdB)
713 if SNRmin == None: SNRmin = numpy.nanmin(SNRdB)
710 if SNRmax == None: SNRmax = numpy.nanmax(SNRdB)
714 if SNRmax == None: SNRmax = numpy.nanmax(SNRdB)
711
715
712 self.setup(id=id,
716 self.setup(id=id,
713 nplots=nplots,
717 nplots=nplots,
714 wintitle=wintitle,
718 wintitle=wintitle,
715 show=show)
719 show=show)
716
720
717 if timerange != None:
721 if timerange != None:
718 self.timerange = timerange
722 self.timerange = timerange
719
723
720 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
724 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
721
725
722 if ymin == None: ymin = numpy.nanmin(y)
726 if ymin == None: ymin = numpy.nanmin(y)
723 if ymax == None: ymax = numpy.nanmax(y)
727 if ymax == None: ymax = numpy.nanmax(y)
724 if zmin == None: zmin = dataOut.abscissaList[0]
728 if zmin == None: zmin = numpy.nanmin(z)
725 if zmax == None: zmax = dataOut.abscissaList[-1]
729 if zmax == None: zmax = numpy.nanmax(z)
726
730
727 self.FTP_WEI = ftp_wei
731 self.FTP_WEI = ftp_wei
728 self.EXP_CODE = exp_code
732 self.EXP_CODE = exp_code
729 self.SUB_EXP_CODE = sub_exp_code
733 self.SUB_EXP_CODE = sub_exp_code
730 self.PLOT_POS = plot_pos
734 self.PLOT_POS = plot_pos
731
735
732 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
736 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
733 self.isConfig = True
737 self.isConfig = True
734 self.figfile = figfile
738 self.figfile = figfile
735 update_figfile = True
739 update_figfile = True
736
740
737 self.setWinTitle(title)
741 self.setWinTitle(title)
738
742
739 for i in range(self.nchan):
743 for i in range(self.nchan):
740 index = channelIndexList[i]
744 index = channelIndexList[i]
741 title = "Channel %d: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
745 title = "Channel %d: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
742 axes = self.axesList[i*self.plotFact]
746 axes = self.axesList[i*self.plotFact]
743 z1 = z[i,:].reshape((1,-1))
747 z1 = z[i,:].reshape((1,-1))
744 axes.pcolorbuffer(x, y, z1,
748 axes.pcolorbuffer(x, y, z1,
745 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
749 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
746 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
750 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
747 ticksize=9, cblabel='', cbsize="1%",colormap=colormap)
751 ticksize=9, cblabel='', cbsize="1%",colormap=colormap)
748
752
749 if showSNR:
753 if showSNR:
750 title = "Channel %d SNR: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
754 title = "Channel %d SNR: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
751 axes = self.axesList[i*self.plotFact + 1]
755 axes = self.axesList[i*self.plotFact + 1]
752 SNRdB1 = SNRdB[i,:].reshape((1,-1))
756 SNRdB1 = SNRdB[i,:].reshape((1,-1))
753 axes.pcolorbuffer(x, y, SNRdB1,
757 axes.pcolorbuffer(x, y, SNRdB1,
754 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
758 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
755 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
759 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
756 ticksize=9, cblabel='', cbsize="1%",colormap='jet')
760 ticksize=9, cblabel='', cbsize="1%",colormap='jet')
757
761
758
762
759 self.draw()
763 self.draw()
760
764
761 if dataOut.ltctime >= self.xmax:
765 if dataOut.ltctime >= self.xmax:
762 self.counter_imagwr = wr_period
766 self.counter_imagwr = wr_period
763 self.isConfig = False
767 self.isConfig = False
764 update_figfile = True
768 update_figfile = True
765
769
766 self.save(figpath=figpath,
770 self.save(figpath=figpath,
767 figfile=figfile,
771 figfile=figfile,
768 save=save,
772 save=save,
769 ftp=ftp,
773 ftp=ftp,
770 wr_period=wr_period,
774 wr_period=wr_period,
771 thisDatetime=thisDatetime,
775 thisDatetime=thisDatetime,
772 update_figfile=update_figfile)
776 update_figfile=update_figfile)
773
777
774
778
775
779
776 class Parameters1Plot(Figure):
780 class Parameters1Plot(Figure):
777
781
778 __isConfig = None
782 __isConfig = None
779 __nsubplots = None
783 __nsubplots = None
780
784
781 WIDTHPROF = None
785 WIDTHPROF = None
782 HEIGHTPROF = None
786 HEIGHTPROF = None
783 PREFIX = 'prm'
787 PREFIX = 'prm'
784
788
785 def __init__(self):
789 def __init__(self):
786
790
787 self.timerange = 2*60*60
791 self.timerange = 2*60*60
788 self.isConfig = False
792 self.isConfig = False
789 self.__nsubplots = 1
793 self.__nsubplots = 1
790
794
791 self.WIDTH = 800
795 self.WIDTH = 800
792 self.HEIGHT = 150
796 self.HEIGHT = 150
793 self.WIDTHPROF = 120
797 self.WIDTHPROF = 120
794 self.HEIGHTPROF = 0
798 self.HEIGHTPROF = 0
795 self.counter_imagwr = 0
799 self.counter_imagwr = 0
796
800
797 self.PLOT_CODE = PARMS_CODE
801 self.PLOT_CODE = PARMS_CODE
798
802
799 self.FTP_WEI = None
803 self.FTP_WEI = None
800 self.EXP_CODE = None
804 self.EXP_CODE = None
801 self.SUB_EXP_CODE = None
805 self.SUB_EXP_CODE = None
802 self.PLOT_POS = None
806 self.PLOT_POS = None
803 self.tmin = None
807 self.tmin = None
804 self.tmax = None
808 self.tmax = None
805
809
806 self.xmin = None
810 self.xmin = None
807 self.xmax = None
811 self.xmax = None
808
812
809 self.figfile = None
813 self.figfile = None
810
814
811 def getSubplots(self):
815 def getSubplots(self):
812
816
813 ncol = 1
817 ncol = 1
814 nrow = self.nplots
818 nrow = self.nplots
815
819
816 return nrow, ncol
820 return nrow, ncol
817
821
818 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
822 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
819
823
820 self.__showprofile = showprofile
824 self.__showprofile = showprofile
821 self.nplots = nplots
825 self.nplots = nplots
822
826
823 ncolspan = 1
827 ncolspan = 1
824 colspan = 1
828 colspan = 1
825
829
826 self.createFigure(id = id,
830 self.createFigure(id = id,
827 wintitle = wintitle,
831 wintitle = wintitle,
828 widthplot = self.WIDTH + self.WIDTHPROF,
832 widthplot = self.WIDTH + self.WIDTHPROF,
829 heightplot = self.HEIGHT + self.HEIGHTPROF,
833 heightplot = self.HEIGHT + self.HEIGHTPROF,
830 show=show)
834 show=show)
831
835
832 nrow, ncol = self.getSubplots()
836 nrow, ncol = self.getSubplots()
833
837
834 counter = 0
838 counter = 0
835 for y in range(nrow):
839 for y in range(nrow):
836 for x in range(ncol):
840 for x in range(ncol):
837
841
838 if counter >= self.nplots:
842 if counter >= self.nplots:
839 break
843 break
840
844
841 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
845 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
842
846
843 if showprofile:
847 if showprofile:
844 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
848 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
845
849
846 counter += 1
850 counter += 1
847
851
848 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=False,
852 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=False,
849 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,timerange=None,
853 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,timerange=None,
850 parameterIndex = None, onlyPositive = False,
854 parameterIndex = None, onlyPositive = False,
851 SNRthresh = -numpy.inf, SNR = True, SNRmin = None, SNRmax = None, onlySNR = False,
855 SNRthresh = -numpy.inf, SNR = True, SNRmin = None, SNRmax = None, onlySNR = False,
852 DOP = True,
856 DOP = True,
853 zlabel = "", parameterName = "", parameterObject = "data_param",
857 zlabel = "", parameterName = "", parameterObject = "data_param",
854 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
858 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
855 server=None, folder=None, username=None, password=None,
859 server=None, folder=None, username=None, password=None,
856 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
860 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
857
861
858 """
862 """
859
863
860 Input:
864 Input:
861 dataOut :
865 dataOut :
862 id :
866 id :
863 wintitle :
867 wintitle :
864 channelList :
868 channelList :
865 showProfile :
869 showProfile :
866 xmin : None,
870 xmin : None,
867 xmax : None,
871 xmax : None,
868 ymin : None,
872 ymin : None,
869 ymax : None,
873 ymax : None,
870 zmin : None,
874 zmin : None,
871 zmax : None
875 zmax : None
872 """
876 """
873
877
874 data_param = getattr(dataOut, parameterObject)
878 data_param = getattr(dataOut, parameterObject)
875
879
876 if channelList == None:
880 if channelList == None:
877 channelIndexList = numpy.arange(data_param.shape[0])
881 channelIndexList = numpy.arange(data_param.shape[0])
878 else:
882 else:
879 channelIndexList = numpy.array(channelList)
883 channelIndexList = numpy.array(channelList)
880
884
881 nchan = len(channelIndexList) #Number of channels being plotted
885 nchan = len(channelIndexList) #Number of channels being plotted
882
886
883 if nchan < 1:
887 if nchan < 1:
884 return
888 return
885
889
886 nGraphsByChannel = 0
890 nGraphsByChannel = 0
887
891
888 if SNR:
892 if SNR:
889 nGraphsByChannel += 1
893 nGraphsByChannel += 1
890 if DOP:
894 if DOP:
891 nGraphsByChannel += 1
895 nGraphsByChannel += 1
892
896
893 if nGraphsByChannel < 1:
897 if nGraphsByChannel < 1:
894 return
898 return
895
899
896 nplots = nGraphsByChannel*nchan
900 nplots = nGraphsByChannel*nchan
897
901
898 if timerange is not None:
902 if timerange is not None:
899 self.timerange = timerange
903 self.timerange = timerange
900
904
901 #tmin = None
905 #tmin = None
902 #tmax = None
906 #tmax = None
903 if parameterIndex == None:
907 if parameterIndex == None:
904 parameterIndex = 1
908 parameterIndex = 1
905
909
906 x = dataOut.getTimeRange1(dataOut.paramInterval)
910 x = dataOut.getTimeRange1(dataOut.paramInterval)
907 y = dataOut.heightList
911 y = dataOut.heightList
908 z = data_param[channelIndexList,parameterIndex,:].copy()
912 z = data_param[channelIndexList,parameterIndex,:].copy()
909
913
910 zRange = dataOut.abscissaList
914 zRange = dataOut.abscissaList
911 # nChannels = z.shape[0] #Number of wind dimensions estimated
915 # nChannels = z.shape[0] #Number of wind dimensions estimated
912 # thisDatetime = dataOut.datatime
916 # thisDatetime = dataOut.datatime
913
917
914 if dataOut.data_SNR is not None:
918 if dataOut.data_SNR is not None:
915 SNRarray = dataOut.data_SNR[channelIndexList,:]
919 SNRarray = dataOut.data_SNR[channelIndexList,:]
916 SNRdB = 10*numpy.log10(SNRarray)
920 SNRdB = 10*numpy.log10(SNRarray)
917 # SNRavgdB = 10*numpy.log10(SNRavg)
921 # SNRavgdB = 10*numpy.log10(SNRavg)
918 ind = numpy.where(SNRdB < 10**(SNRthresh/10))
922 ind = numpy.where(SNRdB < 10**(SNRthresh/10))
919 z[ind] = numpy.nan
923 z[ind] = numpy.nan
920
924
921 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
925 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
922 title = wintitle + " Parameters Plot" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
926 title = wintitle + " Parameters Plot" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
923 xlabel = ""
927 xlabel = ""
924 ylabel = "Range (Km)"
928 ylabel = "Range (Km)"
925
929
926 if (SNR and not onlySNR): nplots = 2*nplots
930 if (SNR and not onlySNR): nplots = 2*nplots
927
931
928 if onlyPositive:
932 if onlyPositive:
929 colormap = "jet"
933 colormap = "jet"
930 zmin = 0
934 zmin = 0
931 else: colormap = "RdBu_r"
935 else: colormap = "RdBu_r"
932
936
933 if not self.isConfig:
937 if not self.isConfig:
934
938
935 self.setup(id=id,
939 self.setup(id=id,
936 nplots=nplots,
940 nplots=nplots,
937 wintitle=wintitle,
941 wintitle=wintitle,
938 showprofile=showprofile,
942 showprofile=showprofile,
939 show=show)
943 show=show)
940
944
941 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
945 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
942
946
943 if ymin == None: ymin = numpy.nanmin(y)
947 if ymin == None: ymin = numpy.nanmin(y)
944 if ymax == None: ymax = numpy.nanmax(y)
948 if ymax == None: ymax = numpy.nanmax(y)
945 if zmin == None: zmin = numpy.nanmin(zRange)
949 if zmin == None: zmin = numpy.nanmin(zRange)
946 if zmax == None: zmax = numpy.nanmax(zRange)
950 if zmax == None: zmax = numpy.nanmax(zRange)
947
951
948 if SNR:
952 if SNR:
949 if SNRmin == None: SNRmin = numpy.nanmin(SNRdB)
953 if SNRmin == None: SNRmin = numpy.nanmin(SNRdB)
950 if SNRmax == None: SNRmax = numpy.nanmax(SNRdB)
954 if SNRmax == None: SNRmax = numpy.nanmax(SNRdB)
951
955
952 self.FTP_WEI = ftp_wei
956 self.FTP_WEI = ftp_wei
953 self.EXP_CODE = exp_code
957 self.EXP_CODE = exp_code
954 self.SUB_EXP_CODE = sub_exp_code
958 self.SUB_EXP_CODE = sub_exp_code
955 self.PLOT_POS = plot_pos
959 self.PLOT_POS = plot_pos
956
960
957 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
961 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
958 self.isConfig = True
962 self.isConfig = True
959 self.figfile = figfile
963 self.figfile = figfile
960
964
961 self.setWinTitle(title)
965 self.setWinTitle(title)
962
966
963 if ((self.xmax - x[1]) < (x[1]-x[0])):
967 if ((self.xmax - x[1]) < (x[1]-x[0])):
964 x[1] = self.xmax
968 x[1] = self.xmax
965
969
966 for i in range(nchan):
970 for i in range(nchan):
967
971
968 if (SNR and not onlySNR): j = 2*i
972 if (SNR and not onlySNR): j = 2*i
969 else: j = i
973 else: j = i
970
974
971 j = nGraphsByChannel*i
975 j = nGraphsByChannel*i
972
976
973 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
977 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
974 title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith)
978 title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith)
975
979
976 if not onlySNR:
980 if not onlySNR:
977 axes = self.axesList[j*self.__nsubplots]
981 axes = self.axesList[j*self.__nsubplots]
978 z1 = z[i,:].reshape((1,-1))
982 z1 = z[i,:].reshape((1,-1))
979 axes.pcolorbuffer(x, y, z1,
983 axes.pcolorbuffer(x, y, z1,
980 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
984 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
981 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap=colormap,
985 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap=colormap,
982 ticksize=9, cblabel=zlabel, cbsize="1%")
986 ticksize=9, cblabel=zlabel, cbsize="1%")
983
987
984 if DOP:
988 if DOP:
985 title = "%s Channel %d: %s" %(parameterName, channelIndexList[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
989 title = "%s Channel %d: %s" %(parameterName, channelIndexList[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
986
990
987 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
991 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
988 title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith)
992 title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith)
989 axes = self.axesList[j]
993 axes = self.axesList[j]
990 z1 = z[i,:].reshape((1,-1))
994 z1 = z[i,:].reshape((1,-1))
991 axes.pcolorbuffer(x, y, z1,
995 axes.pcolorbuffer(x, y, z1,
992 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
996 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
993 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap=colormap,
997 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap=colormap,
994 ticksize=9, cblabel=zlabel, cbsize="1%")
998 ticksize=9, cblabel=zlabel, cbsize="1%")
995
999
996 if SNR:
1000 if SNR:
997 title = "Channel %d Signal Noise Ratio (SNR): %s" %(channelIndexList[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1001 title = "Channel %d Signal Noise Ratio (SNR): %s" %(channelIndexList[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
998 axes = self.axesList[(j)*self.__nsubplots]
1002 axes = self.axesList[(j)*self.__nsubplots]
999 if not onlySNR:
1003 if not onlySNR:
1000 axes = self.axesList[(j + 1)*self.__nsubplots]
1004 axes = self.axesList[(j + 1)*self.__nsubplots]
1001
1005
1002 axes = self.axesList[(j + nGraphsByChannel-1)]
1006 axes = self.axesList[(j + nGraphsByChannel-1)]
1003
1007
1004 z1 = SNRdB[i,:].reshape((1,-1))
1008 z1 = SNRdB[i,:].reshape((1,-1))
1005 axes.pcolorbuffer(x, y, z1,
1009 axes.pcolorbuffer(x, y, z1,
1006 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
1010 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
1007 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap="jet",
1011 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap="jet",
1008 ticksize=9, cblabel=zlabel, cbsize="1%")
1012 ticksize=9, cblabel=zlabel, cbsize="1%")
1009
1013
1010
1014
1011
1015
1012 self.draw()
1016 self.draw()
1013
1017
1014 if x[1] >= self.axesList[0].xmax:
1018 if x[1] >= self.axesList[0].xmax:
1015 self.counter_imagwr = wr_period
1019 self.counter_imagwr = wr_period
1016 self.isConfig = False
1020 self.isConfig = False
1017 self.figfile = None
1021 self.figfile = None
1018
1022
1019 self.save(figpath=figpath,
1023 self.save(figpath=figpath,
1020 figfile=figfile,
1024 figfile=figfile,
1021 save=save,
1025 save=save,
1022 ftp=ftp,
1026 ftp=ftp,
1023 wr_period=wr_period,
1027 wr_period=wr_period,
1024 thisDatetime=thisDatetime,
1028 thisDatetime=thisDatetime,
1025 update_figfile=False)
1029 update_figfile=False)
1026
1030
1027 class SpectralFittingPlot(Figure):
1031 class SpectralFittingPlot(Figure):
1028
1032
1029 __isConfig = None
1033 __isConfig = None
1030 __nsubplots = None
1034 __nsubplots = None
1031
1035
1032 WIDTHPROF = None
1036 WIDTHPROF = None
1033 HEIGHTPROF = None
1037 HEIGHTPROF = None
1034 PREFIX = 'prm'
1038 PREFIX = 'prm'
1035
1039
1036
1040
1037 N = None
1041 N = None
1038 ippSeconds = None
1042 ippSeconds = None
1039
1043
1040 def __init__(self):
1044 def __init__(self):
1041 self.isConfig = False
1045 self.isConfig = False
1042 self.__nsubplots = 1
1046 self.__nsubplots = 1
1043
1047
1044 self.PLOT_CODE = SPECFIT_CODE
1048 self.PLOT_CODE = SPECFIT_CODE
1045
1049
1046 self.WIDTH = 450
1050 self.WIDTH = 450
1047 self.HEIGHT = 250
1051 self.HEIGHT = 250
1048 self.WIDTHPROF = 0
1052 self.WIDTHPROF = 0
1049 self.HEIGHTPROF = 0
1053 self.HEIGHTPROF = 0
1050
1054
1051 def getSubplots(self):
1055 def getSubplots(self):
1052
1056
1053 ncol = int(numpy.sqrt(self.nplots)+0.9)
1057 ncol = int(numpy.sqrt(self.nplots)+0.9)
1054 nrow = int(self.nplots*1./ncol + 0.9)
1058 nrow = int(self.nplots*1./ncol + 0.9)
1055
1059
1056 return nrow, ncol
1060 return nrow, ncol
1057
1061
1058 def setup(self, id, nplots, wintitle, showprofile=False, show=True):
1062 def setup(self, id, nplots, wintitle, showprofile=False, show=True):
1059
1063
1060 showprofile = False
1064 showprofile = False
1061 self.__showprofile = showprofile
1065 self.__showprofile = showprofile
1062 self.nplots = nplots
1066 self.nplots = nplots
1063
1067
1064 ncolspan = 5
1068 ncolspan = 5
1065 colspan = 4
1069 colspan = 4
1066 if showprofile:
1070 if showprofile:
1067 ncolspan = 5
1071 ncolspan = 5
1068 colspan = 4
1072 colspan = 4
1069 self.__nsubplots = 2
1073 self.__nsubplots = 2
1070
1074
1071 self.createFigure(id = id,
1075 self.createFigure(id = id,
1072 wintitle = wintitle,
1076 wintitle = wintitle,
1073 widthplot = self.WIDTH + self.WIDTHPROF,
1077 widthplot = self.WIDTH + self.WIDTHPROF,
1074 heightplot = self.HEIGHT + self.HEIGHTPROF,
1078 heightplot = self.HEIGHT + self.HEIGHTPROF,
1075 show=show)
1079 show=show)
1076
1080
1077 nrow, ncol = self.getSubplots()
1081 nrow, ncol = self.getSubplots()
1078
1082
1079 counter = 0
1083 counter = 0
1080 for y in range(nrow):
1084 for y in range(nrow):
1081 for x in range(ncol):
1085 for x in range(ncol):
1082
1086
1083 if counter >= self.nplots:
1087 if counter >= self.nplots:
1084 break
1088 break
1085
1089
1086 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
1090 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
1087
1091
1088 if showprofile:
1092 if showprofile:
1089 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
1093 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
1090
1094
1091 counter += 1
1095 counter += 1
1092
1096
1093 def run(self, dataOut, id, cutHeight=None, fit=False, wintitle="", channelList=None, showprofile=True,
1097 def run(self, dataOut, id, cutHeight=None, fit=False, wintitle="", channelList=None, showprofile=True,
1094 xmin=None, xmax=None, ymin=None, ymax=None,
1098 xmin=None, xmax=None, ymin=None, ymax=None,
1095 save=False, figpath='./', figfile=None, show=True):
1099 save=False, figpath='./', figfile=None, show=True):
1096
1100
1097 """
1101 """
1098
1102
1099 Input:
1103 Input:
1100 dataOut :
1104 dataOut :
1101 id :
1105 id :
1102 wintitle :
1106 wintitle :
1103 channelList :
1107 channelList :
1104 showProfile :
1108 showProfile :
1105 xmin : None,
1109 xmin : None,
1106 xmax : None,
1110 xmax : None,
1107 zmin : None,
1111 zmin : None,
1108 zmax : None
1112 zmax : None
1109 """
1113 """
1110
1114
1111 if cutHeight==None:
1115 if cutHeight==None:
1112 h=270
1116 h=270
1113 heightindex = numpy.abs(cutHeight - dataOut.heightList).argmin()
1117 heightindex = numpy.abs(cutHeight - dataOut.heightList).argmin()
1114 cutHeight = dataOut.heightList[heightindex]
1118 cutHeight = dataOut.heightList[heightindex]
1115
1119
1116 factor = dataOut.normFactor
1120 factor = dataOut.normFactor
1117 x = dataOut.abscissaList[:-1]
1121 x = dataOut.abscissaList[:-1]
1118 #y = dataOut.getHeiRange()
1122 #y = dataOut.getHeiRange()
1119
1123
1120 z = dataOut.data_pre[:,:,heightindex]/factor
1124 z = dataOut.data_pre[:,:,heightindex]/factor
1121 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
1125 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
1122 avg = numpy.average(z, axis=1)
1126 avg = numpy.average(z, axis=1)
1123 listChannels = z.shape[0]
1127 listChannels = z.shape[0]
1124
1128
1125 #Reconstruct Function
1129 #Reconstruct Function
1126 if fit==True:
1130 if fit==True:
1127 groupArray = dataOut.groupList
1131 groupArray = dataOut.groupList
1128 listChannels = groupArray.reshape((groupArray.size))
1132 listChannels = groupArray.reshape((groupArray.size))
1129 listChannels.sort()
1133 listChannels.sort()
1130 spcFitLine = numpy.zeros(z.shape)
1134 spcFitLine = numpy.zeros(z.shape)
1131 constants = dataOut.constants
1135 constants = dataOut.constants
1132
1136
1133 nGroups = groupArray.shape[0]
1137 nGroups = groupArray.shape[0]
1134 nChannels = groupArray.shape[1]
1138 nChannels = groupArray.shape[1]
1135 nProfiles = z.shape[1]
1139 nProfiles = z.shape[1]
1136
1140
1137 for f in range(nGroups):
1141 for f in range(nGroups):
1138 groupChann = groupArray[f,:]
1142 groupChann = groupArray[f,:]
1139 p = dataOut.data_param[f,:,heightindex]
1143 p = dataOut.data_param[f,:,heightindex]
1140 # p = numpy.array([ 89.343967,0.14036615,0.17086219,18.89835291,1.58388365,1.55099167])
1144 # p = numpy.array([ 89.343967,0.14036615,0.17086219,18.89835291,1.58388365,1.55099167])
1141 fitLineAux = dataOut.library.modelFunction(p, constants)*nProfiles
1145 fitLineAux = dataOut.library.modelFunction(p, constants)*nProfiles
1142 fitLineAux = fitLineAux.reshape((nChannels,nProfiles))
1146 fitLineAux = fitLineAux.reshape((nChannels,nProfiles))
1143 spcFitLine[groupChann,:] = fitLineAux
1147 spcFitLine[groupChann,:] = fitLineAux
1144 # spcFitLine = spcFitLine/factor
1148 # spcFitLine = spcFitLine/factor
1145
1149
1146 z = z[listChannels,:]
1150 z = z[listChannels,:]
1147 spcFitLine = spcFitLine[listChannels,:]
1151 spcFitLine = spcFitLine[listChannels,:]
1148 spcFitLinedB = 10*numpy.log10(spcFitLine)
1152 spcFitLinedB = 10*numpy.log10(spcFitLine)
1149
1153
1150 zdB = 10*numpy.log10(z)
1154 zdB = 10*numpy.log10(z)
1151 #thisDatetime = dataOut.datatime
1155 #thisDatetime = dataOut.datatime
1152 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
1156 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
1153 title = wintitle + " Doppler Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
1157 title = wintitle + " Doppler Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
1154 xlabel = "Velocity (m/s)"
1158 xlabel = "Velocity (m/s)"
1155 ylabel = "Spectrum"
1159 ylabel = "Spectrum"
1156
1160
1157 if not self.isConfig:
1161 if not self.isConfig:
1158
1162
1159 nplots = listChannels.size
1163 nplots = listChannels.size
1160
1164
1161 self.setup(id=id,
1165 self.setup(id=id,
1162 nplots=nplots,
1166 nplots=nplots,
1163 wintitle=wintitle,
1167 wintitle=wintitle,
1164 showprofile=showprofile,
1168 showprofile=showprofile,
1165 show=show)
1169 show=show)
1166
1170
1167 if xmin == None: xmin = numpy.nanmin(x)
1171 if xmin == None: xmin = numpy.nanmin(x)
1168 if xmax == None: xmax = numpy.nanmax(x)
1172 if xmax == None: xmax = numpy.nanmax(x)
1169 if ymin == None: ymin = numpy.nanmin(zdB)
1173 if ymin == None: ymin = numpy.nanmin(zdB)
1170 if ymax == None: ymax = numpy.nanmax(zdB)+2
1174 if ymax == None: ymax = numpy.nanmax(zdB)+2
1171
1175
1172 self.isConfig = True
1176 self.isConfig = True
1173
1177
1174 self.setWinTitle(title)
1178 self.setWinTitle(title)
1175 for i in range(self.nplots):
1179 for i in range(self.nplots):
1176 # title = "Channel %d: %4.2fdB" %(dataOut.channelList[i]+1, noisedB[i])
1180 # title = "Channel %d: %4.2fdB" %(dataOut.channelList[i]+1, noisedB[i])
1177 title = "Height %4.1f km\nChannel %d:" %(cutHeight, listChannels[i])
1181 title = "Height %4.1f km\nChannel %d:" %(cutHeight, listChannels[i])
1178 axes = self.axesList[i*self.__nsubplots]
1182 axes = self.axesList[i*self.__nsubplots]
1179 if fit == False:
1183 if fit == False:
1180 axes.pline(x, zdB[i,:],
1184 axes.pline(x, zdB[i,:],
1181 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
1185 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
1182 xlabel=xlabel, ylabel=ylabel, title=title
1186 xlabel=xlabel, ylabel=ylabel, title=title
1183 )
1187 )
1184 if fit == True:
1188 if fit == True:
1185 fitline=spcFitLinedB[i,:]
1189 fitline=spcFitLinedB[i,:]
1186 y=numpy.vstack([zdB[i,:],fitline] )
1190 y=numpy.vstack([zdB[i,:],fitline] )
1187 legendlabels=['Data','Fitting']
1191 legendlabels=['Data','Fitting']
1188 axes.pmultilineyaxis(x, y,
1192 axes.pmultilineyaxis(x, y,
1189 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
1193 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
1190 xlabel=xlabel, ylabel=ylabel, title=title,
1194 xlabel=xlabel, ylabel=ylabel, title=title,
1191 legendlabels=legendlabels, marker=None,
1195 legendlabels=legendlabels, marker=None,
1192 linestyle='solid', grid='both')
1196 linestyle='solid', grid='both')
1193
1197
1194 self.draw()
1198 self.draw()
1195
1199
1196 self.save(figpath=figpath,
1200 self.save(figpath=figpath,
1197 figfile=figfile,
1201 figfile=figfile,
1198 save=save,
1202 save=save,
1199 ftp=ftp,
1203 ftp=ftp,
1200 wr_period=wr_period,
1204 wr_period=wr_period,
1201 thisDatetime=thisDatetime)
1205 thisDatetime=thisDatetime)
1202
1206
1203
1207
1204 class EWDriftsPlot(Figure):
1208 class EWDriftsPlot(Figure):
1205
1209
1206 __isConfig = None
1210 __isConfig = None
1207 __nsubplots = None
1211 __nsubplots = None
1208
1212
1209 WIDTHPROF = None
1213 WIDTHPROF = None
1210 HEIGHTPROF = None
1214 HEIGHTPROF = None
1211 PREFIX = 'drift'
1215 PREFIX = 'drift'
1212
1216
1213 def __init__(self):
1217 def __init__(self):
1214
1218
1215 self.timerange = 2*60*60
1219 self.timerange = 2*60*60
1216 self.isConfig = False
1220 self.isConfig = False
1217 self.__nsubplots = 1
1221 self.__nsubplots = 1
1218
1222
1219 self.WIDTH = 800
1223 self.WIDTH = 800
1220 self.HEIGHT = 150
1224 self.HEIGHT = 150
1221 self.WIDTHPROF = 120
1225 self.WIDTHPROF = 120
1222 self.HEIGHTPROF = 0
1226 self.HEIGHTPROF = 0
1223 self.counter_imagwr = 0
1227 self.counter_imagwr = 0
1224
1228
1225 self.PLOT_CODE = EWDRIFT_CODE
1229 self.PLOT_CODE = EWDRIFT_CODE
1226
1230
1227 self.FTP_WEI = None
1231 self.FTP_WEI = None
1228 self.EXP_CODE = None
1232 self.EXP_CODE = None
1229 self.SUB_EXP_CODE = None
1233 self.SUB_EXP_CODE = None
1230 self.PLOT_POS = None
1234 self.PLOT_POS = None
1231 self.tmin = None
1235 self.tmin = None
1232 self.tmax = None
1236 self.tmax = None
1233
1237
1234 self.xmin = None
1238 self.xmin = None
1235 self.xmax = None
1239 self.xmax = None
1236
1240
1237 self.figfile = None
1241 self.figfile = None
1238
1242
1239 def getSubplots(self):
1243 def getSubplots(self):
1240
1244
1241 ncol = 1
1245 ncol = 1
1242 nrow = self.nplots
1246 nrow = self.nplots
1243
1247
1244 return nrow, ncol
1248 return nrow, ncol
1245
1249
1246 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1250 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1247
1251
1248 self.__showprofile = showprofile
1252 self.__showprofile = showprofile
1249 self.nplots = nplots
1253 self.nplots = nplots
1250
1254
1251 ncolspan = 1
1255 ncolspan = 1
1252 colspan = 1
1256 colspan = 1
1253
1257
1254 self.createFigure(id = id,
1258 self.createFigure(id = id,
1255 wintitle = wintitle,
1259 wintitle = wintitle,
1256 widthplot = self.WIDTH + self.WIDTHPROF,
1260 widthplot = self.WIDTH + self.WIDTHPROF,
1257 heightplot = self.HEIGHT + self.HEIGHTPROF,
1261 heightplot = self.HEIGHT + self.HEIGHTPROF,
1258 show=show)
1262 show=show)
1259
1263
1260 nrow, ncol = self.getSubplots()
1264 nrow, ncol = self.getSubplots()
1261
1265
1262 counter = 0
1266 counter = 0
1263 for y in range(nrow):
1267 for y in range(nrow):
1264 if counter >= self.nplots:
1268 if counter >= self.nplots:
1265 break
1269 break
1266
1270
1267 self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1)
1271 self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1)
1268 counter += 1
1272 counter += 1
1269
1273
1270 def run(self, dataOut, id, wintitle="", channelList=None,
1274 def run(self, dataOut, id, wintitle="", channelList=None,
1271 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
1275 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
1272 zmaxVertical = None, zminVertical = None, zmaxZonal = None, zminZonal = None,
1276 zmaxVertical = None, zminVertical = None, zmaxZonal = None, zminZonal = None,
1273 timerange=None, SNRthresh = -numpy.inf, SNRmin = None, SNRmax = None, SNR_1 = False,
1277 timerange=None, SNRthresh = -numpy.inf, SNRmin = None, SNRmax = None, SNR_1 = False,
1274 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
1278 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
1275 server=None, folder=None, username=None, password=None,
1279 server=None, folder=None, username=None, password=None,
1276 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1280 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1277 """
1281 """
1278
1282
1279 Input:
1283 Input:
1280 dataOut :
1284 dataOut :
1281 id :
1285 id :
1282 wintitle :
1286 wintitle :
1283 channelList :
1287 channelList :
1284 showProfile :
1288 showProfile :
1285 xmin : None,
1289 xmin : None,
1286 xmax : None,
1290 xmax : None,
1287 ymin : None,
1291 ymin : None,
1288 ymax : None,
1292 ymax : None,
1289 zmin : None,
1293 zmin : None,
1290 zmax : None
1294 zmax : None
1291 """
1295 """
1292
1296
1293 if timerange is not None:
1297 if timerange is not None:
1294 self.timerange = timerange
1298 self.timerange = timerange
1295
1299
1296 tmin = None
1300 tmin = None
1297 tmax = None
1301 tmax = None
1298
1302
1299 x = dataOut.getTimeRange1(dataOut.outputInterval)
1303 x = dataOut.getTimeRange1(dataOut.outputInterval)
1300 # y = dataOut.heightList
1304 # y = dataOut.heightList
1301 y = dataOut.heightList
1305 y = dataOut.heightList
1302
1306
1303 z = dataOut.data_output
1307 z = dataOut.data_output
1304 nplots = z.shape[0] #Number of wind dimensions estimated
1308 nplots = z.shape[0] #Number of wind dimensions estimated
1305 nplotsw = nplots
1309 nplotsw = nplots
1306
1310
1307 #If there is a SNR function defined
1311 #If there is a SNR function defined
1308 if dataOut.data_SNR is not None:
1312 if dataOut.data_SNR is not None:
1309 nplots += 1
1313 nplots += 1
1310 SNR = dataOut.data_SNR
1314 SNR = dataOut.data_SNR
1311
1315
1312 if SNR_1:
1316 if SNR_1:
1313 SNR += 1
1317 SNR += 1
1314
1318
1315 SNRavg = numpy.average(SNR, axis=0)
1319 SNRavg = numpy.average(SNR, axis=0)
1316
1320
1317 SNRdB = 10*numpy.log10(SNR)
1321 SNRdB = 10*numpy.log10(SNR)
1318 SNRavgdB = 10*numpy.log10(SNRavg)
1322 SNRavgdB = 10*numpy.log10(SNRavg)
1319
1323
1320 ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0]
1324 ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0]
1321
1325
1322 for i in range(nplotsw):
1326 for i in range(nplotsw):
1323 z[i,ind] = numpy.nan
1327 z[i,ind] = numpy.nan
1324
1328
1325
1329
1326 showprofile = False
1330 showprofile = False
1327 # thisDatetime = dataOut.datatime
1331 # thisDatetime = dataOut.datatime
1328 thisDatetime = datetime.datetime.utcfromtimestamp(x[1])
1332 thisDatetime = datetime.datetime.utcfromtimestamp(x[1])
1329 title = wintitle + " EW Drifts"
1333 title = wintitle + " EW Drifts"
1330 xlabel = ""
1334 xlabel = ""
1331 ylabel = "Height (Km)"
1335 ylabel = "Height (Km)"
1332
1336
1333 if not self.isConfig:
1337 if not self.isConfig:
1334
1338
1335 self.setup(id=id,
1339 self.setup(id=id,
1336 nplots=nplots,
1340 nplots=nplots,
1337 wintitle=wintitle,
1341 wintitle=wintitle,
1338 showprofile=showprofile,
1342 showprofile=showprofile,
1339 show=show)
1343 show=show)
1340
1344
1341 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1345 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1342
1346
1343 if ymin == None: ymin = numpy.nanmin(y)
1347 if ymin == None: ymin = numpy.nanmin(y)
1344 if ymax == None: ymax = numpy.nanmax(y)
1348 if ymax == None: ymax = numpy.nanmax(y)
1345
1349
1346 if zmaxZonal == None: zmaxZonal = numpy.nanmax(abs(z[0,:]))
1350 if zmaxZonal == None: zmaxZonal = numpy.nanmax(abs(z[0,:]))
1347 if zminZonal == None: zminZonal = -zmaxZonal
1351 if zminZonal == None: zminZonal = -zmaxZonal
1348 if zmaxVertical == None: zmaxVertical = numpy.nanmax(abs(z[1,:]))
1352 if zmaxVertical == None: zmaxVertical = numpy.nanmax(abs(z[1,:]))
1349 if zminVertical == None: zminVertical = -zmaxVertical
1353 if zminVertical == None: zminVertical = -zmaxVertical
1350
1354
1351 if dataOut.data_SNR is not None:
1355 if dataOut.data_SNR is not None:
1352 if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB)
1356 if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB)
1353 if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB)
1357 if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB)
1354
1358
1355 self.FTP_WEI = ftp_wei
1359 self.FTP_WEI = ftp_wei
1356 self.EXP_CODE = exp_code
1360 self.EXP_CODE = exp_code
1357 self.SUB_EXP_CODE = sub_exp_code
1361 self.SUB_EXP_CODE = sub_exp_code
1358 self.PLOT_POS = plot_pos
1362 self.PLOT_POS = plot_pos
1359
1363
1360 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1364 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1361 self.isConfig = True
1365 self.isConfig = True
1362
1366
1363
1367
1364 self.setWinTitle(title)
1368 self.setWinTitle(title)
1365
1369
1366 if ((self.xmax - x[1]) < (x[1]-x[0])):
1370 if ((self.xmax - x[1]) < (x[1]-x[0])):
1367 x[1] = self.xmax
1371 x[1] = self.xmax
1368
1372
1369 strWind = ['Zonal','Vertical']
1373 strWind = ['Zonal','Vertical']
1370 strCb = 'Velocity (m/s)'
1374 strCb = 'Velocity (m/s)'
1371 zmaxVector = [zmaxZonal, zmaxVertical]
1375 zmaxVector = [zmaxZonal, zmaxVertical]
1372 zminVector = [zminZonal, zminVertical]
1376 zminVector = [zminZonal, zminVertical]
1373
1377
1374 for i in range(nplotsw):
1378 for i in range(nplotsw):
1375
1379
1376 title = "%s Drifts: %s" %(strWind[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1380 title = "%s Drifts: %s" %(strWind[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1377 axes = self.axesList[i*self.__nsubplots]
1381 axes = self.axesList[i*self.__nsubplots]
1378
1382
1379 z1 = z[i,:].reshape((1,-1))
1383 z1 = z[i,:].reshape((1,-1))
1380
1384
1381 axes.pcolorbuffer(x, y, z1,
1385 axes.pcolorbuffer(x, y, z1,
1382 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zminVector[i], zmax=zmaxVector[i],
1386 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zminVector[i], zmax=zmaxVector[i],
1383 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1387 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1384 ticksize=9, cblabel=strCb, cbsize="1%", colormap="RdBu_r")
1388 ticksize=9, cblabel=strCb, cbsize="1%", colormap="RdBu_r")
1385
1389
1386 if dataOut.data_SNR is not None:
1390 if dataOut.data_SNR is not None:
1387 i += 1
1391 i += 1
1388 if SNR_1:
1392 if SNR_1:
1389 title = "Signal Noise Ratio + 1 (SNR+1): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1393 title = "Signal Noise Ratio + 1 (SNR+1): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1390 else:
1394 else:
1391 title = "Signal Noise Ratio (SNR): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1395 title = "Signal Noise Ratio (SNR): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1392 axes = self.axesList[i*self.__nsubplots]
1396 axes = self.axesList[i*self.__nsubplots]
1393 SNRavgdB = SNRavgdB.reshape((1,-1))
1397 SNRavgdB = SNRavgdB.reshape((1,-1))
1394
1398
1395 axes.pcolorbuffer(x, y, SNRavgdB,
1399 axes.pcolorbuffer(x, y, SNRavgdB,
1396 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
1400 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
1397 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1401 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1398 ticksize=9, cblabel='', cbsize="1%", colormap="jet")
1402 ticksize=9, cblabel='', cbsize="1%", colormap="jet")
1399
1403
1400 self.draw()
1404 self.draw()
1401
1405
1402 if x[1] >= self.axesList[0].xmax:
1406 if x[1] >= self.axesList[0].xmax:
1403 self.counter_imagwr = wr_period
1407 self.counter_imagwr = wr_period
1404 self.isConfig = False
1408 self.isConfig = False
1405 self.figfile = None
1409 self.figfile = None
1406
1410
1407
1411
1408
1412
1409
1413
1410 class PhasePlot(Figure):
1414 class PhasePlot(Figure):
1411
1415
1412 __isConfig = None
1416 __isConfig = None
1413 __nsubplots = None
1417 __nsubplots = None
1414
1418
1415 PREFIX = 'mphase'
1419 PREFIX = 'mphase'
1416
1420
1417 def __init__(self):
1421 def __init__(self):
1418
1422
1419 self.timerange = 24*60*60
1423 self.timerange = 24*60*60
1420 self.isConfig = False
1424 self.isConfig = False
1421 self.__nsubplots = 1
1425 self.__nsubplots = 1
1422 self.counter_imagwr = 0
1426 self.counter_imagwr = 0
1423 self.WIDTH = 600
1427 self.WIDTH = 600
1424 self.HEIGHT = 300
1428 self.HEIGHT = 300
1425 self.WIDTHPROF = 120
1429 self.WIDTHPROF = 120
1426 self.HEIGHTPROF = 0
1430 self.HEIGHTPROF = 0
1427 self.xdata = None
1431 self.xdata = None
1428 self.ydata = None
1432 self.ydata = None
1429
1433
1430 self.PLOT_CODE = MPHASE_CODE
1434 self.PLOT_CODE = MPHASE_CODE
1431
1435
1432 self.FTP_WEI = None
1436 self.FTP_WEI = None
1433 self.EXP_CODE = None
1437 self.EXP_CODE = None
1434 self.SUB_EXP_CODE = None
1438 self.SUB_EXP_CODE = None
1435 self.PLOT_POS = None
1439 self.PLOT_POS = None
1436
1440
1437
1441
1438 self.filename_phase = None
1442 self.filename_phase = None
1439
1443
1440 self.figfile = None
1444 self.figfile = None
1441
1445
1442 def getSubplots(self):
1446 def getSubplots(self):
1443
1447
1444 ncol = 1
1448 ncol = 1
1445 nrow = 1
1449 nrow = 1
1446
1450
1447 return nrow, ncol
1451 return nrow, ncol
1448
1452
1449 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1453 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1450
1454
1451 self.__showprofile = showprofile
1455 self.__showprofile = showprofile
1452 self.nplots = nplots
1456 self.nplots = nplots
1453
1457
1454 ncolspan = 7
1458 ncolspan = 7
1455 colspan = 6
1459 colspan = 6
1456 self.__nsubplots = 2
1460 self.__nsubplots = 2
1457
1461
1458 self.createFigure(id = id,
1462 self.createFigure(id = id,
1459 wintitle = wintitle,
1463 wintitle = wintitle,
1460 widthplot = self.WIDTH+self.WIDTHPROF,
1464 widthplot = self.WIDTH+self.WIDTHPROF,
1461 heightplot = self.HEIGHT+self.HEIGHTPROF,
1465 heightplot = self.HEIGHT+self.HEIGHTPROF,
1462 show=show)
1466 show=show)
1463
1467
1464 nrow, ncol = self.getSubplots()
1468 nrow, ncol = self.getSubplots()
1465
1469
1466 self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1)
1470 self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1)
1467
1471
1468
1472
1469 def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True',
1473 def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True',
1470 xmin=None, xmax=None, ymin=None, ymax=None,
1474 xmin=None, xmax=None, ymin=None, ymax=None,
1471 timerange=None,
1475 timerange=None,
1472 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1476 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1473 server=None, folder=None, username=None, password=None,
1477 server=None, folder=None, username=None, password=None,
1474 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1478 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1475
1479
1476
1480
1477 tmin = None
1481 tmin = None
1478 tmax = None
1482 tmax = None
1479 x = dataOut.getTimeRange1(dataOut.outputInterval)
1483 x = dataOut.getTimeRange1(dataOut.outputInterval)
1480 y = dataOut.getHeiRange()
1484 y = dataOut.getHeiRange()
1481
1485
1482
1486
1483 #thisDatetime = dataOut.datatime
1487 #thisDatetime = dataOut.datatime
1484 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1])
1488 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1])
1485 title = wintitle + " Phase of Beacon Signal" # : %s" %(thisDatetime.strftime("%d-%b-%Y"))
1489 title = wintitle + " Phase of Beacon Signal" # : %s" %(thisDatetime.strftime("%d-%b-%Y"))
1486 xlabel = "Local Time"
1490 xlabel = "Local Time"
1487 ylabel = "Phase"
1491 ylabel = "Phase"
1488
1492
1489
1493
1490 #phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList)))
1494 #phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList)))
1491 phase_beacon = dataOut.data_output
1495 phase_beacon = dataOut.data_output
1492 update_figfile = False
1496 update_figfile = False
1493
1497
1494 if not self.isConfig:
1498 if not self.isConfig:
1495
1499
1496 self.nplots = phase_beacon.size
1500 self.nplots = phase_beacon.size
1497
1501
1498 self.setup(id=id,
1502 self.setup(id=id,
1499 nplots=self.nplots,
1503 nplots=self.nplots,
1500 wintitle=wintitle,
1504 wintitle=wintitle,
1501 showprofile=showprofile,
1505 showprofile=showprofile,
1502 show=show)
1506 show=show)
1503
1507
1504 if timerange is not None:
1508 if timerange is not None:
1505 self.timerange = timerange
1509 self.timerange = timerange
1506
1510
1507 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1511 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1508
1512
1509 if ymin == None: ymin = numpy.nanmin(phase_beacon) - 10.0
1513 if ymin == None: ymin = numpy.nanmin(phase_beacon) - 10.0
1510 if ymax == None: ymax = numpy.nanmax(phase_beacon) + 10.0
1514 if ymax == None: ymax = numpy.nanmax(phase_beacon) + 10.0
1511
1515
1512 self.FTP_WEI = ftp_wei
1516 self.FTP_WEI = ftp_wei
1513 self.EXP_CODE = exp_code
1517 self.EXP_CODE = exp_code
1514 self.SUB_EXP_CODE = sub_exp_code
1518 self.SUB_EXP_CODE = sub_exp_code
1515 self.PLOT_POS = plot_pos
1519 self.PLOT_POS = plot_pos
1516
1520
1517 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1521 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1518 self.isConfig = True
1522 self.isConfig = True
1519 self.figfile = figfile
1523 self.figfile = figfile
1520 self.xdata = numpy.array([])
1524 self.xdata = numpy.array([])
1521 self.ydata = numpy.array([])
1525 self.ydata = numpy.array([])
1522
1526
1523 #open file beacon phase
1527 #open file beacon phase
1524 path = '%s%03d' %(self.PREFIX, self.id)
1528 path = '%s%03d' %(self.PREFIX, self.id)
1525 beacon_file = os.path.join(path,'%s.txt'%self.name)
1529 beacon_file = os.path.join(path,'%s.txt'%self.name)
1526 self.filename_phase = os.path.join(figpath,beacon_file)
1530 self.filename_phase = os.path.join(figpath,beacon_file)
1527 update_figfile = True
1531 update_figfile = True
1528
1532
1529
1533
1530 #store data beacon phase
1534 #store data beacon phase
1531 #self.save_data(self.filename_phase, phase_beacon, thisDatetime)
1535 #self.save_data(self.filename_phase, phase_beacon, thisDatetime)
1532
1536
1533 self.setWinTitle(title)
1537 self.setWinTitle(title)
1534
1538
1535
1539
1536 title = "Phase Offset %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1540 title = "Phase Offset %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1537
1541
1538 legendlabels = ["phase %d"%(chan) for chan in numpy.arange(self.nplots)]
1542 legendlabels = ["phase %d"%(chan) for chan in numpy.arange(self.nplots)]
1539
1543
1540 axes = self.axesList[0]
1544 axes = self.axesList[0]
1541
1545
1542 self.xdata = numpy.hstack((self.xdata, x[0:1]))
1546 self.xdata = numpy.hstack((self.xdata, x[0:1]))
1543
1547
1544 if len(self.ydata)==0:
1548 if len(self.ydata)==0:
1545 self.ydata = phase_beacon.reshape(-1,1)
1549 self.ydata = phase_beacon.reshape(-1,1)
1546 else:
1550 else:
1547 self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1)))
1551 self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1)))
1548
1552
1549
1553
1550 axes.pmultilineyaxis(x=self.xdata, y=self.ydata,
1554 axes.pmultilineyaxis(x=self.xdata, y=self.ydata,
1551 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax,
1555 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax,
1552 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid",
1556 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid",
1553 XAxisAsTime=True, grid='both'
1557 XAxisAsTime=True, grid='both'
1554 )
1558 )
1555
1559
1556 self.draw()
1560 self.draw()
1557
1561
1558 if dataOut.ltctime >= self.xmax:
1562 if dataOut.ltctime >= self.xmax:
1559 self.counter_imagwr = wr_period
1563 self.counter_imagwr = wr_period
1560 self.isConfig = False
1564 self.isConfig = False
1561 update_figfile = True
1565 update_figfile = True
1562
1566
1563 self.save(figpath=figpath,
1567 self.save(figpath=figpath,
1564 figfile=figfile,
1568 figfile=figfile,
1565 save=save,
1569 save=save,
1566 ftp=ftp,
1570 ftp=ftp,
1567 wr_period=wr_period,
1571 wr_period=wr_period,
1568 thisDatetime=thisDatetime,
1572 thisDatetime=thisDatetime,
1569 update_figfile=update_figfile)
1573 update_figfile=update_figfile)
1574
1575
1576 class NSMeteorDetection1Plot(Figure):
1577
1578 isConfig = None
1579 __nsubplots = None
1580
1581 WIDTHPROF = None
1582 HEIGHTPROF = None
1583 PREFIX = 'nsm'
1584
1585 zminList = None
1586 zmaxList = None
1587 cmapList = None
1588 titleList = None
1589 nPairs = None
1590 nChannels = None
1591 nParam = None
1592
1593 def __init__(self):
1594
1595 self.isConfig = False
1596 self.__nsubplots = 1
1597
1598 self.WIDTH = 750
1599 self.HEIGHT = 250
1600 self.WIDTHPROF = 120
1601 self.HEIGHTPROF = 0
1602 self.counter_imagwr = 0
1603
1604 self.PLOT_CODE = SPEC_CODE
1605
1606 self.FTP_WEI = None
1607 self.EXP_CODE = None
1608 self.SUB_EXP_CODE = None
1609 self.PLOT_POS = None
1610
1611 self.__xfilter_ena = False
1612 self.__yfilter_ena = False
1613
1614 def getSubplots(self):
1615
1616 ncol = 3
1617 nrow = int(numpy.ceil(self.nplots/3.0))
1618
1619 return nrow, ncol
1620
1621 def setup(self, id, nplots, wintitle, show=True):
1622
1623 self.nplots = nplots
1624
1625 ncolspan = 1
1626 colspan = 1
1627
1628 self.createFigure(id = id,
1629 wintitle = wintitle,
1630 widthplot = self.WIDTH + self.WIDTHPROF,
1631 heightplot = self.HEIGHT + self.HEIGHTPROF,
1632 show=show)
1633
1634 nrow, ncol = self.getSubplots()
1635
1636 counter = 0
1637 for y in range(nrow):
1638 for x in range(ncol):
1639
1640 if counter >= self.nplots:
1641 break
1642
1643 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
1644
1645 counter += 1
1646
1647 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True,
1648 xmin=None, xmax=None, ymin=None, ymax=None, SNRmin=None, SNRmax=None,
1649 vmin=None, vmax=None, wmin=None, wmax=None, mode = 'SA',
1650 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1651 server=None, folder=None, username=None, password=None,
1652 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False,
1653 xaxis="frequency"):
1654
1655 """
1656
1657 Input:
1658 dataOut :
1659 id :
1660 wintitle :
1661 channelList :
1662 showProfile :
1663 xmin : None,
1664 xmax : None,
1665 ymin : None,
1666 ymax : None,
1667 zmin : None,
1668 zmax : None
1669 """
1670 #SEPARAR EN DOS PLOTS
1671 nParam = dataOut.data_param.shape[1] - 3
1672
1673 utctime = dataOut.data_param[0,0]
1674 tmet = dataOut.data_param[:,1].astype(int)
1675 hmet = dataOut.data_param[:,2].astype(int)
1676
1677 x = dataOut.abscissaList
1678 y = dataOut.heightList
1679
1680 z = numpy.zeros((nParam, y.size, x.size - 1))
1681 z[:,:] = numpy.nan
1682 z[:,hmet,tmet] = dataOut.data_param[:,3:].T
1683 z[0,:,:] = 10*numpy.log10(z[0,:,:])
1684
1685 xlabel = "Time (s)"
1686 ylabel = "Range (km)"
1687
1688 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime)
1689
1690 if not self.isConfig:
1691
1692 nplots = nParam
1693
1694 self.setup(id=id,
1695 nplots=nplots,
1696 wintitle=wintitle,
1697 show=show)
1698
1699 if xmin is None: xmin = numpy.nanmin(x)
1700 if xmax is None: xmax = numpy.nanmax(x)
1701 if ymin is None: ymin = numpy.nanmin(y)
1702 if ymax is None: ymax = numpy.nanmax(y)
1703 if SNRmin is None: SNRmin = numpy.nanmin(z[0,:])
1704 if SNRmax is None: SNRmax = numpy.nanmax(z[0,:])
1705 if vmax is None: vmax = numpy.nanmax(numpy.abs(z[1,:]))
1706 if vmin is None: vmin = -vmax
1707 if wmin is None: wmin = 0
1708 if wmax is None: wmax = 50
1709
1710 pairsList = dataOut.groupList
1711 self.nPairs = len(dataOut.groupList)
1712
1713 zminList = [SNRmin, vmin, cmin] + [pmin]*self.nPairs
1714 zmaxList = [SNRmax, vmax, cmax] + [pmax]*self.nPairs
1715 titleList = ["SNR","Radial Velocity","Coherence"]
1716 cmapList = ["jet","RdBu_r","jet"]
1717
1718 for i in range(self.nPairs):
1719 strAux1 = "Phase Difference "+ str(pairsList[i][0]) + str(pairsList[i][1])
1720 titleList = titleList + [strAux1]
1721 cmapList = cmapList + ["RdBu_r"]
1722
1723 self.zminList = zminList
1724 self.zmaxList = zmaxList
1725 self.cmapList = cmapList
1726 self.titleList = titleList
1727
1728 self.FTP_WEI = ftp_wei
1729 self.EXP_CODE = exp_code
1730 self.SUB_EXP_CODE = sub_exp_code
1731 self.PLOT_POS = plot_pos
1732
1733 self.isConfig = True
1734
1735 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
1736
1737 for i in range(nParam):
1738 title = self.titleList[i] + ": " +str_datetime
1739 axes = self.axesList[i]
1740 axes.pcolor(x, y, z[i,:].T,
1741 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=self.zminList[i], zmax=self.zmaxList[i],
1742 xlabel=xlabel, ylabel=ylabel, title=title, colormap=self.cmapList[i],ticksize=9, cblabel='')
1743 self.draw()
1744
1745 if figfile == None:
1746 str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S")
1747 name = str_datetime
1748 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
1749 name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith)
1750 figfile = self.getFilename(name)
1751
1752 self.save(figpath=figpath,
1753 figfile=figfile,
1754 save=save,
1755 ftp=ftp,
1756 wr_period=wr_period,
1757 thisDatetime=thisDatetime)
1758
1759
1760 class NSMeteorDetection2Plot(Figure):
1761
1762 isConfig = None
1763 __nsubplots = None
1764
1765 WIDTHPROF = None
1766 HEIGHTPROF = None
1767 PREFIX = 'nsm'
1768
1769 zminList = None
1770 zmaxList = None
1771 cmapList = None
1772 titleList = None
1773 nPairs = None
1774 nChannels = None
1775 nParam = None
1776
1777 def __init__(self):
1778
1779 self.isConfig = False
1780 self.__nsubplots = 1
1781
1782 self.WIDTH = 750
1783 self.HEIGHT = 250
1784 self.WIDTHPROF = 120
1785 self.HEIGHTPROF = 0
1786 self.counter_imagwr = 0
1787
1788 self.PLOT_CODE = SPEC_CODE
1789
1790 self.FTP_WEI = None
1791 self.EXP_CODE = None
1792 self.SUB_EXP_CODE = None
1793 self.PLOT_POS = None
1794
1795 self.__xfilter_ena = False
1796 self.__yfilter_ena = False
1797
1798 def getSubplots(self):
1799
1800 ncol = 3
1801 nrow = int(numpy.ceil(self.nplots/3.0))
1802
1803 return nrow, ncol
1804
1805 def setup(self, id, nplots, wintitle, show=True):
1806
1807 self.nplots = nplots
1808
1809 ncolspan = 1
1810 colspan = 1
1811
1812 self.createFigure(id = id,
1813 wintitle = wintitle,
1814 widthplot = self.WIDTH + self.WIDTHPROF,
1815 heightplot = self.HEIGHT + self.HEIGHTPROF,
1816 show=show)
1817
1818 nrow, ncol = self.getSubplots()
1819
1820 counter = 0
1821 for y in range(nrow):
1822 for x in range(ncol):
1823
1824 if counter >= self.nplots:
1825 break
1826
1827 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
1828
1829 counter += 1
1830
1831 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True,
1832 xmin=None, xmax=None, ymin=None, ymax=None, SNRmin=None, SNRmax=None,
1833 vmin=None, vmax=None, wmin=None, wmax=None, mode = 'SA',
1834 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1835 server=None, folder=None, username=None, password=None,
1836 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False,
1837 xaxis="frequency"):
1838
1839 """
1840
1841 Input:
1842 dataOut :
1843 id :
1844 wintitle :
1845 channelList :
1846 showProfile :
1847 xmin : None,
1848 xmax : None,
1849 ymin : None,
1850 ymax : None,
1851 zmin : None,
1852 zmax : None
1853 """
1854 #Rebuild matrix
1855 utctime = dataOut.data_param[0,0]
1856 cmet = dataOut.data_param[:,1].astype(int)
1857 tmet = dataOut.data_param[:,2].astype(int)
1858 hmet = dataOut.data_param[:,3].astype(int)
1859
1860 nParam = 3
1861 nChan = len(dataOut.groupList)
1862 x = dataOut.abscissaList
1863 y = dataOut.heightList
1864
1865 z = numpy.full((nChan, nParam, y.size, x.size - 1),numpy.nan)
1866 z[cmet,:,hmet,tmet] = dataOut.data_param[:,4:]
1867 z[:,0,:,:] = 10*numpy.log10(z[:,0,:,:]) #logarithmic scale
1868 z = numpy.reshape(z, (nChan*nParam, y.size, x.size-1))
1869
1870 xlabel = "Time (s)"
1871 ylabel = "Range (km)"
1872
1873 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime)
1874
1875 if not self.isConfig:
1876
1877 nplots = nParam*nChan
1878
1879 self.setup(id=id,
1880 nplots=nplots,
1881 wintitle=wintitle,
1882 show=show)
1883
1884 if xmin is None: xmin = numpy.nanmin(x)
1885 if xmax is None: xmax = numpy.nanmax(x)
1886 if ymin is None: ymin = numpy.nanmin(y)
1887 if ymax is None: ymax = numpy.nanmax(y)
1888 if SNRmin is None: SNRmin = numpy.nanmin(z[0,:])
1889 if SNRmax is None: SNRmax = numpy.nanmax(z[0,:])
1890 if vmax is None: vmax = numpy.nanmax(numpy.abs(z[1,:]))
1891 if vmin is None: vmin = -vmax
1892 if wmin is None: wmin = 0
1893 if wmax is None: wmax = 50
1894
1895 self.nChannels = nChan
1896
1897 zminList = []
1898 zmaxList = []
1899 titleList = []
1900 cmapList = []
1901 for i in range(self.nChannels):
1902 strAux1 = "SNR Channel "+ str(i)
1903 strAux2 = "Radial Velocity Channel "+ str(i)
1904 strAux3 = "Spectral Width Channel "+ str(i)
1905
1906 titleList = titleList + [strAux1,strAux2,strAux3]
1907 cmapList = cmapList + ["jet","RdBu_r","jet"]
1908 zminList = zminList + [SNRmin,vmin,wmin]
1909 zmaxList = zmaxList + [SNRmax,vmax,wmax]
1910
1911 self.zminList = zminList
1912 self.zmaxList = zmaxList
1913 self.cmapList = cmapList
1914 self.titleList = titleList
1915
1916 self.FTP_WEI = ftp_wei
1917 self.EXP_CODE = exp_code
1918 self.SUB_EXP_CODE = sub_exp_code
1919 self.PLOT_POS = plot_pos
1920
1921 self.isConfig = True
1922
1923 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
1924
1925 for i in range(self.nplots):
1926 title = self.titleList[i] + ": " +str_datetime
1927 axes = self.axesList[i]
1928 axes.pcolor(x, y, z[i,:].T,
1929 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=self.zminList[i], zmax=self.zmaxList[i],
1930 xlabel=xlabel, ylabel=ylabel, title=title, colormap=self.cmapList[i],ticksize=9, cblabel='')
1931 self.draw()
1932
1933 if figfile == None:
1934 str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S")
1935 name = str_datetime
1936 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
1937 name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith)
1938 figfile = self.getFilename(name)
1939
1940 self.save(figpath=figpath,
1941 figfile=figfile,
1942 save=save,
1943 ftp=ftp,
1944 wr_period=wr_period,
1945 thisDatetime=thisDatetime)
1946
1947
General Comments 0
You need to be logged in to leave comments. Login now