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