@@ -1,1148 +1,1151 | |||||
1 | ''' |
|
1 | ''' | |
2 | @author: Daniel Suarez |
|
2 | @author: Daniel Suarez | |
3 | ''' |
|
3 | ''' | |
4 | import os |
|
4 | import os | |
5 | import datetime |
|
5 | import datetime | |
6 | import numpy |
|
6 | import numpy | |
7 |
|
7 | |||
8 | from figure import Figure, isRealtime |
|
8 | from figure import Figure, isRealtime | |
9 |
|
9 | |||
10 | class SpectraPlot(Figure): |
|
10 | class SpectraPlot(Figure): | |
11 |
|
11 | |||
12 | isConfig = None |
|
12 | isConfig = None | |
13 | __nsubplots = None |
|
13 | __nsubplots = None | |
14 |
|
14 | |||
15 | WIDTHPROF = None |
|
15 | WIDTHPROF = None | |
16 | HEIGHTPROF = None |
|
16 | HEIGHTPROF = None | |
17 | PREFIX = 'spc' |
|
17 | PREFIX = 'spc' | |
18 |
|
18 | |||
19 | def __init__(self): |
|
19 | def __init__(self): | |
20 |
|
20 | |||
21 | self.isConfig = False |
|
21 | self.isConfig = False | |
22 | self.__nsubplots = 1 |
|
22 | self.__nsubplots = 1 | |
23 |
|
23 | |||
24 | self.WIDTH = 280 |
|
24 | self.WIDTH = 280 | |
25 | self.HEIGHT = 250 |
|
25 | self.HEIGHT = 250 | |
26 | self.WIDTHPROF = 120 |
|
26 | self.WIDTHPROF = 120 | |
27 | self.HEIGHTPROF = 0 |
|
27 | self.HEIGHTPROF = 0 | |
28 | self.counter_imagwr = 0 |
|
28 | self.counter_imagwr = 0 | |
29 |
|
29 | |||
30 | self.PLOT_CODE = 1 |
|
30 | self.PLOT_CODE = 1 | |
31 | self.FTP_WEI = None |
|
31 | self.FTP_WEI = None | |
32 | self.EXP_CODE = None |
|
32 | self.EXP_CODE = None | |
33 | self.SUB_EXP_CODE = None |
|
33 | self.SUB_EXP_CODE = None | |
34 | self.PLOT_POS = None |
|
34 | self.PLOT_POS = None | |
35 |
|
35 | |||
36 | def getSubplots(self): |
|
36 | def getSubplots(self): | |
37 |
|
37 | |||
38 | ncol = int(numpy.sqrt(self.nplots)+0.9) |
|
38 | ncol = int(numpy.sqrt(self.nplots)+0.9) | |
39 | nrow = int(self.nplots*1./ncol + 0.9) |
|
39 | nrow = int(self.nplots*1./ncol + 0.9) | |
40 |
|
40 | |||
41 | return nrow, ncol |
|
41 | return nrow, ncol | |
42 |
|
42 | |||
43 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
43 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
44 |
|
44 | |||
45 | self.__showprofile = showprofile |
|
45 | self.__showprofile = showprofile | |
46 | self.nplots = nplots |
|
46 | self.nplots = nplots | |
47 |
|
47 | |||
48 | ncolspan = 1 |
|
48 | ncolspan = 1 | |
49 | colspan = 1 |
|
49 | colspan = 1 | |
50 | if showprofile: |
|
50 | if showprofile: | |
51 | ncolspan = 3 |
|
51 | ncolspan = 3 | |
52 | colspan = 2 |
|
52 | colspan = 2 | |
53 | self.__nsubplots = 2 |
|
53 | self.__nsubplots = 2 | |
54 |
|
54 | |||
55 | self.createFigure(id = id, |
|
55 | self.createFigure(id = id, | |
56 | wintitle = wintitle, |
|
56 | wintitle = wintitle, | |
57 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
57 | widthplot = self.WIDTH + self.WIDTHPROF, | |
58 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
58 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
59 | show=show) |
|
59 | show=show) | |
60 |
|
60 | |||
61 | nrow, ncol = self.getSubplots() |
|
61 | nrow, ncol = self.getSubplots() | |
62 |
|
62 | |||
63 | counter = 0 |
|
63 | counter = 0 | |
64 | for y in range(nrow): |
|
64 | for y in range(nrow): | |
65 | for x in range(ncol): |
|
65 | for x in range(ncol): | |
66 |
|
66 | |||
67 | if counter >= self.nplots: |
|
67 | if counter >= self.nplots: | |
68 | break |
|
68 | break | |
69 |
|
69 | |||
70 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
70 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
71 |
|
71 | |||
72 | if showprofile: |
|
72 | if showprofile: | |
73 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
73 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
74 |
|
74 | |||
75 | counter += 1 |
|
75 | counter += 1 | |
76 |
|
76 | |||
77 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True, |
|
77 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True, | |
78 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
78 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
79 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, |
|
79 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, | |
80 | server=None, folder=None, username=None, password=None, |
|
80 | server=None, folder=None, username=None, password=None, | |
81 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False): |
|
81 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False): | |
82 |
|
82 | |||
83 | """ |
|
83 | """ | |
84 |
|
84 | |||
85 | Input: |
|
85 | Input: | |
86 | dataOut : |
|
86 | dataOut : | |
87 | id : |
|
87 | id : | |
88 | wintitle : |
|
88 | wintitle : | |
89 | channelList : |
|
89 | channelList : | |
90 | showProfile : |
|
90 | showProfile : | |
91 | xmin : None, |
|
91 | xmin : None, | |
92 | xmax : None, |
|
92 | xmax : None, | |
93 | ymin : None, |
|
93 | ymin : None, | |
94 | ymax : None, |
|
94 | ymax : None, | |
95 | zmin : None, |
|
95 | zmin : None, | |
96 | zmax : None |
|
96 | zmax : None | |
97 | """ |
|
97 | """ | |
98 |
|
98 | |||
99 | if dataOut.flagNoData: |
|
99 | if dataOut.flagNoData: | |
100 | return None |
|
100 | return None | |
101 |
|
101 | |||
102 | if realtime: |
|
102 | if realtime: | |
103 | if not(isRealtime(utcdatatime = dataOut.utctime)): |
|
103 | if not(isRealtime(utcdatatime = dataOut.utctime)): | |
104 | print 'Skipping this plot function' |
|
104 | print 'Skipping this plot function' | |
105 | return |
|
105 | return | |
106 |
|
106 | |||
107 | if channelList == None: |
|
107 | if channelList == None: | |
108 | channelIndexList = dataOut.channelIndexList |
|
108 | channelIndexList = dataOut.channelIndexList | |
109 | else: |
|
109 | else: | |
110 | channelIndexList = [] |
|
110 | channelIndexList = [] | |
111 | for channel in channelList: |
|
111 | for channel in channelList: | |
112 | if channel not in dataOut.channelList: |
|
112 | if channel not in dataOut.channelList: | |
113 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
113 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
114 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
114 | channelIndexList.append(dataOut.channelList.index(channel)) | |
115 |
|
115 | |||
116 | factor = dataOut.normFactor |
|
116 | factor = dataOut.normFactor | |
117 |
|
117 | |||
118 | x = dataOut.getVelRange(1) |
|
118 | x = dataOut.getVelRange(1) | |
119 | y = dataOut.getHeiRange() |
|
119 | y = dataOut.getHeiRange() | |
120 |
|
120 | |||
121 | z = dataOut.data_spc[channelIndexList,:,:]/factor |
|
121 | z = dataOut.data_spc[channelIndexList,:,:]/factor | |
122 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
122 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
123 | avg = numpy.average(z, axis=1) |
|
123 | avg = numpy.average(z, axis=1) | |
124 | avg = numpy.nanmean(z, axis=1) |
|
124 | avg = numpy.nanmean(z, axis=1) | |
125 | noise = dataOut.noise/factor |
|
125 | noise = dataOut.noise/factor | |
126 |
|
126 | |||
127 | zdB = 10*numpy.log10(z) |
|
127 | zdB = 10*numpy.log10(z) | |
128 | avgdB = 10*numpy.log10(avg) |
|
128 | avgdB = 10*numpy.log10(avg) | |
129 | noisedB = 10*numpy.log10(noise) |
|
129 | noisedB = 10*numpy.log10(noise) | |
130 |
|
130 | |||
131 | #thisDatetime = dataOut.datatime |
|
131 | #thisDatetime = dataOut.datatime | |
132 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) |
|
132 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) | |
133 | title = wintitle + " Spectra" |
|
133 | title = wintitle + " Spectra" | |
134 | xlabel = "Velocity (m/s)" |
|
134 | xlabel = "Velocity (m/s)" | |
135 | ylabel = "Range (Km)" |
|
135 | ylabel = "Range (Km)" | |
136 |
|
136 | |||
137 | if not self.isConfig: |
|
137 | if not self.isConfig: | |
138 |
|
138 | |||
139 | nplots = len(channelIndexList) |
|
139 | nplots = len(channelIndexList) | |
140 |
|
140 | |||
141 | self.setup(id=id, |
|
141 | self.setup(id=id, | |
142 | nplots=nplots, |
|
142 | nplots=nplots, | |
143 | wintitle=wintitle, |
|
143 | wintitle=wintitle, | |
144 | showprofile=showprofile, |
|
144 | showprofile=showprofile, | |
145 | show=show) |
|
145 | show=show) | |
146 |
|
146 | |||
147 | if xmin == None: xmin = numpy.nanmin(x) |
|
147 | if xmin == None: xmin = numpy.nanmin(x) | |
148 | if xmax == None: xmax = numpy.nanmax(x) |
|
148 | if xmax == None: xmax = numpy.nanmax(x) | |
149 | if ymin == None: ymin = numpy.nanmin(y) |
|
149 | if ymin == None: ymin = numpy.nanmin(y) | |
150 | if ymax == None: ymax = numpy.nanmax(y) |
|
150 | if ymax == None: ymax = numpy.nanmax(y) | |
151 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 |
|
151 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 | |
152 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 |
|
152 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 | |
153 |
|
153 | |||
154 | self.FTP_WEI = ftp_wei |
|
154 | self.FTP_WEI = ftp_wei | |
155 | self.EXP_CODE = exp_code |
|
155 | self.EXP_CODE = exp_code | |
156 | self.SUB_EXP_CODE = sub_exp_code |
|
156 | self.SUB_EXP_CODE = sub_exp_code | |
157 | self.PLOT_POS = plot_pos |
|
157 | self.PLOT_POS = plot_pos | |
158 |
|
158 | |||
159 | self.isConfig = True |
|
159 | self.isConfig = True | |
160 |
|
160 | |||
161 | self.setWinTitle(title) |
|
161 | self.setWinTitle(title) | |
162 |
|
162 | |||
163 | for i in range(self.nplots): |
|
163 | for i in range(self.nplots): | |
164 | str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) |
|
164 | str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) | |
165 | title = "Channel %d: %4.2fdB: %s" %(dataOut.channelList[i]+1, noisedB[i], str_datetime) |
|
165 | title = "Channel %d: %4.2fdB: %s" %(dataOut.channelList[i]+1, noisedB[i], str_datetime) | |
166 | axes = self.axesList[i*self.__nsubplots] |
|
166 | axes = self.axesList[i*self.__nsubplots] | |
167 | axes.pcolor(x, y, zdB[i,:,:], |
|
167 | axes.pcolor(x, y, zdB[i,:,:], | |
168 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
168 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
169 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
169 | xlabel=xlabel, ylabel=ylabel, title=title, | |
170 | ticksize=9, cblabel='') |
|
170 | ticksize=9, cblabel='') | |
171 |
|
171 | |||
172 | if self.__showprofile: |
|
172 | if self.__showprofile: | |
173 | axes = self.axesList[i*self.__nsubplots +1] |
|
173 | axes = self.axesList[i*self.__nsubplots +1] | |
174 | axes.pline(avgdB[i], y, |
|
174 | axes.pline(avgdB[i], y, | |
175 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, |
|
175 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, | |
176 | xlabel='dB', ylabel='', title='', |
|
176 | xlabel='dB', ylabel='', title='', | |
177 | ytick_visible=False, |
|
177 | ytick_visible=False, | |
178 | grid='x') |
|
178 | grid='x') | |
179 |
|
179 | |||
180 | noiseline = numpy.repeat(noisedB[i], len(y)) |
|
180 | noiseline = numpy.repeat(noisedB[i], len(y)) | |
181 | axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2) |
|
181 | axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2) | |
182 |
|
182 | |||
183 | self.draw() |
|
183 | self.draw() | |
184 |
|
184 | |||
185 | if figfile == None: |
|
185 | if figfile == None: | |
186 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
186 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
187 | figfile = self.getFilename(name = str_datetime) |
|
187 | figfile = self.getFilename(name = str_datetime) | |
188 |
|
188 | |||
189 | if figpath != '': |
|
189 | if figpath != '': | |
190 | self.counter_imagwr += 1 |
|
190 | self.counter_imagwr += 1 | |
191 | if (self.counter_imagwr>=wr_period): |
|
191 | if (self.counter_imagwr>=wr_period): | |
192 | # store png plot to local folder |
|
192 | # store png plot to local folder | |
193 | self.saveFigure(figpath, figfile) |
|
193 | self.saveFigure(figpath, figfile) | |
194 | # store png plot to FTP server according to RT-Web format |
|
194 | # store png plot to FTP server according to RT-Web format | |
195 | name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) |
|
195 | name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) | |
196 | ftp_filename = os.path.join(figpath, name) |
|
196 | ftp_filename = os.path.join(figpath, name) | |
197 | self.saveFigure(figpath, ftp_filename) |
|
197 | self.saveFigure(figpath, ftp_filename) | |
198 | self.counter_imagwr = 0 |
|
198 | self.counter_imagwr = 0 | |
199 |
|
199 | |||
200 |
|
200 | |||
201 | class CrossSpectraPlot(Figure): |
|
201 | class CrossSpectraPlot(Figure): | |
202 |
|
202 | |||
203 | isConfig = None |
|
203 | isConfig = None | |
204 | __nsubplots = None |
|
204 | __nsubplots = None | |
205 |
|
205 | |||
206 | WIDTH = None |
|
206 | WIDTH = None | |
207 | HEIGHT = None |
|
207 | HEIGHT = None | |
208 | WIDTHPROF = None |
|
208 | WIDTHPROF = None | |
209 | HEIGHTPROF = None |
|
209 | HEIGHTPROF = None | |
210 | PREFIX = 'cspc' |
|
210 | PREFIX = 'cspc' | |
211 |
|
211 | |||
212 | def __init__(self): |
|
212 | def __init__(self): | |
213 |
|
213 | |||
214 | self.isConfig = False |
|
214 | self.isConfig = False | |
215 | self.__nsubplots = 4 |
|
215 | self.__nsubplots = 4 | |
216 | self.counter_imagwr = 0 |
|
216 | self.counter_imagwr = 0 | |
217 | self.WIDTH = 250 |
|
217 | self.WIDTH = 250 | |
218 | self.HEIGHT = 250 |
|
218 | self.HEIGHT = 250 | |
219 | self.WIDTHPROF = 0 |
|
219 | self.WIDTHPROF = 0 | |
220 | self.HEIGHTPROF = 0 |
|
220 | self.HEIGHTPROF = 0 | |
221 |
|
221 | |||
222 | self.PLOT_CODE = 1 |
|
222 | self.PLOT_CODE = 1 | |
223 | self.FTP_WEI = None |
|
223 | self.FTP_WEI = None | |
224 | self.EXP_CODE = None |
|
224 | self.EXP_CODE = None | |
225 | self.SUB_EXP_CODE = None |
|
225 | self.SUB_EXP_CODE = None | |
226 | self.PLOT_POS = None |
|
226 | self.PLOT_POS = None | |
227 |
|
227 | |||
228 | def getSubplots(self): |
|
228 | def getSubplots(self): | |
229 |
|
229 | |||
230 | ncol = 4 |
|
230 | ncol = 4 | |
231 | nrow = self.nplots |
|
231 | nrow = self.nplots | |
232 |
|
232 | |||
233 | return nrow, ncol |
|
233 | return nrow, ncol | |
234 |
|
234 | |||
235 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
235 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
236 |
|
236 | |||
237 | self.__showprofile = showprofile |
|
237 | self.__showprofile = showprofile | |
238 | self.nplots = nplots |
|
238 | self.nplots = nplots | |
239 |
|
239 | |||
240 | ncolspan = 1 |
|
240 | ncolspan = 1 | |
241 | colspan = 1 |
|
241 | colspan = 1 | |
242 |
|
242 | |||
243 | self.createFigure(id = id, |
|
243 | self.createFigure(id = id, | |
244 | wintitle = wintitle, |
|
244 | wintitle = wintitle, | |
245 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
245 | widthplot = self.WIDTH + self.WIDTHPROF, | |
246 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
246 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
247 | show=True) |
|
247 | show=True) | |
248 |
|
248 | |||
249 | nrow, ncol = self.getSubplots() |
|
249 | nrow, ncol = self.getSubplots() | |
250 |
|
250 | |||
251 | counter = 0 |
|
251 | counter = 0 | |
252 | for y in range(nrow): |
|
252 | for y in range(nrow): | |
253 | for x in range(ncol): |
|
253 | for x in range(ncol): | |
254 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
254 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
255 |
|
255 | |||
256 | counter += 1 |
|
256 | counter += 1 | |
257 |
|
257 | |||
258 | def run(self, dataOut, id, wintitle="", pairsList=None, |
|
258 | def run(self, dataOut, id, wintitle="", pairsList=None, | |
259 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
259 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
260 | save=False, figpath='./', figfile=None, ftp=False, wr_period=1, |
|
260 | save=False, figpath='./', figfile=None, ftp=False, wr_period=1, | |
261 | power_cmap='jet', coherence_cmap='jet', phase_cmap='RdBu_r', show=True, |
|
261 | power_cmap='jet', coherence_cmap='jet', phase_cmap='RdBu_r', show=True, | |
262 | server=None, folder=None, username=None, password=None, |
|
262 | server=None, folder=None, username=None, password=None, | |
263 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): |
|
263 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): | |
264 |
|
264 | |||
265 | """ |
|
265 | """ | |
266 |
|
266 | |||
267 | Input: |
|
267 | Input: | |
268 | dataOut : |
|
268 | dataOut : | |
269 | id : |
|
269 | id : | |
270 | wintitle : |
|
270 | wintitle : | |
271 | channelList : |
|
271 | channelList : | |
272 | showProfile : |
|
272 | showProfile : | |
273 | xmin : None, |
|
273 | xmin : None, | |
274 | xmax : None, |
|
274 | xmax : None, | |
275 | ymin : None, |
|
275 | ymin : None, | |
276 | ymax : None, |
|
276 | ymax : None, | |
277 | zmin : None, |
|
277 | zmin : None, | |
278 | zmax : None |
|
278 | zmax : None | |
279 | """ |
|
279 | """ | |
280 |
|
280 | |||
281 | if pairsList == None: |
|
281 | if pairsList == None: | |
282 | pairsIndexList = dataOut.pairsIndexList |
|
282 | pairsIndexList = dataOut.pairsIndexList | |
283 | else: |
|
283 | else: | |
284 | pairsIndexList = [] |
|
284 | pairsIndexList = [] | |
285 | for pair in pairsList: |
|
285 | for pair in pairsList: | |
286 | if pair not in dataOut.pairsList: |
|
286 | if pair not in dataOut.pairsList: | |
287 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) |
|
287 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) | |
288 | pairsIndexList.append(dataOut.pairsList.index(pair)) |
|
288 | pairsIndexList.append(dataOut.pairsList.index(pair)) | |
289 |
|
289 | |||
290 | if pairsIndexList == []: |
|
290 | if pairsIndexList == []: | |
291 | return |
|
291 | return | |
292 |
|
292 | |||
293 | if len(pairsIndexList) > 4: |
|
293 | if len(pairsIndexList) > 4: | |
294 | pairsIndexList = pairsIndexList[0:4] |
|
294 | pairsIndexList = pairsIndexList[0:4] | |
295 | factor = dataOut.normFactor |
|
295 | factor = dataOut.normFactor | |
296 | x = dataOut.getVelRange(1) |
|
296 | x = dataOut.getVelRange(1) | |
297 | y = dataOut.getHeiRange() |
|
297 | y = dataOut.getHeiRange() | |
298 | z = dataOut.data_spc[:,:,:]/factor |
|
298 | z = dataOut.data_spc[:,:,:]/factor | |
299 | # z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
299 | # z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
300 | avg = numpy.abs(numpy.average(z, axis=1)) |
|
300 | avg = numpy.abs(numpy.average(z, axis=1)) | |
301 | noise = dataOut.noise()/factor |
|
301 | noise = dataOut.noise()/factor | |
302 |
|
302 | |||
303 | zdB = 10*numpy.log10(z) |
|
303 | zdB = 10*numpy.log10(z) | |
304 | avgdB = 10*numpy.log10(avg) |
|
304 | avgdB = 10*numpy.log10(avg) | |
305 | noisedB = 10*numpy.log10(noise) |
|
305 | noisedB = 10*numpy.log10(noise) | |
306 |
|
306 | |||
307 |
|
307 | |||
308 | #thisDatetime = dataOut.datatime |
|
308 | #thisDatetime = dataOut.datatime | |
309 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) |
|
309 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) | |
310 | title = wintitle + " Cross-Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
310 | title = wintitle + " Cross-Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
311 | xlabel = "Velocity (m/s)" |
|
311 | xlabel = "Velocity (m/s)" | |
312 | ylabel = "Range (Km)" |
|
312 | ylabel = "Range (Km)" | |
313 |
|
313 | |||
314 | if not self.isConfig: |
|
314 | if not self.isConfig: | |
315 |
|
315 | |||
316 | nplots = len(pairsIndexList) |
|
316 | nplots = len(pairsIndexList) | |
317 |
|
317 | |||
318 | self.setup(id=id, |
|
318 | self.setup(id=id, | |
319 | nplots=nplots, |
|
319 | nplots=nplots, | |
320 | wintitle=wintitle, |
|
320 | wintitle=wintitle, | |
321 | showprofile=False, |
|
321 | showprofile=False, | |
322 | show=show) |
|
322 | show=show) | |
323 |
|
323 | |||
324 | if xmin == None: xmin = numpy.nanmin(x) |
|
324 | if xmin == None: xmin = numpy.nanmin(x) | |
325 | if xmax == None: xmax = numpy.nanmax(x) |
|
325 | if xmax == None: xmax = numpy.nanmax(x) | |
326 | if ymin == None: ymin = numpy.nanmin(y) |
|
326 | if ymin == None: ymin = numpy.nanmin(y) | |
327 | if ymax == None: ymax = numpy.nanmax(y) |
|
327 | if ymax == None: ymax = numpy.nanmax(y) | |
328 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 |
|
328 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 | |
329 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 |
|
329 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 | |
330 |
|
330 | |||
331 | self.FTP_WEI = ftp_wei |
|
331 | self.FTP_WEI = ftp_wei | |
332 | self.EXP_CODE = exp_code |
|
332 | self.EXP_CODE = exp_code | |
333 | self.SUB_EXP_CODE = sub_exp_code |
|
333 | self.SUB_EXP_CODE = sub_exp_code | |
334 | self.PLOT_POS = plot_pos |
|
334 | self.PLOT_POS = plot_pos | |
335 |
|
335 | |||
336 | self.isConfig = True |
|
336 | self.isConfig = True | |
337 |
|
337 | |||
338 | self.setWinTitle(title) |
|
338 | self.setWinTitle(title) | |
339 |
|
339 | |||
340 | for i in range(self.nplots): |
|
340 | for i in range(self.nplots): | |
341 | pair = dataOut.pairsList[pairsIndexList[i]] |
|
341 | pair = dataOut.pairsList[pairsIndexList[i]] | |
342 | str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) |
|
342 | str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) | |
343 | title = "Ch%d: %4.2fdB: %s" %(pair[0], noisedB[pair[0]], str_datetime) |
|
343 | title = "Ch%d: %4.2fdB: %s" %(pair[0], noisedB[pair[0]], str_datetime) | |
344 | zdB = 10.*numpy.log10(dataOut.data_spc[pair[0],:,:]/factor) |
|
344 | zdB = 10.*numpy.log10(dataOut.data_spc[pair[0],:,:]/factor) | |
345 | axes0 = self.axesList[i*self.__nsubplots] |
|
345 | axes0 = self.axesList[i*self.__nsubplots] | |
346 | axes0.pcolor(x, y, zdB, |
|
346 | axes0.pcolor(x, y, zdB, | |
347 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
347 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
348 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
348 | xlabel=xlabel, ylabel=ylabel, title=title, | |
349 | ticksize=9, colormap=power_cmap, cblabel='') |
|
349 | ticksize=9, colormap=power_cmap, cblabel='') | |
350 |
|
350 | |||
351 | title = "Ch%d: %4.2fdB: %s" %(pair[1], noisedB[pair[1]], str_datetime) |
|
351 | title = "Ch%d: %4.2fdB: %s" %(pair[1], noisedB[pair[1]], str_datetime) | |
352 | zdB = 10.*numpy.log10(dataOut.data_spc[pair[1],:,:]/factor) |
|
352 | zdB = 10.*numpy.log10(dataOut.data_spc[pair[1],:,:]/factor) | |
353 | axes0 = self.axesList[i*self.__nsubplots+1] |
|
353 | axes0 = self.axesList[i*self.__nsubplots+1] | |
354 | axes0.pcolor(x, y, zdB, |
|
354 | axes0.pcolor(x, y, zdB, | |
355 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
355 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
356 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
356 | xlabel=xlabel, ylabel=ylabel, title=title, | |
357 | ticksize=9, colormap=power_cmap, cblabel='') |
|
357 | ticksize=9, colormap=power_cmap, cblabel='') | |
358 |
|
358 | |||
359 | coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:]) |
|
359 | coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:]) | |
360 | coherence = numpy.abs(coherenceComplex) |
|
360 | coherence = numpy.abs(coherenceComplex) | |
361 | # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi |
|
361 | # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi | |
362 | phase = numpy.arctan2(coherenceComplex.imag, coherenceComplex.real)*180/numpy.pi |
|
362 | phase = numpy.arctan2(coherenceComplex.imag, coherenceComplex.real)*180/numpy.pi | |
363 |
|
363 | |||
364 | title = "Coherence %d%d" %(pair[0], pair[1]) |
|
364 | title = "Coherence %d%d" %(pair[0], pair[1]) | |
365 | axes0 = self.axesList[i*self.__nsubplots+2] |
|
365 | axes0 = self.axesList[i*self.__nsubplots+2] | |
366 | axes0.pcolor(x, y, coherence, |
|
366 | axes0.pcolor(x, y, coherence, | |
367 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1, |
|
367 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1, | |
368 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
368 | xlabel=xlabel, ylabel=ylabel, title=title, | |
369 | ticksize=9, colormap=coherence_cmap, cblabel='') |
|
369 | ticksize=9, colormap=coherence_cmap, cblabel='') | |
370 |
|
370 | |||
371 | title = "Phase %d%d" %(pair[0], pair[1]) |
|
371 | title = "Phase %d%d" %(pair[0], pair[1]) | |
372 | axes0 = self.axesList[i*self.__nsubplots+3] |
|
372 | axes0 = self.axesList[i*self.__nsubplots+3] | |
373 | axes0.pcolor(x, y, phase, |
|
373 | axes0.pcolor(x, y, phase, | |
374 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180, |
|
374 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180, | |
375 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
375 | xlabel=xlabel, ylabel=ylabel, title=title, | |
376 | ticksize=9, colormap=phase_cmap, cblabel='') |
|
376 | ticksize=9, colormap=phase_cmap, cblabel='') | |
377 |
|
377 | |||
378 |
|
378 | |||
379 |
|
379 | |||
380 | self.draw() |
|
380 | self.draw() | |
381 |
|
381 | |||
382 | if save: |
|
382 | if save: | |
383 |
|
383 | |||
384 | self.counter_imagwr += 1 |
|
384 | self.counter_imagwr += 1 | |
385 | if (self.counter_imagwr==wr_period): |
|
385 | if (self.counter_imagwr==wr_period): | |
386 | if figfile == None: |
|
386 | if figfile == None: | |
387 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
387 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
388 | figfile = self.getFilename(name = str_datetime) |
|
388 | figfile = self.getFilename(name = str_datetime) | |
389 |
|
389 | |||
390 | self.saveFigure(figpath, figfile) |
|
390 | self.saveFigure(figpath, figfile) | |
391 |
|
391 | |||
392 | if ftp: |
|
392 | if ftp: | |
393 | #provisionalmente envia archivos en el formato de la web en tiempo real |
|
393 | #provisionalmente envia archivos en el formato de la web en tiempo real | |
394 | name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) |
|
394 | name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) | |
395 | path = '%s%03d' %(self.PREFIX, self.id) |
|
395 | path = '%s%03d' %(self.PREFIX, self.id) | |
396 | ftp_file = os.path.join(path,'ftp','%s.png'%name) |
|
396 | ftp_file = os.path.join(path,'ftp','%s.png'%name) | |
397 | self.saveFigure(figpath, ftp_file) |
|
397 | self.saveFigure(figpath, ftp_file) | |
398 | ftp_filename = os.path.join(figpath,ftp_file) |
|
398 | ftp_filename = os.path.join(figpath,ftp_file) | |
399 |
|
399 | |||
400 | try: |
|
400 | try: | |
401 | self.sendByFTP(ftp_filename, server, folder, username, password) |
|
401 | self.sendByFTP(ftp_filename, server, folder, username, password) | |
402 | except: |
|
402 | except: | |
403 | self.counter_imagwr = 0 |
|
403 | self.counter_imagwr = 0 | |
404 | print ValueError, 'Error FTP' |
|
404 | print ValueError, 'Error FTP' | |
405 |
|
405 | |||
406 | self.counter_imagwr = 0 |
|
406 | self.counter_imagwr = 0 | |
407 |
|
407 | |||
408 | class RTIPlot(Figure): |
|
408 | class RTIPlot(Figure): | |
409 |
|
409 | |||
410 | isConfig = None |
|
410 | isConfig = None | |
411 | __nsubplots = None |
|
411 | __nsubplots = None | |
412 |
|
412 | |||
413 | WIDTHPROF = None |
|
413 | WIDTHPROF = None | |
414 | HEIGHTPROF = None |
|
414 | HEIGHTPROF = None | |
415 | PREFIX = 'rti' |
|
415 | PREFIX = 'rti' | |
416 |
|
416 | |||
417 | def __init__(self): |
|
417 | def __init__(self): | |
418 |
|
418 | |||
419 | self.timerange = 2*60*60 |
|
419 | self.timerange = 2*60*60 | |
420 | self.isConfig = False |
|
420 | self.isConfig = False | |
421 | self.__nsubplots = 1 |
|
421 | self.__nsubplots = 1 | |
422 |
|
422 | |||
423 | self.WIDTH = 800 |
|
423 | self.WIDTH = 800 | |
424 | self.HEIGHT = 150 |
|
424 | self.HEIGHT = 150 | |
425 | self.WIDTHPROF = 120 |
|
425 | self.WIDTHPROF = 120 | |
426 | self.HEIGHTPROF = 0 |
|
426 | self.HEIGHTPROF = 0 | |
427 | self.counter_imagwr = 0 |
|
427 | self.counter_imagwr = 0 | |
428 |
|
428 | |||
429 | self.PLOT_CODE = 0 |
|
429 | self.PLOT_CODE = 0 | |
430 | self.FTP_WEI = None |
|
430 | self.FTP_WEI = None | |
431 | self.EXP_CODE = None |
|
431 | self.EXP_CODE = None | |
432 | self.SUB_EXP_CODE = None |
|
432 | self.SUB_EXP_CODE = None | |
433 | self.PLOT_POS = None |
|
433 | self.PLOT_POS = None | |
434 | self.tmin = None |
|
434 | self.tmin = None | |
435 | self.tmax = None |
|
435 | self.tmax = None | |
436 |
|
436 | |||
437 | self.xmin = None |
|
437 | self.xmin = None | |
438 | self.xmax = None |
|
438 | self.xmax = None | |
439 |
|
439 | |||
|
440 | self.figfile = None | |||
|
441 | ||||
440 | def getSubplots(self): |
|
442 | def getSubplots(self): | |
441 |
|
443 | |||
442 | ncol = 1 |
|
444 | ncol = 1 | |
443 | nrow = self.nplots |
|
445 | nrow = self.nplots | |
444 |
|
446 | |||
445 | return nrow, ncol |
|
447 | return nrow, ncol | |
446 |
|
448 | |||
447 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
449 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
448 |
|
450 | |||
449 | self.__showprofile = showprofile |
|
451 | self.__showprofile = showprofile | |
450 | self.nplots = nplots |
|
452 | self.nplots = nplots | |
451 |
|
453 | |||
452 | ncolspan = 1 |
|
454 | ncolspan = 1 | |
453 | colspan = 1 |
|
455 | colspan = 1 | |
454 | if showprofile: |
|
456 | if showprofile: | |
455 | ncolspan = 7 |
|
457 | ncolspan = 7 | |
456 | colspan = 6 |
|
458 | colspan = 6 | |
457 | self.__nsubplots = 2 |
|
459 | self.__nsubplots = 2 | |
458 |
|
460 | |||
459 | self.createFigure(id = id, |
|
461 | self.createFigure(id = id, | |
460 | wintitle = wintitle, |
|
462 | wintitle = wintitle, | |
461 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
463 | widthplot = self.WIDTH + self.WIDTHPROF, | |
462 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
464 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
463 | show=show) |
|
465 | show=show) | |
464 |
|
466 | |||
465 | nrow, ncol = self.getSubplots() |
|
467 | nrow, ncol = self.getSubplots() | |
466 |
|
468 | |||
467 | counter = 0 |
|
469 | counter = 0 | |
468 | for y in range(nrow): |
|
470 | for y in range(nrow): | |
469 | for x in range(ncol): |
|
471 | for x in range(ncol): | |
470 |
|
472 | |||
471 | if counter >= self.nplots: |
|
473 | if counter >= self.nplots: | |
472 | break |
|
474 | break | |
473 |
|
475 | |||
474 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
476 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
475 |
|
477 | |||
476 | if showprofile: |
|
478 | if showprofile: | |
477 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
479 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
478 |
|
480 | |||
479 | counter += 1 |
|
481 | counter += 1 | |
480 |
|
482 | |||
481 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True', |
|
483 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True', | |
482 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
484 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
483 | timerange=None, |
|
485 | timerange=None, | |
484 | save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True, |
|
486 | save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True, | |
485 | server=None, folder=None, username=None, password=None, |
|
487 | server=None, folder=None, username=None, password=None, | |
486 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): |
|
488 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): | |
487 |
|
489 | |||
488 | """ |
|
490 | """ | |
489 |
|
491 | |||
490 | Input: |
|
492 | Input: | |
491 | dataOut : |
|
493 | dataOut : | |
492 | id : |
|
494 | id : | |
493 | wintitle : |
|
495 | wintitle : | |
494 | channelList : |
|
496 | channelList : | |
495 | showProfile : |
|
497 | showProfile : | |
496 | xmin : None, |
|
498 | xmin : None, | |
497 | xmax : None, |
|
499 | xmax : None, | |
498 | ymin : None, |
|
500 | ymin : None, | |
499 | ymax : None, |
|
501 | ymax : None, | |
500 | zmin : None, |
|
502 | zmin : None, | |
501 | zmax : None |
|
503 | zmax : None | |
502 | """ |
|
504 | """ | |
503 |
|
505 | |||
504 | if channelList == None: |
|
506 | if channelList == None: | |
505 | channelIndexList = dataOut.channelIndexList |
|
507 | channelIndexList = dataOut.channelIndexList | |
506 | else: |
|
508 | else: | |
507 | channelIndexList = [] |
|
509 | channelIndexList = [] | |
508 | for channel in channelList: |
|
510 | for channel in channelList: | |
509 | if channel not in dataOut.channelList: |
|
511 | if channel not in dataOut.channelList: | |
510 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
512 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
511 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
513 | channelIndexList.append(dataOut.channelList.index(channel)) | |
512 |
|
514 | |||
513 | if timerange != None: |
|
515 | if timerange != None: | |
514 | self.timerange = timerange |
|
516 | self.timerange = timerange | |
515 |
|
517 | |||
516 | #tmin = None |
|
518 | #tmin = None | |
517 | #tmax = None |
|
519 | #tmax = None | |
518 | factor = dataOut.normFactor |
|
520 | factor = dataOut.normFactor | |
519 | x = dataOut.getTimeRange() |
|
521 | x = dataOut.getTimeRange() | |
520 | y = dataOut.getHeiRange() |
|
522 | y = dataOut.getHeiRange() | |
521 |
|
523 | |||
522 | z = dataOut.data_spc[channelIndexList,:,:]/factor |
|
524 | z = dataOut.data_spc[channelIndexList,:,:]/factor | |
523 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
525 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
524 | avg = numpy.average(z, axis=1) |
|
526 | avg = numpy.average(z, axis=1) | |
525 |
|
527 | |||
526 | avgdB = 10.*numpy.log10(avg) |
|
528 | avgdB = 10.*numpy.log10(avg) | |
527 |
|
529 | |||
528 |
|
530 | |||
529 | # thisDatetime = dataOut.datatime |
|
531 | # thisDatetime = dataOut.datatime | |
530 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) |
|
532 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) | |
531 | title = wintitle + " RTI" #: %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
533 | title = wintitle + " RTI" #: %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
532 | xlabel = "" |
|
534 | xlabel = "" | |
533 | ylabel = "Range (Km)" |
|
535 | ylabel = "Range (Km)" | |
534 |
|
536 | |||
535 | if not self.isConfig: |
|
537 | if not self.isConfig: | |
536 |
|
538 | |||
537 | nplots = len(channelIndexList) |
|
539 | nplots = len(channelIndexList) | |
538 |
|
540 | |||
539 | self.setup(id=id, |
|
541 | self.setup(id=id, | |
540 | nplots=nplots, |
|
542 | nplots=nplots, | |
541 | wintitle=wintitle, |
|
543 | wintitle=wintitle, | |
542 | showprofile=showprofile, |
|
544 | showprofile=showprofile, | |
543 | show=show) |
|
545 | show=show) | |
544 |
|
546 | |||
545 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) |
|
547 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) | |
546 |
|
548 | |||
547 | # if timerange != None: |
|
549 | # if timerange != None: | |
548 | # self.timerange = timerange |
|
550 | # self.timerange = timerange | |
549 | # self.xmin, self.tmax = self.getTimeLim(x, xmin, xmax, timerange) |
|
551 | # self.xmin, self.tmax = self.getTimeLim(x, xmin, xmax, timerange) | |
550 |
|
552 | |||
551 |
|
553 | |||
552 |
|
554 | |||
553 | if ymin == None: ymin = numpy.nanmin(y) |
|
555 | if ymin == None: ymin = numpy.nanmin(y) | |
554 | if ymax == None: ymax = numpy.nanmax(y) |
|
556 | if ymax == None: ymax = numpy.nanmax(y) | |
555 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 |
|
557 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 | |
556 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 |
|
558 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 | |
557 |
|
559 | |||
558 | self.FTP_WEI = ftp_wei |
|
560 | self.FTP_WEI = ftp_wei | |
559 | self.EXP_CODE = exp_code |
|
561 | self.EXP_CODE = exp_code | |
560 | self.SUB_EXP_CODE = sub_exp_code |
|
562 | self.SUB_EXP_CODE = sub_exp_code | |
561 | self.PLOT_POS = plot_pos |
|
563 | self.PLOT_POS = plot_pos | |
562 |
|
564 | |||
563 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
565 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
564 | self.isConfig = True |
|
566 | self.isConfig = True | |
565 |
|
567 | self.figfile = figfile | ||
566 |
|
568 | |||
567 | self.setWinTitle(title) |
|
569 | self.setWinTitle(title) | |
568 |
|
570 | |||
569 | if ((self.xmax - x[1]) < (x[1]-x[0])): |
|
571 | if ((self.xmax - x[1]) < (x[1]-x[0])): | |
570 | x[1] = self.xmax |
|
572 | x[1] = self.xmax | |
571 |
|
573 | |||
572 | for i in range(self.nplots): |
|
574 | for i in range(self.nplots): | |
573 | title = "Channel %d: %s" %(dataOut.channelList[i]+1, thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
575 | title = "Channel %d: %s" %(dataOut.channelList[i]+1, thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
574 | axes = self.axesList[i*self.__nsubplots] |
|
576 | axes = self.axesList[i*self.__nsubplots] | |
575 | zdB = avgdB[i].reshape((1,-1)) |
|
577 | zdB = avgdB[i].reshape((1,-1)) | |
576 | axes.pcolorbuffer(x, y, zdB, |
|
578 | axes.pcolorbuffer(x, y, zdB, | |
577 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
579 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
578 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
580 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
579 | ticksize=9, cblabel='', cbsize="1%") |
|
581 | ticksize=9, cblabel='', cbsize="1%") | |
580 |
|
582 | |||
581 | if self.__showprofile: |
|
583 | if self.__showprofile: | |
582 | axes = self.axesList[i*self.__nsubplots +1] |
|
584 | axes = self.axesList[i*self.__nsubplots +1] | |
583 | axes.pline(avgdB[i], y, |
|
585 | axes.pline(avgdB[i], y, | |
584 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, |
|
586 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, | |
585 | xlabel='dB', ylabel='', title='', |
|
587 | xlabel='dB', ylabel='', title='', | |
586 | ytick_visible=False, |
|
588 | ytick_visible=False, | |
587 | grid='x') |
|
589 | grid='x') | |
588 |
|
590 | |||
589 | self.draw() |
|
591 | self.draw() | |
590 |
|
592 | |||
591 | if x[1] >= self.axesList[0].xmax: |
|
593 | if x[1] >= self.axesList[0].xmax: | |
592 | self.counter_imagwr = wr_period |
|
594 | self.counter_imagwr = wr_period | |
593 | self.__isConfig = False |
|
595 | self.__isConfig = False | |
594 |
|
596 | |||
595 | if figfile == None: |
|
597 | ||
|
598 | if self.figfile == None: | |||
596 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
599 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
597 | figfile = self.getFilename(name = str_datetime) |
|
600 | self.figfile = self.getFilename(name = str_datetime) | |
598 |
|
601 | |||
599 | if figpath != '': |
|
602 | if figpath != '': | |
600 |
|
603 | |||
601 | self.counter_imagwr += 1 |
|
604 | self.counter_imagwr += 1 | |
602 | if (self.counter_imagwr>=wr_period): |
|
605 | if (self.counter_imagwr>=wr_period): | |
603 | # store png plot to local folder |
|
606 | # store png plot to local folder | |
604 | self.saveFigure(figpath, figfile) |
|
607 | self.saveFigure(figpath, self.figfile) | |
605 | # store png plot to FTP server according to RT-Web format |
|
608 | # store png plot to FTP server according to RT-Web format | |
606 | name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) |
|
609 | name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) | |
607 | ftp_filename = os.path.join(figpath, name) |
|
610 | ftp_filename = os.path.join(figpath, name) | |
608 | self.saveFigure(figpath, ftp_filename) |
|
611 | self.saveFigure(figpath, ftp_filename) | |
609 |
|
612 | |||
610 | self.counter_imagwr = 0 |
|
613 | self.counter_imagwr = 0 | |
611 |
|
614 | |||
612 |
|
615 | |||
613 | class CoherenceMap(Figure): |
|
616 | class CoherenceMap(Figure): | |
614 | isConfig = None |
|
617 | isConfig = None | |
615 | __nsubplots = None |
|
618 | __nsubplots = None | |
616 |
|
619 | |||
617 | WIDTHPROF = None |
|
620 | WIDTHPROF = None | |
618 | HEIGHTPROF = None |
|
621 | HEIGHTPROF = None | |
619 | PREFIX = 'cmap' |
|
622 | PREFIX = 'cmap' | |
620 |
|
623 | |||
621 | def __init__(self): |
|
624 | def __init__(self): | |
622 | self.timerange = 2*60*60 |
|
625 | self.timerange = 2*60*60 | |
623 | self.isConfig = False |
|
626 | self.isConfig = False | |
624 | self.__nsubplots = 1 |
|
627 | self.__nsubplots = 1 | |
625 |
|
628 | |||
626 | self.WIDTH = 800 |
|
629 | self.WIDTH = 800 | |
627 | self.HEIGHT = 150 |
|
630 | self.HEIGHT = 150 | |
628 | self.WIDTHPROF = 120 |
|
631 | self.WIDTHPROF = 120 | |
629 | self.HEIGHTPROF = 0 |
|
632 | self.HEIGHTPROF = 0 | |
630 | self.counter_imagwr = 0 |
|
633 | self.counter_imagwr = 0 | |
631 |
|
634 | |||
632 | self.PLOT_CODE = 3 |
|
635 | self.PLOT_CODE = 3 | |
633 | self.FTP_WEI = None |
|
636 | self.FTP_WEI = None | |
634 | self.EXP_CODE = None |
|
637 | self.EXP_CODE = None | |
635 | self.SUB_EXP_CODE = None |
|
638 | self.SUB_EXP_CODE = None | |
636 | self.PLOT_POS = None |
|
639 | self.PLOT_POS = None | |
637 | self.counter_imagwr = 0 |
|
640 | self.counter_imagwr = 0 | |
638 |
|
641 | |||
639 | self.xmin = None |
|
642 | self.xmin = None | |
640 | self.xmax = None |
|
643 | self.xmax = None | |
641 |
|
644 | |||
642 | def getSubplots(self): |
|
645 | def getSubplots(self): | |
643 | ncol = 1 |
|
646 | ncol = 1 | |
644 | nrow = self.nplots*2 |
|
647 | nrow = self.nplots*2 | |
645 |
|
648 | |||
646 | return nrow, ncol |
|
649 | return nrow, ncol | |
647 |
|
650 | |||
648 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
651 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
649 | self.__showprofile = showprofile |
|
652 | self.__showprofile = showprofile | |
650 | self.nplots = nplots |
|
653 | self.nplots = nplots | |
651 |
|
654 | |||
652 | ncolspan = 1 |
|
655 | ncolspan = 1 | |
653 | colspan = 1 |
|
656 | colspan = 1 | |
654 | if showprofile: |
|
657 | if showprofile: | |
655 | ncolspan = 7 |
|
658 | ncolspan = 7 | |
656 | colspan = 6 |
|
659 | colspan = 6 | |
657 | self.__nsubplots = 2 |
|
660 | self.__nsubplots = 2 | |
658 |
|
661 | |||
659 | self.createFigure(id = id, |
|
662 | self.createFigure(id = id, | |
660 | wintitle = wintitle, |
|
663 | wintitle = wintitle, | |
661 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
664 | widthplot = self.WIDTH + self.WIDTHPROF, | |
662 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
665 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
663 | show=True) |
|
666 | show=True) | |
664 |
|
667 | |||
665 | nrow, ncol = self.getSubplots() |
|
668 | nrow, ncol = self.getSubplots() | |
666 |
|
669 | |||
667 | for y in range(nrow): |
|
670 | for y in range(nrow): | |
668 | for x in range(ncol): |
|
671 | for x in range(ncol): | |
669 |
|
672 | |||
670 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
673 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
671 |
|
674 | |||
672 | if showprofile: |
|
675 | if showprofile: | |
673 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
676 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
674 |
|
677 | |||
675 | def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True', |
|
678 | def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True', | |
676 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
679 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
677 | timerange=None, |
|
680 | timerange=None, | |
678 | save=False, figpath='./', figfile=None, ftp=False, wr_period=1, |
|
681 | save=False, figpath='./', figfile=None, ftp=False, wr_period=1, | |
679 | coherence_cmap='jet', phase_cmap='RdBu_r', show=True, |
|
682 | coherence_cmap='jet', phase_cmap='RdBu_r', show=True, | |
680 | server=None, folder=None, username=None, password=None, |
|
683 | server=None, folder=None, username=None, password=None, | |
681 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): |
|
684 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): | |
682 |
|
685 | |||
683 | if pairsList == None: |
|
686 | if pairsList == None: | |
684 | pairsIndexList = dataOut.pairsIndexList |
|
687 | pairsIndexList = dataOut.pairsIndexList | |
685 | else: |
|
688 | else: | |
686 | pairsIndexList = [] |
|
689 | pairsIndexList = [] | |
687 | for pair in pairsList: |
|
690 | for pair in pairsList: | |
688 | if pair not in dataOut.pairsList: |
|
691 | if pair not in dataOut.pairsList: | |
689 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) |
|
692 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) | |
690 | pairsIndexList.append(dataOut.pairsList.index(pair)) |
|
693 | pairsIndexList.append(dataOut.pairsList.index(pair)) | |
691 |
|
694 | |||
692 | if timerange != None: |
|
695 | if timerange != None: | |
693 | self.timerange = timerange |
|
696 | self.timerange = timerange | |
694 |
|
697 | |||
695 | if pairsIndexList == []: |
|
698 | if pairsIndexList == []: | |
696 | return |
|
699 | return | |
697 |
|
700 | |||
698 | if len(pairsIndexList) > 4: |
|
701 | if len(pairsIndexList) > 4: | |
699 | pairsIndexList = pairsIndexList[0:4] |
|
702 | pairsIndexList = pairsIndexList[0:4] | |
700 |
|
703 | |||
701 | # tmin = None |
|
704 | # tmin = None | |
702 | # tmax = None |
|
705 | # tmax = None | |
703 | x = dataOut.getTimeRange() |
|
706 | x = dataOut.getTimeRange() | |
704 | y = dataOut.getHeiRange() |
|
707 | y = dataOut.getHeiRange() | |
705 |
|
708 | |||
706 | #thisDatetime = dataOut.datatime |
|
709 | #thisDatetime = dataOut.datatime | |
707 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) |
|
710 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) | |
708 | title = wintitle + " CoherenceMap" #: %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
711 | title = wintitle + " CoherenceMap" #: %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
709 | xlabel = "" |
|
712 | xlabel = "" | |
710 | ylabel = "Range (Km)" |
|
713 | ylabel = "Range (Km)" | |
711 |
|
714 | |||
712 | if not self.isConfig: |
|
715 | if not self.isConfig: | |
713 | nplots = len(pairsIndexList) |
|
716 | nplots = len(pairsIndexList) | |
714 | self.setup(id=id, |
|
717 | self.setup(id=id, | |
715 | nplots=nplots, |
|
718 | nplots=nplots, | |
716 | wintitle=wintitle, |
|
719 | wintitle=wintitle, | |
717 | showprofile=showprofile, |
|
720 | showprofile=showprofile, | |
718 | show=show) |
|
721 | show=show) | |
719 |
|
722 | |||
720 | #tmin, tmax = self.getTimeLim(x, xmin, xmax) |
|
723 | #tmin, tmax = self.getTimeLim(x, xmin, xmax) | |
721 |
|
724 | |||
722 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) |
|
725 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) | |
723 |
|
726 | |||
724 | if ymin == None: ymin = numpy.nanmin(y) |
|
727 | if ymin == None: ymin = numpy.nanmin(y) | |
725 | if ymax == None: ymax = numpy.nanmax(y) |
|
728 | if ymax == None: ymax = numpy.nanmax(y) | |
726 | if zmin == None: zmin = 0. |
|
729 | if zmin == None: zmin = 0. | |
727 | if zmax == None: zmax = 1. |
|
730 | if zmax == None: zmax = 1. | |
728 |
|
731 | |||
729 | self.FTP_WEI = ftp_wei |
|
732 | self.FTP_WEI = ftp_wei | |
730 | self.EXP_CODE = exp_code |
|
733 | self.EXP_CODE = exp_code | |
731 | self.SUB_EXP_CODE = sub_exp_code |
|
734 | self.SUB_EXP_CODE = sub_exp_code | |
732 | self.PLOT_POS = plot_pos |
|
735 | self.PLOT_POS = plot_pos | |
733 |
|
736 | |||
734 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
737 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
735 |
|
738 | |||
736 | self.isConfig = True |
|
739 | self.isConfig = True | |
737 |
|
740 | |||
738 | self.setWinTitle(title) |
|
741 | self.setWinTitle(title) | |
739 |
|
742 | |||
740 | if ((self.xmax - x[1]) < (x[1]-x[0])): |
|
743 | if ((self.xmax - x[1]) < (x[1]-x[0])): | |
741 | x[1] = self.xmax |
|
744 | x[1] = self.xmax | |
742 |
|
745 | |||
743 | for i in range(self.nplots): |
|
746 | for i in range(self.nplots): | |
744 |
|
747 | |||
745 | pair = dataOut.pairsList[pairsIndexList[i]] |
|
748 | pair = dataOut.pairsList[pairsIndexList[i]] | |
746 |
|
749 | |||
747 | ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i],:,:],axis=0) |
|
750 | ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i],:,:],axis=0) | |
748 | powa = numpy.average(dataOut.data_spc[pair[0],:,:],axis=0) |
|
751 | powa = numpy.average(dataOut.data_spc[pair[0],:,:],axis=0) | |
749 | powb = numpy.average(dataOut.data_spc[pair[1],:,:],axis=0) |
|
752 | powb = numpy.average(dataOut.data_spc[pair[1],:,:],axis=0) | |
750 |
|
753 | |||
751 |
|
754 | |||
752 | avgcoherenceComplex = ccf/numpy.sqrt(powa*powb) |
|
755 | avgcoherenceComplex = ccf/numpy.sqrt(powa*powb) | |
753 | coherence = numpy.abs(avgcoherenceComplex) |
|
756 | coherence = numpy.abs(avgcoherenceComplex) | |
754 |
|
757 | |||
755 | z = coherence.reshape((1,-1)) |
|
758 | z = coherence.reshape((1,-1)) | |
756 |
|
759 | |||
757 | counter = 0 |
|
760 | counter = 0 | |
758 |
|
761 | |||
759 | title = "Coherence %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
762 | title = "Coherence %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
760 | axes = self.axesList[i*self.__nsubplots*2] |
|
763 | axes = self.axesList[i*self.__nsubplots*2] | |
761 | axes.pcolorbuffer(x, y, z, |
|
764 | axes.pcolorbuffer(x, y, z, | |
762 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
765 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
763 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
766 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
764 | ticksize=9, cblabel='', colormap=coherence_cmap, cbsize="1%") |
|
767 | ticksize=9, cblabel='', colormap=coherence_cmap, cbsize="1%") | |
765 |
|
768 | |||
766 | if self.__showprofile: |
|
769 | if self.__showprofile: | |
767 | counter += 1 |
|
770 | counter += 1 | |
768 | axes = self.axesList[i*self.__nsubplots*2 + counter] |
|
771 | axes = self.axesList[i*self.__nsubplots*2 + counter] | |
769 | axes.pline(coherence, y, |
|
772 | axes.pline(coherence, y, | |
770 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, |
|
773 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, | |
771 | xlabel='', ylabel='', title='', ticksize=7, |
|
774 | xlabel='', ylabel='', title='', ticksize=7, | |
772 | ytick_visible=False, nxticks=5, |
|
775 | ytick_visible=False, nxticks=5, | |
773 | grid='x') |
|
776 | grid='x') | |
774 |
|
777 | |||
775 | counter += 1 |
|
778 | counter += 1 | |
776 |
|
779 | |||
777 | phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi |
|
780 | phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi | |
778 |
|
781 | |||
779 | z = phase.reshape((1,-1)) |
|
782 | z = phase.reshape((1,-1)) | |
780 |
|
783 | |||
781 | title = "Phase %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
784 | title = "Phase %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
782 | axes = self.axesList[i*self.__nsubplots*2 + counter] |
|
785 | axes = self.axesList[i*self.__nsubplots*2 + counter] | |
783 | axes.pcolorbuffer(x, y, z, |
|
786 | axes.pcolorbuffer(x, y, z, | |
784 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180, |
|
787 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180, | |
785 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
788 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
786 | ticksize=9, cblabel='', colormap=phase_cmap, cbsize="1%") |
|
789 | ticksize=9, cblabel='', colormap=phase_cmap, cbsize="1%") | |
787 |
|
790 | |||
788 | if self.__showprofile: |
|
791 | if self.__showprofile: | |
789 | counter += 1 |
|
792 | counter += 1 | |
790 | axes = self.axesList[i*self.__nsubplots*2 + counter] |
|
793 | axes = self.axesList[i*self.__nsubplots*2 + counter] | |
791 | axes.pline(phase, y, |
|
794 | axes.pline(phase, y, | |
792 | xmin=-180, xmax=180, ymin=ymin, ymax=ymax, |
|
795 | xmin=-180, xmax=180, ymin=ymin, ymax=ymax, | |
793 | xlabel='', ylabel='', title='', ticksize=7, |
|
796 | xlabel='', ylabel='', title='', ticksize=7, | |
794 | ytick_visible=False, nxticks=4, |
|
797 | ytick_visible=False, nxticks=4, | |
795 | grid='x') |
|
798 | grid='x') | |
796 |
|
799 | |||
797 | self.draw() |
|
800 | self.draw() | |
798 |
|
801 | |||
799 | if x[1] >= self.axesList[0].xmax: |
|
802 | if x[1] >= self.axesList[0].xmax: | |
800 | self.counter_imagwr = wr_period |
|
803 | self.counter_imagwr = wr_period | |
801 | self.__isConfig = False |
|
804 | self.__isConfig = False | |
802 |
|
805 | |||
803 | if figfile == None: |
|
806 | if figfile == None: | |
804 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
807 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
805 | figfile = self.getFilename(name = str_datetime) |
|
808 | figfile = self.getFilename(name = str_datetime) | |
806 |
|
809 | |||
807 | if figpath != '': |
|
810 | if figpath != '': | |
808 |
|
811 | |||
809 | self.counter_imagwr += 1 |
|
812 | self.counter_imagwr += 1 | |
810 | if (self.counter_imagwr>=wr_period): |
|
813 | if (self.counter_imagwr>=wr_period): | |
811 | # store png plot to local folder |
|
814 | # store png plot to local folder | |
812 | self.saveFigure(figpath, figfile) |
|
815 | self.saveFigure(figpath, figfile) | |
813 | # store png plot to FTP server according to RT-Web format |
|
816 | # store png plot to FTP server according to RT-Web format | |
814 | name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) |
|
817 | name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) | |
815 | ftp_filename = os.path.join(figpath, name) |
|
818 | ftp_filename = os.path.join(figpath, name) | |
816 | self.saveFigure(figpath, ftp_filename) |
|
819 | self.saveFigure(figpath, ftp_filename) | |
817 |
|
820 | |||
818 | self.counter_imagwr = 0 |
|
821 | self.counter_imagwr = 0 | |
819 |
|
822 | |||
820 | class PowerProfile(Figure): |
|
823 | class PowerProfile(Figure): | |
821 | isConfig = None |
|
824 | isConfig = None | |
822 | __nsubplots = None |
|
825 | __nsubplots = None | |
823 |
|
826 | |||
824 | WIDTHPROF = None |
|
827 | WIDTHPROF = None | |
825 | HEIGHTPROF = None |
|
828 | HEIGHTPROF = None | |
826 | PREFIX = 'spcprofile' |
|
829 | PREFIX = 'spcprofile' | |
827 |
|
830 | |||
828 | def __init__(self): |
|
831 | def __init__(self): | |
829 | self.isConfig = False |
|
832 | self.isConfig = False | |
830 | self.__nsubplots = 1 |
|
833 | self.__nsubplots = 1 | |
831 |
|
834 | |||
832 | self.WIDTH = 300 |
|
835 | self.WIDTH = 300 | |
833 | self.HEIGHT = 500 |
|
836 | self.HEIGHT = 500 | |
834 | self.counter_imagwr = 0 |
|
837 | self.counter_imagwr = 0 | |
835 |
|
838 | |||
836 | def getSubplots(self): |
|
839 | def getSubplots(self): | |
837 | ncol = 1 |
|
840 | ncol = 1 | |
838 | nrow = 1 |
|
841 | nrow = 1 | |
839 |
|
842 | |||
840 | return nrow, ncol |
|
843 | return nrow, ncol | |
841 |
|
844 | |||
842 | def setup(self, id, nplots, wintitle, show): |
|
845 | def setup(self, id, nplots, wintitle, show): | |
843 |
|
846 | |||
844 | self.nplots = nplots |
|
847 | self.nplots = nplots | |
845 |
|
848 | |||
846 | ncolspan = 1 |
|
849 | ncolspan = 1 | |
847 | colspan = 1 |
|
850 | colspan = 1 | |
848 |
|
851 | |||
849 | self.createFigure(id = id, |
|
852 | self.createFigure(id = id, | |
850 | wintitle = wintitle, |
|
853 | wintitle = wintitle, | |
851 | widthplot = self.WIDTH, |
|
854 | widthplot = self.WIDTH, | |
852 | heightplot = self.HEIGHT, |
|
855 | heightplot = self.HEIGHT, | |
853 | show=show) |
|
856 | show=show) | |
854 |
|
857 | |||
855 | nrow, ncol = self.getSubplots() |
|
858 | nrow, ncol = self.getSubplots() | |
856 |
|
859 | |||
857 | counter = 0 |
|
860 | counter = 0 | |
858 | for y in range(nrow): |
|
861 | for y in range(nrow): | |
859 | for x in range(ncol): |
|
862 | for x in range(ncol): | |
860 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
863 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
861 |
|
864 | |||
862 | def run(self, dataOut, id, wintitle="", channelList=None, |
|
865 | def run(self, dataOut, id, wintitle="", channelList=None, | |
863 | xmin=None, xmax=None, ymin=None, ymax=None, |
|
866 | xmin=None, xmax=None, ymin=None, ymax=None, | |
864 | save=False, figpath='./', figfile=None, show=True, wr_period=1, |
|
867 | save=False, figpath='./', figfile=None, show=True, wr_period=1, | |
865 | server=None, folder=None, username=None, password=None,): |
|
868 | server=None, folder=None, username=None, password=None,): | |
866 |
|
869 | |||
867 | if dataOut.flagNoData: |
|
870 | if dataOut.flagNoData: | |
868 | return None |
|
871 | return None | |
869 |
|
872 | |||
870 | if channelList == None: |
|
873 | if channelList == None: | |
871 | channelIndexList = dataOut.channelIndexList |
|
874 | channelIndexList = dataOut.channelIndexList | |
872 | channelList = dataOut.channelList |
|
875 | channelList = dataOut.channelList | |
873 | else: |
|
876 | else: | |
874 | channelIndexList = [] |
|
877 | channelIndexList = [] | |
875 | for channel in channelList: |
|
878 | for channel in channelList: | |
876 | if channel not in dataOut.channelList: |
|
879 | if channel not in dataOut.channelList: | |
877 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
880 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
878 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
881 | channelIndexList.append(dataOut.channelList.index(channel)) | |
879 |
|
882 | |||
880 | try: |
|
883 | try: | |
881 | factor = dataOut.normFactor |
|
884 | factor = dataOut.normFactor | |
882 | except: |
|
885 | except: | |
883 | factor = 1 |
|
886 | factor = 1 | |
884 |
|
887 | |||
885 | y = dataOut.getHeiRange() |
|
888 | y = dataOut.getHeiRange() | |
886 |
|
889 | |||
887 | #for voltage |
|
890 | #for voltage | |
888 | if dataOut.type == 'Voltage': |
|
891 | if dataOut.type == 'Voltage': | |
889 | x = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:]) |
|
892 | x = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:]) | |
890 | x = x.real |
|
893 | x = x.real | |
891 | x = numpy.where(numpy.isfinite(x), x, numpy.NAN) |
|
894 | x = numpy.where(numpy.isfinite(x), x, numpy.NAN) | |
892 |
|
895 | |||
893 | #for spectra |
|
896 | #for spectra | |
894 | if dataOut.type == 'Spectra': |
|
897 | if dataOut.type == 'Spectra': | |
895 | x = dataOut.data_spc[channelIndexList,:,:]/factor |
|
898 | x = dataOut.data_spc[channelIndexList,:,:]/factor | |
896 | x = numpy.where(numpy.isfinite(x), x, numpy.NAN) |
|
899 | x = numpy.where(numpy.isfinite(x), x, numpy.NAN) | |
897 | x = numpy.average(x, axis=1) |
|
900 | x = numpy.average(x, axis=1) | |
898 |
|
901 | |||
899 |
|
902 | |||
900 | xdB = 10*numpy.log10(x) |
|
903 | xdB = 10*numpy.log10(x) | |
901 |
|
904 | |||
902 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) |
|
905 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) | |
903 | title = wintitle + " Power Profile %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
906 | title = wintitle + " Power Profile %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
904 | xlabel = "dB" |
|
907 | xlabel = "dB" | |
905 | ylabel = "Range (Km)" |
|
908 | ylabel = "Range (Km)" | |
906 |
|
909 | |||
907 | if not self.isConfig: |
|
910 | if not self.isConfig: | |
908 |
|
911 | |||
909 | nplots = 1 |
|
912 | nplots = 1 | |
910 |
|
913 | |||
911 | self.setup(id=id, |
|
914 | self.setup(id=id, | |
912 | nplots=nplots, |
|
915 | nplots=nplots, | |
913 | wintitle=wintitle, |
|
916 | wintitle=wintitle, | |
914 | show=show) |
|
917 | show=show) | |
915 |
|
918 | |||
916 | if ymin == None: ymin = numpy.nanmin(y) |
|
919 | if ymin == None: ymin = numpy.nanmin(y) | |
917 | if ymax == None: ymax = numpy.nanmax(y) |
|
920 | if ymax == None: ymax = numpy.nanmax(y) | |
918 | if xmin == None: xmin = numpy.nanmin(xdB)*0.9 |
|
921 | if xmin == None: xmin = numpy.nanmin(xdB)*0.9 | |
919 | if xmax == None: xmax = numpy.nanmax(xdB)*0.9 |
|
922 | if xmax == None: xmax = numpy.nanmax(xdB)*0.9 | |
920 |
|
923 | |||
921 | self.__isConfig = True |
|
924 | self.__isConfig = True | |
922 |
|
925 | |||
923 | self.setWinTitle(title) |
|
926 | self.setWinTitle(title) | |
924 |
|
927 | |||
925 | title = "Power Profile: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
928 | title = "Power Profile: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
926 | axes = self.axesList[0] |
|
929 | axes = self.axesList[0] | |
927 |
|
930 | |||
928 | legendlabels = ["channel %d"%x for x in channelList] |
|
931 | legendlabels = ["channel %d"%x for x in channelList] | |
929 | axes.pmultiline(xdB, y, |
|
932 | axes.pmultiline(xdB, y, | |
930 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, |
|
933 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, | |
931 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, |
|
934 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, | |
932 | ytick_visible=True, nxticks=5, |
|
935 | ytick_visible=True, nxticks=5, | |
933 | grid='x') |
|
936 | grid='x') | |
934 |
|
937 | |||
935 | self.draw() |
|
938 | self.draw() | |
936 |
|
939 | |||
937 | if save: |
|
940 | if save: | |
938 | date = thisDatetime.strftime("%Y%m%d") |
|
941 | date = thisDatetime.strftime("%Y%m%d") | |
939 | if figfile == None: |
|
942 | if figfile == None: | |
940 | figfile = self.getFilename(name = date) |
|
943 | figfile = self.getFilename(name = date) | |
941 |
|
944 | |||
942 | self.saveFigure(figpath, figfile) |
|
945 | self.saveFigure(figpath, figfile) | |
943 |
|
946 | |||
944 | self.counter_imagwr += 1 |
|
947 | self.counter_imagwr += 1 | |
945 | if (ftp and (self.counter_imagwr==wr_period)): |
|
948 | if (ftp and (self.counter_imagwr==wr_period)): | |
946 | ftp_filename = os.path.join(figpath,figfile) |
|
949 | ftp_filename = os.path.join(figpath,figfile) | |
947 | self.sendByFTP_Thread(ftp_filename, server, folder, username, password) |
|
950 | self.sendByFTP_Thread(ftp_filename, server, folder, username, password) | |
948 | self.counter_imagwr = 0 |
|
951 | self.counter_imagwr = 0 | |
949 |
|
952 | |||
950 | class Noise(Figure): |
|
953 | class Noise(Figure): | |
951 |
|
954 | |||
952 | isConfig = None |
|
955 | isConfig = None | |
953 | __nsubplots = None |
|
956 | __nsubplots = None | |
954 |
|
957 | |||
955 | PREFIX = 'noise' |
|
958 | PREFIX = 'noise' | |
956 |
|
959 | |||
957 | def __init__(self): |
|
960 | def __init__(self): | |
958 |
|
961 | |||
959 | self.timerange = 24*60*60 |
|
962 | self.timerange = 24*60*60 | |
960 | self.isConfig = False |
|
963 | self.isConfig = False | |
961 | self.__nsubplots = 1 |
|
964 | self.__nsubplots = 1 | |
962 | self.counter_imagwr = 0 |
|
965 | self.counter_imagwr = 0 | |
963 | self.WIDTH = 600 |
|
966 | self.WIDTH = 600 | |
964 | self.HEIGHT = 300 |
|
967 | self.HEIGHT = 300 | |
965 | self.WIDTHPROF = 120 |
|
968 | self.WIDTHPROF = 120 | |
966 | self.HEIGHTPROF = 0 |
|
969 | self.HEIGHTPROF = 0 | |
967 | self.xdata = None |
|
970 | self.xdata = None | |
968 | self.ydata = None |
|
971 | self.ydata = None | |
969 |
|
972 | |||
970 | self.PLOT_CODE = 77 |
|
973 | self.PLOT_CODE = 77 | |
971 | self.FTP_WEI = None |
|
974 | self.FTP_WEI = None | |
972 | self.EXP_CODE = None |
|
975 | self.EXP_CODE = None | |
973 | self.SUB_EXP_CODE = None |
|
976 | self.SUB_EXP_CODE = None | |
974 | self.PLOT_POS = None |
|
977 | self.PLOT_POS = None | |
975 |
|
978 | |||
976 | def getSubplots(self): |
|
979 | def getSubplots(self): | |
977 |
|
980 | |||
978 | ncol = 1 |
|
981 | ncol = 1 | |
979 | nrow = 1 |
|
982 | nrow = 1 | |
980 |
|
983 | |||
981 | return nrow, ncol |
|
984 | return nrow, ncol | |
982 |
|
985 | |||
983 | def openfile(self, filename): |
|
986 | def openfile(self, filename): | |
984 | f = open(filename,'w+') |
|
987 | f = open(filename,'w+') | |
985 | f.write('\n\n') |
|
988 | f.write('\n\n') | |
986 | f.write('JICAMARCA RADIO OBSERVATORY - Noise \n') |
|
989 | f.write('JICAMARCA RADIO OBSERVATORY - Noise \n') | |
987 | f.write('DD MM YYYY HH MM SS Channel0 Channel1 Channel2 Channel3\n\n' ) |
|
990 | f.write('DD MM YYYY HH MM SS Channel0 Channel1 Channel2 Channel3\n\n' ) | |
988 | f.close() |
|
991 | f.close() | |
989 |
|
992 | |||
990 | def save_data(self, filename_phase, data, data_datetime): |
|
993 | def save_data(self, filename_phase, data, data_datetime): | |
991 | f=open(filename_phase,'a') |
|
994 | f=open(filename_phase,'a') | |
992 | timetuple_data = data_datetime.timetuple() |
|
995 | timetuple_data = data_datetime.timetuple() | |
993 | day = str(timetuple_data.tm_mday) |
|
996 | day = str(timetuple_data.tm_mday) | |
994 | month = str(timetuple_data.tm_mon) |
|
997 | month = str(timetuple_data.tm_mon) | |
995 | year = str(timetuple_data.tm_year) |
|
998 | year = str(timetuple_data.tm_year) | |
996 | hour = str(timetuple_data.tm_hour) |
|
999 | hour = str(timetuple_data.tm_hour) | |
997 | minute = str(timetuple_data.tm_min) |
|
1000 | minute = str(timetuple_data.tm_min) | |
998 | second = str(timetuple_data.tm_sec) |
|
1001 | second = str(timetuple_data.tm_sec) | |
999 | f.write(day+' '+month+' '+year+' '+hour+' '+minute+' '+second+' '+str(data[0])+' '+str(data[1])+' '+str(data[2])+' '+str(data[3])+'\n') |
|
1002 | f.write(day+' '+month+' '+year+' '+hour+' '+minute+' '+second+' '+str(data[0])+' '+str(data[1])+' '+str(data[2])+' '+str(data[3])+'\n') | |
1000 | f.close() |
|
1003 | f.close() | |
1001 |
|
1004 | |||
1002 |
|
1005 | |||
1003 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
1006 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
1004 |
|
1007 | |||
1005 | self.__showprofile = showprofile |
|
1008 | self.__showprofile = showprofile | |
1006 | self.nplots = nplots |
|
1009 | self.nplots = nplots | |
1007 |
|
1010 | |||
1008 | ncolspan = 7 |
|
1011 | ncolspan = 7 | |
1009 | colspan = 6 |
|
1012 | colspan = 6 | |
1010 | self.__nsubplots = 2 |
|
1013 | self.__nsubplots = 2 | |
1011 |
|
1014 | |||
1012 | self.createFigure(id = id, |
|
1015 | self.createFigure(id = id, | |
1013 | wintitle = wintitle, |
|
1016 | wintitle = wintitle, | |
1014 | widthplot = self.WIDTH+self.WIDTHPROF, |
|
1017 | widthplot = self.WIDTH+self.WIDTHPROF, | |
1015 | heightplot = self.HEIGHT+self.HEIGHTPROF, |
|
1018 | heightplot = self.HEIGHT+self.HEIGHTPROF, | |
1016 | show=show) |
|
1019 | show=show) | |
1017 |
|
1020 | |||
1018 | nrow, ncol = self.getSubplots() |
|
1021 | nrow, ncol = self.getSubplots() | |
1019 |
|
1022 | |||
1020 | self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1) |
|
1023 | self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1) | |
1021 |
|
1024 | |||
1022 |
|
1025 | |||
1023 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True', |
|
1026 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True', | |
1024 | xmin=None, xmax=None, ymin=None, ymax=None, |
|
1027 | xmin=None, xmax=None, ymin=None, ymax=None, | |
1025 | timerange=None, |
|
1028 | timerange=None, | |
1026 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, |
|
1029 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, | |
1027 | server=None, folder=None, username=None, password=None, |
|
1030 | server=None, folder=None, username=None, password=None, | |
1028 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): |
|
1031 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): | |
1029 |
|
1032 | |||
1030 | if channelList == None: |
|
1033 | if channelList == None: | |
1031 | channelIndexList = dataOut.channelIndexList |
|
1034 | channelIndexList = dataOut.channelIndexList | |
1032 | channelList = dataOut.channelList |
|
1035 | channelList = dataOut.channelList | |
1033 | else: |
|
1036 | else: | |
1034 | channelIndexList = [] |
|
1037 | channelIndexList = [] | |
1035 | for channel in channelList: |
|
1038 | for channel in channelList: | |
1036 | if channel not in dataOut.channelList: |
|
1039 | if channel not in dataOut.channelList: | |
1037 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
1040 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
1038 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
1041 | channelIndexList.append(dataOut.channelList.index(channel)) | |
1039 |
|
1042 | |||
1040 | if timerange != None: |
|
1043 | if timerange != None: | |
1041 | self.timerange = timerange |
|
1044 | self.timerange = timerange | |
1042 |
|
1045 | |||
1043 | tmin = None |
|
1046 | tmin = None | |
1044 | tmax = None |
|
1047 | tmax = None | |
1045 | x = dataOut.getTimeRange() |
|
1048 | x = dataOut.getTimeRange() | |
1046 | y = dataOut.getHeiRange() |
|
1049 | y = dataOut.getHeiRange() | |
1047 | factor = dataOut.normFactor |
|
1050 | factor = dataOut.normFactor | |
1048 | noise = dataOut.noise()/factor |
|
1051 | noise = dataOut.noise()/factor | |
1049 | noisedB = 10*numpy.log10(noise) |
|
1052 | noisedB = 10*numpy.log10(noise) | |
1050 |
|
1053 | |||
1051 | #thisDatetime = dataOut.datatime |
|
1054 | #thisDatetime = dataOut.datatime | |
1052 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) |
|
1055 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) | |
1053 | title = wintitle + " Noise" # : %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
1056 | title = wintitle + " Noise" # : %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
1054 | xlabel = "" |
|
1057 | xlabel = "" | |
1055 | ylabel = "Intensity (dB)" |
|
1058 | ylabel = "Intensity (dB)" | |
1056 |
|
1059 | |||
1057 | if not self.isConfig: |
|
1060 | if not self.isConfig: | |
1058 |
|
1061 | |||
1059 | nplots = 1 |
|
1062 | nplots = 1 | |
1060 |
|
1063 | |||
1061 | self.setup(id=id, |
|
1064 | self.setup(id=id, | |
1062 | nplots=nplots, |
|
1065 | nplots=nplots, | |
1063 | wintitle=wintitle, |
|
1066 | wintitle=wintitle, | |
1064 | showprofile=showprofile, |
|
1067 | showprofile=showprofile, | |
1065 | show=show) |
|
1068 | show=show) | |
1066 |
|
1069 | |||
1067 | tmin, tmax = self.getTimeLim(x, xmin, xmax) |
|
1070 | tmin, tmax = self.getTimeLim(x, xmin, xmax) | |
1068 | if ymin == None: ymin = numpy.nanmin(noisedB) - 10.0 |
|
1071 | if ymin == None: ymin = numpy.nanmin(noisedB) - 10.0 | |
1069 | if ymax == None: ymax = numpy.nanmax(noisedB) + 10.0 |
|
1072 | if ymax == None: ymax = numpy.nanmax(noisedB) + 10.0 | |
1070 |
|
1073 | |||
1071 | self.FTP_WEI = ftp_wei |
|
1074 | self.FTP_WEI = ftp_wei | |
1072 | self.EXP_CODE = exp_code |
|
1075 | self.EXP_CODE = exp_code | |
1073 | self.SUB_EXP_CODE = sub_exp_code |
|
1076 | self.SUB_EXP_CODE = sub_exp_code | |
1074 | self.PLOT_POS = plot_pos |
|
1077 | self.PLOT_POS = plot_pos | |
1075 |
|
1078 | |||
1076 |
|
1079 | |||
1077 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
1080 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
1078 | self.isConfig = True |
|
1081 | self.isConfig = True | |
1079 |
|
1082 | |||
1080 | self.xdata = numpy.array([]) |
|
1083 | self.xdata = numpy.array([]) | |
1081 | self.ydata = numpy.array([]) |
|
1084 | self.ydata = numpy.array([]) | |
1082 |
|
1085 | |||
1083 | #open file beacon phase |
|
1086 | #open file beacon phase | |
1084 | path = '%s%03d' %(self.PREFIX, self.id) |
|
1087 | path = '%s%03d' %(self.PREFIX, self.id) | |
1085 | noise_file = os.path.join(path,'%s.txt'%self.name) |
|
1088 | noise_file = os.path.join(path,'%s.txt'%self.name) | |
1086 | self.filename_noise = os.path.join(figpath,noise_file) |
|
1089 | self.filename_noise = os.path.join(figpath,noise_file) | |
1087 | self.openfile(self.filename_noise) |
|
1090 | self.openfile(self.filename_noise) | |
1088 |
|
1091 | |||
1089 |
|
1092 | |||
1090 | #store data beacon phase |
|
1093 | #store data beacon phase | |
1091 | self.save_data(self.filename_noise, noisedB, thisDatetime) |
|
1094 | self.save_data(self.filename_noise, noisedB, thisDatetime) | |
1092 |
|
1095 | |||
1093 |
|
1096 | |||
1094 | self.setWinTitle(title) |
|
1097 | self.setWinTitle(title) | |
1095 |
|
1098 | |||
1096 |
|
1099 | |||
1097 | title = "Noise %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
1100 | title = "Noise %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
1098 |
|
1101 | |||
1099 | legendlabels = ["channel %d"%(idchannel+1) for idchannel in channelList] |
|
1102 | legendlabels = ["channel %d"%(idchannel+1) for idchannel in channelList] | |
1100 | axes = self.axesList[0] |
|
1103 | axes = self.axesList[0] | |
1101 |
|
1104 | |||
1102 | self.xdata = numpy.hstack((self.xdata, x[0:1])) |
|
1105 | self.xdata = numpy.hstack((self.xdata, x[0:1])) | |
1103 |
|
1106 | |||
1104 | if len(self.ydata)==0: |
|
1107 | if len(self.ydata)==0: | |
1105 | self.ydata = noisedB[channelIndexList].reshape(-1,1) |
|
1108 | self.ydata = noisedB[channelIndexList].reshape(-1,1) | |
1106 | else: |
|
1109 | else: | |
1107 | self.ydata = numpy.hstack((self.ydata, noisedB[channelIndexList].reshape(-1,1))) |
|
1110 | self.ydata = numpy.hstack((self.ydata, noisedB[channelIndexList].reshape(-1,1))) | |
1108 |
|
1111 | |||
1109 |
|
1112 | |||
1110 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, |
|
1113 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, | |
1111 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, |
|
1114 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, | |
1112 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid", |
|
1115 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid", | |
1113 | XAxisAsTime=True, grid='both' |
|
1116 | XAxisAsTime=True, grid='both' | |
1114 | ) |
|
1117 | ) | |
1115 |
|
1118 | |||
1116 | self.draw() |
|
1119 | self.draw() | |
1117 |
|
1120 | |||
1118 | # if save: |
|
1121 | # if save: | |
1119 | # |
|
1122 | # | |
1120 | # if figfile == None: |
|
1123 | # if figfile == None: | |
1121 | # figfile = self.getFilename(name = self.name) |
|
1124 | # figfile = self.getFilename(name = self.name) | |
1122 | # |
|
1125 | # | |
1123 | # self.saveFigure(figpath, figfile) |
|
1126 | # self.saveFigure(figpath, figfile) | |
1124 |
|
1127 | |||
1125 | if save: |
|
1128 | if save: | |
1126 |
|
1129 | |||
1127 | self.counter_imagwr += 1 |
|
1130 | self.counter_imagwr += 1 | |
1128 | if (self.counter_imagwr==wr_period): |
|
1131 | if (self.counter_imagwr==wr_period): | |
1129 | if figfile == None: |
|
1132 | if figfile == None: | |
1130 | figfile = self.getFilename(name = self.name) |
|
1133 | figfile = self.getFilename(name = self.name) | |
1131 | self.saveFigure(figpath, figfile) |
|
1134 | self.saveFigure(figpath, figfile) | |
1132 |
|
1135 | |||
1133 | if ftp: |
|
1136 | if ftp: | |
1134 | #provisionalmente envia archivos en el formato de la web en tiempo real |
|
1137 | #provisionalmente envia archivos en el formato de la web en tiempo real | |
1135 | name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) |
|
1138 | name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) | |
1136 | path = '%s%03d' %(self.PREFIX, self.id) |
|
1139 | path = '%s%03d' %(self.PREFIX, self.id) | |
1137 | ftp_file = os.path.join(path,'ftp','%s.png'%name) |
|
1140 | ftp_file = os.path.join(path,'ftp','%s.png'%name) | |
1138 | self.saveFigure(figpath, ftp_file) |
|
1141 | self.saveFigure(figpath, ftp_file) | |
1139 | ftp_filename = os.path.join(figpath,ftp_file) |
|
1142 | ftp_filename = os.path.join(figpath,ftp_file) | |
1140 | self.sendByFTP_Thread(ftp_filename, server, folder, username, password) |
|
1143 | self.sendByFTP_Thread(ftp_filename, server, folder, username, password) | |
1141 | self.counter_imagwr = 0 |
|
1144 | self.counter_imagwr = 0 | |
1142 |
|
1145 | |||
1143 | self.counter_imagwr = 0 |
|
1146 | self.counter_imagwr = 0 | |
1144 |
|
1147 | |||
1145 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: |
|
1148 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: | |
1146 | self.isConfig = False |
|
1149 | self.isConfig = False | |
1147 | del self.xdata |
|
1150 | del self.xdata | |
1148 | del self.ydata |
|
1151 | del self.ydata |
General Comments 0
You need to be logged in to leave comments.
Login now