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