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