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