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