##// END OF EJS Templates
update y revision RHI
avaldezp -
r1411:e3b451d0f24e
parent child
Show More

The requested changes are too big and content was truncated. Show full diff

@@ -0,0 +1,122
1 # Ing. AVP
2 # 04/01/2022
3 # ARCHIVO DE LECTURA
4 #---- DATA RHI --- 23 DE NOVIEMBRE DEL 2021 --- 23/11/2021---
5 #---- PEDESTAL ----------------------------------------------
6 #------- HORA 143826 /DATA_RM/TEST_PEDESTAL/P20211123-143826 14:38-15:10
7 #---- RADAR ----------------------------------------------
8 #------- 14:26-15:00
9 #------- /DATA_RM/DRONE/2MHZ_5V_ELEVACION/
10 #------- /DATA_RM/DRONE/2MHZ_5V_ELEVACION/ch0/2021-11-23T19-00-00
11
12 import os, sys
13 import datetime
14 import time
15 import numpy
16 from ext_met import getfirstFilefromPath,getDatavaluefromDirFilename
17 from schainpy.controller import Project
18 #-----------------------------------------------------------------------------------------
19 print("[SETUP]-RADAR METEOROLOGICO-")
20 path_ped = "/DATA_RM/TEST_PEDESTAL/P20211123-143826"
21 print("PATH PEDESTAL :",path_ped)
22 path_adq = "/DATA_RM/DRONE/2MHZ_5V_ELEVACION/"
23 print("PATH DATA :",path_adq)
24 figpath_pp_rti = "/home/soporte/Pictures/TEST_PP_RHI"
25 print("PATH PP RTI :",figpath_pp_rti)
26 figpath_pp_rhi = "/home/soporte/Pictures/TEST_PP_RHI"
27 print("PATH PP RHI :",figpath_pp_rhi)
28 path_pp_save_int = "/DATA_RM/TEST_SAVE_PP_INT_RHI"
29 print("PATH SAVE PP INT :",path_pp_save_int)
30 print(" ")
31 #-------------------------------------------------------------------------------------------
32 print("SELECCIONAR MODO: PPI (0) O RHI (1)")
33 mode_wr = 1
34 if mode_wr==0:
35 print("[ ON ] MODE PPI")
36 list_ped = getfirstFilefromPath(path=path_ped,meta="PE",ext=".hdf5")
37 ff_pedestal = list_ped[2]
38 azi_vel = getDatavaluefromDirFilename(path=path_ped,file=ff_pedestal,value="azi_vel")
39 V = round(azi_vel[0])
40 print("VELOCIDAD AZI :", int(numpy.mean(azi_vel)),"Β°/seg")
41 else:
42 print("[ ON ] MODE RHI")
43 list_ped = getfirstFilefromPath(path=path_ped,meta="PE",ext=".hdf5")
44 ff_pedestal = list_ped[2]
45 ele_vel = getDatavaluefromDirFilename(path=path_ped,file=ff_pedestal,value="ele_vel")
46 V = round(ele_vel[0])
47 V = 10.0
48 print("VELOCIDAD ELE :", int(numpy.mean(ele_vel)),"Β°/seg")
49 print(" ")
50 #---------------------------------------------------------------------------------------
51 print("SELECCIONAR MODO: PULSE PAIR (0) O FREQUENCY (1)")
52 mode_proc = 0
53 if mode_proc==0:
54 print("[ ON ] MODE PULSEPAIR")
55 else:
56 print("[ ON ] MODE FREQUENCY")
57 ipp = 60.0
58 print("IPP(Km.) : %1.2f"%ipp)
59 ipp_sec = (ipp*1.0e3/150.0)*1.0e-6
60 print("IPP(useg.) : %1.2f"%(ipp_sec*(1.0e6)))
61 VEL=V
62 n= int(1/(VEL*ipp_sec))
63 print("NΒ° Profiles : ", n)
64 #--------------------------------------------
65 plot_rti = 0
66 plot_rhi = 1
67 integration = 1
68 save = 0
69 #---------------------------RANGO DE PLOTEO----------------------------------
70 dBmin = '1'
71 dBmax = '85'
72 xmin = '17'
73 xmax = '17.25'
74 ymin = '0'
75 ymax = '600'
76 #----------------------------------------------------------------------------
77 time.sleep(3)
78 #---------------------SIGNAL CHAIN ------------------------------------
79 desc = "USRP_WEATHER_RADAR"
80 filename = "USRP_processing.xml"
81 controllerObj = Project()
82 controllerObj.setup(id = '191', name='Test_USRP', description=desc)
83 #---------------------UNIDAD DE LECTURA--------------------------------
84 readUnitConfObj = controllerObj.addReadUnit(datatype='DigitalRFReader',
85 path=path_adq,
86 startDate="2021/11/10",#today,
87 endDate="2021/12/30",#today,
88 startTime='17:10:25',
89 endTime='23:59:59',
90 delay=0,
91 #set=0,
92 online=0,
93 walk=1,
94 ippKm=ipp)
95
96 procUnitConfObjA = controllerObj.addProcUnit(datatype='VoltageProc',inputId=readUnitConfObj.getId())
97
98 opObj11 = procUnitConfObjA.addOperation(name='selectHeights')
99 opObj11.addParameter(name='minIndex', value='1', format='int')
100 # opObj11.addParameter(name='maxIndex', value='10000', format='int')
101 opObj11.addParameter(name='maxIndex', value='400', format='int')
102
103 if mode_proc==0:
104 opObj11 = procUnitConfObjA.addOperation(name='PulsePair', optype='other')
105 opObj11.addParameter(name='n', value=int(n), format='int')
106 procUnitConfObjB= controllerObj.addProcUnit(datatype='ParametersProc',inputId=procUnitConfObjA.getId())
107
108 if integration==1:
109 opObj11 = procUnitConfObjB.addOperation(name='PedestalInformation')
110 opObj11.addParameter(name='path_ped', value=path_ped)
111 opObj11.addParameter(name='t_Interval_p', value='0.01', format='float')
112
113 if plot_rhi==1:
114 opObj11 = procUnitConfObjB.addOperation(name='Block360')
115 opObj11.addParameter(name='n', value='10', format='int')
116 opObj11.addParameter(name='mode', value=mode_proc, format='int')
117 # este bloque funciona bien con divisores de 360 no olvidar 0 10 20 30 40 60 90 120 180
118 opObj11= procUnitConfObjB.addOperation(name='WeatherRHIPlot',optype='other')
119 opObj11.addParameter(name='save', value=figpath_pp_rhi)
120 opObj11.addParameter(name='save_period', value=1)
121
122 controllerObj.start()
@@ -0,0 +1,57
1 import numpy as np
2 import matplotlib.pyplot as plt
3 import wradlib as wrl
4 import warnings
5 # libreia nueva
6 from mpl_toolkits.axisartist.grid_finder import FixedLocator, DictFormatter
7 warnings.filterwarnings('ignore')
8 # lectura de gaMIC hdf5 file
9 filename = wrl.util.get_wradlib_data_file("/home/soporte/Downloads/2014-06-09--185000.rhi.mvol")
10 data1, metadata = wrl.io.read_gamic_hdf5(filename)
11 print(data1)
12 data1 = data1['SCAN0']['ZH']['data']
13 print(data1)
14 print("SHAPE Data",np.array(data1).shape)
15 r = metadata['SCAN0']['r']
16 print("r",r)
17 print("longitud r",len(r))
18 th = metadata['SCAN0']['el']
19 print("th",th)
20 print("longitud th",len(th))
21 az = metadata['SCAN0']['az']
22 print("az",az)
23 site = (metadata['VOL']['Longitude'], metadata['VOL']['Latitude'],
24 metadata['VOL']['Height'])
25
26 print("Longitud,Latitud,Altura",site)
27 ma1 = np.array(data1)
28 '''
29 mask_ind = np.where(data1 <= np.nanmin(data1))
30 data1[mask_ind] = np.nan
31 ma1 = np.ma.array(data1, mask=np.isnan(data1))
32 '''
33 #cgax, pm = wrl.vis.plot_rhi(ma1,r=r,th=th,rf=1e3)
34 fig = plt.figure(figsize=(10,8))
35 cgax, pm = wrl.vis.plot_rhi(ma1,r=r,th=th,rf=1e3,fig=fig, ax=111,proj='cg')
36 caax = cgax.parasites[0]
37 paax = cgax.parasites[1]
38 cgax.set_ylim(0, 14)
39 #caax = cgax.parasites[0]
40 #paax = cgax.parasites[1]
41 #cgax, pm = wrl.vis.plot_rhi(ma1, r=r, th=th, rf=1e3, fig=fig, ax=111, proj='cg')
42 txt = plt.title('Simple RHI',y=1.05)
43 #cbar = plt.gcf().colorbar(pm, pad=0.05, ax=paax)
44 cbar = plt.gcf().colorbar(pm, pad=0.05)
45 cbar.set_label('reflectivity [dBZ]')
46 caax.set_xlabel('x_range [km]')
47 caax.set_ylabel('y_range [km]')
48 plt.text(1.0, 1.05, 'azimuth', transform=caax.transAxes, va='bottom',ha='right')
49 gh = cgax.get_grid_helper()
50
51 # set theta to some nice values
52 locs = [0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14.,
53 15., 16., 17., 18., 20., 22., 25., 30., 35., 40., 50., 60., 70., 80., 90.]
54 gh.grid_finder.grid_locator1 = FixedLocator(locs)
55 gh.grid_finder.tick_formatter1 = DictFormatter(dict([(i, r"${0:.0f}^\circ$".format(i)) for i in locs]))
56
57 plt.show()
@@ -1,687 +1,707
1 1 import os
2 2 import datetime
3 3 import numpy
4 4
5 5 from schainpy.model.graphics.jroplot_base import Plot, plt
6 6 from schainpy.model.graphics.jroplot_spectra import SpectraPlot, RTIPlot, CoherencePlot, SpectraCutPlot
7 7 from schainpy.utils import log
8 8 # libreria wradlib
9 9 import wradlib as wrl
10 10
11 11 EARTH_RADIUS = 6.3710e3
12 12
13 13
14 14 def ll2xy(lat1, lon1, lat2, lon2):
15 15
16 16 p = 0.017453292519943295
17 17 a = 0.5 - numpy.cos((lat2 - lat1) * p)/2 + numpy.cos(lat1 * p) * \
18 18 numpy.cos(lat2 * p) * (1 - numpy.cos((lon2 - lon1) * p)) / 2
19 19 r = 12742 * numpy.arcsin(numpy.sqrt(a))
20 20 theta = numpy.arctan2(numpy.sin((lon2-lon1)*p)*numpy.cos(lat2*p), numpy.cos(lat1*p)
21 21 * numpy.sin(lat2*p)-numpy.sin(lat1*p)*numpy.cos(lat2*p)*numpy.cos((lon2-lon1)*p))
22 22 theta = -theta + numpy.pi/2
23 23 return r*numpy.cos(theta), r*numpy.sin(theta)
24 24
25 25
26 26 def km2deg(km):
27 27 '''
28 28 Convert distance in km to degrees
29 29 '''
30 30
31 31 return numpy.rad2deg(km/EARTH_RADIUS)
32 32
33 33
34 34
35 35 class SpectralMomentsPlot(SpectraPlot):
36 36 '''
37 37 Plot for Spectral Moments
38 38 '''
39 39 CODE = 'spc_moments'
40 40 # colormap = 'jet'
41 41 # plot_type = 'pcolor'
42 42
43 43 class DobleGaussianPlot(SpectraPlot):
44 44 '''
45 45 Plot for Double Gaussian Plot
46 46 '''
47 47 CODE = 'gaussian_fit'
48 48 # colormap = 'jet'
49 49 # plot_type = 'pcolor'
50 50
51 51 class DoubleGaussianSpectraCutPlot(SpectraCutPlot):
52 52 '''
53 53 Plot SpectraCut with Double Gaussian Fit
54 54 '''
55 55 CODE = 'cut_gaussian_fit'
56 56
57 57 class SnrPlot(RTIPlot):
58 58 '''
59 59 Plot for SNR Data
60 60 '''
61 61
62 62 CODE = 'snr'
63 63 colormap = 'jet'
64 64
65 65 def update(self, dataOut):
66 66
67 67 data = {
68 68 'snr': 10*numpy.log10(dataOut.data_snr)
69 69 }
70 70
71 71 return data, {}
72 72
73 73 class DopplerPlot(RTIPlot):
74 74 '''
75 75 Plot for DOPPLER Data (1st moment)
76 76 '''
77 77
78 78 CODE = 'dop'
79 79 colormap = 'jet'
80 80
81 81 def update(self, dataOut):
82 82
83 83 data = {
84 84 'dop': 10*numpy.log10(dataOut.data_dop)
85 85 }
86 86
87 87 return data, {}
88 88
89 89 class PowerPlot(RTIPlot):
90 90 '''
91 91 Plot for Power Data (0 moment)
92 92 '''
93 93
94 94 CODE = 'pow'
95 95 colormap = 'jet'
96 96
97 97 def update(self, dataOut):
98 98 data = {
99 99 'pow': 10*numpy.log10(dataOut.data_pow/dataOut.normFactor)
100 100 }
101 101 return data, {}
102 102
103 103 class SpectralWidthPlot(RTIPlot):
104 104 '''
105 105 Plot for Spectral Width Data (2nd moment)
106 106 '''
107 107
108 108 CODE = 'width'
109 109 colormap = 'jet'
110 110
111 111 def update(self, dataOut):
112 112
113 113 data = {
114 114 'width': dataOut.data_width
115 115 }
116 116
117 117 return data, {}
118 118
119 119 class SkyMapPlot(Plot):
120 120 '''
121 121 Plot for meteors detection data
122 122 '''
123 123
124 124 CODE = 'param'
125 125
126 126 def setup(self):
127 127
128 128 self.ncols = 1
129 129 self.nrows = 1
130 130 self.width = 7.2
131 131 self.height = 7.2
132 132 self.nplots = 1
133 133 self.xlabel = 'Zonal Zenith Angle (deg)'
134 134 self.ylabel = 'Meridional Zenith Angle (deg)'
135 135 self.polar = True
136 136 self.ymin = -180
137 137 self.ymax = 180
138 138 self.colorbar = False
139 139
140 140 def plot(self):
141 141
142 142 arrayParameters = numpy.concatenate(self.data['param'])
143 143 error = arrayParameters[:, -1]
144 144 indValid = numpy.where(error == 0)[0]
145 145 finalMeteor = arrayParameters[indValid, :]
146 146 finalAzimuth = finalMeteor[:, 3]
147 147 finalZenith = finalMeteor[:, 4]
148 148
149 149 x = finalAzimuth * numpy.pi / 180
150 150 y = finalZenith
151 151
152 152 ax = self.axes[0]
153 153
154 154 if ax.firsttime:
155 155 ax.plot = ax.plot(x, y, 'bo', markersize=5)[0]
156 156 else:
157 157 ax.plot.set_data(x, y)
158 158
159 159 dt1 = self.getDateTime(self.data.min_time).strftime('%y/%m/%d %H:%M:%S')
160 160 dt2 = self.getDateTime(self.data.max_time).strftime('%y/%m/%d %H:%M:%S')
161 161 title = 'Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n' % (dt1,
162 162 dt2,
163 163 len(x))
164 164 self.titles[0] = title
165 165
166 166
167 167 class GenericRTIPlot(Plot):
168 168 '''
169 169 Plot for data_xxxx object
170 170 '''
171 171
172 172 CODE = 'param'
173 173 colormap = 'viridis'
174 174 plot_type = 'pcolorbuffer'
175 175
176 176 def setup(self):
177 177 self.xaxis = 'time'
178 178 self.ncols = 1
179 179 self.nrows = self.data.shape('param')[0]
180 180 self.nplots = self.nrows
181 181 self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.08, 'right':0.95, 'top': 0.95})
182 182
183 183 if not self.xlabel:
184 184 self.xlabel = 'Time'
185 185
186 186 self.ylabel = 'Range [km]'
187 187 if not self.titles:
188 188 self.titles = ['Param {}'.format(x) for x in range(self.nrows)]
189 189
190 190 def update(self, dataOut):
191 191
192 192 data = {
193 193 'param' : numpy.concatenate([getattr(dataOut, attr) for attr in self.attr_data], axis=0)
194 194 }
195 195
196 196 meta = {}
197 197
198 198 return data, meta
199 199
200 200 def plot(self):
201 201 # self.data.normalize_heights()
202 202 self.x = self.data.times
203 203 self.y = self.data.yrange
204 204 self.z = self.data['param']
205 205 self.z = 10*numpy.log10(self.z)
206 206 self.z = numpy.ma.masked_invalid(self.z)
207 207
208 208 if self.decimation is None:
209 209 x, y, z = self.fill_gaps(self.x, self.y, self.z)
210 210 else:
211 211 x, y, z = self.fill_gaps(*self.decimate())
212 212
213 213 for n, ax in enumerate(self.axes):
214 214
215 215 self.zmax = self.zmax if self.zmax is not None else numpy.max(
216 216 self.z[n])
217 217 self.zmin = self.zmin if self.zmin is not None else numpy.min(
218 218 self.z[n])
219 219
220 220 if ax.firsttime:
221 221 if self.zlimits is not None:
222 222 self.zmin, self.zmax = self.zlimits[n]
223 223
224 224 ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n],
225 225 vmin=self.zmin,
226 226 vmax=self.zmax,
227 227 cmap=self.cmaps[n]
228 228 )
229 229 else:
230 230 if self.zlimits is not None:
231 231 self.zmin, self.zmax = self.zlimits[n]
232 232 ax.collections.remove(ax.collections[0])
233 233 ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n],
234 234 vmin=self.zmin,
235 235 vmax=self.zmax,
236 236 cmap=self.cmaps[n]
237 237 )
238 238
239 239
240 240 class PolarMapPlot(Plot):
241 241 '''
242 242 Plot for weather radar
243 243 '''
244 244
245 245 CODE = 'param'
246 246 colormap = 'seismic'
247 247
248 248 def setup(self):
249 249 self.ncols = 1
250 250 self.nrows = 1
251 251 self.width = 9
252 252 self.height = 8
253 253 self.mode = self.data.meta['mode']
254 254 if self.channels is not None:
255 255 self.nplots = len(self.channels)
256 256 self.nrows = len(self.channels)
257 257 else:
258 258 self.nplots = self.data.shape(self.CODE)[0]
259 259 self.nrows = self.nplots
260 260 self.channels = list(range(self.nplots))
261 261 if self.mode == 'E':
262 262 self.xlabel = 'Longitude'
263 263 self.ylabel = 'Latitude'
264 264 else:
265 265 self.xlabel = 'Range (km)'
266 266 self.ylabel = 'Height (km)'
267 267 self.bgcolor = 'white'
268 268 self.cb_labels = self.data.meta['units']
269 269 self.lat = self.data.meta['latitude']
270 270 self.lon = self.data.meta['longitude']
271 271 self.xmin, self.xmax = float(
272 272 km2deg(self.xmin) + self.lon), float(km2deg(self.xmax) + self.lon)
273 273 self.ymin, self.ymax = float(
274 274 km2deg(self.ymin) + self.lat), float(km2deg(self.ymax) + self.lat)
275 275 # self.polar = True
276 276
277 277 def plot(self):
278 278
279 279 for n, ax in enumerate(self.axes):
280 280 data = self.data['param'][self.channels[n]]
281 281
282 282 zeniths = numpy.linspace(
283 283 0, self.data.meta['max_range'], data.shape[1])
284 284 if self.mode == 'E':
285 285 azimuths = -numpy.radians(self.data.yrange)+numpy.pi/2
286 286 r, theta = numpy.meshgrid(zeniths, azimuths)
287 287 x, y = r*numpy.cos(theta)*numpy.cos(numpy.radians(self.data.meta['elevation'])), r*numpy.sin(
288 288 theta)*numpy.cos(numpy.radians(self.data.meta['elevation']))
289 289 x = km2deg(x) + self.lon
290 290 y = km2deg(y) + self.lat
291 291 else:
292 292 azimuths = numpy.radians(self.data.yrange)
293 293 r, theta = numpy.meshgrid(zeniths, azimuths)
294 294 x, y = r*numpy.cos(theta), r*numpy.sin(theta)
295 295 self.y = zeniths
296 296
297 297 if ax.firsttime:
298 298 if self.zlimits is not None:
299 299 self.zmin, self.zmax = self.zlimits[n]
300 300 ax.plt = ax.pcolormesh( # r, theta, numpy.ma.array(data, mask=numpy.isnan(data)),
301 301 x, y, numpy.ma.array(data, mask=numpy.isnan(data)),
302 302 vmin=self.zmin,
303 303 vmax=self.zmax,
304 304 cmap=self.cmaps[n])
305 305 else:
306 306 if self.zlimits is not None:
307 307 self.zmin, self.zmax = self.zlimits[n]
308 308 ax.collections.remove(ax.collections[0])
309 309 ax.plt = ax.pcolormesh( # r, theta, numpy.ma.array(data, mask=numpy.isnan(data)),
310 310 x, y, numpy.ma.array(data, mask=numpy.isnan(data)),
311 311 vmin=self.zmin,
312 312 vmax=self.zmax,
313 313 cmap=self.cmaps[n])
314 314
315 315 if self.mode == 'A':
316 316 continue
317 317
318 318 # plot district names
319 319 f = open('/data/workspace/schain_scripts/distrito.csv')
320 320 for line in f:
321 321 label, lon, lat = [s.strip() for s in line.split(',') if s]
322 322 lat = float(lat)
323 323 lon = float(lon)
324 324 # ax.plot(lon, lat, '.b', ms=2)
325 325 ax.text(lon, lat, label.decode('utf8'), ha='center',
326 326 va='bottom', size='8', color='black')
327 327
328 328 # plot limites
329 329 limites = []
330 330 tmp = []
331 331 for line in open('/data/workspace/schain_scripts/lima.csv'):
332 332 if '#' in line:
333 333 if tmp:
334 334 limites.append(tmp)
335 335 tmp = []
336 336 continue
337 337 values = line.strip().split(',')
338 338 tmp.append((float(values[0]), float(values[1])))
339 339 for points in limites:
340 340 ax.add_patch(
341 341 Polygon(points, ec='k', fc='none', ls='--', lw=0.5))
342 342
343 343 # plot Cuencas
344 344 for cuenca in ('rimac', 'lurin', 'mala', 'chillon', 'chilca', 'chancay-huaral'):
345 345 f = open('/data/workspace/schain_scripts/{}.csv'.format(cuenca))
346 346 values = [line.strip().split(',') for line in f]
347 347 points = [(float(s[0]), float(s[1])) for s in values]
348 348 ax.add_patch(Polygon(points, ec='b', fc='none'))
349 349
350 350 # plot grid
351 351 for r in (15, 30, 45, 60):
352 352 ax.add_artist(plt.Circle((self.lon, self.lat),
353 353 km2deg(r), color='0.6', fill=False, lw=0.2))
354 354 ax.text(
355 355 self.lon + (km2deg(r))*numpy.cos(60*numpy.pi/180),
356 356 self.lat + (km2deg(r))*numpy.sin(60*numpy.pi/180),
357 357 '{}km'.format(r),
358 358 ha='center', va='bottom', size='8', color='0.6', weight='heavy')
359 359
360 360 if self.mode == 'E':
361 361 title = 'El={}$^\circ$'.format(self.data.meta['elevation'])
362 362 label = 'E{:02d}'.format(int(self.data.meta['elevation']))
363 363 else:
364 364 title = 'Az={}$^\circ$'.format(self.data.meta['azimuth'])
365 365 label = 'A{:02d}'.format(int(self.data.meta['azimuth']))
366 366
367 367 self.save_labels = ['{}-{}'.format(lbl, label) for lbl in self.labels]
368 368 self.titles = ['{} {}'.format(
369 369 self.data.parameters[x], title) for x in self.channels]
370 370
371 371 class WeatherPlot(Plot):
372 372 CODE = 'weather'
373 373 plot_name = 'weather'
374 374 plot_type = 'ppistyle'
375 375 buffering = False
376 376
377 377 def setup(self):
378 378 self.ncols = 1
379 379 self.nrows = 1
380 380 self.nplots= 1
381 381 self.ylabel= 'Range [Km]'
382 382 self.titles= ['Weather']
383 383 self.colorbar=False
384 384 self.width =8
385 385 self.height =8
386 386 self.ini =0
387 387 self.len_azi =0
388 388 self.buffer_ini = None
389 389 self.buffer_azi = None
390 390 self.plots_adjust.update({'wspace': 0.4, 'hspace':0.4, 'left': 0.1, 'right': 0.9, 'bottom': 0.08})
391 391 self.flag =0
392 392 self.indicador= 0
393 393 self.last_data_azi = None
394 394 self.val_mean = None
395 395
396 396 def update(self, dataOut):
397 397
398 398 data = {}
399 399 meta = {}
400 400 if hasattr(dataOut, 'dataPP_POWER'):
401 401 factor = 1
402
403 402 if hasattr(dataOut, 'nFFTPoints'):
404 403 factor = dataOut.normFactor
405
406 ####print("factor",factor)
407 404 data['weather'] = 10*numpy.log10(dataOut.data_360[1]/(factor))
408 ####print("weather",data['weather'])
409 405 data['azi'] = dataOut.data_azi
410
411 406 data['ele'] = dataOut.data_ele
412 407 return data, meta
413 408
414 409 def get2List(self,angulos):
415 410 list1=[]
416 411 list2=[]
417 412 for i in reversed(range(len(angulos))):
418 413 diff_ = angulos[i]-angulos[i-1]
419 414 if diff_ >1.5:
420 415 list1.append(i-1)
421 416 list2.append(diff_)
422 417 return list(reversed(list1)),list(reversed(list2))
423 418
424 419 def fixData360(self,list_,ang_):
425 420 if list_[0]==-1:
426 421 vec = numpy.where(ang_<ang_[0])
427 422 ang_[vec] = ang_[vec]+360
428 423 return ang_
429 424 return ang_
430 425
431
432 426 def fixData360HL(self,angulos):
433 427 vec = numpy.where(angulos>=360)
434 428 angulos[vec]=angulos[vec]-360
435 429 return angulos
436 430
437 431 def search_pos(self,pos,list_):
438 432 for i in range(len(list_)):
439 433 if pos == list_[i]:
440 434 return True,i
441 435 i=None
442 436 return False,i
443 437
444 438 def fixDataComp(self,ang_,list1_,list2_):
445 439 size = len(ang_)
446 440 size2 = 0
447 441 for i in range(len(list2_)):
448 442 size2=size2+round(list2_[i])-1
449 443 new_size= size+size2
450 444 ang_new = numpy.zeros(new_size)
451 445 ang_new2 = numpy.zeros(new_size)
452 446
453 447 tmp = 0
454 448 c = 0
455 449 for i in range(len(ang_)):
456 450 ang_new[tmp +c] = ang_[i]
457 451 ang_new2[tmp+c] = ang_[i]
458 452 condition , value = self.search_pos(i,list1_)
459 453 if condition:
460 454 pos = tmp + c + 1
461 455 for k in range(round(list2_[value])-1):
462 456 ang_new[pos+k] = ang_new[pos+k-1]+1
463 457 ang_new2[pos+k] = numpy.nan
464 458 tmp = pos +k
465 459 c = 0
466 460 c=c+1
467 461 return ang_new,ang_new2
468 462
469
470 463 def globalCheckPED(self,angulos):
471 464 l1,l2 = self.get2List(angulos)
472 465 if len(l1)>0:
473 466 angulos2 = self.fixData360(list_=l1,ang_=angulos)
474 467 l1,l2 = self.get2List(angulos2)
475 468
476 469 ang1_,ang2_ = self.fixDataComp(ang_=angulos2,list1_=l1,list2_=l2)
477 470 ang1_ = self.fixData360HL(ang1_)
478 471 ang2_ = self.fixData360HL(ang2_)
479
480 472 else:
481 473 ang1_= angulos
482 474 ang2_= angulos
483 475 return ang1_,ang2_
484 476
485 477 def analizeDATA(self,data_azi):
486 478 list1 = []
487 479 list2 = []
488 480 dat = data_azi
489 481 for i in reversed(range(1,len(dat))):
490 482 if dat[i]>dat[i-1]:
491 483 diff = int(dat[i])-int(dat[i-1])
492 484 else:
493 485 diff = 360+int(dat[i])-int(dat[i-1])
494 486 if diff > 1:
495 487 list1.append(i-1)
496 488 list2.append(diff-1)
497 489 return list1,list2
498 490
499 491 def fixDATANEW(self,data_azi,data_weather):
500 492 list1,list2 = self.analizeDATA(data_azi)
501 493 if len(list1)== 0:
502 494 return data_azi,data_weather
503 495 else:
504 496 resize = 0
505 497 for i in range(len(list2)):
506 498 resize= resize + list2[i]
507 499 new_data_azi = numpy.resize(data_azi,resize)
508 500 new_data_weather= numpy.resize(date_weather,resize)
509 501
510 502 for i in range(len(list2)):
511 503 j=0
512 504 position=list1[i]+1
513 505 for j in range(list2[i]):
514 506 new_data_azi[position+j]=new_data_azi[position+j-1]+1
515
516 507 return new_data_azi
517 508
518 509 def fixDATA(self,data_azi):
519 510 data=data_azi
520 511 for i in range(len(data)):
521 512 if numpy.isnan(data[i]):
522 513 data[i]=data[i-1]+1
523 514 return data
524 515
525 516 def replaceNAN(self,data_weather,data_azi,val):
526 517 data= data_azi
527 518 data_T= data_weather
528 519 if data.shape[0]> data_T.shape[0]:
529 520 data_N = numpy.ones( [data.shape[0],data_T.shape[1]])
530 521 c = 0
531 522 for i in range(len(data)):
532 523 if numpy.isnan(data[i]):
533 524 data_N[i,:]=numpy.ones(data_T.shape[1])*numpy.nan
534 525 else:
535 526 data_N[i,:]=data_T[c,:]
536 527 sc=c+1
537 528 else:
538 529 for i in range(len(data)):
539 530 if numpy.isnan(data[i]):
540 531 data_T[i,:]=numpy.ones(data_T.shape[1])*numpy.nan
541 532 return data_T
542 533
543 534 def const_ploteo(self,data_weather,data_azi,step,res):
544 535 if self.ini==0:
545 #------- AZIMUTH
536 #-------
546 537 n = (360/res)-len(data_azi)
547 538 #--------------------- new -------------------------
548 ####data_azi_old = data_azi
549 539 data_azi_new ,data_azi_old= self.globalCheckPED(data_azi)
550 540 #------------------------
551 ####data_azi_new = self.fixDATA(data_azi)
552 #ata_azi_new = self.fixDATANEW(data_azi)
553 541 start = data_azi_new[-1] + res
554 542 end = data_azi_new[0] - res
555 ##### new
543 #------ new
556 544 self.last_data_azi = end
557 545 if start>end:
558 546 end = end + 360
559 547 azi_vacia = numpy.linspace(start,end,int(n))
560 548 azi_vacia = numpy.where(azi_vacia>360,azi_vacia-360,azi_vacia)
561 549 data_azi = numpy.hstack((data_azi_new,azi_vacia))
562 550 # RADAR
563 551 val_mean = numpy.mean(data_weather[:,-1])
564 552 self.val_mean = val_mean
565 553 data_weather_cmp = numpy.ones([(360-data_weather.shape[0]),data_weather.shape[1]])*val_mean
566 554 data_weather = self.replaceNAN(data_weather=data_weather,data_azi=data_azi_old,val=self.val_mean)
567 555 data_weather = numpy.vstack((data_weather,data_weather_cmp))
568 556 else:
569 557 # azimuth
570 558 flag=0
571 559 start_azi = self.res_azi[0]
572 560 #-----------new------------
573 561 data_azi ,data_azi_old= self.globalCheckPED(data_azi)
574 print("---------------------------------------------------")
575 print("data_azi",data_azi)
576 print("data_azi_old",data_azi_old)
577 562 data_weather = self.replaceNAN(data_weather=data_weather,data_azi=data_azi_old,val=self.val_mean)
578 563 #--------------------------
579 ####data_azi_old = data_azi
580 ### weather ###
581 ####data_weather = self.replaceNAN(data_weather=data_weather,data_azi=data_azi_old,val=self.val_mean)
582
583 ####if numpy.isnan(data_azi[0]):
584 #### data_azi[0]=self.last_data_azi+1
585 ####data_azi = self.fixDATA(data_azi)
586 564 start = data_azi[0]
587 565 end = data_azi[-1]
588 566 self.last_data_azi= end
589 ####print("start",start)
590 ####print("end",end)
591 567 if start< start_azi:
592 568 start = start +360
593 569 if end <start_azi:
594 570 end = end +360
595 ####print("start",start)
596 ####print("end",end)
597 #### AQUI SERA LA MAGIA
571
598 572 pos_ini = int((start-start_azi)/res)
599 573 len_azi = len(data_azi)
600 574 if (360-pos_ini)<len_azi:
601 575 if pos_ini+1==360:
602 576 pos_ini=0
603 577 else:
604 578 flag=1
605 579 dif= 360-pos_ini
606 580 comp= len_azi-dif
607
608 581 #-----------------
609 ####print(pos_ini)
610 ####print(len_azi)
611 ####print("shape",self.res_azi.shape)
612 582 if flag==0:
613 583 # AZIMUTH
614 584 self.res_azi[pos_ini:pos_ini+len_azi] = data_azi
615 585 # RADAR
616 586 self.res_weather[pos_ini:pos_ini+len_azi,:] = data_weather
617 587 else:
618 588 # AZIMUTH
619 589 self.res_azi[pos_ini:pos_ini+dif] = data_azi[0:dif]
620 590 self.res_azi[0:comp] = data_azi[dif:]
621 591 # RADAR
622 592 self.res_weather[pos_ini:pos_ini+dif,:] = data_weather[0:dif,:]
623 593 self.res_weather[0:comp,:] = data_weather[dif:,:]
624 594 flag=0
625 595 data_azi = self.res_azi
626 596 data_weather = self.res_weather
627 597
628 598 return data_weather,data_azi
629 599
630 600 def plot(self):
631 #print("--------------------------------------",self.ini,"-----------------------------------")
632 #numpy.set_printoptions(suppress=True)
633 ####print("times: ",self.data.times)
634 601 thisDatetime = datetime.datetime.utcfromtimestamp(self.data.times[-1]).strftime('%Y-%m-%d %H:%M:%S')
635 #print("times: ",thisDatetime)
636 602 data = self.data[-1]
637 ####ALTURA altura_tmp_h
638 ###print("Y RANGES",self.data.yrange,len(self.data.yrange))
639 ###altura_h = (data['weather'].shape[1])/10.0
640 ###stoprange = float(altura_h*0.3)#stoprange = float(33*1.5) por ahora 400
641 ###rangestep = float(0.03)
642 ###r = numpy.arange(0, stoprange, rangestep)
643 ###print("r",r,len(r))
644 #-----------------------------update----------------------
645 603 r= self.data.yrange
646 604 delta_height = r[1]-r[0]
647 #print("1",r)
648 605 r_mask= numpy.where(r>=0)[0]
649 606 r = numpy.arange(len(r_mask))*delta_height
650 #print("2",r)
651 607 self.y = 2*r
652 ######self.y = self.data.yrange
653 608 # RADAR
654 609 #data_weather = data['weather']
655 610 # PEDESTAL
656 611 #data_azi = data['azi']
657 612 res = 1
658 613 # STEP
659 614 step = (360/(res*data['weather'].shape[0]))
660 #print("shape wr_data", wr_data.shape)
661 #print("shape wr_azi",wr_azi.shape)
662 #print("step",step)
663 ####print("Time---->",self.data.times[-1],thisDatetime)
664 #print("alturas", len(self.y))numpy.where(r>=0)
615
665 616 self.res_weather, self.res_azi = self.const_ploteo(data_weather=data['weather'][:,r_mask],data_azi=data['azi'],step=step,res=res)
666 #numpy.set_printoptions(suppress=True)
667 #print("resultado",self.res_azi)
668 617 self.res_ele =numpy.mean(data['ele'])
669 ###########################/DATA_RM/10_tmp/ch0###############################
670 618 ################# PLOTEO ###################
671 ##########################################################
672 619
673 620 for i,ax in enumerate(self.axes):
674 621 if ax.firsttime:
675 622 plt.clf()
676 623 cgax, pm = wrl.vis.plot_ppi(self.res_weather,r=r,az=self.res_azi,fig=self.figures[0], proj='cg', vmin=8, vmax=35)
677 624 else:
678 625 plt.clf()
679 626 cgax, pm = wrl.vis.plot_ppi(self.res_weather,r=r,az=self.res_azi,fig=self.figures[0], proj='cg', vmin=8, vmax=35)
680 627 caax = cgax.parasites[0]
681 628 paax = cgax.parasites[1]
682 629 cbar = plt.gcf().colorbar(pm, pad=0.075)
683 630 caax.set_xlabel('x_range [km]')
684 631 caax.set_ylabel('y_range [km]')
685 632 plt.text(1.0, 1.05, 'Azimuth '+str(thisDatetime)+" Step "+str(self.ini)+ " Elev: "+str(round(self.res_ele,2)), transform=caax.transAxes, va='bottom',ha='right')
686 633
687 634 self.ini= self.ini+1
635
636
637 class WeatherRHIPlot(Plot):
638 CODE = 'weather'
639 plot_name = 'weather'
640 plot_type = 'rhistyle'
641 buffering = False
642
643 def setup(self):
644 self.ncols = 1
645 self.nrows = 1
646 self.nplots= 1
647 self.ylabel= 'Range [Km]'
648 self.titles= ['Weather']
649 self.colorbar=False
650 self.width =8
651 self.height =8
652 self.ini =0
653 self.len_azi =0
654 self.buffer_ini = None
655 self.buffer_azi = None
656 self.plots_adjust.update({'wspace': 0.4, 'hspace':0.4, 'left': 0.1, 'right': 0.9, 'bottom': 0.08})
657 self.flag =0
658 self.indicador= 0
659 self.last_data_azi = None
660 self.val_mean = None
661
662 def update(self, dataOut):
663
664 data = {}
665 meta = {}
666 if hasattr(dataOut, 'dataPP_POWER'):
667 factor = 1
668 if hasattr(dataOut, 'nFFTPoints'):
669 factor = dataOut.normFactor
670 data['weather'] = 10*numpy.log10(dataOut.data_360[1]/(factor))
671 data['azi'] = dataOut.data_azi
672 data['ele'] = dataOut.data_ele
673 return data, meta
674
675 def plot(self):
676 thisDatetime = datetime.datetime.utcfromtimestamp(self.data.times[-1]).strftime('%Y-%m-%d %H:%M:%S')
677 data = self.data[-1]
678 r = self.data.yrange
679 delta_height = r[1]-r[0]
680 r_mask = numpy.where(r>=0)[0]
681 r = numpy.arange(len(r_mask))*delta_height
682 self.y = 2*r
683 ###self.res_weather, self.res_ele = self.const_ploteo(data_weather=data['weather'][:,r_mask],data_azi=data['ele'],step=step,res=res)
684 ###self.res_azi = numpy.mean(data['azi'])
685 #-------------
686 # 90 angulos en el axis 0
687 # 1000 step en el axis 1
688 self.res_weather = numpy.ones([90,1000])
689 r = numpy.linspace(0,1999,1000)
690 self.res_ele = numpy.arange(0,90)
691 self.res_azi = 240
692 #-------------
693 for i,ax in enumerate(self.axes):
694 if ax.firsttime:
695 plt.clf()
696 cgax, pm = wrl.vis.plot_rhi(self.res_weather,r=r,th=self.res_ele,fig=self.figures[0], proj='cg')
697 else:
698 plt.clf()
699 cgax, pm = wrl.vis.plot_rhi(self.res_weather,r=r,th=self.res_ele,fig=self.figures[0], proj='cg')
700 caax = cgax.parasites[0]
701 paax = cgax.parasites[1]
702 cbar = plt.gcf().colorbar(pm, pad=0.075)
703 caax.set_xlabel('x_range [km]')
704 caax.set_ylabel('y_range [km]')
705 plt.text(1.0, 1.05, 'Elevacion '+str(thisDatetime)+" Step "+str(self.ini)+ " Azi: "+str(round(self.res_azi,2)), transform=caax.transAxes, va='bottom',ha='right')
706
707 self.ini= self.ini+1
1 NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
@@ -1,133 +1,133
1 1 # Ing. AVP
2 2 # 04/01/2022
3 3 # ARCHIVO DE LECTURA
4 4 import os, sys
5 5 import datetime
6 6 import time
7 7 import numpy
8 8 from ext_met import getfirstFilefromPath,getDatavaluefromDirFilename
9 9 from schainpy.controller import Project
10 10 #-----------------------------------------------------------------------------------------
11 11 print("[SETUP]-RADAR METEOROLOGICO-")
12 12 path_ped = "/DATA_RM/TEST_PEDESTAL/P20211110-171003"
13 13 print("PATH PEDESTAL :",path_ped)
14 14 path_adq = "/DATA_RM/10"
15 15 print("PATH DATA :",path_adq)
16 16 figpath_pp_rti = "/home/soporte/Pictures/TEST_PP_RTI"
17 17 print("PATH PP RTI :",figpath_pp_rti)
18 18 figpath_pp_ppi = "/home/soporte/Pictures/TEST_PP_PPI"
19 19 print("PATH PP PPI :",figpath_pp_ppi)
20 20 path_pp_save_int = "/DATA_RM/TEST_SAVE_PP_INT"
21 21 print("PATH SAVE PP INT :",path_pp_save_int)
22 22 print(" ")
23 23 #-------------------------------------------------------------------------------------------
24 24 print("SELECCIONAR MODO: PPI (0) O RHI (1)")
25 25 mode_wr = 0
26 26 if mode_wr==0:
27 27 print("[ ON ] MODE PPI")
28 28 list_ped = getfirstFilefromPath(path=path_ped,meta="PE",ext=".hdf5")
29 29 ff_pedestal = list_ped[2]
30 30 azi_vel = getDatavaluefromDirFilename(path=path_ped,file=ff_pedestal,value="azi_vel")
31 31 V = round(azi_vel[0])
32 32 print("VELOCIDAD AZI :", int(numpy.mean(azi_vel)),"Β°/seg")
33 33 else:
34 34 print("[ ON ] MODE RHI")
35 35 list_ped = getfirstFilefromPath(path=path_ped,meta="PE",ext=".hdf5")
36 36 ff_pedestal = list_ped[2]
37 37 V = round(ele_vel[0])
38 38 ele_vel = getDatavaluefromDirFilename(path=path_ped,file=ff_pedestal,value="ele_vel")
39 39 print("VELOCIDAD ELE :", int(numpy.mean(ele_vel)),"Β°/seg")
40 40 print(" ")
41 41 #---------------------------------------------------------------------------------------
42 42 print("SELECCIONAR MODO: PULSE PAIR (0) O FREQUENCY (1)")
43 43 mode_proc = 0
44 44 if mode_proc==0:
45 45 print("[ ON ] MODE PULSEPAIR")
46 46 else:
47 47 print("[ ON ] MODE FREQUENCY")
48 48 ipp = 60.0
49 49 print("IPP(Km.) : %1.2f"%ipp)
50 50 ipp_sec = (ipp*1.0e3/150.0)*1.0e-6
51 51 print("IPP(useg.) : %1.2f"%(ipp_sec*(1.0e6)))
52 52 VEL=V
53 53 n= int(1/(VEL*ipp_sec))
54 54 print("NΒ° Profiles : ", n)
55 55 #---------------------------------------------------------------------------------------
56 56 plot_rti = 0
57 57 plot_ppi = 1
58 58 integration = 1
59 59 save = 0
60 60 #---------------------------RANGO DE PLOTEO----------------------------------
61 61 dBmin = '1'
62 62 dBmax = '85'
63 63 xmin = '17'
64 64 xmax = '17.25'
65 65 ymin = '0'
66 66 ymax = '600'
67 67 #----------------------------------------------------------------------------
68 68 time.sleep(3)
69 69 #---------------------SIGNAL CHAIN ------------------------------------
70 70 desc = "USRP_WEATHER_RADAR"
71 71 filename = "USRP_processing.xml"
72 72 controllerObj = Project()
73 73 controllerObj.setup(id = '191', name='Test_USRP', description=desc)
74 74 #---------------------UNIDAD DE LECTURA--------------------------------
75 75 readUnitConfObj = controllerObj.addReadUnit(datatype='DigitalRFReader',
76 76 path=path_adq,
77 77 startDate="2021/11/10",#today,
78 78 endDate="2021/12/30",#today,
79 79 startTime='17:10:25',
80 80 endTime='23:59:59',
81 81 delay=0,
82 82 #set=0,
83 83 online=0,
84 84 walk=1,
85 85 ippKm=ipp)
86 86
87 87 procUnitConfObjA = controllerObj.addProcUnit(datatype='VoltageProc',inputId=readUnitConfObj.getId())
88 88
89 89 opObj11 = procUnitConfObjA.addOperation(name='selectHeights')
90 90 opObj11.addParameter(name='minIndex', value='1', format='int')
91 91 # opObj11.addParameter(name='maxIndex', value='10000', format='int')
92 92 opObj11.addParameter(name='maxIndex', value='400', format='int')
93 93
94 94 if mode_proc==0:
95 95 opObj11 = procUnitConfObjA.addOperation(name='PulsePair', optype='other')
96 96 opObj11.addParameter(name='n', value=int(n), format='int')
97 97 procUnitConfObjB= controllerObj.addProcUnit(datatype='ParametersProc',inputId=procUnitConfObjA.getId())
98
98 # REVISAR EL test_sim00013.py
99 99 if plot_rti==1:
100 100 opObj11 = procUnitConfObjB.addOperation(name='GenericRTIPlot',optype='external')
101 101 opObj11.addParameter(name='attr_data', value='dataPP_POW')
102 102 opObj11.addParameter(name='colormap', value='jet')
103 103 opObj11.addParameter(name='xmin', value=xmin)
104 104 opObj11.addParameter(name='xmax', value=xmax)
105 105 opObj11.addParameter(name='zmin', value=dBmin)
106 106 opObj11.addParameter(name='zmax', value=dBmax)
107 107 opObj11.addParameter(name='save', value=figpath_pp_rti)
108 108 opObj11.addParameter(name='showprofile', value=0)
109 109 opObj11.addParameter(name='save_period', value=50)
110 110 if integration==1:
111 111 opObj11 = procUnitConfObjB.addOperation(name='PedestalInformation')
112 112 opObj11.addParameter(name='path_ped', value=path_ped)
113 113 opObj11.addParameter(name='t_Interval_p', value='0.01', format='float')
114 114
115 115 if plot_ppi==1:
116 116 opObj11 = procUnitConfObjB.addOperation(name='Block360')
117 117 opObj11.addParameter(name='n', value='10', format='int')
118 118 opObj11.addParameter(name='mode', value=mode_proc, format='int')
119 119 # este bloque funciona bien con divisores de 360 no olvidar 0 10 20 30 40 60 90 120 180
120 120 opObj11= procUnitConfObjB.addOperation(name='WeatherPlot',optype='other')
121 121 opObj11.addParameter(name='save', value=figpath_pp_ppi)
122 122 opObj11.addParameter(name='save_period', value=1)
123 123
124 124 if save==1:
125 125 opObj10 = procUnitConfObjB.addOperation(name='HDFWriter')
126 126 opObj10.addParameter(name='path',value=path_pp_save_int)
127 127 opObj10.addParameter(name='mode',value="weather")
128 128 opObj10.addParameter(name='blocksPerFile',value='360',format='int')
129 129 opObj10.addParameter(name='metadataList',value='utctimeInit,timeZone,paramInterval,profileIndex,channelList,heightList,flagDataAsBlock',format='list')
130 130 opObj10.addParameter(name='dataList',value='dataPP_POW,dataPP_DOP,azimuth,elevation,utctime',format='list')#,format='list'
131 131
132 132
133 133 controllerObj.start()
General Comments 0
You need to be logged in to leave comments. Login now