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