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