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