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 | import os |
|
1 | import os | |
2 | import datetime |
|
2 | import datetime | |
3 | import numpy |
|
3 | import numpy | |
4 |
|
4 | |||
5 | from schainpy.model.graphics.jroplot_base import Plot, plt |
|
5 | from schainpy.model.graphics.jroplot_base import Plot, plt | |
6 | from schainpy.model.graphics.jroplot_spectra import SpectraPlot, RTIPlot, CoherencePlot, SpectraCutPlot |
|
6 | from schainpy.model.graphics.jroplot_spectra import SpectraPlot, RTIPlot, CoherencePlot, SpectraCutPlot | |
7 | from schainpy.utils import log |
|
7 | from schainpy.utils import log | |
8 | # libreria wradlib |
|
8 | # libreria wradlib | |
9 | import wradlib as wrl |
|
9 | import wradlib as wrl | |
10 |
|
10 | |||
11 | EARTH_RADIUS = 6.3710e3 |
|
11 | EARTH_RADIUS = 6.3710e3 | |
12 |
|
12 | |||
13 |
|
13 | |||
14 | def ll2xy(lat1, lon1, lat2, lon2): |
|
14 | def ll2xy(lat1, lon1, lat2, lon2): | |
15 |
|
15 | |||
16 | p = 0.017453292519943295 |
|
16 | p = 0.017453292519943295 | |
17 | a = 0.5 - numpy.cos((lat2 - lat1) * p)/2 + numpy.cos(lat1 * p) * \ |
|
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 |
|
18 | numpy.cos(lat2 * p) * (1 - numpy.cos((lon2 - lon1) * p)) / 2 | |
19 | r = 12742 * numpy.arcsin(numpy.sqrt(a)) |
|
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) |
|
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)) |
|
21 | * numpy.sin(lat2*p)-numpy.sin(lat1*p)*numpy.cos(lat2*p)*numpy.cos((lon2-lon1)*p)) | |
22 | theta = -theta + numpy.pi/2 |
|
22 | theta = -theta + numpy.pi/2 | |
23 | return r*numpy.cos(theta), r*numpy.sin(theta) |
|
23 | return r*numpy.cos(theta), r*numpy.sin(theta) | |
24 |
|
24 | |||
25 |
|
25 | |||
26 | def km2deg(km): |
|
26 | def km2deg(km): | |
27 | ''' |
|
27 | ''' | |
28 | Convert distance in km to degrees |
|
28 | Convert distance in km to degrees | |
29 | ''' |
|
29 | ''' | |
30 |
|
30 | |||
31 | return numpy.rad2deg(km/EARTH_RADIUS) |
|
31 | return numpy.rad2deg(km/EARTH_RADIUS) | |
32 |
|
32 | |||
33 |
|
33 | |||
34 |
|
34 | |||
35 | class SpectralMomentsPlot(SpectraPlot): |
|
35 | class SpectralMomentsPlot(SpectraPlot): | |
36 | ''' |
|
36 | ''' | |
37 | Plot for Spectral Moments |
|
37 | Plot for Spectral Moments | |
38 | ''' |
|
38 | ''' | |
39 | CODE = 'spc_moments' |
|
39 | CODE = 'spc_moments' | |
40 | # colormap = 'jet' |
|
40 | # colormap = 'jet' | |
41 | # plot_type = 'pcolor' |
|
41 | # plot_type = 'pcolor' | |
42 |
|
42 | |||
43 | class DobleGaussianPlot(SpectraPlot): |
|
43 | class DobleGaussianPlot(SpectraPlot): | |
44 | ''' |
|
44 | ''' | |
45 | Plot for Double Gaussian Plot |
|
45 | Plot for Double Gaussian Plot | |
46 | ''' |
|
46 | ''' | |
47 | CODE = 'gaussian_fit' |
|
47 | CODE = 'gaussian_fit' | |
48 | # colormap = 'jet' |
|
48 | # colormap = 'jet' | |
49 | # plot_type = 'pcolor' |
|
49 | # plot_type = 'pcolor' | |
50 |
|
50 | |||
51 | class DoubleGaussianSpectraCutPlot(SpectraCutPlot): |
|
51 | class DoubleGaussianSpectraCutPlot(SpectraCutPlot): | |
52 | ''' |
|
52 | ''' | |
53 | Plot SpectraCut with Double Gaussian Fit |
|
53 | Plot SpectraCut with Double Gaussian Fit | |
54 | ''' |
|
54 | ''' | |
55 | CODE = 'cut_gaussian_fit' |
|
55 | CODE = 'cut_gaussian_fit' | |
56 |
|
56 | |||
57 | class SnrPlot(RTIPlot): |
|
57 | class SnrPlot(RTIPlot): | |
58 | ''' |
|
58 | ''' | |
59 | Plot for SNR Data |
|
59 | Plot for SNR Data | |
60 | ''' |
|
60 | ''' | |
61 |
|
61 | |||
62 | CODE = 'snr' |
|
62 | CODE = 'snr' | |
63 | colormap = 'jet' |
|
63 | colormap = 'jet' | |
64 |
|
64 | |||
65 | def update(self, dataOut): |
|
65 | def update(self, dataOut): | |
66 |
|
66 | |||
67 | data = { |
|
67 | data = { | |
68 | 'snr': 10*numpy.log10(dataOut.data_snr) |
|
68 | 'snr': 10*numpy.log10(dataOut.data_snr) | |
69 | } |
|
69 | } | |
70 |
|
70 | |||
71 | return data, {} |
|
71 | return data, {} | |
72 |
|
72 | |||
73 | class DopplerPlot(RTIPlot): |
|
73 | class DopplerPlot(RTIPlot): | |
74 | ''' |
|
74 | ''' | |
75 | Plot for DOPPLER Data (1st moment) |
|
75 | Plot for DOPPLER Data (1st moment) | |
76 | ''' |
|
76 | ''' | |
77 |
|
77 | |||
78 | CODE = 'dop' |
|
78 | CODE = 'dop' | |
79 | colormap = 'jet' |
|
79 | colormap = 'jet' | |
80 |
|
80 | |||
81 | def update(self, dataOut): |
|
81 | def update(self, dataOut): | |
82 |
|
82 | |||
83 | data = { |
|
83 | data = { | |
84 | 'dop': 10*numpy.log10(dataOut.data_dop) |
|
84 | 'dop': 10*numpy.log10(dataOut.data_dop) | |
85 | } |
|
85 | } | |
86 |
|
86 | |||
87 | return data, {} |
|
87 | return data, {} | |
88 |
|
88 | |||
89 | class PowerPlot(RTIPlot): |
|
89 | class PowerPlot(RTIPlot): | |
90 | ''' |
|
90 | ''' | |
91 | Plot for Power Data (0 moment) |
|
91 | Plot for Power Data (0 moment) | |
92 | ''' |
|
92 | ''' | |
93 |
|
93 | |||
94 | CODE = 'pow' |
|
94 | CODE = 'pow' | |
95 | colormap = 'jet' |
|
95 | colormap = 'jet' | |
96 |
|
96 | |||
97 | def update(self, dataOut): |
|
97 | def update(self, dataOut): | |
98 |
|
98 | |||
99 | data = { |
|
99 | data = { | |
100 | 'pow': 10*numpy.log10(dataOut.data_pow/dataOut.normFactor) |
|
100 | 'pow': 10*numpy.log10(dataOut.data_pow/dataOut.normFactor) | |
101 | } |
|
101 | } | |
102 |
|
102 | |||
103 | return data, {} |
|
103 | return data, {} | |
104 |
|
104 | |||
105 | class SpectralWidthPlot(RTIPlot): |
|
105 | class SpectralWidthPlot(RTIPlot): | |
106 | ''' |
|
106 | ''' | |
107 | Plot for Spectral Width Data (2nd moment) |
|
107 | Plot for Spectral Width Data (2nd moment) | |
108 | ''' |
|
108 | ''' | |
109 |
|
109 | |||
110 | CODE = 'width' |
|
110 | CODE = 'width' | |
111 | colormap = 'jet' |
|
111 | colormap = 'jet' | |
112 |
|
112 | |||
113 | def update(self, dataOut): |
|
113 | def update(self, dataOut): | |
114 |
|
114 | |||
115 | data = { |
|
115 | data = { | |
116 | 'width': dataOut.data_width |
|
116 | 'width': dataOut.data_width | |
117 | } |
|
117 | } | |
118 |
|
118 | |||
119 | return data, {} |
|
119 | return data, {} | |
120 |
|
120 | |||
121 | class SkyMapPlot(Plot): |
|
121 | class SkyMapPlot(Plot): | |
122 | ''' |
|
122 | ''' | |
123 | Plot for meteors detection data |
|
123 | Plot for meteors detection data | |
124 | ''' |
|
124 | ''' | |
125 |
|
125 | |||
126 | CODE = 'param' |
|
126 | CODE = 'param' | |
127 |
|
127 | |||
128 | def setup(self): |
|
128 | def setup(self): | |
129 |
|
129 | |||
130 | self.ncols = 1 |
|
130 | self.ncols = 1 | |
131 | self.nrows = 1 |
|
131 | self.nrows = 1 | |
132 | self.width = 7.2 |
|
132 | self.width = 7.2 | |
133 | self.height = 7.2 |
|
133 | self.height = 7.2 | |
134 | self.nplots = 1 |
|
134 | self.nplots = 1 | |
135 | self.xlabel = 'Zonal Zenith Angle (deg)' |
|
135 | self.xlabel = 'Zonal Zenith Angle (deg)' | |
136 | self.ylabel = 'Meridional Zenith Angle (deg)' |
|
136 | self.ylabel = 'Meridional Zenith Angle (deg)' | |
137 | self.polar = True |
|
137 | self.polar = True | |
138 | self.ymin = -180 |
|
138 | self.ymin = -180 | |
139 | self.ymax = 180 |
|
139 | self.ymax = 180 | |
140 | self.colorbar = False |
|
140 | self.colorbar = False | |
141 |
|
141 | |||
142 | def plot(self): |
|
142 | def plot(self): | |
143 |
|
143 | |||
144 | arrayParameters = numpy.concatenate(self.data['param']) |
|
144 | arrayParameters = numpy.concatenate(self.data['param']) | |
145 | error = arrayParameters[:, -1] |
|
145 | error = arrayParameters[:, -1] | |
146 | indValid = numpy.where(error == 0)[0] |
|
146 | indValid = numpy.where(error == 0)[0] | |
147 | finalMeteor = arrayParameters[indValid, :] |
|
147 | finalMeteor = arrayParameters[indValid, :] | |
148 | finalAzimuth = finalMeteor[:, 3] |
|
148 | finalAzimuth = finalMeteor[:, 3] | |
149 | finalZenith = finalMeteor[:, 4] |
|
149 | finalZenith = finalMeteor[:, 4] | |
150 |
|
150 | |||
151 | x = finalAzimuth * numpy.pi / 180 |
|
151 | x = finalAzimuth * numpy.pi / 180 | |
152 | y = finalZenith |
|
152 | y = finalZenith | |
153 |
|
153 | |||
154 | ax = self.axes[0] |
|
154 | ax = self.axes[0] | |
155 |
|
155 | |||
156 | if ax.firsttime: |
|
156 | if ax.firsttime: | |
157 | ax.plot = ax.plot(x, y, 'bo', markersize=5)[0] |
|
157 | ax.plot = ax.plot(x, y, 'bo', markersize=5)[0] | |
158 | else: |
|
158 | else: | |
159 | ax.plot.set_data(x, y) |
|
159 | ax.plot.set_data(x, y) | |
160 |
|
160 | |||
161 | dt1 = self.getDateTime(self.data.min_time).strftime('%y/%m/%d %H:%M:%S') |
|
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') |
|
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, |
|
163 | title = 'Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n' % (dt1, | |
164 | dt2, |
|
164 | dt2, | |
165 | len(x)) |
|
165 | len(x)) | |
166 | self.titles[0] = title |
|
166 | self.titles[0] = title | |
167 |
|
167 | |||
168 |
|
168 | |||
169 | class GenericRTIPlot(Plot): |
|
169 | class GenericRTIPlot(Plot): | |
170 | ''' |
|
170 | ''' | |
171 | Plot for data_xxxx object |
|
171 | Plot for data_xxxx object | |
172 | ''' |
|
172 | ''' | |
173 |
|
173 | |||
174 | CODE = 'param' |
|
174 | CODE = 'param' | |
175 | colormap = 'viridis' |
|
175 | colormap = 'viridis' | |
176 | plot_type = 'pcolorbuffer' |
|
176 | plot_type = 'pcolorbuffer' | |
177 |
|
177 | |||
178 | def setup(self): |
|
178 | def setup(self): | |
179 | self.xaxis = 'time' |
|
179 | self.xaxis = 'time' | |
180 | self.ncols = 1 |
|
180 | self.ncols = 1 | |
181 | self.nrows = self.data.shape('param')[0] |
|
181 | self.nrows = self.data.shape('param')[0] | |
182 | self.nplots = self.nrows |
|
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}) |
|
183 | self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.08, 'right':0.95, 'top': 0.95}) | |
184 |
|
184 | |||
185 | if not self.xlabel: |
|
185 | if not self.xlabel: | |
186 | self.xlabel = 'Time' |
|
186 | self.xlabel = 'Time' | |
187 |
|
187 | |||
188 | self.ylabel = 'Range [km]' |
|
188 | self.ylabel = 'Range [km]' | |
189 | if not self.titles: |
|
189 | if not self.titles: | |
190 | self.titles = ['Param {}'.format(x) for x in range(self.nrows)] |
|
190 | self.titles = ['Param {}'.format(x) for x in range(self.nrows)] | |
191 |
|
191 | |||
192 | def update(self, dataOut): |
|
192 | def update(self, dataOut): | |
193 |
|
193 | |||
194 | data = { |
|
194 | data = { | |
195 | 'param' : numpy.concatenate([getattr(dataOut, attr) for attr in self.attr_data], axis=0) |
|
195 | 'param' : numpy.concatenate([getattr(dataOut, attr) for attr in self.attr_data], axis=0) | |
196 | } |
|
196 | } | |
197 |
|
197 | |||
198 | meta = {} |
|
198 | meta = {} | |
199 |
|
199 | |||
200 | return data, meta |
|
200 | return data, meta | |
201 |
|
201 | |||
202 | def plot(self): |
|
202 | def plot(self): | |
203 | # self.data.normalize_heights() |
|
203 | # self.data.normalize_heights() | |
204 | self.x = self.data.times |
|
204 | self.x = self.data.times | |
205 | self.y = self.data.yrange |
|
205 | self.y = self.data.yrange | |
206 | self.z = self.data['param'] |
|
206 | self.z = self.data['param'] | |
207 |
|
207 | |||
208 | self.z = 10*numpy.log10(self.z) |
|
208 | self.z = 10*numpy.log10(self.z) | |
209 |
|
209 | |||
210 | self.z = numpy.ma.masked_invalid(self.z) |
|
210 | self.z = numpy.ma.masked_invalid(self.z) | |
211 |
|
211 | |||
212 | if self.decimation is None: |
|
212 | if self.decimation is None: | |
213 | x, y, z = self.fill_gaps(self.x, self.y, self.z) |
|
213 | x, y, z = self.fill_gaps(self.x, self.y, self.z) | |
214 | else: |
|
214 | else: | |
215 | x, y, z = self.fill_gaps(*self.decimate()) |
|
215 | x, y, z = self.fill_gaps(*self.decimate()) | |
216 |
|
216 | |||
217 | for n, ax in enumerate(self.axes): |
|
217 | for n, ax in enumerate(self.axes): | |
218 |
|
218 | |||
219 | self.zmax = self.zmax if self.zmax is not None else numpy.max( |
|
219 | self.zmax = self.zmax if self.zmax is not None else numpy.max( | |
220 | self.z[n]) |
|
220 | self.z[n]) | |
221 | self.zmin = self.zmin if self.zmin is not None else numpy.min( |
|
221 | self.zmin = self.zmin if self.zmin is not None else numpy.min( | |
222 | self.z[n]) |
|
222 | self.z[n]) | |
223 |
|
223 | |||
224 | if ax.firsttime: |
|
224 | if ax.firsttime: | |
225 | if self.zlimits is not None: |
|
225 | if self.zlimits is not None: | |
226 | self.zmin, self.zmax = self.zlimits[n] |
|
226 | self.zmin, self.zmax = self.zlimits[n] | |
227 |
|
227 | |||
228 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], |
|
228 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], | |
229 | vmin=self.zmin, |
|
229 | vmin=self.zmin, | |
230 | vmax=self.zmax, |
|
230 | vmax=self.zmax, | |
231 | cmap=self.cmaps[n] |
|
231 | cmap=self.cmaps[n] | |
232 | ) |
|
232 | ) | |
233 | else: |
|
233 | else: | |
234 | if self.zlimits is not None: |
|
234 | if self.zlimits is not None: | |
235 | self.zmin, self.zmax = self.zlimits[n] |
|
235 | self.zmin, self.zmax = self.zlimits[n] | |
236 | ax.collections.remove(ax.collections[0]) |
|
236 | ax.collections.remove(ax.collections[0]) | |
237 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], |
|
237 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], | |
238 | vmin=self.zmin, |
|
238 | vmin=self.zmin, | |
239 | vmax=self.zmax, |
|
239 | vmax=self.zmax, | |
240 | cmap=self.cmaps[n] |
|
240 | cmap=self.cmaps[n] | |
241 | ) |
|
241 | ) | |
242 |
|
242 | |||
243 |
|
243 | |||
244 | class PolarMapPlot(Plot): |
|
244 | class PolarMapPlot(Plot): | |
245 | ''' |
|
245 | ''' | |
246 | Plot for weather radar |
|
246 | Plot for weather radar | |
247 | ''' |
|
247 | ''' | |
248 |
|
248 | |||
249 | CODE = 'param' |
|
249 | CODE = 'param' | |
250 | colormap = 'seismic' |
|
250 | colormap = 'seismic' | |
251 |
|
251 | |||
252 | def setup(self): |
|
252 | def setup(self): | |
253 | self.ncols = 1 |
|
253 | self.ncols = 1 | |
254 | self.nrows = 1 |
|
254 | self.nrows = 1 | |
255 | self.width = 9 |
|
255 | self.width = 9 | |
256 | self.height = 8 |
|
256 | self.height = 8 | |
257 | self.mode = self.data.meta['mode'] |
|
257 | self.mode = self.data.meta['mode'] | |
258 | if self.channels is not None: |
|
258 | if self.channels is not None: | |
259 | self.nplots = len(self.channels) |
|
259 | self.nplots = len(self.channels) | |
260 | self.nrows = len(self.channels) |
|
260 | self.nrows = len(self.channels) | |
261 | else: |
|
261 | else: | |
262 | self.nplots = self.data.shape(self.CODE)[0] |
|
262 | self.nplots = self.data.shape(self.CODE)[0] | |
263 | self.nrows = self.nplots |
|
263 | self.nrows = self.nplots | |
264 | self.channels = list(range(self.nplots)) |
|
264 | self.channels = list(range(self.nplots)) | |
265 | if self.mode == 'E': |
|
265 | if self.mode == 'E': | |
266 | self.xlabel = 'Longitude' |
|
266 | self.xlabel = 'Longitude' | |
267 | self.ylabel = 'Latitude' |
|
267 | self.ylabel = 'Latitude' | |
268 | else: |
|
268 | else: | |
269 | self.xlabel = 'Range (km)' |
|
269 | self.xlabel = 'Range (km)' | |
270 | self.ylabel = 'Height (km)' |
|
270 | self.ylabel = 'Height (km)' | |
271 | self.bgcolor = 'white' |
|
271 | self.bgcolor = 'white' | |
272 | self.cb_labels = self.data.meta['units'] |
|
272 | self.cb_labels = self.data.meta['units'] | |
273 | self.lat = self.data.meta['latitude'] |
|
273 | self.lat = self.data.meta['latitude'] | |
274 | self.lon = self.data.meta['longitude'] |
|
274 | self.lon = self.data.meta['longitude'] | |
275 | self.xmin, self.xmax = float( |
|
275 | self.xmin, self.xmax = float( | |
276 | km2deg(self.xmin) + self.lon), float(km2deg(self.xmax) + self.lon) |
|
276 | km2deg(self.xmin) + self.lon), float(km2deg(self.xmax) + self.lon) | |
277 | self.ymin, self.ymax = float( |
|
277 | self.ymin, self.ymax = float( | |
278 | km2deg(self.ymin) + self.lat), float(km2deg(self.ymax) + self.lat) |
|
278 | km2deg(self.ymin) + self.lat), float(km2deg(self.ymax) + self.lat) | |
279 | # self.polar = True |
|
279 | # self.polar = True | |
280 |
|
280 | |||
281 | def plot(self): |
|
281 | def plot(self): | |
282 |
|
282 | |||
283 | for n, ax in enumerate(self.axes): |
|
283 | for n, ax in enumerate(self.axes): | |
284 | data = self.data['param'][self.channels[n]] |
|
284 | data = self.data['param'][self.channels[n]] | |
285 |
|
285 | |||
286 | zeniths = numpy.linspace( |
|
286 | zeniths = numpy.linspace( | |
287 | 0, self.data.meta['max_range'], data.shape[1]) |
|
287 | 0, self.data.meta['max_range'], data.shape[1]) | |
288 | if self.mode == 'E': |
|
288 | if self.mode == 'E': | |
289 | azimuths = -numpy.radians(self.data.yrange)+numpy.pi/2 |
|
289 | azimuths = -numpy.radians(self.data.yrange)+numpy.pi/2 | |
290 | r, theta = numpy.meshgrid(zeniths, azimuths) |
|
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( |
|
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'])) |
|
292 | theta)*numpy.cos(numpy.radians(self.data.meta['elevation'])) | |
293 | x = km2deg(x) + self.lon |
|
293 | x = km2deg(x) + self.lon | |
294 | y = km2deg(y) + self.lat |
|
294 | y = km2deg(y) + self.lat | |
295 | else: |
|
295 | else: | |
296 | azimuths = numpy.radians(self.data.yrange) |
|
296 | azimuths = numpy.radians(self.data.yrange) | |
297 | r, theta = numpy.meshgrid(zeniths, azimuths) |
|
297 | r, theta = numpy.meshgrid(zeniths, azimuths) | |
298 | x, y = r*numpy.cos(theta), r*numpy.sin(theta) |
|
298 | x, y = r*numpy.cos(theta), r*numpy.sin(theta) | |
299 | self.y = zeniths |
|
299 | self.y = zeniths | |
300 |
|
300 | |||
301 | if ax.firsttime: |
|
301 | if ax.firsttime: | |
302 | if self.zlimits is not None: |
|
302 | if self.zlimits is not None: | |
303 | self.zmin, self.zmax = self.zlimits[n] |
|
303 | self.zmin, self.zmax = self.zlimits[n] | |
304 | ax.plt = ax.pcolormesh( # r, theta, numpy.ma.array(data, mask=numpy.isnan(data)), |
|
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)), |
|
305 | x, y, numpy.ma.array(data, mask=numpy.isnan(data)), | |
306 | vmin=self.zmin, |
|
306 | vmin=self.zmin, | |
307 | vmax=self.zmax, |
|
307 | vmax=self.zmax, | |
308 | cmap=self.cmaps[n]) |
|
308 | cmap=self.cmaps[n]) | |
309 | else: |
|
309 | else: | |
310 | if self.zlimits is not None: |
|
310 | if self.zlimits is not None: | |
311 | self.zmin, self.zmax = self.zlimits[n] |
|
311 | self.zmin, self.zmax = self.zlimits[n] | |
312 | ax.collections.remove(ax.collections[0]) |
|
312 | ax.collections.remove(ax.collections[0]) | |
313 | ax.plt = ax.pcolormesh( # r, theta, numpy.ma.array(data, mask=numpy.isnan(data)), |
|
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)), |
|
314 | x, y, numpy.ma.array(data, mask=numpy.isnan(data)), | |
315 | vmin=self.zmin, |
|
315 | vmin=self.zmin, | |
316 | vmax=self.zmax, |
|
316 | vmax=self.zmax, | |
317 | cmap=self.cmaps[n]) |
|
317 | cmap=self.cmaps[n]) | |
318 |
|
318 | |||
319 | if self.mode == 'A': |
|
319 | if self.mode == 'A': | |
320 | continue |
|
320 | continue | |
321 |
|
321 | |||
322 | # plot district names |
|
322 | # plot district names | |
323 | f = open('/data/workspace/schain_scripts/distrito.csv') |
|
323 | f = open('/data/workspace/schain_scripts/distrito.csv') | |
324 | for line in f: |
|
324 | for line in f: | |
325 | label, lon, lat = [s.strip() for s in line.split(',') if s] |
|
325 | label, lon, lat = [s.strip() for s in line.split(',') if s] | |
326 | lat = float(lat) |
|
326 | lat = float(lat) | |
327 | lon = float(lon) |
|
327 | lon = float(lon) | |
328 | # ax.plot(lon, lat, '.b', ms=2) |
|
328 | # ax.plot(lon, lat, '.b', ms=2) | |
329 | ax.text(lon, lat, label.decode('utf8'), ha='center', |
|
329 | ax.text(lon, lat, label.decode('utf8'), ha='center', | |
330 | va='bottom', size='8', color='black') |
|
330 | va='bottom', size='8', color='black') | |
331 |
|
331 | |||
332 | # plot limites |
|
332 | # plot limites | |
333 | limites = [] |
|
333 | limites = [] | |
334 | tmp = [] |
|
334 | tmp = [] | |
335 | for line in open('/data/workspace/schain_scripts/lima.csv'): |
|
335 | for line in open('/data/workspace/schain_scripts/lima.csv'): | |
336 | if '#' in line: |
|
336 | if '#' in line: | |
337 | if tmp: |
|
337 | if tmp: | |
338 | limites.append(tmp) |
|
338 | limites.append(tmp) | |
339 | tmp = [] |
|
339 | tmp = [] | |
340 | continue |
|
340 | continue | |
341 | values = line.strip().split(',') |
|
341 | values = line.strip().split(',') | |
342 | tmp.append((float(values[0]), float(values[1]))) |
|
342 | tmp.append((float(values[0]), float(values[1]))) | |
343 | for points in limites: |
|
343 | for points in limites: | |
344 | ax.add_patch( |
|
344 | ax.add_patch( | |
345 | Polygon(points, ec='k', fc='none', ls='--', lw=0.5)) |
|
345 | Polygon(points, ec='k', fc='none', ls='--', lw=0.5)) | |
346 |
|
346 | |||
347 | # plot Cuencas |
|
347 | # plot Cuencas | |
348 | for cuenca in ('rimac', 'lurin', 'mala', 'chillon', 'chilca', 'chancay-huaral'): |
|
348 | for cuenca in ('rimac', 'lurin', 'mala', 'chillon', 'chilca', 'chancay-huaral'): | |
349 | f = open('/data/workspace/schain_scripts/{}.csv'.format(cuenca)) |
|
349 | f = open('/data/workspace/schain_scripts/{}.csv'.format(cuenca)) | |
350 | values = [line.strip().split(',') for line in f] |
|
350 | values = [line.strip().split(',') for line in f] | |
351 | points = [(float(s[0]), float(s[1])) for s in values] |
|
351 | points = [(float(s[0]), float(s[1])) for s in values] | |
352 | ax.add_patch(Polygon(points, ec='b', fc='none')) |
|
352 | ax.add_patch(Polygon(points, ec='b', fc='none')) | |
353 |
|
353 | |||
354 | # plot grid |
|
354 | # plot grid | |
355 | for r in (15, 30, 45, 60): |
|
355 | for r in (15, 30, 45, 60): | |
356 | ax.add_artist(plt.Circle((self.lon, self.lat), |
|
356 | ax.add_artist(plt.Circle((self.lon, self.lat), | |
357 | km2deg(r), color='0.6', fill=False, lw=0.2)) |
|
357 | km2deg(r), color='0.6', fill=False, lw=0.2)) | |
358 | ax.text( |
|
358 | ax.text( | |
359 | self.lon + (km2deg(r))*numpy.cos(60*numpy.pi/180), |
|
359 | self.lon + (km2deg(r))*numpy.cos(60*numpy.pi/180), | |
360 | self.lat + (km2deg(r))*numpy.sin(60*numpy.pi/180), |
|
360 | self.lat + (km2deg(r))*numpy.sin(60*numpy.pi/180), | |
361 | '{}km'.format(r), |
|
361 | '{}km'.format(r), | |
362 | ha='center', va='bottom', size='8', color='0.6', weight='heavy') |
|
362 | ha='center', va='bottom', size='8', color='0.6', weight='heavy') | |
363 |
|
363 | |||
364 | if self.mode == 'E': |
|
364 | if self.mode == 'E': | |
365 | title = 'El={}$^\circ$'.format(self.data.meta['elevation']) |
|
365 | title = 'El={}$^\circ$'.format(self.data.meta['elevation']) | |
366 | label = 'E{:02d}'.format(int(self.data.meta['elevation'])) |
|
366 | label = 'E{:02d}'.format(int(self.data.meta['elevation'])) | |
367 | else: |
|
367 | else: | |
368 | title = 'Az={}$^\circ$'.format(self.data.meta['azimuth']) |
|
368 | title = 'Az={}$^\circ$'.format(self.data.meta['azimuth']) | |
369 | label = 'A{:02d}'.format(int(self.data.meta['azimuth'])) |
|
369 | label = 'A{:02d}'.format(int(self.data.meta['azimuth'])) | |
370 |
|
370 | |||
371 | self.save_labels = ['{}-{}'.format(lbl, label) for lbl in self.labels] |
|
371 | self.save_labels = ['{}-{}'.format(lbl, label) for lbl in self.labels] | |
372 | self.titles = ['{} {}'.format( |
|
372 | self.titles = ['{} {}'.format( | |
373 | self.data.parameters[x], title) for x in self.channels] |
|
373 | self.data.parameters[x], title) for x in self.channels] | |
374 |
|
374 | |||
375 | class WeatherPlot(Plot): |
|
375 | class WeatherPlot(Plot): | |
376 | CODE = 'weather' |
|
376 | CODE = 'weather' | |
377 | plot_name = 'weather' |
|
377 | plot_name = 'weather' | |
378 | plot_type = 'ppistyle' |
|
378 | plot_type = 'ppistyle' | |
379 | buffering = False |
|
379 | buffering = False | |
380 |
|
380 | |||
381 | def setup(self): |
|
381 | def setup(self): | |
382 | self.ncols = 1 |
|
382 | self.ncols = 1 | |
383 | self.nrows = 1 |
|
383 | self.nrows = 1 | |
384 | self.nplots= 1 |
|
384 | self.nplots= 1 | |
385 | self.ylabel= 'Range [Km]' |
|
385 | self.ylabel= 'Range [Km]' | |
386 | self.titles= ['Weather'] |
|
386 | self.titles= ['Weather'] | |
387 | self.colorbar=False |
|
387 | self.colorbar=False | |
388 | self.width =8 |
|
388 | self.width =8 | |
389 | self.height =8 |
|
389 | self.height =8 | |
390 | self.ini =0 |
|
390 | self.ini =0 | |
391 | self.len_azi =0 |
|
391 | self.len_azi =0 | |
392 | self.buffer_ini = None |
|
392 | self.buffer_ini = None | |
393 | self.buffer_azi = 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}) |
|
394 | self.plots_adjust.update({'wspace': 0.4, 'hspace':0.4, 'left': 0.1, 'right': 0.9, 'bottom': 0.08}) | |
395 | self.flag =0 |
|
395 | self.flag =0 | |
396 | self.indicador= 0 |
|
396 | self.indicador= 0 | |
397 |
|
397 | |||
398 | def update(self, dataOut): |
|
398 | def update(self, dataOut): | |
399 |
|
399 | |||
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 | |||
407 | def plot(self): |
|
408 | def const_ploteo(self,data_weather,data_azi,step,res): | |
408 | thisDatetime = datetime.datetime.utcfromtimestamp(self.data.times[-1]) |
|
409 | #print("data_weather",data_weather) | |
409 | print("--------------------------------------",self.ini,"-----------------------------------") |
|
410 | print("data_azi",data_azi) | |
410 |
print("t |
|
411 | print("step",step) | |
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 |
|
|
412 | if self.ini==0: | |
455 | res = 1 |
|
413 | #------- AZIMUTH | |
456 |
|
|
414 | n = (360/res)-len(data_azi) | |
457 | val = numpy.mean(tmp_v[:,0]) |
|
415 | start = data_azi[-1] + res | |
458 | self.len_azi = len(tmp_z) |
|
416 | end = data_azi[0] - res | |
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 |
|
|
417 | if start>end: | |
467 |
end |
|
418 | end = end + 360 | |
468 |
|
|
419 | azi_vacia = numpy.linspace(start,end,int(n)) | |
469 |
|
|
420 | azi_vacia = numpy.where(azi_vacia>360,azi_vacia-360,azi_vacia) | |
470 | self.buf_azi = tmp_z |
|
421 | data_azi = numpy.hstack((data_azi,azi_vacia)) | |
471 | self.buffer_ini_azi = numpy.hstack((tmp_z,azi_zeros)) |
|
422 | # RADAR | |
472 | self.ini = self.ini+1 |
|
423 | val_mean = numpy.mean(data_weather[:,0]) | |
473 | elif 0<self.ini<step: |
|
424 | data_weather_cmp = numpy.ones([(360-data_weather.shape[0]),data_weather.shape[1]])*val_mean | |
474 | ''' |
|
425 | data_weather = numpy.vstack((data_weather,data_weather_cmp)) | |
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 |
|
|
426 | else: | |
494 | # nuevo######### |
|
427 | # azimuth | |
495 | self.buffer_ini[0:self.buf_tmp.shape[0],:]=self.buf_tmp |
|
428 | flag=0 | |
496 | ################ |
|
429 | start_azi = self.res_azi[0] | |
497 | #val=30.0 |
|
430 | start = data_azi[0] | |
498 | #ones = numpy.ones([(360-self.buf_tmp.shape[0]),self.buf_tmp.shape[1]])*val |
|
431 | end = data_azi[-1] | |
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 |
|
|
432 | print("start",start) | |
510 |
|
|
433 | print("end",end) | |
511 |
|
|
434 | if start< start_azi: | |
|
435 | start = start +360 | |||
|
436 | if end <start_azi: | |||
512 |
|
|
437 | 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 |
|
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 | |||
549 | else: |
|
447 | else: | |
550 | step = (360/(res*tmp_v.shape[0])) |
|
448 | flag=1 | |
551 | # aqui estaba realizando el debug de simulacion |
|
449 | dif= 360-pos_ini | |
552 | # tmp_v=tmp_v +5 en cada step sumaba 5 |
|
450 | comp= len_azi-dif | |
553 | # y el mismo valor despues de la primera vuelta |
|
451 | ||
554 | #tmp_v=tmp_v+5+(self.ini-step)*1### aqui yo habia sumado 5 por las puras |
|
452 | print(pos_ini) | |
555 |
|
453 | print(len_azi) | ||
556 | start= tmp_z[0] |
|
454 | print("shape",self.res_azi.shape) | |
557 | end = tmp_z[-1] |
|
455 | if flag==0: | |
558 | #print("start","end",start,end) |
|
456 | # AZIMUTH | |
559 | ###print(self.buffer_ini_azi[:120]) |
|
457 | self.res_azi[pos_ini:pos_ini+len_azi] = data_azi | |
560 |
|
458 | # RADAR | ||
561 | if step>=2: |
|
459 | self.res_weather[pos_ini:pos_ini+len_azi,:] = data_weather | |
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 |
|
|
460 | else: | |
575 | final= len(tmp_z[index_i:]) |
|
461 | # AZIMUTH | |
576 | self.buf_azi[len(tmp_z)*(self.flag+1):index_f]=tmp_z[index_i:index_i+final] |
|
462 | self.res_azi[pos_ini:pos_ini+dif] = data_azi[0:dif] | |
577 | self.buf_tmp[len(tmp_z)*(self.flag+1):index_f,:]=tmp_v[index_i:index_i+final,:] |
|
463 | self.res_azi[0:comp] = data_azi[dif:] | |
578 | if limit_i<tmp_z[0]<limit_s: |
|
464 | # RADAR | |
579 | index_f =int(numpy.where(self.buf_azi>=tmp_z[-1])[0][0]) |
|
465 | self.res_weather[pos_ini:pos_ini+dif,:] = data_weather[0:dif,:] | |
580 | n_p =index_f-len(tmp_z)*(self.flag+1) |
|
466 | self.res_weather[0:comp,:] = data_weather[dif:,:] | |
581 |
|
|
467 | flag=0 | |
582 | self.buf_azi[len(tmp_z)*(self.flag+1):index_f]=tmp_z[-1]*numpy.ones(n_p) |
|
468 | data_azi = self.res_azi | |
583 | self.buf_tmp[len(tmp_z)*(self.flag+1):index_f,:]=tmp_v[-1,:]*numpy.ones([n_p,tmp_v.shape[1]]) |
|
469 | data_weather = self.res_weather | |
|
470 | ||||
|
471 | return data_weather,data_azi | |||
|
472 | ||||
|
473 | def plot(self): | |||
|
474 | print("--------------------------------------",self.ini,"-----------------------------------") | |||
|
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 | |||
|
482 | rangestep = float(0.15) | |||
|
483 | r = numpy.arange(0, stoprange, rangestep) | |||
|
484 | self.y = 2*r | |||
|
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) | |||
|
494 | #print("step",step) | |||
|
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 | ########################################################## | |||
584 |
|
503 | |||
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 |
@@ -1,203 +1,206 | |||||
1 | ''' |
|
1 | ''' | |
2 | Base clases to create Processing units and operations, the MPDecorator |
|
2 | Base clases to create Processing units and operations, the MPDecorator | |
3 | must be used in plotting and writing operations to allow to run as an |
|
3 | must be used in plotting and writing operations to allow to run as an | |
4 | external process. |
|
4 | external process. | |
5 | ''' |
|
5 | ''' | |
6 |
|
6 | |||
7 | import inspect |
|
7 | import inspect | |
8 | import zmq |
|
8 | import zmq | |
9 | import time |
|
9 | import time | |
10 | import pickle |
|
10 | import pickle | |
11 | import traceback |
|
11 | import traceback | |
12 | from threading import Thread |
|
12 | from threading import Thread | |
13 | from multiprocessing import Process, Queue |
|
13 | from multiprocessing import Process, Queue | |
14 | from schainpy.utils import log |
|
14 | from schainpy.utils import log | |
15 |
|
15 | |||
16 |
|
16 | |||
17 | class ProcessingUnit(object): |
|
17 | class ProcessingUnit(object): | |
18 | ''' |
|
18 | ''' | |
19 | Base class to create Signal Chain Units |
|
19 | Base class to create Signal Chain Units | |
20 | ''' |
|
20 | ''' | |
21 |
|
21 | |||
22 | proc_type = 'processing' |
|
22 | proc_type = 'processing' | |
23 |
|
23 | |||
24 | def __init__(self): |
|
24 | def __init__(self): | |
25 |
|
25 | |||
26 | self.dataIn = None |
|
26 | self.dataIn = None | |
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__ | |
38 | else: |
|
38 | else: | |
39 | return inspect.getargspec(self.run).args |
|
39 | return inspect.getargspec(self.run).args | |
40 |
|
40 | |||
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): | |
48 |
|
48 | |||
49 | if objId not in list(self.operations.keys()): |
|
49 | if objId not in list(self.operations.keys()): | |
50 | return None |
|
50 | return None | |
51 |
|
51 | |||
52 | return self.operations[objId] |
|
52 | return self.operations[objId] | |
53 |
|
53 | |||
54 | def call(self, **kwargs): |
|
54 | def call(self, **kwargs): | |
55 | ''' |
|
55 | ''' | |
56 | ''' |
|
56 | ''' | |
57 |
|
57 | |||
58 | try: |
|
58 | try: | |
59 | if self.dataIn is not None and self.dataIn.flagNoData and not self.dataIn.error: |
|
59 | if self.dataIn is not None and self.dataIn.flagNoData and not self.dataIn.error: | |
60 | return self.dataIn.isReady() |
|
60 | return self.dataIn.isReady() | |
61 | elif self.dataIn is None or not self.dataIn.error: |
|
61 | elif self.dataIn is None or not self.dataIn.error: | |
62 | self.run(**kwargs) |
|
62 | self.run(**kwargs) | |
63 | elif self.dataIn.error: |
|
63 | elif self.dataIn.error: | |
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: | |
71 | log.error(err.split('SchainError:')[-1].split('\n')[0].strip(), self.name) |
|
71 | log.error(err.split('SchainError:')[-1].split('\n')[0].strip(), self.name) | |
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) | |
|
82 | op.queue.put(aux) | |||
81 |
elif optype == 'external' and self.dataOut.error: |
|
83 | elif optype == 'external' and self.dataOut.error: | |
82 | op.queue.put(self.dataOut) |
|
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 | |||
86 | def setup(self): |
|
89 | def setup(self): | |
87 |
|
90 | |||
88 | raise NotImplementedError |
|
91 | raise NotImplementedError | |
89 |
|
92 | |||
90 | def run(self): |
|
93 | def run(self): | |
91 |
|
94 | |||
92 | raise NotImplementedError |
|
95 | raise NotImplementedError | |
93 |
|
96 | |||
94 | def close(self): |
|
97 | def close(self): | |
95 |
|
98 | |||
96 | return |
|
99 | return | |
97 |
|
100 | |||
98 |
|
101 | |||
99 | class Operation(object): |
|
102 | 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): | |
107 |
|
110 | |||
108 | self.id = None |
|
111 | self.id = None | |
109 | self.isConfig = False |
|
112 | self.isConfig = False | |
110 |
|
113 | |||
111 | if not hasattr(self, 'name'): |
|
114 | if not hasattr(self, 'name'): | |
112 | self.name = self.__class__.__name__ |
|
115 | self.name = self.__class__.__name__ | |
113 |
|
116 | |||
114 | def getAllowedArgs(self): |
|
117 | def getAllowedArgs(self): | |
115 | if hasattr(self, '__attrs__'): |
|
118 | if hasattr(self, '__attrs__'): | |
116 | return self.__attrs__ |
|
119 | return self.__attrs__ | |
117 | else: |
|
120 | else: | |
118 | return inspect.getargspec(self.run).args |
|
121 | return inspect.getargspec(self.run).args | |
119 |
|
122 | |||
120 | def setup(self): |
|
123 | def setup(self): | |
121 |
|
124 | |||
122 | self.isConfig = True |
|
125 | self.isConfig = True | |
123 |
|
126 | |||
124 | raise NotImplementedError |
|
127 | raise NotImplementedError | |
125 |
|
128 | |||
126 | def run(self, dataIn, **kwargs): |
|
129 | def run(self, dataIn, **kwargs): | |
127 | """ |
|
130 | """ | |
128 | Realiza las operaciones necesarias sobre la dataIn.data y actualiza los |
|
131 | Realiza las operaciones necesarias sobre la dataIn.data y actualiza los | |
129 | atributos del objeto dataIn. |
|
132 | atributos del objeto dataIn. | |
130 |
|
133 | |||
131 | Input: |
|
134 | Input: | |
132 |
|
135 | |||
133 | dataIn : objeto del tipo JROData |
|
136 | dataIn : objeto del tipo JROData | |
134 |
|
137 | |||
135 | Return: |
|
138 | Return: | |
136 |
|
139 | |||
137 | None |
|
140 | None | |
138 |
|
141 | |||
139 | Affected: |
|
142 | Affected: | |
140 | __buffer : buffer de recepcion de datos. |
|
143 | __buffer : buffer de recepcion de datos. | |
141 |
|
144 | |||
142 | """ |
|
145 | """ | |
143 | if not self.isConfig: |
|
146 | if not self.isConfig: | |
144 | self.setup(**kwargs) |
|
147 | self.setup(**kwargs) | |
145 |
|
148 | |||
146 | raise NotImplementedError |
|
149 | raise NotImplementedError | |
147 |
|
150 | |||
148 | def close(self): |
|
151 | def close(self): | |
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): | |
161 |
|
164 | |||
162 | def __init__(self, *args, **kwargs): |
|
165 | def __init__(self, *args, **kwargs): | |
163 | super(MPClass, self).__init__() |
|
166 | super(MPClass, self).__init__() | |
164 | Process.__init__(self) |
|
167 | Process.__init__(self) | |
165 |
|
168 | |||
166 | self.args = args |
|
169 | self.args = args | |
167 | self.kwargs = kwargs |
|
170 | self.kwargs = kwargs | |
168 | self.t = time.time() |
|
171 | self.t = time.time() | |
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() | |
186 |
|
189 | |||
187 | if not dataOut.error: |
|
190 | if not dataOut.error: | |
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 | |
195 |
|
198 | |||
196 | self.close() |
|
199 | self.close() | |
197 |
|
200 | |||
198 | def close(self): |
|
201 | def close(self): | |
199 |
|
202 | |||
200 | BaseClass.close(self) |
|
203 | BaseClass.close(self) | |
201 | log.success('Done...(Time:{:4.2f} secs)'.format(time.time()-self.start_time), self.name) |
|
204 | log.success('Done...(Time:{:4.2f} secs)'.format(time.time()-self.start_time), self.name) | |
202 |
|
205 | |||
203 | return MPClass |
|
206 | return MPClass |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file | ||
The requested commit or file is too big and content was truncated. Show full diff |
@@ -1,127 +1,147 | |||||
1 | #!python |
|
1 | #!python | |
2 | ''' |
|
2 | ''' | |
3 | ''' |
|
3 | ''' | |
4 |
|
4 | |||
5 | import os, sys |
|
5 | import os, sys | |
6 | import datetime |
|
6 | import datetime | |
7 | import time |
|
7 | import time | |
8 |
|
8 | |||
9 | #path = os.path.dirname(os.getcwd()) |
|
9 | #path = os.path.dirname(os.getcwd()) | |
10 | #path = os.path.dirname(path) |
|
10 | #path = os.path.dirname(path) | |
11 | #sys.path.insert(0, path) |
|
11 | #sys.path.insert(0, path) | |
12 |
|
12 | |||
13 | from schainpy.controller import Project |
|
13 | from schainpy.controller import Project | |
14 |
|
14 | |||
15 | desc = "USRP_test" |
|
15 | desc = "USRP_test" | |
16 | filename = "USRP_processing.xml" |
|
16 | filename = "USRP_processing.xml" | |
17 | controllerObj = Project() |
|
17 | controllerObj = Project() | |
18 | controllerObj.setup(id = '191', name='Test_USRP', description=desc) |
|
18 | controllerObj.setup(id = '191', name='Test_USRP', description=desc) | |
19 |
|
19 | |||
20 | ############## USED TO PLOT IQ VOLTAGE, POWER AND SPECTRA ############# |
|
20 | ############## USED TO PLOT IQ VOLTAGE, POWER AND SPECTRA ############# | |
21 |
|
21 | |||
22 | ####################################################################### |
|
22 | ####################################################################### | |
23 | ######PATH DE LECTURA, ESCRITURA, GRAFICOS Y ENVIO WEB################# |
|
23 | ######PATH DE LECTURA, ESCRITURA, GRAFICOS Y ENVIO WEB################# | |
24 | ####################################################################### |
|
24 | ####################################################################### | |
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" | |
33 | ####################################################################### |
|
53 | ####################################################################### | |
34 | ################# RANGO DE PLOTEO###################################### |
|
54 | ################# RANGO DE PLOTEO###################################### | |
35 | ####################################################################### |
|
55 | ####################################################################### | |
36 | dBmin = '-5' |
|
56 | dBmin = '-5' | |
37 | dBmax = '20' |
|
57 | dBmax = '20' | |
38 | xmin = '0' |
|
58 | xmin = '0' | |
39 | xmax ='24' |
|
59 | xmax ='24' | |
40 | ymin = '0' |
|
60 | ymin = '0' | |
41 | ymax = '600' |
|
61 | ymax = '600' | |
42 | ####################################################################### |
|
62 | ####################################################################### | |
43 | ########################FECHA########################################## |
|
63 | ########################FECHA########################################## | |
44 | ####################################################################### |
|
64 | ####################################################################### | |
45 | str = datetime.date.today() |
|
65 | str = datetime.date.today() | |
46 | today = str.strftime("%Y/%m/%d") |
|
66 | today = str.strftime("%Y/%m/%d") | |
47 | str2 = str - datetime.timedelta(days=1) |
|
67 | str2 = str - datetime.timedelta(days=1) | |
48 | yesterday = str2.strftime("%Y/%m/%d") |
|
68 | yesterday = str2.strftime("%Y/%m/%d") | |
49 | ####################################################################### |
|
69 | ####################################################################### | |
50 | ######################## UNIDAD DE LECTURA############################# |
|
70 | ######################## UNIDAD DE LECTURA############################# | |
51 | ####################################################################### |
|
71 | ####################################################################### | |
52 | readUnitConfObj = controllerObj.addReadUnit(datatype='DigitalRFReader', |
|
72 | readUnitConfObj = controllerObj.addReadUnit(datatype='DigitalRFReader', | |
53 | path=path, |
|
73 | path=path, | |
54 | startDate="2021/01/01",#today, |
|
74 | startDate="2021/01/01",#today, | |
55 | endDate="2021/12/30",#today, |
|
75 | endDate="2021/12/30",#today, | |
56 | startTime='00:00:00', |
|
76 | startTime='00:00:00', | |
57 | endTime='23:59:59', |
|
77 | endTime='23:59:59', | |
58 | delay=0, |
|
78 | delay=0, | |
59 | #set=0, |
|
79 | #set=0, | |
60 | online=0, |
|
80 | online=0, | |
61 | walk=1, |
|
81 | walk=1, | |
62 | ippKm = 60) |
|
82 | ippKm = 60) | |
63 |
|
83 | |||
64 | opObj11 = readUnitConfObj.addOperation(name='printInfo') |
|
84 | opObj11 = readUnitConfObj.addOperation(name='printInfo') | |
65 | #opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock') |
|
85 | #opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock') | |
66 | ####################################################################### |
|
86 | ####################################################################### | |
67 | ################ OPERACIONES DOMINIO DEL TIEMPO######################## |
|
87 | ################ OPERACIONES DOMINIO DEL TIEMPO######################## | |
68 | ####################################################################### |
|
88 | ####################################################################### | |
69 |
|
89 | |||
70 | procUnitConfObjA = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId()) |
|
90 | procUnitConfObjA = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId()) | |
71 |
|
91 | |||
72 | # |
|
92 | # | |
73 | # 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,'+\ |
|
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 | # '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' |
|
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 | #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 | ''' | |
83 | opObj11 = procUnitConfObjA.addOperation(name='PulsepairPowerPlot', optype='other') |
|
103 | opObj11 = procUnitConfObjA.addOperation(name='PulsepairPowerPlot', optype='other') | |
84 | opObj11 = procUnitConfObjA.addOperation(name='PulsepairSignalPlot', optype='other') |
|
104 | opObj11 = procUnitConfObjA.addOperation(name='PulsepairSignalPlot', optype='other') | |
85 | opObj11 = procUnitConfObjA.addOperation(name='PulsepairVelocityPlot', optype='other') |
|
105 | opObj11 = procUnitConfObjA.addOperation(name='PulsepairVelocityPlot', optype='other') | |
86 | #opObj11.addParameter(name='xmax', value=8) |
|
106 | #opObj11.addParameter(name='xmax', value=8) | |
87 | opObj11 = procUnitConfObjA.addOperation(name='PulsepairSpecwidthPlot', optype='other') |
|
107 | opObj11 = procUnitConfObjA.addOperation(name='PulsepairSpecwidthPlot', optype='other') | |
88 | ''' |
|
108 | ''' | |
89 | # OJO SCOPE |
|
109 | # OJO SCOPE | |
90 | #opObj10 = procUnitConfObjA.addOperation(name='ScopePlot', optype='external') |
|
110 | #opObj10 = procUnitConfObjA.addOperation(name='ScopePlot', optype='external') | |
91 | #opObj10.addParameter(name='id', value='10', format='int') |
|
111 | #opObj10.addParameter(name='id', value='10', format='int') | |
92 | ##opObj10.addParameter(name='xmin', value='0', format='int') |
|
112 | ##opObj10.addParameter(name='xmin', value='0', format='int') | |
93 | ##opObj10.addParameter(name='xmax', value='50', format='int') |
|
113 | ##opObj10.addParameter(name='xmax', value='50', format='int') | |
94 | #opObj10.addParameter(name='type', value='iq') |
|
114 | #opObj10.addParameter(name='type', value='iq') | |
95 | ##opObj10.addParameter(name='ymin', value='-5000', format='int') |
|
115 | ##opObj10.addParameter(name='ymin', value='-5000', format='int') | |
96 | ##opObj10.addParameter(name='ymax', value='8500', format='int') |
|
116 | ##opObj10.addParameter(name='ymax', value='8500', format='int') | |
97 | #opObj11.addParameter(name='save', value=figpath, format='str') |
|
117 | #opObj11.addParameter(name='save', value=figpath, format='str') | |
98 | #opObj11.addParameter(name='save_period', value=10, format='int') |
|
118 | #opObj11.addParameter(name='save_period', value=10, format='int') | |
99 |
|
119 | |||
100 | #opObj10 = procUnitConfObjA.addOperation(name='setH0') |
|
120 | #opObj10 = procUnitConfObjA.addOperation(name='setH0') | |
101 | #opObj10.addParameter(name='h0', value='-5000', format='float') |
|
121 | #opObj10.addParameter(name='h0', value='-5000', format='float') | |
102 |
|
122 | |||
103 | #opObj11 = procUnitConfObjA.addOperation(name='filterByHeights') |
|
123 | #opObj11 = procUnitConfObjA.addOperation(name='filterByHeights') | |
104 | #opObj11.addParameter(name='window', value='1', format='int') |
|
124 | #opObj11.addParameter(name='window', value='1', format='int') | |
105 |
|
125 | |||
106 | #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' |
|
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 | #opObj11 = procUnitConfObjSousy.addOperation(name='Decoder', optype='other') |
|
127 | #opObj11 = procUnitConfObjSousy.addOperation(name='Decoder', optype='other') | |
108 | #opObj11.addParameter(name='code', value=codigo, formatyesterday='floatlist') |
|
128 | #opObj11.addParameter(name='code', value=codigo, formatyesterday='floatlist') | |
109 | #opObj11.addParameter(name='nCode', value='1', format='int') |
|
129 | #opObj11.addParameter(name='nCode', value='1', format='int') | |
110 | #opObj11.addParameter(name='nBaud', value='28', format='int') |
|
130 | #opObj11.addParameter(name='nBaud', value='28', format='int') | |
111 |
|
131 | |||
112 | #opObj11 = procUnitConfObjA.addOperation(name='CohInt', optype='other') |
|
132 | #opObj11 = procUnitConfObjA.addOperation(name='CohInt', optype='other') | |
113 | #opObj11.addParameter(name='n', value='100', format='int') |
|
133 | #opObj11.addParameter(name='n', value='100', format='int') | |
114 |
|
134 | |||
115 | ####################################################################### |
|
135 | ####################################################################### | |
116 | ########## OPERACIONES ParametersProc######################## |
|
136 | ########## OPERACIONES ParametersProc######################## | |
117 | ####################################################################### |
|
137 | ####################################################################### | |
118 |
|
138 | |||
119 | procUnitConfObjB= controllerObj.addProcUnit(datatype='ParametersProc',inputId=procUnitConfObjA.getId()) |
|
139 | procUnitConfObjB= controllerObj.addProcUnit(datatype='ParametersProc',inputId=procUnitConfObjA.getId()) | |
120 | opObj10 = procUnitConfObjB.addOperation(name='HDFWriter') |
|
140 | opObj10 = procUnitConfObjB.addOperation(name='HDFWriter') | |
121 | opObj10.addParameter(name='path',value=path_pp) |
|
141 | opObj10.addParameter(name='path',value=path_pp) | |
122 | #opObj10.addParameter(name='mode',value=0) |
|
142 | #opObj10.addParameter(name='mode',value=0) | |
123 | opObj10.addParameter(name='blocksPerFile',value='100',format='int') |
|
143 | opObj10.addParameter(name='blocksPerFile',value='100',format='int') | |
124 | opObj10.addParameter(name='metadataList',value='utctimeInit,timeZone,paramInterval,profileIndex,channelList,heightList,flagDataAsBlock',format='list') |
|
144 | opObj10.addParameter(name='metadataList',value='utctimeInit,timeZone,paramInterval,profileIndex,channelList,heightList,flagDataAsBlock',format='list') | |
125 | opObj10.addParameter(name='dataList',value='dataPP_POW,dataPP_DOP,utctime',format='list')#,format='list' |
|
145 | opObj10.addParameter(name='dataList',value='dataPP_POW,dataPP_DOP,utctime',format='list')#,format='list' | |
126 |
|
146 | |||
127 | controllerObj.start() |
|
147 | controllerObj.start() |
@@ -1,146 +1,157 | |||||
1 | #!python |
|
1 | #!python | |
2 | ''' |
|
2 | ''' | |
3 | ''' |
|
3 | ''' | |
4 |
|
4 | |||
5 | import os, sys |
|
5 | import os, sys | |
6 | import datetime |
|
6 | import datetime | |
7 | import time |
|
7 | import time | |
8 |
|
8 | |||
9 | #path = os.path.dirname(os.getcwd()) |
|
9 | #path = os.path.dirname(os.getcwd()) | |
10 | #path = os.path.dirname(path) |
|
10 | #path = os.path.dirname(path) | |
11 | #sys.path.insert(0, path) |
|
11 | #sys.path.insert(0, path) | |
12 |
|
12 | |||
13 | from schainpy.controller import Project |
|
13 | from schainpy.controller import Project | |
14 |
|
14 | |||
15 | desc = "USRP_test" |
|
15 | desc = "USRP_test" | |
16 | filename = "USRP_processing.xml" |
|
16 | filename = "USRP_processing.xml" | |
17 | controllerObj = Project() |
|
17 | controllerObj = Project() | |
18 | controllerObj.setup(id = '191', name='Test_USRP', description=desc) |
|
18 | controllerObj.setup(id = '191', name='Test_USRP', description=desc) | |
19 |
|
19 | |||
20 | ############## USED TO PLOT IQ VOLTAGE, POWER AND SPECTRA ############# |
|
20 | ############## USED TO PLOT IQ VOLTAGE, POWER AND SPECTRA ############# | |
21 |
|
21 | |||
22 | ####################################################################### |
|
22 | ####################################################################### | |
23 | ######PATH DE LECTURA, ESCRITURA, GRAFICOS Y ENVIO WEB################# |
|
23 | ######PATH DE LECTURA, ESCRITURA, GRAFICOS Y ENVIO WEB################# | |
24 | ####################################################################### |
|
24 | ####################################################################### | |
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_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" | |
39 | ####################################################################### |
|
44 | ####################################################################### | |
40 | ################# RANGO DE PLOTEO###################################### |
|
45 | ################# RANGO DE PLOTEO###################################### | |
41 | ####################################################################### |
|
46 | ####################################################################### | |
42 | dBmin = '-5' |
|
47 | dBmin = '-5' | |
43 | dBmax = '20' |
|
48 | dBmax = '20' | |
44 | xmin = '0' |
|
49 | xmin = '0' | |
45 | xmax ='24' |
|
50 | xmax ='24' | |
46 | ymin = '0' |
|
51 | ymin = '0' | |
47 | ymax = '600' |
|
52 | ymax = '600' | |
48 | ####################################################################### |
|
53 | ####################################################################### | |
49 | ########################FECHA########################################## |
|
54 | ########################FECHA########################################## | |
50 | ####################################################################### |
|
55 | ####################################################################### | |
51 | str = datetime.date.today() |
|
56 | str = datetime.date.today() | |
52 | today = str.strftime("%Y/%m/%d") |
|
57 | today = str.strftime("%Y/%m/%d") | |
53 | str2 = str - datetime.timedelta(days=1) |
|
58 | str2 = str - datetime.timedelta(days=1) | |
54 | yesterday = str2.strftime("%Y/%m/%d") |
|
59 | yesterday = str2.strftime("%Y/%m/%d") | |
55 | ####################################################################### |
|
60 | ####################################################################### | |
56 | ######################## UNIDAD DE LECTURA############################# |
|
61 | ######################## UNIDAD DE LECTURA############################# | |
57 | ####################################################################### |
|
62 | ####################################################################### | |
58 | readUnitConfObj = controllerObj.addReadUnit(datatype='DigitalRFReader', |
|
63 | readUnitConfObj = controllerObj.addReadUnit(datatype='DigitalRFReader', | |
59 | path=path, |
|
64 | path=path, | |
60 | startDate="2021/01/01",#today, |
|
65 | startDate="2021/01/01",#today, | |
61 | endDate="2021/12/30",#today, |
|
66 | endDate="2021/12/30",#today, | |
62 | startTime='00:00:00', |
|
67 | startTime='00:00:00', | |
63 | endTime='23:59:59', |
|
68 | endTime='23:59:59', | |
64 | delay=0, |
|
69 | delay=0, | |
65 | #set=0, |
|
70 | #set=0, | |
66 | online=0, |
|
71 | online=0, | |
67 | walk=1, |
|
72 | walk=1, | |
68 | ippKm = 60) |
|
73 | ippKm = 60) | |
69 |
|
74 | |||
70 | opObj11 = readUnitConfObj.addOperation(name='printInfo') |
|
75 | opObj11 = readUnitConfObj.addOperation(name='printInfo') | |
71 | #opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock') |
|
76 | #opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock') | |
72 | ####################################################################### |
|
77 | ####################################################################### | |
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 | |||
84 | # |
|
95 | # | |
85 | # 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,'+\ |
|
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 | # '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' |
|
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 | #opObj11 = procUnitConfObjA.addOperation(name='setRadarFrequency') |
|
99 | #opObj11 = procUnitConfObjA.addOperation(name='setRadarFrequency') | |
89 | #opObj11.addParameter(name='frequency', value='70312500') |
|
100 | #opObj11.addParameter(name='frequency', value='70312500') | |
90 | #opObj11 = procUnitConfObjA.addOperation(name='PulsePair', optype='other') |
|
101 | #opObj11 = procUnitConfObjA.addOperation(name='PulsePair', optype='other') | |
91 | #opObj11.addParameter(name='n', value='625', format='int')#10 |
|
102 | #opObj11.addParameter(name='n', value='625', format='int')#10 | |
92 | #opObj11.addParameter(name='removeDC', value=1, format='int') |
|
103 | #opObj11.addParameter(name='removeDC', value=1, format='int') | |
93 |
|
104 | |||
94 | # Ploteo TEST |
|
105 | # Ploteo TEST | |
95 | ''' |
|
106 | ''' | |
96 | opObj11 = procUnitConfObjA.addOperation(name='PulsepairPowerPlot', optype='other') |
|
107 | opObj11 = procUnitConfObjA.addOperation(name='PulsepairPowerPlot', optype='other') | |
97 | opObj11 = procUnitConfObjA.addOperation(name='PulsepairSignalPlot', optype='other') |
|
108 | opObj11 = procUnitConfObjA.addOperation(name='PulsepairSignalPlot', optype='other') | |
98 | opObj11 = procUnitConfObjA.addOperation(name='PulsepairVelocityPlot', optype='other') |
|
109 | opObj11 = procUnitConfObjA.addOperation(name='PulsepairVelocityPlot', optype='other') | |
99 | #opObj11.addParameter(name='xmax', value=8) |
|
110 | #opObj11.addParameter(name='xmax', value=8) | |
100 | opObj11 = procUnitConfObjA.addOperation(name='PulsepairSpecwidthPlot', optype='other') |
|
111 | opObj11 = procUnitConfObjA.addOperation(name='PulsepairSpecwidthPlot', optype='other') | |
101 | ''' |
|
112 | ''' | |
102 | # OJO SCOPE |
|
113 | # OJO SCOPE | |
103 | #opObj10 = procUnitConfObjA.addOperation(name='ScopePlot', optype='external') |
|
114 | #opObj10 = procUnitConfObjA.addOperation(name='ScopePlot', optype='external') | |
104 | #opObj10.addParameter(name='buffer_sizeid', value='10', format='int') |
|
115 | #opObj10.addParameter(name='buffer_sizeid', value='10', format='int') | |
105 | ##opObj10.addParameter(name='xmin', value='0', format='int') |
|
116 | ##opObj10.addParameter(name='xmin', value='0', format='int') | |
106 | ##opObj10.addParameter(name='xmax', value='50', format='int') |
|
117 | ##opObj10.addParameter(name='xmax', value='50', format='int') | |
107 | #opObj10.addParameter(name='type', value='iq') |
|
118 | #opObj10.addParameter(name='type', value='iq') | |
108 | ##opObj10.addParameter(name='ymin', value='-5000', format='int') |
|
119 | ##opObj10.addParameter(name='ymin', value='-5000', format='int') | |
109 | ##opObj10.addParameter(name='ymax', value='8500', format='int') |
|
120 | ##opObj10.addParameter(name='ymax', value='8500', format='int') | |
110 | #opObj11.addParameter(name='save', value=figpath, format='str') |
|
121 | #opObj11.addParameter(name='save', value=figpath, format='str') | |
111 | #opObj11.addParameter(name='save_period', value=10, format='int') |
|
122 | #opObj11.addParameter(name='save_period', value=10, format='int') | |
112 |
|
123 | |||
113 | #opObj10 = procUnitConfObjA.addOperation(name='setH0') |
|
124 | #opObj10 = procUnitConfObjA.addOperation(name='setH0') | |
114 | #opObj10.addParameter(name='h0', value='-5000', format='float') |
|
125 | #opObj10.addParameter(name='h0', value='-5000', format='float') | |
115 |
|
126 | |||
116 | #opObj11 = procUnitConfObjA.addOperation(name='filterByHeights') |
|
127 | #opObj11 = procUnitConfObjA.addOperation(name='filterByHeights') | |
117 | #opObj11.addParameter(name='window', value='1', format='int') |
|
128 | #opObj11.addParameter(name='window', value='1', format='int') | |
118 |
|
129 | |||
119 | #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' |
|
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 | #opObj11 = procUnitConfObjSousy.addOperation(name='Decoder', optype='other') |
|
131 | #opObj11 = procUnitConfObjSousy.addOperation(name='Decoder', optype='other') | |
121 | #opObj11.addParameter(name='code', value=codigo, formatyesterday='floatlist') |
|
132 | #opObj11.addParameter(name='code', value=codigo, formatyesterday='floatlist') | |
122 | #opObj11.addParameter(name='nCode', value='1', format='int') |
|
133 | #opObj11.addParameter(name='nCode', value='1', format='int') | |
123 | #opObj11.addParameter(name='nBaud', value='28', format='int') |
|
134 | #opObj11.addParameter(name='nBaud', value='28', format='int') | |
124 |
|
135 | |||
125 | #opObj11 = procUnitConfObjA.addOperation(name='CohInt', optype='other') |
|
136 | #opObj11 = procUnitConfObjA.addOperation(name='CohInt', optype='other') | |
126 | #opObj11.addParameter(name='n', value='100', format='int') |
|
137 | #opObj11.addParameter(name='n', value='100', format='int') | |
127 |
|
138 | |||
128 | ####################################################################### |
|
139 | ####################################################################### | |
129 | ########## OPERACIONES ParametersProc######################## |
|
140 | ########## OPERACIONES ParametersProc######################## | |
130 | ####################################################################### |
|
141 | ####################################################################### | |
131 |
|
142 | |||
132 | procUnitConfObjC= controllerObj.addProcUnit(datatype='ParametersProc',inputId=procUnitConfObjB.getId()) |
|
143 | procUnitConfObjC= controllerObj.addProcUnit(datatype='ParametersProc',inputId=procUnitConfObjB.getId()) | |
133 |
|
144 | |||
134 | procUnitConfObjC.addOperation(name='SpectralMoments') |
|
145 | procUnitConfObjC.addOperation(name='SpectralMoments') | |
135 |
|
146 | |||
136 |
|
147 | |||
137 | opObj10 = procUnitConfObjC.addOperation(name='HDFWriter') |
|
148 | opObj10 = procUnitConfObjC.addOperation(name='HDFWriter') | |
138 | opObj10.addParameter(name='path',value=path_pp) |
|
149 | opObj10.addParameter(name='path',value=path_pp) | |
139 | #opObj10.addParameter(name='mode',value=0) |
|
150 | #opObj10.addParameter(name='mode',value=0) | |
140 | opObj10.addParameter(name='blocksPerFile',value='100',format='int') |
|
151 | opObj10.addParameter(name='blocksPerFile',value='100',format='int') | |
141 | #opObj10.addParameter(name='metadataList',value='utctimeInit,heightList,nIncohInt,nCohInt,nProfiles,channelList',format='list')#profileIndex |
|
152 | #opObj10.addParameter(name='metadataList',value='utctimeInit,heightList,nIncohInt,nCohInt,nProfiles,channelList',format='list')#profileIndex | |
142 | opObj10.addParameter(name='metadataList',value='utctimeInit,heightList,nIncohInt,nCohInt,nProfiles,channelList',format='list')#profileIndex |
|
153 | opObj10.addParameter(name='metadataList',value='utctimeInit,heightList,nIncohInt,nCohInt,nProfiles,channelList',format='list')#profileIndex | |
143 |
|
154 | |||
144 | opObj10.addParameter(name='dataList',value='data_pow,data_dop,utctime',format='list')#,format='list' |
|
155 | opObj10.addParameter(name='dataList',value='data_pow,data_dop,utctime',format='list')#,format='list' | |
145 |
|
156 | |||
146 | controllerObj.start() |
|
157 | controllerObj.start() |
@@ -1,64 +1,75 | |||||
1 | import os,sys |
|
1 | import os,sys | |
2 | import datetime |
|
2 | import datetime | |
3 | import time |
|
3 | import time | |
4 | from schainpy.controller import Project |
|
4 | from schainpy.controller import Project | |
5 | #path='/DATA_RM/TEST_HDF5/d2021200' |
|
5 | #path='/DATA_RM/TEST_HDF5/d2021200' | |
6 | #path='/DATA_RM/TEST_HDF5/d2021200' |
|
6 | #path='/DATA_RM/TEST_HDF5/d2021200' | |
7 | #path='/DATA_RM/TEST_HDF5/d2021214' |
|
7 | #path='/DATA_RM/TEST_HDF5/d2021214' | |
8 | #path='/DATA_RM/TEST_HDF5/d2021229' |
|
8 | #path='/DATA_RM/TEST_HDF5/d2021229' | |
9 |
|
9 | |||
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' | |
24 | desc = "Simulator Test" |
|
31 | desc = "Simulator Test" | |
25 |
|
32 | |||
26 | controllerObj = Project() |
|
33 | controllerObj = Project() | |
27 | controllerObj.setup(id='10',name='Test Simulator',description=desc) |
|
34 | controllerObj.setup(id='10',name='Test Simulator',description=desc) | |
28 | readUnitConfObj = controllerObj.addReadUnit(datatype='HDFReader', |
|
35 | readUnitConfObj = controllerObj.addReadUnit(datatype='HDFReader', | |
29 | path=path, |
|
36 | path=path, | |
30 | startDate="2021/01/01", #"2020/01/01",#today, |
|
37 | startDate="2021/01/01", #"2020/01/01",#today, | |
31 | endDate= "2021/12/01", #"2020/12/30",#today, |
|
38 | endDate= "2021/12/01", #"2020/12/30",#today, | |
32 | startTime='00:00:00', |
|
39 | startTime='00:00:00', | |
33 | endTime='23:59:59', |
|
40 | endTime='23:59:59', | |
34 | t_Interval_p=0.01, |
|
41 | t_Interval_p=0.01, | |
35 | n_Muestras_p=100, |
|
42 | n_Muestras_p=100, | |
36 | delay=30, |
|
43 | delay=30, | |
37 | #set=0, |
|
44 | #set=0, | |
38 | online=0, |
|
45 | online=0, | |
39 | walk=0, |
|
46 | walk=0, | |
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) | |
46 | opObj11.addParameter(name='path_adq', value=path_adq) |
|
57 | 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 | |||
54 | opObj11 = procUnitConfObjA.addOperation(name='Block360') |
|
65 | opObj11 = procUnitConfObjA.addOperation(name='Block360') | |
55 | opObj11.addParameter(name='n', value='10', format='int') |
|
66 | 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 | |
64 | #online 0 utc_adq 1617489815.4804 |
|
75 | #online 0 utc_adq 1617489815.4804 |
@@ -1,89 +1,90 | |||||
1 | import os,sys,json |
|
1 | import os,sys,json | |
2 | import datetime |
|
2 | import datetime | |
3 | import time |
|
3 | import time | |
4 | from schainpy.controller import Project |
|
4 | from schainpy.controller import Project | |
5 | ''' |
|
5 | ''' | |
6 | NOTA: |
|
6 | NOTA: | |
7 | Este script de prueba. |
|
7 | Este script de prueba. | |
8 | - Unidad del lectura 'HDFReader'. |
|
8 | - Unidad del lectura 'HDFReader'. | |
9 | - Unidad de procesamiento ParametersProc |
|
9 | - Unidad de procesamiento ParametersProc | |
10 | - Operacion SpectralMomentsPlot |
|
10 | - Operacion SpectralMomentsPlot | |
11 |
|
11 | |||
12 | ''' |
|
12 | ''' | |
13 | #path = '/home/soporte/Downloads/RAWDATA_PP' |
|
13 | #path = '/home/soporte/Downloads/RAWDATA_PP' | |
14 | #path = '/DATA_RM/TEST_HDF5/d2021203' |
|
14 | #path = '/DATA_RM/TEST_HDF5/d2021203' | |
15 | ####################################################################### |
|
15 | ####################################################################### | |
16 | ################# RANGO DE PLOTEO###################################### |
|
16 | ################# RANGO DE PLOTEO###################################### | |
17 | ####################################################################### |
|
17 | ####################################################################### | |
18 | dBmin = '1' |
|
18 | 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 | ####################################################################### | |
27 | ####################################################################### |
|
27 | ####################################################################### | |
28 | # este script lee los archivos pre-procesados pulse-pair y permite el |
|
28 | # este script lee los archivos pre-procesados pulse-pair y permite el | |
29 | # el ploteo del rti, mostrando los valores de potencia de la senal. |
|
29 | # el ploteo del rti, mostrando los valores de potencia de la senal. | |
30 | # el resultado del grafico depende del programa USRP_ADQ_PP.py |
|
30 | # el resultado del grafico depende del programa USRP_ADQ_PP.py | |
31 | # debido al procesamiento del Pulse Pair. |
|
31 | # debido al procesamiento del Pulse Pair. | |
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 = { | |
40 | 'Data': { |
|
41 | 'Data': { | |
41 | 'dataPP_POW': ['Data/dataPP_POW/channel00','Data/dataPP_POW/channel01'], |
|
42 | 'dataPP_POW': ['Data/dataPP_POW/channel00','Data/dataPP_POW/channel01'], | |
42 | 'dataPP_DOP': ['Data/dataPP_DOP/channel00','Data/dataPP_DOP/channel01'], |
|
43 | 'dataPP_DOP': ['Data/dataPP_DOP/channel00','Data/dataPP_DOP/channel01'], | |
43 | 'utctime':'Data/utctime' |
|
44 | 'utctime':'Data/utctime' | |
44 | }, |
|
45 | }, | |
45 | 'Metadata': { |
|
46 | 'Metadata': { | |
46 | 'heightList' :'Metadata/heightList', |
|
47 | 'heightList' :'Metadata/heightList', | |
47 | 'flagDataAsBlock':'Metadata/flagDataAsBlock', |
|
48 | 'flagDataAsBlock':'Metadata/flagDataAsBlock', | |
48 | 'channelList' :'Metadata/channelList', |
|
49 | 'channelList' :'Metadata/channelList', | |
49 | 'profileIndex' :'Metadata/profileIndex' |
|
50 | 'profileIndex' :'Metadata/profileIndex' | |
50 | } |
|
51 | } | |
51 | } |
|
52 | } | |
52 |
|
53 | |||
53 | controllerObj = Project() |
|
54 | controllerObj = Project() | |
54 |
|
55 | |||
55 | controllerObj.setup(id='10',name='Test Simulator',description=desc) |
|
56 | controllerObj.setup(id='10',name='Test Simulator',description=desc) | |
56 |
|
57 | |||
57 | readUnitConfObj = controllerObj.addReadUnit(datatype='HDFReader', |
|
58 | readUnitConfObj = controllerObj.addReadUnit(datatype='HDFReader', | |
58 | path=path, |
|
59 | path=path, | |
59 | startDate="2021/01/01", #"2020/01/01",#today, |
|
60 | startDate="2021/01/01", #"2020/01/01",#today, | |
60 | endDate= "2021/12/01", #"2020/12/30",#today, |
|
61 | endDate= "2021/12/01", #"2020/12/30",#today, | |
61 | startTime='00:00:00', |
|
62 | startTime='00:00:00', | |
62 | endTime='23:59:59', |
|
63 | endTime='23:59:59', | |
63 | delay=0, |
|
64 | delay=0, | |
64 | #set=0, |
|
65 | #set=0, | |
65 | online=0, |
|
66 | online=0, | |
66 | walk=0, |
|
67 | walk=0, | |
67 | description= json.dumps(desc_data))#1 |
|
68 | description= json.dumps(desc_data))#1 | |
68 |
|
69 | |||
69 | procUnitConfObjA = controllerObj.addProcUnit(datatype='ParametersProc',inputId=readUnitConfObj.getId()) |
|
70 | procUnitConfObjA = controllerObj.addProcUnit(datatype='ParametersProc',inputId=readUnitConfObj.getId()) | |
70 |
|
71 | |||
71 | #opObj11 = procUnitConfObjA.addOperation(name='PulsepairPowerPlot', optype='other')#PulsepairPowerPlot |
|
72 | #opObj11 = procUnitConfObjA.addOperation(name='PulsepairPowerPlot', optype='other')#PulsepairPowerPlot | |
72 | #opObj11 = procUnitConfObjA.addOperation(name='PulsepairSignalPlot', optype='other') |
|
73 | #opObj11 = procUnitConfObjA.addOperation(name='PulsepairSignalPlot', optype='other') | |
73 | #opObj11 = procUnitConfObjA.addOperation(name='PulsepairVelocityPlot', optype='other') |
|
74 | #opObj11 = procUnitConfObjA.addOperation(name='PulsepairVelocityPlot', optype='other') | |
74 |
|
75 | |||
75 | opObj11 = procUnitConfObjA.addOperation(name='GenericRTIPlot',optype='external') |
|
76 | opObj11 = procUnitConfObjA.addOperation(name='GenericRTIPlot',optype='external') | |
76 |
|
77 | |||
77 | opObj11.addParameter(name='attr_data', value='dataPP_POW') |
|
78 | opObj11.addParameter(name='attr_data', value='dataPP_POW') | |
78 | opObj11.addParameter(name='colormap', value='jet') |
|
79 | opObj11.addParameter(name='colormap', value='jet') | |
79 |
|
80 | |||
80 | opObj11.addParameter(name='xmin', value=tmmin) |
|
81 | opObj11.addParameter(name='xmin', value=tmmin) | |
81 | opObj11.addParameter(name='xmax', value=tmmax) |
|
82 | opObj11.addParameter(name='xmax', value=tmmax) | |
82 | opObj11.addParameter(name='zmin', value=dBmin) |
|
83 | opObj11.addParameter(name='zmin', value=dBmin) | |
83 | opObj11.addParameter(name='zmax', value=dBmax) |
|
84 | opObj11.addParameter(name='zmax', value=dBmax) | |
84 | opObj11.addParameter(name='save', value=figpath) |
|
85 | opObj11.addParameter(name='save', value=figpath) | |
85 | opObj11.addParameter(name='showprofile', value=0) |
|
86 | opObj11.addParameter(name='showprofile', value=0) | |
86 | opObj11.addParameter(name='save_period', value=10) |
|
87 | opObj11.addParameter(name='save_period', value=10) | |
87 |
|
88 | |||
88 |
|
89 | |||
89 | controllerObj.start() |
|
90 | controllerObj.start() |
@@ -1,75 +1,78 | |||||
1 | import os,sys,json |
|
1 | import os,sys,json | |
2 | import datetime |
|
2 | import datetime | |
3 | import time |
|
3 | import time | |
4 | from schainpy.controller import Project |
|
4 | from schainpy.controller import Project | |
5 | ''' |
|
5 | ''' | |
6 | NOTA: |
|
6 | NOTA: | |
7 | Este script de prueba. |
|
7 | Este script de prueba. | |
8 | - Unidad del lectura 'HDFReader'. |
|
8 | - Unidad del lectura 'HDFReader'. | |
9 | - Unidad de procesamiento ParametersProc |
|
9 | - Unidad de procesamiento ParametersProc | |
10 | - Operacion SpectralMomentsPlot |
|
10 | - Operacion SpectralMomentsPlot | |
11 |
|
11 | |||
12 | ''' |
|
12 | ''' | |
13 |
|
13 | |||
14 | ####################################################################### |
|
14 | ####################################################################### | |
15 | ################# RANGO DE PLOTEO###################################### |
|
15 | ################# RANGO DE PLOTEO###################################### | |
16 | ####################################################################### |
|
16 | ####################################################################### | |
17 | dBmin = '1' |
|
17 | 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': { | |
33 | 'data_pow': ['Data/data_pow/channel00','Data/data_pow/channel01'], |
|
36 | 'data_pow': ['Data/data_pow/channel00','Data/data_pow/channel01'], | |
34 | 'data_dop': ['Data/data_dop/channel00','Data/data_dop/channel01'], |
|
37 | 'data_dop': ['Data/data_dop/channel00','Data/data_dop/channel01'], | |
35 | 'utctime':'Data/utctime' |
|
38 | 'utctime':'Data/utctime' | |
36 | }, |
|
39 | }, | |
37 | 'Metadata': { |
|
40 | 'Metadata': { | |
38 | 'heightList':'Metadata/heightList', |
|
41 | 'heightList':'Metadata/heightList', | |
39 | 'nIncohInt' :'Metadata/nIncohInt', |
|
42 | 'nIncohInt' :'Metadata/nIncohInt', | |
40 | 'nCohInt' :'Metadata/nCohInt', |
|
43 | 'nCohInt' :'Metadata/nCohInt', | |
41 | 'nProfiles' :'Metadata/nProfiles', |
|
44 | 'nProfiles' :'Metadata/nProfiles', | |
42 | 'channelList' :'Metadata/channelList', |
|
45 | 'channelList' :'Metadata/channelList', | |
43 | 'utctimeInit' :'Metadata/utctimeInit' |
|
46 | 'utctimeInit' :'Metadata/utctimeInit' | |
44 |
|
47 | |||
45 | } |
|
48 | } | |
46 | } |
|
49 | } | |
47 |
|
50 | |||
48 | controllerObj = Project() |
|
51 | controllerObj = Project() | |
49 |
|
52 | |||
50 | controllerObj.setup(id='10',name='Test Simulator',description=desc) |
|
53 | controllerObj.setup(id='10',name='Test Simulator',description=desc) | |
51 |
|
54 | |||
52 | readUnitConfObj = controllerObj.addReadUnit(datatype='HDFReader', |
|
55 | readUnitConfObj = controllerObj.addReadUnit(datatype='HDFReader', | |
53 | path=path, |
|
56 | path=path, | |
54 | startDate="2021/01/01", #"2020/01/01",#today, |
|
57 | startDate="2021/01/01", #"2020/01/01",#today, | |
55 | endDate= "2021/12/01", #"2020/12/30",#today, |
|
58 | endDate= "2021/12/01", #"2020/12/30",#today, | |
56 | startTime='00:00:00', |
|
59 | startTime='00:00:00', | |
57 | endTime='23:59:59', |
|
60 | endTime='23:59:59', | |
58 | delay=0, |
|
61 | delay=0, | |
59 | #set=0, |
|
62 | #set=0, | |
60 | online=0, |
|
63 | online=0, | |
61 | walk=1, |
|
64 | walk=1, | |
62 | description= json.dumps(desc_data))#1 |
|
65 | description= json.dumps(desc_data))#1 | |
63 |
|
66 | |||
64 | procUnitConfObjA = controllerObj.addProcUnit(datatype='ParametersProc',inputId=readUnitConfObj.getId()) |
|
67 | procUnitConfObjA = controllerObj.addProcUnit(datatype='ParametersProc',inputId=readUnitConfObj.getId()) | |
65 |
|
68 | |||
66 | opObj11 = procUnitConfObjA.addOperation(name='PowerPlot',optype='external') |
|
69 | opObj11 = procUnitConfObjA.addOperation(name='PowerPlot',optype='external') | |
67 | opObj11.addParameter(name='xmin', value=tmmin) |
|
70 | opObj11.addParameter(name='xmin', value=tmmin) | |
68 | opObj11.addParameter(name='xmax', value=tmmax) |
|
71 | opObj11.addParameter(name='xmax', value=tmmax) | |
69 | opObj11.addParameter(name='zmin', value=dBmin) |
|
72 | opObj11.addParameter(name='zmin', value=dBmin) | |
70 | opObj11.addParameter(name='zmax', value=dBmax) |
|
73 | opObj11.addParameter(name='zmax', value=dBmax) | |
71 | opObj11.addParameter(name='save', value=figpath) |
|
74 | opObj11.addParameter(name='save', value=figpath) | |
72 | opObj11.addParameter(name='showprofile', value=0) |
|
75 | opObj11.addParameter(name='showprofile', value=0) | |
73 | opObj11.addParameter(name='save_period', value=10) |
|
76 | opObj11.addParameter(name='save_period', value=10) | |
74 |
|
77 | |||
75 | controllerObj.start() |
|
78 | controllerObj.start() |
General Comments 0
You need to be logged in to leave comments.
Login now