##// END OF EJS Templates
PlotsListos Fase,Coh, Snr, Dop
J Gomez -
r983:0103550174e2
parent child
Show More
@@ -1,934 +1,957
1
1
2 import os
2 import os
3 import zmq
3 import zmq
4 import time
4 import time
5 import numpy
5 import numpy
6 import datetime
6 import datetime
7 import numpy as np
7 import numpy as np
8 import matplotlib
8 import matplotlib
9 import glob
9 import glob
10 matplotlib.use('TkAgg')
10 matplotlib.use('TkAgg')
11 import matplotlib.pyplot as plt
11 import matplotlib.pyplot as plt
12 from mpl_toolkits.axes_grid1 import make_axes_locatable
12 from mpl_toolkits.axes_grid1 import make_axes_locatable
13 from matplotlib.ticker import FuncFormatter, LinearLocator
13 from matplotlib.ticker import FuncFormatter, LinearLocator
14 from multiprocessing import Process
14 from multiprocessing import Process
15
15
16 from schainpy.model.proc.jroproc_base import Operation
16 from schainpy.model.proc.jroproc_base import Operation
17
17
18 plt.ion()
18 plt.ion()
19
19
20 func = lambda x, pos: ('%s') %(datetime.datetime.fromtimestamp(x).strftime('%H:%M'))
20 func = lambda x, pos: ('%s') %(datetime.datetime.fromtimestamp(x).strftime('%H:%M'))
21
21
22 d1970 = datetime.datetime(1970,1,1)
22 d1970 = datetime.datetime(1970,1,1)
23
23
24 class PlotData(Operation, Process):
24 class PlotData(Operation, Process):
25
25
26 CODE = 'Figure'
26 CODE = 'Figure'
27 colormap = 'jro'
27 colormap = 'jro'
28 CONFLATE = False
28 CONFLATE = False
29 __MAXNUMX = 80
29 __MAXNUMX = 80
30 __missing = 1E30
30 __missing = 1E30
31
31
32 def __init__(self, **kwargs):
32 def __init__(self, **kwargs):
33
33
34 Operation.__init__(self, plot=True, **kwargs)
34 Operation.__init__(self, plot=True, **kwargs)
35 Process.__init__(self)
35 Process.__init__(self)
36 self.kwargs['code'] = self.CODE
36 self.kwargs['code'] = self.CODE
37 self.mp = False
37 self.mp = False
38 self.dataOut = None
38 self.dataOut = None
39 self.isConfig = False
39 self.isConfig = False
40 self.figure = None
40 self.figure = None
41 self.axes = []
41 self.axes = []
42 self.localtime = kwargs.pop('localtime', True)
42 self.localtime = kwargs.pop('localtime', True)
43 self.show = kwargs.get('show', True)
43 self.show = kwargs.get('show', True)
44 self.save = kwargs.get('save', False)
44 self.save = kwargs.get('save', False)
45 self.colormap = kwargs.get('colormap', self.colormap)
45 self.colormap = kwargs.get('colormap', self.colormap)
46 self.colormap_coh = kwargs.get('colormap_coh', 'jet')
46 self.colormap_coh = kwargs.get('colormap_coh', 'jet')
47 self.colormap_phase = kwargs.get('colormap_phase', 'RdBu_r')
47 self.colormap_phase = kwargs.get('colormap_phase', 'RdBu_r')
48 self.showprofile = kwargs.get('showprofile', True)
48 self.showprofile = kwargs.get('showprofile', True)
49 self.title = kwargs.get('wintitle', '')
49 self.title = kwargs.get('wintitle', '')
50 self.xaxis = kwargs.get('xaxis', 'frequency')
50 self.xaxis = kwargs.get('xaxis', 'frequency')
51 self.zmin = kwargs.get('zmin', None)
51 self.zmin = kwargs.get('zmin', None)
52 self.zmax = kwargs.get('zmax', None)
52 self.zmax = kwargs.get('zmax', None)
53 self.xmin = kwargs.get('xmin', None)
53 self.xmin = kwargs.get('xmin', None)
54 self.xmax = kwargs.get('xmax', None)
54 self.xmax = kwargs.get('xmax', None)
55 self.xrange = kwargs.get('xrange', 24)
55 self.xrange = kwargs.get('xrange', 24)
56 self.ymin = kwargs.get('ymin', None)
56 self.ymin = kwargs.get('ymin', None)
57 self.ymax = kwargs.get('ymax', None)
57 self.ymax = kwargs.get('ymax', None)
58 self.__MAXNUMY = kwargs.get('decimation', 80)
58 self.__MAXNUMY = kwargs.get('decimation', 80)
59 self.throttle_value = 5
59 self.throttle_value = 5
60 self.times = []
60 self.times = []
61 #self.interactive = self.kwargs['parent']
61 #self.interactive = self.kwargs['parent']
62
62
63 '''
63 '''
64 this new parameter is created to plot data from varius channels at different figures
64 this new parameter is created to plot data from varius channels at different figures
65 1. crear una lista de figuras donde se puedan plotear las figuras,
65 1. crear una lista de figuras donde se puedan plotear las figuras,
66 2. dar las opciones de configuracion a cada figura, estas opciones son iguales para ambas figuras
66 2. dar las opciones de configuracion a cada figura, estas opciones son iguales para ambas figuras
67 3. probar?
67 3. probar?
68 '''
68 '''
69 self.ind_plt_ch = kwargs.get('ind_plt_ch', False)
69 self.ind_plt_ch = kwargs.get('ind_plt_ch', False)
70 self.figurelist = None
70 self.figurelist = None
71
71
72
72
73 def fill_gaps(self, x_buffer, y_buffer, z_buffer):
73 def fill_gaps(self, x_buffer, y_buffer, z_buffer):
74
74
75 if x_buffer.shape[0] < 2:
75 if x_buffer.shape[0] < 2:
76 return x_buffer, y_buffer, z_buffer
76 return x_buffer, y_buffer, z_buffer
77
77
78 deltas = x_buffer[1:] - x_buffer[0:-1]
78 deltas = x_buffer[1:] - x_buffer[0:-1]
79 x_median = np.median(deltas)
79 x_median = np.median(deltas)
80
80
81 index = np.where(deltas > 5*x_median)
81 index = np.where(deltas > 5*x_median)
82
82
83 if len(index[0]) != 0:
83 if len(index[0]) != 0:
84 z_buffer[::, index[0], ::] = self.__missing
84 z_buffer[::, index[0], ::] = self.__missing
85 z_buffer = np.ma.masked_inside(z_buffer,
85 z_buffer = np.ma.masked_inside(z_buffer,
86 0.99*self.__missing,
86 0.99*self.__missing,
87 1.01*self.__missing)
87 1.01*self.__missing)
88
88
89 return x_buffer, y_buffer, z_buffer
89 return x_buffer, y_buffer, z_buffer
90
90
91 def decimate(self):
91 def decimate(self):
92
92
93 # dx = int(len(self.x)/self.__MAXNUMX) + 1
93 # dx = int(len(self.x)/self.__MAXNUMX) + 1
94 dy = int(len(self.y)/self.__MAXNUMY) + 1
94 dy = int(len(self.y)/self.__MAXNUMY) + 1
95
95
96 # x = self.x[::dx]
96 # x = self.x[::dx]
97 x = self.x
97 x = self.x
98 y = self.y[::dy]
98 y = self.y[::dy]
99 z = self.z[::, ::, ::dy]
99 z = self.z[::, ::, ::dy]
100
100
101 return x, y, z
101 return x, y, z
102
102
103 '''
103 '''
104 JM:
104 JM:
105 elimana las otras imagenes generadas debido a que lso workers no llegan en orden y le pueden
105 elimana las otras imagenes generadas debido a que lso workers no llegan en orden y le pueden
106 poner otro tiempo a la figura q no necesariamente es el ultimo.
106 poner otro tiempo a la figura q no necesariamente es el ultimo.
107 Solo se realiza cuando termina la imagen.
107 Solo se realiza cuando termina la imagen.
108 Problemas:
108 Problemas:
109 -Aun no encuentro.
109
110 File "/home/ci-81/workspace/schainv2.3/schainpy/model/graphics/jroplot_data.py", line 145, in __plot
111 for n, eachfigure in enumerate(self.figurelist):
112 TypeError: 'NoneType' object is not iterable
113
110 '''
114 '''
111 def deleteanotherfiles(self):
115 def deleteanotherfiles(self):
112 figurenames=[]
116 figurenames=[]
113 for n, eachfigure in enumerate(self.figurelist):
117 if self.figurelist != None:
114 #add specific name for each channel in channelList
118 for n, eachfigure in enumerate(self.figurelist):
115 ghostfigname = os.path.join(self.save, '{}_{}_{}'.format(self.titles[n].replace(' ',''),self.CODE,
119 #add specific name for each channel in channelList
116 datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d')))
120 ghostfigname = os.path.join(self.save, '{}_{}_{}'.format(self.titles[n].replace(' ',''),self.CODE,
117 figname = os.path.join(self.save, '{}_{}_{}.png'.format(self.titles[n].replace(' ',''),self.CODE,
121 datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d')))
118 datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S')))
122 figname = os.path.join(self.save, '{}_{}_{}.png'.format(self.titles[n].replace(' ',''),self.CODE,
123 datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S')))
119
124
125 for ghostfigure in glob.glob(ghostfigname+'*'): #ghostfigure will adopt all posible names of figures
126 if ghostfigure != figname:
127 os.remove(ghostfigure)
128 print 'Removing GhostFigures:' , figname
129 else :
130 '''Erasing ghost images for just on******************'''
131 ghostfigname = os.path.join(self.save, '{}_{}'.format(self.CODE,datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d')))
132 figname = os.path.join(self.save, '{}_{}.png'.format(self.CODE,datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S')))
120 for ghostfigure in glob.glob(ghostfigname+'*'): #ghostfigure will adopt all posible names of figures
133 for ghostfigure in glob.glob(ghostfigname+'*'): #ghostfigure will adopt all posible names of figures
121 if ghostfigure != figname:
134 if ghostfigure != figname:
122 os.remove(ghostfigure)
135 os.remove(ghostfigure)
123 print 'Removing GhostFigures:' , figname
136 print 'Removing GhostFigures:' , figname
124
137
125 def __plot(self):
138 def __plot(self):
126
139
127 print 'plotting...{}'.format(self.CODE)
140 print 'plotting...{}'.format(self.CODE)
128 if self.ind_plt_ch is False : #standard
141 if self.ind_plt_ch is False : #standard
129 if self.show:
142 if self.show:
130 self.figure.show()
143 self.figure.show()
131 self.plot()
144 self.plot()
132 plt.tight_layout()
145 plt.tight_layout()
133 self.figure.canvas.manager.set_window_title('{} {} - {}'.format(self.title, self.CODE.upper(),
146 self.figure.canvas.manager.set_window_title('{} {} - {}'.format(self.title, self.CODE.upper(),
134 datetime.datetime.fromtimestamp(self.max_time).strftime('%Y/%m/%d')))
147 datetime.datetime.fromtimestamp(self.max_time).strftime('%Y/%m/%d')))
135 else :
148 else :
149 print 'len(self.figurelist): ',len(self.figurelist)
136 for n, eachfigure in enumerate(self.figurelist):
150 for n, eachfigure in enumerate(self.figurelist):
137 if self.show:
151 if self.show:
138 eachfigure.show()
152 eachfigure.show()
139
153
140 self.plot() # ok? como elijo que figura?
154 self.plot() # ok? como elijo que figura?
141 #eachfigure.subplots_adjust(left=0.2)
155 #eachfigure.subplots_adjust(left=0.2)
142 #eachfigure.subplots_adjuccst(right=0.2)
156 #eachfigure.subplots_adjuccst(right=0.2)
143 eachfigure.tight_layout() # ajuste de cada subplot
157 eachfigure.tight_layout() # ajuste de cada subplot
144 eachfigure.canvas.manager.set_window_title('{} {} - {}'.format(self.title[n], self.CODE.upper(),
158 eachfigure.canvas.manager.set_window_title('{} {} - {}'.format(self.title[n], self.CODE.upper(),
145 datetime.datetime.fromtimestamp(self.max_time).strftime('%Y/%m/%d')))
159 datetime.datetime.fromtimestamp(self.max_time).strftime('%Y/%m/%d')))
146
160
147 # if self.save:
161 # if self.save:
148 # if self.ind_plt_ch is False : #standard
162 # if self.ind_plt_ch is False : #standard
149 # figname = os.path.join(self.save, '{}_{}.png'.format(self.CODE,
163 # figname = os.path.join(self.save, '{}_{}.png'.format(self.CODE,
150 # datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S')))
164 # datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S')))
151 # print 'Saving figure: {}'.format(figname)
165 # print 'Saving figure: {}'.format(figname)
152 # self.figure.savefig(figname)
166 # self.figure.savefig(figname)
153 # else :
167 # else :
154 # for n, eachfigure in enumerate(self.figurelist):
168 # for n, eachfigure in enumerate(self.figurelist):
155 # #add specific name for each channel in channelList
169 # #add specific name for each channel in channelList
156 # figname = os.path.join(self.save, '{}_{}_{}.png'.format(self.titles[n],self.CODE,
170 # figname = os.path.join(self.save, '{}_{}_{}.png'.format(self.titles[n],self.CODE,
157 # datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S')))
171 # datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S')))
158 #
172 #
159 # print 'Saving figure: {}'.format(figname)
173 # print 'Saving figure: {}'.format(figname)
160 # eachfigure.savefig(figname)
174 # eachfigure.savefig(figname)
161
175
162 if self.ind_plt_ch is False :
176 if self.ind_plt_ch is False :
163 self.figure.canvas.draw()
177 self.figure.canvas.draw()
164 else :
178 else :
165 for eachfigure in self.figurelist:
179 for eachfigure in self.figurelist:
166 eachfigure.canvas.draw()
180 eachfigure.canvas.draw()
167
181
168 if self.save:
182 if self.save:
169 if self.ind_plt_ch is False : #standard
183 if self.ind_plt_ch is False : #standard
170 figname = os.path.join(self.save, '{}_{}.png'.format(self.CODE,
184 figname = os.path.join(self.save, '{}_{}.png'.format(self.CODE,
171 datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S')))
185 datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S')))
172 print 'Saving figure: {}'.format(figname)
186 print 'Saving figure: {}'.format(figname)
173 self.figure.savefig(figname)
187 self.figure.savefig(figname)
174 else :
188 else :
175 for n, eachfigure in enumerate(self.figurelist):
189 for n, eachfigure in enumerate(self.figurelist):
176 #add specific name for each channel in channelList
190 #add specific name for each channel in channelList
177 figname = os.path.join(self.save, '{}_{}_{}.png'.format(self.titles[n].replace(' ',''),self.CODE,
191 figname = os.path.join(self.save, '{}_{}_{}.png'.format(self.titles[n].replace(' ',''),self.CODE,
178 datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S')))
192 datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S')))
179
193
180 print 'Saving figure: {}'.format(figname)
194 print 'Saving figure: {}'.format(figname)
181 eachfigure.savefig(figname)
195 eachfigure.savefig(figname)
182
196
183
197
184 def plot(self):
198 def plot(self):
185
199
186 print 'plotting...{}'.format(self.CODE.upper())
200 print 'plotting...{}'.format(self.CODE.upper())
187 return
201 return
188
202
189 def run(self):
203 def run(self):
190
204
191 print '[Starting] {}'.format(self.name)
205 print '[Starting] {}'.format(self.name)
192
206
193 context = zmq.Context()
207 context = zmq.Context()
194 receiver = context.socket(zmq.SUB)
208 receiver = context.socket(zmq.SUB)
195 receiver.setsockopt(zmq.SUBSCRIBE, '')
209 receiver.setsockopt(zmq.SUBSCRIBE, '')
196 receiver.setsockopt(zmq.CONFLATE, self.CONFLATE)
210 receiver.setsockopt(zmq.CONFLATE, self.CONFLATE)
197
211
198 if 'server' in self.kwargs['parent']:
212 if 'server' in self.kwargs['parent']:
199 receiver.connect('ipc:///tmp/{}.plots'.format(self.kwargs['parent']['server']))
213 receiver.connect('ipc:///tmp/{}.plots'.format(self.kwargs['parent']['server']))
200 else:
214 else:
201 receiver.connect("ipc:///tmp/zmq.plots")
215 receiver.connect("ipc:///tmp/zmq.plots")
202
216
203 seconds_passed = 0
217 seconds_passed = 0
204
218
205 while True:
219 while True:
206 try:
220 try:
207 self.data = receiver.recv_pyobj(flags=zmq.NOBLOCK)#flags=zmq.NOBLOCK
221 self.data = receiver.recv_pyobj(flags=zmq.NOBLOCK)#flags=zmq.NOBLOCK
208 self.started = self.data['STARTED']
222 self.started = self.data['STARTED']
209 self.dataOut = self.data['dataOut']
223 self.dataOut = self.data['dataOut']
210
224
211 if (len(self.times) < len(self.data['times']) and not self.started and self.data['ENDED']):
225 if (len(self.times) < len(self.data['times']) and not self.started and self.data['ENDED']):
212 continue
226 continue
213
227
214 self.times = self.data['times']
228 self.times = self.data['times']
215 self.times.sort()
229 self.times.sort()
216 self.throttle_value = self.data['throttle']
230 self.throttle_value = self.data['throttle']
217 self.min_time = self.times[0]
231 self.min_time = self.times[0]
218 self.max_time = self.times[-1]
232 self.max_time = self.times[-1]
219
233
220 if self.isConfig is False:
234 if self.isConfig is False:
221 print 'setting up'
235 print 'setting up'
222 self.setup()
236 self.setup()
223 self.isConfig = True
237 self.isConfig = True
224 self.__plot()
238 self.__plot()
225
239
226 if self.data['ENDED'] is True:
240 if self.data['ENDED'] is True:
227 print '********GRAPHIC ENDED********'
241 print '********GRAPHIC ENDED********'
228 self.ended = True
242 self.ended = True
229 self.isConfig = False
243 self.isConfig = False
230 self.__plot()
244 self.__plot()
245 #TODO : AUN NO FUNCIONA PARA COHERENCIA.
231 self.deleteanotherfiles() #CLPDG
246 self.deleteanotherfiles() #CLPDG
232 elif seconds_passed >= self.data['throttle']:
247 elif seconds_passed >= self.data['throttle']:
233 print 'passed', seconds_passed
248 print 'passed', seconds_passed
234 self.__plot()
249 self.__plot()
235 seconds_passed = 0
250 seconds_passed = 0
236
251
237 except zmq.Again as e:
252 except zmq.Again as e:
238 print 'Waiting for data...'
253 print 'Waiting for data...'
239 plt.pause(2)
254 plt.pause(2)
240 seconds_passed += 2
255 seconds_passed += 2
241
256
242 def close(self):
257 def close(self):
243 if self.dataOut:
258 if self.dataOut:
244 self.__plot()
259 self.__plot()
245
260
246
261
247 class PlotSpectraData(PlotData):
262 class PlotSpectraData(PlotData):
248
263
249 CODE = 'spc'
264 CODE = 'spc'
250 colormap = 'jro'
265 colormap = 'jro'
251 CONFLATE = False
266 CONFLATE = False
252
267
253 def setup(self):
268 def setup(self):
254
269
255 ncolspan = 1
270 ncolspan = 1
256 colspan = 1
271 colspan = 1
257 self.ncols = int(numpy.sqrt(self.dataOut.nChannels)+0.9)
272 self.ncols = int(numpy.sqrt(self.dataOut.nChannels)+0.9)
258 self.nrows = int(self.dataOut.nChannels*1./self.ncols + 0.9)
273 self.nrows = int(self.dataOut.nChannels*1./self.ncols + 0.9)
259 self.width = 3.6*self.ncols
274 self.width = 3.6*self.ncols
260 self.height = 3.2*self.nrows
275 self.height = 3.2*self.nrows
261 if self.showprofile:
276 if self.showprofile:
262 ncolspan = 3
277 ncolspan = 3
263 colspan = 2
278 colspan = 2
264 self.width += 1.2*self.ncols
279 self.width += 1.2*self.ncols
265
280
266 self.ylabel = 'Range [Km]'
281 self.ylabel = 'Range [Km]'
267 self.titles = ['Channel {}'.format(x) for x in self.dataOut.channelList]
282 self.titles = ['Channel {}'.format(x) for x in self.dataOut.channelList]
268
283
269 if self.figure is None:
284 if self.figure is None:
270 self.figure = plt.figure(figsize=(self.width, self.height),
285 self.figure = plt.figure(figsize=(self.width, self.height),
271 edgecolor='k',
286 edgecolor='k',
272 facecolor='w')
287 facecolor='w')
273 else:
288 else:
274 self.figure.clf()
289 self.figure.clf()
275
290
276 n = 0
291 n = 0
277 for y in range(self.nrows):
292 for y in range(self.nrows):
278 for x in range(self.ncols):
293 for x in range(self.ncols):
279 if n >= self.dataOut.nChannels:
294 if n >= self.dataOut.nChannels:
280 break
295 break
281 ax = plt.subplot2grid((self.nrows, self.ncols*ncolspan), (y, x*ncolspan), 1, colspan)
296 ax = plt.subplot2grid((self.nrows, self.ncols*ncolspan), (y, x*ncolspan), 1, colspan)
282 if self.showprofile:
297 if self.showprofile:
283 ax.ax_profile = plt.subplot2grid((self.nrows, self.ncols*ncolspan), (y, x*ncolspan+colspan), 1, 1)
298 ax.ax_profile = plt.subplot2grid((self.nrows, self.ncols*ncolspan), (y, x*ncolspan+colspan), 1, 1)
284
299
285 ax.firsttime = True
300 ax.firsttime = True
286 self.axes.append(ax)
301 self.axes.append(ax)
287 n += 1
302 n += 1
288
303
289 def plot(self):
304 def plot(self):
290
305
291 if self.xaxis == "frequency":
306 if self.xaxis == "frequency":
292 x = self.dataOut.getFreqRange(1)/1000.
307 x = self.dataOut.getFreqRange(1)/1000.
293 xlabel = "Frequency (kHz)"
308 xlabel = "Frequency (kHz)"
294 elif self.xaxis == "time":
309 elif self.xaxis == "time":
295 x = self.dataOut.getAcfRange(1)
310 x = self.dataOut.getAcfRange(1)
296 xlabel = "Time (ms)"
311 xlabel = "Time (ms)"
297 else:
312 else:
298 x = self.dataOut.getVelRange(1)
313 x = self.dataOut.getVelRange(1)
299 xlabel = "Velocity (m/s)"
314 xlabel = "Velocity (m/s)"
300
315
301 y = self.dataOut.getHeiRange()
316 y = self.dataOut.getHeiRange()
302 z = self.data[self.CODE]
317 z = self.data[self.CODE]
303
318
304 for n, ax in enumerate(self.axes):
319 for n, ax in enumerate(self.axes):
305 if ax.firsttime:
320 if ax.firsttime:
306 self.xmax = self.xmax if self.xmax else np.nanmax(x)
321 self.xmax = self.xmax if self.xmax else np.nanmax(x)
307 self.xmin = self.xmin if self.xmin else -self.xmax
322 self.xmin = self.xmin if self.xmin else -self.xmax
308 self.ymin = self.ymin if self.ymin else np.nanmin(y)
323 self.ymin = self.ymin if self.ymin else np.nanmin(y)
309 self.ymax = self.ymax if self.ymax else np.nanmax(y)
324 self.ymax = self.ymax if self.ymax else np.nanmax(y)
310 self.zmin = self.zmin if self.zmin else np.nanmin(z)
325 self.zmin = self.zmin if self.zmin else np.nanmin(z)
311 self.zmax = self.zmax if self.zmax else np.nanmax(z)
326 self.zmax = self.zmax if self.zmax else np.nanmax(z)
312 ax.plot = ax.pcolormesh(x, y, z[n].T,
327 ax.plot = ax.pcolormesh(x, y, z[n].T,
313 vmin=self.zmin,
328 vmin=self.zmin,
314 vmax=self.zmax,
329 vmax=self.zmax,
315 cmap=plt.get_cmap(self.colormap)
330 cmap=plt.get_cmap(self.colormap)
316 )
331 )
317 divider = make_axes_locatable(ax)
332 divider = make_axes_locatable(ax)
318 cax = divider.new_horizontal(size='3%', pad=0.05)
333 cax = divider.new_horizontal(size='3%', pad=0.05)
319 self.figure.add_axes(cax)
334 self.figure.add_axes(cax)
320 plt.colorbar(ax.plot, cax)
335 plt.colorbar(ax.plot, cax)
321
336
322 ax.set_xlim(self.xmin, self.xmax)
337 ax.set_xlim(self.xmin, self.xmax)
323 ax.set_ylim(self.ymin, self.ymax)
338 ax.set_ylim(self.ymin, self.ymax)
324
339
325 ax.set_ylabel(self.ylabel)
340 ax.set_ylabel(self.ylabel)
326 ax.set_xlabel(xlabel)
341 ax.set_xlabel(xlabel)
327
342
328 ax.firsttime = False
343 ax.firsttime = False
329
344
330 if self.showprofile:
345 if self.showprofile:
331 ax.plot_profile= ax.ax_profile.plot(self.data['rti'][self.max_time][n], y)[0]
346 ax.plot_profile= ax.ax_profile.plot(self.data['rti'][self.max_time][n], y)[0]
332 ax.ax_profile.set_xlim(self.zmin, self.zmax)
347 ax.ax_profile.set_xlim(self.zmin, self.zmax)
333 ax.ax_profile.set_ylim(self.ymin, self.ymax)
348 ax.ax_profile.set_ylim(self.ymin, self.ymax)
334 ax.ax_profile.set_xlabel('dB')
349 ax.ax_profile.set_xlabel('dB')
335 ax.ax_profile.grid(b=True, axis='x')
350 ax.ax_profile.grid(b=True, axis='x')
336 ax.plot_noise = ax.ax_profile.plot(numpy.repeat(self.data['noise'][self.max_time][n], len(y)), y,
351 ax.plot_noise = ax.ax_profile.plot(numpy.repeat(self.data['noise'][self.max_time][n], len(y)), y,
337 color="k", linestyle="dashed", lw=2)[0]
352 color="k", linestyle="dashed", lw=2)[0]
338 [tick.set_visible(False) for tick in ax.ax_profile.get_yticklabels()]
353 [tick.set_visible(False) for tick in ax.ax_profile.get_yticklabels()]
339 else:
354 else:
340 ax.plot.set_array(z[n].T.ravel())
355 ax.plot.set_array(z[n].T.ravel())
341 if self.showprofile:
356 if self.showprofile:
342 ax.plot_profile.set_data(self.data['rti'][self.max_time][n], y)
357 ax.plot_profile.set_data(self.data['rti'][self.max_time][n], y)
343 ax.plot_noise.set_data(numpy.repeat(self.data['noise'][self.max_time][n], len(y)), y)
358 ax.plot_noise.set_data(numpy.repeat(self.data['noise'][self.max_time][n], len(y)), y)
344
359
345 ax.set_title('{} - Noise: {:.2f} dB'.format(self.titles[n], self.data['noise'][self.max_time][n]),
360 ax.set_title('{} - Noise: {:.2f} dB'.format(self.titles[n], self.data['noise'][self.max_time][n]),
346 size=8)
361 size=8)
347 self.saveTime = self.max_time
362 self.saveTime = self.max_time
348
363
349
364
350 class PlotCrossSpectraData(PlotData):
365 class PlotCrossSpectraData(PlotData):
351
366
352 CODE = 'cspc'
367 CODE = 'cspc'
353 zmin_coh = None
368 zmin_coh = None
354 zmax_coh = None
369 zmax_coh = None
355 zmin_phase = None
370 zmin_phase = None
356 zmax_phase = None
371 zmax_phase = None
357 CONFLATE = False
372 CONFLATE = False
358
373
359 def setup(self):
374 def setup(self):
360
375
361 ncolspan = 1
376 ncolspan = 1
362 colspan = 1
377 colspan = 1
363 self.ncols = 2
378 self.ncols = 2
364 self.nrows = self.dataOut.nPairs
379 self.nrows = self.dataOut.nPairs
365 self.width = 3.6*self.ncols
380 self.width = 3.6*self.ncols
366 self.height = 3.2*self.nrows
381 self.height = 3.2*self.nrows
367
382
368 self.ylabel = 'Range [Km]'
383 self.ylabel = 'Range [Km]'
369 self.titles = ['Channel {}'.format(x) for x in self.dataOut.channelList]
384 self.titles = ['Channel {}'.format(x) for x in self.dataOut.channelList]
370
385
371 if self.figure is None:
386 if self.figure is None:
372 self.figure = plt.figure(figsize=(self.width, self.height),
387 self.figure = plt.figure(figsize=(self.width, self.height),
373 edgecolor='k',
388 edgecolor='k',
374 facecolor='w')
389 facecolor='w')
375 else:
390 else:
376 self.figure.clf()
391 self.figure.clf()
377
392
378 for y in range(self.nrows):
393 for y in range(self.nrows):
379 for x in range(self.ncols):
394 for x in range(self.ncols):
380 ax = plt.subplot2grid((self.nrows, self.ncols), (y, x), 1, 1)
395 ax = plt.subplot2grid((self.nrows, self.ncols), (y, x), 1, 1)
381 ax.firsttime = True
396 ax.firsttime = True
382 self.axes.append(ax)
397 self.axes.append(ax)
383
398
384 def plot(self):
399 def plot(self):
385
400
386 if self.xaxis == "frequency":
401 if self.xaxis == "frequency":
387 x = self.dataOut.getFreqRange(1)/1000.
402 x = self.dataOut.getFreqRange(1)/1000.
388 xlabel = "Frequency (kHz)"
403 xlabel = "Frequency (kHz)"
389 elif self.xaxis == "time":
404 elif self.xaxis == "time":
390 x = self.dataOut.getAcfRange(1)
405 x = self.dataOut.getAcfRange(1)
391 xlabel = "Time (ms)"
406 xlabel = "Time (ms)"
392 else:
407 else:
393 x = self.dataOut.getVelRange(1)
408 x = self.dataOut.getVelRange(1)
394 xlabel = "Velocity (m/s)"
409 xlabel = "Velocity (m/s)"
395
410
396 y = self.dataOut.getHeiRange()
411 y = self.dataOut.getHeiRange()
397 z_coh = self.data['cspc_coh']
412 z_coh = self.data['cspc_coh']
398 z_phase = self.data['cspc_phase']
413 z_phase = self.data['cspc_phase']
399
414
400 for n in range(self.nrows):
415 for n in range(self.nrows):
401 ax = self.axes[2*n]
416 ax = self.axes[2*n]
402 ax1 = self.axes[2*n+1]
417 ax1 = self.axes[2*n+1]
403 if ax.firsttime:
418 if ax.firsttime:
404 self.xmax = self.xmax if self.xmax else np.nanmax(x)
419 self.xmax = self.xmax if self.xmax else np.nanmax(x)
405 self.xmin = self.xmin if self.xmin else -self.xmax
420 self.xmin = self.xmin if self.xmin else -self.xmax
406 self.ymin = self.ymin if self.ymin else np.nanmin(y)
421 self.ymin = self.ymin if self.ymin else np.nanmin(y)
407 self.ymax = self.ymax if self.ymax else np.nanmax(y)
422 self.ymax = self.ymax if self.ymax else np.nanmax(y)
408 self.zmin_coh = self.zmin_coh if self.zmin_coh else 0.0
423 self.zmin_coh = self.zmin_coh if self.zmin_coh else 0.0
409 self.zmax_coh = self.zmax_coh if self.zmax_coh else 1.0
424 self.zmax_coh = self.zmax_coh if self.zmax_coh else 1.0
410 self.zmin_phase = self.zmin_phase if self.zmin_phase else -180
425 self.zmin_phase = self.zmin_phase if self.zmin_phase else -180
411 self.zmax_phase = self.zmax_phase if self.zmax_phase else 180
426 self.zmax_phase = self.zmax_phase if self.zmax_phase else 180
412
427
413 ax.plot = ax.pcolormesh(x, y, z_coh[n].T,
428 ax.plot = ax.pcolormesh(x, y, z_coh[n].T,
414 vmin=self.zmin_coh,
429 vmin=self.zmin_coh,
415 vmax=self.zmax_coh,
430 vmax=self.zmax_coh,
416 cmap=plt.get_cmap(self.colormap_coh)
431 cmap=plt.get_cmap(self.colormap_coh)
417 )
432 )
418 divider = make_axes_locatable(ax)
433 divider = make_axes_locatable(ax)
419 cax = divider.new_horizontal(size='3%', pad=0.05)
434 cax = divider.new_horizontal(size='3%', pad=0.05)
420 self.figure.add_axes(cax)
435 self.figure.add_axes(cax)
421 plt.colorbar(ax.plot, cax)
436 plt.colorbar(ax.plot, cax)
422
437
423 ax.set_xlim(self.xmin, self.xmax)
438 ax.set_xlim(self.xmin, self.xmax)
424 ax.set_ylim(self.ymin, self.ymax)
439 ax.set_ylim(self.ymin, self.ymax)
425
440
426 ax.set_ylabel(self.ylabel)
441 ax.set_ylabel(self.ylabel)
427 ax.set_xlabel(xlabel)
442 ax.set_xlabel(xlabel)
428 ax.firsttime = False
443 ax.firsttime = False
429
444
430 ax1.plot = ax1.pcolormesh(x, y, z_phase[n].T,
445 ax1.plot = ax1.pcolormesh(x, y, z_phase[n].T,
431 vmin=self.zmin_phase,
446 vmin=self.zmin_phase,
432 vmax=self.zmax_phase,
447 vmax=self.zmax_phase,
433 cmap=plt.get_cmap(self.colormap_phase)
448 cmap=plt.get_cmap(self.colormap_phase)
434 )
449 )
435 divider = make_axes_locatable(ax1)
450 divider = make_axes_locatable(ax1)
436 cax = divider.new_horizontal(size='3%', pad=0.05)
451 cax = divider.new_horizontal(size='3%', pad=0.05)
437 self.figure.add_axes(cax)
452 self.figure.add_axes(cax)
438 plt.colorbar(ax1.plot, cax)
453 plt.colorbar(ax1.plot, cax)
439
454
440 ax1.set_xlim(self.xmin, self.xmax)
455 ax1.set_xlim(self.xmin, self.xmax)
441 ax1.set_ylim(self.ymin, self.ymax)
456 ax1.set_ylim(self.ymin, self.ymax)
442
457
443 ax1.set_ylabel(self.ylabel)
458 ax1.set_ylabel(self.ylabel)
444 ax1.set_xlabel(xlabel)
459 ax1.set_xlabel(xlabel)
445 ax1.firsttime = False
460 ax1.firsttime = False
446 else:
461 else:
447 ax.plot.set_array(z_coh[n].T.ravel())
462 ax.plot.set_array(z_coh[n].T.ravel())
448 ax1.plot.set_array(z_phase[n].T.ravel())
463 ax1.plot.set_array(z_phase[n].T.ravel())
449
464
450 ax.set_title('Coherence Ch{} * Ch{}'.format(self.dataOut.pairsList[n][0], self.dataOut.pairsList[n][1]), size=8)
465 ax.set_title('Coherence Ch{} * Ch{}'.format(self.dataOut.pairsList[n][0], self.dataOut.pairsList[n][1]), size=8)
451 ax1.set_title('Phase Ch{} * Ch{}'.format(self.dataOut.pairsList[n][0], self.dataOut.pairsList[n][1]), size=8)
466 ax1.set_title('Phase Ch{} * Ch{}'.format(self.dataOut.pairsList[n][0], self.dataOut.pairsList[n][1]), size=8)
452 self.saveTime = self.max_time
467 self.saveTime = self.max_time
453
468
454
469
455 class PlotSpectraMeanData(PlotSpectraData):
470 class PlotSpectraMeanData(PlotSpectraData):
456
471
457 CODE = 'spc_mean'
472 CODE = 'spc_mean'
458 colormap = 'jet'
473 colormap = 'jet'
459
474
460 def plot(self):
475 def plot(self):
461
476
462 if self.xaxis == "frequency":
477 if self.xaxis == "frequency":
463 x = self.dataOut.getFreqRange(1)/1000.
478 x = self.dataOut.getFreqRange(1)/1000.
464 xlabel = "Frequency (kHz)"
479 xlabel = "Frequency (kHz)"
465 elif self.xaxis == "time":
480 elif self.xaxis == "time":
466 x = self.dataOut.getAcfRange(1)
481 x = self.dataOut.getAcfRange(1)
467 xlabel = "Time (ms)"
482 xlabel = "Time (ms)"
468 else:
483 else:
469 x = self.dataOut.getVelRange(1)
484 x = self.dataOut.getVelRange(1)
470 xlabel = "Velocity (m/s)"
485 xlabel = "Velocity (m/s)"
471
486
472 y = self.dataOut.getHeiRange()
487 y = self.dataOut.getHeiRange()
473 z = self.data['spc']
488 z = self.data['spc']
474 mean = self.data['mean'][self.max_time]
489 mean = self.data['mean'][self.max_time]
475
490
476 for n, ax in enumerate(self.axes):
491 for n, ax in enumerate(self.axes):
477
492
478 if ax.firsttime:
493 if ax.firsttime:
479 self.xmax = self.xmax if self.xmax else np.nanmax(x)
494 self.xmax = self.xmax if self.xmax else np.nanmax(x)
480 self.xmin = self.xmin if self.xmin else -self.xmax
495 self.xmin = self.xmin if self.xmin else -self.xmax
481 self.ymin = self.ymin if self.ymin else np.nanmin(y)
496 self.ymin = self.ymin if self.ymin else np.nanmin(y)
482 self.ymax = self.ymax if self.ymax else np.nanmax(y)
497 self.ymax = self.ymax if self.ymax else np.nanmax(y)
483 self.zmin = self.zmin if self.zmin else np.nanmin(z)
498 self.zmin = self.zmin if self.zmin else np.nanmin(z)
484 self.zmax = self.zmax if self.zmax else np.nanmax(z)
499 self.zmax = self.zmax if self.zmax else np.nanmax(z)
485 ax.plt = ax.pcolormesh(x, y, z[n].T,
500 ax.plt = ax.pcolormesh(x, y, z[n].T,
486 vmin=self.zmin,
501 vmin=self.zmin,
487 vmax=self.zmax,
502 vmax=self.zmax,
488 cmap=plt.get_cmap(self.colormap)
503 cmap=plt.get_cmap(self.colormap)
489 )
504 )
490 ax.plt_dop = ax.plot(mean[n], y,
505 ax.plt_dop = ax.plot(mean[n], y,
491 color='k')[0]
506 color='k')[0]
492
507
493 divider = make_axes_locatable(ax)
508 divider = make_axes_locatable(ax)
494 cax = divider.new_horizontal(size='3%', pad=0.05)
509 cax = divider.new_horizontal(size='3%', pad=0.05)
495 self.figure.add_axes(cax)
510 self.figure.add_axes(cax)
496 plt.colorbar(ax.plt, cax)
511 plt.colorbar(ax.plt, cax)
497
512
498 ax.set_xlim(self.xmin, self.xmax)
513 ax.set_xlim(self.xmin, self.xmax)
499 ax.set_ylim(self.ymin, self.ymax)
514 ax.set_ylim(self.ymin, self.ymax)
500
515
501 ax.set_ylabel(self.ylabel)
516 ax.set_ylabel(self.ylabel)
502 ax.set_xlabel(xlabel)
517 ax.set_xlabel(xlabel)
503
518
504 ax.firsttime = False
519 ax.firsttime = False
505
520
506 if self.showprofile:
521 if self.showprofile:
507 ax.plt_profile= ax.ax_profile.plot(self.data['rti'][self.max_time][n], y)[0]
522 ax.plt_profile= ax.ax_profile.plot(self.data['rti'][self.max_time][n], y)[0]
508 ax.ax_profile.set_xlim(self.zmin, self.zmax)
523 ax.ax_profile.set_xlim(self.zmin, self.zmax)
509 ax.ax_profile.set_ylim(self.ymin, self.ymax)
524 ax.ax_profile.set_ylim(self.ymin, self.ymax)
510 ax.ax_profile.set_xlabel('dB')
525 ax.ax_profile.set_xlabel('dB')
511 ax.ax_profile.grid(b=True, axis='x')
526 ax.ax_profile.grid(b=True, axis='x')
512 ax.plt_noise = ax.ax_profile.plot(numpy.repeat(self.data['noise'][self.max_time][n], len(y)), y,
527 ax.plt_noise = ax.ax_profile.plot(numpy.repeat(self.data['noise'][self.max_time][n], len(y)), y,
513 color="k", linestyle="dashed", lw=2)[0]
528 color="k", linestyle="dashed", lw=2)[0]
514 [tick.set_visible(False) for tick in ax.ax_profile.get_yticklabels()]
529 [tick.set_visible(False) for tick in ax.ax_profile.get_yticklabels()]
515 else:
530 else:
516 ax.plt.set_array(z[n].T.ravel())
531 ax.plt.set_array(z[n].T.ravel())
517 ax.plt_dop.set_data(mean[n], y)
532 ax.plt_dop.set_data(mean[n], y)
518 if self.showprofile:
533 if self.showprofile:
519 ax.plt_profile.set_data(self.data['rti'][self.max_time][n], y)
534 ax.plt_profile.set_data(self.data['rti'][self.max_time][n], y)
520 ax.plt_noise.set_data(numpy.repeat(self.data['noise'][self.max_time][n], len(y)), y)
535 ax.plt_noise.set_data(numpy.repeat(self.data['noise'][self.max_time][n], len(y)), y)
521
536
522 ax.set_title('{} - Noise: {:.2f} dB'.format(self.titles[n], self.data['noise'][self.max_time][n]),
537 ax.set_title('{} - Noise: {:.2f} dB'.format(self.titles[n], self.data['noise'][self.max_time][n]),
523 size=8)
538 size=8)
524 self.saveTime = self.max_time
539 self.saveTime = self.max_time
525
540
526
541
527 class PlotRTIData(PlotData):
542 class PlotRTIData(PlotData):
528
543
529 CODE = 'rti'
544 CODE = 'rti'
530 colormap = 'jro'
545 colormap = 'jro'
531
546
532 def setup(self):
547 def setup(self):
533 self.ncols = 1
548 self.ncols = 1
534 self.nrows = self.dataOut.nChannels
549 self.nrows = self.dataOut.nChannels
535 self.width = 10
550 self.width = 10
536 self.height = 2.2*self.nrows if self.nrows<6 else 12
551 #TODO : arreglar la altura de la figura, esta hardcodeada.
552 #Se arreglo, testear!
553 if self.ind_plt_ch:
554 self.height = 3.2#*self.nrows if self.nrows<6 else 12
555 else:
556 self.height = 2.2*self.nrows if self.nrows<6 else 12
557
558 '''
537 if self.nrows==1:
559 if self.nrows==1:
538 self.height += 1
560 self.height += 1
561 '''
539 self.ylabel = 'Range [Km]'
562 self.ylabel = 'Range [Km]'
540 self.titles = ['Channel {}'.format(x) for x in self.dataOut.channelList]
563 self.titles = ['Channel {}'.format(x) for x in self.dataOut.channelList]
541
564
542 '''
565 '''
543 Logica:
566 Logica:
544 1) Si la variable ind_plt_ch es True, va a crear mas de 1 figura
567 1) Si la variable ind_plt_ch es True, va a crear mas de 1 figura
545 2) guardamos "Figures" en una lista y "axes" en otra, quizas se deberia guardar el
568 2) guardamos "Figures" en una lista y "axes" en otra, quizas se deberia guardar el
546 axis dentro de "Figures" como un diccionario.
569 axis dentro de "Figures" como un diccionario.
547 '''
570 '''
548 if self.ind_plt_ch is False: #standard mode
571 if self.ind_plt_ch is False: #standard mode
549
572
550 if self.figure is None: #solo para la priemra vez
573 if self.figure is None: #solo para la priemra vez
551 self.figure = plt.figure(figsize=(self.width, self.height),
574 self.figure = plt.figure(figsize=(self.width, self.height),
552 edgecolor='k',
575 edgecolor='k',
553 facecolor='w')
576 facecolor='w')
554 else:
577 else:
555 self.figure.clf()
578 self.figure.clf()
556 self.axes = []
579 self.axes = []
557
580
558
581
559 for n in range(self.nrows):
582 for n in range(self.nrows):
560 ax = self.figure.add_subplot(self.nrows, self.ncols, n+1)
583 ax = self.figure.add_subplot(self.nrows, self.ncols, n+1)
561 #ax = self.figure(n+1)
584 #ax = self.figure(n+1)
562 ax.firsttime = True
585 ax.firsttime = True
563 self.axes.append(ax)
586 self.axes.append(ax)
564
587
565 else : #append one figure foreach channel in channelList
588 else : #append one figure foreach channel in channelList
566 if self.figurelist == None:
589 if self.figurelist == None:
567 self.figurelist = []
590 self.figurelist = []
568 for n in range(self.nrows):
591 for n in range(self.nrows):
569 self.figure = plt.figure(figsize=(self.width, self.height),
592 self.figure = plt.figure(figsize=(self.width, self.height),
570 edgecolor='k',
593 edgecolor='k',
571 facecolor='w')
594 facecolor='w')
572 #add always one subplot
595 #add always one subplot
573 self.figurelist.append(self.figure)
596 self.figurelist.append(self.figure)
574
597
575 else : # cada dia nuevo limpia el axes, pero mantiene el figure
598 else : # cada dia nuevo limpia el axes, pero mantiene el figure
576 for eachfigure in self.figurelist:
599 for eachfigure in self.figurelist:
577 eachfigure.clf() # eliminaria todas las figuras de la lista?
600 eachfigure.clf() # eliminaria todas las figuras de la lista?
578 self.axes = []
601 self.axes = []
579
602
580 for eachfigure in self.figurelist:
603 for eachfigure in self.figurelist:
581 ax = eachfigure.add_subplot(1,1,1) #solo 1 axis por figura
604 ax = eachfigure.add_subplot(1,1,1) #solo 1 axis por figura
582 #ax = self.figure(n+1)
605 #ax = self.figure(n+1)
583 ax.firsttime = True
606 ax.firsttime = True
584 #Cada figura tiene un distinto puntero
607 #Cada figura tiene un distinto puntero
585 self.axes.append(ax)
608 self.axes.append(ax)
586 #plt.close(eachfigure)
609 #plt.close(eachfigure)
587
610
588
611
589 def plot(self):
612 def plot(self):
590
613
591 if self.ind_plt_ch is False: #standard mode
614 if self.ind_plt_ch is False: #standard mode
592 self.x = np.array(self.times)
615 self.x = np.array(self.times)
593 self.y = self.dataOut.getHeiRange()
616 self.y = self.dataOut.getHeiRange()
594 self.z = []
617 self.z = []
595
618
596 for ch in range(self.nrows):
619 for ch in range(self.nrows):
597 self.z.append([self.data[self.CODE][t][ch] for t in self.times])
620 self.z.append([self.data[self.CODE][t][ch] for t in self.times])
598
621
599 self.z = np.array(self.z)
622 self.z = np.array(self.z)
600 for n, ax in enumerate(self.axes):
623 for n, ax in enumerate(self.axes):
601 x, y, z = self.fill_gaps(*self.decimate())
624 x, y, z = self.fill_gaps(*self.decimate())
602 xmin = self.min_time
625 xmin = self.min_time
603 xmax = xmin+self.xrange*60*60
626 xmax = xmin+self.xrange*60*60
604 self.zmin = self.zmin if self.zmin else np.min(self.z)
627 self.zmin = self.zmin if self.zmin else np.min(self.z)
605 self.zmax = self.zmax if self.zmax else np.max(self.z)
628 self.zmax = self.zmax if self.zmax else np.max(self.z)
606 if ax.firsttime:
629 if ax.firsttime:
607 self.ymin = self.ymin if self.ymin else np.nanmin(self.y)
630 self.ymin = self.ymin if self.ymin else np.nanmin(self.y)
608 self.ymax = self.ymax if self.ymax else np.nanmax(self.y)
631 self.ymax = self.ymax if self.ymax else np.nanmax(self.y)
609 plot = ax.pcolormesh(x, y, z[n].T,
632 plot = ax.pcolormesh(x, y, z[n].T,
610 vmin=self.zmin,
633 vmin=self.zmin,
611 vmax=self.zmax,
634 vmax=self.zmax,
612 cmap=plt.get_cmap(self.colormap)
635 cmap=plt.get_cmap(self.colormap)
613 )
636 )
614 divider = make_axes_locatable(ax)
637 divider = make_axes_locatable(ax)
615 cax = divider.new_horizontal(size='2%', pad=0.05)
638 cax = divider.new_horizontal(size='2%', pad=0.05)
616 self.figure.add_axes(cax)
639 self.figure.add_axes(cax)
617 plt.colorbar(plot, cax)
640 plt.colorbar(plot, cax)
618 ax.set_ylim(self.ymin, self.ymax)
641 ax.set_ylim(self.ymin, self.ymax)
619 ax.xaxis.set_major_formatter(FuncFormatter(func))
642 ax.xaxis.set_major_formatter(FuncFormatter(func))
620 ax.xaxis.set_major_locator(LinearLocator(6))
643 ax.xaxis.set_major_locator(LinearLocator(6))
621 ax.set_ylabel(self.ylabel)
644 ax.set_ylabel(self.ylabel)
622 if self.xmin is None:
645 if self.xmin is None:
623 xmin = self.min_time
646 xmin = self.min_time
624 else:
647 else:
625 xmin = (datetime.datetime.combine(self.dataOut.datatime.date(),
648 xmin = (datetime.datetime.combine(self.dataOut.datatime.date(),
626 datetime.time(self.xmin, 0, 0))-d1970).total_seconds()
649 datetime.time(self.xmin, 0, 0))-d1970).total_seconds()
627 ax.set_xlim(xmin, xmax)
650 ax.set_xlim(xmin, xmax)
628 ax.firsttime = False
651 ax.firsttime = False
629 else:
652 else:
630 ax.collections.remove(ax.collections[0])
653 ax.collections.remove(ax.collections[0])
631 ax.set_xlim(xmin, xmax)
654 ax.set_xlim(xmin, xmax)
632 plot = ax.pcolormesh(x, y, z[n].T,
655 plot = ax.pcolormesh(x, y, z[n].T,
633 vmin=self.zmin,
656 vmin=self.zmin,
634 vmax=self.zmax,
657 vmax=self.zmax,
635 cmap=plt.get_cmap(self.colormap)
658 cmap=plt.get_cmap(self.colormap)
636 )
659 )
637 ax.set_title('{} {}'.format(self.titles[n],
660 ax.set_title('{} {}'.format(self.titles[n],
638 datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S')),
661 datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S')),
639 size=8)
662 size=8)
640
663
641 self.saveTime = self.min_time
664 self.saveTime = self.min_time
642 else :
665 else :
643 self.x = np.array(self.times)
666 self.x = np.array(self.times)
644 self.y = self.dataOut.getHeiRange()
667 self.y = self.dataOut.getHeiRange()
645 self.z = []
668 self.z = []
646
669
647 for ch in range(self.nrows):
670 for ch in range(self.nrows):
648 self.z.append([self.data[self.CODE][t][ch] for t in self.times])
671 self.z.append([self.data[self.CODE][t][ch] for t in self.times])
649
672
650 self.z = np.array(self.z)
673 self.z = np.array(self.z)
651 for n, eachfigure in enumerate(self.figurelist): #estaba ax in axes
674 for n, eachfigure in enumerate(self.figurelist): #estaba ax in axes
652
675
653 x, y, z = self.fill_gaps(*self.decimate())
676 x, y, z = self.fill_gaps(*self.decimate())
654 xmin = self.min_time
677 xmin = self.min_time
655 xmax = xmin+self.xrange*60*60
678 xmax = xmin+self.xrange*60*60
656 self.zmin = self.zmin if self.zmin else np.min(self.z)
679 self.zmin = self.zmin if self.zmin else np.min(self.z)
657 self.zmax = self.zmax if self.zmax else np.max(self.z)
680 self.zmax = self.zmax if self.zmax else np.max(self.z)
658 if self.axes[n].firsttime:
681 if self.axes[n].firsttime:
659 self.ymin = self.ymin if self.ymin else np.nanmin(self.y)
682 self.ymin = self.ymin if self.ymin else np.nanmin(self.y)
660 self.ymax = self.ymax if self.ymax else np.nanmax(self.y)
683 self.ymax = self.ymax if self.ymax else np.nanmax(self.y)
661 plot = self.axes[n].pcolormesh(x, y, z[n].T,
684 plot = self.axes[n].pcolormesh(x, y, z[n].T,
662 vmin=self.zmin,
685 vmin=self.zmin,
663 vmax=self.zmax,
686 vmax=self.zmax,
664 cmap=plt.get_cmap(self.colormap)
687 cmap=plt.get_cmap(self.colormap)
665 )
688 )
666 divider = make_axes_locatable(self.axes[n])
689 divider = make_axes_locatable(self.axes[n])
667 cax = divider.new_horizontal(size='2%', pad=0.05)
690 cax = divider.new_horizontal(size='2%', pad=0.05)
668 eachfigure.add_axes(cax)
691 eachfigure.add_axes(cax)
669 #self.figure2.add_axes(cax)
692 #self.figure2.add_axes(cax)
670 plt.colorbar(plot, cax)
693 plt.colorbar(plot, cax)
671 self.axes[n].set_ylim(self.ymin, self.ymax)
694 self.axes[n].set_ylim(self.ymin, self.ymax)
672
695
673 self.axes[n].xaxis.set_major_formatter(FuncFormatter(func))
696 self.axes[n].xaxis.set_major_formatter(FuncFormatter(func))
674 self.axes[n].xaxis.set_major_locator(LinearLocator(6))
697 self.axes[n].xaxis.set_major_locator(LinearLocator(6))
675
698
676 self.axes[n].set_ylabel(self.ylabel)
699 self.axes[n].set_ylabel(self.ylabel)
677
700
678 if self.xmin is None:
701 if self.xmin is None:
679 xmin = self.min_time
702 xmin = self.min_time
680 else:
703 else:
681 xmin = (datetime.datetime.combine(self.dataOut.datatime.date(),
704 xmin = (datetime.datetime.combine(self.dataOut.datatime.date(),
682 datetime.time(self.xmin, 0, 0))-d1970).total_seconds()
705 datetime.time(self.xmin, 0, 0))-d1970).total_seconds()
683
706
684 self.axes[n].set_xlim(xmin, xmax)
707 self.axes[n].set_xlim(xmin, xmax)
685 self.axes[n].firsttime = False
708 self.axes[n].firsttime = False
686 else:
709 else:
687 self.axes[n].collections.remove(self.axes[n].collections[0])
710 self.axes[n].collections.remove(self.axes[n].collections[0])
688 self.axes[n].set_xlim(xmin, xmax)
711 self.axes[n].set_xlim(xmin, xmax)
689 plot = self.axes[n].pcolormesh(x, y, z[n].T,
712 plot = self.axes[n].pcolormesh(x, y, z[n].T,
690 vmin=self.zmin,
713 vmin=self.zmin,
691 vmax=self.zmax,
714 vmax=self.zmax,
692 cmap=plt.get_cmap(self.colormap)
715 cmap=plt.get_cmap(self.colormap)
693 )
716 )
694 self.axes[n].set_title('{} {}'.format(self.titles[n],
717 self.axes[n].set_title('{} {}'.format(self.titles[n],
695 datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S')),
718 datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S')),
696 size=8)
719 size=8)
697
720
698 self.saveTime = self.min_time
721 self.saveTime = self.min_time
699
722
700
723
701 class PlotCOHData(PlotRTIData):
724 class PlotCOHData(PlotRTIData):
702
725
703 CODE = 'coh'
726 CODE = 'coh'
704
727
705 def setup(self):
728 def setup(self):
706
729
707 self.ncols = 1
730 self.ncols = 1
708 self.nrows = self.dataOut.nPairs
731 self.nrows = self.dataOut.nPairs
709 self.width = 10
732 self.width = 10
710 self.height = 2.2*self.nrows if self.nrows<6 else 12
733 self.height = 2.2*self.nrows if self.nrows<6 else 12
711 if self.nrows==1:
734 if self.nrows==1:
712 self.height += 1
735 self.height += 1
713 self.ylabel = 'Range [Km]'
736 self.ylabel = 'Range [Km]'
714 self.titles = ['{} Ch{} * Ch{}'.format(self.CODE.upper(), x[0], x[1]) for x in self.dataOut.pairsList]
737 self.titles = ['{} Ch{} * Ch{}'.format(self.CODE.upper(), x[0], x[1]) for x in self.dataOut.pairsList]
715
738
716 if self.figure is None:
739 if self.figure is None:
717 self.figure = plt.figure(figsize=(self.width, self.height),
740 self.figure = plt.figure(figsize=(self.width, self.height),
718 edgecolor='k',
741 edgecolor='k',
719 facecolor='w')
742 facecolor='w')
720 else:
743 else:
721 self.figure.clf()
744 self.figure.clf()
722 self.axes = []
745 self.axes = []
723
746
724 for n in range(self.nrows):
747 for n in range(self.nrows):
725 ax = self.figure.add_subplot(self.nrows, self.ncols, n+1)
748 ax = self.figure.add_subplot(self.nrows, self.ncols, n+1)
726 ax.firsttime = True
749 ax.firsttime = True
727 self.axes.append(ax)
750 self.axes.append(ax)
728
751
729
752
730 class PlotNoiseData(PlotData):
753 class PlotNoiseData(PlotData):
731 CODE = 'noise'
754 CODE = 'noise'
732
755
733 def setup(self):
756 def setup(self):
734
757
735 self.ncols = 1
758 self.ncols = 1
736 self.nrows = 1
759 self.nrows = 1
737 self.width = 10
760 self.width = 10
738 self.height = 3.2
761 self.height = 3.2
739 self.ylabel = 'Intensity [dB]'
762 self.ylabel = 'Intensity [dB]'
740 self.titles = ['Noise']
763 self.titles = ['Noise']
741
764
742 if self.figure is None:
765 if self.figure is None:
743 self.figure = plt.figure(figsize=(self.width, self.height),
766 self.figure = plt.figure(figsize=(self.width, self.height),
744 edgecolor='k',
767 edgecolor='k',
745 facecolor='w')
768 facecolor='w')
746 else:
769 else:
747 self.figure.clf()
770 self.figure.clf()
748 self.axes = []
771 self.axes = []
749
772
750 self.ax = self.figure.add_subplot(self.nrows, self.ncols, 1)
773 self.ax = self.figure.add_subplot(self.nrows, self.ncols, 1)
751 self.ax.firsttime = True
774 self.ax.firsttime = True
752
775
753 def plot(self):
776 def plot(self):
754
777
755 x = self.times
778 x = self.times
756 xmin = self.min_time
779 xmin = self.min_time
757 xmax = xmin+self.xrange*60*60
780 xmax = xmin+self.xrange*60*60
758 if self.ax.firsttime:
781 if self.ax.firsttime:
759 for ch in self.dataOut.channelList:
782 for ch in self.dataOut.channelList:
760 y = [self.data[self.CODE][t][ch] for t in self.times]
783 y = [self.data[self.CODE][t][ch] for t in self.times]
761 self.ax.plot(x, y, lw=1, label='Ch{}'.format(ch))
784 self.ax.plot(x, y, lw=1, label='Ch{}'.format(ch))
762 self.ax.firsttime = False
785 self.ax.firsttime = False
763 self.ax.xaxis.set_major_formatter(FuncFormatter(func))
786 self.ax.xaxis.set_major_formatter(FuncFormatter(func))
764 self.ax.xaxis.set_major_locator(LinearLocator(6))
787 self.ax.xaxis.set_major_locator(LinearLocator(6))
765 self.ax.set_ylabel(self.ylabel)
788 self.ax.set_ylabel(self.ylabel)
766 plt.legend()
789 plt.legend()
767 else:
790 else:
768 for ch in self.dataOut.channelList:
791 for ch in self.dataOut.channelList:
769 y = [self.data[self.CODE][t][ch] for t in self.times]
792 y = [self.data[self.CODE][t][ch] for t in self.times]
770 self.ax.lines[ch].set_data(x, y)
793 self.ax.lines[ch].set_data(x, y)
771
794
772 self.ax.set_xlim(xmin, xmax)
795 self.ax.set_xlim(xmin, xmax)
773 self.ax.set_ylim(min(y)-5, max(y)+5)
796 self.ax.set_ylim(min(y)-5, max(y)+5)
774 self.saveTime = self.min_time
797 self.saveTime = self.min_time
775
798
776
799
777 class PlotWindProfilerData(PlotRTIData):
800 class PlotWindProfilerData(PlotRTIData):
778
801
779 CODE = 'wind'
802 CODE = 'wind'
780 colormap = 'seismic'
803 colormap = 'seismic'
781
804
782 def setup(self):
805 def setup(self):
783 self.ncols = 1
806 self.ncols = 1
784 self.nrows = self.dataOut.data_output.shape[0]
807 self.nrows = self.dataOut.data_output.shape[0]
785 self.width = 10
808 self.width = 10
786 self.height = 2.2*self.nrows
809 self.height = 2.2*self.nrows
787 self.ylabel = 'Height [Km]'
810 self.ylabel = 'Height [Km]'
788 self.titles = ['Zonal Wind' ,'Meridional Wind', 'Vertical Wind']
811 self.titles = ['Zonal Wind' ,'Meridional Wind', 'Vertical Wind']
789 self.clabels = ['Velocity (m/s)','Velocity (m/s)','Velocity (cm/s)']
812 self.clabels = ['Velocity (m/s)','Velocity (m/s)','Velocity (cm/s)']
790 self.windFactor = [1, 1, 100]
813 self.windFactor = [1, 1, 100]
791
814
792 if self.figure is None:
815 if self.figure is None:
793 self.figure = plt.figure(figsize=(self.width, self.height),
816 self.figure = plt.figure(figsize=(self.width, self.height),
794 edgecolor='k',
817 edgecolor='k',
795 facecolor='w')
818 facecolor='w')
796 else:
819 else:
797 self.figure.clf()
820 self.figure.clf()
798 self.axes = []
821 self.axes = []
799
822
800 for n in range(self.nrows):
823 for n in range(self.nrows):
801 ax = self.figure.add_subplot(self.nrows, self.ncols, n+1)
824 ax = self.figure.add_subplot(self.nrows, self.ncols, n+1)
802 ax.firsttime = True
825 ax.firsttime = True
803 self.axes.append(ax)
826 self.axes.append(ax)
804
827
805 def plot(self):
828 def plot(self):
806
829
807 self.x = np.array(self.times)
830 self.x = np.array(self.times)
808 self.y = self.dataOut.heightList
831 self.y = self.dataOut.heightList
809 self.z = []
832 self.z = []
810
833
811 for ch in range(self.nrows):
834 for ch in range(self.nrows):
812 self.z.append([self.data['output'][t][ch] for t in self.times])
835 self.z.append([self.data['output'][t][ch] for t in self.times])
813
836
814 self.z = np.array(self.z)
837 self.z = np.array(self.z)
815 self.z = numpy.ma.masked_invalid(self.z)
838 self.z = numpy.ma.masked_invalid(self.z)
816
839
817 cmap=plt.get_cmap(self.colormap)
840 cmap=plt.get_cmap(self.colormap)
818 cmap.set_bad('black', 1.)
841 cmap.set_bad('black', 1.)
819
842
820 for n, ax in enumerate(self.axes):
843 for n, ax in enumerate(self.axes):
821 x, y, z = self.fill_gaps(*self.decimate())
844 x, y, z = self.fill_gaps(*self.decimate())
822 xmin = self.min_time
845 xmin = self.min_time
823 xmax = xmin+self.xrange*60*60
846 xmax = xmin+self.xrange*60*60
824 if ax.firsttime:
847 if ax.firsttime:
825 self.ymin = self.ymin if self.ymin else np.nanmin(self.y)
848 self.ymin = self.ymin if self.ymin else np.nanmin(self.y)
826 self.ymax = self.ymax if self.ymax else np.nanmax(self.y)
849 self.ymax = self.ymax if self.ymax else np.nanmax(self.y)
827 self.zmax = self.zmax if self.zmax else numpy.nanmax(abs(self.z[:-1, :]))
850 self.zmax = self.zmax if self.zmax else numpy.nanmax(abs(self.z[:-1, :]))
828 self.zmin = self.zmin if self.zmin else -self.zmax
851 self.zmin = self.zmin if self.zmin else -self.zmax
829
852
830 plot = ax.pcolormesh(x, y, z[n].T*self.windFactor[n],
853 plot = ax.pcolormesh(x, y, z[n].T*self.windFactor[n],
831 vmin=self.zmin,
854 vmin=self.zmin,
832 vmax=self.zmax,
855 vmax=self.zmax,
833 cmap=cmap
856 cmap=cmap
834 )
857 )
835 divider = make_axes_locatable(ax)
858 divider = make_axes_locatable(ax)
836 cax = divider.new_horizontal(size='2%', pad=0.05)
859 cax = divider.new_horizontal(size='2%', pad=0.05)
837 self.figure.add_axes(cax)
860 self.figure.add_axes(cax)
838 cb = plt.colorbar(plot, cax)
861 cb = plt.colorbar(plot, cax)
839 cb.set_label(self.clabels[n])
862 cb.set_label(self.clabels[n])
840 ax.set_ylim(self.ymin, self.ymax)
863 ax.set_ylim(self.ymin, self.ymax)
841
864
842 ax.xaxis.set_major_formatter(FuncFormatter(func))
865 ax.xaxis.set_major_formatter(FuncFormatter(func))
843 ax.xaxis.set_major_locator(LinearLocator(6))
866 ax.xaxis.set_major_locator(LinearLocator(6))
844
867
845 ax.set_ylabel(self.ylabel)
868 ax.set_ylabel(self.ylabel)
846
869
847 ax.set_xlim(xmin, xmax)
870 ax.set_xlim(xmin, xmax)
848 ax.firsttime = False
871 ax.firsttime = False
849 else:
872 else:
850 ax.collections.remove(ax.collections[0])
873 ax.collections.remove(ax.collections[0])
851 ax.set_xlim(xmin, xmax)
874 ax.set_xlim(xmin, xmax)
852 plot = ax.pcolormesh(x, y, z[n].T*self.windFactor[n],
875 plot = ax.pcolormesh(x, y, z[n].T*self.windFactor[n],
853 vmin=self.zmin,
876 vmin=self.zmin,
854 vmax=self.zmax,
877 vmax=self.zmax,
855 cmap=plt.get_cmap(self.colormap)
878 cmap=plt.get_cmap(self.colormap)
856 )
879 )
857 ax.set_title('{} {}'.format(self.titles[n],
880 ax.set_title('{} {}'.format(self.titles[n],
858 datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S')),
881 datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S')),
859 size=8)
882 size=8)
860
883
861 self.saveTime = self.min_time
884 self.saveTime = self.min_time
862
885
863
886
864 class PlotSNRData(PlotRTIData):
887 class PlotSNRData(PlotRTIData):
865 CODE = 'snr'
888 CODE = 'snr'
866 colormap = 'jet'
889 colormap = 'jet'
867
890
868 class PlotDOPData(PlotRTIData):
891 class PlotDOPData(PlotRTIData):
869 CODE = 'dop'
892 CODE = 'dop'
870 colormap = 'jet'
893 colormap = 'jet'
871
894
872
895
873 class PlotPHASEData(PlotCOHData):
896 class PlotPHASEData(PlotCOHData):
874 CODE = 'phase'
897 CODE = 'phase'
875 colormap = 'seismic'
898 colormap = 'seismic'
876
899
877
900
878 class PlotSkyMapData(PlotData):
901 class PlotSkyMapData(PlotData):
879
902
880 CODE = 'met'
903 CODE = 'met'
881
904
882 def setup(self):
905 def setup(self):
883
906
884 self.ncols = 1
907 self.ncols = 1
885 self.nrows = 1
908 self.nrows = 1
886 self.width = 7.2
909 self.width = 7.2
887 self.height = 7.2
910 self.height = 7.2
888
911
889 self.xlabel = 'Zonal Zenith Angle (deg)'
912 self.xlabel = 'Zonal Zenith Angle (deg)'
890 self.ylabel = 'Meridional Zenith Angle (deg)'
913 self.ylabel = 'Meridional Zenith Angle (deg)'
891
914
892 if self.figure is None:
915 if self.figure is None:
893 self.figure = plt.figure(figsize=(self.width, self.height),
916 self.figure = plt.figure(figsize=(self.width, self.height),
894 edgecolor='k',
917 edgecolor='k',
895 facecolor='w')
918 facecolor='w')
896 else:
919 else:
897 self.figure.clf()
920 self.figure.clf()
898
921
899 self.ax = plt.subplot2grid((self.nrows, self.ncols), (0, 0), 1, 1, polar=True)
922 self.ax = plt.subplot2grid((self.nrows, self.ncols), (0, 0), 1, 1, polar=True)
900 self.ax.firsttime = True
923 self.ax.firsttime = True
901
924
902
925
903 def plot(self):
926 def plot(self):
904
927
905 arrayParameters = np.concatenate([self.data['param'][t] for t in self.times])
928 arrayParameters = np.concatenate([self.data['param'][t] for t in self.times])
906 error = arrayParameters[:,-1]
929 error = arrayParameters[:,-1]
907 indValid = numpy.where(error == 0)[0]
930 indValid = numpy.where(error == 0)[0]
908 finalMeteor = arrayParameters[indValid,:]
931 finalMeteor = arrayParameters[indValid,:]
909 finalAzimuth = finalMeteor[:,3]
932 finalAzimuth = finalMeteor[:,3]
910 finalZenith = finalMeteor[:,4]
933 finalZenith = finalMeteor[:,4]
911
934
912 x = finalAzimuth*numpy.pi/180
935 x = finalAzimuth*numpy.pi/180
913 y = finalZenith
936 y = finalZenith
914
937
915 if self.ax.firsttime:
938 if self.ax.firsttime:
916 self.ax.plot = self.ax.plot(x, y, 'bo', markersize=5)[0]
939 self.ax.plot = self.ax.plot(x, y, 'bo', markersize=5)[0]
917 self.ax.set_ylim(0,90)
940 self.ax.set_ylim(0,90)
918 self.ax.set_yticks(numpy.arange(0,90,20))
941 self.ax.set_yticks(numpy.arange(0,90,20))
919 self.ax.set_xlabel(self.xlabel)
942 self.ax.set_xlabel(self.xlabel)
920 self.ax.set_ylabel(self.ylabel)
943 self.ax.set_ylabel(self.ylabel)
921 self.ax.yaxis.labelpad = 40
944 self.ax.yaxis.labelpad = 40
922 self.ax.firsttime = False
945 self.ax.firsttime = False
923 else:
946 else:
924 self.ax.plot.set_data(x, y)
947 self.ax.plot.set_data(x, y)
925
948
926
949
927 dt1 = datetime.datetime.fromtimestamp(self.min_time).strftime('%y/%m/%d %H:%M:%S')
950 dt1 = datetime.datetime.fromtimestamp(self.min_time).strftime('%y/%m/%d %H:%M:%S')
928 dt2 = datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S')
951 dt2 = datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S')
929 title = 'Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n' % (dt1,
952 title = 'Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n' % (dt1,
930 dt2,
953 dt2,
931 len(x))
954 len(x))
932 self.ax.set_title(title, size=8)
955 self.ax.set_title(title, size=8)
933
956
934 self.saveTime = self.max_time
957 self.saveTime = self.max_time
@@ -1,101 +1,109
1 import argparse
1 import argparse
2
2 import datetime
3 from schainpy.controller import Project, multiSchain
3 from schainpy.controller import Project, multiSchain
4
4
5 desc = "HF_EXAMPLE"
5 desc = "HF_EXAMPLE"
6 path='/home/ci-81/Documents/DATA/HFADATA/hfdata_2017/pdata/sp1_f0'
6 path='/home/ci-81/Documents/DATA/HFADATA/hfdata_2017/pdata/sp1_f0'
7 path = '/media/ci-81/Huancayo/DATA/hfradar_2016/pdata/sp1_f1'
7 path = '/media/ci-81/Huancayo/DATA/hfradar_2016/pdata/sp1_f1'
8 path = '/media/ci-81/Huancayo/DATA/hfradar_2016/pdata/sp1_f1'
8 path = '/media/ci-81/Huancayo/DATA/hfradar_2016/pdata/sp1_f1'
9 def fiber(cursor, skip, q, dt):
9 def fiber(cursor, skip, q, dt):
10
10
11 controllerObj = Project()
11 controllerObj = Project()
12
12
13 controllerObj.setup(id='191', name='test01', description=desc)
13 controllerObj.setup(id='191', name='test01', description=desc)
14
14
15 readUnitConfObj = controllerObj.addReadUnit(datatype='SpectraReader',
15 readUnitConfObj = controllerObj.addReadUnit(datatype='SpectraReader',
16 path=path,
16 path=path,
17 startDate=dt,
17 startDate=dt,
18 endDate=dt,
18 endDate=dt,
19 startTime="00:00:00",
19 startTime="00:00:00",
20 endTime="23:59:59",
20 endTime="23:59:59",
21 online=0,
21 online=0,
22 #set=1426485881,
22 #set=1426485881,
23 delay=10,
23 delay=10,
24 walk=1,
24 walk=1,
25 queue=q,
25 queue=q,
26 cursor=cursor,
26 cursor=cursor,
27 skip=skip,
27 skip=skip,
28 #timezone=-5*3600
28 #timezone=-5*3600
29 )
29 )
30
30
31 # #opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock')
31 # #opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock')
32 #
32 #
33 procUnitConfObj2 = controllerObj.addProcUnit(datatype='Spectra', inputId=readUnitConfObj.getId())
33 procUnitConfObj2 = controllerObj.addProcUnit(datatype='Spectra', inputId=readUnitConfObj.getId())
34 opObj10 = procUnitConfObj2.addOperation(name='removeInterference')
34 opObj10 = procUnitConfObj2.addOperation(name='removeInterference')
35
35
36 # procUnitConfObj2.addParameter(name='nipp', value='5', format='int')
36 # procUnitConfObj2.addParameter(name='nipp', value='5', format='int')
37
37
38 procUnitConfObj3 = controllerObj.addProcUnit(datatype='ParametersProc', inputId=readUnitConfObj.getId())
38 procUnitConfObj3 = controllerObj.addProcUnit(datatype='ParametersProc', inputId=readUnitConfObj.getId())
39 opObj11 = procUnitConfObj3.addOperation(name='SpectralMoments', optype='other')
39 opObj11 = procUnitConfObj3.addOperation(name='SpectralMoments', optype='other')
40
40
41 #
41 #
42 # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other')
42 # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other')
43 # opObj11.addParameter(name='id', value='1000', format='int')
43 # opObj11.addParameter(name='id', value='1000', format='int')
44 # opObj11.addParameter(name='wintitle', value='HF_Jicamarca_Spc', format='str')
44 # opObj11.addParameter(name='wintitle', value='HF_Jicamarca_Spc', format='str')
45 # opObj11.addParameter(name='channelList', value='0', format='intlist')
45 # opObj11.addParameter(name='channelList', value='0', format='intlist')
46 # opObj11.addParameter(name='zmin', value='-120', format='float')
46 # opObj11.addParameter(name='zmin', value='-120', format='float')
47 # opObj11.addParameter(name='zmax', value='-70', format='float')
47 # opObj11.addParameter(name='zmax', value='-70', format='float')
48 # opObj11.addParameter(name='save', value='1', format='int')
48 # opObj11.addParameter(name='save', value='1', format='int')
49 # opObj11.addParameter(name='figpath', value=figpath, format='str')
49 # opObj11.addParameter(name='figpath', value=figpath, format='str')
50
50
51 # opObj11 = procUnitConfObj3.addOperation(name='Parameters1Plot', optype='other')
51 # opObj11 = procUnitConfObj3.addOperation(name='Parameters1Plot', optype='other')
52 # opObj11.addParameter(name='channelList', value='0', format='intList')
52 # opObj11.addParameter(name='channelList', value='0', format='intList')
53
53
54 # opObj11.addParameter(name='id', value='2000', format='int')
54 # opObj11.addParameter(name='id', value='2000', format='int')
55 # opObj11.addParameter(name='colormap', value='0', format='bool')
55 # opObj11.addParameter(name='colormap', value='0', format='bool')
56 # opObj11.addParameter(name='onlySNR', value='1', format='bool')
56 # opObj11.addParameter(name='onlySNR', value='1', format='bool')
57 # opObj11.addParameter(name='DOP', value='0', format='bool')
57 # opObj11.addParameter(name='DOP', value='0', format='bool')
58 # opObj11.addParameter(name='showSNR', value='1', format='bool')
58 # opObj11.addParameter(name='showSNR', value='1', format='bool')
59 # opObj11.addParameter(name='SNRthresh', value='0', format='int')
59 # opObj11.addParameter(name='SNRthresh', value='0', format='int')
60 # opObj11.addParameter(name='SNRmin', value='-10', format='int')
60 # opObj11.addParameter(name='SNRmin', value='-10', format='int')
61 # opObj11.addParameter(name='SNRmax', value='30', format='int')
61 # opObj11.addParameter(name='SNRmax', value='30', format='int')
62
62
63 # opObj11.addParameter(name='showSNR', value='1', format='int')
63 # opObj11.addParameter(name='showSNR', value='1', format='int')
64 # # opObj11.addParameter(name='channelList', value='0', format='intlist')
64 # # opObj11.addParameter(name='channelList', value='0', format='intlist')
65 # # opObj11.addParameter(name='xmin', value='0', format='float')
65 # # opObj11.addParameter(name='xmin', value='0', format='float')
66 # opObj11.addParameter(name='xmin', value='0', format='float')
66 # opObj11.addParameter(name='xmin', value='0', format='float')
67 # opObj11.addParameter(name='xmax', value='24', format='float')
67 # opObj11.addParameter(name='xmax', value='24', format='float')
68
68
69 # opObj11.addParameter(name='zmin', value='-110', format='float')
69 # opObj11.addParameter(name='zmin', value='-110', format='float')
70 # opObj11.addParameter(name='zmax', value='-70', format='float')
70 # opObj11.addParameter(name='zmax', value='-70', format='float')
71 # opObj11.addParameter(name='save', value='0', format='int')
71 # opObj11.addParameter(name='save', value='0', format='int')
72 # # opObj11.addParameter(name='figpath', value='/tmp/', format='str')
72 # # opObj11.addParameter(name='figpath', value='/tmp/', format='str')
73 #
73 #
74 opObj12 = procUnitConfObj3.addOperation(name='PublishData', optype='other')
74 opObj12 = procUnitConfObj3.addOperation(name='PublishData', optype='other')
75 #opObj12.addParameter(name='server', value='tcp://10.10.10.82:3001', format='int')
75 #opObj12.addParameter(name='server', value='tcp://10.10.10.82:3001', format='int')
76 opObj12.addParameter(name='zeromq', value=1, format='int')
76 opObj12.addParameter(name='zeromq', value=1, format='int')
77
77
78
78
79 # opObj13 = procUnitConfObj3.addOperation(name='PublishData', optype='other')
79 # opObj13 = procUnitConfObj3.addOperation(name='PublishData', optype='other')
80 # opObj13.addParameter(name='zeromq', value=1, format='int')
80 # opObj13.addParameter(name='zeromq', value=1, format='int')
81 # opObj13.addParameter(name='server', value="juanca", format='str')
81 # opObj13.addParameter(name='server', value="juanca", format='str')
82
82
83 # opObj12.addParameter(name='delay', value=1, format='int')
83 # opObj12.addParameter(name='delay', value=1, format='int')
84
84
85
85
86 # print "Escribiendo el archivo XML"
86 # print "Escribiendo el archivo XML"
87 # controllerObj.writeXml(filename)
87 # controllerObj.writeXml(filename)
88 # print "Leyendo el archivo XML"
88 # print "Leyendo el archivo XML"
89 # controllerObj.readXml(filename)
89 # controllerObj.readXml(filename)
90
90
91
91
92 # timeit.timeit('controllerObj.run()', number=2)
92 # timeit.timeit('controllerObj.run()', number=2)
93
93
94 controllerObj.start()
94 controllerObj.start()
95
95
96
96
97 if __name__ == '__main__':
97 if __name__ == '__main__':
98 ############################DATE##########################################
99 doitnow = datetime.datetime.now() - datetime.timedelta(days=1) # Un dia antes
100 y = doitnow.year
101 m = doitnow.month
102 d = int(doitnow.day)
103 date = str(y)+"/"+str(m)+"/"+str(d)
104 ###########################################################################
98 parser = argparse.ArgumentParser(description='Set number of parallel processes')
105 parser = argparse.ArgumentParser(description='Set number of parallel processes')
99 parser.add_argument('--nProcess', default=1, type=int)
106 parser.add_argument('--nProcess', default=1, type=int)
100 args = parser.parse_args()
107 args = parser.parse_args()
101 multiSchain(fiber, nProcess=8, startDate='2016/04/23', endDate='2016/04/27')
108 multiSchain(fiber, nProcess=8, startDate='2016/04/23', endDate='2016/04/23')
109 #multiSchain(fiber, nProcess=4, startDate=date, endDate=date) #Plot automatico de un dia antes
@@ -1,82 +1,89
1 #!/usr/bin/env python
1 #!/usr/bin/env python
2 '''
2 '''
3 Created on Jul 7, 2014
3 Created on Jul 7, 2014
4
4
5 @author: roj-idl71
5 @author: roj-idl71
6 '''
6 '''
7 import os, sys
7 import os, sys
8
8
9 from schainpy.controller import Project
9 from schainpy.controller import Project
10
10
11 if __name__ == '__main__':
11 if __name__ == '__main__':
12 desc = "Segundo Test"
12 desc = "Segundo Test"
13
13
14 controllerObj = Project()
14 controllerObj = Project()
15 controllerObj.setup(id='191', name='test01', description=desc)
15 controllerObj.setup(id='191', name='test01', description=desc)
16
16
17 proc1 = controllerObj.addProcUnit(name='PlotterReceiver')
17 proc1 = controllerObj.addProcUnit(name='PlotterReceiver')
18 # proc1.addParameter(name='realtime', value='0', format='bool')
18 # proc1.addParameter(name='realtime', value='0', format='bool')
19 #proc1.addParameter(name='plottypes', value='rti,coh,phase,snr,dop', format='str')
19 #proc1.addParameter(name='plottypes', value='rti,coh,phase,snr,dop', format='str')
20 #proc1.addParameter(name='plottypes', value='rti,coh,phase,snr', format='str')
20 #proc1.addParameter(name='plottypes', value='rti,coh,phase,snr', format='str')
21 proc1.addParameter(name='plottypes', value='snr,dop', format='str')
21
22 #proc1.addParameter(name='plottypes', value='snr,dop', format='str')
23 proc1.addParameter(name='plottypes', value='rti,dop,snr,phase,coh', format='str')
24 #proc1.addParameter(name='plottypes', value='phase,coh', format='str')
22
25
23 #proc1.addParameter(name='throttle', value='10', format='int')
26 #proc1.addParameter(name='throttle', value='10', format='int')
24
27
25 proc1.addParameter(name='interactive', value='0', format='bool') # ? PREGUNTAR
28 proc1.addParameter(name='interactive', value='0', format='bool') # ? PREGUNTAR
26 # proc1.addParameter(name='server', value='tcp://10.10.10.82:7000', format='str')
29 # proc1.addParameter(name='server', value='tcp://10.10.10.82:7000', format='str')
27 ## TODO Agregar direccion de server de publicacion a graficos como variable
30 ## TODO Agregar direccion de server de publicacion a graficos como variable
28
31
29 """
32 """
30 op1 = proc1.addOperation(name='PlotRTIData', optype='other')
33 op1 = proc1.addOperation(name='PlotRTIData', optype='other')
31 op1.addParameter(name='wintitle', value='HF System', format='str')
34 op1.addParameter(name='wintitle', value='HF System', format='str')
32 op1.addParameter(name='save', value='/home/ci-81/Pictures', format='str')
35 op1.addParameter(name='save', value='/home/ci-81/Pictures', format='str')
33 op1.addParameter(name='show', value='0', format='bool')
36 op1.addParameter(name='show', value='0', format='bool')
34 op1.addParameter(name='zmin', value='-110', format='float')
37 op1.addParameter(name='zmin', value='-110', format='float')
35 op1.addParameter(name='zmax', value='-50', format='float')
38 op1.addParameter(name='zmax', value='-50', format='float')
36 op1.addParameter(name='colormap', value='jet', format='str')
39 op1.addParameter(name='colormap', value='jet', format='str')
37 #
38 op2 = proc1.addOperation(name='PlotCOHData', optype='other')
39 op2.addParameter(name='wintitle', value='HF System', format='str')
40 op2.addParameter(name='zmin', value='0.001', format='float')
41 op2.addParameter(name='zmax', value='1', format='float')
42 op2.addParameter(name='save', value='/home/ci-81/Pictures', format='str')
43 op2.addParameter(name='colormap', value='jet', format='str')
44 op2.addParameter(name='show', value='0', format='bool')
45 # #
46
40
47 op6 = proc1.addOperation(name='PlotPHASEData', optype='other')
48 op6.addParameter(name='wintitle', value='HF System', format='str')
49 op6.addParameter(name='save', value='/home/ci-81/Pictures', format='str')
50 op6.addParameter(name='show', value='1', format='bool')
51 #
52
41
53 # proc2 = controllerObj.addProcUnit(name='ReceiverData')
42 # proc2 = controllerObj.addProcUnit(name='ReceiverData')
54 # proc2.addParameter(name='server', value='juanca', format='str')
43 # proc2.addParameter(name='server', value='juanca', format='str')
55 # proc2.addParameter(name='plottypes', value='snr,dop', format='str')
44 # proc2.addParameter(name='plottypes', value='snr,dop', format='str')
56 #
45 #
57 """
46 """
47
48 op2 = proc1.addOperation(name='PlotCOHData', optype='other')
49 op2.addParameter(name='wintitle', value='HF System Coh', format='str')
50 op2.addParameter(name='zmin', value='0.001', format='float')
51 op2.addParameter(name='zmax', value='1', format='float')
52 op2.addParameter(name='save', value='/home/ci-81/Pictures', format='str')
53 op2.addParameter(name='colormap', value='jet', format='str')
54 op2.addParameter(name='show', value='1', format='bool')
55
58 op3 = proc1.addOperation(name='PlotSNRData', optype='other')
56 op3 = proc1.addOperation(name='PlotSNRData', optype='other')
59 op3.addParameter(name='wintitle', value='HF System SNR0', format='str')
57 op3.addParameter(name='wintitle', value='HF System SNR0', format='str')
60 op3.addParameter(name='save', value='/home/ci-81/Pictures', format='str')
58 op3.addParameter(name='save', value='/home/ci-81/Pictures', format='str')
61 op3.addParameter(name='show', value='0', format='bool')
59 op3.addParameter(name='show', value='1', format='bool')
62 op3.addParameter(name='zmin', value='-10', format='int')
60 op3.addParameter(name='zmin', value='-10', format='int')
63 op3.addParameter(name='zmax', value='30', format='int')
61 op3.addParameter(name='zmax', value='30', format='int')
64 op3.addParameter(name='SNRthresh', value='0', format='float')
62 op3.addParameter(name='SNRthresh', value='0', format='float')
65 op3.addParameter(name='ind_plt_ch',value='1',format = 'bool')
63 op3.addParameter(name='ind_plt_ch',value='1',format = 'bool')
66
64
67 #
65
68 op5 = proc1.addOperation(name='PlotDOPData', optype='other')
66 op5 = proc1.addOperation(name='PlotDOPData', optype='other')
69 op5.addParameter(name='wintitle', value='HF System DOP', format='str')
67 op5.addParameter(name='wintitle', value='HF System DOP', format='str')
70 op5.addParameter(name='save', value='/home/ci-81/Pictures', format='str')
68 op5.addParameter(name='save', value='/home/ci-81/Pictures', format='str')
71 op5.addParameter(name='show', value='1', format='bool')
69 op5.addParameter(name='show', value='1', format='bool')
72 op5.addParameter(name='zmin', value='-120', format='float')
70 op5.addParameter(name='zmin', value='-140', format='float')
73 op5.addParameter(name='zmax', value='120', format='float')
71 op5.addParameter(name='zmax', value='140', format='float')
74 op5.addParameter(name='colormap', value='RdBu_r', format='str')
72 op5.addParameter(name='colormap', value='RdBu_r', format='str')
75 op5.addParameter(name='ind_plt_ch',value='1',format = 'bool')
73 op5.addParameter(name='ind_plt_ch',value='1',format = 'bool')
76 """
74
77 op4 = proc1.addOperation(name='PlotSNRData1', optype='other')
75 # op4 = proc1.addOperation(name='PlotSNRData1', optype='other')
78 op4.addParameter(name='wintitle', value='HF System SNR1', format='str')
76 # op4.addParameter(name='wintitle', value='HF System SNR1', format='str')
79 op4.addParameter(name='save', value='/home/ci-81/Pictures', format='str')
77 # op4.addParameter(name='save', value='/home/ci-81/Pictures', format='str')
80 op4.addParameter(name='show', value='0', format='bool')
78 # op4.addParameter(name='show', value='0', format='bool')
81 """
79
80 op6 = proc1.addOperation(name='PlotPHASEData', optype='other')
81 op6.addParameter(name='wintitle', value='HF System', format='str')
82 op6.addParameter(name='colormap', value='RdBu_r', format='str')
83 op6.addParameter(name='zmin', value='-180', format='float')
84 op6.addParameter(name='zmax', value='180', format='float')
85 op6.addParameter(name='save', value='/home/ci-81/Pictures', format='str')
86 op6.addParameter(name='show', value='1', format='bool')
87 op6.addParameter(name='ind_plt_ch',value='0',format = 'bool')
88 """ """
82 controllerObj.start()
89 controllerObj.start()
@@ -1,1 +1,1
1 <Project description="HF_EXAMPLE" id="191" name="test01"><ReadUnit datatype="SpectraReader" id="1911" inputId="0" name="SpectraReader"><Operation id="19111" name="run" priority="1" type="self"><Parameter format="str" id="191111" name="datatype" value="SpectraReader" /><Parameter format="str" id="191112" name="path" value="/media/ci-81/Huancayo/DATA/hfradar_2016/pdata/sp1_f1" /><Parameter format="date" id="191113" name="startDate" value="2016/04/24" /><Parameter format="date" id="191114" name="endDate" value="2016/04/24" /><Parameter format="time" id="191115" name="startTime" value="00:00:00" /><Parameter format="time" id="191116" name="endTime" value="23:59:59" /><Parameter format="int" id="191118" name="cursor" value="8" /><Parameter format="int" id="191119" name="skip" value="18" /><Parameter format="int" id="191120" name="delay" value="10" /><Parameter format="int" id="191121" name="walk" value="1" /><Parameter format="int" id="191122" name="online" value="0" /></Operation></ReadUnit><ProcUnit datatype="ParametersProc" id="1913" inputId="1911" name="ParametersProc"><Operation id="19131" name="run" priority="1" type="self" /><Operation id="19132" name="SpectralMoments" priority="2" type="other" /><Operation id="19133" name="PublishData" priority="3" type="other"><Parameter format="int" id="191331" name="zeromq" value="1" /></Operation></ProcUnit><ProcUnit datatype="Spectra" id="1912" inputId="1911" name="SpectraProc"><Operation id="19121" name="run" priority="1" type="self" /><Operation id="19122" name="removeInterference" priority="2" type="self" /></ProcUnit></Project> No newline at end of file
1 <Project description="HF_EXAMPLE" id="191" name="test01"><ReadUnit datatype="SpectraReader" id="1911" inputId="0" name="SpectraReader"><Operation id="19111" name="run" priority="1" type="self"><Parameter format="str" id="191111" name="datatype" value="SpectraReader" /><Parameter format="str" id="191112" name="path" value="/media/ci-81/Huancayo/DATA/hfradar_2016/pdata/sp1_f1" /><Parameter format="date" id="191113" name="startDate" value="2016/04/23" /><Parameter format="date" id="191114" name="endDate" value="2016/04/23" /><Parameter format="time" id="191115" name="startTime" value="00:00:00" /><Parameter format="time" id="191116" name="endTime" value="23:59:59" /><Parameter format="int" id="191118" name="cursor" value="8" /><Parameter format="int" id="191119" name="skip" value="16" /><Parameter format="int" id="191120" name="delay" value="10" /><Parameter format="int" id="191121" name="walk" value="1" /><Parameter format="int" id="191122" name="online" value="0" /></Operation></ReadUnit><ProcUnit datatype="ParametersProc" id="1913" inputId="1911" name="ParametersProc"><Operation id="19131" name="run" priority="1" type="self" /><Operation id="19132" name="SpectralMoments" priority="2" type="other" /><Operation id="19133" name="PublishData" priority="3" type="other"><Parameter format="int" id="191331" name="zeromq" value="1" /></Operation></ProcUnit><ProcUnit datatype="Spectra" id="1912" inputId="1911" name="SpectraProc"><Operation id="19121" name="run" priority="1" type="self" /><Operation id="19122" name="removeInterference" priority="2" type="self" /></ProcUnit></Project> No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now