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