The requested changes are too big and content was truncated. Show full diff
@@ -0,0 +1,55 | |||
|
1 | print("LECTURA DE ARCHIVOS DE CONFIGURACION") | |
|
2 | class ReadfileWR(): | |
|
3 | def __init__(self,filename): | |
|
4 | f = open(filename, "r") | |
|
5 | i=0 | |
|
6 | self.dict={'resolution':None,'vel_ped_azi':None,'pos_ped_ele':None,'ipp':None,'n':None,'len_ped':None,\ | |
|
7 | 't_s_ped':None,'t_f_ped':None,'b_f_adq':None,'t_f_adq':None,'mode':None} | |
|
8 | while(True): | |
|
9 | ##print(i) | |
|
10 | linea = f.readline() | |
|
11 | if i==4: | |
|
12 | resolution=float(linea) | |
|
13 | self.dict['resolution']=resolution | |
|
14 | if i==6: | |
|
15 | vel_pedestal_a=float(linea) | |
|
16 | self.dict['vel_ped_azi']=vel_pedestal_a | |
|
17 | if i==8: | |
|
18 | vel_pedestal_e=float(linea) | |
|
19 | self.dict['pos_ped_ele']=vel_pedestal_e | |
|
20 | if i==10: | |
|
21 | ipp = float(linea) | |
|
22 | self.dict['ipp']= round(ipp,5) | |
|
23 | if i==12: | |
|
24 | n = float(linea) | |
|
25 | self.dict['n']= n | |
|
26 | if i==14: | |
|
27 | len_pedestal= float(linea) | |
|
28 | self.dict['len_ped']= len_pedestal | |
|
29 | if i==16: | |
|
30 | time_x_sample_ped=float(linea) | |
|
31 | self.dict['t_s_ped']= time_x_sample_ped | |
|
32 | if i==18: | |
|
33 | time_x_file_ped = float(linea) | |
|
34 | self.dict['t_f_ped']= time_x_file_ped | |
|
35 | if i==20: | |
|
36 | bloques_x_file_adq= float(linea) | |
|
37 | self.dict['b_f_adq']=bloques_x_file_adq | |
|
38 | if i==22: | |
|
39 | time_x_file_adq = float(linea) | |
|
40 | self.dict['t_f_adq'] = time_x_file_adq | |
|
41 | if i==24: | |
|
42 | mode= int(linea) | |
|
43 | self.dict['mode'] = mode | |
|
44 | #print(linea) | |
|
45 | if not linea: | |
|
46 | break | |
|
47 | i+=1 | |
|
48 | f.close() | |
|
49 | def getDict(self): | |
|
50 | return self.dict | |
|
51 | ||
|
52 | ||
|
53 | filename= "/home/developer/Downloads/config_WR.txt" | |
|
54 | dict= ReadfileWR(filename).getDict() | |
|
55 | print(dict) |
@@ -1,565 +1,567 | |||
|
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 |
|
7 | 7 | from schainpy.utils import log |
|
8 | 8 | import wradlib as wrl |
|
9 | 9 | |
|
10 | 10 | EARTH_RADIUS = 6.3710e3 |
|
11 | 11 | |
|
12 | 12 | |
|
13 | 13 | def ll2xy(lat1, lon1, lat2, lon2): |
|
14 | 14 | |
|
15 | 15 | p = 0.017453292519943295 |
|
16 | 16 | a = 0.5 - numpy.cos((lat2 - lat1) * p)/2 + numpy.cos(lat1 * p) * \ |
|
17 | 17 | numpy.cos(lat2 * p) * (1 - numpy.cos((lon2 - lon1) * p)) / 2 |
|
18 | 18 | r = 12742 * numpy.arcsin(numpy.sqrt(a)) |
|
19 | 19 | theta = numpy.arctan2(numpy.sin((lon2-lon1)*p)*numpy.cos(lat2*p), numpy.cos(lat1*p) |
|
20 | 20 | * numpy.sin(lat2*p)-numpy.sin(lat1*p)*numpy.cos(lat2*p)*numpy.cos((lon2-lon1)*p)) |
|
21 | 21 | theta = -theta + numpy.pi/2 |
|
22 | 22 | return r*numpy.cos(theta), r*numpy.sin(theta) |
|
23 | 23 | |
|
24 | 24 | |
|
25 | 25 | def km2deg(km): |
|
26 | 26 | ''' |
|
27 | 27 | Convert distance in km to degrees |
|
28 | 28 | ''' |
|
29 | 29 | |
|
30 | 30 | return numpy.rad2deg(km/EARTH_RADIUS) |
|
31 | 31 | |
|
32 | 32 | |
|
33 | 33 | |
|
34 | 34 | class SpectralMomentsPlot(SpectraPlot): |
|
35 | 35 | ''' |
|
36 | 36 | Plot for Spectral Moments |
|
37 | 37 | ''' |
|
38 | 38 | CODE = 'spc_moments' |
|
39 | 39 | colormap = 'jet' |
|
40 | 40 | plot_type = 'pcolor' |
|
41 | 41 | |
|
42 | 42 | |
|
43 | 43 | class SnrPlot(RTIPlot): |
|
44 | 44 | ''' |
|
45 | 45 | Plot for SNR Data |
|
46 | 46 | ''' |
|
47 | 47 | |
|
48 | 48 | CODE = 'snr' |
|
49 | 49 | colormap = 'jet' |
|
50 | 50 | |
|
51 | 51 | def update(self, dataOut): |
|
52 | 52 | |
|
53 | 53 | data = { |
|
54 | 54 | 'snr': 10*numpy.log10(dataOut.data_snr) |
|
55 | 55 | } |
|
56 | 56 | |
|
57 | 57 | return data, {} |
|
58 | 58 | |
|
59 | 59 | class DopplerPlot(RTIPlot): |
|
60 | 60 | ''' |
|
61 | 61 | Plot for DOPPLER Data (1st moment) |
|
62 | 62 | ''' |
|
63 | 63 | |
|
64 | 64 | CODE = 'dop' |
|
65 | 65 | colormap = 'jet' |
|
66 | 66 | |
|
67 | 67 | def update(self, dataOut): |
|
68 | 68 | |
|
69 | 69 | data = { |
|
70 | 70 | 'dop': 10*numpy.log10(dataOut.data_dop) |
|
71 | 71 | } |
|
72 | 72 | |
|
73 | 73 | return data, {} |
|
74 | 74 | |
|
75 | 75 | class PowerPlot(RTIPlot): |
|
76 | 76 | ''' |
|
77 | 77 | Plot for Power Data (0 moment) |
|
78 | 78 | ''' |
|
79 | 79 | |
|
80 | 80 | CODE = 'pow' |
|
81 | 81 | colormap = 'jet' |
|
82 | 82 | |
|
83 | 83 | def update(self, dataOut): |
|
84 | 84 | |
|
85 | 85 | data = { |
|
86 | 86 | 'pow': 10*numpy.log10(dataOut.data_pow) |
|
87 | 87 | } |
|
88 | 88 | |
|
89 | 89 | return data, {} |
|
90 | 90 | |
|
91 | 91 | class SpectralWidthPlot(RTIPlot): |
|
92 | 92 | ''' |
|
93 | 93 | Plot for Spectral Width Data (2nd moment) |
|
94 | 94 | ''' |
|
95 | 95 | |
|
96 | 96 | CODE = 'width' |
|
97 | 97 | colormap = 'jet' |
|
98 | 98 | |
|
99 | 99 | def update(self, dataOut): |
|
100 | 100 | |
|
101 | 101 | data = { |
|
102 | 102 | 'width': dataOut.data_width |
|
103 | 103 | } |
|
104 | 104 | |
|
105 | 105 | return data, {} |
|
106 | 106 | |
|
107 | 107 | class SkyMapPlot(Plot): |
|
108 | 108 | ''' |
|
109 | 109 | Plot for meteors detection data |
|
110 | 110 | ''' |
|
111 | 111 | |
|
112 | 112 | CODE = 'param' |
|
113 | 113 | |
|
114 | 114 | def setup(self): |
|
115 | 115 | |
|
116 | 116 | self.ncols = 1 |
|
117 | 117 | self.nrows = 1 |
|
118 | 118 | self.width = 7.2 |
|
119 | 119 | self.height = 7.2 |
|
120 | 120 | self.nplots = 1 |
|
121 | 121 | self.xlabel = 'Zonal Zenith Angle (deg)' |
|
122 | 122 | self.ylabel = 'Meridional Zenith Angle (deg)' |
|
123 | 123 | self.polar = True |
|
124 | 124 | self.ymin = -180 |
|
125 | 125 | self.ymax = 180 |
|
126 | 126 | self.colorbar = False |
|
127 | 127 | |
|
128 | 128 | def plot(self): |
|
129 | 129 | |
|
130 | 130 | arrayParameters = numpy.concatenate(self.data['param']) |
|
131 | 131 | error = arrayParameters[:, -1] |
|
132 | 132 | indValid = numpy.where(error == 0)[0] |
|
133 | 133 | finalMeteor = arrayParameters[indValid, :] |
|
134 | 134 | finalAzimuth = finalMeteor[:, 3] |
|
135 | 135 | finalZenith = finalMeteor[:, 4] |
|
136 | 136 | |
|
137 | 137 | x = finalAzimuth * numpy.pi / 180 |
|
138 | 138 | y = finalZenith |
|
139 | 139 | |
|
140 | 140 | ax = self.axes[0] |
|
141 | 141 | |
|
142 | 142 | if ax.firsttime: |
|
143 | 143 | ax.plot = ax.plot(x, y, 'bo', markersize=5)[0] |
|
144 | 144 | else: |
|
145 | 145 | ax.plot.set_data(x, y) |
|
146 | 146 | |
|
147 | 147 | dt1 = self.getDateTime(self.data.min_time).strftime('%y/%m/%d %H:%M:%S') |
|
148 | 148 | dt2 = self.getDateTime(self.data.max_time).strftime('%y/%m/%d %H:%M:%S') |
|
149 | 149 | title = 'Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n' % (dt1, |
|
150 | 150 | dt2, |
|
151 | 151 | len(x)) |
|
152 | 152 | self.titles[0] = title |
|
153 | 153 | |
|
154 | 154 | |
|
155 | 155 | class GenericRTIPlot(Plot): |
|
156 | 156 | ''' |
|
157 | 157 | Plot for data_xxxx object |
|
158 | 158 | ''' |
|
159 | 159 | |
|
160 | 160 | CODE = 'param' |
|
161 | 161 | colormap = 'viridis' |
|
162 | 162 | plot_type = 'pcolorbuffer' |
|
163 | 163 | |
|
164 | 164 | def setup(self): |
|
165 | 165 | self.xaxis = 'time' |
|
166 | 166 | self.ncols = 1 |
|
167 | 167 | self.nrows = self.data.shape(self.attr_data)[0] |
|
168 | 168 | self.nplots = self.nrows |
|
169 | 169 | self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.08, 'right':0.95, 'top': 0.95}) |
|
170 | 170 | |
|
171 | 171 | if not self.xlabel: |
|
172 | 172 | self.xlabel = 'Time' |
|
173 | 173 | |
|
174 | 174 | self.ylabel = 'Height [km]' |
|
175 | 175 | if not self.titles: |
|
176 | 176 | self.titles = self.data.parameters \ |
|
177 | 177 | if self.data.parameters else ['Param {}'.format(x) for x in range(self.nrows)] |
|
178 | 178 | |
|
179 | 179 | def update(self, dataOut): |
|
180 | 180 | |
|
181 | 181 | data = { |
|
182 | 182 | self.attr_data : getattr(dataOut, self.attr_data) |
|
183 | 183 | } |
|
184 | 184 | |
|
185 | 185 | meta = {} |
|
186 | 186 | |
|
187 | 187 | return data, meta |
|
188 | 188 | |
|
189 | 189 | def plot(self): |
|
190 | 190 | # self.data.normalize_heights() |
|
191 | 191 | self.x = self.data.times |
|
192 | 192 | self.y = self.data.yrange |
|
193 | 193 | self.z = self.data[self.attr_data] |
|
194 | 194 | |
|
195 | 195 | self.z = numpy.ma.masked_invalid(self.z) |
|
196 | 196 | |
|
197 | 197 | if self.decimation is None: |
|
198 | 198 | x, y, z = self.fill_gaps(self.x, self.y, self.z) |
|
199 | 199 | else: |
|
200 | 200 | x, y, z = self.fill_gaps(*self.decimate()) |
|
201 | 201 | |
|
202 | 202 | for n, ax in enumerate(self.axes): |
|
203 | 203 | |
|
204 | 204 | self.zmax = self.zmax if self.zmax is not None else numpy.max( |
|
205 | 205 | self.z[n]) |
|
206 | 206 | self.zmin = self.zmin if self.zmin is not None else numpy.min( |
|
207 | 207 | self.z[n]) |
|
208 | 208 | |
|
209 | 209 | if ax.firsttime: |
|
210 | 210 | if self.zlimits is not None: |
|
211 | 211 | self.zmin, self.zmax = self.zlimits[n] |
|
212 | 212 | |
|
213 | 213 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], |
|
214 | 214 | vmin=self.zmin, |
|
215 | 215 | vmax=self.zmax, |
|
216 | 216 | cmap=self.cmaps[n] |
|
217 | 217 | ) |
|
218 | 218 | else: |
|
219 | 219 | if self.zlimits is not None: |
|
220 | 220 | self.zmin, self.zmax = self.zlimits[n] |
|
221 | 221 | ax.collections.remove(ax.collections[0]) |
|
222 | 222 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], |
|
223 | 223 | vmin=self.zmin, |
|
224 | 224 | vmax=self.zmax, |
|
225 | 225 | cmap=self.cmaps[n] |
|
226 | 226 | ) |
|
227 | 227 | |
|
228 | 228 | |
|
229 | 229 | class PolarMapPlot(Plot): |
|
230 | 230 | ''' |
|
231 | 231 | Plot for weather radar |
|
232 | 232 | ''' |
|
233 | 233 | |
|
234 | 234 | CODE = 'param' |
|
235 | 235 | colormap = 'seismic' |
|
236 | 236 | |
|
237 | 237 | def setup(self): |
|
238 | 238 | self.ncols = 1 |
|
239 | 239 | self.nrows = 1 |
|
240 | 240 | self.width = 9 |
|
241 | 241 | self.height = 8 |
|
242 | 242 | self.mode = self.data.meta['mode'] |
|
243 | 243 | if self.channels is not None: |
|
244 | 244 | self.nplots = len(self.channels) |
|
245 | 245 | self.nrows = len(self.channels) |
|
246 | 246 | else: |
|
247 | 247 | self.nplots = self.data.shape(self.CODE)[0] |
|
248 | 248 | self.nrows = self.nplots |
|
249 | 249 | self.channels = list(range(self.nplots)) |
|
250 | 250 | if self.mode == 'E': |
|
251 | 251 | self.xlabel = 'Longitude' |
|
252 | 252 | self.ylabel = 'Latitude' |
|
253 | 253 | else: |
|
254 | 254 | self.xlabel = 'Range (km)' |
|
255 | 255 | self.ylabel = 'Height (km)' |
|
256 | 256 | self.bgcolor = 'white' |
|
257 | 257 | self.cb_labels = self.data.meta['units'] |
|
258 | 258 | self.lat = self.data.meta['latitude'] |
|
259 | 259 | self.lon = self.data.meta['longitude'] |
|
260 | 260 | self.xmin, self.xmax = float( |
|
261 | 261 | km2deg(self.xmin) + self.lon), float(km2deg(self.xmax) + self.lon) |
|
262 | 262 | self.ymin, self.ymax = float( |
|
263 | 263 | km2deg(self.ymin) + self.lat), float(km2deg(self.ymax) + self.lat) |
|
264 | 264 | # self.polar = True |
|
265 | 265 | |
|
266 | 266 | def plot(self): |
|
267 | 267 | |
|
268 | 268 | for n, ax in enumerate(self.axes): |
|
269 | 269 | data = self.data['param'][self.channels[n]] |
|
270 | 270 | |
|
271 | 271 | zeniths = numpy.linspace( |
|
272 | 272 | 0, self.data.meta['max_range'], data.shape[1]) |
|
273 | 273 | if self.mode == 'E': |
|
274 | 274 | azimuths = -numpy.radians(self.data.yrange)+numpy.pi/2 |
|
275 | 275 | r, theta = numpy.meshgrid(zeniths, azimuths) |
|
276 | 276 | x, y = r*numpy.cos(theta)*numpy.cos(numpy.radians(self.data.meta['elevation'])), r*numpy.sin( |
|
277 | 277 | theta)*numpy.cos(numpy.radians(self.data.meta['elevation'])) |
|
278 | 278 | x = km2deg(x) + self.lon |
|
279 | 279 | y = km2deg(y) + self.lat |
|
280 | 280 | else: |
|
281 | 281 | azimuths = numpy.radians(self.data.yrange) |
|
282 | 282 | r, theta = numpy.meshgrid(zeniths, azimuths) |
|
283 | 283 | x, y = r*numpy.cos(theta), r*numpy.sin(theta) |
|
284 | 284 | self.y = zeniths |
|
285 | 285 | |
|
286 | 286 | if ax.firsttime: |
|
287 | 287 | if self.zlimits is not None: |
|
288 | 288 | self.zmin, self.zmax = self.zlimits[n] |
|
289 | 289 | ax.plt = ax.pcolormesh( # r, theta, numpy.ma.array(data, mask=numpy.isnan(data)), |
|
290 | 290 | x, y, numpy.ma.array(data, mask=numpy.isnan(data)), |
|
291 | 291 | vmin=self.zmin, |
|
292 | 292 | vmax=self.zmax, |
|
293 | 293 | cmap=self.cmaps[n]) |
|
294 | 294 | else: |
|
295 | 295 | if self.zlimits is not None: |
|
296 | 296 | self.zmin, self.zmax = self.zlimits[n] |
|
297 | 297 | ax.collections.remove(ax.collections[0]) |
|
298 | 298 | ax.plt = ax.pcolormesh( # r, theta, numpy.ma.array(data, mask=numpy.isnan(data)), |
|
299 | 299 | x, y, numpy.ma.array(data, mask=numpy.isnan(data)), |
|
300 | 300 | vmin=self.zmin, |
|
301 | 301 | vmax=self.zmax, |
|
302 | 302 | cmap=self.cmaps[n]) |
|
303 | 303 | |
|
304 | 304 | if self.mode == 'A': |
|
305 | 305 | continue |
|
306 | 306 | |
|
307 | 307 | # plot district names |
|
308 | 308 | f = open('/data/workspace/schain_scripts/distrito.csv') |
|
309 | 309 | for line in f: |
|
310 | 310 | label, lon, lat = [s.strip() for s in line.split(',') if s] |
|
311 | 311 | lat = float(lat) |
|
312 | 312 | lon = float(lon) |
|
313 | 313 | # ax.plot(lon, lat, '.b', ms=2) |
|
314 | 314 | ax.text(lon, lat, label.decode('utf8'), ha='center', |
|
315 | 315 | va='bottom', size='8', color='black') |
|
316 | 316 | |
|
317 | 317 | # plot limites |
|
318 | 318 | limites = [] |
|
319 | 319 | tmp = [] |
|
320 | 320 | for line in open('/data/workspace/schain_scripts/lima.csv'): |
|
321 | 321 | if '#' in line: |
|
322 | 322 | if tmp: |
|
323 | 323 | limites.append(tmp) |
|
324 | 324 | tmp = [] |
|
325 | 325 | continue |
|
326 | 326 | values = line.strip().split(',') |
|
327 | 327 | tmp.append((float(values[0]), float(values[1]))) |
|
328 | 328 | for points in limites: |
|
329 | 329 | ax.add_patch( |
|
330 | 330 | Polygon(points, ec='k', fc='none', ls='--', lw=0.5)) |
|
331 | 331 | |
|
332 | 332 | # plot Cuencas |
|
333 | 333 | for cuenca in ('rimac', 'lurin', 'mala', 'chillon', 'chilca', 'chancay-huaral'): |
|
334 | 334 | f = open('/data/workspace/schain_scripts/{}.csv'.format(cuenca)) |
|
335 | 335 | values = [line.strip().split(',') for line in f] |
|
336 | 336 | points = [(float(s[0]), float(s[1])) for s in values] |
|
337 | 337 | ax.add_patch(Polygon(points, ec='b', fc='none')) |
|
338 | 338 | |
|
339 | 339 | # plot grid |
|
340 | 340 | for r in (15, 30, 45, 60): |
|
341 | 341 | ax.add_artist(plt.Circle((self.lon, self.lat), |
|
342 | 342 | km2deg(r), color='0.6', fill=False, lw=0.2)) |
|
343 | 343 | ax.text( |
|
344 | 344 | self.lon + (km2deg(r))*numpy.cos(60*numpy.pi/180), |
|
345 | 345 | self.lat + (km2deg(r))*numpy.sin(60*numpy.pi/180), |
|
346 | 346 | '{}km'.format(r), |
|
347 | 347 | ha='center', va='bottom', size='8', color='0.6', weight='heavy') |
|
348 | 348 | |
|
349 | 349 | if self.mode == 'E': |
|
350 | 350 | title = 'El={}$^\circ$'.format(self.data.meta['elevation']) |
|
351 | 351 | label = 'E{:02d}'.format(int(self.data.meta['elevation'])) |
|
352 | 352 | else: |
|
353 | 353 | title = 'Az={}$^\circ$'.format(self.data.meta['azimuth']) |
|
354 | 354 | label = 'A{:02d}'.format(int(self.data.meta['azimuth'])) |
|
355 | 355 | |
|
356 | 356 | self.save_labels = ['{}-{}'.format(lbl, label) for lbl in self.labels] |
|
357 | 357 | self.titles = ['{} {}'.format( |
|
358 | 358 | self.data.parameters[x], title) for x in self.channels] |
|
359 | 359 | |
|
360 | 360 | class WeatherPlot(Plot): |
|
361 | 361 | CODE = 'weather' |
|
362 | 362 | plot_name = 'weather' |
|
363 | 363 | plot_type = 'ppistyle' |
|
364 | 364 | buffering = False |
|
365 | 365 | |
|
366 | 366 | def setup(self): |
|
367 | 367 | self.ncols = 1 |
|
368 | 368 | self.nrows = 1 |
|
369 | 369 | self.nplots= 1 |
|
370 | 370 | self.ylabel= 'Range [Km]' |
|
371 | 371 | self.titles= ['Weather'] |
|
372 | 372 | self.colorbar=False |
|
373 | 373 | self.width =8 |
|
374 | 374 | self.height =8 |
|
375 | 375 | self.ini =0 |
|
376 | 376 | self.len_azi =0 |
|
377 | 377 | self.buffer_ini = None |
|
378 | 378 | self.buffer_azi = None |
|
379 | 379 | self.plots_adjust.update({'wspace': 0.4, 'hspace':0.4, 'left': 0.1, 'right': 0.9, 'bottom': 0.08}) |
|
380 | 380 | self.flag =0 |
|
381 | 381 | self.indicador= 0 |
|
382 | 382 | |
|
383 | 383 | def update(self, dataOut): |
|
384 | 384 | |
|
385 | 385 | data = {} |
|
386 | 386 | meta = {} |
|
387 | 387 | data['weather'] = 10*numpy.log10(dataOut.data_360/(650**2)) |
|
388 | 388 | data['azi'] = dataOut.data_azi |
|
389 | 389 | |
|
390 | 390 | return data, meta |
|
391 | 391 | |
|
392 | 392 | def plot(self): |
|
393 | thisDatetime = datetime.datetime.utcfromtimestamp(self.data.times[-1]) | |
|
394 | print("thisDatetime",thisDatetime) | |
|
393 | 395 | stoprange = float(33*1.5) |
|
394 | 396 | rangestep = float(0.15) |
|
395 | 397 | r = numpy.arange(0, stoprange, rangestep) |
|
396 | 398 | self.y = 2*r |
|
397 | 399 | data = self.data[-1] |
|
398 | 400 | |
|
399 | 401 | tmp_v = data['weather'] |
|
400 | 402 | tmp_z = data['azi'] |
|
401 | 403 | res = 1 |
|
402 | 404 | step = (360/(res*tmp_v.shape[0])) |
|
403 | 405 | mode = 1 |
|
404 | 406 | if mode==0: |
|
405 | print("self.ini",self.ini) | |
|
407 | #print("self.ini",self.ini) | |
|
406 | 408 | val = numpy.mean(tmp_v[:,0]) |
|
407 | 409 | self.len_azi = len(tmp_z) |
|
408 | 410 | ones = numpy.ones([(360-tmp_v.shape[0]),tmp_v.shape[1]])*val |
|
409 | 411 | self.buffer_ini = numpy.vstack((tmp_v,ones)) |
|
410 | 412 | |
|
411 | 413 | n = ((360/res)-len(tmp_z)) |
|
412 | 414 | start = tmp_z[-1]+res |
|
413 | 415 | end = tmp_z[0]-res |
|
414 | 416 | if start>end: |
|
415 | 417 | end = end+360 |
|
416 | 418 | azi_zeros = numpy.linspace(start,end,int(n)) |
|
417 | 419 | azi_zeros = numpy.where(azi_zeros>360,azi_zeros-360,azi_zeros) |
|
418 | 420 | self.buffer_ini_azi = numpy.hstack((tmp_z,azi_zeros)) |
|
419 | 421 | self.ini = self.ini+1 |
|
420 | 422 | |
|
421 | 423 | if mode==1: |
|
422 | print("self.ini",self.ini) | |
|
424 | #print("self.ini",self.ini) | |
|
423 | 425 | if self.ini==0: |
|
424 | 426 | res = 1 |
|
425 | 427 | step = (360/(res*tmp_v.shape[0])) |
|
426 | 428 | val = numpy.mean(tmp_v[:,0]) |
|
427 | 429 | self.len_azi = len(tmp_z) |
|
428 | 430 | self.buf_tmp = tmp_v |
|
429 | 431 | ones = numpy.ones([(360-tmp_v.shape[0]),tmp_v.shape[1]])*val |
|
430 | 432 | self.buffer_ini = numpy.vstack((tmp_v,ones)) |
|
431 | 433 | |
|
432 | 434 | n = ((360/res)-len(tmp_z)) |
|
433 | 435 | start = tmp_z[-1]+res |
|
434 | 436 | end = tmp_z[0]-res |
|
435 | 437 | if start>end: |
|
436 | 438 | end =end+360 |
|
437 | 439 | azi_zeros = numpy.linspace(start,end,int(n)) |
|
438 | 440 | azi_zeros = numpy.where(azi_zeros>360,azi_zeros-360,azi_zeros) |
|
439 | 441 | self.buf_azi = tmp_z |
|
440 | 442 | self.buffer_ini_azi = numpy.hstack((tmp_z,azi_zeros)) |
|
441 | 443 | self.ini = self.ini+1 |
|
442 | 444 | elif 0<self.ini<step: |
|
443 | 445 | ''' |
|
444 | 446 | if self.ini>31: |
|
445 | 447 | start= tmp_z[0] |
|
446 | 448 | end =tmp_z[-1] |
|
447 | 449 | print("start","end",start,end) |
|
448 | 450 | if self.ini==32: |
|
449 | 451 | tmp_v=tmp_v+20 |
|
450 | 452 | if self.ini==33: |
|
451 | 453 | tmp_v=tmp_v+10 |
|
452 | 454 | if self.ini==34: |
|
453 | 455 | tmp_v=tmp_v+20 |
|
454 | 456 | if self.ini==35: |
|
455 | 457 | tmp_v=tmp_v+20 |
|
456 | 458 | ''' |
|
457 | 459 | self.buf_tmp= numpy.vstack((self.buf_tmp,tmp_v)) |
|
458 | 460 | if self.buf_tmp.shape[0]==360: |
|
459 | 461 | self.buffer_ini=self.buf_tmp |
|
460 | 462 | else: |
|
461 | 463 | val=30.0 |
|
462 | 464 | ones = numpy.ones([(360-self.buf_tmp.shape[0]),self.buf_tmp.shape[1]])*val |
|
463 | 465 | self.buffer_ini = numpy.vstack((self.buf_tmp,ones)) |
|
464 | 466 | |
|
465 | 467 | self.buf_azi = numpy.hstack((self.buf_azi,tmp_z)) |
|
466 | 468 | n = ((360/res)-len(self.buf_azi)) |
|
467 | 469 | if n==0: |
|
468 | 470 | self.buffer_ini_azi = self.buf_azi |
|
469 | 471 | else: |
|
470 | 472 | start = self.buf_azi[-1]+res |
|
471 | 473 | end = self.buf_azi[0]-res |
|
472 | 474 | if start>end: |
|
473 | 475 | end =end+360 |
|
474 | 476 | azi_zeros = numpy.linspace(start,end,int(n)) |
|
475 | 477 | azi_zeros = numpy.where(azi_zeros>360,azi_zeros-360,azi_zeros) |
|
476 | 478 | if tmp_z[0]<self.buf_azi[0] <tmp_z[-1]: |
|
477 | 479 | self.indicador=1 |
|
478 | 480 | if self.indicador==1: |
|
479 | 481 | azi_zeros = numpy.ones(360-len(self.buf_azi))*(tmp_z[-1]+res) |
|
480 | 482 | # self.indicador = True |
|
481 | 483 | #if self.indicador==True: |
|
482 | 484 | # azi_zeros = numpy.ones(360-len(self.buf_azi))*(tmp_z[-1]+res) |
|
483 | 485 | |
|
484 | 486 | #self.buf_azi = tmp_z |
|
485 | 487 | self.buffer_ini_azi = numpy.hstack((self.buf_azi,azi_zeros)) |
|
486 | 488 | |
|
487 | 489 | if self.ini==step-1: |
|
488 | 490 | start= tmp_z[0] |
|
489 | 491 | end = tmp_z[-1] |
|
490 | print("start","end",start,end) | |
|
491 | print(self.buffer_ini_azi[:80]) | |
|
492 | #print("start","end",start,end) | |
|
493 | ###print(self.buffer_ini_azi[:80]) | |
|
492 | 494 | self.ini = self.ini+1 |
|
493 | 495 | |
|
494 | 496 | else: |
|
495 | 497 | step = (360/(res*tmp_v.shape[0])) |
|
496 | 498 | tmp_v=tmp_v+5+(self.ini-step)*1 |
|
497 | 499 | |
|
498 | 500 | start= tmp_z[0] |
|
499 | 501 | end = tmp_z[-1] |
|
500 | print("start","end",start,end) | |
|
501 | print(self.buffer_ini_azi[:120]) | |
|
502 | #print("start","end",start,end) | |
|
503 | ###print(self.buffer_ini_azi[:120]) | |
|
502 | 504 | |
|
503 | 505 | if step>=2: |
|
504 | 506 | if self.flag<step-1: |
|
505 | 507 | limit_i=self.buf_azi[len(tmp_z)*(self.flag+1)] |
|
506 | 508 | limit_s=self.buf_azi[len(tmp_z)*(self.flag+2)-1] |
|
507 | 509 | print("flag",self.flag,limit_i,limit_s) |
|
508 | 510 | if limit_i< tmp_z[-1]< limit_s: |
|
509 | 511 | index_i=int(numpy.where(tmp_z<=self.buf_azi[len(tmp_z)*(self.flag+1)])[0][-1]) |
|
510 | 512 | 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]) |
|
511 | 513 | print("tmp_r",tmp_r) |
|
512 | 514 | index_f=(self.flag+1)*len(tmp_z)+tmp_r |
|
513 | 515 | |
|
514 | 516 | if len(tmp_z[index_i:])>len(self.buf_azi[len(tmp_z)*(self.flag+1):index_f]): |
|
515 | 517 | final = len(self.buf_azi[len(tmp_z)*(self.flag+1):index_f]) |
|
516 | 518 | else: |
|
517 | 519 | final= len(tmp_z[index_i:]) |
|
518 | 520 | self.buf_azi[len(tmp_z)*(self.flag+1):index_f]=tmp_z[index_i:index_i+final] |
|
519 | 521 | self.buf_tmp[len(tmp_z)*(self.flag+1):index_f,:]=tmp_v[index_i:index_i+final,:] |
|
520 | 522 | if limit_i<tmp_z[0]<limit_s: |
|
521 | 523 | index_f =int(numpy.where(self.buf_azi>=tmp_z[-1])[0][0]) |
|
522 | 524 | n_p =index_f-len(tmp_z)*(self.flag+1) |
|
523 | 525 | if n_p>0: |
|
524 | 526 | self.buf_azi[len(tmp_z)*(self.flag+1):index_f]=tmp_z[-1]*numpy.ones(n_p) |
|
525 | 527 | self.buf_tmp[len(tmp_z)*(self.flag+1):index_f,:]=tmp_v[-1,:]*numpy.ones([n_p,tmp_v.shape[1]]) |
|
526 | 528 | |
|
527 | 529 | ''' |
|
528 | 530 | if self.buf_azi[len(tmp_z)]<tmp_z[-1]<self.buf_azi[2*len(tmp_z)-1]: |
|
529 | 531 | index_i= int(numpy.where(tmp_z <= self.buf_azi[len(tmp_z)])[0][-1]) |
|
530 | 532 | index_f= int(numpy.where(self.buf_azi>=tmp_z[-1])[0][0]) |
|
531 | 533 | #print("index",index_i,index_f) |
|
532 | 534 | if len(tmp_z[index_i:])>len(self.buf_azi[len(tmp_z):index_f]): |
|
533 | 535 | final = len(self.buf_azi[len(tmp_z):index_f]) |
|
534 | 536 | else: |
|
535 | 537 | final = len(tmp_z[index_i:]) |
|
536 | 538 | self.buf_azi[len(tmp_z):index_f]=tmp_z[index_i:index_i+final] |
|
537 | 539 | self.buf_tmp[len(tmp_z):index_f,:]=tmp_v[index_i:index_i+final,:] |
|
538 | 540 | ''' |
|
539 | 541 | self.buf_tmp[len(tmp_z)*(self.flag):len(tmp_z)*(self.flag+1),:]=tmp_v |
|
540 | 542 | self.buf_azi[len(tmp_z)*(self.flag):len(tmp_z)*(self.flag+1)] = tmp_z |
|
541 | 543 | self.buffer_ini=self.buf_tmp |
|
542 | 544 | self.buffer_ini_azi = self.buf_azi |
|
543 | print("--------salida------------") | |
|
545 | ##print("--------salida------------") | |
|
544 | 546 | start= tmp_z[0] |
|
545 | 547 | end = tmp_z[-1] |
|
546 | print("start","end",start,end) | |
|
547 | print(self.buffer_ini_azi[:120]) | |
|
548 | ##print("start","end",start,end) | |
|
549 | ##print(self.buffer_ini_azi[:120]) | |
|
548 | 550 | self.ini= self.ini+1 |
|
549 | 551 | self.flag = self.flag +1 |
|
550 | 552 | if self.flag==step: |
|
551 | 553 | self.flag=0 |
|
552 | 554 | |
|
553 | 555 | for i,ax in enumerate(self.axes): |
|
554 | 556 | if ax.firsttime: |
|
555 | 557 | plt.clf() |
|
556 | 558 | cgax, pm = wrl.vis.plot_ppi(self.buffer_ini,r=r,az=self.buffer_ini_azi,fig=self.figures[0], proj='cg', vmin=30, vmax=70) |
|
557 | 559 | else: |
|
558 | 560 | plt.clf() |
|
559 | 561 | cgax, pm = wrl.vis.plot_ppi(self.buffer_ini,r=r,az=self.buffer_ini_azi,fig=self.figures[0], proj='cg', vmin=30, vmax=70) |
|
560 | 562 | caax = cgax.parasites[0] |
|
561 | 563 | paax = cgax.parasites[1] |
|
562 | 564 | cbar = plt.gcf().colorbar(pm, pad=0.075) |
|
563 | 565 | caax.set_xlabel('x_range [km]') |
|
564 | 566 | caax.set_ylabel('y_range [km]') |
|
565 | plt.text(1.0, 1.05, 'azimuth', transform=caax.transAxes, va='bottom',ha='right') | |
|
567 | plt.text(1.0, 1.05, 'azimuth '+str(thisDatetime), transform=caax.transAxes, va='bottom',ha='right') |
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
@@ -1,37 +1,38 | |||
|
1 | 1 | import os,sys |
|
2 | 2 | import datetime |
|
3 | 3 | import time |
|
4 | 4 | from schainpy.controller import Project |
|
5 | 5 | #path = '/home/alex/Downloads/hdf5_testPP2' |
|
6 | 6 | #path = '/home/alex/Downloads/hdf5_test' |
|
7 | 7 | #path='/home/alex/Downloads/hdf5_wr' |
|
8 | 8 | path='/home/developer/Downloads/HDF5_WR' |
|
9 | 9 | figpath = path |
|
10 | 10 | desc = "Simulator Test" |
|
11 | 11 | |
|
12 | 12 | controllerObj = Project() |
|
13 | 13 | |
|
14 | 14 | controllerObj.setup(id='10',name='Test Simulator',description=desc) |
|
15 | 15 | |
|
16 | 16 | readUnitConfObj = controllerObj.addReadUnit(datatype='HDFReader', |
|
17 | 17 | path=path, |
|
18 | 18 | startDate="2021/01/01", #"2020/01/01",#today, |
|
19 | 19 | endDate= "2021/12/01", #"2020/12/30",#today, |
|
20 | 20 | startTime='00:00:00', |
|
21 | 21 | endTime='23:59:59', |
|
22 | 22 | delay=0, |
|
23 | 23 | #set=0, |
|
24 | 24 | online=0, |
|
25 | 25 | walk=0)#1 |
|
26 | 26 | |
|
27 | 27 | procUnitConfObjA = controllerObj.addProcUnit(datatype='ParametersProc',inputId=readUnitConfObj.getId()) |
|
28 | ||
|
28 | 29 | opObj11 = procUnitConfObjA.addOperation(name='Block360') |
|
29 |
opObj11.addParameter(name='n', value=' |
|
|
30 | opObj11.addParameter(name='n', value='40', format='int') | |
|
30 | 31 | |
|
31 | 32 | opObj11= procUnitConfObjA.addOperation(name='WeatherPlot',optype='other') |
|
32 |
|
|
|
33 |
|
|
|
33 | opObj11.addParameter(name='save', value=figpath) | |
|
34 | opObj11.addParameter(name='save_period', value=1) | |
|
34 | 35 | #opObj11 = procUnitConfObjA.addOperation(name='PowerPlot', optype='other')#PulsepairPowerPlot |
|
35 | 36 | #opObj11 = procUnitConfObjA.addOperation(name='PPSignalPlot', optype='other') |
|
36 | 37 | |
|
37 | 38 | controllerObj.start() |
@@ -1,38 +1,55 | |||
|
1 | 1 | import os,sys |
|
2 | 2 | import datetime |
|
3 | 3 | import time |
|
4 | 4 | from schainpy.controller import Project |
|
5 | ||
|
6 | #************************************************************************* | |
|
7 | #**************************LECTURA config_WR.txt************************** | |
|
8 | #************************************************************************* | |
|
9 | from readFileconfig import ReadfileWR | |
|
10 | filename= "/home/developer/Downloads/config_WR.txt" | |
|
11 | dict= ReadfileWR(filename).getDict() | |
|
12 | ||
|
13 | FixRCP_IPP = dict['ipp']*0.15 #equivalencia | |
|
14 | dataBlocksPerFile= dict['b_f_adq'] | |
|
15 | profilesPerBlock= int(dict['n']) | |
|
16 | pulsepair = int(dict['n']) | |
|
17 | #************************************************************************* | |
|
5 | 18 | path = '/home/developer/Downloads/HDF5_TESTPP2V3' |
|
6 | 19 | figpath = path |
|
7 | 20 | desc = "Simulator Test" |
|
8 | 21 | controllerObj = Project() |
|
9 | 22 | controllerObj.setup(id='10',name='Test Simulator',description=desc) |
|
10 | 23 | readUnitConfObj = controllerObj.addReadUnit(datatype='SimulatorReader', |
|
11 | 24 | frequency=9.345e9, |
|
12 |
FixRCP_IPP= |
|
|
25 | FixRCP_IPP= FixRCP_IPP, | |
|
13 | 26 | Tau_0 = 30, |
|
14 | 27 | AcqH0_0=0, |
|
15 | 28 | samples=330, |
|
16 | 29 | AcqDH_0=0.15, |
|
17 | 30 | FixRCP_TXA=0.15, |
|
18 | 31 | FixRCP_TXB=0.15, |
|
19 | 32 | Fdoppler=600.0, |
|
20 | 33 | Hdoppler=36, |
|
21 | 34 | Adoppler=300,#300 |
|
22 | 35 | delay=0, |
|
23 | 36 | online=0, |
|
24 | 37 | walk=0, |
|
25 |
profilesPerBlock= |
|
|
26 |
dataBlocksPerFile= |
|
|
38 | profilesPerBlock=profilesPerBlock, | |
|
39 | dataBlocksPerFile=dataBlocksPerFile)#,#nTotalReadFiles=2) | |
|
27 | 40 | #opObj11 = readUnitConfObj.addOperation(name='printInfo') |
|
28 | 41 | procUnitConfObjA = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId()) |
|
42 | ||
|
29 | 43 | opObj11 = procUnitConfObjA.addOperation(name='PulsePair') |
|
30 |
opObj11.addParameter(name='n', value= |
|
|
44 | opObj11.addParameter(name='n', value=pulsepair, format='int')#10 | |
|
45 | ||
|
31 | 46 | procUnitConfObjB= controllerObj.addProcUnit(datatype='ParametersProc',inputId=procUnitConfObjA.getId()) |
|
47 | ||
|
32 | 48 | opObj10 = procUnitConfObjB.addOperation(name='HDFWriter') |
|
33 | 49 | opObj10.addParameter(name='path',value=figpath) |
|
34 | 50 | #opObj10.addParameter(name='mode',value=2) |
|
35 | 51 | opObj10.addParameter(name='blocksPerFile',value='100',format='int') |
|
36 | 52 | opObj10.addParameter(name='metadataList',value='utctimeInit,paramInterval,heightList,profileIndex,flagDataAsBlock',format='list') |
|
37 | 53 | opObj10.addParameter(name='dataList',value='dataPP_POW,dataPP_DOP,utctime',format='list')#,format='list' |
|
54 | ||
|
38 | 55 | controllerObj.start() |
@@ -1,73 +1,74 | |||
|
1 | 1 | import os,sys |
|
2 | 2 | import datetime |
|
3 | 3 | import time |
|
4 | 4 | from schainpy.controller import Project |
|
5 | ||
|
5 | 6 | path = '/home/alex/Downloads/NEW_WR2/spc16removeDC' |
|
6 | 7 | figpath = path |
|
7 | 8 | desc = "Simulator Test" |
|
8 | 9 | |
|
9 | 10 | controllerObj = Project() |
|
10 | 11 | |
|
11 | 12 | controllerObj.setup(id='10',name='Test Simulator',description=desc) |
|
12 | 13 | |
|
13 | 14 | readUnitConfObj = controllerObj.addReadUnit(datatype='SimulatorReader', |
|
14 | 15 | frequency=9.345e9, |
|
15 | 16 | FixRCP_IPP= 60, |
|
16 | 17 | Tau_0 = 30, |
|
17 | 18 | AcqH0_0=0, |
|
18 | 19 | samples=330, |
|
19 | 20 | AcqDH_0=0.15, |
|
20 | 21 | FixRCP_TXA=0.15, |
|
21 | 22 | FixRCP_TXB=0.15, |
|
22 | 23 | Fdoppler=600.0, |
|
23 | 24 | Hdoppler=36, |
|
24 | 25 | Adoppler=300,#300 |
|
25 | 26 | delay=0, |
|
26 | 27 | online=0, |
|
27 | 28 | walk=0, |
|
28 | 29 | profilesPerBlock=625, |
|
29 | 30 | dataBlocksPerFile=100)#,#nTotalReadFiles=2) |
|
30 | 31 | ''' |
|
31 | 32 | readUnitConfObj = controllerObj.addReadUnit(datatype='VoltageReader', |
|
32 | 33 | path=path, |
|
33 | 34 | startDate="2020/01/01", #"2020/01/01",#today, |
|
34 | 35 | endDate= "2020/12/01", #"2020/12/30",#today, |
|
35 | 36 | startTime='00:00:00', |
|
36 | 37 | endTime='23:59:59', |
|
37 | 38 | delay=0, |
|
38 | 39 | #set=0, |
|
39 | 40 | online=0, |
|
40 | 41 | walk=1) |
|
41 | 42 | ''' |
|
42 | 43 | opObj11 = readUnitConfObj.addOperation(name='printInfo') |
|
43 | 44 | |
|
44 | 45 | procUnitConfObjA = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId()) |
|
45 | 46 | #opObj11 = procUnitConfObjA.addOperation(name='CohInt', optype='other') |
|
46 | 47 | #opObj11.addParameter(name='n', value='10', format='int') |
|
47 | 48 | |
|
48 | 49 | #opObj10 = procUnitConfObjA.addOperation(name='selectChannels') |
|
49 | 50 | #opObj10.addParameter(name='channelList', value=[0]) |
|
50 | 51 | opObj11 = procUnitConfObjA.addOperation(name='PulsePairVoltage', optype='other') |
|
51 | 52 | opObj11.addParameter(name='n', value='625', format='int')#10 |
|
52 | 53 | opObj11.addParameter(name='removeDC', value=1, format='int') |
|
53 | 54 | |
|
54 | 55 | #opObj11 = procUnitConfObjA.addOperation(name='PulsepairPowerPlot', optype='other') |
|
55 | 56 | #opObj11 = procUnitConfObjA.addOperation(name='PulsepairSignalPlot', optype='other') |
|
56 | 57 | |
|
57 | 58 | |
|
58 | 59 | #opObj11 = procUnitConfObjA.addOperation(name='PulsepairVelocityPlot', optype='other') |
|
59 | 60 | #opObj11.addParameter(name='xmax', value=8) |
|
60 | 61 | |
|
61 | 62 | #opObj11 = procUnitConfObjA.addOperation(name='PulsepairSpecwidthPlot', optype='other') |
|
62 | 63 | |
|
63 | 64 | procUnitConfObjB= controllerObj.addProcUnit(datatype='ParametersProc',inputId=procUnitConfObjA.getId()) |
|
64 | 65 | |
|
65 | 66 | |
|
66 | 67 | opObj10 = procUnitConfObjB.addOperation(name='ParameterWriter') |
|
67 | 68 | opObj10.addParameter(name='path',value=figpath) |
|
68 | 69 | #opObj10.addParameter(name='mode',value=0) |
|
69 | 70 | opObj10.addParameter(name='blocksPerFile',value='100',format='int') |
|
70 | 71 | opObj10.addParameter(name='metadataList',value='utctimeInit,timeInterval',format='list') |
|
71 | 72 | opObj10.addParameter(name='dataList',value='dataPP_POW,dataPP_DOP,dataPP_SNR,dataPP_WIDTH')#,format='list' |
|
72 | 73 | |
|
73 | 74 | controllerObj.start() |
@@ -1,189 +1,214 | |||
|
1 | 1 | import os,numpy,h5py |
|
2 | 2 | from shutil import copyfile |
|
3 | 3 | import sys,time |
|
4 | 4 | |
|
5 | 5 | def isNumber(str): |
|
6 | 6 | try: |
|
7 | 7 | float(str) |
|
8 | 8 | return True |
|
9 | 9 | except: |
|
10 | 10 | return False |
|
11 | 11 | |
|
12 | 12 | def getfirstFilefromPath(path,meta,ext): |
|
13 | 13 | validFilelist = [] |
|
14 | 14 | fileList = os.listdir(path) |
|
15 | 15 | if len(fileList)<1: |
|
16 | 16 | return None |
|
17 | 17 | # meta 1234 567 8-18 BCDE |
|
18 | 18 | # H,D,PE YYYY DDD EPOC .ext |
|
19 | 19 | |
|
20 | 20 | for thisFile in fileList: |
|
21 | 21 | if meta =="PE": |
|
22 | 22 | try: |
|
23 | 23 | number= int(thisFile[len(meta)+7:len(meta)+17]) |
|
24 | 24 | except: |
|
25 | 25 | print("There is a file or folder with different format") |
|
26 | 26 | if meta == "D": |
|
27 | 27 | try: |
|
28 | 28 | number= int(thisFile[8:11]) |
|
29 | 29 | except: |
|
30 | 30 | print("There is a file or folder with different format") |
|
31 | 31 | |
|
32 | 32 | if not isNumber(str=number): |
|
33 | 33 | continue |
|
34 | 34 | if (os.path.splitext(thisFile)[-1].lower() != ext.lower()): |
|
35 | 35 | continue |
|
36 | 36 | validFilelist.sort() |
|
37 | 37 | validFilelist.append(thisFile) |
|
38 | 38 | if len(validFilelist)>0: |
|
39 | 39 | validFilelist = sorted(validFilelist,key=str.lower) |
|
40 | 40 | return validFilelist |
|
41 | 41 | return None |
|
42 | 42 | |
|
43 | 43 | def gettimeutcfromDirFilename(path,file): |
|
44 | 44 | dir_file= path+"/"+file |
|
45 | 45 | fp = h5py.File(dir_file,'r') |
|
46 | 46 | epoc = fp['Metadata'].get('utctimeInit')[()] |
|
47 | 47 | fp.close() |
|
48 | 48 | return epoc |
|
49 | 49 | |
|
50 | 50 | def getDatavaluefromDirFilename(path,file,value): |
|
51 | 51 | dir_file= path+"/"+file |
|
52 | 52 | fp = h5py.File(dir_file,'r') |
|
53 | 53 | array = fp['Data'].get(value)[()] |
|
54 | 54 | fp.close() |
|
55 | 55 | return array |
|
56 | 56 | |
|
57 | opt = input ("Ingresa Modo de integracion: ") | |
|
58 | ||
|
59 | if opt==1: | |
|
60 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· Velocidad de PedestalΒ·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· | |
|
61 | w = input ("Ingresa velocidad de Pedestal: ") | |
|
62 | w = 4 | |
|
63 | w = float(w) | |
|
64 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· Resolucion minimo en gradosΒ·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· | |
|
65 | alfa = input ("Ingresa resolucion minima en grados: ") | |
|
66 | alfa = 1 | |
|
67 | alfa = float(alfa) | |
|
68 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· IPP del Experimento Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· | |
|
69 | IPP = input ("Ingresa el IPP del experimento: ") | |
|
70 | IPP = 0.0004 | |
|
71 | IPP = float(IPP) | |
|
72 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· MODE Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· | |
|
73 | mode = input ("Ingresa el MODO del experimento Time(1) or F(0): ") | |
|
74 | mode = 1 | |
|
75 | mode = int(mode) | |
|
76 | ||
|
77 | time_Interval_p=0.01 | |
|
78 | n_perfiles_p = 100 | |
|
79 | blocksPerFile = 100 | |
|
80 | tiempo_file_1_adq=25 | |
|
81 | tiempo_file_1_ped=1 | |
|
57 | 82 | |
|
58 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· Velocidad de PedestalΒ·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· | |
|
59 | w = input ("Ingresa velocidad de Pedestal: ") | |
|
60 | w = 4 | |
|
61 | w = float(w) | |
|
62 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· Resolucion minimo en gradosΒ·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· | |
|
63 | alfa = input ("Ingresa resolucion minima en grados: ") | |
|
64 | alfa = 1 | |
|
65 | alfa = float(alfa) | |
|
66 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· IPP del Experimento Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· | |
|
67 | IPP = input ("Ingresa el IPP del experimento: ") | |
|
68 | IPP = 0.0004 | |
|
69 | IPP = float(IPP) | |
|
70 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· MODE Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· | |
|
71 | mode = input ("Ingresa el MODO del experimento T or F: ") | |
|
72 | mode = "T" | |
|
73 | mode = str(mode) | |
|
83 | else: | |
|
84 | from readFileconfig import ReadfileWR | |
|
85 | filename= "/home/developer/Downloads/config_WR.txt" | |
|
86 | dict= ReadfileWR(filename).getDict() | |
|
87 | mode = dict['mode'] | |
|
88 | w = dict['vel_ped_azi'] | |
|
89 | alfa= dict['resolution'] | |
|
90 | IPP = dict['ipp']*1e-6 | |
|
91 | time_Interval_p = dict['t_s_ped'] | |
|
92 | n_perfiles_p = dict['len_ped'] | |
|
93 | blocksPerFile = int(dict['b_f_adq']) | |
|
94 | ||
|
95 | tiempo_file_1_adq= dict['t_f_adq'] | |
|
96 | tiempo_file_1_ped= dict['t_f_ped'] | |
|
74 | 97 | |
|
75 | 98 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· Tiempo en generar la resolucion minΒ·Β·Β· |
|
76 | 99 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· MCU Β·Β· var_ang = w * (var_tiempo)Β·Β·Β· |
|
77 | 100 | var_tiempo = alfa/w |
|
78 | 101 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· Tiempo Equivalente en perfilesΒ·Β·Β·Β·Β·Β·Β·Β· |
|
79 | 102 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· var_tiempo = IPP * ( num_perfiles )Β· |
|
80 | 103 | num_perfiles = int(var_tiempo/IPP) |
|
81 | 104 | |
|
82 | 105 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·DATA PEDESTALΒ·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· |
|
83 | 106 | dir_pedestal = "/home/developer/Downloads/Pedestal/P2021093" |
|
84 | 107 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· DATA ADQΒ·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· |
|
85 |
if mode== |
|
|
108 | if mode==1: | |
|
86 | 109 | dir_adq = "/home/developer/Downloads/HDF5_TESTPP2V3/d2021093" # Time domain |
|
87 | 110 | else: |
|
88 | 111 | dir_adq = "/home/developer/Downloads/hdf5_test/d2021053" # Frequency domain |
|
89 | 112 | |
|
90 | 113 | print( "Velocidad angular :", w) |
|
91 | 114 | print( "Resolucion minima en grados :", alfa) |
|
92 | 115 | print( "Numero de perfiles equivalente:", num_perfiles) |
|
93 | 116 | print( "Mode :", mode) |
|
94 | 117 | |
|
95 | 118 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· First FileΒ·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· |
|
96 | 119 | list_pedestal = getfirstFilefromPath(path=dir_pedestal,meta="PE",ext=".hdf5") |
|
97 | 120 | list_adq = getfirstFilefromPath(path=dir_adq ,meta="D",ext=".hdf5") |
|
98 | 121 | print("list_pedestal") |
|
99 | 122 | #print(list_pedestal) |
|
100 | 123 | print("list_adq") |
|
101 | 124 | #print(list_adq) |
|
102 | 125 | #sys.exit(0) |
|
103 | 126 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· utc time Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· |
|
104 | 127 | utc_pedestal= gettimeutcfromDirFilename(path=dir_pedestal,file=list_pedestal[0]) |
|
105 | 128 | utc_adq = gettimeutcfromDirFilename(path=dir_adq ,file=list_adq[0]) |
|
106 | 129 | |
|
107 | 130 | print("utc_pedestal :",utc_pedestal) |
|
108 | 131 | print("utc_adq :",utc_adq) |
|
109 | 132 | #sys.exit(0) |
|
110 | 133 | |
|
111 | 134 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Relacion: utc_adq (+/-) var_tiempo*nro_file= utc_pedestal |
|
112 | time_Interval_p = 0.01 | |
|
113 |
n_perfiles_p = |
|
|
135 | time_Interval_p = time_Interval_p#0.01 | |
|
136 | n_perfiles_p = n_perfiles_p #100 muestras por achivo del pedestal | |
|
114 | 137 | |
|
115 | 138 | |
|
116 | 139 | if utc_adq>utc_pedestal: |
|
117 | 140 | nro_file = int((utc_adq - utc_pedestal)/(time_Interval_p*n_perfiles_p)) |
|
118 | 141 | print("nro_file",nro_file) |
|
119 | 142 | ff_pedestal = list_pedestal[nro_file] |
|
120 | 143 | print(ff_pedestal) |
|
121 | 144 | utc_pedestal = gettimeutcfromDirFilename(path=dir_pedestal,file=ff_pedestal) |
|
122 | 145 | print(utc_pedestal) |
|
123 | 146 | nro_key_p = int((utc_adq-utc_pedestal)/time_Interval_p) |
|
124 | 147 | print(nro_key_p) |
|
125 | 148 | #sys.exit(0) |
|
126 | 149 | if utc_adq >utc_pedestal: |
|
127 | 150 | ff_pedestal = ff_pedestal |
|
128 | 151 | else: |
|
129 | 152 | nro_file = nro_file-1 |
|
130 | 153 | ff_pedestal = list_pedestal[nro_file] |
|
131 | 154 | utc_pedestal = gettimeutcfromDirFilename(path=dir_pedestal,file=ff_pedestal) |
|
132 | 155 | angulo = getDatavaluefromDirFilename(path=dir_pedestal,file=ff_pedestal,value="azimuth") |
|
133 | 156 | nro_key_p = int((utc_adq-utc_pedestal)/time_Interval_p) |
|
134 | 157 | print("nro_file :",nro_file) |
|
135 | 158 | print("name_file :",ff_pedestal) |
|
136 | 159 | print("utc_pedestal_file :",utc_pedestal) |
|
137 | 160 | print("nro_key_p :",nro_key_p) |
|
138 | 161 | print("utc_pedestal_init :",utc_pedestal+nro_key_p*time_Interval_p) |
|
139 | 162 | print("angulo_array :",angulo[nro_key_p]) |
|
140 | 163 | #4+25+25+25+21 |
|
141 | 164 | #while True: |
|
142 | 165 | list_pedestal = getfirstFilefromPath(path=dir_pedestal,meta="PE",ext=".hdf5") |
|
143 | 166 | list_adq = getfirstFilefromPath(path=dir_adq ,meta="D",ext=".hdf5") |
|
144 | 167 | |
|
145 | 168 | nro_file = nro_file #10 |
|
146 | 169 | nro_key_perfil = nro_key_p |
|
147 | blocksPerFile = 100##### aqui se cambia dependiendo de los blqoues por achivo en adq | |
|
170 | blocksPerFile = blocksPerFile#100##### aqui se cambia dependiendo de los blqoues por achivo en adq | |
|
148 | 171 | wr_path = "/home/developer/Downloads/HDF5_WR/" |
|
149 | 172 | # Lectura de archivos de adquisicion para adicion de azimuth |
|
150 | 173 | # factor de archivos |
|
151 | 174 | #f_a_p = tiempo_file_1_adq/tiempo_file_1_ped=25/1 = 25 |
|
152 |
tiempo_file_1_adq= |
|
|
153 | tiempo_file_1_ped=1 | |
|
175 | tiempo_file_1_adq = tiempo_file_1_adq | |
|
176 | tiempo_file_1_ped = tiempo_file_1_ped | |
|
177 | ||
|
154 | 178 | f_a_p= int(tiempo_file_1_adq/tiempo_file_1_ped) |
|
179 | ||
|
155 | 180 | for thisFile in range(len(list_adq)): |
|
156 | 181 | print("thisFileAdq",thisFile) |
|
157 | 182 | angulo_adq = numpy.zeros(blocksPerFile) |
|
158 | 183 | tmp = 0 |
|
159 | 184 | for j in range(blocksPerFile): |
|
160 | 185 | iterador = nro_key_perfil + f_a_p*(j-tmp) |
|
161 | 186 | #print("iterador",iterador) |
|
162 | 187 | if iterador < n_perfiles_p: |
|
163 | 188 | nro_file = nro_file |
|
164 | 189 | else: |
|
165 | 190 | nro_file = nro_file+1 |
|
166 | 191 | dif = blocksPerFile-(nro_key_perfil+f_a_p*(j-tmp-1)) |
|
167 | 192 | tmp = j |
|
168 | 193 | nro_key_perfil= f_a_p-dif |
|
169 | 194 | iterador = nro_key_perfil |
|
170 | 195 | #print(iterador) |
|
171 | 196 | print("nro_file",nro_file) |
|
172 | 197 | ff_pedestal = list_pedestal[nro_file] |
|
173 | 198 | angulo = getDatavaluefromDirFilename(path=dir_pedestal,file=ff_pedestal,value="azimuth") |
|
174 | 199 | angulo_adq[j]= angulo[iterador] |
|
175 | 200 | copyfile(dir_adq+"/"+list_adq[thisFile],wr_path+list_adq[thisFile]) |
|
176 | 201 | fp = h5py.File(wr_path+list_adq[thisFile],'a') |
|
177 | 202 | #grp = fp.create_group("Pedestal") |
|
178 | 203 | grp = fp['Metadata'] |
|
179 | 204 | #sgrp = grp.create_group('Pedestal') |
|
180 | 205 | dset = grp.create_dataset("azimuth" , data=angulo_adq) |
|
181 | 206 | fp.close() |
|
182 | 207 | print("Angulo",angulo_adq) |
|
183 | 208 | print("Angulo",len(angulo_adq)) |
|
184 | 209 | nro_key_perfil=iterador + f_a_p |
|
185 | 210 | if nro_key_perfil< n_perfiles_p: |
|
186 | 211 | nro_file = nro_file |
|
187 | 212 | else: |
|
188 | 213 | nro_file = nro_file+1 |
|
189 | 214 | nro_key_perfil= nro_key_p |
General Comments 0
You need to be logged in to leave comments.
Login now