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) |
@@ -400,228 +400,119 class WeatherPlot(Plot): | |||||
400 | data = {} |
|
400 | data = {} | |
401 | meta = {} |
|
401 | meta = {} | |
402 | data['weather'] = 10*numpy.log10(dataOut.data_360[0]/(250**2)) |
|
402 | data['weather'] = 10*numpy.log10(dataOut.data_360[0]/(250**2)) | |
|
403 | print(data['weather']) | |||
403 | data['azi'] = dataOut.data_azi |
|
404 | data['azi'] = dataOut.data_azi | |
404 |
|
405 | print("UPDATE",data['azi']) | ||
405 | return data, meta |
|
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 | def plot(self): |
|
473 | def plot(self): | |
408 | thisDatetime = datetime.datetime.utcfromtimestamp(self.data.times[-1]) |
|
|||
409 | print("--------------------------------------",self.ini,"-----------------------------------") |
|
474 | print("--------------------------------------",self.ini,"-----------------------------------") | |
410 | print("time",self.data.times[-1]) |
|
475 | #numpy.set_printoptions(suppress=True) | |
411 | data = self.data[-1] |
|
476 | #print(self.data.times) | |
412 | #print("debug_0", data) |
|
477 | thisDatetime = datetime.datetime.utcfromtimestamp(self.data.times[-1]) | |
413 | tmp_h = (data['weather'].shape[1])/10.0 |
|
478 | data = self.data[-1] | |
414 | #print("debug_1",tmp_h) |
|
479 | # ALTURA altura_tmp_h | |
415 | stoprange = float(tmp_h*1.5)#stoprange = float(33*1.5) por ahora 400 |
|
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 | rangestep = float(0.15) |
|
482 | rangestep = float(0.15) | |
417 | r = numpy.arange(0, stoprange, rangestep) |
|
483 | r = numpy.arange(0, stoprange, rangestep) | |
418 | self.y = 2*r |
|
484 | self.y = 2*r | |
419 | print("---------------") |
|
485 | # RADAR | |
420 |
|
|
486 | #data_weather = data['weather'] | |
421 | #print("tmp_v",tmp_v.shape) |
|
487 | # PEDESTAL | |
422 |
|
|
488 | #data_azi = data['azi'] | |
423 | print("tmp_z-------------->",tmp_z) |
|
489 | res = 1 | |
424 | ##if self.ini==0: |
|
490 | # STEP | |
425 | ## tmp_z= [0,1,2,3,4,5,6,7,8,9] |
|
491 | step = (360/(res*data['weather'].shape[0])) | |
426 |
|
492 | #print("shape wr_data", wr_data.shape) | ||
427 |
#print(" |
|
493 | #print("shape wr_azi",wr_azi.shape) | |
428 | res = 1 |
|
|||
429 | step = (360/(res*tmp_v.shape[0])) |
|
|||
430 | #print("step",step) |
|
494 | #print("step",step) | |
431 | mode = 1 |
|
495 | print("Time---->",self.data.times[-1],thisDatetime) | |
432 | if mode==0: |
|
496 | #print("alturas", len(self.y)) | |
433 | #print("self.ini",self.ini) |
|
497 | self.res_weather, self.res_azi = self.const_ploteo(data_weather=data['weather'],data_azi=data['azi'],step=step,res=res) | |
434 | val = numpy.mean(tmp_v[:,0]) |
|
498 | #numpy.set_printoptions(suppress=True) | |
435 | self.len_azi = len(tmp_z) |
|
499 | #print("resultado",self.res_azi) | |
436 | ones = numpy.ones([(360-tmp_v.shape[0]),tmp_v.shape[1]])*val |
|
500 | ########################################################## | |
437 | self.buffer_ini = numpy.vstack((tmp_v,ones)) |
|
501 | ################# PLOTEO ################### | |
438 |
|
502 | ########################################################## | ||
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 |
|
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 | for i,ax in enumerate(self.axes): |
|
504 | for i,ax in enumerate(self.axes): | |
614 | if ax.firsttime: |
|
505 | if ax.firsttime: | |
615 | plt.clf() |
|
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 | else: |
|
508 | else: | |
618 | plt.clf() |
|
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 | caax = cgax.parasites[0] |
|
511 | caax = cgax.parasites[0] | |
621 | paax = cgax.parasites[1] |
|
512 | paax = cgax.parasites[1] | |
622 | cbar = plt.gcf().colorbar(pm, pad=0.075) |
|
513 | cbar = plt.gcf().colorbar(pm, pad=0.075) | |
623 | caax.set_xlabel('x_range [km]') |
|
514 | caax.set_xlabel('x_range [km]') | |
624 | caax.set_ylabel('y_range [km]') |
|
515 | caax.set_ylabel('y_range [km]') | |
625 | plt.text(1.0, 1.05, 'azimuth '+str(thisDatetime)+"step"+str(self.ini), transform=caax.transAxes, va='bottom',ha='right') |
|
516 | plt.text(1.0, 1.05, 'azimuth '+str(thisDatetime)+"step"+str(self.ini), transform=caax.transAxes, va='bottom',ha='right') | |
626 | #import time |
|
517 | ||
627 | #time.sleep(0.5) |
|
518 | self.ini= self.ini+1 |
@@ -27,11 +27,11 class ProcessingUnit(object): | |||||
27 | self.dataOut = None |
|
27 | self.dataOut = None | |
28 | self.isConfig = False |
|
28 | self.isConfig = False | |
29 | self.operations = [] |
|
29 | self.operations = [] | |
30 |
|
30 | |||
31 | def setInput(self, unit): |
|
31 | def setInput(self, unit): | |
32 |
|
32 | |||
33 | self.dataIn = unit.dataOut |
|
33 | self.dataIn = unit.dataOut | |
34 |
|
34 | |||
35 | def getAllowedArgs(self): |
|
35 | def getAllowedArgs(self): | |
36 | if hasattr(self, '__attrs__'): |
|
36 | if hasattr(self, '__attrs__'): | |
37 | return self.__attrs__ |
|
37 | return self.__attrs__ | |
@@ -41,7 +41,7 class ProcessingUnit(object): | |||||
41 | def addOperation(self, conf, operation): |
|
41 | def addOperation(self, conf, operation): | |
42 | ''' |
|
42 | ''' | |
43 | ''' |
|
43 | ''' | |
44 |
|
44 | |||
45 | self.operations.append((operation, conf.type, conf.getKwargs())) |
|
45 | self.operations.append((operation, conf.type, conf.getKwargs())) | |
46 |
|
46 | |||
47 | def getOperationObj(self, objId): |
|
47 | def getOperationObj(self, objId): | |
@@ -64,7 +64,7 class ProcessingUnit(object): | |||||
64 | self.dataOut.error = self.dataIn.error |
|
64 | self.dataOut.error = self.dataIn.error | |
65 | self.dataOut.flagNoData = True |
|
65 | self.dataOut.flagNoData = True | |
66 | except: |
|
66 | except: | |
67 |
err = traceback.format_exc() |
|
67 | err = traceback.format_exc() | |
68 | if 'SchainWarning' in err: |
|
68 | if 'SchainWarning' in err: | |
69 | log.warning(err.split('SchainWarning:')[-1].split('\n')[0].strip(), self.name) |
|
69 | log.warning(err.split('SchainWarning:')[-1].split('\n')[0].strip(), self.name) | |
70 | elif 'SchainError' in err: |
|
70 | elif 'SchainError' in err: | |
@@ -72,14 +72,17 class ProcessingUnit(object): | |||||
72 | else: |
|
72 | else: | |
73 | log.error(err, self.name) |
|
73 | log.error(err, self.name) | |
74 | self.dataOut.error = True |
|
74 | self.dataOut.error = True | |
75 |
|
75 | ##### correcion de la declaracion Out | ||
76 | for op, optype, opkwargs in self.operations: |
|
76 | for op, optype, opkwargs in self.operations: | |
|
77 | aux = self.dataOut.copy() | |||
77 | if optype == 'other' and not self.dataOut.flagNoData: |
|
78 | if optype == 'other' and not self.dataOut.flagNoData: | |
78 | self.dataOut = op.run(self.dataOut, **opkwargs) |
|
79 | self.dataOut = op.run(self.dataOut, **opkwargs) | |
79 | elif optype == 'external' and not self.dataOut.flagNoData: |
|
80 | elif optype == 'external' and not self.dataOut.flagNoData: | |
80 | op.queue.put(self.dataOut) |
|
81 | #op.queue.put(self.dataOut) | |
81 | elif optype == 'external' and self.dataOut.error: |
|
82 | op.queue.put(aux) | |
82 | op.queue.put(self.dataOut) |
|
83 | elif optype == 'external' and self.dataOut.error: | |
|
84 | #op.queue.put(self.dataOut) | |||
|
85 | op.queue.put(aux) | |||
83 |
|
86 | |||
84 | return 'Error' if self.dataOut.error else self.dataOut.isReady() |
|
87 | return 'Error' if self.dataOut.error else self.dataOut.isReady() | |
85 |
|
88 | |||
@@ -100,7 +103,7 class Operation(object): | |||||
100 |
|
103 | |||
101 | ''' |
|
104 | ''' | |
102 | ''' |
|
105 | ''' | |
103 |
|
106 | |||
104 | proc_type = 'operation' |
|
107 | proc_type = 'operation' | |
105 |
|
108 | |||
106 | def __init__(self): |
|
109 | def __init__(self): | |
@@ -149,12 +152,12 class Operation(object): | |||||
149 |
|
152 | |||
150 | return |
|
153 | return | |
151 |
|
154 | |||
152 |
|
155 | |||
153 | def MPDecorator(BaseClass): |
|
156 | def MPDecorator(BaseClass): | |
154 | """ |
|
157 | """ | |
155 | Multiprocessing class decorator |
|
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 | class MPClass(BaseClass, Process): |
|
163 | class MPClass(BaseClass, Process): | |
@@ -169,17 +172,17 def MPDecorator(BaseClass): | |||||
169 | self.op_type = 'external' |
|
172 | self.op_type = 'external' | |
170 | self.name = BaseClass.__name__ |
|
173 | self.name = BaseClass.__name__ | |
171 | self.__doc__ = BaseClass.__doc__ |
|
174 | self.__doc__ = BaseClass.__doc__ | |
172 |
|
175 | |||
173 | if 'plot' in self.name.lower() and not self.name.endswith('_'): |
|
176 | if 'plot' in self.name.lower() and not self.name.endswith('_'): | |
174 | self.name = '{}{}'.format(self.CODE.upper(), 'Plot') |
|
177 | self.name = '{}{}'.format(self.CODE.upper(), 'Plot') | |
175 |
|
178 | |||
176 | self.start_time = time.time() |
|
179 | self.start_time = time.time() | |
177 | self.err_queue = args[3] |
|
180 | self.err_queue = args[3] | |
178 | self.queue = Queue(maxsize=1) |
|
181 | self.queue = Queue(maxsize=1) | |
179 | self.myrun = BaseClass.run |
|
182 | self.myrun = BaseClass.run | |
180 |
|
183 | |||
181 | def run(self): |
|
184 | def run(self): | |
182 |
|
185 | |||
183 | while True: |
|
186 | while True: | |
184 |
|
187 | |||
185 | dataOut = self.queue.get() |
|
188 | dataOut = self.queue.get() | |
@@ -188,7 +191,7 def MPDecorator(BaseClass): | |||||
188 | try: |
|
191 | try: | |
189 | BaseClass.run(self, dataOut, **self.kwargs) |
|
192 | BaseClass.run(self, dataOut, **self.kwargs) | |
190 | except: |
|
193 | except: | |
191 |
err = traceback.format_exc() |
|
194 | err = traceback.format_exc() | |
192 | log.error(err, self.name) |
|
195 | log.error(err, self.name) | |
193 | else: |
|
196 | else: | |
194 | break |
|
197 | break |
@@ -4079,8 +4079,16 class PedestalInformation(Operation): | |||||
4079 |
|
4079 | |||
4080 | return c-1,utc_ped_list[c-1],utc_ped_list[c] |
|
4080 | return c-1,utc_ped_list[c-1],utc_ped_list[c] | |
4081 |
|
4081 | |||
4082 |
|
4082 | def verificarNROFILE(self,dataOut,utc_ped,f_a_p,n_Muestras_p): | ||
4083 | def setup_offline(self,list_pedestal,list_adq): |
|
4083 | var =int(f_a_p/n_Muestras_p) | |
|
4084 | flag=0 | |||
|
4085 | for i in range(var): | |||
|
4086 | if dataOut.utctime+i==utc_ped: | |||
|
4087 | flag==1 | |||
|
4088 | break | |||
|
4089 | return flag | |||
|
4090 | ||||
|
4091 | def setup_offline(self,dataOut,list_pedestal,list_adq): | |||
4084 | print("SETUP OFFLINE") |
|
4092 | print("SETUP OFFLINE") | |
4085 | print(self.path_ped) |
|
4093 | print(self.path_ped) | |
4086 | print(self.path_adq) |
|
4094 | print(self.path_adq) | |
@@ -4095,7 +4103,11 class PedestalInformation(Operation): | |||||
4095 | print("dios existe donde esta") |
|
4103 | print("dios existe donde esta") | |
4096 | #print("utc_ped_list",utc_ped_list) |
|
4104 | #print("utc_ped_list",utc_ped_list) | |
4097 | print("utc_adq",utc_adq) |
|
4105 | print("utc_adq",utc_adq) | |
4098 | nro_file,utc_ped,utc_ped_1ss = self.getNROFile(utc_adq=utc_adq, utc_ped_list= utc_ped_list) |
|
4106 | # utc_adq_dataOut | |
|
4107 | utc_adq_dataOut =dataOut.utctime | |||
|
4108 | print("Offline-utc_adq_dataout",utc_adq_dataOut) | |||
|
4109 | ||||
|
4110 | nro_file,utc_ped,utc_ped_1 = self.getNROFile(utc_adq=utc_adq, utc_ped_list= utc_ped_list) | |||
4099 |
|
4111 | |||
4100 | print("nro_file",nro_file,"utc_ped",utc_ped) |
|
4112 | print("nro_file",nro_file,"utc_ped",utc_ped) | |
4101 | print("nro_file",i) |
|
4113 | print("nro_file",i) | |
@@ -4135,82 +4147,6 class PedestalInformation(Operation): | |||||
4135 | self.nro_file = nro_file |
|
4147 | self.nro_file = nro_file | |
4136 | self.nro_key_p = nro_key_p |
|
4148 | self.nro_key_p = nro_key_p | |
4137 |
|
4149 | |||
4138 |
|
||||
4139 | ''' |
|
|||
4140 | print("############################") |
|
|||
4141 | utc_adq = dataOut.utctime |
|
|||
4142 | print("ONLINE",dataOut.utctime) |
|
|||
4143 | print("utc_adq" , utc_adq) |
|
|||
4144 | utc_pedestal= self.gettimeutcfromDirFilename(path=self.path_ped,file=self.list_pedestal[0]) |
|
|||
4145 | print("utc_pedestal", utc_pedestal) |
|
|||
4146 | flag_i = 0 |
|
|||
4147 | flag = 0 |
|
|||
4148 | ready = 0 |
|
|||
4149 | if len(self.list_pedestal)!=0: |
|
|||
4150 | enable_p=1 |
|
|||
4151 | if (enable_p!=0): |
|
|||
4152 | while(flag_i==0): |
|
|||
4153 | if utc_adq>utc_pedestal: |
|
|||
4154 | nro_file = int((utc_adq - utc_pedestal)/(self.t_Interval_p*self.n_Muestras_p)) |
|
|||
4155 | print("nro_file--------------------",nro_file) |
|
|||
4156 | print(len(self.list_pedestal)) |
|
|||
4157 | if nro_file> len(self.list_pedestal): |
|
|||
4158 | nro_file = len(self.list_pedestal)-1 |
|
|||
4159 | ff_pedestal = self.list_pedestal[nro_file] |
|
|||
4160 | print(ff_pedestal) |
|
|||
4161 | utc_pedestal = self.gettimeutcfromDirFilename(path=self.path_ped,file=ff_pedestal) |
|
|||
4162 | while(flag==0): |
|
|||
4163 | print("adq",utc_adq) |
|
|||
4164 | print("ped",utc_pedestal) |
|
|||
4165 | print("nro_file",nro_file) |
|
|||
4166 | if utc_adq >utc_pedestal: |
|
|||
4167 | print("DENTRO DEL IF-SETUP") |
|
|||
4168 | ff_pedestal = self.list_pedestal[nro_file] |
|
|||
4169 | if 0<(utc_adq - utc_pedestal)<(self.t_Interval_p*self.n_Muestras_p): |
|
|||
4170 | nro_file= nro_file |
|
|||
4171 | ff_pedestal = self.list_pedestal[nro_file] |
|
|||
4172 | ready = 1 |
|
|||
4173 | if (utc_adq-utc_pedestal)>(self.t_Interval_p*self.n_Muestras_p): |
|
|||
4174 | nro_tmp= int((utc_adq-utc_pedestal)/(self.n_Muestras_p)) |
|
|||
4175 | nro_file= nro_file+1*nro_tmp#chsssssssssssssssssssasssddasdas/ equear esta condicion |
|
|||
4176 | if nro_tmp==0: |
|
|||
4177 | nro_file= nro_file +1 |
|
|||
4178 | ff_pedestal = self.list_pedestal[nro_file] |
|
|||
4179 | print("",ff_pedestal) |
|
|||
4180 | utc_pedestal = self.gettimeutcfromDirFilename(path=self.path_ped,file=ff_pedestal) |
|
|||
4181 | else: |
|
|||
4182 | print("DENTRO DEL ELSE-SETUP") |
|
|||
4183 | nro_tmp= int((utc_pedestal-utc_adq)/(self.n_Muestras_p)) |
|
|||
4184 | if utc_pedestal>utc_adq and nro_tmp==0: |
|
|||
4185 | nro_tmp= int((utc_pedestal-utc_adq)) |
|
|||
4186 | print("nro_tmp",nro_tmp) |
|
|||
4187 | if nro_file>nro_tmp: |
|
|||
4188 | nro_file = nro_file-1*nro_tmp |
|
|||
4189 | else: |
|
|||
4190 | nro_file =nro_file -1 |
|
|||
4191 |
|
||||
4192 | ff_pedestal = self.list_pedestal[nro_file] |
|
|||
4193 | utc_pedestal = self.gettimeutcfromDirFilename(path=self.path_ped,file=ff_pedestal) |
|
|||
4194 |
|
||||
4195 | if ready: |
|
|||
4196 | angulo = self.getDatavaluefromDirFilename(path=self.path_ped,file=ff_pedestal,value="azimuth") |
|
|||
4197 | nro_key_p = int((utc_adq-utc_pedestal)/self.t_Interval_p) |
|
|||
4198 | print("nro_file :",nro_file) |
|
|||
4199 | print("name_file :",ff_pedestal) |
|
|||
4200 | print("utc_pedestal_file :",utc_pedestal) |
|
|||
4201 | print("nro_key_p :",nro_key_p) |
|
|||
4202 | print("utc_pedestal_init :",utc_pedestal+nro_key_p*self.t_Interval_p) |
|
|||
4203 | print("angulo_array :",angulo[nro_key_p]) |
|
|||
4204 | flag=1 |
|
|||
4205 | flag_i=1 |
|
|||
4206 | else: |
|
|||
4207 | print("La lista de archivos de pedestal o adq esta vacia") |
|
|||
4208 | nro_file=None |
|
|||
4209 | nro_key_p=None |
|
|||
4210 | self.nro_file = nro_file |
|
|||
4211 | self.nro_key_p = nro_key_p |
|
|||
4212 | ''' |
|
|||
4213 |
|
||||
4214 | def setup(self,dataOut,path_ped,path_adq,t_Interval_p,n_Muestras_p,blocksPerfile,f_a_p,online): |
|
4150 | def setup(self,dataOut,path_ped,path_adq,t_Interval_p,n_Muestras_p,blocksPerfile,f_a_p,online): | |
4215 | self.__dataReady = False |
|
4151 | self.__dataReady = False | |
4216 | self.path_ped = path_ped |
|
4152 | self.path_ped = path_ped | |
@@ -4235,18 +4171,18 class PedestalInformation(Operation): | |||||
4235 | print("Enable Online") |
|
4171 | print("Enable Online") | |
4236 | self.setup_online(dataOut) |
|
4172 | self.setup_online(dataOut) | |
4237 | else: |
|
4173 | else: | |
4238 | self.setup_offline(list_pedestal=self.list_pedestal,list_adq=self.list_adq) |
|
4174 | self.setup_offline(dataOut,list_pedestal=self.list_pedestal,list_adq=self.list_adq) | |
4239 |
|
4175 | |||
4240 | def setNextFileP(self,dataOut): |
|
4176 | def setNextFileP(self,dataOut): | |
4241 | if self.online: |
|
4177 | if self.online: | |
4242 | data_pedestal = self.setNextFileonline() |
|
4178 | data_pedestal = self.setNextFileonline() | |
4243 | else: |
|
4179 | else: | |
4244 | data_pedestal = self.setNextFileoffline() |
|
4180 | data_pedestal = self.setNextFileoffline(dataOut) | |
4245 |
|
4181 | |||
4246 | return data_pedestal |
|
4182 | return data_pedestal | |
4247 |
|
4183 | |||
4248 |
|
4184 | |||
4249 | def setNextFileoffline(self): |
|
4185 | def setNextFileoffline(self,dataOut): | |
4250 | ##tmp=0 |
|
4186 | ##tmp=0 | |
4251 | for j in range(self.blocksPerfile): |
|
4187 | for j in range(self.blocksPerfile): | |
4252 | ###print("NUMERO DEL BLOQUE---->",j) |
|
4188 | ###print("NUMERO DEL BLOQUE---->",j) | |
@@ -4261,6 +4197,13 class PedestalInformation(Operation): | |||||
4261 | self.nro_file = self.nro_file |
|
4197 | self.nro_file = self.nro_file | |
4262 | else: |
|
4198 | else: | |
4263 | self.nro_file = self.nro_file+1 |
|
4199 | self.nro_file = self.nro_file+1 | |
|
4200 | print("PRUEBA-------------") | |||
|
4201 | utc_ped_setnext=self.gettimeutcfromDirFilename(path=self.path_ped,file=self.list_pedestal[self.nro_file]) | |||
|
4202 | utc_adq_setnext=dataOut.utctime | |||
|
4203 | print("utc_pedestal",utc_ped_setnext) | |||
|
4204 | print("utc_adq",utc_adq_setnext) | |||
|
4205 | ||||
|
4206 | ||||
4264 | dif = self.blocksPerfile-(self.nro_key_p+self.f_a_p*(self.c_ped-2)) |
|
4207 | dif = self.blocksPerfile-(self.nro_key_p+self.f_a_p*(self.c_ped-2)) | |
4265 | self.c_ped = 1 |
|
4208 | self.c_ped = 1 | |
4266 | ##tmp = j |
|
4209 | ##tmp = j | |
@@ -4274,7 +4217,9 class PedestalInformation(Operation): | |||||
4274 | #print("tmp",tmp) |
|
4217 | #print("tmp",tmp) | |
4275 | try: |
|
4218 | try: | |
4276 | ff_pedestal = self.list_pedestal[self.nro_file] |
|
4219 | ff_pedestal = self.list_pedestal[self.nro_file] | |
|
4220 | print("ff_pedestal",ff_pedestal) | |||
4277 | except: |
|
4221 | except: | |
|
4222 | print("############# EXCEPCION ######################") | |||
4278 | return numpy.ones(self.blocksPerfile)*numpy.nan |
|
4223 | return numpy.ones(self.blocksPerfile)*numpy.nan | |
4279 |
|
4224 | |||
4280 | #angulo = self.getDatavaluefromDirFilename(path=self.path_ped,file=ff_pedestal,value="azimuth") |
|
4225 | #angulo = self.getDatavaluefromDirFilename(path=self.path_ped,file=ff_pedestal,value="azimuth") | |
@@ -4343,6 +4288,7 class PedestalInformation(Operation): | |||||
4343 |
|
4288 | |||
4344 | def run(self, dataOut,path_ped,path_adq,t_Interval_p,n_Muestras_p,blocksPerfile,f_a_p,online): |
|
4289 | def run(self, dataOut,path_ped,path_adq,t_Interval_p,n_Muestras_p,blocksPerfile,f_a_p,online): | |
4345 | if not self.isConfig: |
|
4290 | if not self.isConfig: | |
|
4291 | print("######################SETUP#########################################") | |||
4346 | self.setup( dataOut, path_ped,path_adq,t_Interval_p,n_Muestras_p,blocksPerfile,f_a_p,online) |
|
4292 | self.setup( dataOut, path_ped,path_adq,t_Interval_p,n_Muestras_p,blocksPerfile,f_a_p,online) | |
4347 | self.isConfig = True |
|
4293 | self.isConfig = True | |
4348 |
|
4294 | |||
@@ -4352,10 +4298,12 class PedestalInformation(Operation): | |||||
4352 | if self.__profIndex==0: |
|
4298 | if self.__profIndex==0: | |
4353 | angulo_adq = self.setNextFileP(dataOut) |
|
4299 | angulo_adq = self.setNextFileP(dataOut) | |
4354 | dataOut.azimuth = angulo_adq |
|
4300 | dataOut.azimuth = angulo_adq | |
|
4301 | print("TIEMPO:",dataOut.utctime) | |||
4355 | ##print("####################################################################") |
|
4302 | ##print("####################################################################") | |
4356 | ##print("angulos",dataOut.azimuth,len(dataOut.azimuth)) |
|
4303 | ##print("angulos",dataOut.azimuth,len(dataOut.azimuth)) | |
4357 | self.__dataReady = True |
|
4304 | self.__dataReady = True | |
4358 | self.__profIndex += 1 |
|
4305 | self.__profIndex += 1 | |
|
4306 | print("TIEMPO_bucle:",dataOut.utctime) | |||
4359 | if self.__profIndex== blocksPerfile: |
|
4307 | if self.__profIndex== blocksPerfile: | |
4360 | self.__profIndex = 0 |
|
4308 | self.__profIndex = 0 | |
4361 | if self.__dataReady: |
|
4309 | if self.__dataReady: |
@@ -25,8 +25,28 controllerObj.setup(id = '191', name='Test_USRP', description=desc) | |||||
25 | #path = '/media/data/data/vientos/57.2063km/echoes/NCO_Woodman' |
|
25 | #path = '/media/data/data/vientos/57.2063km/echoes/NCO_Woodman' | |
26 | #path = '/DATA_RM/TEST_INTEGRACION' |
|
26 | #path = '/DATA_RM/TEST_INTEGRACION' | |
27 | #path = '/DATA_RM/TEST_ONLINE' |
|
27 | #path = '/DATA_RM/TEST_ONLINE' | |
28 | path = '/DATA_RM/TEST_INTEGRACION/ADQ_OFFLINE/' |
|
28 | #path = '/DATA_RM/TEST_INTEGRACION/ADQ_OFFLINE/' | |
29 | path_pp = '/DATA_RM/TEST_HDF5' |
|
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 | figpath = '/home/soporte/Pictures/TEST_INTEGRACION_IMG' |
|
51 | figpath = '/home/soporte/Pictures/TEST_INTEGRACION_IMG' | |
32 | #remotefolder = "/home/wmaster/graficos" |
|
52 | #remotefolder = "/home/wmaster/graficos" | |
@@ -76,7 +96,7 procUnitConfObjA = controllerObj.addProcUnit(datatype='VoltageProc', inputId=rea | |||||
76 | #opObj11 = procUnitConfObjA.addOperation(name='setRadarFrequency') |
|
96 | #opObj11 = procUnitConfObjA.addOperation(name='setRadarFrequency') | |
77 | #opObj11.addParameter(name='frequency', value='70312500') |
|
97 | #opObj11.addParameter(name='frequency', value='70312500') | |
78 | opObj11 = procUnitConfObjA.addOperation(name='PulsePair', optype='other') |
|
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 | opObj11.addParameter(name='removeDC', value=1, format='int') |
|
100 | opObj11.addParameter(name='removeDC', value=1, format='int') | |
81 | # Ploteo TEST |
|
101 | # Ploteo TEST | |
82 | ''' |
|
102 | ''' |
@@ -28,11 +28,16 controllerObj.setup(id = '191', name='Test_USRP', description=desc) | |||||
28 | #path_pp = '/DATA_RM/TEST_HDF5' |
|
28 | #path_pp = '/DATA_RM/TEST_HDF5' | |
29 |
|
29 | |||
30 | #figpath = '/home/soporte/Pictures/TEST_INTEGRACION_IMG' |
|
30 | #figpath = '/home/soporte/Pictures/TEST_INTEGRACION_IMG' | |
31 | path = '/DATA_RM/TEST_INTEGRACION/ADQ_OFFLINE/' |
|
31 | ###path = '/DATA_RM/TEST_INTEGRACION/ADQ_OFFLINE/' | |
32 | path_pp = '/DATA_RM/TEST_HDF5_SPEC' |
|
32 | ###path_pp = '/DATA_RM/TEST_HDF5_SPEC' | |
33 |
|
||||
34 |
|
||||
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 | #remotefolder = "/home/wmaster/graficos" |
|
43 | #remotefolder = "/home/wmaster/graficos" | |
@@ -73,11 +78,17 opObj11 = readUnitConfObj.addOperation(name='printInfo') | |||||
73 | ################ OPERACIONES DOMINIO DEL TIEMPO######################## |
|
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 | procUnitConfObjA = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId()) |
|
87 | procUnitConfObjA = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId()) | |
77 |
|
88 | |||
78 | procUnitConfObjB = controllerObj.addProcUnit(datatype='SpectraProc', inputId=procUnitConfObjA.getId()) |
|
89 | procUnitConfObjB = controllerObj.addProcUnit(datatype='SpectraProc', inputId=procUnitConfObjA.getId()) | |
79 |
procUnitConfObjB.addParameter(name='nFFTPoints', value= |
|
90 | procUnitConfObjB.addParameter(name='nFFTPoints', value=n, format='int') | |
80 |
procUnitConfObjB.addParameter(name='nProfiles' , value= |
|
91 | procUnitConfObjB.addParameter(name='nProfiles' , value=n, format='int') | |
81 |
|
92 | |||
82 |
|
93 | |||
83 |
|
94 |
@@ -10,14 +10,21 from schainpy.controller import Project | |||||
10 | #path='/DATA_RM/TEST_HDF5/d2021231' |
|
10 | #path='/DATA_RM/TEST_HDF5/d2021231' | |
11 | #path='/DATA_RM/TEST_HDF5/ADQ_OFFLINE/d2021231' |
|
11 | #path='/DATA_RM/TEST_HDF5/ADQ_OFFLINE/d2021231' | |
12 | path='/DATA_RM/TEST_HDF5/d2021231' |
|
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 | path_adq=path |
|
16 | path_adq=path | |
15 | #path_ped='/DATA_RM/TEST_PEDESTAL/P2021200' |
|
17 | #path_ped='/DATA_RM/TEST_PEDESTAL/P2021200' | |
16 | #path_ped='/DATA_RM/TEST_PEDESTAL/P2021214' |
|
18 | #path_ped='/DATA_RM/TEST_PEDESTAL/P2021214' | |
17 | #path_ped='/DATA_RM/TEST_PEDESTAL/P2021230' |
|
19 | #path_ped='/DATA_RM/TEST_PEDESTAL/P2021230' | |
18 | #path_ped='/DATA_RM/TEST_PEDESTAL/P20210819' |
|
20 | #path_ped='/DATA_RM/TEST_PEDESTAL/P20210819' | |
19 | #path_ped='/DATA_RM/TEST_PEDESTAL/P20210819-154315' |
|
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 | figpath = '/home/soporte/Pictures' |
|
30 | figpath = '/home/soporte/Pictures' | |
@@ -40,6 +47,10 readUnitConfObj = controllerObj.addReadUnit(datatype='HDFReader', | |||||
40 | nTries=6)#1 |
|
47 | nTries=6)#1 | |
41 |
|
48 | |||
42 | procUnitConfObjA = controllerObj.addProcUnit(datatype='ParametersProc',inputId=readUnitConfObj.getId()) |
|
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 | opObj11 = procUnitConfObjA.addOperation(name='PedestalInformation') |
|
55 | opObj11 = procUnitConfObjA.addOperation(name='PedestalInformation') | |
45 | opObj11.addParameter(name='path_ped', value=path_ped) |
|
56 | opObj11.addParameter(name='path_ped', value=path_ped) | |
@@ -47,7 +58,7 opObj11.addParameter(name='path_adq', value=path_adq) | |||||
47 | opObj11.addParameter(name='t_Interval_p', value='0.01', format='float') |
|
58 | opObj11.addParameter(name='t_Interval_p', value='0.01', format='float') | |
48 | opObj11.addParameter(name='n_Muestras_p', value='100', format='float') |
|
59 | opObj11.addParameter(name='n_Muestras_p', value='100', format='float') | |
49 | opObj11.addParameter(name='blocksPerfile', value='100', format='int') |
|
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 | opObj11.addParameter(name='online', value='0', format='int')# habilitar el enable aqui tambien |
|
62 | opObj11.addParameter(name='online', value='0', format='int')# habilitar el enable aqui tambien | |
52 |
|
63 | |||
53 |
|
64 | |||
@@ -56,8 +67,8 opObj11.addParameter(name='n', value='10', format='int') | |||||
56 | # este bloque funciona bien con divisores de 360 no olvidar 0 10 20 30 40 60 90 120 180 |
|
67 | # este bloque funciona bien con divisores de 360 no olvidar 0 10 20 30 40 60 90 120 180 | |
57 |
|
68 | |||
58 | opObj11= procUnitConfObjA.addOperation(name='WeatherPlot',optype='other') |
|
69 | opObj11= procUnitConfObjA.addOperation(name='WeatherPlot',optype='other') | |
59 | opObj11.addParameter(name='save', value=figpath) |
|
70 | #opObj11.addParameter(name='save', value=figpath) | |
60 | opObj11.addParameter(name='save_period', value=1) |
|
71 | #opObj11.addParameter(name='save_period', value=1) | |
61 |
|
72 | |||
62 | controllerObj.start() |
|
73 | controllerObj.start() | |
63 | #online 1 utc_adq 1617490240.48 |
|
74 | #online 1 utc_adq 1617490240.48 |
@@ -19,8 +19,8 dBmin = '1' | |||||
19 | dBmax = '85' |
|
19 | dBmax = '85' | |
20 | xmin = '0' |
|
20 | xmin = '0' | |
21 | xmax ='24' |
|
21 | xmax ='24' | |
22 |
tmmin = 1 |
|
22 | tmmin = 12.2 | |
23 |
tmmax = 1 |
|
23 | tmmax = 12.40 | |
24 | ymin = '0' |
|
24 | ymin = '0' | |
25 | ymax = '600' |
|
25 | ymax = '600' | |
26 | ####################################################################### |
|
26 | ####################################################################### | |
@@ -32,8 +32,9 ymax = '600' | |||||
32 |
|
32 | |||
33 | ####################################################################### |
|
33 | ####################################################################### | |
34 | ####################################################################### |
|
34 | ####################################################################### | |
35 |
|
35 | #path_pp = '/DATA_RM/TEST_HDF5_PP_22' | ||
36 |
path='/DATA_RM/TEST_HDF5/d20212 |
|
36 | path='/DATA_RM/TEST_HDF5_PP_22/d2021265' | |
|
37 | #path='/DATA_RM/TEST_HDF5/d2021231' | |||
37 | figpath = '/home/soporte/Downloads/IMAGE' |
|
38 | figpath = '/home/soporte/Downloads/IMAGE' | |
38 | desc = "Simulator Test" |
|
39 | desc = "Simulator Test" | |
39 | desc_data = { |
|
40 | desc_data = { |
@@ -18,15 +18,18 dBmin = '1' | |||||
18 | dBmax = '65' |
|
18 | dBmax = '65' | |
19 | xmin = '0' |
|
19 | xmin = '0' | |
20 | xmax ='24' |
|
20 | xmax ='24' | |
21 | tmmin = 16.2 |
|
21 | #tmmin = 16.2 | |
22 | tmmax = 16.25 |
|
22 | #tmmax = 16.25 | |
|
23 | tmmin =15 | |||
|
24 | tmmax =15.5 | |||
23 | ymin = '0' |
|
25 | ymin = '0' | |
24 | ymax = '600' |
|
26 | ymax = '600' | |
25 | ####################################################################### |
|
27 | ####################################################################### | |
26 | ####################################################################### |
|
28 | ####################################################################### | |
27 | ####################################################################### |
|
29 | ####################################################################### | |
28 | path = '/DATA_RM/TEST_HDF5_SPEC' |
|
30 | #path = '/DATA_RM/TEST_HDF5_SPEC' | |
29 | figpath = '/home/soporte/Downloads/IMAGE' |
|
31 | path = '/DATA_RM/TEST_HDF5_SPEC_23/6v/' | |
|
32 | figpath = '/home/soporte/Downloads/23/6v' | |||
30 | desc = "Simulator Test" |
|
33 | desc = "Simulator Test" | |
31 | desc_data = { |
|
34 | desc_data = { | |
32 | 'Data': { |
|
35 | 'Data': { |
General Comments 0
You need to be logged in to leave comments.
Login now