The requested changes are too big and content was truncated. Show full diff
This diff has been collapsed as it changes many lines, (628 lines changed) Show them Hide them | |||
@@ -0,0 +1,628 | |||
|
1 | import os | |
|
2 | import datetime | |
|
3 | import numpy | |
|
4 | ||
|
5 | from schainpy.model.graphics.jroplot_base import Plot, plt | |
|
6 | from schainpy.model.graphics.jroplot_spectra import SpectraPlot, RTIPlot, CoherencePlot, SpectraCutPlot | |
|
7 | from schainpy.utils import log | |
|
8 | # libreria wradlib | |
|
9 | import wradlib as wrl | |
|
10 | ||
|
11 | EARTH_RADIUS = 6.3710e3 | |
|
12 | ||
|
13 | ||
|
14 | def ll2xy(lat1, lon1, lat2, lon2): | |
|
15 | ||
|
16 | p = 0.017453292519943295 | |
|
17 | a = 0.5 - numpy.cos((lat2 - lat1) * p)/2 + numpy.cos(lat1 * p) * \ | |
|
18 | numpy.cos(lat2 * p) * (1 - numpy.cos((lon2 - lon1) * p)) / 2 | |
|
19 | r = 12742 * numpy.arcsin(numpy.sqrt(a)) | |
|
20 | theta = numpy.arctan2(numpy.sin((lon2-lon1)*p)*numpy.cos(lat2*p), numpy.cos(lat1*p) | |
|
21 | * numpy.sin(lat2*p)-numpy.sin(lat1*p)*numpy.cos(lat2*p)*numpy.cos((lon2-lon1)*p)) | |
|
22 | theta = -theta + numpy.pi/2 | |
|
23 | return r*numpy.cos(theta), r*numpy.sin(theta) | |
|
24 | ||
|
25 | ||
|
26 | def km2deg(km): | |
|
27 | ''' | |
|
28 | Convert distance in km to degrees | |
|
29 | ''' | |
|
30 | ||
|
31 | return numpy.rad2deg(km/EARTH_RADIUS) | |
|
32 | ||
|
33 | ||
|
34 | ||
|
35 | class SpectralMomentsPlot(SpectraPlot): | |
|
36 | ''' | |
|
37 | Plot for Spectral Moments | |
|
38 | ''' | |
|
39 | CODE = 'spc_moments' | |
|
40 | # colormap = 'jet' | |
|
41 | # plot_type = 'pcolor' | |
|
42 | ||
|
43 | class DobleGaussianPlot(SpectraPlot): | |
|
44 | ''' | |
|
45 | Plot for Double Gaussian Plot | |
|
46 | ''' | |
|
47 | CODE = 'gaussian_fit' | |
|
48 | # colormap = 'jet' | |
|
49 | # plot_type = 'pcolor' | |
|
50 | ||
|
51 | class DoubleGaussianSpectraCutPlot(SpectraCutPlot): | |
|
52 | ''' | |
|
53 | Plot SpectraCut with Double Gaussian Fit | |
|
54 | ''' | |
|
55 | CODE = 'cut_gaussian_fit' | |
|
56 | ||
|
57 | class SnrPlot(RTIPlot): | |
|
58 | ''' | |
|
59 | Plot for SNR Data | |
|
60 | ''' | |
|
61 | ||
|
62 | CODE = 'snr' | |
|
63 | colormap = 'jet' | |
|
64 | ||
|
65 | def update(self, dataOut): | |
|
66 | ||
|
67 | data = { | |
|
68 | 'snr': 10*numpy.log10(dataOut.data_snr) | |
|
69 | } | |
|
70 | ||
|
71 | return data, {} | |
|
72 | ||
|
73 | class DopplerPlot(RTIPlot): | |
|
74 | ''' | |
|
75 | Plot for DOPPLER Data (1st moment) | |
|
76 | ''' | |
|
77 | ||
|
78 | CODE = 'dop' | |
|
79 | colormap = 'jet' | |
|
80 | ||
|
81 | def update(self, dataOut): | |
|
82 | ||
|
83 | data = { | |
|
84 | 'dop': 10*numpy.log10(dataOut.data_dop) | |
|
85 | } | |
|
86 | ||
|
87 | return data, {} | |
|
88 | ||
|
89 | class PowerPlot(RTIPlot): | |
|
90 | ''' | |
|
91 | Plot for Power Data (0 moment) | |
|
92 | ''' | |
|
93 | ||
|
94 | CODE = 'pow' | |
|
95 | colormap = 'jet' | |
|
96 | ||
|
97 | def update(self, dataOut): | |
|
98 | ||
|
99 | data = { | |
|
100 | 'pow': 10*numpy.log10(dataOut.data_pow/dataOut.normFactor) | |
|
101 | } | |
|
102 | ||
|
103 | return data, {} | |
|
104 | ||
|
105 | class SpectralWidthPlot(RTIPlot): | |
|
106 | ''' | |
|
107 | Plot for Spectral Width Data (2nd moment) | |
|
108 | ''' | |
|
109 | ||
|
110 | CODE = 'width' | |
|
111 | colormap = 'jet' | |
|
112 | ||
|
113 | def update(self, dataOut): | |
|
114 | ||
|
115 | data = { | |
|
116 | 'width': dataOut.data_width | |
|
117 | } | |
|
118 | ||
|
119 | return data, {} | |
|
120 | ||
|
121 | class SkyMapPlot(Plot): | |
|
122 | ''' | |
|
123 | Plot for meteors detection data | |
|
124 | ''' | |
|
125 | ||
|
126 | CODE = 'param' | |
|
127 | ||
|
128 | def setup(self): | |
|
129 | ||
|
130 | self.ncols = 1 | |
|
131 | self.nrows = 1 | |
|
132 | self.width = 7.2 | |
|
133 | self.height = 7.2 | |
|
134 | self.nplots = 1 | |
|
135 | self.xlabel = 'Zonal Zenith Angle (deg)' | |
|
136 | self.ylabel = 'Meridional Zenith Angle (deg)' | |
|
137 | self.polar = True | |
|
138 | self.ymin = -180 | |
|
139 | self.ymax = 180 | |
|
140 | self.colorbar = False | |
|
141 | ||
|
142 | def plot(self): | |
|
143 | ||
|
144 | arrayParameters = numpy.concatenate(self.data['param']) | |
|
145 | error = arrayParameters[:, -1] | |
|
146 | indValid = numpy.where(error == 0)[0] | |
|
147 | finalMeteor = arrayParameters[indValid, :] | |
|
148 | finalAzimuth = finalMeteor[:, 3] | |
|
149 | finalZenith = finalMeteor[:, 4] | |
|
150 | ||
|
151 | x = finalAzimuth * numpy.pi / 180 | |
|
152 | y = finalZenith | |
|
153 | ||
|
154 | ax = self.axes[0] | |
|
155 | ||
|
156 | if ax.firsttime: | |
|
157 | ax.plot = ax.plot(x, y, 'bo', markersize=5)[0] | |
|
158 | else: | |
|
159 | ax.plot.set_data(x, y) | |
|
160 | ||
|
161 | dt1 = self.getDateTime(self.data.min_time).strftime('%y/%m/%d %H:%M:%S') | |
|
162 | dt2 = self.getDateTime(self.data.max_time).strftime('%y/%m/%d %H:%M:%S') | |
|
163 | title = 'Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n' % (dt1, | |
|
164 | dt2, | |
|
165 | len(x)) | |
|
166 | self.titles[0] = title | |
|
167 | ||
|
168 | ||
|
169 | class GenericRTIPlot(Plot): | |
|
170 | ''' | |
|
171 | Plot for data_xxxx object | |
|
172 | ''' | |
|
173 | ||
|
174 | CODE = 'param' | |
|
175 | colormap = 'viridis' | |
|
176 | plot_type = 'pcolorbuffer' | |
|
177 | ||
|
178 | def setup(self): | |
|
179 | self.xaxis = 'time' | |
|
180 | self.ncols = 1 | |
|
181 | self.nrows = self.data.shape('param')[0] | |
|
182 | self.nplots = self.nrows | |
|
183 | self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.08, 'right':0.95, 'top': 0.95}) | |
|
184 | ||
|
185 | if not self.xlabel: | |
|
186 | self.xlabel = 'Time' | |
|
187 | ||
|
188 | self.ylabel = 'Range [km]' | |
|
189 | if not self.titles: | |
|
190 | self.titles = ['Param {}'.format(x) for x in range(self.nrows)] | |
|
191 | ||
|
192 | def update(self, dataOut): | |
|
193 | ||
|
194 | data = { | |
|
195 | 'param' : numpy.concatenate([getattr(dataOut, attr) for attr in self.attr_data], axis=0) | |
|
196 | } | |
|
197 | ||
|
198 | meta = {} | |
|
199 | ||
|
200 | return data, meta | |
|
201 | ||
|
202 | def plot(self): | |
|
203 | # self.data.normalize_heights() | |
|
204 | self.x = self.data.times | |
|
205 | self.y = self.data.yrange | |
|
206 | self.z = self.data['param'] | |
|
207 | ||
|
208 | self.z = 10*numpy.log10(self.z) | |
|
209 | ||
|
210 | self.z = numpy.ma.masked_invalid(self.z) | |
|
211 | ||
|
212 | if self.decimation is None: | |
|
213 | x, y, z = self.fill_gaps(self.x, self.y, self.z) | |
|
214 | else: | |
|
215 | x, y, z = self.fill_gaps(*self.decimate()) | |
|
216 | ||
|
217 | for n, ax in enumerate(self.axes): | |
|
218 | ||
|
219 | self.zmax = self.zmax if self.zmax is not None else numpy.max( | |
|
220 | self.z[n]) | |
|
221 | self.zmin = self.zmin if self.zmin is not None else numpy.min( | |
|
222 | self.z[n]) | |
|
223 | ||
|
224 | if ax.firsttime: | |
|
225 | if self.zlimits is not None: | |
|
226 | self.zmin, self.zmax = self.zlimits[n] | |
|
227 | ||
|
228 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], | |
|
229 | vmin=self.zmin, | |
|
230 | vmax=self.zmax, | |
|
231 | cmap=self.cmaps[n] | |
|
232 | ) | |
|
233 | else: | |
|
234 | if self.zlimits is not None: | |
|
235 | self.zmin, self.zmax = self.zlimits[n] | |
|
236 | ax.collections.remove(ax.collections[0]) | |
|
237 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], | |
|
238 | vmin=self.zmin, | |
|
239 | vmax=self.zmax, | |
|
240 | cmap=self.cmaps[n] | |
|
241 | ) | |
|
242 | ||
|
243 | ||
|
244 | class PolarMapPlot(Plot): | |
|
245 | ''' | |
|
246 | Plot for weather radar | |
|
247 | ''' | |
|
248 | ||
|
249 | CODE = 'param' | |
|
250 | colormap = 'seismic' | |
|
251 | ||
|
252 | def setup(self): | |
|
253 | self.ncols = 1 | |
|
254 | self.nrows = 1 | |
|
255 | self.width = 9 | |
|
256 | self.height = 8 | |
|
257 | self.mode = self.data.meta['mode'] | |
|
258 | if self.channels is not None: | |
|
259 | self.nplots = len(self.channels) | |
|
260 | self.nrows = len(self.channels) | |
|
261 | else: | |
|
262 | self.nplots = self.data.shape(self.CODE)[0] | |
|
263 | self.nrows = self.nplots | |
|
264 | self.channels = list(range(self.nplots)) | |
|
265 | if self.mode == 'E': | |
|
266 | self.xlabel = 'Longitude' | |
|
267 | self.ylabel = 'Latitude' | |
|
268 | else: | |
|
269 | self.xlabel = 'Range (km)' | |
|
270 | self.ylabel = 'Height (km)' | |
|
271 | self.bgcolor = 'white' | |
|
272 | self.cb_labels = self.data.meta['units'] | |
|
273 | self.lat = self.data.meta['latitude'] | |
|
274 | self.lon = self.data.meta['longitude'] | |
|
275 | self.xmin, self.xmax = float( | |
|
276 | km2deg(self.xmin) + self.lon), float(km2deg(self.xmax) + self.lon) | |
|
277 | self.ymin, self.ymax = float( | |
|
278 | km2deg(self.ymin) + self.lat), float(km2deg(self.ymax) + self.lat) | |
|
279 | # self.polar = True | |
|
280 | ||
|
281 | def plot(self): | |
|
282 | ||
|
283 | for n, ax in enumerate(self.axes): | |
|
284 | data = self.data['param'][self.channels[n]] | |
|
285 | ||
|
286 | zeniths = numpy.linspace( | |
|
287 | 0, self.data.meta['max_range'], data.shape[1]) | |
|
288 | if self.mode == 'E': | |
|
289 | azimuths = -numpy.radians(self.data.yrange)+numpy.pi/2 | |
|
290 | r, theta = numpy.meshgrid(zeniths, azimuths) | |
|
291 | x, y = r*numpy.cos(theta)*numpy.cos(numpy.radians(self.data.meta['elevation'])), r*numpy.sin( | |
|
292 | theta)*numpy.cos(numpy.radians(self.data.meta['elevation'])) | |
|
293 | x = km2deg(x) + self.lon | |
|
294 | y = km2deg(y) + self.lat | |
|
295 | else: | |
|
296 | azimuths = numpy.radians(self.data.yrange) | |
|
297 | r, theta = numpy.meshgrid(zeniths, azimuths) | |
|
298 | x, y = r*numpy.cos(theta), r*numpy.sin(theta) | |
|
299 | self.y = zeniths | |
|
300 | ||
|
301 | if ax.firsttime: | |
|
302 | if self.zlimits is not None: | |
|
303 | self.zmin, self.zmax = self.zlimits[n] | |
|
304 | ax.plt = ax.pcolormesh( # r, theta, numpy.ma.array(data, mask=numpy.isnan(data)), | |
|
305 | x, y, numpy.ma.array(data, mask=numpy.isnan(data)), | |
|
306 | vmin=self.zmin, | |
|
307 | vmax=self.zmax, | |
|
308 | cmap=self.cmaps[n]) | |
|
309 | else: | |
|
310 | if self.zlimits is not None: | |
|
311 | self.zmin, self.zmax = self.zlimits[n] | |
|
312 | ax.collections.remove(ax.collections[0]) | |
|
313 | ax.plt = ax.pcolormesh( # r, theta, numpy.ma.array(data, mask=numpy.isnan(data)), | |
|
314 | x, y, numpy.ma.array(data, mask=numpy.isnan(data)), | |
|
315 | vmin=self.zmin, | |
|
316 | vmax=self.zmax, | |
|
317 | cmap=self.cmaps[n]) | |
|
318 | ||
|
319 | if self.mode == 'A': | |
|
320 | continue | |
|
321 | ||
|
322 | # plot district names | |
|
323 | f = open('/data/workspace/schain_scripts/distrito.csv') | |
|
324 | for line in f: | |
|
325 | label, lon, lat = [s.strip() for s in line.split(',') if s] | |
|
326 | lat = float(lat) | |
|
327 | lon = float(lon) | |
|
328 | # ax.plot(lon, lat, '.b', ms=2) | |
|
329 | ax.text(lon, lat, label.decode('utf8'), ha='center', | |
|
330 | va='bottom', size='8', color='black') | |
|
331 | ||
|
332 | # plot limites | |
|
333 | limites = [] | |
|
334 | tmp = [] | |
|
335 | for line in open('/data/workspace/schain_scripts/lima.csv'): | |
|
336 | if '#' in line: | |
|
337 | if tmp: | |
|
338 | limites.append(tmp) | |
|
339 | tmp = [] | |
|
340 | continue | |
|
341 | values = line.strip().split(',') | |
|
342 | tmp.append((float(values[0]), float(values[1]))) | |
|
343 | for points in limites: | |
|
344 | ax.add_patch( | |
|
345 | Polygon(points, ec='k', fc='none', ls='--', lw=0.5)) | |
|
346 | ||
|
347 | # plot Cuencas | |
|
348 | for cuenca in ('rimac', 'lurin', 'mala', 'chillon', 'chilca', 'chancay-huaral'): | |
|
349 | f = open('/data/workspace/schain_scripts/{}.csv'.format(cuenca)) | |
|
350 | values = [line.strip().split(',') for line in f] | |
|
351 | points = [(float(s[0]), float(s[1])) for s in values] | |
|
352 | ax.add_patch(Polygon(points, ec='b', fc='none')) | |
|
353 | ||
|
354 | # plot grid | |
|
355 | for r in (15, 30, 45, 60): | |
|
356 | ax.add_artist(plt.Circle((self.lon, self.lat), | |
|
357 | km2deg(r), color='0.6', fill=False, lw=0.2)) | |
|
358 | ax.text( | |
|
359 | self.lon + (km2deg(r))*numpy.cos(60*numpy.pi/180), | |
|
360 | self.lat + (km2deg(r))*numpy.sin(60*numpy.pi/180), | |
|
361 | '{}km'.format(r), | |
|
362 | ha='center', va='bottom', size='8', color='0.6', weight='heavy') | |
|
363 | ||
|
364 | if self.mode == 'E': | |
|
365 | title = 'El={}$^\circ$'.format(self.data.meta['elevation']) | |
|
366 | label = 'E{:02d}'.format(int(self.data.meta['elevation'])) | |
|
367 | else: | |
|
368 | title = 'Az={}$^\circ$'.format(self.data.meta['azimuth']) | |
|
369 | label = 'A{:02d}'.format(int(self.data.meta['azimuth'])) | |
|
370 | ||
|
371 | self.save_labels = ['{}-{}'.format(lbl, label) for lbl in self.labels] | |
|
372 | self.titles = ['{} {}'.format( | |
|
373 | self.data.parameters[x], title) for x in self.channels] | |
|
374 | ||
|
375 | class WeatherPlot(Plot): | |
|
376 | CODE = 'weather' | |
|
377 | plot_name = 'weather' | |
|
378 | plot_type = 'ppistyle' | |
|
379 | buffering = False | |
|
380 | ||
|
381 | def setup(self): | |
|
382 | self.ncols = 1 | |
|
383 | self.nrows = 1 | |
|
384 | self.nplots= 1 | |
|
385 | self.ylabel= 'Range [Km]' | |
|
386 | self.titles= ['Weather'] | |
|
387 | self.colorbar=False | |
|
388 | self.width =8 | |
|
389 | self.height =8 | |
|
390 | self.ini =0 | |
|
391 | self.len_azi =0 | |
|
392 | self.buffer_ini = None | |
|
393 | self.buffer_azi = None | |
|
394 | self.plots_adjust.update({'wspace': 0.4, 'hspace':0.4, 'left': 0.1, 'right': 0.9, 'bottom': 0.08}) | |
|
395 | self.flag =0 | |
|
396 | self.indicador= 0 | |
|
397 | ||
|
398 | def update(self, dataOut): | |
|
399 | ||
|
400 | data = {} | |
|
401 | meta = {} | |
|
402 | data['weather'] = 10*numpy.log10(dataOut.data_360[0]/(250**2)) | |
|
403 | data['azi'] = dataOut.data_azi | |
|
404 | ||
|
405 | return data, meta | |
|
406 | ||
|
407 | def plot(self): | |
|
408 | thisDatetime = datetime.datetime.utcfromtimestamp(self.data.times[-1]) | |
|
409 | print("--------------------------------------",self.ini,"-----------------------------------") | |
|
410 | print("time",self.data.times[-1]) | |
|
411 | data = self.data[-1] | |
|
412 | #print("debug_0", data) | |
|
413 | tmp_h = (data['weather'].shape[1])/10.0 | |
|
414 | #print("debug_1",tmp_h) | |
|
415 | stoprange = float(tmp_h*1.5)#stoprange = float(33*1.5) por ahora 400 | |
|
416 | rangestep = float(0.15) | |
|
417 | r = numpy.arange(0, stoprange, rangestep) | |
|
418 | self.y = 2*r | |
|
419 | print("---------------") | |
|
420 | tmp_v = data['weather'] | |
|
421 | #print("tmp_v",tmp_v.shape) | |
|
422 | tmp_z = data['azi'] | |
|
423 | print("tmp_z-------------->",tmp_z) | |
|
424 | ##if self.ini==0: | |
|
425 | ## tmp_z= [0,1,2,3,4,5,6,7,8,9] | |
|
426 | ||
|
427 | #print("tmp_z",tmp_z.shape) | |
|
428 | res = 1 | |
|
429 | step = (360/(res*tmp_v.shape[0])) | |
|
430 | #print("step",step) | |
|
431 | mode = 1 | |
|
432 | if mode==0: | |
|
433 | #print("self.ini",self.ini) | |
|
434 | val = numpy.mean(tmp_v[:,0]) | |
|
435 | self.len_azi = len(tmp_z) | |
|
436 | ones = numpy.ones([(360-tmp_v.shape[0]),tmp_v.shape[1]])*val | |
|
437 | self.buffer_ini = numpy.vstack((tmp_v,ones)) | |
|
438 | ||
|
439 | n = ((360/res)-len(tmp_z)) | |
|
440 | start = tmp_z[-1]+res | |
|
441 | end = tmp_z[0]-res | |
|
442 | if start>end: | |
|
443 | end = end+360 | |
|
444 | azi_zeros = numpy.linspace(start,end,int(n)) | |
|
445 | azi_zeros = numpy.where(azi_zeros>360,azi_zeros-360,azi_zeros) | |
|
446 | self.buffer_ini_azi = numpy.hstack((tmp_z,azi_zeros)) | |
|
447 | self.ini = self.ini+1 | |
|
448 | ||
|
449 | if mode==1: | |
|
450 | #print("################") | |
|
451 | #print("################") | |
|
452 | #print("mode",self.ini) | |
|
453 | #print("self.ini",self.ini) | |
|
454 | if self.ini==0: | |
|
455 | res = 1 | |
|
456 | step = (360/(res*tmp_v.shape[0])) | |
|
457 | val = numpy.mean(tmp_v[:,0]) | |
|
458 | self.len_azi = len(tmp_z) | |
|
459 | self.buf_tmp = tmp_v | |
|
460 | ones = numpy.ones([(360-tmp_v.shape[0]),tmp_v.shape[1]])*val | |
|
461 | self.buffer_ini = numpy.vstack((tmp_v,ones)) | |
|
462 | ||
|
463 | n = ((360/res)-len(tmp_z)) | |
|
464 | start = tmp_z[-1]+res | |
|
465 | end = tmp_z[0]-res | |
|
466 | if start>end: | |
|
467 | end =end+360 | |
|
468 | azi_zeros = numpy.linspace(start,end,int(n)) | |
|
469 | azi_zeros = numpy.where(azi_zeros>360,azi_zeros-360,azi_zeros) | |
|
470 | self.buf_azi = tmp_z | |
|
471 | self.buffer_ini_azi = numpy.hstack((tmp_z,azi_zeros)) | |
|
472 | self.ini = self.ini+1 | |
|
473 | elif 0<self.ini<step: | |
|
474 | ''' | |
|
475 | if self.ini>31: | |
|
476 | start= tmp_z[0] | |
|
477 | end =tmp_z[-1] | |
|
478 | print("start","end",start,end) | |
|
479 | if self.ini==32: | |
|
480 | tmp_v=tmp_v+20 | |
|
481 | if self.ini==33: | |
|
482 | tmp_v=tmp_v+10 | |
|
483 | if self.ini==34: | |
|
484 | tmp_v=tmp_v+20 | |
|
485 | if self.ini==35: | |
|
486 | tmp_v=tmp_v+20 | |
|
487 | ''' | |
|
488 | self.buf_tmp= numpy.vstack((self.buf_tmp,tmp_v)) | |
|
489 | print("ERROR_INMINENTE",self.buf_tmp.shape) | |
|
490 | if self.buf_tmp.shape[0]==360: | |
|
491 | print("entre aqui en 360 grados") | |
|
492 | self.buffer_ini=self.buf_tmp | |
|
493 | else: | |
|
494 | # nuevo######### | |
|
495 | self.buffer_ini[0:self.buf_tmp.shape[0],:]=self.buf_tmp | |
|
496 | ################ | |
|
497 | #val=30.0 | |
|
498 | #ones = numpy.ones([(360-self.buf_tmp.shape[0]),self.buf_tmp.shape[1]])*val | |
|
499 | #self.buffer_ini = numpy.vstack((self.buf_tmp,ones)) | |
|
500 | ||
|
501 | self.buf_azi = numpy.hstack((self.buf_azi,tmp_z)) | |
|
502 | n = ((360/res)-len(self.buf_azi)) | |
|
503 | print("n----->",n) | |
|
504 | if n==0: | |
|
505 | self.buffer_ini_azi = self.buf_azi | |
|
506 | else: | |
|
507 | start = self.buf_azi[-1]+res | |
|
508 | end = self.buf_azi[0]-res | |
|
509 | print("start",start) | |
|
510 | print("end",end) | |
|
511 | if start>end: | |
|
512 | end =end+360 | |
|
513 | azi_zeros = numpy.linspace(start,end,int(n)) | |
|
514 | azi_zeros = numpy.where(azi_zeros>360,azi_zeros-360,azi_zeros) | |
|
515 | print("self.buf_azi",self.buf_azi[0]) | |
|
516 | print("tmp_Z 0 ",tmp_z[0]) | |
|
517 | print("tmp_Z -1",tmp_z[-1]) | |
|
518 | if tmp_z[0]<self.buf_azi[0] <tmp_z[-1]: | |
|
519 | print("activando indicador") | |
|
520 | self.indicador=1 | |
|
521 | if self.indicador==1: | |
|
522 | azi_zeros = numpy.ones(360-len(self.buf_azi))*(tmp_z[-1]+res) | |
|
523 | ###start = tmp_z[-1]+res | |
|
524 | ###end = tmp_z[0]-res | |
|
525 | ###if start>end: | |
|
526 | ### end =end+360 | |
|
527 | ###azi_zeros = numpy.linspace(start,end,int(n)) | |
|
528 | ###azi_zeros = numpy.where(azi_zeros>360,azi_zeros-360,azi_zeros) | |
|
529 | #print("azi_zeros",azi_zeros) | |
|
530 | ||
|
531 | ######self.buffer_ini_azi = numpy.hstack((self.buf_azi,azi_zeros)) | |
|
532 | #self.buffer_ini[0:tmv.shape[0],:]=tmp_v | |
|
533 | ##self.indicador=0 | |
|
534 | ||
|
535 | # self.indicador = True | |
|
536 | #if self.indicador==True: | |
|
537 | # azi_zeros = numpy.ones(360-len(self.buf_azi))*(tmp_z[-1]+res) | |
|
538 | ||
|
539 | #self.buf_azi = tmp_z | |
|
540 | self.buffer_ini_azi = numpy.hstack((self.buf_azi,azi_zeros)) | |
|
541 | ||
|
542 | if self.ini==step-1: | |
|
543 | start= tmp_z[0] | |
|
544 | end = tmp_z[-1] | |
|
545 | #print("start","end",start,end) | |
|
546 | ###print(self.buffer_ini_azi[:80]) | |
|
547 | self.ini = self.ini+1 | |
|
548 | ||
|
549 | else: | |
|
550 | step = (360/(res*tmp_v.shape[0])) | |
|
551 | # aqui estaba realizando el debug de simulacion | |
|
552 | # tmp_v=tmp_v +5 en cada step sumaba 5 | |
|
553 | # y el mismo valor despues de la primera vuelta | |
|
554 | #tmp_v=tmp_v+5+(self.ini-step)*1### aqui yo habia sumado 5 por las puras | |
|
555 | ||
|
556 | start= tmp_z[0] | |
|
557 | end = tmp_z[-1] | |
|
558 | #print("start","end",start,end) | |
|
559 | ###print(self.buffer_ini_azi[:120]) | |
|
560 | ||
|
561 | if step>=2: | |
|
562 | if self.flag<step-1: | |
|
563 | limit_i=self.buf_azi[len(tmp_z)*(self.flag+1)] | |
|
564 | limit_s=self.buf_azi[len(tmp_z)*(self.flag+2)-1] | |
|
565 | print("flag",self.flag,limit_i,limit_s) | |
|
566 | if limit_i< tmp_z[-1]< limit_s: | |
|
567 | index_i=int(numpy.where(tmp_z<=self.buf_azi[len(tmp_z)*(self.flag+1)])[0][-1]) | |
|
568 | tmp_r =int(numpy.where(self.buf_azi[(self.flag+1)*len(tmp_z):(self.flag+2)*len(tmp_z)]>=tmp_z[-1])[0][0]) | |
|
569 | print("tmp_r",tmp_r) | |
|
570 | index_f=(self.flag+1)*len(tmp_z)+tmp_r | |
|
571 | ||
|
572 | if len(tmp_z[index_i:])>len(self.buf_azi[len(tmp_z)*(self.flag+1):index_f]): | |
|
573 | final = len(self.buf_azi[len(tmp_z)*(self.flag+1):index_f]) | |
|
574 | else: | |
|
575 | final= len(tmp_z[index_i:]) | |
|
576 | self.buf_azi[len(tmp_z)*(self.flag+1):index_f]=tmp_z[index_i:index_i+final] | |
|
577 | self.buf_tmp[len(tmp_z)*(self.flag+1):index_f,:]=tmp_v[index_i:index_i+final,:] | |
|
578 | if limit_i<tmp_z[0]<limit_s: | |
|
579 | index_f =int(numpy.where(self.buf_azi>=tmp_z[-1])[0][0]) | |
|
580 | n_p =index_f-len(tmp_z)*(self.flag+1) | |
|
581 | if n_p>0: | |
|
582 | self.buf_azi[len(tmp_z)*(self.flag+1):index_f]=tmp_z[-1]*numpy.ones(n_p) | |
|
583 | self.buf_tmp[len(tmp_z)*(self.flag+1):index_f,:]=tmp_v[-1,:]*numpy.ones([n_p,tmp_v.shape[1]]) | |
|
584 | ||
|
585 | ''' | |
|
586 | if self.buf_azi[len(tmp_z)]<tmp_z[-1]<self.buf_azi[2*len(tmp_z)-1]: | |
|
587 | index_i= int(numpy.where(tmp_z <= self.buf_azi[len(tmp_z)])[0][-1]) | |
|
588 | index_f= int(numpy.where(self.buf_azi>=tmp_z[-1])[0][0]) | |
|
589 | #print("index",index_i,index_f) | |
|
590 | if len(tmp_z[index_i:])>len(self.buf_azi[len(tmp_z):index_f]): | |
|
591 | final = len(self.buf_azi[len(tmp_z):index_f]) | |
|
592 | else: | |
|
593 | final = len(tmp_z[index_i:]) | |
|
594 | self.buf_azi[len(tmp_z):index_f]=tmp_z[index_i:index_i+final] | |
|
595 | self.buf_tmp[len(tmp_z):index_f,:]=tmp_v[index_i:index_i+final,:] | |
|
596 | ''' | |
|
597 | self.buf_tmp[len(tmp_z)*(self.flag):len(tmp_z)*(self.flag+1),:]=tmp_v | |
|
598 | self.buf_azi[len(tmp_z)*(self.flag):len(tmp_z)*(self.flag+1)] = tmp_z | |
|
599 | self.buffer_ini=self.buf_tmp | |
|
600 | self.buffer_ini_azi = self.buf_azi | |
|
601 | ##print("--------salida------------") | |
|
602 | start= tmp_z[0] | |
|
603 | end = tmp_z[-1] | |
|
604 | ##print("start","end",start,end) | |
|
605 | ##print(self.buffer_ini_azi[:120]) | |
|
606 | self.ini= self.ini+1 | |
|
607 | self.flag = self.flag +1 | |
|
608 | if self.flag==step: | |
|
609 | self.flag=0 | |
|
610 | numpy.set_printoptions(suppress=True) | |
|
611 | print("buffer_ini_azi") | |
|
612 | print(self.buffer_ini_azi[:20]) | |
|
613 | print(self.buffer_ini_azi[-40:]) | |
|
614 | for i,ax in enumerate(self.axes): | |
|
615 | if ax.firsttime: | |
|
616 | plt.clf() | |
|
617 | cgax, pm = wrl.vis.plot_ppi(self.buffer_ini,r=r,az=self.buffer_ini_azi,fig=self.figures[0], proj='cg', vmin=1, vmax=60) | |
|
618 | else: | |
|
619 | plt.clf() | |
|
620 | cgax, pm = wrl.vis.plot_ppi(self.buffer_ini,r=r,az=self.buffer_ini_azi,fig=self.figures[0], proj='cg', vmin=1, vmax=60) | |
|
621 | caax = cgax.parasites[0] | |
|
622 | paax = cgax.parasites[1] | |
|
623 | cbar = plt.gcf().colorbar(pm, pad=0.075) | |
|
624 | caax.set_xlabel('x_range [km]') | |
|
625 | caax.set_ylabel('y_range [km]') | |
|
626 | plt.text(1.0, 1.05, 'azimuth '+str(thisDatetime)+"step"+str(self.ini), transform=caax.transAxes, va='bottom',ha='right') | |
|
627 | #import time | |
|
628 | #time.sleep(0.5) |
@@ -1,627 +1,518 | |||
|
1 | 1 | import os |
|
2 | 2 | import datetime |
|
3 | 3 | import numpy |
|
4 | 4 | |
|
5 | 5 | from schainpy.model.graphics.jroplot_base import Plot, plt |
|
6 | 6 | from schainpy.model.graphics.jroplot_spectra import SpectraPlot, RTIPlot, CoherencePlot, SpectraCutPlot |
|
7 | 7 | from schainpy.utils import log |
|
8 | 8 | # libreria wradlib |
|
9 | 9 | import wradlib as wrl |
|
10 | 10 | |
|
11 | 11 | EARTH_RADIUS = 6.3710e3 |
|
12 | 12 | |
|
13 | 13 | |
|
14 | 14 | def ll2xy(lat1, lon1, lat2, lon2): |
|
15 | 15 | |
|
16 | 16 | p = 0.017453292519943295 |
|
17 | 17 | a = 0.5 - numpy.cos((lat2 - lat1) * p)/2 + numpy.cos(lat1 * p) * \ |
|
18 | 18 | numpy.cos(lat2 * p) * (1 - numpy.cos((lon2 - lon1) * p)) / 2 |
|
19 | 19 | r = 12742 * numpy.arcsin(numpy.sqrt(a)) |
|
20 | 20 | theta = numpy.arctan2(numpy.sin((lon2-lon1)*p)*numpy.cos(lat2*p), numpy.cos(lat1*p) |
|
21 | 21 | * numpy.sin(lat2*p)-numpy.sin(lat1*p)*numpy.cos(lat2*p)*numpy.cos((lon2-lon1)*p)) |
|
22 | 22 | theta = -theta + numpy.pi/2 |
|
23 | 23 | return r*numpy.cos(theta), r*numpy.sin(theta) |
|
24 | 24 | |
|
25 | 25 | |
|
26 | 26 | def km2deg(km): |
|
27 | 27 | ''' |
|
28 | 28 | Convert distance in km to degrees |
|
29 | 29 | ''' |
|
30 | 30 | |
|
31 | 31 | return numpy.rad2deg(km/EARTH_RADIUS) |
|
32 | 32 | |
|
33 | 33 | |
|
34 | 34 | |
|
35 | 35 | class SpectralMomentsPlot(SpectraPlot): |
|
36 | 36 | ''' |
|
37 | 37 | Plot for Spectral Moments |
|
38 | 38 | ''' |
|
39 | 39 | CODE = 'spc_moments' |
|
40 | 40 | # colormap = 'jet' |
|
41 | 41 | # plot_type = 'pcolor' |
|
42 | 42 | |
|
43 | 43 | class DobleGaussianPlot(SpectraPlot): |
|
44 | 44 | ''' |
|
45 | 45 | Plot for Double Gaussian Plot |
|
46 | 46 | ''' |
|
47 | 47 | CODE = 'gaussian_fit' |
|
48 | 48 | # colormap = 'jet' |
|
49 | 49 | # plot_type = 'pcolor' |
|
50 | 50 | |
|
51 | 51 | class DoubleGaussianSpectraCutPlot(SpectraCutPlot): |
|
52 | 52 | ''' |
|
53 | 53 | Plot SpectraCut with Double Gaussian Fit |
|
54 | 54 | ''' |
|
55 | 55 | CODE = 'cut_gaussian_fit' |
|
56 | 56 | |
|
57 | 57 | class SnrPlot(RTIPlot): |
|
58 | 58 | ''' |
|
59 | 59 | Plot for SNR Data |
|
60 | 60 | ''' |
|
61 | 61 | |
|
62 | 62 | CODE = 'snr' |
|
63 | 63 | colormap = 'jet' |
|
64 | 64 | |
|
65 | 65 | def update(self, dataOut): |
|
66 | 66 | |
|
67 | 67 | data = { |
|
68 | 68 | 'snr': 10*numpy.log10(dataOut.data_snr) |
|
69 | 69 | } |
|
70 | 70 | |
|
71 | 71 | return data, {} |
|
72 | 72 | |
|
73 | 73 | class DopplerPlot(RTIPlot): |
|
74 | 74 | ''' |
|
75 | 75 | Plot for DOPPLER Data (1st moment) |
|
76 | 76 | ''' |
|
77 | 77 | |
|
78 | 78 | CODE = 'dop' |
|
79 | 79 | colormap = 'jet' |
|
80 | 80 | |
|
81 | 81 | def update(self, dataOut): |
|
82 | 82 | |
|
83 | 83 | data = { |
|
84 | 84 | 'dop': 10*numpy.log10(dataOut.data_dop) |
|
85 | 85 | } |
|
86 | 86 | |
|
87 | 87 | return data, {} |
|
88 | 88 | |
|
89 | 89 | class PowerPlot(RTIPlot): |
|
90 | 90 | ''' |
|
91 | 91 | Plot for Power Data (0 moment) |
|
92 | 92 | ''' |
|
93 | 93 | |
|
94 | 94 | CODE = 'pow' |
|
95 | 95 | colormap = 'jet' |
|
96 | 96 | |
|
97 | 97 | def update(self, dataOut): |
|
98 | 98 | |
|
99 | 99 | data = { |
|
100 | 100 | 'pow': 10*numpy.log10(dataOut.data_pow/dataOut.normFactor) |
|
101 | 101 | } |
|
102 | 102 | |
|
103 | 103 | return data, {} |
|
104 | 104 | |
|
105 | 105 | class SpectralWidthPlot(RTIPlot): |
|
106 | 106 | ''' |
|
107 | 107 | Plot for Spectral Width Data (2nd moment) |
|
108 | 108 | ''' |
|
109 | 109 | |
|
110 | 110 | CODE = 'width' |
|
111 | 111 | colormap = 'jet' |
|
112 | 112 | |
|
113 | 113 | def update(self, dataOut): |
|
114 | 114 | |
|
115 | 115 | data = { |
|
116 | 116 | 'width': dataOut.data_width |
|
117 | 117 | } |
|
118 | 118 | |
|
119 | 119 | return data, {} |
|
120 | 120 | |
|
121 | 121 | class SkyMapPlot(Plot): |
|
122 | 122 | ''' |
|
123 | 123 | Plot for meteors detection data |
|
124 | 124 | ''' |
|
125 | 125 | |
|
126 | 126 | CODE = 'param' |
|
127 | 127 | |
|
128 | 128 | def setup(self): |
|
129 | 129 | |
|
130 | 130 | self.ncols = 1 |
|
131 | 131 | self.nrows = 1 |
|
132 | 132 | self.width = 7.2 |
|
133 | 133 | self.height = 7.2 |
|
134 | 134 | self.nplots = 1 |
|
135 | 135 | self.xlabel = 'Zonal Zenith Angle (deg)' |
|
136 | 136 | self.ylabel = 'Meridional Zenith Angle (deg)' |
|
137 | 137 | self.polar = True |
|
138 | 138 | self.ymin = -180 |
|
139 | 139 | self.ymax = 180 |
|
140 | 140 | self.colorbar = False |
|
141 | 141 | |
|
142 | 142 | def plot(self): |
|
143 | 143 | |
|
144 | 144 | arrayParameters = numpy.concatenate(self.data['param']) |
|
145 | 145 | error = arrayParameters[:, -1] |
|
146 | 146 | indValid = numpy.where(error == 0)[0] |
|
147 | 147 | finalMeteor = arrayParameters[indValid, :] |
|
148 | 148 | finalAzimuth = finalMeteor[:, 3] |
|
149 | 149 | finalZenith = finalMeteor[:, 4] |
|
150 | 150 | |
|
151 | 151 | x = finalAzimuth * numpy.pi / 180 |
|
152 | 152 | y = finalZenith |
|
153 | 153 | |
|
154 | 154 | ax = self.axes[0] |
|
155 | 155 | |
|
156 | 156 | if ax.firsttime: |
|
157 | 157 | ax.plot = ax.plot(x, y, 'bo', markersize=5)[0] |
|
158 | 158 | else: |
|
159 | 159 | ax.plot.set_data(x, y) |
|
160 | 160 | |
|
161 | 161 | dt1 = self.getDateTime(self.data.min_time).strftime('%y/%m/%d %H:%M:%S') |
|
162 | 162 | dt2 = self.getDateTime(self.data.max_time).strftime('%y/%m/%d %H:%M:%S') |
|
163 | 163 | title = 'Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n' % (dt1, |
|
164 | 164 | dt2, |
|
165 | 165 | len(x)) |
|
166 | 166 | self.titles[0] = title |
|
167 | 167 | |
|
168 | 168 | |
|
169 | 169 | class GenericRTIPlot(Plot): |
|
170 | 170 | ''' |
|
171 | 171 | Plot for data_xxxx object |
|
172 | 172 | ''' |
|
173 | 173 | |
|
174 | 174 | CODE = 'param' |
|
175 | 175 | colormap = 'viridis' |
|
176 | 176 | plot_type = 'pcolorbuffer' |
|
177 | 177 | |
|
178 | 178 | def setup(self): |
|
179 | 179 | self.xaxis = 'time' |
|
180 | 180 | self.ncols = 1 |
|
181 | 181 | self.nrows = self.data.shape('param')[0] |
|
182 | 182 | self.nplots = self.nrows |
|
183 | 183 | self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.08, 'right':0.95, 'top': 0.95}) |
|
184 | 184 | |
|
185 | 185 | if not self.xlabel: |
|
186 | 186 | self.xlabel = 'Time' |
|
187 | 187 | |
|
188 | 188 | self.ylabel = 'Range [km]' |
|
189 | 189 | if not self.titles: |
|
190 | 190 | self.titles = ['Param {}'.format(x) for x in range(self.nrows)] |
|
191 | 191 | |
|
192 | 192 | def update(self, dataOut): |
|
193 | 193 | |
|
194 | 194 | data = { |
|
195 | 195 | 'param' : numpy.concatenate([getattr(dataOut, attr) for attr in self.attr_data], axis=0) |
|
196 | 196 | } |
|
197 | 197 | |
|
198 | 198 | meta = {} |
|
199 | 199 | |
|
200 | 200 | return data, meta |
|
201 | 201 | |
|
202 | 202 | def plot(self): |
|
203 | 203 | # self.data.normalize_heights() |
|
204 | 204 | self.x = self.data.times |
|
205 | 205 | self.y = self.data.yrange |
|
206 | 206 | self.z = self.data['param'] |
|
207 | 207 | |
|
208 | 208 | self.z = 10*numpy.log10(self.z) |
|
209 | 209 | |
|
210 | 210 | self.z = numpy.ma.masked_invalid(self.z) |
|
211 | 211 | |
|
212 | 212 | if self.decimation is None: |
|
213 | 213 | x, y, z = self.fill_gaps(self.x, self.y, self.z) |
|
214 | 214 | else: |
|
215 | 215 | x, y, z = self.fill_gaps(*self.decimate()) |
|
216 | 216 | |
|
217 | 217 | for n, ax in enumerate(self.axes): |
|
218 | 218 | |
|
219 | 219 | self.zmax = self.zmax if self.zmax is not None else numpy.max( |
|
220 | 220 | self.z[n]) |
|
221 | 221 | self.zmin = self.zmin if self.zmin is not None else numpy.min( |
|
222 | 222 | self.z[n]) |
|
223 | 223 | |
|
224 | 224 | if ax.firsttime: |
|
225 | 225 | if self.zlimits is not None: |
|
226 | 226 | self.zmin, self.zmax = self.zlimits[n] |
|
227 | 227 | |
|
228 | 228 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], |
|
229 | 229 | vmin=self.zmin, |
|
230 | 230 | vmax=self.zmax, |
|
231 | 231 | cmap=self.cmaps[n] |
|
232 | 232 | ) |
|
233 | 233 | else: |
|
234 | 234 | if self.zlimits is not None: |
|
235 | 235 | self.zmin, self.zmax = self.zlimits[n] |
|
236 | 236 | ax.collections.remove(ax.collections[0]) |
|
237 | 237 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], |
|
238 | 238 | vmin=self.zmin, |
|
239 | 239 | vmax=self.zmax, |
|
240 | 240 | cmap=self.cmaps[n] |
|
241 | 241 | ) |
|
242 | 242 | |
|
243 | 243 | |
|
244 | 244 | class PolarMapPlot(Plot): |
|
245 | 245 | ''' |
|
246 | 246 | Plot for weather radar |
|
247 | 247 | ''' |
|
248 | 248 | |
|
249 | 249 | CODE = 'param' |
|
250 | 250 | colormap = 'seismic' |
|
251 | 251 | |
|
252 | 252 | def setup(self): |
|
253 | 253 | self.ncols = 1 |
|
254 | 254 | self.nrows = 1 |
|
255 | 255 | self.width = 9 |
|
256 | 256 | self.height = 8 |
|
257 | 257 | self.mode = self.data.meta['mode'] |
|
258 | 258 | if self.channels is not None: |
|
259 | 259 | self.nplots = len(self.channels) |
|
260 | 260 | self.nrows = len(self.channels) |
|
261 | 261 | else: |
|
262 | 262 | self.nplots = self.data.shape(self.CODE)[0] |
|
263 | 263 | self.nrows = self.nplots |
|
264 | 264 | self.channels = list(range(self.nplots)) |
|
265 | 265 | if self.mode == 'E': |
|
266 | 266 | self.xlabel = 'Longitude' |
|
267 | 267 | self.ylabel = 'Latitude' |
|
268 | 268 | else: |
|
269 | 269 | self.xlabel = 'Range (km)' |
|
270 | 270 | self.ylabel = 'Height (km)' |
|
271 | 271 | self.bgcolor = 'white' |
|
272 | 272 | self.cb_labels = self.data.meta['units'] |
|
273 | 273 | self.lat = self.data.meta['latitude'] |
|
274 | 274 | self.lon = self.data.meta['longitude'] |
|
275 | 275 | self.xmin, self.xmax = float( |
|
276 | 276 | km2deg(self.xmin) + self.lon), float(km2deg(self.xmax) + self.lon) |
|
277 | 277 | self.ymin, self.ymax = float( |
|
278 | 278 | km2deg(self.ymin) + self.lat), float(km2deg(self.ymax) + self.lat) |
|
279 | 279 | # self.polar = True |
|
280 | 280 | |
|
281 | 281 | def plot(self): |
|
282 | 282 | |
|
283 | 283 | for n, ax in enumerate(self.axes): |
|
284 | 284 | data = self.data['param'][self.channels[n]] |
|
285 | 285 | |
|
286 | 286 | zeniths = numpy.linspace( |
|
287 | 287 | 0, self.data.meta['max_range'], data.shape[1]) |
|
288 | 288 | if self.mode == 'E': |
|
289 | 289 | azimuths = -numpy.radians(self.data.yrange)+numpy.pi/2 |
|
290 | 290 | r, theta = numpy.meshgrid(zeniths, azimuths) |
|
291 | 291 | x, y = r*numpy.cos(theta)*numpy.cos(numpy.radians(self.data.meta['elevation'])), r*numpy.sin( |
|
292 | 292 | theta)*numpy.cos(numpy.radians(self.data.meta['elevation'])) |
|
293 | 293 | x = km2deg(x) + self.lon |
|
294 | 294 | y = km2deg(y) + self.lat |
|
295 | 295 | else: |
|
296 | 296 | azimuths = numpy.radians(self.data.yrange) |
|
297 | 297 | r, theta = numpy.meshgrid(zeniths, azimuths) |
|
298 | 298 | x, y = r*numpy.cos(theta), r*numpy.sin(theta) |
|
299 | 299 | self.y = zeniths |
|
300 | 300 | |
|
301 | 301 | if ax.firsttime: |
|
302 | 302 | if self.zlimits is not None: |
|
303 | 303 | self.zmin, self.zmax = self.zlimits[n] |
|
304 | 304 | ax.plt = ax.pcolormesh( # r, theta, numpy.ma.array(data, mask=numpy.isnan(data)), |
|
305 | 305 | x, y, numpy.ma.array(data, mask=numpy.isnan(data)), |
|
306 | 306 | vmin=self.zmin, |
|
307 | 307 | vmax=self.zmax, |
|
308 | 308 | cmap=self.cmaps[n]) |
|
309 | 309 | else: |
|
310 | 310 | if self.zlimits is not None: |
|
311 | 311 | self.zmin, self.zmax = self.zlimits[n] |
|
312 | 312 | ax.collections.remove(ax.collections[0]) |
|
313 | 313 | ax.plt = ax.pcolormesh( # r, theta, numpy.ma.array(data, mask=numpy.isnan(data)), |
|
314 | 314 | x, y, numpy.ma.array(data, mask=numpy.isnan(data)), |
|
315 | 315 | vmin=self.zmin, |
|
316 | 316 | vmax=self.zmax, |
|
317 | 317 | cmap=self.cmaps[n]) |
|
318 | 318 | |
|
319 | 319 | if self.mode == 'A': |
|
320 | 320 | continue |
|
321 | 321 | |
|
322 | 322 | # plot district names |
|
323 | 323 | f = open('/data/workspace/schain_scripts/distrito.csv') |
|
324 | 324 | for line in f: |
|
325 | 325 | label, lon, lat = [s.strip() for s in line.split(',') if s] |
|
326 | 326 | lat = float(lat) |
|
327 | 327 | lon = float(lon) |
|
328 | 328 | # ax.plot(lon, lat, '.b', ms=2) |
|
329 | 329 | ax.text(lon, lat, label.decode('utf8'), ha='center', |
|
330 | 330 | va='bottom', size='8', color='black') |
|
331 | 331 | |
|
332 | 332 | # plot limites |
|
333 | 333 | limites = [] |
|
334 | 334 | tmp = [] |
|
335 | 335 | for line in open('/data/workspace/schain_scripts/lima.csv'): |
|
336 | 336 | if '#' in line: |
|
337 | 337 | if tmp: |
|
338 | 338 | limites.append(tmp) |
|
339 | 339 | tmp = [] |
|
340 | 340 | continue |
|
341 | 341 | values = line.strip().split(',') |
|
342 | 342 | tmp.append((float(values[0]), float(values[1]))) |
|
343 | 343 | for points in limites: |
|
344 | 344 | ax.add_patch( |
|
345 | 345 | Polygon(points, ec='k', fc='none', ls='--', lw=0.5)) |
|
346 | 346 | |
|
347 | 347 | # plot Cuencas |
|
348 | 348 | for cuenca in ('rimac', 'lurin', 'mala', 'chillon', 'chilca', 'chancay-huaral'): |
|
349 | 349 | f = open('/data/workspace/schain_scripts/{}.csv'.format(cuenca)) |
|
350 | 350 | values = [line.strip().split(',') for line in f] |
|
351 | 351 | points = [(float(s[0]), float(s[1])) for s in values] |
|
352 | 352 | ax.add_patch(Polygon(points, ec='b', fc='none')) |
|
353 | 353 | |
|
354 | 354 | # plot grid |
|
355 | 355 | for r in (15, 30, 45, 60): |
|
356 | 356 | ax.add_artist(plt.Circle((self.lon, self.lat), |
|
357 | 357 | km2deg(r), color='0.6', fill=False, lw=0.2)) |
|
358 | 358 | ax.text( |
|
359 | 359 | self.lon + (km2deg(r))*numpy.cos(60*numpy.pi/180), |
|
360 | 360 | self.lat + (km2deg(r))*numpy.sin(60*numpy.pi/180), |
|
361 | 361 | '{}km'.format(r), |
|
362 | 362 | ha='center', va='bottom', size='8', color='0.6', weight='heavy') |
|
363 | 363 | |
|
364 | 364 | if self.mode == 'E': |
|
365 | 365 | title = 'El={}$^\circ$'.format(self.data.meta['elevation']) |
|
366 | 366 | label = 'E{:02d}'.format(int(self.data.meta['elevation'])) |
|
367 | 367 | else: |
|
368 | 368 | title = 'Az={}$^\circ$'.format(self.data.meta['azimuth']) |
|
369 | 369 | label = 'A{:02d}'.format(int(self.data.meta['azimuth'])) |
|
370 | 370 | |
|
371 | 371 | self.save_labels = ['{}-{}'.format(lbl, label) for lbl in self.labels] |
|
372 | 372 | self.titles = ['{} {}'.format( |
|
373 | 373 | self.data.parameters[x], title) for x in self.channels] |
|
374 | 374 | |
|
375 | 375 | class WeatherPlot(Plot): |
|
376 | 376 | CODE = 'weather' |
|
377 | 377 | plot_name = 'weather' |
|
378 | 378 | plot_type = 'ppistyle' |
|
379 | 379 | buffering = False |
|
380 | 380 | |
|
381 | 381 | def setup(self): |
|
382 | 382 | self.ncols = 1 |
|
383 | 383 | self.nrows = 1 |
|
384 | 384 | self.nplots= 1 |
|
385 | 385 | self.ylabel= 'Range [Km]' |
|
386 | 386 | self.titles= ['Weather'] |
|
387 | 387 | self.colorbar=False |
|
388 | 388 | self.width =8 |
|
389 | 389 | self.height =8 |
|
390 | 390 | self.ini =0 |
|
391 | 391 | self.len_azi =0 |
|
392 | 392 | self.buffer_ini = None |
|
393 | 393 | self.buffer_azi = None |
|
394 | 394 | self.plots_adjust.update({'wspace': 0.4, 'hspace':0.4, 'left': 0.1, 'right': 0.9, 'bottom': 0.08}) |
|
395 | 395 | self.flag =0 |
|
396 | 396 | self.indicador= 0 |
|
397 | 397 | |
|
398 | 398 | def update(self, dataOut): |
|
399 | 399 | |
|
400 | 400 | data = {} |
|
401 | 401 | meta = {} |
|
402 | 402 | data['weather'] = 10*numpy.log10(dataOut.data_360[0]/(250**2)) |
|
403 | print(data['weather']) | |
|
403 | 404 | data['azi'] = dataOut.data_azi |
|
404 | ||
|
405 | print("UPDATE",data['azi']) | |
|
405 | 406 | return data, meta |
|
406 | 407 | |
|
408 | def const_ploteo(self,data_weather,data_azi,step,res): | |
|
409 | #print("data_weather",data_weather) | |
|
410 | print("data_azi",data_azi) | |
|
411 | print("step",step) | |
|
412 | if self.ini==0: | |
|
413 | #------- AZIMUTH | |
|
414 | n = (360/res)-len(data_azi) | |
|
415 | start = data_azi[-1] + res | |
|
416 | end = data_azi[0] - res | |
|
417 | if start>end: | |
|
418 | end = end + 360 | |
|
419 | azi_vacia = numpy.linspace(start,end,int(n)) | |
|
420 | azi_vacia = numpy.where(azi_vacia>360,azi_vacia-360,azi_vacia) | |
|
421 | data_azi = numpy.hstack((data_azi,azi_vacia)) | |
|
422 | # RADAR | |
|
423 | val_mean = numpy.mean(data_weather[:,0]) | |
|
424 | data_weather_cmp = numpy.ones([(360-data_weather.shape[0]),data_weather.shape[1]])*val_mean | |
|
425 | data_weather = numpy.vstack((data_weather,data_weather_cmp)) | |
|
426 | else: | |
|
427 | # azimuth | |
|
428 | flag=0 | |
|
429 | start_azi = self.res_azi[0] | |
|
430 | start = data_azi[0] | |
|
431 | end = data_azi[-1] | |
|
432 | print("start",start) | |
|
433 | print("end",end) | |
|
434 | if start< start_azi: | |
|
435 | start = start +360 | |
|
436 | if end <start_azi: | |
|
437 | end = end +360 | |
|
438 | ||
|
439 | print("start",start) | |
|
440 | print("end",end) | |
|
441 | #### AQUI SERA LA MAGIA | |
|
442 | pos_ini = int((start-start_azi)/res) | |
|
443 | len_azi = len(data_azi) | |
|
444 | if (360-pos_ini)<len_azi: | |
|
445 | if pos_ini+1==360: | |
|
446 | pos_ini=0 | |
|
447 | else: | |
|
448 | flag=1 | |
|
449 | dif= 360-pos_ini | |
|
450 | comp= len_azi-dif | |
|
451 | ||
|
452 | print(pos_ini) | |
|
453 | print(len_azi) | |
|
454 | print("shape",self.res_azi.shape) | |
|
455 | if flag==0: | |
|
456 | # AZIMUTH | |
|
457 | self.res_azi[pos_ini:pos_ini+len_azi] = data_azi | |
|
458 | # RADAR | |
|
459 | self.res_weather[pos_ini:pos_ini+len_azi,:] = data_weather | |
|
460 | else: | |
|
461 | # AZIMUTH | |
|
462 | self.res_azi[pos_ini:pos_ini+dif] = data_azi[0:dif] | |
|
463 | self.res_azi[0:comp] = data_azi[dif:] | |
|
464 | # RADAR | |
|
465 | self.res_weather[pos_ini:pos_ini+dif,:] = data_weather[0:dif,:] | |
|
466 | self.res_weather[0:comp,:] = data_weather[dif:,:] | |
|
467 | flag=0 | |
|
468 | data_azi = self.res_azi | |
|
469 | data_weather = self.res_weather | |
|
470 | ||
|
471 | return data_weather,data_azi | |
|
472 | ||
|
407 | 473 | def plot(self): |
|
408 | thisDatetime = datetime.datetime.utcfromtimestamp(self.data.times[-1]) | |
|
409 | 474 | print("--------------------------------------",self.ini,"-----------------------------------") |
|
410 | print("time",self.data.times[-1]) | |
|
411 | data = self.data[-1] | |
|
412 | #print("debug_0", data) | |
|
413 | tmp_h = (data['weather'].shape[1])/10.0 | |
|
414 | #print("debug_1",tmp_h) | |
|
415 | stoprange = float(tmp_h*1.5)#stoprange = float(33*1.5) por ahora 400 | |
|
475 | #numpy.set_printoptions(suppress=True) | |
|
476 | #print(self.data.times) | |
|
477 | thisDatetime = datetime.datetime.utcfromtimestamp(self.data.times[-1]) | |
|
478 | data = self.data[-1] | |
|
479 | # ALTURA altura_tmp_h | |
|
480 | altura_h = (data['weather'].shape[1])/10.0 | |
|
481 | stoprange = float(altura_h*1.5)#stoprange = float(33*1.5) por ahora 400 | |
|
416 | 482 | rangestep = float(0.15) |
|
417 | 483 | r = numpy.arange(0, stoprange, rangestep) |
|
418 | 484 | self.y = 2*r |
|
419 | print("---------------") | |
|
420 |
|
|
|
421 | #print("tmp_v",tmp_v.shape) | |
|
422 |
|
|
|
423 | print("tmp_z-------------->",tmp_z) | |
|
424 | ##if self.ini==0: | |
|
425 | ## tmp_z= [0,1,2,3,4,5,6,7,8,9] | |
|
426 | ||
|
427 |
#print(" |
|
|
428 | res = 1 | |
|
429 | step = (360/(res*tmp_v.shape[0])) | |
|
485 | # RADAR | |
|
486 | #data_weather = data['weather'] | |
|
487 | # PEDESTAL | |
|
488 | #data_azi = data['azi'] | |
|
489 | res = 1 | |
|
490 | # STEP | |
|
491 | step = (360/(res*data['weather'].shape[0])) | |
|
492 | #print("shape wr_data", wr_data.shape) | |
|
493 | #print("shape wr_azi",wr_azi.shape) | |
|
430 | 494 | #print("step",step) |
|
431 | mode = 1 | |
|
432 | if mode==0: | |
|
433 | #print("self.ini",self.ini) | |
|
434 | val = numpy.mean(tmp_v[:,0]) | |
|
435 | self.len_azi = len(tmp_z) | |
|
436 | ones = numpy.ones([(360-tmp_v.shape[0]),tmp_v.shape[1]])*val | |
|
437 | self.buffer_ini = numpy.vstack((tmp_v,ones)) | |
|
438 | ||
|
439 | n = ((360/res)-len(tmp_z)) | |
|
440 | start = tmp_z[-1]+res | |
|
441 | end = tmp_z[0]-res | |
|
442 | if start>end: | |
|
443 | end = end+360 | |
|
444 | azi_zeros = numpy.linspace(start,end,int(n)) | |
|
445 | azi_zeros = numpy.where(azi_zeros>360,azi_zeros-360,azi_zeros) | |
|
446 | self.buffer_ini_azi = numpy.hstack((tmp_z,azi_zeros)) | |
|
447 | self.ini = self.ini+1 | |
|
448 | ||
|
449 | if mode==1: | |
|
450 | #print("################") | |
|
451 | #print("################") | |
|
452 | #print("mode",self.ini) | |
|
453 | #print("self.ini",self.ini) | |
|
454 | if self.ini==0: | |
|
455 | res = 1 | |
|
456 | step = (360/(res*tmp_v.shape[0])) | |
|
457 | val = numpy.mean(tmp_v[:,0]) | |
|
458 | self.len_azi = len(tmp_z) | |
|
459 | self.buf_tmp = tmp_v | |
|
460 | ones = numpy.ones([(360-tmp_v.shape[0]),tmp_v.shape[1]])*val | |
|
461 | self.buffer_ini = numpy.vstack((tmp_v,ones)) | |
|
462 | ||
|
463 | n = ((360/res)-len(tmp_z)) | |
|
464 | start = tmp_z[-1]+res | |
|
465 | end = tmp_z[0]-res | |
|
466 | if start>end: | |
|
467 | end =end+360 | |
|
468 | azi_zeros = numpy.linspace(start,end,int(n)) | |
|
469 | azi_zeros = numpy.where(azi_zeros>360,azi_zeros-360,azi_zeros) | |
|
470 | self.buf_azi = tmp_z | |
|
471 | self.buffer_ini_azi = numpy.hstack((tmp_z,azi_zeros)) | |
|
472 | self.ini = self.ini+1 | |
|
473 | elif 0<self.ini<step: | |
|
474 | ''' | |
|
475 | if self.ini>31: | |
|
476 | start= tmp_z[0] | |
|
477 | end =tmp_z[-1] | |
|
478 | print("start","end",start,end) | |
|
479 | if self.ini==32: | |
|
480 | tmp_v=tmp_v+20 | |
|
481 | if self.ini==33: | |
|
482 | tmp_v=tmp_v+10 | |
|
483 | if self.ini==34: | |
|
484 | tmp_v=tmp_v+20 | |
|
485 | if self.ini==35: | |
|
486 | tmp_v=tmp_v+20 | |
|
487 | ''' | |
|
488 | self.buf_tmp= numpy.vstack((self.buf_tmp,tmp_v)) | |
|
489 | print("ERROR_INMINENTE",self.buf_tmp.shape) | |
|
490 | if self.buf_tmp.shape[0]==360: | |
|
491 | print("entre aqui en 360 grados") | |
|
492 | self.buffer_ini=self.buf_tmp | |
|
493 | else: | |
|
494 | # nuevo######### | |
|
495 | self.buffer_ini[0:self.buf_tmp.shape[0],:]=self.buf_tmp | |
|
496 | ################ | |
|
497 | #val=30.0 | |
|
498 | #ones = numpy.ones([(360-self.buf_tmp.shape[0]),self.buf_tmp.shape[1]])*val | |
|
499 | #self.buffer_ini = numpy.vstack((self.buf_tmp,ones)) | |
|
500 | ||
|
501 | self.buf_azi = numpy.hstack((self.buf_azi,tmp_z)) | |
|
502 | n = ((360/res)-len(self.buf_azi)) | |
|
503 | print("n----->",n) | |
|
504 | if n==0: | |
|
505 | self.buffer_ini_azi = self.buf_azi | |
|
506 | else: | |
|
507 | start = self.buf_azi[-1]+res | |
|
508 | end = self.buf_azi[0]-res | |
|
509 | print("start",start) | |
|
510 | print("end",end) | |
|
511 | if start>end: | |
|
512 | end =end+360 | |
|
513 | azi_zeros = numpy.linspace(start,end,int(n)) | |
|
514 | azi_zeros = numpy.where(azi_zeros>360,azi_zeros-360,azi_zeros) | |
|
515 | print("self.buf_azi",self.buf_azi[0]) | |
|
516 | print("tmp_Z 0 ",tmp_z[0]) | |
|
517 | print("tmp_Z -1",tmp_z[-1]) | |
|
518 | if tmp_z[0]<self.buf_azi[0] <tmp_z[-1]: | |
|
519 | print("activando indicador") | |
|
520 | self.indicador=1 | |
|
521 | if self.indicador==1: | |
|
522 | azi_zeros = numpy.ones(360-len(self.buf_azi))*(tmp_z[-1]+res) | |
|
523 | ###start = tmp_z[-1]+res | |
|
524 | ###end = tmp_z[0]-res | |
|
525 | ###if start>end: | |
|
526 | ### end =end+360 | |
|
527 | ###azi_zeros = numpy.linspace(start,end,int(n)) | |
|
528 | ###azi_zeros = numpy.where(azi_zeros>360,azi_zeros-360,azi_zeros) | |
|
529 | print("azi_zeros",azi_zeros) | |
|
530 | ||
|
531 | ######self.buffer_ini_azi = numpy.hstack((self.buf_azi,azi_zeros)) | |
|
532 | #self.buffer_ini[0:tmv.shape[0],:]=tmp_v | |
|
533 | ##self.indicador=0 | |
|
534 | ||
|
535 | # self.indicador = True | |
|
536 | #if self.indicador==True: | |
|
537 | # azi_zeros = numpy.ones(360-len(self.buf_azi))*(tmp_z[-1]+res) | |
|
538 | ||
|
539 | #self.buf_azi = tmp_z | |
|
540 | self.buffer_ini_azi = numpy.hstack((self.buf_azi,azi_zeros)) | |
|
541 | ||
|
542 | if self.ini==step-1: | |
|
543 | start= tmp_z[0] | |
|
544 | end = tmp_z[-1] | |
|
545 | #print("start","end",start,end) | |
|
546 | ###print(self.buffer_ini_azi[:80]) | |
|
547 | self.ini = self.ini+1 | |
|
495 | print("Time---->",self.data.times[-1],thisDatetime) | |
|
496 | #print("alturas", len(self.y)) | |
|
497 | self.res_weather, self.res_azi = self.const_ploteo(data_weather=data['weather'],data_azi=data['azi'],step=step,res=res) | |
|
498 | #numpy.set_printoptions(suppress=True) | |
|
499 | #print("resultado",self.res_azi) | |
|
500 | ########################################################## | |
|
501 | ################# PLOTEO ################### | |
|
502 | ########################################################## | |
|
548 | 503 | |
|
549 | else: | |
|
550 | step = (360/(res*tmp_v.shape[0])) | |
|
551 | # aqui estaba realizando el debug de simulacion | |
|
552 | # tmp_v=tmp_v +5 en cada step sumaba 5 | |
|
553 | # y el mismo valor despues de la primera vuelta | |
|
554 | #tmp_v=tmp_v+5+(self.ini-step)*1### aqui yo habia sumado 5 por las puras | |
|
555 | ||
|
556 | start= tmp_z[0] | |
|
557 | end = tmp_z[-1] | |
|
558 | #print("start","end",start,end) | |
|
559 | ###print(self.buffer_ini_azi[:120]) | |
|
560 | ||
|
561 | if step>=2: | |
|
562 | if self.flag<step-1: | |
|
563 | limit_i=self.buf_azi[len(tmp_z)*(self.flag+1)] | |
|
564 | limit_s=self.buf_azi[len(tmp_z)*(self.flag+2)-1] | |
|
565 | print("flag",self.flag,limit_i,limit_s) | |
|
566 | if limit_i< tmp_z[-1]< limit_s: | |
|
567 | index_i=int(numpy.where(tmp_z<=self.buf_azi[len(tmp_z)*(self.flag+1)])[0][-1]) | |
|
568 | tmp_r =int(numpy.where(self.buf_azi[(self.flag+1)*len(tmp_z):(self.flag+2)*len(tmp_z)]>=tmp_z[-1])[0][0]) | |
|
569 | print("tmp_r",tmp_r) | |
|
570 | index_f=(self.flag+1)*len(tmp_z)+tmp_r | |
|
571 | ||
|
572 | if len(tmp_z[index_i:])>len(self.buf_azi[len(tmp_z)*(self.flag+1):index_f]): | |
|
573 | final = len(self.buf_azi[len(tmp_z)*(self.flag+1):index_f]) | |
|
574 | else: | |
|
575 | final= len(tmp_z[index_i:]) | |
|
576 | self.buf_azi[len(tmp_z)*(self.flag+1):index_f]=tmp_z[index_i:index_i+final] | |
|
577 | self.buf_tmp[len(tmp_z)*(self.flag+1):index_f,:]=tmp_v[index_i:index_i+final,:] | |
|
578 | if limit_i<tmp_z[0]<limit_s: | |
|
579 | index_f =int(numpy.where(self.buf_azi>=tmp_z[-1])[0][0]) | |
|
580 | n_p =index_f-len(tmp_z)*(self.flag+1) | |
|
581 | if n_p>0: | |
|
582 | self.buf_azi[len(tmp_z)*(self.flag+1):index_f]=tmp_z[-1]*numpy.ones(n_p) | |
|
583 | self.buf_tmp[len(tmp_z)*(self.flag+1):index_f,:]=tmp_v[-1,:]*numpy.ones([n_p,tmp_v.shape[1]]) | |
|
584 | ||
|
585 | ''' | |
|
586 | if self.buf_azi[len(tmp_z)]<tmp_z[-1]<self.buf_azi[2*len(tmp_z)-1]: | |
|
587 | index_i= int(numpy.where(tmp_z <= self.buf_azi[len(tmp_z)])[0][-1]) | |
|
588 | index_f= int(numpy.where(self.buf_azi>=tmp_z[-1])[0][0]) | |
|
589 | #print("index",index_i,index_f) | |
|
590 | if len(tmp_z[index_i:])>len(self.buf_azi[len(tmp_z):index_f]): | |
|
591 | final = len(self.buf_azi[len(tmp_z):index_f]) | |
|
592 | else: | |
|
593 | final = len(tmp_z[index_i:]) | |
|
594 | self.buf_azi[len(tmp_z):index_f]=tmp_z[index_i:index_i+final] | |
|
595 | self.buf_tmp[len(tmp_z):index_f,:]=tmp_v[index_i:index_i+final,:] | |
|
596 | ''' | |
|
597 | self.buf_tmp[len(tmp_z)*(self.flag):len(tmp_z)*(self.flag+1),:]=tmp_v | |
|
598 | self.buf_azi[len(tmp_z)*(self.flag):len(tmp_z)*(self.flag+1)] = tmp_z | |
|
599 | self.buffer_ini=self.buf_tmp | |
|
600 | self.buffer_ini_azi = self.buf_azi | |
|
601 | ##print("--------salida------------") | |
|
602 | start= tmp_z[0] | |
|
603 | end = tmp_z[-1] | |
|
604 | ##print("start","end",start,end) | |
|
605 | ##print(self.buffer_ini_azi[:120]) | |
|
606 | self.ini= self.ini+1 | |
|
607 | self.flag = self.flag +1 | |
|
608 | if self.flag==step: | |
|
609 | self.flag=0 | |
|
610 | numpy.set_printoptions(suppress=True) | |
|
611 | print("buffer_ini_azi") | |
|
612 | print(self.buffer_ini_azi) | |
|
613 | 504 | for i,ax in enumerate(self.axes): |
|
614 | 505 | if ax.firsttime: |
|
615 | 506 | plt.clf() |
|
616 |
cgax, pm = wrl.vis.plot_ppi(self. |
|
|
507 | cgax, pm = wrl.vis.plot_ppi(self.res_weather,r=r,az=self.res_azi,fig=self.figures[0], proj='cg', vmin=1, vmax=60) | |
|
617 | 508 | else: |
|
618 | 509 | plt.clf() |
|
619 |
cgax, pm = wrl.vis.plot_ppi(self. |
|
|
510 | cgax, pm = wrl.vis.plot_ppi(self.res_weather,r=r,az=self.res_azi,fig=self.figures[0], proj='cg', vmin=1, vmax=60) | |
|
620 | 511 | caax = cgax.parasites[0] |
|
621 | 512 | paax = cgax.parasites[1] |
|
622 | 513 | cbar = plt.gcf().colorbar(pm, pad=0.075) |
|
623 | 514 | caax.set_xlabel('x_range [km]') |
|
624 | 515 | caax.set_ylabel('y_range [km]') |
|
625 | 516 | plt.text(1.0, 1.05, 'azimuth '+str(thisDatetime)+"step"+str(self.ini), transform=caax.transAxes, va='bottom',ha='right') |
|
626 | #import time | |
|
627 | #time.sleep(0.5) | |
|
517 | ||
|
518 | self.ini= self.ini+1 |
@@ -1,203 +1,206 | |||
|
1 | 1 | ''' |
|
2 | 2 | Base clases to create Processing units and operations, the MPDecorator |
|
3 | 3 | must be used in plotting and writing operations to allow to run as an |
|
4 | 4 | external process. |
|
5 | 5 | ''' |
|
6 | 6 | |
|
7 | 7 | import inspect |
|
8 | 8 | import zmq |
|
9 | 9 | import time |
|
10 | 10 | import pickle |
|
11 | 11 | import traceback |
|
12 | 12 | from threading import Thread |
|
13 | 13 | from multiprocessing import Process, Queue |
|
14 | 14 | from schainpy.utils import log |
|
15 | 15 | |
|
16 | 16 | |
|
17 | 17 | class ProcessingUnit(object): |
|
18 | 18 | ''' |
|
19 | 19 | Base class to create Signal Chain Units |
|
20 | 20 | ''' |
|
21 | 21 | |
|
22 | 22 | proc_type = 'processing' |
|
23 | 23 | |
|
24 | 24 | def __init__(self): |
|
25 | 25 | |
|
26 | 26 | self.dataIn = None |
|
27 | 27 | self.dataOut = None |
|
28 | 28 | self.isConfig = False |
|
29 | 29 | self.operations = [] |
|
30 | ||
|
30 | ||
|
31 | 31 | def setInput(self, unit): |
|
32 | 32 | |
|
33 | 33 | self.dataIn = unit.dataOut |
|
34 | ||
|
34 | ||
|
35 | 35 | def getAllowedArgs(self): |
|
36 | 36 | if hasattr(self, '__attrs__'): |
|
37 | 37 | return self.__attrs__ |
|
38 | 38 | else: |
|
39 | 39 | return inspect.getargspec(self.run).args |
|
40 | 40 | |
|
41 | 41 | def addOperation(self, conf, operation): |
|
42 | 42 | ''' |
|
43 | 43 | ''' |
|
44 | ||
|
44 | ||
|
45 | 45 | self.operations.append((operation, conf.type, conf.getKwargs())) |
|
46 | 46 | |
|
47 | 47 | def getOperationObj(self, objId): |
|
48 | 48 | |
|
49 | 49 | if objId not in list(self.operations.keys()): |
|
50 | 50 | return None |
|
51 | 51 | |
|
52 | 52 | return self.operations[objId] |
|
53 | 53 | |
|
54 | 54 | def call(self, **kwargs): |
|
55 | 55 | ''' |
|
56 | 56 | ''' |
|
57 | 57 | |
|
58 | 58 | try: |
|
59 | 59 | if self.dataIn is not None and self.dataIn.flagNoData and not self.dataIn.error: |
|
60 | 60 | return self.dataIn.isReady() |
|
61 | 61 | elif self.dataIn is None or not self.dataIn.error: |
|
62 | 62 | self.run(**kwargs) |
|
63 | 63 | elif self.dataIn.error: |
|
64 | 64 | self.dataOut.error = self.dataIn.error |
|
65 | 65 | self.dataOut.flagNoData = True |
|
66 | 66 | except: |
|
67 |
err = traceback.format_exc() |
|
|
67 | err = traceback.format_exc() | |
|
68 | 68 | if 'SchainWarning' in err: |
|
69 | 69 | log.warning(err.split('SchainWarning:')[-1].split('\n')[0].strip(), self.name) |
|
70 | 70 | elif 'SchainError' in err: |
|
71 | 71 | log.error(err.split('SchainError:')[-1].split('\n')[0].strip(), self.name) |
|
72 | 72 | else: |
|
73 | 73 | log.error(err, self.name) |
|
74 | 74 | self.dataOut.error = True |
|
75 | ||
|
75 | ##### correcion de la declaracion Out | |
|
76 | 76 | for op, optype, opkwargs in self.operations: |
|
77 | aux = self.dataOut.copy() | |
|
77 | 78 | if optype == 'other' and not self.dataOut.flagNoData: |
|
78 | 79 | self.dataOut = op.run(self.dataOut, **opkwargs) |
|
79 | 80 | elif optype == 'external' and not self.dataOut.flagNoData: |
|
80 | op.queue.put(self.dataOut) | |
|
81 | elif optype == 'external' and self.dataOut.error: | |
|
82 | op.queue.put(self.dataOut) | |
|
81 | #op.queue.put(self.dataOut) | |
|
82 | op.queue.put(aux) | |
|
83 | elif optype == 'external' and self.dataOut.error: | |
|
84 | #op.queue.put(self.dataOut) | |
|
85 | op.queue.put(aux) | |
|
83 | 86 | |
|
84 | 87 | return 'Error' if self.dataOut.error else self.dataOut.isReady() |
|
85 | 88 | |
|
86 | 89 | def setup(self): |
|
87 | 90 | |
|
88 | 91 | raise NotImplementedError |
|
89 | 92 | |
|
90 | 93 | def run(self): |
|
91 | 94 | |
|
92 | 95 | raise NotImplementedError |
|
93 | 96 | |
|
94 | 97 | def close(self): |
|
95 | 98 | |
|
96 | 99 | return |
|
97 | 100 | |
|
98 | 101 | |
|
99 | 102 | class Operation(object): |
|
100 | 103 | |
|
101 | 104 | ''' |
|
102 | 105 | ''' |
|
103 | ||
|
106 | ||
|
104 | 107 | proc_type = 'operation' |
|
105 | 108 | |
|
106 | 109 | def __init__(self): |
|
107 | 110 | |
|
108 | 111 | self.id = None |
|
109 | 112 | self.isConfig = False |
|
110 | 113 | |
|
111 | 114 | if not hasattr(self, 'name'): |
|
112 | 115 | self.name = self.__class__.__name__ |
|
113 | 116 | |
|
114 | 117 | def getAllowedArgs(self): |
|
115 | 118 | if hasattr(self, '__attrs__'): |
|
116 | 119 | return self.__attrs__ |
|
117 | 120 | else: |
|
118 | 121 | return inspect.getargspec(self.run).args |
|
119 | 122 | |
|
120 | 123 | def setup(self): |
|
121 | 124 | |
|
122 | 125 | self.isConfig = True |
|
123 | 126 | |
|
124 | 127 | raise NotImplementedError |
|
125 | 128 | |
|
126 | 129 | def run(self, dataIn, **kwargs): |
|
127 | 130 | """ |
|
128 | 131 | Realiza las operaciones necesarias sobre la dataIn.data y actualiza los |
|
129 | 132 | atributos del objeto dataIn. |
|
130 | 133 | |
|
131 | 134 | Input: |
|
132 | 135 | |
|
133 | 136 | dataIn : objeto del tipo JROData |
|
134 | 137 | |
|
135 | 138 | Return: |
|
136 | 139 | |
|
137 | 140 | None |
|
138 | 141 | |
|
139 | 142 | Affected: |
|
140 | 143 | __buffer : buffer de recepcion de datos. |
|
141 | 144 | |
|
142 | 145 | """ |
|
143 | 146 | if not self.isConfig: |
|
144 | 147 | self.setup(**kwargs) |
|
145 | 148 | |
|
146 | 149 | raise NotImplementedError |
|
147 | 150 | |
|
148 | 151 | def close(self): |
|
149 | 152 | |
|
150 | 153 | return |
|
151 | 154 | |
|
152 | ||
|
155 | ||
|
153 | 156 | def MPDecorator(BaseClass): |
|
154 | 157 | """ |
|
155 | 158 | Multiprocessing class decorator |
|
156 | 159 | |
|
157 |
This function add multiprocessing features to a BaseClass. |
|
|
160 | This function add multiprocessing features to a BaseClass. | |
|
158 | 161 | """ |
|
159 | 162 | |
|
160 | 163 | class MPClass(BaseClass, Process): |
|
161 | 164 | |
|
162 | 165 | def __init__(self, *args, **kwargs): |
|
163 | 166 | super(MPClass, self).__init__() |
|
164 | 167 | Process.__init__(self) |
|
165 | 168 | |
|
166 | 169 | self.args = args |
|
167 | 170 | self.kwargs = kwargs |
|
168 | 171 | self.t = time.time() |
|
169 | 172 | self.op_type = 'external' |
|
170 | 173 | self.name = BaseClass.__name__ |
|
171 | 174 | self.__doc__ = BaseClass.__doc__ |
|
172 | ||
|
175 | ||
|
173 | 176 | if 'plot' in self.name.lower() and not self.name.endswith('_'): |
|
174 | 177 | self.name = '{}{}'.format(self.CODE.upper(), 'Plot') |
|
175 | ||
|
178 | ||
|
176 | 179 | self.start_time = time.time() |
|
177 | 180 | self.err_queue = args[3] |
|
178 | 181 | self.queue = Queue(maxsize=1) |
|
179 | 182 | self.myrun = BaseClass.run |
|
180 | 183 | |
|
181 | 184 | def run(self): |
|
182 | ||
|
185 | ||
|
183 | 186 | while True: |
|
184 | 187 | |
|
185 | 188 | dataOut = self.queue.get() |
|
186 | 189 | |
|
187 | 190 | if not dataOut.error: |
|
188 | 191 | try: |
|
189 | 192 | BaseClass.run(self, dataOut, **self.kwargs) |
|
190 | 193 | except: |
|
191 |
err = traceback.format_exc() |
|
|
194 | err = traceback.format_exc() | |
|
192 | 195 | log.error(err, self.name) |
|
193 | 196 | else: |
|
194 | 197 | break |
|
195 | 198 | |
|
196 | 199 | self.close() |
|
197 | 200 | |
|
198 | 201 | def close(self): |
|
199 | 202 | |
|
200 | 203 | BaseClass.close(self) |
|
201 | 204 | log.success('Done...(Time:{:4.2f} secs)'.format(time.time()-self.start_time), self.name) |
|
202 | 205 | |
|
203 | 206 | return MPClass |
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
@@ -1,127 +1,147 | |||
|
1 | 1 | #!python |
|
2 | 2 | ''' |
|
3 | 3 | ''' |
|
4 | 4 | |
|
5 | 5 | import os, sys |
|
6 | 6 | import datetime |
|
7 | 7 | import time |
|
8 | 8 | |
|
9 | 9 | #path = os.path.dirname(os.getcwd()) |
|
10 | 10 | #path = os.path.dirname(path) |
|
11 | 11 | #sys.path.insert(0, path) |
|
12 | 12 | |
|
13 | 13 | from schainpy.controller import Project |
|
14 | 14 | |
|
15 | 15 | desc = "USRP_test" |
|
16 | 16 | filename = "USRP_processing.xml" |
|
17 | 17 | controllerObj = Project() |
|
18 | 18 | controllerObj.setup(id = '191', name='Test_USRP', description=desc) |
|
19 | 19 | |
|
20 | 20 | ############## USED TO PLOT IQ VOLTAGE, POWER AND SPECTRA ############# |
|
21 | 21 | |
|
22 | 22 | ####################################################################### |
|
23 | 23 | ######PATH DE LECTURA, ESCRITURA, GRAFICOS Y ENVIO WEB################# |
|
24 | 24 | ####################################################################### |
|
25 | 25 | #path = '/media/data/data/vientos/57.2063km/echoes/NCO_Woodman' |
|
26 | 26 | #path = '/DATA_RM/TEST_INTEGRACION' |
|
27 | 27 | #path = '/DATA_RM/TEST_ONLINE' |
|
28 | path = '/DATA_RM/TEST_INTEGRACION/ADQ_OFFLINE/' | |
|
29 | path_pp = '/DATA_RM/TEST_HDF5' | |
|
28 | #path = '/DATA_RM/TEST_INTEGRACION/ADQ_OFFLINE/' | |
|
29 | # ULTIMO TEST 22 DE SEPTIEMBRE | |
|
30 | path = '/DATA_RM/USRP_22' | |
|
31 | #path_pp = '/DATA_RM/TEST_HDF5' | |
|
32 | # UTIMO TEST 22 DE SEPTIEMBRE | |
|
33 | path_pp = '/DATA_RM/TEST_HDF5_PP_22' | |
|
34 | ###################################################### | |
|
35 | ##### OJO TENER EN CUENTA EL n= para el Pulse Pair ### | |
|
36 | ###################################################### | |
|
37 | ######## BUSCAMOS EL numero de IPP equivalente 1Β°##### | |
|
38 | ######## Sea V la velocidad del Pedestal en Β°/seg##### | |
|
39 | ######## 1Β° sera Recorrido en un tiempo de 1/V ###### | |
|
40 | ######## IPP del Radar 400 useg --> 60 Km ############ | |
|
41 | ######## n = 1/(V*IPP) , NUMERO DE IPP ############# | |
|
42 | ######## n = 1/(V*IPP) ############################# | |
|
43 | V=2 | |
|
44 | IPP=400*1e-6 | |
|
45 | n= 1/(V*IPP) | |
|
46 | print("n numero de Perfiles a procesar con Pulse Pair: ", n) | |
|
47 | ||
|
48 | ||
|
49 | ||
|
30 | 50 | |
|
31 | 51 | figpath = '/home/soporte/Pictures/TEST_INTEGRACION_IMG' |
|
32 | 52 | #remotefolder = "/home/wmaster/graficos" |
|
33 | 53 | ####################################################################### |
|
34 | 54 | ################# RANGO DE PLOTEO###################################### |
|
35 | 55 | ####################################################################### |
|
36 | 56 | dBmin = '-5' |
|
37 | 57 | dBmax = '20' |
|
38 | 58 | xmin = '0' |
|
39 | 59 | xmax ='24' |
|
40 | 60 | ymin = '0' |
|
41 | 61 | ymax = '600' |
|
42 | 62 | ####################################################################### |
|
43 | 63 | ########################FECHA########################################## |
|
44 | 64 | ####################################################################### |
|
45 | 65 | str = datetime.date.today() |
|
46 | 66 | today = str.strftime("%Y/%m/%d") |
|
47 | 67 | str2 = str - datetime.timedelta(days=1) |
|
48 | 68 | yesterday = str2.strftime("%Y/%m/%d") |
|
49 | 69 | ####################################################################### |
|
50 | 70 | ######################## UNIDAD DE LECTURA############################# |
|
51 | 71 | ####################################################################### |
|
52 | 72 | readUnitConfObj = controllerObj.addReadUnit(datatype='DigitalRFReader', |
|
53 | 73 | path=path, |
|
54 | 74 | startDate="2021/01/01",#today, |
|
55 | 75 | endDate="2021/12/30",#today, |
|
56 | 76 | startTime='00:00:00', |
|
57 | 77 | endTime='23:59:59', |
|
58 | 78 | delay=0, |
|
59 | 79 | #set=0, |
|
60 | 80 | online=0, |
|
61 | 81 | walk=1, |
|
62 | 82 | ippKm = 60) |
|
63 | 83 | |
|
64 | 84 | opObj11 = readUnitConfObj.addOperation(name='printInfo') |
|
65 | 85 | #opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock') |
|
66 | 86 | ####################################################################### |
|
67 | 87 | ################ OPERACIONES DOMINIO DEL TIEMPO######################## |
|
68 | 88 | ####################################################################### |
|
69 | 89 | |
|
70 | 90 | procUnitConfObjA = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId()) |
|
71 | 91 | |
|
72 | 92 | # |
|
73 | 93 | # codigo64='1,1,1,0,1,1,0,1,1,1,1,0,0,0,1,0,1,1,1,0,1,1,0,1,0,0,0,1,1,1,0,1,1,1,1,0,1,1,0,1,1,1,1,0,0,0,1,0,0,0,0,1,0,0,1,0,1,1,1,0,0,0,1,0,'+\ |
|
74 | 94 | # '1,1,1,0,1,1,0,1,1,1,1,0,0,0,1,0,1,1,1,0,1,1,0,1,0,0,0,1,1,1,0,1,0,0,0,1,0,0,1,0,0,0,0,1,1,1,0,1,1,1,1,0,1,1,0,1,0,0,0,1,1,1,0,1' |
|
75 | 95 | |
|
76 | 96 | #opObj11 = procUnitConfObjA.addOperation(name='setRadarFrequency') |
|
77 | 97 | #opObj11.addParameter(name='frequency', value='70312500') |
|
78 | 98 | opObj11 = procUnitConfObjA.addOperation(name='PulsePair', optype='other') |
|
79 |
opObj11.addParameter(name='n', value= |
|
|
99 | opObj11.addParameter(name='n', value=int(n), format='int')#10 VOY A USAR 250 DADO QUE LA VELOCIDAD ES 10 GRADOS | |
|
80 | 100 | opObj11.addParameter(name='removeDC', value=1, format='int') |
|
81 | 101 | # Ploteo TEST |
|
82 | 102 | ''' |
|
83 | 103 | opObj11 = procUnitConfObjA.addOperation(name='PulsepairPowerPlot', optype='other') |
|
84 | 104 | opObj11 = procUnitConfObjA.addOperation(name='PulsepairSignalPlot', optype='other') |
|
85 | 105 | opObj11 = procUnitConfObjA.addOperation(name='PulsepairVelocityPlot', optype='other') |
|
86 | 106 | #opObj11.addParameter(name='xmax', value=8) |
|
87 | 107 | opObj11 = procUnitConfObjA.addOperation(name='PulsepairSpecwidthPlot', optype='other') |
|
88 | 108 | ''' |
|
89 | 109 | # OJO SCOPE |
|
90 | 110 | #opObj10 = procUnitConfObjA.addOperation(name='ScopePlot', optype='external') |
|
91 | 111 | #opObj10.addParameter(name='id', value='10', format='int') |
|
92 | 112 | ##opObj10.addParameter(name='xmin', value='0', format='int') |
|
93 | 113 | ##opObj10.addParameter(name='xmax', value='50', format='int') |
|
94 | 114 | #opObj10.addParameter(name='type', value='iq') |
|
95 | 115 | ##opObj10.addParameter(name='ymin', value='-5000', format='int') |
|
96 | 116 | ##opObj10.addParameter(name='ymax', value='8500', format='int') |
|
97 | 117 | #opObj11.addParameter(name='save', value=figpath, format='str') |
|
98 | 118 | #opObj11.addParameter(name='save_period', value=10, format='int') |
|
99 | 119 | |
|
100 | 120 | #opObj10 = procUnitConfObjA.addOperation(name='setH0') |
|
101 | 121 | #opObj10.addParameter(name='h0', value='-5000', format='float') |
|
102 | 122 | |
|
103 | 123 | #opObj11 = procUnitConfObjA.addOperation(name='filterByHeights') |
|
104 | 124 | #opObj11.addParameter(name='window', value='1', format='int') |
|
105 | 125 | |
|
106 | 126 | #codigo='1,1,-1,1,1,-1,1,-1,-1,1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,-1,1,1,1,1,-1,-1,-1' |
|
107 | 127 | #opObj11 = procUnitConfObjSousy.addOperation(name='Decoder', optype='other') |
|
108 | 128 | #opObj11.addParameter(name='code', value=codigo, formatyesterday='floatlist') |
|
109 | 129 | #opObj11.addParameter(name='nCode', value='1', format='int') |
|
110 | 130 | #opObj11.addParameter(name='nBaud', value='28', format='int') |
|
111 | 131 | |
|
112 | 132 | #opObj11 = procUnitConfObjA.addOperation(name='CohInt', optype='other') |
|
113 | 133 | #opObj11.addParameter(name='n', value='100', format='int') |
|
114 | 134 | |
|
115 | 135 | ####################################################################### |
|
116 | 136 | ########## OPERACIONES ParametersProc######################## |
|
117 | 137 | ####################################################################### |
|
118 | 138 | |
|
119 | 139 | procUnitConfObjB= controllerObj.addProcUnit(datatype='ParametersProc',inputId=procUnitConfObjA.getId()) |
|
120 | 140 | opObj10 = procUnitConfObjB.addOperation(name='HDFWriter') |
|
121 | 141 | opObj10.addParameter(name='path',value=path_pp) |
|
122 | 142 | #opObj10.addParameter(name='mode',value=0) |
|
123 | 143 | opObj10.addParameter(name='blocksPerFile',value='100',format='int') |
|
124 | 144 | opObj10.addParameter(name='metadataList',value='utctimeInit,timeZone,paramInterval,profileIndex,channelList,heightList,flagDataAsBlock',format='list') |
|
125 | 145 | opObj10.addParameter(name='dataList',value='dataPP_POW,dataPP_DOP,utctime',format='list')#,format='list' |
|
126 | 146 | |
|
127 | 147 | controllerObj.start() |
@@ -1,146 +1,157 | |||
|
1 | 1 | #!python |
|
2 | 2 | ''' |
|
3 | 3 | ''' |
|
4 | 4 | |
|
5 | 5 | import os, sys |
|
6 | 6 | import datetime |
|
7 | 7 | import time |
|
8 | 8 | |
|
9 | 9 | #path = os.path.dirname(os.getcwd()) |
|
10 | 10 | #path = os.path.dirname(path) |
|
11 | 11 | #sys.path.insert(0, path) |
|
12 | 12 | |
|
13 | 13 | from schainpy.controller import Project |
|
14 | 14 | |
|
15 | 15 | desc = "USRP_test" |
|
16 | 16 | filename = "USRP_processing.xml" |
|
17 | 17 | controllerObj = Project() |
|
18 | 18 | controllerObj.setup(id = '191', name='Test_USRP', description=desc) |
|
19 | 19 | |
|
20 | 20 | ############## USED TO PLOT IQ VOLTAGE, POWER AND SPECTRA ############# |
|
21 | 21 | |
|
22 | 22 | ####################################################################### |
|
23 | 23 | ######PATH DE LECTURA, ESCRITURA, GRAFICOS Y ENVIO WEB################# |
|
24 | 24 | ####################################################################### |
|
25 | 25 | #path = '/media/data/data/vientos/57.2063km/echoes/NCO_Woodman' |
|
26 | 26 | #path = '/DATA_RM/TEST_INTEGRACION' |
|
27 | 27 | #path = '/DATA_RM/TEST_ONLINE' |
|
28 | 28 | #path_pp = '/DATA_RM/TEST_HDF5' |
|
29 | 29 | |
|
30 | 30 | #figpath = '/home/soporte/Pictures/TEST_INTEGRACION_IMG' |
|
31 | path = '/DATA_RM/TEST_INTEGRACION/ADQ_OFFLINE/' | |
|
32 | path_pp = '/DATA_RM/TEST_HDF5_SPEC' | |
|
33 | ||
|
34 | ||
|
31 | ###path = '/DATA_RM/TEST_INTEGRACION/ADQ_OFFLINE/' | |
|
32 | ###path_pp = '/DATA_RM/TEST_HDF5_SPEC' | |
|
35 | 33 | |
|
34 | #path = '/DATA_RM/USRP_22' | |
|
35 | path = '/DATA_RM/23/6v' | |
|
36 | #path_pp = '/DATA_RM/TEST_HDF5' | |
|
37 | # UTIMO TEST 22 DE SEPTIEMBRE | |
|
38 | #path_pp = '/DATA_RM/TEST_HDF5_SPEC_22' | |
|
39 | #path_pp = '/DATA_RM/TEST_HDF5_SPEC_3v' | |
|
40 | path_pp = '/DATA_RM/TEST_HDF5_SPEC_23/6v' | |
|
36 | 41 | |
|
37 | 42 | |
|
38 | 43 | #remotefolder = "/home/wmaster/graficos" |
|
39 | 44 | ####################################################################### |
|
40 | 45 | ################# RANGO DE PLOTEO###################################### |
|
41 | 46 | ####################################################################### |
|
42 | 47 | dBmin = '-5' |
|
43 | 48 | dBmax = '20' |
|
44 | 49 | xmin = '0' |
|
45 | 50 | xmax ='24' |
|
46 | 51 | ymin = '0' |
|
47 | 52 | ymax = '600' |
|
48 | 53 | ####################################################################### |
|
49 | 54 | ########################FECHA########################################## |
|
50 | 55 | ####################################################################### |
|
51 | 56 | str = datetime.date.today() |
|
52 | 57 | today = str.strftime("%Y/%m/%d") |
|
53 | 58 | str2 = str - datetime.timedelta(days=1) |
|
54 | 59 | yesterday = str2.strftime("%Y/%m/%d") |
|
55 | 60 | ####################################################################### |
|
56 | 61 | ######################## UNIDAD DE LECTURA############################# |
|
57 | 62 | ####################################################################### |
|
58 | 63 | readUnitConfObj = controllerObj.addReadUnit(datatype='DigitalRFReader', |
|
59 | 64 | path=path, |
|
60 | 65 | startDate="2021/01/01",#today, |
|
61 | 66 | endDate="2021/12/30",#today, |
|
62 | 67 | startTime='00:00:00', |
|
63 | 68 | endTime='23:59:59', |
|
64 | 69 | delay=0, |
|
65 | 70 | #set=0, |
|
66 | 71 | online=0, |
|
67 | 72 | walk=1, |
|
68 | 73 | ippKm = 60) |
|
69 | 74 | |
|
70 | 75 | opObj11 = readUnitConfObj.addOperation(name='printInfo') |
|
71 | 76 | #opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock') |
|
72 | 77 | ####################################################################### |
|
73 | 78 | ################ OPERACIONES DOMINIO DEL TIEMPO######################## |
|
74 | 79 | ####################################################################### |
|
75 | 80 | |
|
81 | ||
|
82 | V=6 | |
|
83 | IPP=400*1e-6 | |
|
84 | n= int(1/(V*IPP)) | |
|
85 | print("n numero de Perfiles a procesar con nFFTPoints ", n) | |
|
86 | ||
|
76 | 87 | procUnitConfObjA = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId()) |
|
77 | 88 | |
|
78 | 89 | procUnitConfObjB = controllerObj.addProcUnit(datatype='SpectraProc', inputId=procUnitConfObjA.getId()) |
|
79 |
procUnitConfObjB.addParameter(name='nFFTPoints', value= |
|
|
80 |
procUnitConfObjB.addParameter(name='nProfiles' , value= |
|
|
90 | procUnitConfObjB.addParameter(name='nFFTPoints', value=n, format='int') | |
|
91 | procUnitConfObjB.addParameter(name='nProfiles' , value=n, format='int') | |
|
81 | 92 | |
|
82 | 93 | |
|
83 | 94 | |
|
84 | 95 | # |
|
85 | 96 | # codigo64='1,1,1,0,1,1,0,1,1,1,1,0,0,0,1,0,1,1,1,0,1,1,0,1,0,0,0,1,1,1,0,1,1,1,1,0,1,1,0,1,1,1,1,0,0,0,1,0,0,0,0,1,0,0,1,0,1,1,1,0,0,0,1,0,'+\ |
|
86 | 97 | # '1,1,1,0,1,1,0,1,1,1,1,0,0,0,1,0,1,1,1,0,1,1,0,1,0,0,0,1,1,1,0,1,0,0,0,1,0,0,1,0,0,0,0,1,1,1,0,1,1,1,1,0,1,1,0,1,0,0,0,1,1,1,0,1' |
|
87 | 98 | |
|
88 | 99 | #opObj11 = procUnitConfObjA.addOperation(name='setRadarFrequency') |
|
89 | 100 | #opObj11.addParameter(name='frequency', value='70312500') |
|
90 | 101 | #opObj11 = procUnitConfObjA.addOperation(name='PulsePair', optype='other') |
|
91 | 102 | #opObj11.addParameter(name='n', value='625', format='int')#10 |
|
92 | 103 | #opObj11.addParameter(name='removeDC', value=1, format='int') |
|
93 | 104 | |
|
94 | 105 | # Ploteo TEST |
|
95 | 106 | ''' |
|
96 | 107 | opObj11 = procUnitConfObjA.addOperation(name='PulsepairPowerPlot', optype='other') |
|
97 | 108 | opObj11 = procUnitConfObjA.addOperation(name='PulsepairSignalPlot', optype='other') |
|
98 | 109 | opObj11 = procUnitConfObjA.addOperation(name='PulsepairVelocityPlot', optype='other') |
|
99 | 110 | #opObj11.addParameter(name='xmax', value=8) |
|
100 | 111 | opObj11 = procUnitConfObjA.addOperation(name='PulsepairSpecwidthPlot', optype='other') |
|
101 | 112 | ''' |
|
102 | 113 | # OJO SCOPE |
|
103 | 114 | #opObj10 = procUnitConfObjA.addOperation(name='ScopePlot', optype='external') |
|
104 | 115 | #opObj10.addParameter(name='buffer_sizeid', value='10', format='int') |
|
105 | 116 | ##opObj10.addParameter(name='xmin', value='0', format='int') |
|
106 | 117 | ##opObj10.addParameter(name='xmax', value='50', format='int') |
|
107 | 118 | #opObj10.addParameter(name='type', value='iq') |
|
108 | 119 | ##opObj10.addParameter(name='ymin', value='-5000', format='int') |
|
109 | 120 | ##opObj10.addParameter(name='ymax', value='8500', format='int') |
|
110 | 121 | #opObj11.addParameter(name='save', value=figpath, format='str') |
|
111 | 122 | #opObj11.addParameter(name='save_period', value=10, format='int') |
|
112 | 123 | |
|
113 | 124 | #opObj10 = procUnitConfObjA.addOperation(name='setH0') |
|
114 | 125 | #opObj10.addParameter(name='h0', value='-5000', format='float') |
|
115 | 126 | |
|
116 | 127 | #opObj11 = procUnitConfObjA.addOperation(name='filterByHeights') |
|
117 | 128 | #opObj11.addParameter(name='window', value='1', format='int') |
|
118 | 129 | |
|
119 | 130 | #codigo='1,1,-1,1,1,-1,1,-1,-1,1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,-1,1,1,1,1,-1,-1,-1' |
|
120 | 131 | #opObj11 = procUnitConfObjSousy.addOperation(name='Decoder', optype='other') |
|
121 | 132 | #opObj11.addParameter(name='code', value=codigo, formatyesterday='floatlist') |
|
122 | 133 | #opObj11.addParameter(name='nCode', value='1', format='int') |
|
123 | 134 | #opObj11.addParameter(name='nBaud', value='28', format='int') |
|
124 | 135 | |
|
125 | 136 | #opObj11 = procUnitConfObjA.addOperation(name='CohInt', optype='other') |
|
126 | 137 | #opObj11.addParameter(name='n', value='100', format='int') |
|
127 | 138 | |
|
128 | 139 | ####################################################################### |
|
129 | 140 | ########## OPERACIONES ParametersProc######################## |
|
130 | 141 | ####################################################################### |
|
131 | 142 | |
|
132 | 143 | procUnitConfObjC= controllerObj.addProcUnit(datatype='ParametersProc',inputId=procUnitConfObjB.getId()) |
|
133 | 144 | |
|
134 | 145 | procUnitConfObjC.addOperation(name='SpectralMoments') |
|
135 | 146 | |
|
136 | 147 | |
|
137 | 148 | opObj10 = procUnitConfObjC.addOperation(name='HDFWriter') |
|
138 | 149 | opObj10.addParameter(name='path',value=path_pp) |
|
139 | 150 | #opObj10.addParameter(name='mode',value=0) |
|
140 | 151 | opObj10.addParameter(name='blocksPerFile',value='100',format='int') |
|
141 | 152 | #opObj10.addParameter(name='metadataList',value='utctimeInit,heightList,nIncohInt,nCohInt,nProfiles,channelList',format='list')#profileIndex |
|
142 | 153 | opObj10.addParameter(name='metadataList',value='utctimeInit,heightList,nIncohInt,nCohInt,nProfiles,channelList',format='list')#profileIndex |
|
143 | 154 | |
|
144 | 155 | opObj10.addParameter(name='dataList',value='data_pow,data_dop,utctime',format='list')#,format='list' |
|
145 | 156 | |
|
146 | 157 | controllerObj.start() |
@@ -1,64 +1,75 | |||
|
1 | 1 | import os,sys |
|
2 | 2 | import datetime |
|
3 | 3 | import time |
|
4 | 4 | from schainpy.controller import Project |
|
5 | 5 | #path='/DATA_RM/TEST_HDF5/d2021200' |
|
6 | 6 | #path='/DATA_RM/TEST_HDF5/d2021200' |
|
7 | 7 | #path='/DATA_RM/TEST_HDF5/d2021214' |
|
8 | 8 | #path='/DATA_RM/TEST_HDF5/d2021229' |
|
9 | 9 | |
|
10 | 10 | #path='/DATA_RM/TEST_HDF5/d2021231' |
|
11 | 11 | #path='/DATA_RM/TEST_HDF5/ADQ_OFFLINE/d2021231' |
|
12 | 12 | path='/DATA_RM/TEST_HDF5/d2021231' |
|
13 | ||
|
13 | #path='/DATA_RM/TEST_14_HDF5/d2021257' | |
|
14 | ## TEST ULTIMA PRUEBA 22 DE SEPTIEMBRE | |
|
15 | path = '/DATA_RM/TEST_HDF5_PP_22/d2021265' | |
|
14 | 16 | path_adq=path |
|
15 | 17 | #path_ped='/DATA_RM/TEST_PEDESTAL/P2021200' |
|
16 | 18 | #path_ped='/DATA_RM/TEST_PEDESTAL/P2021214' |
|
17 | 19 | #path_ped='/DATA_RM/TEST_PEDESTAL/P2021230' |
|
18 | 20 | #path_ped='/DATA_RM/TEST_PEDESTAL/P20210819' |
|
19 | 21 | #path_ped='/DATA_RM/TEST_PEDESTAL/P20210819-154315' |
|
20 |
path_ped='/DATA_RM/TEST_PEDESTAL/P |
|
|
22 | #path_ped='/DATA_RM/TEST_PEDESTAL/P20210914-162434' | |
|
23 | #path_ped='/DATA_RM/TEST_PEDESTAL/PEDESTAL_OFFLINE/P20210819-161524' | |
|
24 | #pruebas con perdida de datos | |
|
25 | #path_ped='/DATA_RM/TEST_PEDESTAL/PEDESTAL_OFFLINE/P20210819-161524_TEST' | |
|
26 | ## TEST ULTIMA PRUEBA 22 DE SEPTIEMBRE | |
|
27 | path_ped='/DATA_RM/TEST_PEDESTAL/P20210922-122731' | |
|
21 | 28 | |
|
22 | 29 | |
|
23 | 30 | figpath = '/home/soporte/Pictures' |
|
24 | 31 | desc = "Simulator Test" |
|
25 | 32 | |
|
26 | 33 | controllerObj = Project() |
|
27 | 34 | controllerObj.setup(id='10',name='Test Simulator',description=desc) |
|
28 | 35 | readUnitConfObj = controllerObj.addReadUnit(datatype='HDFReader', |
|
29 | 36 | path=path, |
|
30 | 37 | startDate="2021/01/01", #"2020/01/01",#today, |
|
31 | 38 | endDate= "2021/12/01", #"2020/12/30",#today, |
|
32 | 39 | startTime='00:00:00', |
|
33 | 40 | endTime='23:59:59', |
|
34 | 41 | t_Interval_p=0.01, |
|
35 | 42 | n_Muestras_p=100, |
|
36 | 43 | delay=30, |
|
37 | 44 | #set=0, |
|
38 | 45 | online=0, |
|
39 | 46 | walk=0, |
|
40 | 47 | nTries=6)#1 |
|
41 | 48 | |
|
42 | 49 | procUnitConfObjA = controllerObj.addProcUnit(datatype='ParametersProc',inputId=readUnitConfObj.getId()) |
|
50 | V=2 | |
|
51 | blocksPerfile=100 | |
|
52 | print("Velocidad del Pedestal",V) | |
|
53 | f_a_p= int(blocksPerfile/V) | |
|
43 | 54 | |
|
44 | 55 | opObj11 = procUnitConfObjA.addOperation(name='PedestalInformation') |
|
45 | 56 | opObj11.addParameter(name='path_ped', value=path_ped) |
|
46 | 57 | opObj11.addParameter(name='path_adq', value=path_adq) |
|
47 | 58 | opObj11.addParameter(name='t_Interval_p', value='0.01', format='float') |
|
48 | 59 | opObj11.addParameter(name='n_Muestras_p', value='100', format='float') |
|
49 | 60 | opObj11.addParameter(name='blocksPerfile', value='100', format='int') |
|
50 |
opObj11.addParameter(name='f_a_p', value= |
|
|
61 | opObj11.addParameter(name='f_a_p', value=f_a_p, format='int') | |
|
51 | 62 | opObj11.addParameter(name='online', value='0', format='int')# habilitar el enable aqui tambien |
|
52 | 63 | |
|
53 | 64 | |
|
54 | 65 | opObj11 = procUnitConfObjA.addOperation(name='Block360') |
|
55 | 66 | opObj11.addParameter(name='n', value='10', format='int') |
|
56 | 67 | # este bloque funciona bien con divisores de 360 no olvidar 0 10 20 30 40 60 90 120 180 |
|
57 | 68 | |
|
58 | 69 | opObj11= procUnitConfObjA.addOperation(name='WeatherPlot',optype='other') |
|
59 | opObj11.addParameter(name='save', value=figpath) | |
|
60 | opObj11.addParameter(name='save_period', value=1) | |
|
70 | #opObj11.addParameter(name='save', value=figpath) | |
|
71 | #opObj11.addParameter(name='save_period', value=1) | |
|
61 | 72 | |
|
62 | 73 | controllerObj.start() |
|
63 | 74 | #online 1 utc_adq 1617490240.48 |
|
64 | 75 | #online 0 utc_adq 1617489815.4804 |
@@ -1,89 +1,90 | |||
|
1 | 1 | import os,sys,json |
|
2 | 2 | import datetime |
|
3 | 3 | import time |
|
4 | 4 | from schainpy.controller import Project |
|
5 | 5 | ''' |
|
6 | 6 | NOTA: |
|
7 | 7 | Este script de prueba. |
|
8 | 8 | - Unidad del lectura 'HDFReader'. |
|
9 | 9 | - Unidad de procesamiento ParametersProc |
|
10 | 10 | - Operacion SpectralMomentsPlot |
|
11 | 11 | |
|
12 | 12 | ''' |
|
13 | 13 | #path = '/home/soporte/Downloads/RAWDATA_PP' |
|
14 | 14 | #path = '/DATA_RM/TEST_HDF5/d2021203' |
|
15 | 15 | ####################################################################### |
|
16 | 16 | ################# RANGO DE PLOTEO###################################### |
|
17 | 17 | ####################################################################### |
|
18 | 18 | dBmin = '1' |
|
19 | 19 | dBmax = '85' |
|
20 | 20 | xmin = '0' |
|
21 | 21 | xmax ='24' |
|
22 |
tmmin = 1 |
|
|
23 |
tmmax = 1 |
|
|
22 | tmmin = 12.2 | |
|
23 | tmmax = 12.40 | |
|
24 | 24 | ymin = '0' |
|
25 | 25 | ymax = '600' |
|
26 | 26 | ####################################################################### |
|
27 | 27 | ####################################################################### |
|
28 | 28 | # este script lee los archivos pre-procesados pulse-pair y permite el |
|
29 | 29 | # el ploteo del rti, mostrando los valores de potencia de la senal. |
|
30 | 30 | # el resultado del grafico depende del programa USRP_ADQ_PP.py |
|
31 | 31 | # debido al procesamiento del Pulse Pair. |
|
32 | 32 | |
|
33 | 33 | ####################################################################### |
|
34 | 34 | ####################################################################### |
|
35 | ||
|
36 |
path='/DATA_RM/TEST_HDF5/d20212 |
|
|
35 | #path_pp = '/DATA_RM/TEST_HDF5_PP_22' | |
|
36 | path='/DATA_RM/TEST_HDF5_PP_22/d2021265' | |
|
37 | #path='/DATA_RM/TEST_HDF5/d2021231' | |
|
37 | 38 | figpath = '/home/soporte/Downloads/IMAGE' |
|
38 | 39 | desc = "Simulator Test" |
|
39 | 40 | desc_data = { |
|
40 | 41 | 'Data': { |
|
41 | 42 | 'dataPP_POW': ['Data/dataPP_POW/channel00','Data/dataPP_POW/channel01'], |
|
42 | 43 | 'dataPP_DOP': ['Data/dataPP_DOP/channel00','Data/dataPP_DOP/channel01'], |
|
43 | 44 | 'utctime':'Data/utctime' |
|
44 | 45 | }, |
|
45 | 46 | 'Metadata': { |
|
46 | 47 | 'heightList' :'Metadata/heightList', |
|
47 | 48 | 'flagDataAsBlock':'Metadata/flagDataAsBlock', |
|
48 | 49 | 'channelList' :'Metadata/channelList', |
|
49 | 50 | 'profileIndex' :'Metadata/profileIndex' |
|
50 | 51 | } |
|
51 | 52 | } |
|
52 | 53 | |
|
53 | 54 | controllerObj = Project() |
|
54 | 55 | |
|
55 | 56 | controllerObj.setup(id='10',name='Test Simulator',description=desc) |
|
56 | 57 | |
|
57 | 58 | readUnitConfObj = controllerObj.addReadUnit(datatype='HDFReader', |
|
58 | 59 | path=path, |
|
59 | 60 | startDate="2021/01/01", #"2020/01/01",#today, |
|
60 | 61 | endDate= "2021/12/01", #"2020/12/30",#today, |
|
61 | 62 | startTime='00:00:00', |
|
62 | 63 | endTime='23:59:59', |
|
63 | 64 | delay=0, |
|
64 | 65 | #set=0, |
|
65 | 66 | online=0, |
|
66 | 67 | walk=0, |
|
67 | 68 | description= json.dumps(desc_data))#1 |
|
68 | 69 | |
|
69 | 70 | procUnitConfObjA = controllerObj.addProcUnit(datatype='ParametersProc',inputId=readUnitConfObj.getId()) |
|
70 | 71 | |
|
71 | 72 | #opObj11 = procUnitConfObjA.addOperation(name='PulsepairPowerPlot', optype='other')#PulsepairPowerPlot |
|
72 | 73 | #opObj11 = procUnitConfObjA.addOperation(name='PulsepairSignalPlot', optype='other') |
|
73 | 74 | #opObj11 = procUnitConfObjA.addOperation(name='PulsepairVelocityPlot', optype='other') |
|
74 | 75 | |
|
75 | 76 | opObj11 = procUnitConfObjA.addOperation(name='GenericRTIPlot',optype='external') |
|
76 | 77 | |
|
77 | 78 | opObj11.addParameter(name='attr_data', value='dataPP_POW') |
|
78 | 79 | opObj11.addParameter(name='colormap', value='jet') |
|
79 | 80 | |
|
80 | 81 | opObj11.addParameter(name='xmin', value=tmmin) |
|
81 | 82 | opObj11.addParameter(name='xmax', value=tmmax) |
|
82 | 83 | opObj11.addParameter(name='zmin', value=dBmin) |
|
83 | 84 | opObj11.addParameter(name='zmax', value=dBmax) |
|
84 | 85 | opObj11.addParameter(name='save', value=figpath) |
|
85 | 86 | opObj11.addParameter(name='showprofile', value=0) |
|
86 | 87 | opObj11.addParameter(name='save_period', value=10) |
|
87 | 88 | |
|
88 | 89 | |
|
89 | 90 | controllerObj.start() |
@@ -1,75 +1,78 | |||
|
1 | 1 | import os,sys,json |
|
2 | 2 | import datetime |
|
3 | 3 | import time |
|
4 | 4 | from schainpy.controller import Project |
|
5 | 5 | ''' |
|
6 | 6 | NOTA: |
|
7 | 7 | Este script de prueba. |
|
8 | 8 | - Unidad del lectura 'HDFReader'. |
|
9 | 9 | - Unidad de procesamiento ParametersProc |
|
10 | 10 | - Operacion SpectralMomentsPlot |
|
11 | 11 | |
|
12 | 12 | ''' |
|
13 | 13 | |
|
14 | 14 | ####################################################################### |
|
15 | 15 | ################# RANGO DE PLOTEO###################################### |
|
16 | 16 | ####################################################################### |
|
17 | 17 | dBmin = '1' |
|
18 | 18 | dBmax = '65' |
|
19 | 19 | xmin = '0' |
|
20 | 20 | xmax ='24' |
|
21 | tmmin = 16.2 | |
|
22 | tmmax = 16.25 | |
|
21 | #tmmin = 16.2 | |
|
22 | #tmmax = 16.25 | |
|
23 | tmmin =15 | |
|
24 | tmmax =15.5 | |
|
23 | 25 | ymin = '0' |
|
24 | 26 | ymax = '600' |
|
25 | 27 | ####################################################################### |
|
26 | 28 | ####################################################################### |
|
27 | 29 | ####################################################################### |
|
28 | path = '/DATA_RM/TEST_HDF5_SPEC' | |
|
29 | figpath = '/home/soporte/Downloads/IMAGE' | |
|
30 | #path = '/DATA_RM/TEST_HDF5_SPEC' | |
|
31 | path = '/DATA_RM/TEST_HDF5_SPEC_23/6v/' | |
|
32 | figpath = '/home/soporte/Downloads/23/6v' | |
|
30 | 33 | desc = "Simulator Test" |
|
31 | 34 | desc_data = { |
|
32 | 35 | 'Data': { |
|
33 | 36 | 'data_pow': ['Data/data_pow/channel00','Data/data_pow/channel01'], |
|
34 | 37 | 'data_dop': ['Data/data_dop/channel00','Data/data_dop/channel01'], |
|
35 | 38 | 'utctime':'Data/utctime' |
|
36 | 39 | }, |
|
37 | 40 | 'Metadata': { |
|
38 | 41 | 'heightList':'Metadata/heightList', |
|
39 | 42 | 'nIncohInt' :'Metadata/nIncohInt', |
|
40 | 43 | 'nCohInt' :'Metadata/nCohInt', |
|
41 | 44 | 'nProfiles' :'Metadata/nProfiles', |
|
42 | 45 | 'channelList' :'Metadata/channelList', |
|
43 | 46 | 'utctimeInit' :'Metadata/utctimeInit' |
|
44 | 47 | |
|
45 | 48 | } |
|
46 | 49 | } |
|
47 | 50 | |
|
48 | 51 | controllerObj = Project() |
|
49 | 52 | |
|
50 | 53 | controllerObj.setup(id='10',name='Test Simulator',description=desc) |
|
51 | 54 | |
|
52 | 55 | readUnitConfObj = controllerObj.addReadUnit(datatype='HDFReader', |
|
53 | 56 | path=path, |
|
54 | 57 | startDate="2021/01/01", #"2020/01/01",#today, |
|
55 | 58 | endDate= "2021/12/01", #"2020/12/30",#today, |
|
56 | 59 | startTime='00:00:00', |
|
57 | 60 | endTime='23:59:59', |
|
58 | 61 | delay=0, |
|
59 | 62 | #set=0, |
|
60 | 63 | online=0, |
|
61 | 64 | walk=1, |
|
62 | 65 | description= json.dumps(desc_data))#1 |
|
63 | 66 | |
|
64 | 67 | procUnitConfObjA = controllerObj.addProcUnit(datatype='ParametersProc',inputId=readUnitConfObj.getId()) |
|
65 | 68 | |
|
66 | 69 | opObj11 = procUnitConfObjA.addOperation(name='PowerPlot',optype='external') |
|
67 | 70 | opObj11.addParameter(name='xmin', value=tmmin) |
|
68 | 71 | opObj11.addParameter(name='xmax', value=tmmax) |
|
69 | 72 | opObj11.addParameter(name='zmin', value=dBmin) |
|
70 | 73 | opObj11.addParameter(name='zmax', value=dBmax) |
|
71 | 74 | opObj11.addParameter(name='save', value=figpath) |
|
72 | 75 | opObj11.addParameter(name='showprofile', value=0) |
|
73 | 76 | opObj11.addParameter(name='save_period', value=10) |
|
74 | 77 | |
|
75 | 78 | controllerObj.start() |
General Comments 0
You need to be logged in to leave comments.
Login now