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