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