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