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