##// END OF EJS Templates
Bug fixed when plot changed from one day to the next
Julio Valdez -
r852:997c2d76e6fd
parent child
Show More
@@ -1,1947 +1,1949
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 = 300
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 = "Height (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:
557 self.counter_imagwr = wr_period
558 self.isConfig = False
559 update_figfile = True
560
561 self.save(figpath=figpath,
556 self.save(figpath=figpath,
562 figfile=figfile,
557 figfile=figfile,
563 save=save,
558 save=save,
564 ftp=ftp,
559 ftp=ftp,
565 wr_period=wr_period,
560 wr_period=wr_period,
566 thisDatetime=thisDatetime,
561 thisDatetime=thisDatetime,
567 update_figfile=update_figfile)
562 update_figfile=update_figfile)
568
563
564 if dataOut.ltctime + dataOut.outputInterval >= self.xmax:
565 self.counter_imagwr = wr_period
566 self.isConfig = False
567 update_figfile = True
568
569
569 class ParametersPlot(Figure):
570 class ParametersPlot(Figure):
570
571
571 __isConfig = None
572 __isConfig = None
572 __nsubplots = None
573 __nsubplots = None
573
574
574 WIDTHPROF = None
575 WIDTHPROF = None
575 HEIGHTPROF = None
576 HEIGHTPROF = None
576 PREFIX = 'param'
577 PREFIX = 'param'
577
578
578 nplots = None
579 nplots = None
579 nchan = None
580 nchan = None
580
581
581 def __init__(self):
582 def __init__(self):
582
583
583 self.timerange = None
584 self.timerange = None
584 self.isConfig = False
585 self.isConfig = False
585 self.__nsubplots = 1
586 self.__nsubplots = 1
586
587
587 self.WIDTH = 800
588 self.WIDTH = 800
588 self.HEIGHT = 180
589 self.HEIGHT = 180
589 self.WIDTHPROF = 120
590 self.WIDTHPROF = 120
590 self.HEIGHTPROF = 0
591 self.HEIGHTPROF = 0
591 self.counter_imagwr = 0
592 self.counter_imagwr = 0
592
593
593 self.PLOT_CODE = RTI_CODE
594 self.PLOT_CODE = RTI_CODE
594
595
595 self.FTP_WEI = None
596 self.FTP_WEI = None
596 self.EXP_CODE = None
597 self.EXP_CODE = None
597 self.SUB_EXP_CODE = None
598 self.SUB_EXP_CODE = None
598 self.PLOT_POS = None
599 self.PLOT_POS = None
599 self.tmin = None
600 self.tmin = None
600 self.tmax = None
601 self.tmax = None
601
602
602 self.xmin = None
603 self.xmin = None
603 self.xmax = None
604 self.xmax = None
604
605
605 self.figfile = None
606 self.figfile = None
606
607
607 def getSubplots(self):
608 def getSubplots(self):
608
609
609 ncol = 1
610 ncol = 1
610 nrow = self.nplots
611 nrow = self.nplots
611
612
612 return nrow, ncol
613 return nrow, ncol
613
614
614 def setup(self, id, nplots, wintitle, show=True):
615 def setup(self, id, nplots, wintitle, show=True):
615
616
616 self.nplots = nplots
617 self.nplots = nplots
617
618
618 ncolspan = 1
619 ncolspan = 1
619 colspan = 1
620 colspan = 1
620
621
621 self.createFigure(id = id,
622 self.createFigure(id = id,
622 wintitle = wintitle,
623 wintitle = wintitle,
623 widthplot = self.WIDTH + self.WIDTHPROF,
624 widthplot = self.WIDTH + self.WIDTHPROF,
624 heightplot = self.HEIGHT + self.HEIGHTPROF,
625 heightplot = self.HEIGHT + self.HEIGHTPROF,
625 show=show)
626 show=show)
626
627
627 nrow, ncol = self.getSubplots()
628 nrow, ncol = self.getSubplots()
628
629
629 counter = 0
630 counter = 0
630 for y in range(nrow):
631 for y in range(nrow):
631 for x in range(ncol):
632 for x in range(ncol):
632
633
633 if counter >= self.nplots:
634 if counter >= self.nplots:
634 break
635 break
635
636
636 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
637 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
637
638
638 counter += 1
639 counter += 1
639
640
640 def run(self, dataOut, id, wintitle="", channelList=None, paramIndex = 0, colormap=True,
641 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,
642 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, timerange=None,
642 showSNR=False, SNRthresh = -numpy.inf, SNRmin=None, SNRmax=None,
643 showSNR=False, SNRthresh = -numpy.inf, SNRmin=None, SNRmax=None,
643 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
644 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
644 server=None, folder=None, username=None, password=None,
645 server=None, folder=None, username=None, password=None,
645 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
646 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
646
647
647 """
648 """
648
649
649 Input:
650 Input:
650 dataOut :
651 dataOut :
651 id :
652 id :
652 wintitle :
653 wintitle :
653 channelList :
654 channelList :
654 showProfile :
655 showProfile :
655 xmin : None,
656 xmin : None,
656 xmax : None,
657 xmax : None,
657 ymin : None,
658 ymin : None,
658 ymax : None,
659 ymax : None,
659 zmin : None,
660 zmin : None,
660 zmax : None
661 zmax : None
661 """
662 """
662
663
663 if colormap:
664 if colormap:
664 colormap="jet"
665 colormap="jet"
665 else:
666 else:
666 colormap="RdBu_r"
667 colormap="RdBu_r"
667
668
668 if not isTimeInHourRange(dataOut.datatime, xmin, xmax):
669 if not isTimeInHourRange(dataOut.datatime, xmin, xmax):
669 return
670 return
670
671
671 if channelList == None:
672 if channelList == None:
672 channelIndexList = range(dataOut.data_param.shape[0])
673 channelIndexList = range(dataOut.data_param.shape[0])
673 else:
674 else:
674 channelIndexList = []
675 channelIndexList = []
675 for channel in channelList:
676 for channel in channelList:
676 if channel not in dataOut.channelList:
677 if channel not in dataOut.channelList:
677 raise ValueError, "Channel %d is not in dataOut.channelList"
678 raise ValueError, "Channel %d is not in dataOut.channelList"
678 channelIndexList.append(dataOut.channelList.index(channel))
679 channelIndexList.append(dataOut.channelList.index(channel))
679
680
680 x = dataOut.getTimeRange1(dataOut.paramInterval)
681 x = dataOut.getTimeRange1(dataOut.paramInterval)
681 y = dataOut.getHeiRange()
682 y = dataOut.getHeiRange()
682
683
683 if dataOut.data_param.ndim == 3:
684 if dataOut.data_param.ndim == 3:
684 z = dataOut.data_param[channelIndexList,paramIndex,:]
685 z = dataOut.data_param[channelIndexList,paramIndex,:]
685 else:
686 else:
686 z = dataOut.data_param[channelIndexList,:]
687 z = dataOut.data_param[channelIndexList,:]
687
688
688 if showSNR:
689 if showSNR:
689 #SNR data
690 #SNR data
690 SNRarray = dataOut.data_SNR[channelIndexList,:]
691 SNRarray = dataOut.data_SNR[channelIndexList,:]
691 SNRdB = 10*numpy.log10(SNRarray)
692 SNRdB = 10*numpy.log10(SNRarray)
692 ind = numpy.where(SNRdB < SNRthresh)
693 ind = numpy.where(SNRdB < SNRthresh)
693 z[ind] = numpy.nan
694 z[ind] = numpy.nan
694
695
695 thisDatetime = dataOut.datatime
696 thisDatetime = dataOut.datatime
696 # thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
697 # thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
697 title = wintitle + " Parameters Plot" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
698 title = wintitle + " Parameters Plot" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
698 xlabel = ""
699 xlabel = ""
699 ylabel = "Range (Km)"
700 ylabel = "Range (Km)"
700
701
701 update_figfile = False
702 update_figfile = False
702
703
703 if not self.isConfig:
704 if not self.isConfig:
704
705
705 nchan = len(channelIndexList)
706 nchan = len(channelIndexList)
706 self.nchan = nchan
707 self.nchan = nchan
707 self.plotFact = 1
708 self.plotFact = 1
708 nplots = nchan
709 nplots = nchan
709
710
710 if showSNR:
711 if showSNR:
711 nplots = nchan*2
712 nplots = nchan*2
712 self.plotFact = 2
713 self.plotFact = 2
713 if SNRmin == None: SNRmin = numpy.nanmin(SNRdB)
714 if SNRmin == None: SNRmin = numpy.nanmin(SNRdB)
714 if SNRmax == None: SNRmax = numpy.nanmax(SNRdB)
715 if SNRmax == None: SNRmax = numpy.nanmax(SNRdB)
715
716
716 self.setup(id=id,
717 self.setup(id=id,
717 nplots=nplots,
718 nplots=nplots,
718 wintitle=wintitle,
719 wintitle=wintitle,
719 show=show)
720 show=show)
720
721
721 if timerange != None:
722 if timerange != None:
722 self.timerange = timerange
723 self.timerange = timerange
723
724
724 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
725 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
725
726
726 if ymin == None: ymin = numpy.nanmin(y)
727 if ymin == None: ymin = numpy.nanmin(y)
727 if ymax == None: ymax = numpy.nanmax(y)
728 if ymax == None: ymax = numpy.nanmax(y)
728 if zmin == None: zmin = numpy.nanmin(z)
729 if zmin == None: zmin = numpy.nanmin(z)
729 if zmax == None: zmax = numpy.nanmax(z)
730 if zmax == None: zmax = numpy.nanmax(z)
730
731
731 self.FTP_WEI = ftp_wei
732 self.FTP_WEI = ftp_wei
732 self.EXP_CODE = exp_code
733 self.EXP_CODE = exp_code
733 self.SUB_EXP_CODE = sub_exp_code
734 self.SUB_EXP_CODE = sub_exp_code
734 self.PLOT_POS = plot_pos
735 self.PLOT_POS = plot_pos
735
736
736 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
737 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
737 self.isConfig = True
738 self.isConfig = True
738 self.figfile = figfile
739 self.figfile = figfile
739 update_figfile = True
740 update_figfile = True
740
741
741 self.setWinTitle(title)
742 self.setWinTitle(title)
742
743
743 for i in range(self.nchan):
744 for i in range(self.nchan):
744 index = channelIndexList[i]
745 index = channelIndexList[i]
745 title = "Channel %d: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
746 title = "Channel %d: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
746 axes = self.axesList[i*self.plotFact]
747 axes = self.axesList[i*self.plotFact]
747 z1 = z[i,:].reshape((1,-1))
748 z1 = z[i,:].reshape((1,-1))
748 axes.pcolorbuffer(x, y, z1,
749 axes.pcolorbuffer(x, y, z1,
749 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
750 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
750 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
751 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
751 ticksize=9, cblabel='', cbsize="1%",colormap=colormap)
752 ticksize=9, cblabel='', cbsize="1%",colormap=colormap)
752
753
753 if showSNR:
754 if showSNR:
754 title = "Channel %d SNR: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
755 title = "Channel %d SNR: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
755 axes = self.axesList[i*self.plotFact + 1]
756 axes = self.axesList[i*self.plotFact + 1]
756 SNRdB1 = SNRdB[i,:].reshape((1,-1))
757 SNRdB1 = SNRdB[i,:].reshape((1,-1))
757 axes.pcolorbuffer(x, y, SNRdB1,
758 axes.pcolorbuffer(x, y, SNRdB1,
758 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
759 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
759 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
760 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
760 ticksize=9, cblabel='', cbsize="1%",colormap='jet')
761 ticksize=9, cblabel='', cbsize="1%",colormap='jet')
761
762
762
763
763 self.draw()
764 self.draw()
764
765
765 if dataOut.ltctime >= self.xmax:
766 if dataOut.ltctime >= self.xmax:
766 self.counter_imagwr = wr_period
767 self.counter_imagwr = wr_period
767 self.isConfig = False
768 self.isConfig = False
768 update_figfile = True
769 update_figfile = True
769
770
770 self.save(figpath=figpath,
771 self.save(figpath=figpath,
771 figfile=figfile,
772 figfile=figfile,
772 save=save,
773 save=save,
773 ftp=ftp,
774 ftp=ftp,
774 wr_period=wr_period,
775 wr_period=wr_period,
775 thisDatetime=thisDatetime,
776 thisDatetime=thisDatetime,
776 update_figfile=update_figfile)
777 update_figfile=update_figfile)
777
778
778
779
779
780
780 class Parameters1Plot(Figure):
781 class Parameters1Plot(Figure):
781
782
782 __isConfig = None
783 __isConfig = None
783 __nsubplots = None
784 __nsubplots = None
784
785
785 WIDTHPROF = None
786 WIDTHPROF = None
786 HEIGHTPROF = None
787 HEIGHTPROF = None
787 PREFIX = 'prm'
788 PREFIX = 'prm'
788
789
789 def __init__(self):
790 def __init__(self):
790
791
791 self.timerange = 2*60*60
792 self.timerange = 2*60*60
792 self.isConfig = False
793 self.isConfig = False
793 self.__nsubplots = 1
794 self.__nsubplots = 1
794
795
795 self.WIDTH = 800
796 self.WIDTH = 800
796 self.HEIGHT = 150
797 self.HEIGHT = 150
797 self.WIDTHPROF = 120
798 self.WIDTHPROF = 120
798 self.HEIGHTPROF = 0
799 self.HEIGHTPROF = 0
799 self.counter_imagwr = 0
800 self.counter_imagwr = 0
800
801
801 self.PLOT_CODE = PARMS_CODE
802 self.PLOT_CODE = PARMS_CODE
802
803
803 self.FTP_WEI = None
804 self.FTP_WEI = None
804 self.EXP_CODE = None
805 self.EXP_CODE = None
805 self.SUB_EXP_CODE = None
806 self.SUB_EXP_CODE = None
806 self.PLOT_POS = None
807 self.PLOT_POS = None
807 self.tmin = None
808 self.tmin = None
808 self.tmax = None
809 self.tmax = None
809
810
810 self.xmin = None
811 self.xmin = None
811 self.xmax = None
812 self.xmax = None
812
813
813 self.figfile = None
814 self.figfile = None
814
815
815 def getSubplots(self):
816 def getSubplots(self):
816
817
817 ncol = 1
818 ncol = 1
818 nrow = self.nplots
819 nrow = self.nplots
819
820
820 return nrow, ncol
821 return nrow, ncol
821
822
822 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
823 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
823
824
824 self.__showprofile = showprofile
825 self.__showprofile = showprofile
825 self.nplots = nplots
826 self.nplots = nplots
826
827
827 ncolspan = 1
828 ncolspan = 1
828 colspan = 1
829 colspan = 1
829
830
830 self.createFigure(id = id,
831 self.createFigure(id = id,
831 wintitle = wintitle,
832 wintitle = wintitle,
832 widthplot = self.WIDTH + self.WIDTHPROF,
833 widthplot = self.WIDTH + self.WIDTHPROF,
833 heightplot = self.HEIGHT + self.HEIGHTPROF,
834 heightplot = self.HEIGHT + self.HEIGHTPROF,
834 show=show)
835 show=show)
835
836
836 nrow, ncol = self.getSubplots()
837 nrow, ncol = self.getSubplots()
837
838
838 counter = 0
839 counter = 0
839 for y in range(nrow):
840 for y in range(nrow):
840 for x in range(ncol):
841 for x in range(ncol):
841
842
842 if counter >= self.nplots:
843 if counter >= self.nplots:
843 break
844 break
844
845
845 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
846 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
846
847
847 if showprofile:
848 if showprofile:
848 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
849 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
849
850
850 counter += 1
851 counter += 1
851
852
852 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=False,
853 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=False,
853 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,timerange=None,
854 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,timerange=None,
854 parameterIndex = None, onlyPositive = False,
855 parameterIndex = None, onlyPositive = False,
855 SNRthresh = -numpy.inf, SNR = True, SNRmin = None, SNRmax = None, onlySNR = False,
856 SNRthresh = -numpy.inf, SNR = True, SNRmin = None, SNRmax = None, onlySNR = False,
856 DOP = True,
857 DOP = True,
857 zlabel = "", parameterName = "", parameterObject = "data_param",
858 zlabel = "", parameterName = "", parameterObject = "data_param",
858 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
859 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
859 server=None, folder=None, username=None, password=None,
860 server=None, folder=None, username=None, password=None,
860 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
861 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
861
862
862 """
863 """
863
864
864 Input:
865 Input:
865 dataOut :
866 dataOut :
866 id :
867 id :
867 wintitle :
868 wintitle :
868 channelList :
869 channelList :
869 showProfile :
870 showProfile :
870 xmin : None,
871 xmin : None,
871 xmax : None,
872 xmax : None,
872 ymin : None,
873 ymin : None,
873 ymax : None,
874 ymax : None,
874 zmin : None,
875 zmin : None,
875 zmax : None
876 zmax : None
876 """
877 """
877
878
878 data_param = getattr(dataOut, parameterObject)
879 data_param = getattr(dataOut, parameterObject)
879
880
880 if channelList == None:
881 if channelList == None:
881 channelIndexList = numpy.arange(data_param.shape[0])
882 channelIndexList = numpy.arange(data_param.shape[0])
882 else:
883 else:
883 channelIndexList = numpy.array(channelList)
884 channelIndexList = numpy.array(channelList)
884
885
885 nchan = len(channelIndexList) #Number of channels being plotted
886 nchan = len(channelIndexList) #Number of channels being plotted
886
887
887 if nchan < 1:
888 if nchan < 1:
888 return
889 return
889
890
890 nGraphsByChannel = 0
891 nGraphsByChannel = 0
891
892
892 if SNR:
893 if SNR:
893 nGraphsByChannel += 1
894 nGraphsByChannel += 1
894 if DOP:
895 if DOP:
895 nGraphsByChannel += 1
896 nGraphsByChannel += 1
896
897
897 if nGraphsByChannel < 1:
898 if nGraphsByChannel < 1:
898 return
899 return
899
900
900 nplots = nGraphsByChannel*nchan
901 nplots = nGraphsByChannel*nchan
901
902
902 if timerange is not None:
903 if timerange is not None:
903 self.timerange = timerange
904 self.timerange = timerange
904
905
905 #tmin = None
906 #tmin = None
906 #tmax = None
907 #tmax = None
907 if parameterIndex == None:
908 if parameterIndex == None:
908 parameterIndex = 1
909 parameterIndex = 1
909
910
910 x = dataOut.getTimeRange1(dataOut.paramInterval)
911 x = dataOut.getTimeRange1(dataOut.paramInterval)
911 y = dataOut.heightList
912 y = dataOut.heightList
912 z = data_param[channelIndexList,parameterIndex,:].copy()
913 z = data_param[channelIndexList,parameterIndex,:].copy()
913
914
914 zRange = dataOut.abscissaList
915 zRange = dataOut.abscissaList
915 # nChannels = z.shape[0] #Number of wind dimensions estimated
916 # nChannels = z.shape[0] #Number of wind dimensions estimated
916 # thisDatetime = dataOut.datatime
917 # thisDatetime = dataOut.datatime
917
918
918 if dataOut.data_SNR is not None:
919 if dataOut.data_SNR is not None:
919 SNRarray = dataOut.data_SNR[channelIndexList,:]
920 SNRarray = dataOut.data_SNR[channelIndexList,:]
920 SNRdB = 10*numpy.log10(SNRarray)
921 SNRdB = 10*numpy.log10(SNRarray)
921 # SNRavgdB = 10*numpy.log10(SNRavg)
922 # SNRavgdB = 10*numpy.log10(SNRavg)
922 ind = numpy.where(SNRdB < 10**(SNRthresh/10))
923 ind = numpy.where(SNRdB < 10**(SNRthresh/10))
923 z[ind] = numpy.nan
924 z[ind] = numpy.nan
924
925
925 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
926 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
926 title = wintitle + " Parameters Plot" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
927 title = wintitle + " Parameters Plot" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
927 xlabel = ""
928 xlabel = ""
928 ylabel = "Range (Km)"
929 ylabel = "Range (Km)"
929
930
930 if (SNR and not onlySNR): nplots = 2*nplots
931 if (SNR and not onlySNR): nplots = 2*nplots
931
932
932 if onlyPositive:
933 if onlyPositive:
933 colormap = "jet"
934 colormap = "jet"
934 zmin = 0
935 zmin = 0
935 else: colormap = "RdBu_r"
936 else: colormap = "RdBu_r"
936
937
937 if not self.isConfig:
938 if not self.isConfig:
938
939
939 self.setup(id=id,
940 self.setup(id=id,
940 nplots=nplots,
941 nplots=nplots,
941 wintitle=wintitle,
942 wintitle=wintitle,
942 showprofile=showprofile,
943 showprofile=showprofile,
943 show=show)
944 show=show)
944
945
945 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
946 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
946
947
947 if ymin == None: ymin = numpy.nanmin(y)
948 if ymin == None: ymin = numpy.nanmin(y)
948 if ymax == None: ymax = numpy.nanmax(y)
949 if ymax == None: ymax = numpy.nanmax(y)
949 if zmin == None: zmin = numpy.nanmin(zRange)
950 if zmin == None: zmin = numpy.nanmin(zRange)
950 if zmax == None: zmax = numpy.nanmax(zRange)
951 if zmax == None: zmax = numpy.nanmax(zRange)
951
952
952 if SNR:
953 if SNR:
953 if SNRmin == None: SNRmin = numpy.nanmin(SNRdB)
954 if SNRmin == None: SNRmin = numpy.nanmin(SNRdB)
954 if SNRmax == None: SNRmax = numpy.nanmax(SNRdB)
955 if SNRmax == None: SNRmax = numpy.nanmax(SNRdB)
955
956
956 self.FTP_WEI = ftp_wei
957 self.FTP_WEI = ftp_wei
957 self.EXP_CODE = exp_code
958 self.EXP_CODE = exp_code
958 self.SUB_EXP_CODE = sub_exp_code
959 self.SUB_EXP_CODE = sub_exp_code
959 self.PLOT_POS = plot_pos
960 self.PLOT_POS = plot_pos
960
961
961 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
962 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
962 self.isConfig = True
963 self.isConfig = True
963 self.figfile = figfile
964 self.figfile = figfile
964
965
965 self.setWinTitle(title)
966 self.setWinTitle(title)
966
967
967 if ((self.xmax - x[1]) < (x[1]-x[0])):
968 if ((self.xmax - x[1]) < (x[1]-x[0])):
968 x[1] = self.xmax
969 x[1] = self.xmax
969
970
970 for i in range(nchan):
971 for i in range(nchan):
971
972
972 if (SNR and not onlySNR): j = 2*i
973 if (SNR and not onlySNR): j = 2*i
973 else: j = i
974 else: j = i
974
975
975 j = nGraphsByChannel*i
976 j = nGraphsByChannel*i
976
977
977 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
978 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
978 title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith)
979 title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith)
979
980
980 if not onlySNR:
981 if not onlySNR:
981 axes = self.axesList[j*self.__nsubplots]
982 axes = self.axesList[j*self.__nsubplots]
982 z1 = z[i,:].reshape((1,-1))
983 z1 = z[i,:].reshape((1,-1))
983 axes.pcolorbuffer(x, y, z1,
984 axes.pcolorbuffer(x, y, z1,
984 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
985 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
985 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap=colormap,
986 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap=colormap,
986 ticksize=9, cblabel=zlabel, cbsize="1%")
987 ticksize=9, cblabel=zlabel, cbsize="1%")
987
988
988 if DOP:
989 if DOP:
989 title = "%s Channel %d: %s" %(parameterName, channelIndexList[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
990 title = "%s Channel %d: %s" %(parameterName, channelIndexList[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
990
991
991 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
992 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
992 title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith)
993 title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith)
993 axes = self.axesList[j]
994 axes = self.axesList[j]
994 z1 = z[i,:].reshape((1,-1))
995 z1 = z[i,:].reshape((1,-1))
995 axes.pcolorbuffer(x, y, z1,
996 axes.pcolorbuffer(x, y, z1,
996 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
997 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
997 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap=colormap,
998 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap=colormap,
998 ticksize=9, cblabel=zlabel, cbsize="1%")
999 ticksize=9, cblabel=zlabel, cbsize="1%")
999
1000
1000 if SNR:
1001 if SNR:
1001 title = "Channel %d Signal Noise Ratio (SNR): %s" %(channelIndexList[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1002 title = "Channel %d Signal Noise Ratio (SNR): %s" %(channelIndexList[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1002 axes = self.axesList[(j)*self.__nsubplots]
1003 axes = self.axesList[(j)*self.__nsubplots]
1003 if not onlySNR:
1004 if not onlySNR:
1004 axes = self.axesList[(j + 1)*self.__nsubplots]
1005 axes = self.axesList[(j + 1)*self.__nsubplots]
1005
1006
1006 axes = self.axesList[(j + nGraphsByChannel-1)]
1007 axes = self.axesList[(j + nGraphsByChannel-1)]
1007
1008
1008 z1 = SNRdB[i,:].reshape((1,-1))
1009 z1 = SNRdB[i,:].reshape((1,-1))
1009 axes.pcolorbuffer(x, y, z1,
1010 axes.pcolorbuffer(x, y, z1,
1010 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
1011 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
1011 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap="jet",
1012 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap="jet",
1012 ticksize=9, cblabel=zlabel, cbsize="1%")
1013 ticksize=9, cblabel=zlabel, cbsize="1%")
1013
1014
1014
1015
1015
1016
1016 self.draw()
1017 self.draw()
1017
1018
1018 if x[1] >= self.axesList[0].xmax:
1019 if x[1] >= self.axesList[0].xmax:
1019 self.counter_imagwr = wr_period
1020 self.counter_imagwr = wr_period
1020 self.isConfig = False
1021 self.isConfig = False
1021 self.figfile = None
1022 self.figfile = None
1022
1023
1023 self.save(figpath=figpath,
1024 self.save(figpath=figpath,
1024 figfile=figfile,
1025 figfile=figfile,
1025 save=save,
1026 save=save,
1026 ftp=ftp,
1027 ftp=ftp,
1027 wr_period=wr_period,
1028 wr_period=wr_period,
1028 thisDatetime=thisDatetime,
1029 thisDatetime=thisDatetime,
1029 update_figfile=False)
1030 update_figfile=False)
1030
1031
1031 class SpectralFittingPlot(Figure):
1032 class SpectralFittingPlot(Figure):
1032
1033
1033 __isConfig = None
1034 __isConfig = None
1034 __nsubplots = None
1035 __nsubplots = None
1035
1036
1036 WIDTHPROF = None
1037 WIDTHPROF = None
1037 HEIGHTPROF = None
1038 HEIGHTPROF = None
1038 PREFIX = 'prm'
1039 PREFIX = 'prm'
1039
1040
1040
1041
1041 N = None
1042 N = None
1042 ippSeconds = None
1043 ippSeconds = None
1043
1044
1044 def __init__(self):
1045 def __init__(self):
1045 self.isConfig = False
1046 self.isConfig = False
1046 self.__nsubplots = 1
1047 self.__nsubplots = 1
1047
1048
1048 self.PLOT_CODE = SPECFIT_CODE
1049 self.PLOT_CODE = SPECFIT_CODE
1049
1050
1050 self.WIDTH = 450
1051 self.WIDTH = 450
1051 self.HEIGHT = 250
1052 self.HEIGHT = 250
1052 self.WIDTHPROF = 0
1053 self.WIDTHPROF = 0
1053 self.HEIGHTPROF = 0
1054 self.HEIGHTPROF = 0
1054
1055
1055 def getSubplots(self):
1056 def getSubplots(self):
1056
1057
1057 ncol = int(numpy.sqrt(self.nplots)+0.9)
1058 ncol = int(numpy.sqrt(self.nplots)+0.9)
1058 nrow = int(self.nplots*1./ncol + 0.9)
1059 nrow = int(self.nplots*1./ncol + 0.9)
1059
1060
1060 return nrow, ncol
1061 return nrow, ncol
1061
1062
1062 def setup(self, id, nplots, wintitle, showprofile=False, show=True):
1063 def setup(self, id, nplots, wintitle, showprofile=False, show=True):
1063
1064
1064 showprofile = False
1065 showprofile = False
1065 self.__showprofile = showprofile
1066 self.__showprofile = showprofile
1066 self.nplots = nplots
1067 self.nplots = nplots
1067
1068
1068 ncolspan = 5
1069 ncolspan = 5
1069 colspan = 4
1070 colspan = 4
1070 if showprofile:
1071 if showprofile:
1071 ncolspan = 5
1072 ncolspan = 5
1072 colspan = 4
1073 colspan = 4
1073 self.__nsubplots = 2
1074 self.__nsubplots = 2
1074
1075
1075 self.createFigure(id = id,
1076 self.createFigure(id = id,
1076 wintitle = wintitle,
1077 wintitle = wintitle,
1077 widthplot = self.WIDTH + self.WIDTHPROF,
1078 widthplot = self.WIDTH + self.WIDTHPROF,
1078 heightplot = self.HEIGHT + self.HEIGHTPROF,
1079 heightplot = self.HEIGHT + self.HEIGHTPROF,
1079 show=show)
1080 show=show)
1080
1081
1081 nrow, ncol = self.getSubplots()
1082 nrow, ncol = self.getSubplots()
1082
1083
1083 counter = 0
1084 counter = 0
1084 for y in range(nrow):
1085 for y in range(nrow):
1085 for x in range(ncol):
1086 for x in range(ncol):
1086
1087
1087 if counter >= self.nplots:
1088 if counter >= self.nplots:
1088 break
1089 break
1089
1090
1090 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
1091 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
1091
1092
1092 if showprofile:
1093 if showprofile:
1093 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
1094 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
1094
1095
1095 counter += 1
1096 counter += 1
1096
1097
1097 def run(self, dataOut, id, cutHeight=None, fit=False, wintitle="", channelList=None, showprofile=True,
1098 def run(self, dataOut, id, cutHeight=None, fit=False, wintitle="", channelList=None, showprofile=True,
1098 xmin=None, xmax=None, ymin=None, ymax=None,
1099 xmin=None, xmax=None, ymin=None, ymax=None,
1099 save=False, figpath='./', figfile=None, show=True):
1100 save=False, figpath='./', figfile=None, show=True):
1100
1101
1101 """
1102 """
1102
1103
1103 Input:
1104 Input:
1104 dataOut :
1105 dataOut :
1105 id :
1106 id :
1106 wintitle :
1107 wintitle :
1107 channelList :
1108 channelList :
1108 showProfile :
1109 showProfile :
1109 xmin : None,
1110 xmin : None,
1110 xmax : None,
1111 xmax : None,
1111 zmin : None,
1112 zmin : None,
1112 zmax : None
1113 zmax : None
1113 """
1114 """
1114
1115
1115 if cutHeight==None:
1116 if cutHeight==None:
1116 h=270
1117 h=270
1117 heightindex = numpy.abs(cutHeight - dataOut.heightList).argmin()
1118 heightindex = numpy.abs(cutHeight - dataOut.heightList).argmin()
1118 cutHeight = dataOut.heightList[heightindex]
1119 cutHeight = dataOut.heightList[heightindex]
1119
1120
1120 factor = dataOut.normFactor
1121 factor = dataOut.normFactor
1121 x = dataOut.abscissaList[:-1]
1122 x = dataOut.abscissaList[:-1]
1122 #y = dataOut.getHeiRange()
1123 #y = dataOut.getHeiRange()
1123
1124
1124 z = dataOut.data_pre[:,:,heightindex]/factor
1125 z = dataOut.data_pre[:,:,heightindex]/factor
1125 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
1126 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
1126 avg = numpy.average(z, axis=1)
1127 avg = numpy.average(z, axis=1)
1127 listChannels = z.shape[0]
1128 listChannels = z.shape[0]
1128
1129
1129 #Reconstruct Function
1130 #Reconstruct Function
1130 if fit==True:
1131 if fit==True:
1131 groupArray = dataOut.groupList
1132 groupArray = dataOut.groupList
1132 listChannels = groupArray.reshape((groupArray.size))
1133 listChannels = groupArray.reshape((groupArray.size))
1133 listChannels.sort()
1134 listChannels.sort()
1134 spcFitLine = numpy.zeros(z.shape)
1135 spcFitLine = numpy.zeros(z.shape)
1135 constants = dataOut.constants
1136 constants = dataOut.constants
1136
1137
1137 nGroups = groupArray.shape[0]
1138 nGroups = groupArray.shape[0]
1138 nChannels = groupArray.shape[1]
1139 nChannels = groupArray.shape[1]
1139 nProfiles = z.shape[1]
1140 nProfiles = z.shape[1]
1140
1141
1141 for f in range(nGroups):
1142 for f in range(nGroups):
1142 groupChann = groupArray[f,:]
1143 groupChann = groupArray[f,:]
1143 p = dataOut.data_param[f,:,heightindex]
1144 p = dataOut.data_param[f,:,heightindex]
1144 # p = numpy.array([ 89.343967,0.14036615,0.17086219,18.89835291,1.58388365,1.55099167])
1145 # p = numpy.array([ 89.343967,0.14036615,0.17086219,18.89835291,1.58388365,1.55099167])
1145 fitLineAux = dataOut.library.modelFunction(p, constants)*nProfiles
1146 fitLineAux = dataOut.library.modelFunction(p, constants)*nProfiles
1146 fitLineAux = fitLineAux.reshape((nChannels,nProfiles))
1147 fitLineAux = fitLineAux.reshape((nChannels,nProfiles))
1147 spcFitLine[groupChann,:] = fitLineAux
1148 spcFitLine[groupChann,:] = fitLineAux
1148 # spcFitLine = spcFitLine/factor
1149 # spcFitLine = spcFitLine/factor
1149
1150
1150 z = z[listChannels,:]
1151 z = z[listChannels,:]
1151 spcFitLine = spcFitLine[listChannels,:]
1152 spcFitLine = spcFitLine[listChannels,:]
1152 spcFitLinedB = 10*numpy.log10(spcFitLine)
1153 spcFitLinedB = 10*numpy.log10(spcFitLine)
1153
1154
1154 zdB = 10*numpy.log10(z)
1155 zdB = 10*numpy.log10(z)
1155 #thisDatetime = dataOut.datatime
1156 #thisDatetime = dataOut.datatime
1156 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
1157 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
1157 title = wintitle + " Doppler Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
1158 title = wintitle + " Doppler Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
1158 xlabel = "Velocity (m/s)"
1159 xlabel = "Velocity (m/s)"
1159 ylabel = "Spectrum"
1160 ylabel = "Spectrum"
1160
1161
1161 if not self.isConfig:
1162 if not self.isConfig:
1162
1163
1163 nplots = listChannels.size
1164 nplots = listChannels.size
1164
1165
1165 self.setup(id=id,
1166 self.setup(id=id,
1166 nplots=nplots,
1167 nplots=nplots,
1167 wintitle=wintitle,
1168 wintitle=wintitle,
1168 showprofile=showprofile,
1169 showprofile=showprofile,
1169 show=show)
1170 show=show)
1170
1171
1171 if xmin == None: xmin = numpy.nanmin(x)
1172 if xmin == None: xmin = numpy.nanmin(x)
1172 if xmax == None: xmax = numpy.nanmax(x)
1173 if xmax == None: xmax = numpy.nanmax(x)
1173 if ymin == None: ymin = numpy.nanmin(zdB)
1174 if ymin == None: ymin = numpy.nanmin(zdB)
1174 if ymax == None: ymax = numpy.nanmax(zdB)+2
1175 if ymax == None: ymax = numpy.nanmax(zdB)+2
1175
1176
1176 self.isConfig = True
1177 self.isConfig = True
1177
1178
1178 self.setWinTitle(title)
1179 self.setWinTitle(title)
1179 for i in range(self.nplots):
1180 for i in range(self.nplots):
1180 # title = "Channel %d: %4.2fdB" %(dataOut.channelList[i]+1, noisedB[i])
1181 # title = "Channel %d: %4.2fdB" %(dataOut.channelList[i]+1, noisedB[i])
1181 title = "Height %4.1f km\nChannel %d:" %(cutHeight, listChannels[i])
1182 title = "Height %4.1f km\nChannel %d:" %(cutHeight, listChannels[i])
1182 axes = self.axesList[i*self.__nsubplots]
1183 axes = self.axesList[i*self.__nsubplots]
1183 if fit == False:
1184 if fit == False:
1184 axes.pline(x, zdB[i,:],
1185 axes.pline(x, zdB[i,:],
1185 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
1186 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
1186 xlabel=xlabel, ylabel=ylabel, title=title
1187 xlabel=xlabel, ylabel=ylabel, title=title
1187 )
1188 )
1188 if fit == True:
1189 if fit == True:
1189 fitline=spcFitLinedB[i,:]
1190 fitline=spcFitLinedB[i,:]
1190 y=numpy.vstack([zdB[i,:],fitline] )
1191 y=numpy.vstack([zdB[i,:],fitline] )
1191 legendlabels=['Data','Fitting']
1192 legendlabels=['Data','Fitting']
1192 axes.pmultilineyaxis(x, y,
1193 axes.pmultilineyaxis(x, y,
1193 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
1194 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
1194 xlabel=xlabel, ylabel=ylabel, title=title,
1195 xlabel=xlabel, ylabel=ylabel, title=title,
1195 legendlabels=legendlabels, marker=None,
1196 legendlabels=legendlabels, marker=None,
1196 linestyle='solid', grid='both')
1197 linestyle='solid', grid='both')
1197
1198
1198 self.draw()
1199 self.draw()
1199
1200
1200 self.save(figpath=figpath,
1201 self.save(figpath=figpath,
1201 figfile=figfile,
1202 figfile=figfile,
1202 save=save,
1203 save=save,
1203 ftp=ftp,
1204 ftp=ftp,
1204 wr_period=wr_period,
1205 wr_period=wr_period,
1205 thisDatetime=thisDatetime)
1206 thisDatetime=thisDatetime)
1206
1207
1207
1208
1208 class EWDriftsPlot(Figure):
1209 class EWDriftsPlot(Figure):
1209
1210
1210 __isConfig = None
1211 __isConfig = None
1211 __nsubplots = None
1212 __nsubplots = None
1212
1213
1213 WIDTHPROF = None
1214 WIDTHPROF = None
1214 HEIGHTPROF = None
1215 HEIGHTPROF = None
1215 PREFIX = 'drift'
1216 PREFIX = 'drift'
1216
1217
1217 def __init__(self):
1218 def __init__(self):
1218
1219
1219 self.timerange = 2*60*60
1220 self.timerange = 2*60*60
1220 self.isConfig = False
1221 self.isConfig = False
1221 self.__nsubplots = 1
1222 self.__nsubplots = 1
1222
1223
1223 self.WIDTH = 800
1224 self.WIDTH = 800
1224 self.HEIGHT = 150
1225 self.HEIGHT = 150
1225 self.WIDTHPROF = 120
1226 self.WIDTHPROF = 120
1226 self.HEIGHTPROF = 0
1227 self.HEIGHTPROF = 0
1227 self.counter_imagwr = 0
1228 self.counter_imagwr = 0
1228
1229
1229 self.PLOT_CODE = EWDRIFT_CODE
1230 self.PLOT_CODE = EWDRIFT_CODE
1230
1231
1231 self.FTP_WEI = None
1232 self.FTP_WEI = None
1232 self.EXP_CODE = None
1233 self.EXP_CODE = None
1233 self.SUB_EXP_CODE = None
1234 self.SUB_EXP_CODE = None
1234 self.PLOT_POS = None
1235 self.PLOT_POS = None
1235 self.tmin = None
1236 self.tmin = None
1236 self.tmax = None
1237 self.tmax = None
1237
1238
1238 self.xmin = None
1239 self.xmin = None
1239 self.xmax = None
1240 self.xmax = None
1240
1241
1241 self.figfile = None
1242 self.figfile = None
1242
1243
1243 def getSubplots(self):
1244 def getSubplots(self):
1244
1245
1245 ncol = 1
1246 ncol = 1
1246 nrow = self.nplots
1247 nrow = self.nplots
1247
1248
1248 return nrow, ncol
1249 return nrow, ncol
1249
1250
1250 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1251 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1251
1252
1252 self.__showprofile = showprofile
1253 self.__showprofile = showprofile
1253 self.nplots = nplots
1254 self.nplots = nplots
1254
1255
1255 ncolspan = 1
1256 ncolspan = 1
1256 colspan = 1
1257 colspan = 1
1257
1258
1258 self.createFigure(id = id,
1259 self.createFigure(id = id,
1259 wintitle = wintitle,
1260 wintitle = wintitle,
1260 widthplot = self.WIDTH + self.WIDTHPROF,
1261 widthplot = self.WIDTH + self.WIDTHPROF,
1261 heightplot = self.HEIGHT + self.HEIGHTPROF,
1262 heightplot = self.HEIGHT + self.HEIGHTPROF,
1262 show=show)
1263 show=show)
1263
1264
1264 nrow, ncol = self.getSubplots()
1265 nrow, ncol = self.getSubplots()
1265
1266
1266 counter = 0
1267 counter = 0
1267 for y in range(nrow):
1268 for y in range(nrow):
1268 if counter >= self.nplots:
1269 if counter >= self.nplots:
1269 break
1270 break
1270
1271
1271 self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1)
1272 self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1)
1272 counter += 1
1273 counter += 1
1273
1274
1274 def run(self, dataOut, id, wintitle="", channelList=None,
1275 def run(self, dataOut, id, wintitle="", channelList=None,
1275 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
1276 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
1276 zmaxVertical = None, zminVertical = None, zmaxZonal = None, zminZonal = None,
1277 zmaxVertical = None, zminVertical = None, zmaxZonal = None, zminZonal = None,
1277 timerange=None, SNRthresh = -numpy.inf, SNRmin = None, SNRmax = None, SNR_1 = False,
1278 timerange=None, SNRthresh = -numpy.inf, SNRmin = None, SNRmax = None, SNR_1 = False,
1278 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
1279 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
1279 server=None, folder=None, username=None, password=None,
1280 server=None, folder=None, username=None, password=None,
1280 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1281 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1281 """
1282 """
1282
1283
1283 Input:
1284 Input:
1284 dataOut :
1285 dataOut :
1285 id :
1286 id :
1286 wintitle :
1287 wintitle :
1287 channelList :
1288 channelList :
1288 showProfile :
1289 showProfile :
1289 xmin : None,
1290 xmin : None,
1290 xmax : None,
1291 xmax : None,
1291 ymin : None,
1292 ymin : None,
1292 ymax : None,
1293 ymax : None,
1293 zmin : None,
1294 zmin : None,
1294 zmax : None
1295 zmax : None
1295 """
1296 """
1296
1297
1297 if timerange is not None:
1298 if timerange is not None:
1298 self.timerange = timerange
1299 self.timerange = timerange
1299
1300
1300 tmin = None
1301 tmin = None
1301 tmax = None
1302 tmax = None
1302
1303
1303 x = dataOut.getTimeRange1(dataOut.outputInterval)
1304 x = dataOut.getTimeRange1(dataOut.outputInterval)
1304 # y = dataOut.heightList
1305 # y = dataOut.heightList
1305 y = dataOut.heightList
1306 y = dataOut.heightList
1306
1307
1307 z = dataOut.data_output
1308 z = dataOut.data_output
1308 nplots = z.shape[0] #Number of wind dimensions estimated
1309 nplots = z.shape[0] #Number of wind dimensions estimated
1309 nplotsw = nplots
1310 nplotsw = nplots
1310
1311
1311 #If there is a SNR function defined
1312 #If there is a SNR function defined
1312 if dataOut.data_SNR is not None:
1313 if dataOut.data_SNR is not None:
1313 nplots += 1
1314 nplots += 1
1314 SNR = dataOut.data_SNR
1315 SNR = dataOut.data_SNR
1315
1316
1316 if SNR_1:
1317 if SNR_1:
1317 SNR += 1
1318 SNR += 1
1318
1319
1319 SNRavg = numpy.average(SNR, axis=0)
1320 SNRavg = numpy.average(SNR, axis=0)
1320
1321
1321 SNRdB = 10*numpy.log10(SNR)
1322 SNRdB = 10*numpy.log10(SNR)
1322 SNRavgdB = 10*numpy.log10(SNRavg)
1323 SNRavgdB = 10*numpy.log10(SNRavg)
1323
1324
1324 ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0]
1325 ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0]
1325
1326
1326 for i in range(nplotsw):
1327 for i in range(nplotsw):
1327 z[i,ind] = numpy.nan
1328 z[i,ind] = numpy.nan
1328
1329
1329
1330
1330 showprofile = False
1331 showprofile = False
1331 # thisDatetime = dataOut.datatime
1332 # thisDatetime = dataOut.datatime
1332 thisDatetime = datetime.datetime.utcfromtimestamp(x[1])
1333 thisDatetime = datetime.datetime.utcfromtimestamp(x[1])
1333 title = wintitle + " EW Drifts"
1334 title = wintitle + " EW Drifts"
1334 xlabel = ""
1335 xlabel = ""
1335 ylabel = "Height (Km)"
1336 ylabel = "Height (Km)"
1336
1337
1337 if not self.isConfig:
1338 if not self.isConfig:
1338
1339
1339 self.setup(id=id,
1340 self.setup(id=id,
1340 nplots=nplots,
1341 nplots=nplots,
1341 wintitle=wintitle,
1342 wintitle=wintitle,
1342 showprofile=showprofile,
1343 showprofile=showprofile,
1343 show=show)
1344 show=show)
1344
1345
1345 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1346 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1346
1347
1347 if ymin == None: ymin = numpy.nanmin(y)
1348 if ymin == None: ymin = numpy.nanmin(y)
1348 if ymax == None: ymax = numpy.nanmax(y)
1349 if ymax == None: ymax = numpy.nanmax(y)
1349
1350
1350 if zmaxZonal == None: zmaxZonal = numpy.nanmax(abs(z[0,:]))
1351 if zmaxZonal == None: zmaxZonal = numpy.nanmax(abs(z[0,:]))
1351 if zminZonal == None: zminZonal = -zmaxZonal
1352 if zminZonal == None: zminZonal = -zmaxZonal
1352 if zmaxVertical == None: zmaxVertical = numpy.nanmax(abs(z[1,:]))
1353 if zmaxVertical == None: zmaxVertical = numpy.nanmax(abs(z[1,:]))
1353 if zminVertical == None: zminVertical = -zmaxVertical
1354 if zminVertical == None: zminVertical = -zmaxVertical
1354
1355
1355 if dataOut.data_SNR is not None:
1356 if dataOut.data_SNR is not None:
1356 if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB)
1357 if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB)
1357 if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB)
1358 if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB)
1358
1359
1359 self.FTP_WEI = ftp_wei
1360 self.FTP_WEI = ftp_wei
1360 self.EXP_CODE = exp_code
1361 self.EXP_CODE = exp_code
1361 self.SUB_EXP_CODE = sub_exp_code
1362 self.SUB_EXP_CODE = sub_exp_code
1362 self.PLOT_POS = plot_pos
1363 self.PLOT_POS = plot_pos
1363
1364
1364 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1365 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1365 self.isConfig = True
1366 self.isConfig = True
1366
1367
1367
1368
1368 self.setWinTitle(title)
1369 self.setWinTitle(title)
1369
1370
1370 if ((self.xmax - x[1]) < (x[1]-x[0])):
1371 if ((self.xmax - x[1]) < (x[1]-x[0])):
1371 x[1] = self.xmax
1372 x[1] = self.xmax
1372
1373
1373 strWind = ['Zonal','Vertical']
1374 strWind = ['Zonal','Vertical']
1374 strCb = 'Velocity (m/s)'
1375 strCb = 'Velocity (m/s)'
1375 zmaxVector = [zmaxZonal, zmaxVertical]
1376 zmaxVector = [zmaxZonal, zmaxVertical]
1376 zminVector = [zminZonal, zminVertical]
1377 zminVector = [zminZonal, zminVertical]
1377
1378
1378 for i in range(nplotsw):
1379 for i in range(nplotsw):
1379
1380
1380 title = "%s Drifts: %s" %(strWind[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1381 title = "%s Drifts: %s" %(strWind[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1381 axes = self.axesList[i*self.__nsubplots]
1382 axes = self.axesList[i*self.__nsubplots]
1382
1383
1383 z1 = z[i,:].reshape((1,-1))
1384 z1 = z[i,:].reshape((1,-1))
1384
1385
1385 axes.pcolorbuffer(x, y, z1,
1386 axes.pcolorbuffer(x, y, z1,
1386 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zminVector[i], zmax=zmaxVector[i],
1387 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zminVector[i], zmax=zmaxVector[i],
1387 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1388 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1388 ticksize=9, cblabel=strCb, cbsize="1%", colormap="RdBu_r")
1389 ticksize=9, cblabel=strCb, cbsize="1%", colormap="RdBu_r")
1389
1390
1390 if dataOut.data_SNR is not None:
1391 if dataOut.data_SNR is not None:
1391 i += 1
1392 i += 1
1392 if SNR_1:
1393 if SNR_1:
1393 title = "Signal Noise Ratio + 1 (SNR+1): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1394 title = "Signal Noise Ratio + 1 (SNR+1): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1394 else:
1395 else:
1395 title = "Signal Noise Ratio (SNR): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1396 title = "Signal Noise Ratio (SNR): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1396 axes = self.axesList[i*self.__nsubplots]
1397 axes = self.axesList[i*self.__nsubplots]
1397 SNRavgdB = SNRavgdB.reshape((1,-1))
1398 SNRavgdB = SNRavgdB.reshape((1,-1))
1398
1399
1399 axes.pcolorbuffer(x, y, SNRavgdB,
1400 axes.pcolorbuffer(x, y, SNRavgdB,
1400 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
1401 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
1401 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1402 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1402 ticksize=9, cblabel='', cbsize="1%", colormap="jet")
1403 ticksize=9, cblabel='', cbsize="1%", colormap="jet")
1403
1404
1404 self.draw()
1405 self.draw()
1405
1406
1406 if x[1] >= self.axesList[0].xmax:
1407 if x[1] >= self.axesList[0].xmax:
1407 self.counter_imagwr = wr_period
1408 self.counter_imagwr = wr_period
1408 self.isConfig = False
1409 self.isConfig = False
1409 self.figfile = None
1410 self.figfile = None
1410
1411
1411
1412
1412
1413
1413
1414
1414 class PhasePlot(Figure):
1415 class PhasePlot(Figure):
1415
1416
1416 __isConfig = None
1417 __isConfig = None
1417 __nsubplots = None
1418 __nsubplots = None
1418
1419
1419 PREFIX = 'mphase'
1420 PREFIX = 'mphase'
1420
1421
1421 def __init__(self):
1422 def __init__(self):
1422
1423
1423 self.timerange = 24*60*60
1424 self.timerange = 24*60*60
1424 self.isConfig = False
1425 self.isConfig = False
1425 self.__nsubplots = 1
1426 self.__nsubplots = 1
1426 self.counter_imagwr = 0
1427 self.counter_imagwr = 0
1427 self.WIDTH = 600
1428 self.WIDTH = 600
1428 self.HEIGHT = 300
1429 self.HEIGHT = 300
1429 self.WIDTHPROF = 120
1430 self.WIDTHPROF = 120
1430 self.HEIGHTPROF = 0
1431 self.HEIGHTPROF = 0
1431 self.xdata = None
1432 self.xdata = None
1432 self.ydata = None
1433 self.ydata = None
1433
1434
1434 self.PLOT_CODE = MPHASE_CODE
1435 self.PLOT_CODE = MPHASE_CODE
1435
1436
1436 self.FTP_WEI = None
1437 self.FTP_WEI = None
1437 self.EXP_CODE = None
1438 self.EXP_CODE = None
1438 self.SUB_EXP_CODE = None
1439 self.SUB_EXP_CODE = None
1439 self.PLOT_POS = None
1440 self.PLOT_POS = None
1440
1441
1441
1442
1442 self.filename_phase = None
1443 self.filename_phase = None
1443
1444
1444 self.figfile = None
1445 self.figfile = None
1445
1446
1446 def getSubplots(self):
1447 def getSubplots(self):
1447
1448
1448 ncol = 1
1449 ncol = 1
1449 nrow = 1
1450 nrow = 1
1450
1451
1451 return nrow, ncol
1452 return nrow, ncol
1452
1453
1453 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1454 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1454
1455
1455 self.__showprofile = showprofile
1456 self.__showprofile = showprofile
1456 self.nplots = nplots
1457 self.nplots = nplots
1457
1458
1458 ncolspan = 7
1459 ncolspan = 7
1459 colspan = 6
1460 colspan = 6
1460 self.__nsubplots = 2
1461 self.__nsubplots = 2
1461
1462
1462 self.createFigure(id = id,
1463 self.createFigure(id = id,
1463 wintitle = wintitle,
1464 wintitle = wintitle,
1464 widthplot = self.WIDTH+self.WIDTHPROF,
1465 widthplot = self.WIDTH+self.WIDTHPROF,
1465 heightplot = self.HEIGHT+self.HEIGHTPROF,
1466 heightplot = self.HEIGHT+self.HEIGHTPROF,
1466 show=show)
1467 show=show)
1467
1468
1468 nrow, ncol = self.getSubplots()
1469 nrow, ncol = self.getSubplots()
1469
1470
1470 self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1)
1471 self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1)
1471
1472
1472
1473
1473 def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True',
1474 def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True',
1474 xmin=None, xmax=None, ymin=None, ymax=None,
1475 xmin=None, xmax=None, ymin=None, ymax=None,
1475 timerange=None,
1476 timerange=None,
1476 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1477 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1477 server=None, folder=None, username=None, password=None,
1478 server=None, folder=None, username=None, password=None,
1478 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1479 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1479
1480
1480
1481
1481 tmin = None
1482 tmin = None
1482 tmax = None
1483 tmax = None
1483 x = dataOut.getTimeRange1(dataOut.outputInterval)
1484 x = dataOut.getTimeRange1(dataOut.outputInterval)
1484 y = dataOut.getHeiRange()
1485 y = dataOut.getHeiRange()
1485
1486
1486
1487
1487 #thisDatetime = dataOut.datatime
1488 #thisDatetime = dataOut.datatime
1488 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1])
1489 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime)
1489 title = wintitle + " Phase of Beacon Signal" # : %s" %(thisDatetime.strftime("%d-%b-%Y"))
1490 title = wintitle + " Phase of Beacon Signal" # : %s" %(thisDatetime.strftime("%d-%b-%Y"))
1490 xlabel = "Local Time"
1491 xlabel = "Local Time"
1491 ylabel = "Phase"
1492 ylabel = "Phase"
1492
1493
1493
1494
1494 #phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList)))
1495 #phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList)))
1495 phase_beacon = dataOut.data_output
1496 phase_beacon = dataOut.data_output
1496 update_figfile = False
1497 update_figfile = False
1497
1498
1498 if not self.isConfig:
1499 if not self.isConfig:
1499
1500
1500 self.nplots = phase_beacon.size
1501 self.nplots = phase_beacon.size
1501
1502
1502 self.setup(id=id,
1503 self.setup(id=id,
1503 nplots=self.nplots,
1504 nplots=self.nplots,
1504 wintitle=wintitle,
1505 wintitle=wintitle,
1505 showprofile=showprofile,
1506 showprofile=showprofile,
1506 show=show)
1507 show=show)
1507
1508
1508 if timerange is not None:
1509 if timerange is not None:
1509 self.timerange = timerange
1510 self.timerange = timerange
1510
1511
1511 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1512 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1512
1513
1513 if ymin == None: ymin = numpy.nanmin(phase_beacon) - 10.0
1514 if ymin == None: ymin = numpy.nanmin(phase_beacon) - 10.0
1514 if ymax == None: ymax = numpy.nanmax(phase_beacon) + 10.0
1515 if ymax == None: ymax = numpy.nanmax(phase_beacon) + 10.0
1515
1516
1516 self.FTP_WEI = ftp_wei
1517 self.FTP_WEI = ftp_wei
1517 self.EXP_CODE = exp_code
1518 self.EXP_CODE = exp_code
1518 self.SUB_EXP_CODE = sub_exp_code
1519 self.SUB_EXP_CODE = sub_exp_code
1519 self.PLOT_POS = plot_pos
1520 self.PLOT_POS = plot_pos
1520
1521
1521 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1522 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1522 self.isConfig = True
1523 self.isConfig = True
1523 self.figfile = figfile
1524 self.figfile = figfile
1524 self.xdata = numpy.array([])
1525 self.xdata = numpy.array([])
1525 self.ydata = numpy.array([])
1526 self.ydata = numpy.array([])
1526
1527
1527 #open file beacon phase
1528 #open file beacon phase
1528 path = '%s%03d' %(self.PREFIX, self.id)
1529 path = '%s%03d' %(self.PREFIX, self.id)
1529 beacon_file = os.path.join(path,'%s.txt'%self.name)
1530 beacon_file = os.path.join(path,'%s.txt'%self.name)
1530 self.filename_phase = os.path.join(figpath,beacon_file)
1531 self.filename_phase = os.path.join(figpath,beacon_file)
1531 update_figfile = True
1532 update_figfile = True
1532
1533
1533
1534
1534 #store data beacon phase
1535 #store data beacon phase
1535 #self.save_data(self.filename_phase, phase_beacon, thisDatetime)
1536 #self.save_data(self.filename_phase, phase_beacon, thisDatetime)
1536
1537
1537 self.setWinTitle(title)
1538 self.setWinTitle(title)
1538
1539
1539
1540
1540 title = "Phase Offset %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1541 title = "Phase Offset %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1541
1542
1542 legendlabels = ["phase %d"%(chan) for chan in numpy.arange(self.nplots)]
1543 legendlabels = ["phase %d"%(chan) for chan in numpy.arange(self.nplots)]
1543
1544
1544 axes = self.axesList[0]
1545 axes = self.axesList[0]
1545
1546
1546 self.xdata = numpy.hstack((self.xdata, x[0:1]))
1547 self.xdata = numpy.hstack((self.xdata, x[0:1]))
1547
1548
1548 if len(self.ydata)==0:
1549 if len(self.ydata)==0:
1549 self.ydata = phase_beacon.reshape(-1,1)
1550 self.ydata = phase_beacon.reshape(-1,1)
1550 else:
1551 else:
1551 self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1)))
1552 self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1)))
1552
1553
1553
1554
1554 axes.pmultilineyaxis(x=self.xdata, y=self.ydata,
1555 axes.pmultilineyaxis(x=self.xdata, y=self.ydata,
1555 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax,
1556 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax,
1556 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid",
1557 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid",
1557 XAxisAsTime=True, grid='both'
1558 XAxisAsTime=True, grid='both'
1558 )
1559 )
1559
1560
1560 self.draw()
1561 self.draw()
1561
1562
1562 if dataOut.ltctime >= self.xmax:
1563 self.counter_imagwr = wr_period
1564 self.isConfig = False
1565 update_figfile = True
1566
1567 self.save(figpath=figpath,
1563 self.save(figpath=figpath,
1568 figfile=figfile,
1564 figfile=figfile,
1569 save=save,
1565 save=save,
1570 ftp=ftp,
1566 ftp=ftp,
1571 wr_period=wr_period,
1567 wr_period=wr_period,
1572 thisDatetime=thisDatetime,
1568 thisDatetime=thisDatetime,
1573 update_figfile=update_figfile)
1569 update_figfile=update_figfile)
1574
1570
1571 if dataOut.ltctime + dataOut.outputInterval >= self.xmax:
1572 self.counter_imagwr = wr_period
1573 self.isConfig = False
1574 update_figfile = True
1575
1576
1575
1577
1576 class NSMeteorDetection1Plot(Figure):
1578 class NSMeteorDetection1Plot(Figure):
1577
1579
1578 isConfig = None
1580 isConfig = None
1579 __nsubplots = None
1581 __nsubplots = None
1580
1582
1581 WIDTHPROF = None
1583 WIDTHPROF = None
1582 HEIGHTPROF = None
1584 HEIGHTPROF = None
1583 PREFIX = 'nsm'
1585 PREFIX = 'nsm'
1584
1586
1585 zminList = None
1587 zminList = None
1586 zmaxList = None
1588 zmaxList = None
1587 cmapList = None
1589 cmapList = None
1588 titleList = None
1590 titleList = None
1589 nPairs = None
1591 nPairs = None
1590 nChannels = None
1592 nChannels = None
1591 nParam = None
1593 nParam = None
1592
1594
1593 def __init__(self):
1595 def __init__(self):
1594
1596
1595 self.isConfig = False
1597 self.isConfig = False
1596 self.__nsubplots = 1
1598 self.__nsubplots = 1
1597
1599
1598 self.WIDTH = 750
1600 self.WIDTH = 750
1599 self.HEIGHT = 250
1601 self.HEIGHT = 250
1600 self.WIDTHPROF = 120
1602 self.WIDTHPROF = 120
1601 self.HEIGHTPROF = 0
1603 self.HEIGHTPROF = 0
1602 self.counter_imagwr = 0
1604 self.counter_imagwr = 0
1603
1605
1604 self.PLOT_CODE = SPEC_CODE
1606 self.PLOT_CODE = SPEC_CODE
1605
1607
1606 self.FTP_WEI = None
1608 self.FTP_WEI = None
1607 self.EXP_CODE = None
1609 self.EXP_CODE = None
1608 self.SUB_EXP_CODE = None
1610 self.SUB_EXP_CODE = None
1609 self.PLOT_POS = None
1611 self.PLOT_POS = None
1610
1612
1611 self.__xfilter_ena = False
1613 self.__xfilter_ena = False
1612 self.__yfilter_ena = False
1614 self.__yfilter_ena = False
1613
1615
1614 def getSubplots(self):
1616 def getSubplots(self):
1615
1617
1616 ncol = 3
1618 ncol = 3
1617 nrow = int(numpy.ceil(self.nplots/3.0))
1619 nrow = int(numpy.ceil(self.nplots/3.0))
1618
1620
1619 return nrow, ncol
1621 return nrow, ncol
1620
1622
1621 def setup(self, id, nplots, wintitle, show=True):
1623 def setup(self, id, nplots, wintitle, show=True):
1622
1624
1623 self.nplots = nplots
1625 self.nplots = nplots
1624
1626
1625 ncolspan = 1
1627 ncolspan = 1
1626 colspan = 1
1628 colspan = 1
1627
1629
1628 self.createFigure(id = id,
1630 self.createFigure(id = id,
1629 wintitle = wintitle,
1631 wintitle = wintitle,
1630 widthplot = self.WIDTH + self.WIDTHPROF,
1632 widthplot = self.WIDTH + self.WIDTHPROF,
1631 heightplot = self.HEIGHT + self.HEIGHTPROF,
1633 heightplot = self.HEIGHT + self.HEIGHTPROF,
1632 show=show)
1634 show=show)
1633
1635
1634 nrow, ncol = self.getSubplots()
1636 nrow, ncol = self.getSubplots()
1635
1637
1636 counter = 0
1638 counter = 0
1637 for y in range(nrow):
1639 for y in range(nrow):
1638 for x in range(ncol):
1640 for x in range(ncol):
1639
1641
1640 if counter >= self.nplots:
1642 if counter >= self.nplots:
1641 break
1643 break
1642
1644
1643 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
1645 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
1644
1646
1645 counter += 1
1647 counter += 1
1646
1648
1647 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True,
1649 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True,
1648 xmin=None, xmax=None, ymin=None, ymax=None, SNRmin=None, SNRmax=None,
1650 xmin=None, xmax=None, ymin=None, ymax=None, SNRmin=None, SNRmax=None,
1649 vmin=None, vmax=None, wmin=None, wmax=None, mode = 'SA',
1651 vmin=None, vmax=None, wmin=None, wmax=None, mode = 'SA',
1650 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1652 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1651 server=None, folder=None, username=None, password=None,
1653 server=None, folder=None, username=None, password=None,
1652 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False,
1654 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False,
1653 xaxis="frequency"):
1655 xaxis="frequency"):
1654
1656
1655 """
1657 """
1656
1658
1657 Input:
1659 Input:
1658 dataOut :
1660 dataOut :
1659 id :
1661 id :
1660 wintitle :
1662 wintitle :
1661 channelList :
1663 channelList :
1662 showProfile :
1664 showProfile :
1663 xmin : None,
1665 xmin : None,
1664 xmax : None,
1666 xmax : None,
1665 ymin : None,
1667 ymin : None,
1666 ymax : None,
1668 ymax : None,
1667 zmin : None,
1669 zmin : None,
1668 zmax : None
1670 zmax : None
1669 """
1671 """
1670 #SEPARAR EN DOS PLOTS
1672 #SEPARAR EN DOS PLOTS
1671 nParam = dataOut.data_param.shape[1] - 3
1673 nParam = dataOut.data_param.shape[1] - 3
1672
1674
1673 utctime = dataOut.data_param[0,0]
1675 utctime = dataOut.data_param[0,0]
1674 tmet = dataOut.data_param[:,1].astype(int)
1676 tmet = dataOut.data_param[:,1].astype(int)
1675 hmet = dataOut.data_param[:,2].astype(int)
1677 hmet = dataOut.data_param[:,2].astype(int)
1676
1678
1677 x = dataOut.abscissaList
1679 x = dataOut.abscissaList
1678 y = dataOut.heightList
1680 y = dataOut.heightList
1679
1681
1680 z = numpy.zeros((nParam, y.size, x.size - 1))
1682 z = numpy.zeros((nParam, y.size, x.size - 1))
1681 z[:,:] = numpy.nan
1683 z[:,:] = numpy.nan
1682 z[:,hmet,tmet] = dataOut.data_param[:,3:].T
1684 z[:,hmet,tmet] = dataOut.data_param[:,3:].T
1683 z[0,:,:] = 10*numpy.log10(z[0,:,:])
1685 z[0,:,:] = 10*numpy.log10(z[0,:,:])
1684
1686
1685 xlabel = "Time (s)"
1687 xlabel = "Time (s)"
1686 ylabel = "Range (km)"
1688 ylabel = "Range (km)"
1687
1689
1688 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime)
1690 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime)
1689
1691
1690 if not self.isConfig:
1692 if not self.isConfig:
1691
1693
1692 nplots = nParam
1694 nplots = nParam
1693
1695
1694 self.setup(id=id,
1696 self.setup(id=id,
1695 nplots=nplots,
1697 nplots=nplots,
1696 wintitle=wintitle,
1698 wintitle=wintitle,
1697 show=show)
1699 show=show)
1698
1700
1699 if xmin is None: xmin = numpy.nanmin(x)
1701 if xmin is None: xmin = numpy.nanmin(x)
1700 if xmax is None: xmax = numpy.nanmax(x)
1702 if xmax is None: xmax = numpy.nanmax(x)
1701 if ymin is None: ymin = numpy.nanmin(y)
1703 if ymin is None: ymin = numpy.nanmin(y)
1702 if ymax is None: ymax = numpy.nanmax(y)
1704 if ymax is None: ymax = numpy.nanmax(y)
1703 if SNRmin is None: SNRmin = numpy.nanmin(z[0,:])
1705 if SNRmin is None: SNRmin = numpy.nanmin(z[0,:])
1704 if SNRmax is None: SNRmax = numpy.nanmax(z[0,:])
1706 if SNRmax is None: SNRmax = numpy.nanmax(z[0,:])
1705 if vmax is None: vmax = numpy.nanmax(numpy.abs(z[1,:]))
1707 if vmax is None: vmax = numpy.nanmax(numpy.abs(z[1,:]))
1706 if vmin is None: vmin = -vmax
1708 if vmin is None: vmin = -vmax
1707 if wmin is None: wmin = 0
1709 if wmin is None: wmin = 0
1708 if wmax is None: wmax = 50
1710 if wmax is None: wmax = 50
1709
1711
1710 pairsList = dataOut.groupList
1712 pairsList = dataOut.groupList
1711 self.nPairs = len(dataOut.groupList)
1713 self.nPairs = len(dataOut.groupList)
1712
1714
1713 zminList = [SNRmin, vmin, cmin] + [pmin]*self.nPairs
1715 zminList = [SNRmin, vmin, cmin] + [pmin]*self.nPairs
1714 zmaxList = [SNRmax, vmax, cmax] + [pmax]*self.nPairs
1716 zmaxList = [SNRmax, vmax, cmax] + [pmax]*self.nPairs
1715 titleList = ["SNR","Radial Velocity","Coherence"]
1717 titleList = ["SNR","Radial Velocity","Coherence"]
1716 cmapList = ["jet","RdBu_r","jet"]
1718 cmapList = ["jet","RdBu_r","jet"]
1717
1719
1718 for i in range(self.nPairs):
1720 for i in range(self.nPairs):
1719 strAux1 = "Phase Difference "+ str(pairsList[i][0]) + str(pairsList[i][1])
1721 strAux1 = "Phase Difference "+ str(pairsList[i][0]) + str(pairsList[i][1])
1720 titleList = titleList + [strAux1]
1722 titleList = titleList + [strAux1]
1721 cmapList = cmapList + ["RdBu_r"]
1723 cmapList = cmapList + ["RdBu_r"]
1722
1724
1723 self.zminList = zminList
1725 self.zminList = zminList
1724 self.zmaxList = zmaxList
1726 self.zmaxList = zmaxList
1725 self.cmapList = cmapList
1727 self.cmapList = cmapList
1726 self.titleList = titleList
1728 self.titleList = titleList
1727
1729
1728 self.FTP_WEI = ftp_wei
1730 self.FTP_WEI = ftp_wei
1729 self.EXP_CODE = exp_code
1731 self.EXP_CODE = exp_code
1730 self.SUB_EXP_CODE = sub_exp_code
1732 self.SUB_EXP_CODE = sub_exp_code
1731 self.PLOT_POS = plot_pos
1733 self.PLOT_POS = plot_pos
1732
1734
1733 self.isConfig = True
1735 self.isConfig = True
1734
1736
1735 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
1737 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
1736
1738
1737 for i in range(nParam):
1739 for i in range(nParam):
1738 title = self.titleList[i] + ": " +str_datetime
1740 title = self.titleList[i] + ": " +str_datetime
1739 axes = self.axesList[i]
1741 axes = self.axesList[i]
1740 axes.pcolor(x, y, z[i,:].T,
1742 axes.pcolor(x, y, z[i,:].T,
1741 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=self.zminList[i], zmax=self.zmaxList[i],
1743 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='')
1744 xlabel=xlabel, ylabel=ylabel, title=title, colormap=self.cmapList[i],ticksize=9, cblabel='')
1743 self.draw()
1745 self.draw()
1744
1746
1745 if figfile == None:
1747 if figfile == None:
1746 str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S")
1748 str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S")
1747 name = str_datetime
1749 name = str_datetime
1748 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
1750 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
1749 name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith)
1751 name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith)
1750 figfile = self.getFilename(name)
1752 figfile = self.getFilename(name)
1751
1753
1752 self.save(figpath=figpath,
1754 self.save(figpath=figpath,
1753 figfile=figfile,
1755 figfile=figfile,
1754 save=save,
1756 save=save,
1755 ftp=ftp,
1757 ftp=ftp,
1756 wr_period=wr_period,
1758 wr_period=wr_period,
1757 thisDatetime=thisDatetime)
1759 thisDatetime=thisDatetime)
1758
1760
1759
1761
1760 class NSMeteorDetection2Plot(Figure):
1762 class NSMeteorDetection2Plot(Figure):
1761
1763
1762 isConfig = None
1764 isConfig = None
1763 __nsubplots = None
1765 __nsubplots = None
1764
1766
1765 WIDTHPROF = None
1767 WIDTHPROF = None
1766 HEIGHTPROF = None
1768 HEIGHTPROF = None
1767 PREFIX = 'nsm'
1769 PREFIX = 'nsm'
1768
1770
1769 zminList = None
1771 zminList = None
1770 zmaxList = None
1772 zmaxList = None
1771 cmapList = None
1773 cmapList = None
1772 titleList = None
1774 titleList = None
1773 nPairs = None
1775 nPairs = None
1774 nChannels = None
1776 nChannels = None
1775 nParam = None
1777 nParam = None
1776
1778
1777 def __init__(self):
1779 def __init__(self):
1778
1780
1779 self.isConfig = False
1781 self.isConfig = False
1780 self.__nsubplots = 1
1782 self.__nsubplots = 1
1781
1783
1782 self.WIDTH = 750
1784 self.WIDTH = 750
1783 self.HEIGHT = 250
1785 self.HEIGHT = 250
1784 self.WIDTHPROF = 120
1786 self.WIDTHPROF = 120
1785 self.HEIGHTPROF = 0
1787 self.HEIGHTPROF = 0
1786 self.counter_imagwr = 0
1788 self.counter_imagwr = 0
1787
1789
1788 self.PLOT_CODE = SPEC_CODE
1790 self.PLOT_CODE = SPEC_CODE
1789
1791
1790 self.FTP_WEI = None
1792 self.FTP_WEI = None
1791 self.EXP_CODE = None
1793 self.EXP_CODE = None
1792 self.SUB_EXP_CODE = None
1794 self.SUB_EXP_CODE = None
1793 self.PLOT_POS = None
1795 self.PLOT_POS = None
1794
1796
1795 self.__xfilter_ena = False
1797 self.__xfilter_ena = False
1796 self.__yfilter_ena = False
1798 self.__yfilter_ena = False
1797
1799
1798 def getSubplots(self):
1800 def getSubplots(self):
1799
1801
1800 ncol = 3
1802 ncol = 3
1801 nrow = int(numpy.ceil(self.nplots/3.0))
1803 nrow = int(numpy.ceil(self.nplots/3.0))
1802
1804
1803 return nrow, ncol
1805 return nrow, ncol
1804
1806
1805 def setup(self, id, nplots, wintitle, show=True):
1807 def setup(self, id, nplots, wintitle, show=True):
1806
1808
1807 self.nplots = nplots
1809 self.nplots = nplots
1808
1810
1809 ncolspan = 1
1811 ncolspan = 1
1810 colspan = 1
1812 colspan = 1
1811
1813
1812 self.createFigure(id = id,
1814 self.createFigure(id = id,
1813 wintitle = wintitle,
1815 wintitle = wintitle,
1814 widthplot = self.WIDTH + self.WIDTHPROF,
1816 widthplot = self.WIDTH + self.WIDTHPROF,
1815 heightplot = self.HEIGHT + self.HEIGHTPROF,
1817 heightplot = self.HEIGHT + self.HEIGHTPROF,
1816 show=show)
1818 show=show)
1817
1819
1818 nrow, ncol = self.getSubplots()
1820 nrow, ncol = self.getSubplots()
1819
1821
1820 counter = 0
1822 counter = 0
1821 for y in range(nrow):
1823 for y in range(nrow):
1822 for x in range(ncol):
1824 for x in range(ncol):
1823
1825
1824 if counter >= self.nplots:
1826 if counter >= self.nplots:
1825 break
1827 break
1826
1828
1827 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
1829 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
1828
1830
1829 counter += 1
1831 counter += 1
1830
1832
1831 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True,
1833 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True,
1832 xmin=None, xmax=None, ymin=None, ymax=None, SNRmin=None, SNRmax=None,
1834 xmin=None, xmax=None, ymin=None, ymax=None, SNRmin=None, SNRmax=None,
1833 vmin=None, vmax=None, wmin=None, wmax=None, mode = 'SA',
1835 vmin=None, vmax=None, wmin=None, wmax=None, mode = 'SA',
1834 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1836 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1835 server=None, folder=None, username=None, password=None,
1837 server=None, folder=None, username=None, password=None,
1836 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False,
1838 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False,
1837 xaxis="frequency"):
1839 xaxis="frequency"):
1838
1840
1839 """
1841 """
1840
1842
1841 Input:
1843 Input:
1842 dataOut :
1844 dataOut :
1843 id :
1845 id :
1844 wintitle :
1846 wintitle :
1845 channelList :
1847 channelList :
1846 showProfile :
1848 showProfile :
1847 xmin : None,
1849 xmin : None,
1848 xmax : None,
1850 xmax : None,
1849 ymin : None,
1851 ymin : None,
1850 ymax : None,
1852 ymax : None,
1851 zmin : None,
1853 zmin : None,
1852 zmax : None
1854 zmax : None
1853 """
1855 """
1854 #Rebuild matrix
1856 #Rebuild matrix
1855 utctime = dataOut.data_param[0,0]
1857 utctime = dataOut.data_param[0,0]
1856 cmet = dataOut.data_param[:,1].astype(int)
1858 cmet = dataOut.data_param[:,1].astype(int)
1857 tmet = dataOut.data_param[:,2].astype(int)
1859 tmet = dataOut.data_param[:,2].astype(int)
1858 hmet = dataOut.data_param[:,3].astype(int)
1860 hmet = dataOut.data_param[:,3].astype(int)
1859
1861
1860 nParam = 3
1862 nParam = 3
1861 nChan = len(dataOut.groupList)
1863 nChan = len(dataOut.groupList)
1862 x = dataOut.abscissaList
1864 x = dataOut.abscissaList
1863 y = dataOut.heightList
1865 y = dataOut.heightList
1864
1866
1865 z = numpy.full((nChan, nParam, y.size, x.size - 1),numpy.nan)
1867 z = numpy.full((nChan, nParam, y.size, x.size - 1),numpy.nan)
1866 z[cmet,:,hmet,tmet] = dataOut.data_param[:,4:]
1868 z[cmet,:,hmet,tmet] = dataOut.data_param[:,4:]
1867 z[:,0,:,:] = 10*numpy.log10(z[:,0,:,:]) #logarithmic scale
1869 z[:,0,:,:] = 10*numpy.log10(z[:,0,:,:]) #logarithmic scale
1868 z = numpy.reshape(z, (nChan*nParam, y.size, x.size-1))
1870 z = numpy.reshape(z, (nChan*nParam, y.size, x.size-1))
1869
1871
1870 xlabel = "Time (s)"
1872 xlabel = "Time (s)"
1871 ylabel = "Range (km)"
1873 ylabel = "Range (km)"
1872
1874
1873 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime)
1875 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime)
1874
1876
1875 if not self.isConfig:
1877 if not self.isConfig:
1876
1878
1877 nplots = nParam*nChan
1879 nplots = nParam*nChan
1878
1880
1879 self.setup(id=id,
1881 self.setup(id=id,
1880 nplots=nplots,
1882 nplots=nplots,
1881 wintitle=wintitle,
1883 wintitle=wintitle,
1882 show=show)
1884 show=show)
1883
1885
1884 if xmin is None: xmin = numpy.nanmin(x)
1886 if xmin is None: xmin = numpy.nanmin(x)
1885 if xmax is None: xmax = numpy.nanmax(x)
1887 if xmax is None: xmax = numpy.nanmax(x)
1886 if ymin is None: ymin = numpy.nanmin(y)
1888 if ymin is None: ymin = numpy.nanmin(y)
1887 if ymax is None: ymax = numpy.nanmax(y)
1889 if ymax is None: ymax = numpy.nanmax(y)
1888 if SNRmin is None: SNRmin = numpy.nanmin(z[0,:])
1890 if SNRmin is None: SNRmin = numpy.nanmin(z[0,:])
1889 if SNRmax is None: SNRmax = numpy.nanmax(z[0,:])
1891 if SNRmax is None: SNRmax = numpy.nanmax(z[0,:])
1890 if vmax is None: vmax = numpy.nanmax(numpy.abs(z[1,:]))
1892 if vmax is None: vmax = numpy.nanmax(numpy.abs(z[1,:]))
1891 if vmin is None: vmin = -vmax
1893 if vmin is None: vmin = -vmax
1892 if wmin is None: wmin = 0
1894 if wmin is None: wmin = 0
1893 if wmax is None: wmax = 50
1895 if wmax is None: wmax = 50
1894
1896
1895 self.nChannels = nChan
1897 self.nChannels = nChan
1896
1898
1897 zminList = []
1899 zminList = []
1898 zmaxList = []
1900 zmaxList = []
1899 titleList = []
1901 titleList = []
1900 cmapList = []
1902 cmapList = []
1901 for i in range(self.nChannels):
1903 for i in range(self.nChannels):
1902 strAux1 = "SNR Channel "+ str(i)
1904 strAux1 = "SNR Channel "+ str(i)
1903 strAux2 = "Radial Velocity Channel "+ str(i)
1905 strAux2 = "Radial Velocity Channel "+ str(i)
1904 strAux3 = "Spectral Width Channel "+ str(i)
1906 strAux3 = "Spectral Width Channel "+ str(i)
1905
1907
1906 titleList = titleList + [strAux1,strAux2,strAux3]
1908 titleList = titleList + [strAux1,strAux2,strAux3]
1907 cmapList = cmapList + ["jet","RdBu_r","jet"]
1909 cmapList = cmapList + ["jet","RdBu_r","jet"]
1908 zminList = zminList + [SNRmin,vmin,wmin]
1910 zminList = zminList + [SNRmin,vmin,wmin]
1909 zmaxList = zmaxList + [SNRmax,vmax,wmax]
1911 zmaxList = zmaxList + [SNRmax,vmax,wmax]
1910
1912
1911 self.zminList = zminList
1913 self.zminList = zminList
1912 self.zmaxList = zmaxList
1914 self.zmaxList = zmaxList
1913 self.cmapList = cmapList
1915 self.cmapList = cmapList
1914 self.titleList = titleList
1916 self.titleList = titleList
1915
1917
1916 self.FTP_WEI = ftp_wei
1918 self.FTP_WEI = ftp_wei
1917 self.EXP_CODE = exp_code
1919 self.EXP_CODE = exp_code
1918 self.SUB_EXP_CODE = sub_exp_code
1920 self.SUB_EXP_CODE = sub_exp_code
1919 self.PLOT_POS = plot_pos
1921 self.PLOT_POS = plot_pos
1920
1922
1921 self.isConfig = True
1923 self.isConfig = True
1922
1924
1923 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
1925 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
1924
1926
1925 for i in range(self.nplots):
1927 for i in range(self.nplots):
1926 title = self.titleList[i] + ": " +str_datetime
1928 title = self.titleList[i] + ": " +str_datetime
1927 axes = self.axesList[i]
1929 axes = self.axesList[i]
1928 axes.pcolor(x, y, z[i,:].T,
1930 axes.pcolor(x, y, z[i,:].T,
1929 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=self.zminList[i], zmax=self.zmaxList[i],
1931 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='')
1932 xlabel=xlabel, ylabel=ylabel, title=title, colormap=self.cmapList[i],ticksize=9, cblabel='')
1931 self.draw()
1933 self.draw()
1932
1934
1933 if figfile == None:
1935 if figfile == None:
1934 str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S")
1936 str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S")
1935 name = str_datetime
1937 name = str_datetime
1936 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
1938 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
1937 name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith)
1939 name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith)
1938 figfile = self.getFilename(name)
1940 figfile = self.getFilename(name)
1939
1941
1940 self.save(figpath=figpath,
1942 self.save(figpath=figpath,
1941 figfile=figfile,
1943 figfile=figfile,
1942 save=save,
1944 save=save,
1943 ftp=ftp,
1945 ftp=ftp,
1944 wr_period=wr_period,
1946 wr_period=wr_period,
1945 thisDatetime=thisDatetime)
1947 thisDatetime=thisDatetime)
1946
1948
1947
1949
General Comments 0
You need to be logged in to leave comments. Login now