##// END OF EJS Templates
se agregan variables para salvar graficos en disco para el ultimo bloque de datos o cuando se actualiza el eje x
Daniel Valdez -
r458:f4edc9ada2c8
parent child
Show More
@@ -1,1698 +1,1720
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
215
216 class RTIPlot(Figure):
216 class RTIPlot(Figure):
217
217
218 __isConfig = None
218 __isConfig = None
219 __nsubplots = None
219 __nsubplots = None
220
220
221 WIDTHPROF = None
221 WIDTHPROF = None
222 HEIGHTPROF = None
222 HEIGHTPROF = None
223 PREFIX = 'rti'
223 PREFIX = 'rti'
224
224
225 def __init__(self):
225 def __init__(self):
226
226
227 self.timerange = 2*60*60
227 self.timerange = 2*60*60
228 self.__isConfig = False
228 self.__isConfig = False
229 self.__nsubplots = 1
229 self.__nsubplots = 1
230
230
231 self.WIDTH = 800
231 self.WIDTH = 800
232 self.HEIGHT = 150
232 self.HEIGHT = 150
233 self.WIDTHPROF = 120
233 self.WIDTHPROF = 120
234 self.HEIGHTPROF = 0
234 self.HEIGHTPROF = 0
235 self.counter_imagwr = 0
235 self.counter_imagwr = 0
236
236
237 self.PLOT_CODE = 0
237 self.PLOT_CODE = 0
238 self.FTP_WEI = None
238 self.FTP_WEI = None
239 self.EXP_CODE = None
239 self.EXP_CODE = None
240 self.SUB_EXP_CODE = None
240 self.SUB_EXP_CODE = None
241 self.PLOT_POS = None
241 self.PLOT_POS = None
242
242
243 def getSubplots(self):
243 def getSubplots(self):
244
244
245 ncol = 1
245 ncol = 1
246 nrow = self.nplots
246 nrow = self.nplots
247
247
248 return nrow, ncol
248 return nrow, ncol
249
249
250 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
250 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
251
251
252 self.__showprofile = showprofile
252 self.__showprofile = showprofile
253 self.nplots = nplots
253 self.nplots = nplots
254
254
255 ncolspan = 1
255 ncolspan = 1
256 colspan = 1
256 colspan = 1
257 if showprofile:
257 if showprofile:
258 ncolspan = 7
258 ncolspan = 7
259 colspan = 6
259 colspan = 6
260 self.__nsubplots = 2
260 self.__nsubplots = 2
261
261
262 self.createFigure(id = id,
262 self.createFigure(id = id,
263 wintitle = wintitle,
263 wintitle = wintitle,
264 widthplot = self.WIDTH + self.WIDTHPROF,
264 widthplot = self.WIDTH + self.WIDTHPROF,
265 heightplot = self.HEIGHT + self.HEIGHTPROF,
265 heightplot = self.HEIGHT + self.HEIGHTPROF,
266 show=show)
266 show=show)
267
267
268 nrow, ncol = self.getSubplots()
268 nrow, ncol = self.getSubplots()
269
269
270 counter = 0
270 counter = 0
271 for y in range(nrow):
271 for y in range(nrow):
272 for x in range(ncol):
272 for x in range(ncol):
273
273
274 if counter >= self.nplots:
274 if counter >= self.nplots:
275 break
275 break
276
276
277 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
277 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
278
278
279 if showprofile:
279 if showprofile:
280 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
280 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
281
281
282 counter += 1
282 counter += 1
283
283
284 def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True',
284 def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True',
285 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
285 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
286 timerange=None,
286 timerange=None,
287 save=False, figpath='./', figfile=None, ftp=False, wr_period=1, show=True,
287 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
288 server=None, folder=None, username=None, password=None,
288 server=None, folder=None, username=None, password=None,
289 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
289 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
290
290
291 """
291 """
292
292
293 Input:
293 Input:
294 dataOut :
294 dataOut :
295 id :
295 id :
296 wintitle :
296 wintitle :
297 channelList :
297 channelList :
298 showProfile :
298 showProfile :
299 xmin : None,
299 xmin : None,
300 xmax : None,
300 xmax : None,
301 ymin : None,
301 ymin : None,
302 ymax : None,
302 ymax : None,
303 zmin : None,
303 zmin : None,
304 zmax : None
304 zmax : None
305 """
305 """
306
306
307 if channelList == None:
307 if channelList == None:
308 channelIndexList = dataOut.channelIndexList
308 channelIndexList = dataOut.channelIndexList
309 else:
309 else:
310 channelIndexList = []
310 channelIndexList = []
311 for channel in channelList:
311 for channel in channelList:
312 if channel not in dataOut.channelList:
312 if channel not in dataOut.channelList:
313 raise ValueError, "Channel %d is not in dataOut.channelList"
313 raise ValueError, "Channel %d is not in dataOut.channelList"
314 channelIndexList.append(dataOut.channelList.index(channel))
314 channelIndexList.append(dataOut.channelList.index(channel))
315
315
316 if timerange != None:
316 if timerange != None:
317 self.timerange = timerange
317 self.timerange = timerange
318
318
319 tmin = None
319 tmin = None
320 tmax = None
320 tmax = None
321 #factor = dataOut.normFactor
321 #factor = dataOut.normFactor
322 x = dataOut.getTimeRange()
322 x = dataOut.getTimeRange()
323 y = dataOut.getHeiRange()
323 y = dataOut.getHeiRange()
324
324
325 z = dataOut.data_spc[channelIndexList,:,:]#/factor
325 z = dataOut.data_spc[channelIndexList,:,:]#/factor
326 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
326 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
327 avg = numpy.average(z, axis=1)
327 avg = numpy.average(z, axis=1)
328
328
329 avgdB = 10.*numpy.log10(avg)
329 avgdB = 10.*numpy.log10(avg)
330
330
331
331
332 # thisDatetime = dataOut.datatime
332 # thisDatetime = dataOut.datatime
333 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1])
333 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1])
334 title = wintitle + " RTI" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
334 title = wintitle + " RTI" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
335 xlabel = ""
335 xlabel = ""
336 ylabel = "Range (Km)"
336 ylabel = "Range (Km)"
337
337
338 if not self.__isConfig:
338 if not self.__isConfig:
339
339
340 nplots = len(channelIndexList)
340 nplots = len(channelIndexList)
341
341
342 self.setup(id=id,
342 self.setup(id=id,
343 nplots=nplots,
343 nplots=nplots,
344 wintitle=wintitle,
344 wintitle=wintitle,
345 showprofile=showprofile,
345 showprofile=showprofile,
346 show=show)
346 show=show)
347
347
348 tmin, tmax = self.getTimeLim(x, xmin, xmax)
348 tmin, tmax = self.getTimeLim(x, xmin, xmax)
349 if ymin == None: ymin = numpy.nanmin(y)
349 if ymin == None: ymin = numpy.nanmin(y)
350 if ymax == None: ymax = numpy.nanmax(y)
350 if ymax == None: ymax = numpy.nanmax(y)
351 if zmin == None: zmin = numpy.nanmin(avgdB)*0.9
351 if zmin == None: zmin = numpy.nanmin(avgdB)*0.9
352 if zmax == None: zmax = numpy.nanmax(avgdB)*0.9
352 if zmax == None: zmax = numpy.nanmax(avgdB)*0.9
353
353
354 self.FTP_WEI = ftp_wei
354 self.FTP_WEI = ftp_wei
355 self.EXP_CODE = exp_code
355 self.EXP_CODE = exp_code
356 self.SUB_EXP_CODE = sub_exp_code
356 self.SUB_EXP_CODE = sub_exp_code
357 self.PLOT_POS = plot_pos
357 self.PLOT_POS = plot_pos
358
358
359 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
359 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
360 self.__isConfig = True
360 self.__isConfig = True
361
361
362
362
363 self.setWinTitle(title)
363 self.setWinTitle(title)
364
364
365 for i in range(self.nplots):
365 for i in range(self.nplots):
366 title = "Channel %d: %s" %(dataOut.channelList[i]+1, thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
366 title = "Channel %d: %s" %(dataOut.channelList[i]+1, thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
367 axes = self.axesList[i*self.__nsubplots]
367 axes = self.axesList[i*self.__nsubplots]
368 zdB = avgdB[i].reshape((1,-1))
368 zdB = avgdB[i].reshape((1,-1))
369 axes.pcolorbuffer(x, y, zdB,
369 axes.pcolorbuffer(x, y, zdB,
370 xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
370 xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
371 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
371 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
372 ticksize=9, cblabel='', cbsize="1%")
372 ticksize=9, cblabel='', cbsize="1%")
373
373
374 if self.__showprofile:
374 if self.__showprofile:
375 axes = self.axesList[i*self.__nsubplots +1]
375 axes = self.axesList[i*self.__nsubplots +1]
376 axes.pline(avgdB[i], y,
376 axes.pline(avgdB[i], y,
377 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
377 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
378 xlabel='dB', ylabel='', title='',
378 xlabel='dB', ylabel='', title='',
379 ytick_visible=False,
379 ytick_visible=False,
380 grid='x')
380 grid='x')
381
381
382 self.draw()
382 self.draw()
383
383
384 if save:
384 if lastone:
385 if dataOut.blocknow >= dataOut.last_block:
386 if figfile == None:
387 figfile = self.getFilename(name = self.name)
388 self.saveFigure(figpath, figfile)
389
390 if (save and not(lastone)):
385
391
386 self.counter_imagwr += 1
392 self.counter_imagwr += 1
387 if (self.counter_imagwr==wr_period):
393 if (self.counter_imagwr==wr_period):
388 if figfile == None:
394 if figfile == None:
389 figfile = self.getFilename(name = self.name)
395 figfile = self.getFilename(name = self.name)
390 self.saveFigure(figpath, figfile)
396 self.saveFigure(figpath, figfile)
391
397
392 if ftp:
398 if ftp:
393 #provisionalmente envia archivos en el formato de la web en tiempo real
399 #provisionalmente envia archivos en el formato de la web en tiempo real
394 name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS)
400 name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS)
395 path = '%s%03d' %(self.PREFIX, self.id)
401 path = '%s%03d' %(self.PREFIX, self.id)
396 ftp_file = os.path.join(path,'ftp','%s.png'%name)
402 ftp_file = os.path.join(path,'ftp','%s.png'%name)
397 self.saveFigure(figpath, ftp_file)
403 self.saveFigure(figpath, ftp_file)
398 ftp_filename = os.path.join(figpath,ftp_file)
404 ftp_filename = os.path.join(figpath,ftp_file)
399 self.sendByFTP_Thread(ftp_filename, server, folder, username, password)
405 self.sendByFTP_Thread(ftp_filename, server, folder, username, password)
400 self.counter_imagwr = 0
406 self.counter_imagwr = 0
401
407
402 self.counter_imagwr = 0
408 self.counter_imagwr = 0
403
409
404 if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax:
410 if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax:
411
405 self.__isConfig = False
412 self.__isConfig = False
413
414 if lastone:
415 if figfile == None:
416 figfile = self.getFilename(name = self.name)
417 self.saveFigure(figpath, figfile)
418
419 if ftp:
420 #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)
422 path = '%s%03d' %(self.PREFIX, self.id)
423 ftp_file = os.path.join(path,'ftp','%s.png'%name)
424 self.saveFigure(figpath, ftp_file)
425 ftp_filename = os.path.join(figpath,ftp_file)
426 self.sendByFTP_Thread(ftp_filename, server, folder, username, password)
427
406
428
407 class SpectraPlot(Figure):
429 class SpectraPlot(Figure):
408
430
409 __isConfig = None
431 __isConfig = None
410 __nsubplots = None
432 __nsubplots = None
411
433
412 WIDTHPROF = None
434 WIDTHPROF = None
413 HEIGHTPROF = None
435 HEIGHTPROF = None
414 PREFIX = 'spc'
436 PREFIX = 'spc'
415
437
416 def __init__(self):
438 def __init__(self):
417
439
418 self.__isConfig = False
440 self.__isConfig = False
419 self.__nsubplots = 1
441 self.__nsubplots = 1
420
442
421 self.WIDTH = 280
443 self.WIDTH = 280
422 self.HEIGHT = 250
444 self.HEIGHT = 250
423 self.WIDTHPROF = 120
445 self.WIDTHPROF = 120
424 self.HEIGHTPROF = 0
446 self.HEIGHTPROF = 0
425 self.counter_imagwr = 0
447 self.counter_imagwr = 0
426
448
427 self.PLOT_CODE = 1
449 self.PLOT_CODE = 1
428 self.FTP_WEI = None
450 self.FTP_WEI = None
429 self.EXP_CODE = None
451 self.EXP_CODE = None
430 self.SUB_EXP_CODE = None
452 self.SUB_EXP_CODE = None
431 self.PLOT_POS = None
453 self.PLOT_POS = None
432
454
433 def getSubplots(self):
455 def getSubplots(self):
434
456
435 ncol = int(numpy.sqrt(self.nplots)+0.9)
457 ncol = int(numpy.sqrt(self.nplots)+0.9)
436 nrow = int(self.nplots*1./ncol + 0.9)
458 nrow = int(self.nplots*1./ncol + 0.9)
437
459
438 return nrow, ncol
460 return nrow, ncol
439
461
440 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
462 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
441
463
442 self.__showprofile = showprofile
464 self.__showprofile = showprofile
443 self.nplots = nplots
465 self.nplots = nplots
444
466
445 ncolspan = 1
467 ncolspan = 1
446 colspan = 1
468 colspan = 1
447 if showprofile:
469 if showprofile:
448 ncolspan = 3
470 ncolspan = 3
449 colspan = 2
471 colspan = 2
450 self.__nsubplots = 2
472 self.__nsubplots = 2
451
473
452 self.createFigure(id = id,
474 self.createFigure(id = id,
453 wintitle = wintitle,
475 wintitle = wintitle,
454 widthplot = self.WIDTH + self.WIDTHPROF,
476 widthplot = self.WIDTH + self.WIDTHPROF,
455 heightplot = self.HEIGHT + self.HEIGHTPROF,
477 heightplot = self.HEIGHT + self.HEIGHTPROF,
456 show=show)
478 show=show)
457
479
458 nrow, ncol = self.getSubplots()
480 nrow, ncol = self.getSubplots()
459
481
460 counter = 0
482 counter = 0
461 for y in range(nrow):
483 for y in range(nrow):
462 for x in range(ncol):
484 for x in range(ncol):
463
485
464 if counter >= self.nplots:
486 if counter >= self.nplots:
465 break
487 break
466
488
467 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
489 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
468
490
469 if showprofile:
491 if showprofile:
470 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
492 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
471
493
472 counter += 1
494 counter += 1
473
495
474 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True,
496 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True,
475 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
497 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
476 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
498 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
477 server=None, folder=None, username=None, password=None,
499 server=None, folder=None, username=None, password=None,
478 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False):
500 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False):
479
501
480 """
502 """
481
503
482 Input:
504 Input:
483 dataOut :
505 dataOut :
484 id :
506 id :
485 wintitle :
507 wintitle :
486 channelList :
508 channelList :
487 showProfile :
509 showProfile :
488 xmin : None,
510 xmin : None,
489 xmax : None,
511 xmax : None,
490 ymin : None,
512 ymin : None,
491 ymax : None,
513 ymax : None,
492 zmin : None,
514 zmin : None,
493 zmax : None
515 zmax : None
494 """
516 """
495
517
496 if realtime:
518 if realtime:
497 if not(isRealtime(utcdatatime = dataOut.utctime)):
519 if not(isRealtime(utcdatatime = dataOut.utctime)):
498 print 'Skipping this plot function'
520 print 'Skipping this plot function'
499 return
521 return
500
522
501 if channelList == None:
523 if channelList == None:
502 channelIndexList = dataOut.channelIndexList
524 channelIndexList = dataOut.channelIndexList
503 else:
525 else:
504 channelIndexList = []
526 channelIndexList = []
505 for channel in channelList:
527 for channel in channelList:
506 if channel not in dataOut.channelList:
528 if channel not in dataOut.channelList:
507 raise ValueError, "Channel %d is not in dataOut.channelList"
529 raise ValueError, "Channel %d is not in dataOut.channelList"
508 channelIndexList.append(dataOut.channelList.index(channel))
530 channelIndexList.append(dataOut.channelList.index(channel))
509 #factor = dataOut.normFactor
531 #factor = dataOut.normFactor
510 x = dataOut.getVelRange(1)
532 x = dataOut.getVelRange(1)
511 y = dataOut.getHeiRange()
533 y = dataOut.getHeiRange()
512
534
513 z = dataOut.data_spc[channelIndexList,:,:]#/factor
535 z = dataOut.data_spc[channelIndexList,:,:]#/factor
514 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
536 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
515 avg = numpy.average(z, axis=1)
537 avg = numpy.average(z, axis=1)
516 noise = dataOut.getNoise()#/factor
538 noise = dataOut.getNoise()#/factor
517
539
518 zdB = 10*numpy.log10(z)
540 zdB = 10*numpy.log10(z)
519 avgdB = 10*numpy.log10(avg)
541 avgdB = 10*numpy.log10(avg)
520 noisedB = 10*numpy.log10(noise)
542 noisedB = 10*numpy.log10(noise)
521
543
522 #thisDatetime = dataOut.datatime
544 #thisDatetime = dataOut.datatime
523 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1])
545 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1])
524 title = wintitle + " Spectra"
546 title = wintitle + " Spectra"
525 xlabel = "Velocity (m/s)"
547 xlabel = "Velocity (m/s)"
526 ylabel = "Range (Km)"
548 ylabel = "Range (Km)"
527
549
528 if not self.__isConfig:
550 if not self.__isConfig:
529
551
530 nplots = len(channelIndexList)
552 nplots = len(channelIndexList)
531
553
532 self.setup(id=id,
554 self.setup(id=id,
533 nplots=nplots,
555 nplots=nplots,
534 wintitle=wintitle,
556 wintitle=wintitle,
535 showprofile=showprofile,
557 showprofile=showprofile,
536 show=show)
558 show=show)
537
559
538 if xmin == None: xmin = numpy.nanmin(x)
560 if xmin == None: xmin = numpy.nanmin(x)
539 if xmax == None: xmax = numpy.nanmax(x)
561 if xmax == None: xmax = numpy.nanmax(x)
540 if ymin == None: ymin = numpy.nanmin(y)
562 if ymin == None: ymin = numpy.nanmin(y)
541 if ymax == None: ymax = numpy.nanmax(y)
563 if ymax == None: ymax = numpy.nanmax(y)
542 if zmin == None: zmin = numpy.nanmin(avgdB)*0.9
564 if zmin == None: zmin = numpy.nanmin(avgdB)*0.9
543 if zmax == None: zmax = numpy.nanmax(avgdB)*0.9
565 if zmax == None: zmax = numpy.nanmax(avgdB)*0.9
544
566
545 self.FTP_WEI = ftp_wei
567 self.FTP_WEI = ftp_wei
546 self.EXP_CODE = exp_code
568 self.EXP_CODE = exp_code
547 self.SUB_EXP_CODE = sub_exp_code
569 self.SUB_EXP_CODE = sub_exp_code
548 self.PLOT_POS = plot_pos
570 self.PLOT_POS = plot_pos
549
571
550 self.__isConfig = True
572 self.__isConfig = True
551
573
552 self.setWinTitle(title)
574 self.setWinTitle(title)
553
575
554 for i in range(self.nplots):
576 for i in range(self.nplots):
555 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
577 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
556 title = "Channel %d: %4.2fdB: %s" %(dataOut.channelList[i]+1, noisedB[i], str_datetime)
578 title = "Channel %d: %4.2fdB: %s" %(dataOut.channelList[i]+1, noisedB[i], str_datetime)
557 axes = self.axesList[i*self.__nsubplots]
579 axes = self.axesList[i*self.__nsubplots]
558 axes.pcolor(x, y, zdB[i,:,:],
580 axes.pcolor(x, y, zdB[i,:,:],
559 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
581 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
560 xlabel=xlabel, ylabel=ylabel, title=title,
582 xlabel=xlabel, ylabel=ylabel, title=title,
561 ticksize=9, cblabel='')
583 ticksize=9, cblabel='')
562
584
563 if self.__showprofile:
585 if self.__showprofile:
564 axes = self.axesList[i*self.__nsubplots +1]
586 axes = self.axesList[i*self.__nsubplots +1]
565 axes.pline(avgdB[i], y,
587 axes.pline(avgdB[i], y,
566 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
588 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
567 xlabel='dB', ylabel='', title='',
589 xlabel='dB', ylabel='', title='',
568 ytick_visible=False,
590 ytick_visible=False,
569 grid='x')
591 grid='x')
570
592
571 noiseline = numpy.repeat(noisedB[i], len(y))
593 noiseline = numpy.repeat(noisedB[i], len(y))
572 axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2)
594 axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2)
573
595
574 self.draw()
596 self.draw()
575
597
576 if save:
598 if save:
577
599
578 self.counter_imagwr += 1
600 self.counter_imagwr += 1
579 if (self.counter_imagwr==wr_period):
601 if (self.counter_imagwr==wr_period):
580 if figfile == None:
602 if figfile == None:
581 str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S")
603 str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S")
582 figfile = self.getFilename(name = str_datetime)
604 figfile = self.getFilename(name = str_datetime)
583
605
584 self.saveFigure(figpath, figfile)
606 self.saveFigure(figpath, figfile)
585
607
586 if ftp:
608 if ftp:
587 #provisionalmente envia archivos en el formato de la web en tiempo real
609 #provisionalmente envia archivos en el formato de la web en tiempo real
588 name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS)
610 name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS)
589 path = '%s%03d' %(self.PREFIX, self.id)
611 path = '%s%03d' %(self.PREFIX, self.id)
590 ftp_file = os.path.join(path,'ftp','%s.png'%name)
612 ftp_file = os.path.join(path,'ftp','%s.png'%name)
591 self.saveFigure(figpath, ftp_file)
613 self.saveFigure(figpath, ftp_file)
592 ftp_filename = os.path.join(figpath,ftp_file)
614 ftp_filename = os.path.join(figpath,ftp_file)
593 self.sendByFTP_Thread(ftp_filename, server, folder, username, password)
615 self.sendByFTP_Thread(ftp_filename, server, folder, username, password)
594 self.counter_imagwr = 0
616 self.counter_imagwr = 0
595
617
596
618
597 self.counter_imagwr = 0
619 self.counter_imagwr = 0
598
620
599
621
600 class Scope(Figure):
622 class Scope(Figure):
601
623
602 __isConfig = None
624 __isConfig = None
603
625
604 def __init__(self):
626 def __init__(self):
605
627
606 self.__isConfig = False
628 self.__isConfig = False
607 self.WIDTH = 600
629 self.WIDTH = 600
608 self.HEIGHT = 200
630 self.HEIGHT = 200
609 self.counter_imagwr = 0
631 self.counter_imagwr = 0
610
632
611 def getSubplots(self):
633 def getSubplots(self):
612
634
613 nrow = self.nplots
635 nrow = self.nplots
614 ncol = 3
636 ncol = 3
615 return nrow, ncol
637 return nrow, ncol
616
638
617 def setup(self, id, nplots, wintitle, show):
639 def setup(self, id, nplots, wintitle, show):
618
640
619 self.nplots = nplots
641 self.nplots = nplots
620
642
621 self.createFigure(id=id,
643 self.createFigure(id=id,
622 wintitle=wintitle,
644 wintitle=wintitle,
623 show=show)
645 show=show)
624
646
625 nrow,ncol = self.getSubplots()
647 nrow,ncol = self.getSubplots()
626 colspan = 3
648 colspan = 3
627 rowspan = 1
649 rowspan = 1
628
650
629 for i in range(nplots):
651 for i in range(nplots):
630 self.addAxes(nrow, ncol, i, 0, colspan, rowspan)
652 self.addAxes(nrow, ncol, i, 0, colspan, rowspan)
631
653
632
654
633
655
634 def run(self, dataOut, id, wintitle="", channelList=None,
656 def run(self, dataOut, id, wintitle="", channelList=None,
635 xmin=None, xmax=None, ymin=None, ymax=None, save=False,
657 xmin=None, xmax=None, ymin=None, ymax=None, save=False,
636 figpath='./', figfile=None, show=True, wr_period=1,
658 figpath='./', figfile=None, show=True, wr_period=1,
637 server=None, folder=None, username=None, password=None):
659 server=None, folder=None, username=None, password=None):
638
660
639 """
661 """
640
662
641 Input:
663 Input:
642 dataOut :
664 dataOut :
643 id :
665 id :
644 wintitle :
666 wintitle :
645 channelList :
667 channelList :
646 xmin : None,
668 xmin : None,
647 xmax : None,
669 xmax : None,
648 ymin : None,
670 ymin : None,
649 ymax : None,
671 ymax : None,
650 """
672 """
651
673
652 if channelList == None:
674 if channelList == None:
653 channelIndexList = dataOut.channelIndexList
675 channelIndexList = dataOut.channelIndexList
654 else:
676 else:
655 channelIndexList = []
677 channelIndexList = []
656 for channel in channelList:
678 for channel in channelList:
657 if channel not in dataOut.channelList:
679 if channel not in dataOut.channelList:
658 raise ValueError, "Channel %d is not in dataOut.channelList"
680 raise ValueError, "Channel %d is not in dataOut.channelList"
659 channelIndexList.append(dataOut.channelList.index(channel))
681 channelIndexList.append(dataOut.channelList.index(channel))
660
682
661 x = dataOut.heightList
683 x = dataOut.heightList
662 y = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:])
684 y = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:])
663 y = y.real
685 y = y.real
664
686
665 #thisDatetime = dataOut.datatime
687 #thisDatetime = dataOut.datatime
666 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1])
688 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1])
667 title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
689 title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
668 xlabel = "Range (Km)"
690 xlabel = "Range (Km)"
669 ylabel = "Intensity"
691 ylabel = "Intensity"
670
692
671 if not self.__isConfig:
693 if not self.__isConfig:
672 nplots = len(channelIndexList)
694 nplots = len(channelIndexList)
673
695
674 self.setup(id=id,
696 self.setup(id=id,
675 nplots=nplots,
697 nplots=nplots,
676 wintitle=wintitle,
698 wintitle=wintitle,
677 show=show)
699 show=show)
678
700
679 if xmin == None: xmin = numpy.nanmin(x)
701 if xmin == None: xmin = numpy.nanmin(x)
680 if xmax == None: xmax = numpy.nanmax(x)
702 if xmax == None: xmax = numpy.nanmax(x)
681 if ymin == None: ymin = numpy.nanmin(y)
703 if ymin == None: ymin = numpy.nanmin(y)
682 if ymax == None: ymax = numpy.nanmax(y)
704 if ymax == None: ymax = numpy.nanmax(y)
683
705
684 self.__isConfig = True
706 self.__isConfig = True
685
707
686 self.setWinTitle(title)
708 self.setWinTitle(title)
687
709
688 for i in range(len(self.axesList)):
710 for i in range(len(self.axesList)):
689 title = "Channel %d" %(i)
711 title = "Channel %d" %(i)
690 axes = self.axesList[i]
712 axes = self.axesList[i]
691 ychannel = y[i,:]
713 ychannel = y[i,:]
692 axes.pline(x, ychannel,
714 axes.pline(x, ychannel,
693 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
715 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
694 xlabel=xlabel, ylabel=ylabel, title=title)
716 xlabel=xlabel, ylabel=ylabel, title=title)
695
717
696 self.draw()
718 self.draw()
697
719
698 if save:
720 if save:
699 date = thisDatetime.strftime("%Y%m%d_%H%M%S")
721 date = thisDatetime.strftime("%Y%m%d_%H%M%S")
700 if figfile == None:
722 if figfile == None:
701 figfile = self.getFilename(name = date)
723 figfile = self.getFilename(name = date)
702
724
703 self.saveFigure(figpath, figfile)
725 self.saveFigure(figpath, figfile)
704
726
705 self.counter_imagwr += 1
727 self.counter_imagwr += 1
706 if (ftp and (self.counter_imagwr==wr_period)):
728 if (ftp and (self.counter_imagwr==wr_period)):
707 ftp_filename = os.path.join(figpath,figfile)
729 ftp_filename = os.path.join(figpath,figfile)
708 self.sendByFTP_Thread(ftp_filename, server, folder, username, password)
730 self.sendByFTP_Thread(ftp_filename, server, folder, username, password)
709 self.counter_imagwr = 0
731 self.counter_imagwr = 0
710
732
711 class PowerProfilePlot(Figure):
733 class PowerProfilePlot(Figure):
712 __isConfig = None
734 __isConfig = None
713 __nsubplots = None
735 __nsubplots = None
714
736
715 WIDTHPROF = None
737 WIDTHPROF = None
716 HEIGHTPROF = None
738 HEIGHTPROF = None
717 PREFIX = 'spcprofile'
739 PREFIX = 'spcprofile'
718
740
719 def __init__(self):
741 def __init__(self):
720 self.__isConfig = False
742 self.__isConfig = False
721 self.__nsubplots = 1
743 self.__nsubplots = 1
722
744
723 self.WIDTH = 300
745 self.WIDTH = 300
724 self.HEIGHT = 500
746 self.HEIGHT = 500
725 self.counter_imagwr = 0
747 self.counter_imagwr = 0
726
748
727 def getSubplots(self):
749 def getSubplots(self):
728 ncol = 1
750 ncol = 1
729 nrow = 1
751 nrow = 1
730
752
731 return nrow, ncol
753 return nrow, ncol
732
754
733 def setup(self, id, nplots, wintitle, show):
755 def setup(self, id, nplots, wintitle, show):
734
756
735 self.nplots = nplots
757 self.nplots = nplots
736
758
737 ncolspan = 1
759 ncolspan = 1
738 colspan = 1
760 colspan = 1
739
761
740 self.createFigure(id = id,
762 self.createFigure(id = id,
741 wintitle = wintitle,
763 wintitle = wintitle,
742 widthplot = self.WIDTH,
764 widthplot = self.WIDTH,
743 heightplot = self.HEIGHT,
765 heightplot = self.HEIGHT,
744 show=show)
766 show=show)
745
767
746 nrow, ncol = self.getSubplots()
768 nrow, ncol = self.getSubplots()
747
769
748 counter = 0
770 counter = 0
749 for y in range(nrow):
771 for y in range(nrow):
750 for x in range(ncol):
772 for x in range(ncol):
751 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
773 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
752
774
753 def run(self, dataOut, id, wintitle="", channelList=None,
775 def run(self, dataOut, id, wintitle="", channelList=None,
754 xmin=None, xmax=None, ymin=None, ymax=None,
776 xmin=None, xmax=None, ymin=None, ymax=None,
755 save=False, figpath='./', figfile=None, show=True, wr_period=1,
777 save=False, figpath='./', figfile=None, show=True, wr_period=1,
756 server=None, folder=None, username=None, password=None,):
778 server=None, folder=None, username=None, password=None,):
757
779
758 if channelList == None:
780 if channelList == None:
759 channelIndexList = dataOut.channelIndexList
781 channelIndexList = dataOut.channelIndexList
760 channelList = dataOut.channelList
782 channelList = dataOut.channelList
761 else:
783 else:
762 channelIndexList = []
784 channelIndexList = []
763 for channel in channelList:
785 for channel in channelList:
764 if channel not in dataOut.channelList:
786 if channel not in dataOut.channelList:
765 raise ValueError, "Channel %d is not in dataOut.channelList"
787 raise ValueError, "Channel %d is not in dataOut.channelList"
766 channelIndexList.append(dataOut.channelList.index(channel))
788 channelIndexList.append(dataOut.channelList.index(channel))
767
789
768 #factor = dataOut.normFactor
790 #factor = dataOut.normFactor
769 y = dataOut.getHeiRange()
791 y = dataOut.getHeiRange()
770 x = dataOut.data_spc[channelIndexList,:,:]#/factor
792 x = dataOut.data_spc[channelIndexList,:,:]#/factor
771 x = numpy.where(numpy.isfinite(x), x, numpy.NAN)
793 x = numpy.where(numpy.isfinite(x), x, numpy.NAN)
772 avg = numpy.average(x, axis=1)
794 avg = numpy.average(x, axis=1)
773
795
774 avgdB = 10*numpy.log10(avg)
796 avgdB = 10*numpy.log10(avg)
775
797
776 #thisDatetime = dataOut.datatime
798 #thisDatetime = dataOut.datatime
777 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1])
799 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1])
778 title = wintitle + " Power Profile %s" %(thisDatetime.strftime("%d-%b-%Y"))
800 title = wintitle + " Power Profile %s" %(thisDatetime.strftime("%d-%b-%Y"))
779 xlabel = "dB"
801 xlabel = "dB"
780 ylabel = "Range (Km)"
802 ylabel = "Range (Km)"
781
803
782 if not self.__isConfig:
804 if not self.__isConfig:
783
805
784 nplots = 1
806 nplots = 1
785
807
786 self.setup(id=id,
808 self.setup(id=id,
787 nplots=nplots,
809 nplots=nplots,
788 wintitle=wintitle,
810 wintitle=wintitle,
789 show=show)
811 show=show)
790
812
791 if ymin == None: ymin = numpy.nanmin(y)
813 if ymin == None: ymin = numpy.nanmin(y)
792 if ymax == None: ymax = numpy.nanmax(y)
814 if ymax == None: ymax = numpy.nanmax(y)
793 if xmin == None: xmin = numpy.nanmin(avgdB)*0.9
815 if xmin == None: xmin = numpy.nanmin(avgdB)*0.9
794 if xmax == None: xmax = numpy.nanmax(avgdB)*0.9
816 if xmax == None: xmax = numpy.nanmax(avgdB)*0.9
795
817
796 self.__isConfig = True
818 self.__isConfig = True
797
819
798 self.setWinTitle(title)
820 self.setWinTitle(title)
799
821
800
822
801 title = "Power Profile: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
823 title = "Power Profile: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
802 axes = self.axesList[0]
824 axes = self.axesList[0]
803
825
804 legendlabels = ["channel %d"%x for x in channelList]
826 legendlabels = ["channel %d"%x for x in channelList]
805 axes.pmultiline(avgdB, y,
827 axes.pmultiline(avgdB, y,
806 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
828 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
807 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels,
829 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels,
808 ytick_visible=True, nxticks=5,
830 ytick_visible=True, nxticks=5,
809 grid='x')
831 grid='x')
810
832
811 self.draw()
833 self.draw()
812
834
813 if save:
835 if save:
814 date = thisDatetime.strftime("%Y%m%d")
836 date = thisDatetime.strftime("%Y%m%d")
815 if figfile == None:
837 if figfile == None:
816 figfile = self.getFilename(name = date)
838 figfile = self.getFilename(name = date)
817
839
818 self.saveFigure(figpath, figfile)
840 self.saveFigure(figpath, figfile)
819
841
820 self.counter_imagwr += 1
842 self.counter_imagwr += 1
821 if (ftp and (self.counter_imagwr==wr_period)):
843 if (ftp and (self.counter_imagwr==wr_period)):
822 ftp_filename = os.path.join(figpath,figfile)
844 ftp_filename = os.path.join(figpath,figfile)
823 self.sendByFTP_Thread(ftp_filename, server, folder, username, password)
845 self.sendByFTP_Thread(ftp_filename, server, folder, username, password)
824 self.counter_imagwr = 0
846 self.counter_imagwr = 0
825
847
826 class CoherenceMap(Figure):
848 class CoherenceMap(Figure):
827 __isConfig = None
849 __isConfig = None
828 __nsubplots = None
850 __nsubplots = None
829
851
830 WIDTHPROF = None
852 WIDTHPROF = None
831 HEIGHTPROF = None
853 HEIGHTPROF = None
832 PREFIX = 'cmap'
854 PREFIX = 'cmap'
833
855
834 def __init__(self):
856 def __init__(self):
835 self.timerange = 2*60*60
857 self.timerange = 2*60*60
836 self.__isConfig = False
858 self.__isConfig = False
837 self.__nsubplots = 1
859 self.__nsubplots = 1
838
860
839 self.WIDTH = 800
861 self.WIDTH = 800
840 self.HEIGHT = 150
862 self.HEIGHT = 150
841 self.WIDTHPROF = 120
863 self.WIDTHPROF = 120
842 self.HEIGHTPROF = 0
864 self.HEIGHTPROF = 0
843 self.counter_imagwr = 0
865 self.counter_imagwr = 0
844
866
845 self.PLOT_CODE = 3
867 self.PLOT_CODE = 3
846 self.FTP_WEI = None
868 self.FTP_WEI = None
847 self.EXP_CODE = None
869 self.EXP_CODE = None
848 self.SUB_EXP_CODE = None
870 self.SUB_EXP_CODE = None
849 self.PLOT_POS = None
871 self.PLOT_POS = None
850 self.counter_imagwr = 0
872 self.counter_imagwr = 0
851
873
852 def getSubplots(self):
874 def getSubplots(self):
853 ncol = 1
875 ncol = 1
854 nrow = self.nplots*2
876 nrow = self.nplots*2
855
877
856 return nrow, ncol
878 return nrow, ncol
857
879
858 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
880 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
859 self.__showprofile = showprofile
881 self.__showprofile = showprofile
860 self.nplots = nplots
882 self.nplots = nplots
861
883
862 ncolspan = 1
884 ncolspan = 1
863 colspan = 1
885 colspan = 1
864 if showprofile:
886 if showprofile:
865 ncolspan = 7
887 ncolspan = 7
866 colspan = 6
888 colspan = 6
867 self.__nsubplots = 2
889 self.__nsubplots = 2
868
890
869 self.createFigure(id = id,
891 self.createFigure(id = id,
870 wintitle = wintitle,
892 wintitle = wintitle,
871 widthplot = self.WIDTH + self.WIDTHPROF,
893 widthplot = self.WIDTH + self.WIDTHPROF,
872 heightplot = self.HEIGHT + self.HEIGHTPROF,
894 heightplot = self.HEIGHT + self.HEIGHTPROF,
873 show=True)
895 show=True)
874
896
875 nrow, ncol = self.getSubplots()
897 nrow, ncol = self.getSubplots()
876
898
877 for y in range(nrow):
899 for y in range(nrow):
878 for x in range(ncol):
900 for x in range(ncol):
879
901
880 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
902 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
881
903
882 if showprofile:
904 if showprofile:
883 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
905 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
884
906
885 def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True',
907 def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True',
886 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
908 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
887 timerange=None,
909 timerange=None,
888 save=False, figpath='./', figfile=None, ftp=False, wr_period=1,
910 save=False, figpath='./', figfile=None, ftp=False, wr_period=1,
889 coherence_cmap='jet', phase_cmap='RdBu_r', show=True,
911 coherence_cmap='jet', phase_cmap='RdBu_r', show=True,
890 server=None, folder=None, username=None, password=None,
912 server=None, folder=None, username=None, password=None,
891 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
913 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
892
914
893 if pairsList == None:
915 if pairsList == None:
894 pairsIndexList = dataOut.pairsIndexList
916 pairsIndexList = dataOut.pairsIndexList
895 else:
917 else:
896 pairsIndexList = []
918 pairsIndexList = []
897 for pair in pairsList:
919 for pair in pairsList:
898 if pair not in dataOut.pairsList:
920 if pair not in dataOut.pairsList:
899 raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair)
921 raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair)
900 pairsIndexList.append(dataOut.pairsList.index(pair))
922 pairsIndexList.append(dataOut.pairsList.index(pair))
901
923
902 if timerange != None:
924 if timerange != None:
903 self.timerange = timerange
925 self.timerange = timerange
904
926
905 if pairsIndexList == []:
927 if pairsIndexList == []:
906 return
928 return
907
929
908 if len(pairsIndexList) > 4:
930 if len(pairsIndexList) > 4:
909 pairsIndexList = pairsIndexList[0:4]
931 pairsIndexList = pairsIndexList[0:4]
910
932
911 tmin = None
933 tmin = None
912 tmax = None
934 tmax = None
913 x = dataOut.getTimeRange()
935 x = dataOut.getTimeRange()
914 y = dataOut.getHeiRange()
936 y = dataOut.getHeiRange()
915
937
916 #thisDatetime = dataOut.datatime
938 #thisDatetime = dataOut.datatime
917 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1])
939 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1])
918 title = wintitle + " CoherenceMap" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
940 title = wintitle + " CoherenceMap" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
919 xlabel = ""
941 xlabel = ""
920 ylabel = "Range (Km)"
942 ylabel = "Range (Km)"
921
943
922 if not self.__isConfig:
944 if not self.__isConfig:
923 nplots = len(pairsIndexList)
945 nplots = len(pairsIndexList)
924 self.setup(id=id,
946 self.setup(id=id,
925 nplots=nplots,
947 nplots=nplots,
926 wintitle=wintitle,
948 wintitle=wintitle,
927 showprofile=showprofile,
949 showprofile=showprofile,
928 show=show)
950 show=show)
929
951
930 tmin, tmax = self.getTimeLim(x, xmin, xmax)
952 tmin, tmax = self.getTimeLim(x, xmin, xmax)
931 if ymin == None: ymin = numpy.nanmin(y)
953 if ymin == None: ymin = numpy.nanmin(y)
932 if ymax == None: ymax = numpy.nanmax(y)
954 if ymax == None: ymax = numpy.nanmax(y)
933 if zmin == None: zmin = 0.
955 if zmin == None: zmin = 0.
934 if zmax == None: zmax = 1.
956 if zmax == None: zmax = 1.
935
957
936 self.FTP_WEI = ftp_wei
958 self.FTP_WEI = ftp_wei
937 self.EXP_CODE = exp_code
959 self.EXP_CODE = exp_code
938 self.SUB_EXP_CODE = sub_exp_code
960 self.SUB_EXP_CODE = sub_exp_code
939 self.PLOT_POS = plot_pos
961 self.PLOT_POS = plot_pos
940
962
941 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
963 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
942
964
943 self.__isConfig = True
965 self.__isConfig = True
944
966
945 self.setWinTitle(title)
967 self.setWinTitle(title)
946
968
947 for i in range(self.nplots):
969 for i in range(self.nplots):
948
970
949 pair = dataOut.pairsList[pairsIndexList[i]]
971 pair = dataOut.pairsList[pairsIndexList[i]]
950 # coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:])
972 # coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:])
951 # avgcoherenceComplex = numpy.average(coherenceComplex, axis=0)
973 # avgcoherenceComplex = numpy.average(coherenceComplex, axis=0)
952 # coherence = numpy.abs(avgcoherenceComplex)
974 # coherence = numpy.abs(avgcoherenceComplex)
953
975
954 ## coherence = numpy.abs(coherenceComplex)
976 ## coherence = numpy.abs(coherenceComplex)
955 ## avg = numpy.average(coherence, axis=0)
977 ## avg = numpy.average(coherence, axis=0)
956
978
957 ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i],:,:],axis=0)
979 ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i],:,:],axis=0)
958 powa = numpy.average(dataOut.data_spc[pair[0],:,:],axis=0)
980 powa = numpy.average(dataOut.data_spc[pair[0],:,:],axis=0)
959 powb = numpy.average(dataOut.data_spc[pair[1],:,:],axis=0)
981 powb = numpy.average(dataOut.data_spc[pair[1],:,:],axis=0)
960
982
961
983
962 avgcoherenceComplex = ccf/numpy.sqrt(powa*powb)
984 avgcoherenceComplex = ccf/numpy.sqrt(powa*powb)
963 coherence = numpy.abs(avgcoherenceComplex)
985 coherence = numpy.abs(avgcoherenceComplex)
964
986
965 z = coherence.reshape((1,-1))
987 z = coherence.reshape((1,-1))
966
988
967 counter = 0
989 counter = 0
968
990
969 title = "Coherence %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
991 title = "Coherence %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
970 axes = self.axesList[i*self.__nsubplots*2]
992 axes = self.axesList[i*self.__nsubplots*2]
971 axes.pcolorbuffer(x, y, z,
993 axes.pcolorbuffer(x, y, z,
972 xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
994 xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
973 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
995 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
974 ticksize=9, cblabel='', colormap=coherence_cmap, cbsize="1%")
996 ticksize=9, cblabel='', colormap=coherence_cmap, cbsize="1%")
975
997
976 if self.__showprofile:
998 if self.__showprofile:
977 counter += 1
999 counter += 1
978 axes = self.axesList[i*self.__nsubplots*2 + counter]
1000 axes = self.axesList[i*self.__nsubplots*2 + counter]
979 axes.pline(coherence, y,
1001 axes.pline(coherence, y,
980 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
1002 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
981 xlabel='', ylabel='', title='', ticksize=7,
1003 xlabel='', ylabel='', title='', ticksize=7,
982 ytick_visible=False, nxticks=5,
1004 ytick_visible=False, nxticks=5,
983 grid='x')
1005 grid='x')
984
1006
985 counter += 1
1007 counter += 1
986 # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi
1008 # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi
987 phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi
1009 phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi
988 # avg = numpy.average(phase, axis=0)
1010 # avg = numpy.average(phase, axis=0)
989 z = phase.reshape((1,-1))
1011 z = phase.reshape((1,-1))
990
1012
991 title = "Phase %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
1013 title = "Phase %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
992 axes = self.axesList[i*self.__nsubplots*2 + counter]
1014 axes = self.axesList[i*self.__nsubplots*2 + counter]
993 axes.pcolorbuffer(x, y, z,
1015 axes.pcolorbuffer(x, y, z,
994 xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180,
1016 xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180,
995 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1017 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
996 ticksize=9, cblabel='', colormap=phase_cmap, cbsize="1%")
1018 ticksize=9, cblabel='', colormap=phase_cmap, cbsize="1%")
997
1019
998 if self.__showprofile:
1020 if self.__showprofile:
999 counter += 1
1021 counter += 1
1000 axes = self.axesList[i*self.__nsubplots*2 + counter]
1022 axes = self.axesList[i*self.__nsubplots*2 + counter]
1001 axes.pline(phase, y,
1023 axes.pline(phase, y,
1002 xmin=-180, xmax=180, ymin=ymin, ymax=ymax,
1024 xmin=-180, xmax=180, ymin=ymin, ymax=ymax,
1003 xlabel='', ylabel='', title='', ticksize=7,
1025 xlabel='', ylabel='', title='', ticksize=7,
1004 ytick_visible=False, nxticks=4,
1026 ytick_visible=False, nxticks=4,
1005 grid='x')
1027 grid='x')
1006
1028
1007 self.draw()
1029 self.draw()
1008
1030
1009 if save:
1031 if save:
1010
1032
1011 self.counter_imagwr += 1
1033 self.counter_imagwr += 1
1012 if (self.counter_imagwr==wr_period):
1034 if (self.counter_imagwr==wr_period):
1013 if figfile == None:
1035 if figfile == None:
1014 figfile = self.getFilename(name = self.name)
1036 figfile = self.getFilename(name = self.name)
1015 self.saveFigure(figpath, figfile)
1037 self.saveFigure(figpath, figfile)
1016
1038
1017 if ftp:
1039 if ftp:
1018 #provisionalmente envia archivos en el formato de la web en tiempo real
1040 #provisionalmente envia archivos en el formato de la web en tiempo real
1019 name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS)
1041 name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS)
1020 path = '%s%03d' %(self.PREFIX, self.id)
1042 path = '%s%03d' %(self.PREFIX, self.id)
1021 ftp_file = os.path.join(path,'ftp','%s.png'%name)
1043 ftp_file = os.path.join(path,'ftp','%s.png'%name)
1022 self.saveFigure(figpath, ftp_file)
1044 self.saveFigure(figpath, ftp_file)
1023 ftp_filename = os.path.join(figpath,ftp_file)
1045 ftp_filename = os.path.join(figpath,ftp_file)
1024 self.sendByFTP_Thread(ftp_filename, server, folder, username, password)
1046 self.sendByFTP_Thread(ftp_filename, server, folder, username, password)
1025 self.counter_imagwr = 0
1047 self.counter_imagwr = 0
1026
1048
1027 self.counter_imagwr = 0
1049 self.counter_imagwr = 0
1028
1050
1029
1051
1030 if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax:
1052 if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax:
1031 self.__isConfig = False
1053 self.__isConfig = False
1032
1054
1033 class BeaconPhase(Figure):
1055 class BeaconPhase(Figure):
1034
1056
1035 __isConfig = None
1057 __isConfig = None
1036 __nsubplots = None
1058 __nsubplots = None
1037
1059
1038 PREFIX = 'beacon_phase'
1060 PREFIX = 'beacon_phase'
1039
1061
1040 def __init__(self):
1062 def __init__(self):
1041
1063
1042 self.timerange = 24*60*60
1064 self.timerange = 24*60*60
1043 self.__isConfig = False
1065 self.__isConfig = False
1044 self.__nsubplots = 1
1066 self.__nsubplots = 1
1045 self.counter_imagwr = 0
1067 self.counter_imagwr = 0
1046 self.WIDTH = 600
1068 self.WIDTH = 600
1047 self.HEIGHT = 300
1069 self.HEIGHT = 300
1048 self.WIDTHPROF = 120
1070 self.WIDTHPROF = 120
1049 self.HEIGHTPROF = 0
1071 self.HEIGHTPROF = 0
1050 self.xdata = None
1072 self.xdata = None
1051 self.ydata = None
1073 self.ydata = None
1052
1074
1053 self.PLOT_CODE = 18
1075 self.PLOT_CODE = 18
1054 self.FTP_WEI = None
1076 self.FTP_WEI = None
1055 self.EXP_CODE = None
1077 self.EXP_CODE = None
1056 self.SUB_EXP_CODE = None
1078 self.SUB_EXP_CODE = None
1057 self.PLOT_POS = None
1079 self.PLOT_POS = None
1058
1080
1059 def getSubplots(self):
1081 def getSubplots(self):
1060
1082
1061 ncol = 1
1083 ncol = 1
1062 nrow = 1
1084 nrow = 1
1063
1085
1064 return nrow, ncol
1086 return nrow, ncol
1065
1087
1066 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1088 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1067
1089
1068 self.__showprofile = showprofile
1090 self.__showprofile = showprofile
1069 self.nplots = nplots
1091 self.nplots = nplots
1070
1092
1071 ncolspan = 7
1093 ncolspan = 7
1072 colspan = 6
1094 colspan = 6
1073 self.__nsubplots = 2
1095 self.__nsubplots = 2
1074
1096
1075 self.createFigure(id = id,
1097 self.createFigure(id = id,
1076 wintitle = wintitle,
1098 wintitle = wintitle,
1077 widthplot = self.WIDTH+self.WIDTHPROF,
1099 widthplot = self.WIDTH+self.WIDTHPROF,
1078 heightplot = self.HEIGHT+self.HEIGHTPROF,
1100 heightplot = self.HEIGHT+self.HEIGHTPROF,
1079 show=show)
1101 show=show)
1080
1102
1081 nrow, ncol = self.getSubplots()
1103 nrow, ncol = self.getSubplots()
1082
1104
1083 self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1)
1105 self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1)
1084
1106
1085
1107
1086 def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True',
1108 def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True',
1087 xmin=None, xmax=None, ymin=None, ymax=None,
1109 xmin=None, xmax=None, ymin=None, ymax=None,
1088 timerange=None,
1110 timerange=None,
1089 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1111 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1090 server=None, folder=None, username=None, password=None,
1112 server=None, folder=None, username=None, password=None,
1091 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1113 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1092
1114
1093 if pairsList == None:
1115 if pairsList == None:
1094 pairsIndexList = dataOut.pairsIndexList
1116 pairsIndexList = dataOut.pairsIndexList
1095 else:
1117 else:
1096 pairsIndexList = []
1118 pairsIndexList = []
1097 for pair in pairsList:
1119 for pair in pairsList:
1098 if pair not in dataOut.pairsList:
1120 if pair not in dataOut.pairsList:
1099 raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair)
1121 raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair)
1100 pairsIndexList.append(dataOut.pairsList.index(pair))
1122 pairsIndexList.append(dataOut.pairsList.index(pair))
1101
1123
1102 if pairsIndexList == []:
1124 if pairsIndexList == []:
1103 return
1125 return
1104
1126
1105 # if len(pairsIndexList) > 4:
1127 # if len(pairsIndexList) > 4:
1106 # pairsIndexList = pairsIndexList[0:4]
1128 # pairsIndexList = pairsIndexList[0:4]
1107
1129
1108 if timerange != None:
1130 if timerange != None:
1109 self.timerange = timerange
1131 self.timerange = timerange
1110
1132
1111 tmin = None
1133 tmin = None
1112 tmax = None
1134 tmax = None
1113 x = dataOut.getTimeRange()
1135 x = dataOut.getTimeRange()
1114 y = dataOut.getHeiRange()
1136 y = dataOut.getHeiRange()
1115
1137
1116
1138
1117 #thisDatetime = dataOut.datatime
1139 #thisDatetime = dataOut.datatime
1118 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1])
1140 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1])
1119 title = wintitle + " Phase of Beacon Signal" # : %s" %(thisDatetime.strftime("%d-%b-%Y"))
1141 title = wintitle + " Phase of Beacon Signal" # : %s" %(thisDatetime.strftime("%d-%b-%Y"))
1120 xlabel = "Local Time"
1142 xlabel = "Local Time"
1121 ylabel = "Phase"
1143 ylabel = "Phase"
1122
1144
1123 nplots = len(pairsIndexList)
1145 nplots = len(pairsIndexList)
1124 #phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList)))
1146 #phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList)))
1125 phase_beacon = numpy.zeros(len(pairsIndexList))
1147 phase_beacon = numpy.zeros(len(pairsIndexList))
1126 for i in range(nplots):
1148 for i in range(nplots):
1127 pair = dataOut.pairsList[pairsIndexList[i]]
1149 pair = dataOut.pairsList[pairsIndexList[i]]
1128 ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i],:,:],axis=0)
1150 ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i],:,:],axis=0)
1129 powa = numpy.average(dataOut.data_spc[pair[0],:,:],axis=0)
1151 powa = numpy.average(dataOut.data_spc[pair[0],:,:],axis=0)
1130 powb = numpy.average(dataOut.data_spc[pair[1],:,:],axis=0)
1152 powb = numpy.average(dataOut.data_spc[pair[1],:,:],axis=0)
1131 avgcoherenceComplex = ccf/numpy.sqrt(powa*powb)
1153 avgcoherenceComplex = ccf/numpy.sqrt(powa*powb)
1132 phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi
1154 phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi
1133
1155
1134 #print "Phase %d%d" %(pair[0], pair[1])
1156 #print "Phase %d%d" %(pair[0], pair[1])
1135 #print phase[dataOut.beacon_heiIndexList]
1157 #print phase[dataOut.beacon_heiIndexList]
1136
1158
1137 phase_beacon[i] = numpy.average(phase[dataOut.beacon_heiIndexList])
1159 phase_beacon[i] = numpy.average(phase[dataOut.beacon_heiIndexList])
1138
1160
1139 if not self.__isConfig:
1161 if not self.__isConfig:
1140
1162
1141 nplots = len(pairsIndexList)
1163 nplots = len(pairsIndexList)
1142
1164
1143 self.setup(id=id,
1165 self.setup(id=id,
1144 nplots=nplots,
1166 nplots=nplots,
1145 wintitle=wintitle,
1167 wintitle=wintitle,
1146 showprofile=showprofile,
1168 showprofile=showprofile,
1147 show=show)
1169 show=show)
1148
1170
1149 tmin, tmax = self.getTimeLim(x, xmin, xmax)
1171 tmin, tmax = self.getTimeLim(x, xmin, xmax)
1150 if ymin == None: ymin = numpy.nanmin(phase_beacon) - 10.0
1172 if ymin == None: ymin = numpy.nanmin(phase_beacon) - 10.0
1151 if ymax == None: ymax = numpy.nanmax(phase_beacon) + 10.0
1173 if ymax == None: ymax = numpy.nanmax(phase_beacon) + 10.0
1152
1174
1153 self.FTP_WEI = ftp_wei
1175 self.FTP_WEI = ftp_wei
1154 self.EXP_CODE = exp_code
1176 self.EXP_CODE = exp_code
1155 self.SUB_EXP_CODE = sub_exp_code
1177 self.SUB_EXP_CODE = sub_exp_code
1156 self.PLOT_POS = plot_pos
1178 self.PLOT_POS = plot_pos
1157
1179
1158 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1180 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1159 self.__isConfig = True
1181 self.__isConfig = True
1160
1182
1161 self.xdata = numpy.array([])
1183 self.xdata = numpy.array([])
1162 self.ydata = numpy.array([])
1184 self.ydata = numpy.array([])
1163
1185
1164 self.setWinTitle(title)
1186 self.setWinTitle(title)
1165
1187
1166
1188
1167 title = "Beacon Signal %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1189 title = "Beacon Signal %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1168
1190
1169 legendlabels = ["pairs %d%d"%(pair[0], pair[1]) for pair in dataOut.pairsList]
1191 legendlabels = ["pairs %d%d"%(pair[0], pair[1]) for pair in dataOut.pairsList]
1170
1192
1171 axes = self.axesList[0]
1193 axes = self.axesList[0]
1172
1194
1173 self.xdata = numpy.hstack((self.xdata, x[0:1]))
1195 self.xdata = numpy.hstack((self.xdata, x[0:1]))
1174
1196
1175 if len(self.ydata)==0:
1197 if len(self.ydata)==0:
1176 self.ydata = phase_beacon.reshape(-1,1)
1198 self.ydata = phase_beacon.reshape(-1,1)
1177 else:
1199 else:
1178 self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1)))
1200 self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1)))
1179
1201
1180
1202
1181 axes.pmultilineyaxis(x=self.xdata, y=self.ydata,
1203 axes.pmultilineyaxis(x=self.xdata, y=self.ydata,
1182 xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax,
1204 xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax,
1183 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid",
1205 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid",
1184 XAxisAsTime=True, grid='both'
1206 XAxisAsTime=True, grid='both'
1185 )
1207 )
1186
1208
1187 self.draw()
1209 self.draw()
1188
1210
1189 if save:
1211 if save:
1190
1212
1191 self.counter_imagwr += 1
1213 self.counter_imagwr += 1
1192 if (self.counter_imagwr==wr_period):
1214 if (self.counter_imagwr==wr_period):
1193 if figfile == None:
1215 if figfile == None:
1194 figfile = self.getFilename(name = self.name)
1216 figfile = self.getFilename(name = self.name)
1195 self.saveFigure(figpath, figfile)
1217 self.saveFigure(figpath, figfile)
1196
1218
1197 if ftp:
1219 if ftp:
1198 #provisionalmente envia archivos en el formato de la web en tiempo real
1220 #provisionalmente envia archivos en el formato de la web en tiempo real
1199 name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS)
1221 name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS)
1200 path = '%s%03d' %(self.PREFIX, self.id)
1222 path = '%s%03d' %(self.PREFIX, self.id)
1201 ftp_file = os.path.join(path,'ftp','%s.png'%name)
1223 ftp_file = os.path.join(path,'ftp','%s.png'%name)
1202 self.saveFigure(figpath, ftp_file)
1224 self.saveFigure(figpath, ftp_file)
1203 ftp_filename = os.path.join(figpath,ftp_file)
1225 ftp_filename = os.path.join(figpath,ftp_file)
1204 self.sendByFTP_Thread(ftp_filename, server, folder, username, password)
1226 self.sendByFTP_Thread(ftp_filename, server, folder, username, password)
1205
1227
1206 self.counter_imagwr = 0
1228 self.counter_imagwr = 0
1207
1229
1208 if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax:
1230 if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax:
1209 self.__isConfig = False
1231 self.__isConfig = False
1210 del self.xdata
1232 del self.xdata
1211 del self.ydata
1233 del self.ydata
1212
1234
1213
1235
1214
1236
1215
1237
1216 class Noise(Figure):
1238 class Noise(Figure):
1217
1239
1218 __isConfig = None
1240 __isConfig = None
1219 __nsubplots = None
1241 __nsubplots = None
1220
1242
1221 PREFIX = 'noise'
1243 PREFIX = 'noise'
1222
1244
1223 def __init__(self):
1245 def __init__(self):
1224
1246
1225 self.timerange = 24*60*60
1247 self.timerange = 24*60*60
1226 self.__isConfig = False
1248 self.__isConfig = False
1227 self.__nsubplots = 1
1249 self.__nsubplots = 1
1228 self.counter_imagwr = 0
1250 self.counter_imagwr = 0
1229 self.WIDTH = 600
1251 self.WIDTH = 600
1230 self.HEIGHT = 300
1252 self.HEIGHT = 300
1231 self.WIDTHPROF = 120
1253 self.WIDTHPROF = 120
1232 self.HEIGHTPROF = 0
1254 self.HEIGHTPROF = 0
1233 self.xdata = None
1255 self.xdata = None
1234 self.ydata = None
1256 self.ydata = None
1235
1257
1236 self.PLOT_CODE = 77
1258 self.PLOT_CODE = 77
1237 self.FTP_WEI = None
1259 self.FTP_WEI = None
1238 self.EXP_CODE = None
1260 self.EXP_CODE = None
1239 self.SUB_EXP_CODE = None
1261 self.SUB_EXP_CODE = None
1240 self.PLOT_POS = None
1262 self.PLOT_POS = None
1241
1263
1242 def getSubplots(self):
1264 def getSubplots(self):
1243
1265
1244 ncol = 1
1266 ncol = 1
1245 nrow = 1
1267 nrow = 1
1246
1268
1247 return nrow, ncol
1269 return nrow, ncol
1248
1270
1249 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1271 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1250
1272
1251 self.__showprofile = showprofile
1273 self.__showprofile = showprofile
1252 self.nplots = nplots
1274 self.nplots = nplots
1253
1275
1254 ncolspan = 7
1276 ncolspan = 7
1255 colspan = 6
1277 colspan = 6
1256 self.__nsubplots = 2
1278 self.__nsubplots = 2
1257
1279
1258 self.createFigure(id = id,
1280 self.createFigure(id = id,
1259 wintitle = wintitle,
1281 wintitle = wintitle,
1260 widthplot = self.WIDTH+self.WIDTHPROF,
1282 widthplot = self.WIDTH+self.WIDTHPROF,
1261 heightplot = self.HEIGHT+self.HEIGHTPROF,
1283 heightplot = self.HEIGHT+self.HEIGHTPROF,
1262 show=show)
1284 show=show)
1263
1285
1264 nrow, ncol = self.getSubplots()
1286 nrow, ncol = self.getSubplots()
1265
1287
1266 self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1)
1288 self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1)
1267
1289
1268
1290
1269 def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True',
1291 def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True',
1270 xmin=None, xmax=None, ymin=None, ymax=None,
1292 xmin=None, xmax=None, ymin=None, ymax=None,
1271 timerange=None,
1293 timerange=None,
1272 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1294 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1273 server=None, folder=None, username=None, password=None,
1295 server=None, folder=None, username=None, password=None,
1274 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1296 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1275
1297
1276 if channelList == None:
1298 if channelList == None:
1277 channelIndexList = dataOut.channelIndexList
1299 channelIndexList = dataOut.channelIndexList
1278 channelList = dataOut.channelList
1300 channelList = dataOut.channelList
1279 else:
1301 else:
1280 channelIndexList = []
1302 channelIndexList = []
1281 for channel in channelList:
1303 for channel in channelList:
1282 if channel not in dataOut.channelList:
1304 if channel not in dataOut.channelList:
1283 raise ValueError, "Channel %d is not in dataOut.channelList"
1305 raise ValueError, "Channel %d is not in dataOut.channelList"
1284 channelIndexList.append(dataOut.channelList.index(channel))
1306 channelIndexList.append(dataOut.channelList.index(channel))
1285
1307
1286 if timerange != None:
1308 if timerange != None:
1287 self.timerange = timerange
1309 self.timerange = timerange
1288
1310
1289 tmin = None
1311 tmin = None
1290 tmax = None
1312 tmax = None
1291 x = dataOut.getTimeRange()
1313 x = dataOut.getTimeRange()
1292 y = dataOut.getHeiRange()
1314 y = dataOut.getHeiRange()
1293 #factor = dataOut.normFactor
1315 #factor = dataOut.normFactor
1294 noise = dataOut.getNoise()#/factor
1316 noise = dataOut.getNoise()#/factor
1295 noisedB = 10*numpy.log10(noise)
1317 noisedB = 10*numpy.log10(noise)
1296
1318
1297 #thisDatetime = dataOut.datatime
1319 #thisDatetime = dataOut.datatime
1298 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1])
1320 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1])
1299 title = wintitle + " Noise" # : %s" %(thisDatetime.strftime("%d-%b-%Y"))
1321 title = wintitle + " Noise" # : %s" %(thisDatetime.strftime("%d-%b-%Y"))
1300 xlabel = ""
1322 xlabel = ""
1301 ylabel = "Intensity (dB)"
1323 ylabel = "Intensity (dB)"
1302
1324
1303 if not self.__isConfig:
1325 if not self.__isConfig:
1304
1326
1305 nplots = 1
1327 nplots = 1
1306
1328
1307 self.setup(id=id,
1329 self.setup(id=id,
1308 nplots=nplots,
1330 nplots=nplots,
1309 wintitle=wintitle,
1331 wintitle=wintitle,
1310 showprofile=showprofile,
1332 showprofile=showprofile,
1311 show=show)
1333 show=show)
1312
1334
1313 tmin, tmax = self.getTimeLim(x, xmin, xmax)
1335 tmin, tmax = self.getTimeLim(x, xmin, xmax)
1314 if ymin == None: ymin = numpy.nanmin(noisedB) - 10.0
1336 if ymin == None: ymin = numpy.nanmin(noisedB) - 10.0
1315 if ymax == None: ymax = numpy.nanmax(noisedB) + 10.0
1337 if ymax == None: ymax = numpy.nanmax(noisedB) + 10.0
1316
1338
1317 self.FTP_WEI = ftp_wei
1339 self.FTP_WEI = ftp_wei
1318 self.EXP_CODE = exp_code
1340 self.EXP_CODE = exp_code
1319 self.SUB_EXP_CODE = sub_exp_code
1341 self.SUB_EXP_CODE = sub_exp_code
1320 self.PLOT_POS = plot_pos
1342 self.PLOT_POS = plot_pos
1321
1343
1322 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1344 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1323
1345
1324
1346
1325 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1347 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1326 self.__isConfig = True
1348 self.__isConfig = True
1327
1349
1328 self.xdata = numpy.array([])
1350 self.xdata = numpy.array([])
1329 self.ydata = numpy.array([])
1351 self.ydata = numpy.array([])
1330
1352
1331 self.setWinTitle(title)
1353 self.setWinTitle(title)
1332
1354
1333
1355
1334 title = "Noise %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1356 title = "Noise %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1335
1357
1336 legendlabels = ["channel %d"%(idchannel+1) for idchannel in channelList]
1358 legendlabels = ["channel %d"%(idchannel+1) for idchannel in channelList]
1337 axes = self.axesList[0]
1359 axes = self.axesList[0]
1338
1360
1339 self.xdata = numpy.hstack((self.xdata, x[0:1]))
1361 self.xdata = numpy.hstack((self.xdata, x[0:1]))
1340
1362
1341 if len(self.ydata)==0:
1363 if len(self.ydata)==0:
1342 self.ydata = noisedB[channelIndexList].reshape(-1,1)
1364 self.ydata = noisedB[channelIndexList].reshape(-1,1)
1343 else:
1365 else:
1344 self.ydata = numpy.hstack((self.ydata, noisedB[channelIndexList].reshape(-1,1)))
1366 self.ydata = numpy.hstack((self.ydata, noisedB[channelIndexList].reshape(-1,1)))
1345
1367
1346
1368
1347 axes.pmultilineyaxis(x=self.xdata, y=self.ydata,
1369 axes.pmultilineyaxis(x=self.xdata, y=self.ydata,
1348 xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax,
1370 xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax,
1349 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid",
1371 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid",
1350 XAxisAsTime=True, grid='both'
1372 XAxisAsTime=True, grid='both'
1351 )
1373 )
1352
1374
1353 self.draw()
1375 self.draw()
1354
1376
1355 # if save:
1377 # if save:
1356 #
1378 #
1357 # if figfile == None:
1379 # if figfile == None:
1358 # figfile = self.getFilename(name = self.name)
1380 # figfile = self.getFilename(name = self.name)
1359 #
1381 #
1360 # self.saveFigure(figpath, figfile)
1382 # self.saveFigure(figpath, figfile)
1361
1383
1362 if save:
1384 if save:
1363
1385
1364 self.counter_imagwr += 1
1386 self.counter_imagwr += 1
1365 if (self.counter_imagwr==wr_period):
1387 if (self.counter_imagwr==wr_period):
1366 if figfile == None:
1388 if figfile == None:
1367 figfile = self.getFilename(name = self.name)
1389 figfile = self.getFilename(name = self.name)
1368 self.saveFigure(figpath, figfile)
1390 self.saveFigure(figpath, figfile)
1369
1391
1370 if ftp:
1392 if ftp:
1371 #provisionalmente envia archivos en el formato de la web en tiempo real
1393 #provisionalmente envia archivos en el formato de la web en tiempo real
1372 name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS)
1394 name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS)
1373 path = '%s%03d' %(self.PREFIX, self.id)
1395 path = '%s%03d' %(self.PREFIX, self.id)
1374 ftp_file = os.path.join(path,'ftp','%s.png'%name)
1396 ftp_file = os.path.join(path,'ftp','%s.png'%name)
1375 self.saveFigure(figpath, ftp_file)
1397 self.saveFigure(figpath, ftp_file)
1376 ftp_filename = os.path.join(figpath,ftp_file)
1398 ftp_filename = os.path.join(figpath,ftp_file)
1377 self.sendByFTP_Thread(ftp_filename, server, folder, username, password)
1399 self.sendByFTP_Thread(ftp_filename, server, folder, username, password)
1378 self.counter_imagwr = 0
1400 self.counter_imagwr = 0
1379
1401
1380 self.counter_imagwr = 0
1402 self.counter_imagwr = 0
1381
1403
1382 if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax:
1404 if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax:
1383 self.__isConfig = False
1405 self.__isConfig = False
1384 del self.xdata
1406 del self.xdata
1385 del self.ydata
1407 del self.ydata
1386
1408
1387
1409
1388 class SpectraHeisScope(Figure):
1410 class SpectraHeisScope(Figure):
1389
1411
1390
1412
1391 __isConfig = None
1413 __isConfig = None
1392 __nsubplots = None
1414 __nsubplots = None
1393
1415
1394 WIDTHPROF = None
1416 WIDTHPROF = None
1395 HEIGHTPROF = None
1417 HEIGHTPROF = None
1396 PREFIX = 'spc'
1418 PREFIX = 'spc'
1397
1419
1398 def __init__(self):
1420 def __init__(self):
1399
1421
1400 self.__isConfig = False
1422 self.__isConfig = False
1401 self.__nsubplots = 1
1423 self.__nsubplots = 1
1402
1424
1403 self.WIDTH = 230
1425 self.WIDTH = 230
1404 self.HEIGHT = 250
1426 self.HEIGHT = 250
1405 self.WIDTHPROF = 120
1427 self.WIDTHPROF = 120
1406 self.HEIGHTPROF = 0
1428 self.HEIGHTPROF = 0
1407 self.counter_imagwr = 0
1429 self.counter_imagwr = 0
1408
1430
1409 def getSubplots(self):
1431 def getSubplots(self):
1410
1432
1411 ncol = int(numpy.sqrt(self.nplots)+0.9)
1433 ncol = int(numpy.sqrt(self.nplots)+0.9)
1412 nrow = int(self.nplots*1./ncol + 0.9)
1434 nrow = int(self.nplots*1./ncol + 0.9)
1413
1435
1414 return nrow, ncol
1436 return nrow, ncol
1415
1437
1416 def setup(self, id, nplots, wintitle, show):
1438 def setup(self, id, nplots, wintitle, show):
1417
1439
1418 showprofile = False
1440 showprofile = False
1419 self.__showprofile = showprofile
1441 self.__showprofile = showprofile
1420 self.nplots = nplots
1442 self.nplots = nplots
1421
1443
1422 ncolspan = 1
1444 ncolspan = 1
1423 colspan = 1
1445 colspan = 1
1424 if showprofile:
1446 if showprofile:
1425 ncolspan = 3
1447 ncolspan = 3
1426 colspan = 2
1448 colspan = 2
1427 self.__nsubplots = 2
1449 self.__nsubplots = 2
1428
1450
1429 self.createFigure(id = id,
1451 self.createFigure(id = id,
1430 wintitle = wintitle,
1452 wintitle = wintitle,
1431 widthplot = self.WIDTH + self.WIDTHPROF,
1453 widthplot = self.WIDTH + self.WIDTHPROF,
1432 heightplot = self.HEIGHT + self.HEIGHTPROF,
1454 heightplot = self.HEIGHT + self.HEIGHTPROF,
1433 show = show)
1455 show = show)
1434
1456
1435 nrow, ncol = self.getSubplots()
1457 nrow, ncol = self.getSubplots()
1436
1458
1437 counter = 0
1459 counter = 0
1438 for y in range(nrow):
1460 for y in range(nrow):
1439 for x in range(ncol):
1461 for x in range(ncol):
1440
1462
1441 if counter >= self.nplots:
1463 if counter >= self.nplots:
1442 break
1464 break
1443
1465
1444 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
1466 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
1445
1467
1446 if showprofile:
1468 if showprofile:
1447 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
1469 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
1448
1470
1449 counter += 1
1471 counter += 1
1450
1472
1451
1473
1452 def run(self, dataOut, id, wintitle="", channelList=None,
1474 def run(self, dataOut, id, wintitle="", channelList=None,
1453 xmin=None, xmax=None, ymin=None, ymax=None, save=False,
1475 xmin=None, xmax=None, ymin=None, ymax=None, save=False,
1454 figpath='./', figfile=None, ftp=False, wr_period=1, show=True,
1476 figpath='./', figfile=None, ftp=False, wr_period=1, show=True,
1455 server=None, folder=None, username=None, password=None):
1477 server=None, folder=None, username=None, password=None):
1456
1478
1457 """
1479 """
1458
1480
1459 Input:
1481 Input:
1460 dataOut :
1482 dataOut :
1461 id :
1483 id :
1462 wintitle :
1484 wintitle :
1463 channelList :
1485 channelList :
1464 xmin : None,
1486 xmin : None,
1465 xmax : None,
1487 xmax : None,
1466 ymin : None,
1488 ymin : None,
1467 ymax : None,
1489 ymax : None,
1468 """
1490 """
1469
1491
1470 if dataOut.realtime:
1492 if dataOut.realtime:
1471 if not(isRealtime(utcdatatime = dataOut.utctime)):
1493 if not(isRealtime(utcdatatime = dataOut.utctime)):
1472 print 'Skipping this plot function'
1494 print 'Skipping this plot function'
1473 return
1495 return
1474
1496
1475 if channelList == None:
1497 if channelList == None:
1476 channelIndexList = dataOut.channelIndexList
1498 channelIndexList = dataOut.channelIndexList
1477 else:
1499 else:
1478 channelIndexList = []
1500 channelIndexList = []
1479 for channel in channelList:
1501 for channel in channelList:
1480 if channel not in dataOut.channelList:
1502 if channel not in dataOut.channelList:
1481 raise ValueError, "Channel %d is not in dataOut.channelList"
1503 raise ValueError, "Channel %d is not in dataOut.channelList"
1482 channelIndexList.append(dataOut.channelList.index(channel))
1504 channelIndexList.append(dataOut.channelList.index(channel))
1483
1505
1484 # x = dataOut.heightList
1506 # x = dataOut.heightList
1485 c = 3E8
1507 c = 3E8
1486 deltaHeight = dataOut.heightList[1] - dataOut.heightList[0]
1508 deltaHeight = dataOut.heightList[1] - dataOut.heightList[0]
1487 #deberia cambiar para el caso de 1Mhz y 100KHz
1509 #deberia cambiar para el caso de 1Mhz y 100KHz
1488 x = numpy.arange(-1*dataOut.nHeights/2.,dataOut.nHeights/2.)*(c/(2*deltaHeight*dataOut.nHeights*1000))
1510 x = numpy.arange(-1*dataOut.nHeights/2.,dataOut.nHeights/2.)*(c/(2*deltaHeight*dataOut.nHeights*1000))
1489 #para 1Mhz descomentar la siguiente linea
1511 #para 1Mhz descomentar la siguiente linea
1490 #x= x/(10000.0)
1512 #x= x/(10000.0)
1491 # y = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:])
1513 # y = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:])
1492 # y = y.real
1514 # y = y.real
1493 datadB = 10.*numpy.log10(dataOut.data_spc)
1515 datadB = 10.*numpy.log10(dataOut.data_spc)
1494 y = datadB
1516 y = datadB
1495
1517
1496 #thisDatetime = dataOut.datatime
1518 #thisDatetime = dataOut.datatime
1497 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1])
1519 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1])
1498 title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
1520 title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
1499 xlabel = ""
1521 xlabel = ""
1500 #para 1Mhz descomentar la siguiente linea
1522 #para 1Mhz descomentar la siguiente linea
1501 #xlabel = "Frequency x 10000"
1523 #xlabel = "Frequency x 10000"
1502 ylabel = "Intensity (dB)"
1524 ylabel = "Intensity (dB)"
1503
1525
1504 if not self.__isConfig:
1526 if not self.__isConfig:
1505 nplots = len(channelIndexList)
1527 nplots = len(channelIndexList)
1506
1528
1507 self.setup(id=id,
1529 self.setup(id=id,
1508 nplots=nplots,
1530 nplots=nplots,
1509 wintitle=wintitle,
1531 wintitle=wintitle,
1510 show=show)
1532 show=show)
1511
1533
1512 if xmin == None: xmin = numpy.nanmin(x)
1534 if xmin == None: xmin = numpy.nanmin(x)
1513 if xmax == None: xmax = numpy.nanmax(x)
1535 if xmax == None: xmax = numpy.nanmax(x)
1514 if ymin == None: ymin = numpy.nanmin(y)
1536 if ymin == None: ymin = numpy.nanmin(y)
1515 if ymax == None: ymax = numpy.nanmax(y)
1537 if ymax == None: ymax = numpy.nanmax(y)
1516
1538
1517 self.__isConfig = True
1539 self.__isConfig = True
1518
1540
1519 self.setWinTitle(title)
1541 self.setWinTitle(title)
1520
1542
1521 for i in range(len(self.axesList)):
1543 for i in range(len(self.axesList)):
1522 ychannel = y[i,:]
1544 ychannel = y[i,:]
1523 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
1545 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
1524 title = "Channel %d: %4.2fdB: %s" %(i, numpy.max(ychannel), str_datetime)
1546 title = "Channel %d: %4.2fdB: %s" %(i, numpy.max(ychannel), str_datetime)
1525 axes = self.axesList[i]
1547 axes = self.axesList[i]
1526 axes.pline(x, ychannel,
1548 axes.pline(x, ychannel,
1527 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
1549 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
1528 xlabel=xlabel, ylabel=ylabel, title=title, grid='both')
1550 xlabel=xlabel, ylabel=ylabel, title=title, grid='both')
1529
1551
1530
1552
1531 self.draw()
1553 self.draw()
1532
1554
1533 if save:
1555 if save:
1534 date = thisDatetime.strftime("%Y%m%d_%H%M%S")
1556 date = thisDatetime.strftime("%Y%m%d_%H%M%S")
1535 if figfile == None:
1557 if figfile == None:
1536 figfile = self.getFilename(name = date)
1558 figfile = self.getFilename(name = date)
1537
1559
1538 self.saveFigure(figpath, figfile)
1560 self.saveFigure(figpath, figfile)
1539
1561
1540 self.counter_imagwr += 1
1562 self.counter_imagwr += 1
1541 if (ftp and (self.counter_imagwr==wr_period)):
1563 if (ftp and (self.counter_imagwr==wr_period)):
1542 ftp_filename = os.path.join(figpath,figfile)
1564 ftp_filename = os.path.join(figpath,figfile)
1543 self.sendByFTP_Thread(ftp_filename, server, folder, username, password)
1565 self.sendByFTP_Thread(ftp_filename, server, folder, username, password)
1544 self.counter_imagwr = 0
1566 self.counter_imagwr = 0
1545
1567
1546
1568
1547 class RTIfromSpectraHeis(Figure):
1569 class RTIfromSpectraHeis(Figure):
1548
1570
1549 __isConfig = None
1571 __isConfig = None
1550 __nsubplots = None
1572 __nsubplots = None
1551
1573
1552 PREFIX = 'rtinoise'
1574 PREFIX = 'rtinoise'
1553
1575
1554 def __init__(self):
1576 def __init__(self):
1555
1577
1556 self.timerange = 24*60*60
1578 self.timerange = 24*60*60
1557 self.__isConfig = False
1579 self.__isConfig = False
1558 self.__nsubplots = 1
1580 self.__nsubplots = 1
1559
1581
1560 self.WIDTH = 820
1582 self.WIDTH = 820
1561 self.HEIGHT = 200
1583 self.HEIGHT = 200
1562 self.WIDTHPROF = 120
1584 self.WIDTHPROF = 120
1563 self.HEIGHTPROF = 0
1585 self.HEIGHTPROF = 0
1564 self.counter_imagwr = 0
1586 self.counter_imagwr = 0
1565 self.xdata = None
1587 self.xdata = None
1566 self.ydata = None
1588 self.ydata = None
1567
1589
1568 def getSubplots(self):
1590 def getSubplots(self):
1569
1591
1570 ncol = 1
1592 ncol = 1
1571 nrow = 1
1593 nrow = 1
1572
1594
1573 return nrow, ncol
1595 return nrow, ncol
1574
1596
1575 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1597 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1576
1598
1577 self.__showprofile = showprofile
1599 self.__showprofile = showprofile
1578 self.nplots = nplots
1600 self.nplots = nplots
1579
1601
1580 ncolspan = 7
1602 ncolspan = 7
1581 colspan = 6
1603 colspan = 6
1582 self.__nsubplots = 2
1604 self.__nsubplots = 2
1583
1605
1584 self.createFigure(id = id,
1606 self.createFigure(id = id,
1585 wintitle = wintitle,
1607 wintitle = wintitle,
1586 widthplot = self.WIDTH+self.WIDTHPROF,
1608 widthplot = self.WIDTH+self.WIDTHPROF,
1587 heightplot = self.HEIGHT+self.HEIGHTPROF,
1609 heightplot = self.HEIGHT+self.HEIGHTPROF,
1588 show = show)
1610 show = show)
1589
1611
1590 nrow, ncol = self.getSubplots()
1612 nrow, ncol = self.getSubplots()
1591
1613
1592 self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1)
1614 self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1)
1593
1615
1594
1616
1595 def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True',
1617 def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True',
1596 xmin=None, xmax=None, ymin=None, ymax=None,
1618 xmin=None, xmax=None, ymin=None, ymax=None,
1597 timerange=None,
1619 timerange=None,
1598 save=False, figpath='./', figfile=None, ftp=False, wr_period=1, show=True,
1620 save=False, figpath='./', figfile=None, ftp=False, wr_period=1, show=True,
1599 server=None, folder=None, username=None, password=None):
1621 server=None, folder=None, username=None, password=None):
1600
1622
1601 if channelList == None:
1623 if channelList == None:
1602 channelIndexList = dataOut.channelIndexList
1624 channelIndexList = dataOut.channelIndexList
1603 channelList = dataOut.channelList
1625 channelList = dataOut.channelList
1604 else:
1626 else:
1605 channelIndexList = []
1627 channelIndexList = []
1606 for channel in channelList:
1628 for channel in channelList:
1607 if channel not in dataOut.channelList:
1629 if channel not in dataOut.channelList:
1608 raise ValueError, "Channel %d is not in dataOut.channelList"
1630 raise ValueError, "Channel %d is not in dataOut.channelList"
1609 channelIndexList.append(dataOut.channelList.index(channel))
1631 channelIndexList.append(dataOut.channelList.index(channel))
1610
1632
1611 if timerange != None:
1633 if timerange != None:
1612 self.timerange = timerange
1634 self.timerange = timerange
1613
1635
1614 tmin = None
1636 tmin = None
1615 tmax = None
1637 tmax = None
1616 x = dataOut.getTimeRange()
1638 x = dataOut.getTimeRange()
1617 y = dataOut.getHeiRange()
1639 y = dataOut.getHeiRange()
1618
1640
1619 #factor = 1
1641 #factor = 1
1620 data = dataOut.data_spc#/factor
1642 data = dataOut.data_spc#/factor
1621 data = numpy.average(data,axis=1)
1643 data = numpy.average(data,axis=1)
1622 datadB = 10*numpy.log10(data)
1644 datadB = 10*numpy.log10(data)
1623
1645
1624 # factor = dataOut.normFactor
1646 # factor = dataOut.normFactor
1625 # noise = dataOut.getNoise()/factor
1647 # noise = dataOut.getNoise()/factor
1626 # noisedB = 10*numpy.log10(noise)
1648 # noisedB = 10*numpy.log10(noise)
1627
1649
1628 #thisDatetime = dataOut.datatime
1650 #thisDatetime = dataOut.datatime
1629 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1])
1651 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1])
1630 title = wintitle + " RTI: %s" %(thisDatetime.strftime("%d-%b-%Y"))
1652 title = wintitle + " RTI: %s" %(thisDatetime.strftime("%d-%b-%Y"))
1631 xlabel = "Local Time"
1653 xlabel = "Local Time"
1632 ylabel = "Intensity (dB)"
1654 ylabel = "Intensity (dB)"
1633
1655
1634 if not self.__isConfig:
1656 if not self.__isConfig:
1635
1657
1636 nplots = 1
1658 nplots = 1
1637
1659
1638 self.setup(id=id,
1660 self.setup(id=id,
1639 nplots=nplots,
1661 nplots=nplots,
1640 wintitle=wintitle,
1662 wintitle=wintitle,
1641 showprofile=showprofile,
1663 showprofile=showprofile,
1642 show=show)
1664 show=show)
1643
1665
1644 tmin, tmax = self.getTimeLim(x, xmin, xmax)
1666 tmin, tmax = self.getTimeLim(x, xmin, xmax)
1645 if ymin == None: ymin = numpy.nanmin(datadB)
1667 if ymin == None: ymin = numpy.nanmin(datadB)
1646 if ymax == None: ymax = numpy.nanmax(datadB)
1668 if ymax == None: ymax = numpy.nanmax(datadB)
1647
1669
1648 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1670 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1649 self.__isConfig = True
1671 self.__isConfig = True
1650
1672
1651 self.xdata = numpy.array([])
1673 self.xdata = numpy.array([])
1652 self.ydata = numpy.array([])
1674 self.ydata = numpy.array([])
1653
1675
1654 self.setWinTitle(title)
1676 self.setWinTitle(title)
1655
1677
1656
1678
1657 # title = "RTI %s" %(thisDatetime.strftime("%d-%b-%Y"))
1679 # title = "RTI %s" %(thisDatetime.strftime("%d-%b-%Y"))
1658 title = "RTI - %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
1680 title = "RTI - %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
1659
1681
1660 legendlabels = ["channel %d"%idchannel for idchannel in channelList]
1682 legendlabels = ["channel %d"%idchannel for idchannel in channelList]
1661 axes = self.axesList[0]
1683 axes = self.axesList[0]
1662
1684
1663 self.xdata = numpy.hstack((self.xdata, x[0:1]))
1685 self.xdata = numpy.hstack((self.xdata, x[0:1]))
1664
1686
1665 if len(self.ydata)==0:
1687 if len(self.ydata)==0:
1666 self.ydata = datadB[channelIndexList].reshape(-1,1)
1688 self.ydata = datadB[channelIndexList].reshape(-1,1)
1667 else:
1689 else:
1668 self.ydata = numpy.hstack((self.ydata, datadB[channelIndexList].reshape(-1,1)))
1690 self.ydata = numpy.hstack((self.ydata, datadB[channelIndexList].reshape(-1,1)))
1669
1691
1670
1692
1671 axes.pmultilineyaxis(x=self.xdata, y=self.ydata,
1693 axes.pmultilineyaxis(x=self.xdata, y=self.ydata,
1672 xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax,
1694 xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax,
1673 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='.', markersize=8, linestyle="solid", grid='both',
1695 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='.', markersize=8, linestyle="solid", grid='both',
1674 XAxisAsTime=True
1696 XAxisAsTime=True
1675 )
1697 )
1676
1698
1677 self.draw()
1699 self.draw()
1678
1700
1679 if save:
1701 if save:
1680
1702
1681 if figfile == None:
1703 if figfile == None:
1682 figfile = self.getFilename(name = self.name)
1704 figfile = self.getFilename(name = self.name)
1683
1705
1684 self.saveFigure(figpath, figfile)
1706 self.saveFigure(figpath, figfile)
1685
1707
1686 self.counter_imagwr += 1
1708 self.counter_imagwr += 1
1687 if (ftp and (self.counter_imagwr==wr_period)):
1709 if (ftp and (self.counter_imagwr==wr_period)):
1688 ftp_filename = os.path.join(figpath,figfile)
1710 ftp_filename = os.path.join(figpath,figfile)
1689 self.sendByFTP_Thread(ftp_filename, server, folder, username, password)
1711 self.sendByFTP_Thread(ftp_filename, server, folder, username, password)
1690 self.counter_imagwr = 0
1712 self.counter_imagwr = 0
1691
1713
1692 if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax:
1714 if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax:
1693 self.__isConfig = False
1715 self.__isConfig = False
1694 del self.xdata
1716 del self.xdata
1695 del self.ydata
1717 del self.ydata
1696
1718
1697
1719
1698 No newline at end of file
1720
General Comments 0
You need to be logged in to leave comments. Login now