The requested changes are too big and content was truncated. Show full diff
This diff has been collapsed as it changes many lines, (1156 lines changed) Show them Hide them | |||
@@ -0,0 +1,1156 | |||
|
1 | ||
|
2 | import os | |
|
3 | import datetime | |
|
4 | import numpy | |
|
5 | from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation, MPDecorator #YONG | |
|
6 | ||
|
7 | from .jroplot_spectra import RTIPlot, NoisePlot | |
|
8 | ||
|
9 | from schainpy.utils import log | |
|
10 | from .plotting_codes import * | |
|
11 | ||
|
12 | from schainpy.model.graphics.jroplot_base import Plot, plt | |
|
13 | ||
|
14 | import matplotlib.pyplot as plt | |
|
15 | import matplotlib.colors as colors | |
|
16 | ||
|
17 | import time | |
|
18 | import math | |
|
19 | ||
|
20 | ||
|
21 | from matplotlib.ticker import MultipleLocator | |
|
22 | ||
|
23 | ||
|
24 | ||
|
25 | class RTIDPPlot(RTIPlot): | |
|
26 | ||
|
27 | ''' | |
|
28 | Plot for RTI Double Pulse Experiment | |
|
29 | ''' | |
|
30 | ||
|
31 | CODE = 'RTIDP' | |
|
32 | colormap = 'jro' | |
|
33 | plot_name = 'RTI' | |
|
34 | ||
|
35 | #cb_label = 'Ne Electron Density (1/cm3)' | |
|
36 | ||
|
37 | def setup(self): | |
|
38 | self.xaxis = 'time' | |
|
39 | self.ncols = 1 | |
|
40 | self.nrows = 3 | |
|
41 | self.nplots = self.nrows | |
|
42 | #self.height=10 | |
|
43 | if self.showSNR: | |
|
44 | self.nrows += 1 | |
|
45 | self.nplots += 1 | |
|
46 | ||
|
47 | self.ylabel = 'Height [km]' | |
|
48 | self.xlabel = 'Time (LT)' | |
|
49 | ||
|
50 | self.cb_label = 'Intensity (dB)' | |
|
51 | ||
|
52 | ||
|
53 | #self.cb_label = cb_label | |
|
54 | ||
|
55 | self.titles = ['{} Channel {}'.format( | |
|
56 | self.plot_name.upper(), '0x1'),'{} Channel {}'.format( | |
|
57 | self.plot_name.upper(), '0'),'{} Channel {}'.format( | |
|
58 | self.plot_name.upper(), '1')] | |
|
59 | ||
|
60 | ||
|
61 | def plot(self): | |
|
62 | ||
|
63 | self.data.normalize_heights() | |
|
64 | self.x = self.data.times | |
|
65 | self.y = self.data.heights[0:self.data.NDP] | |
|
66 | ||
|
67 | if self.showSNR: | |
|
68 | self.z = numpy.concatenate( | |
|
69 | (self.data[self.CODE], self.data['snr']) | |
|
70 | ) | |
|
71 | else: | |
|
72 | ||
|
73 | self.z = self.data[self.CODE] | |
|
74 | #print(numpy.max(self.z[0,0:])) | |
|
75 | ||
|
76 | self.z = numpy.ma.masked_invalid(self.z) | |
|
77 | ||
|
78 | if self.decimation is None: | |
|
79 | x, y, z = self.fill_gaps(self.x, self.y, self.z) | |
|
80 | else: | |
|
81 | x, y, z = self.fill_gaps(*self.decimate()) | |
|
82 | ||
|
83 | for n, ax in enumerate(self.axes): | |
|
84 | ||
|
85 | ||
|
86 | self.zmax = self.zmax if self.zmax is not None else numpy.max( | |
|
87 | self.z[1][0,12:40]) | |
|
88 | self.zmin = self.zmin if self.zmin is not None else numpy.min( | |
|
89 | self.z[1][0,12:40]) | |
|
90 | ||
|
91 | ||
|
92 | ||
|
93 | if ax.firsttime: | |
|
94 | ||
|
95 | if self.zlimits is not None: | |
|
96 | self.zmin, self.zmax = self.zlimits[n] | |
|
97 | ||
|
98 | ||
|
99 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], | |
|
100 | vmin=self.zmin, | |
|
101 | vmax=self.zmax, | |
|
102 | cmap=self.cmaps[n] | |
|
103 | ) | |
|
104 | #plt.tight_layout() | |
|
105 | else: | |
|
106 | if self.zlimits is not None: | |
|
107 | self.zmin, self.zmax = self.zlimits[n] | |
|
108 | ax.collections.remove(ax.collections[0]) | |
|
109 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], | |
|
110 | vmin=self.zmin, | |
|
111 | vmax=self.zmax, | |
|
112 | cmap=self.cmaps[n] | |
|
113 | ) | |
|
114 | #plt.tight_layout() | |
|
115 | ||
|
116 | ||
|
117 | class RTILPPlot(RTIPlot): | |
|
118 | ||
|
119 | ''' | |
|
120 | Plot for RTI Long Pulse | |
|
121 | ''' | |
|
122 | ||
|
123 | CODE = 'RTILP' | |
|
124 | colormap = 'jro' | |
|
125 | plot_name = 'RTI LP' | |
|
126 | ||
|
127 | #cb_label = 'Ne Electron Density (1/cm3)' | |
|
128 | ||
|
129 | def setup(self): | |
|
130 | self.xaxis = 'time' | |
|
131 | self.ncols = 1 | |
|
132 | self.nrows = 4 | |
|
133 | self.nplots = self.nrows | |
|
134 | if self.showSNR: | |
|
135 | self.nrows += 1 | |
|
136 | self.nplots += 1 | |
|
137 | ||
|
138 | self.ylabel = 'Height [km]' | |
|
139 | self.xlabel = 'Time (LT)' | |
|
140 | ||
|
141 | self.cb_label = 'Intensity (dB)' | |
|
142 | ||
|
143 | ||
|
144 | ||
|
145 | #self.cb_label = cb_label | |
|
146 | ||
|
147 | self.titles = ['{} Channel {}'.format( | |
|
148 | self.plot_name.upper(), '0'),'{} Channel {}'.format( | |
|
149 | self.plot_name.upper(), '1'),'{} Channel {}'.format( | |
|
150 | self.plot_name.upper(), '2'),'{} Channel {}'.format( | |
|
151 | self.plot_name.upper(), '3')] | |
|
152 | ||
|
153 | ||
|
154 | def plot(self): | |
|
155 | ||
|
156 | self.data.normalize_heights() | |
|
157 | self.x = self.data.times | |
|
158 | self.y = self.data.heights[0:self.data.NRANGE] | |
|
159 | ||
|
160 | if self.showSNR: | |
|
161 | self.z = numpy.concatenate( | |
|
162 | (self.data[self.CODE], self.data['snr']) | |
|
163 | ) | |
|
164 | else: | |
|
165 | ||
|
166 | self.z = self.data[self.CODE] | |
|
167 | #print(numpy.max(self.z[0,0:])) | |
|
168 | ||
|
169 | self.z = numpy.ma.masked_invalid(self.z) | |
|
170 | ||
|
171 | if self.decimation is None: | |
|
172 | x, y, z = self.fill_gaps(self.x, self.y, self.z) | |
|
173 | else: | |
|
174 | x, y, z = self.fill_gaps(*self.decimate()) | |
|
175 | ||
|
176 | for n, ax in enumerate(self.axes): | |
|
177 | ||
|
178 | ||
|
179 | self.zmax = self.zmax if self.zmax is not None else numpy.max( | |
|
180 | self.z[1][0,12:40]) | |
|
181 | self.zmin = self.zmin if self.zmin is not None else numpy.min( | |
|
182 | self.z[1][0,12:40]) | |
|
183 | ||
|
184 | if ax.firsttime: | |
|
185 | ||
|
186 | if self.zlimits is not None: | |
|
187 | self.zmin, self.zmax = self.zlimits[n] | |
|
188 | ||
|
189 | ||
|
190 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], | |
|
191 | vmin=self.zmin, | |
|
192 | vmax=self.zmax, | |
|
193 | cmap=self.cmaps[n] | |
|
194 | ) | |
|
195 | #plt.tight_layout() | |
|
196 | else: | |
|
197 | if self.zlimits is not None: | |
|
198 | self.zmin, self.zmax = self.zlimits[n] | |
|
199 | ax.collections.remove(ax.collections[0]) | |
|
200 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], | |
|
201 | vmin=self.zmin, | |
|
202 | vmax=self.zmax, | |
|
203 | cmap=self.cmaps[n] | |
|
204 | ) | |
|
205 | #plt.tight_layout() | |
|
206 | ||
|
207 | ||
|
208 | class DenRTIPlot(RTIPlot): | |
|
209 | ||
|
210 | ''' | |
|
211 | Plot for Den | |
|
212 | ''' | |
|
213 | ||
|
214 | CODE = 'denrti' | |
|
215 | colormap = 'jro' | |
|
216 | plot_name = 'Electron Density' | |
|
217 | ||
|
218 | #cb_label = 'Ne Electron Density (1/cm3)' | |
|
219 | ||
|
220 | def setup(self): | |
|
221 | self.xaxis = 'time' | |
|
222 | self.ncols = 1 | |
|
223 | self.nrows = self.data.shape(self.CODE)[0] | |
|
224 | self.nplots = self.nrows | |
|
225 | if self.showSNR: | |
|
226 | self.nrows += 1 | |
|
227 | self.nplots += 1 | |
|
228 | ||
|
229 | self.ylabel = 'Height [km]' | |
|
230 | self.xlabel = 'Time (LT)' | |
|
231 | ||
|
232 | self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18}) | |
|
233 | ||
|
234 | if self.CODE == 'denrti' or self.CODE=='denrtiLP': | |
|
235 | self.cb_label = r'$\mathrm{N_e}$ Electron Density ($\mathrm{1/cm^3}$)' | |
|
236 | ||
|
237 | #self.cb_label = cb_label | |
|
238 | if not self.titles: | |
|
239 | self.titles = self.data.parameters \ | |
|
240 | if self.data.parameters else ['{}'.format(self.plot_name)] | |
|
241 | if self.showSNR: | |
|
242 | self.titles.append('SNR') | |
|
243 | ||
|
244 | def plot(self): | |
|
245 | ||
|
246 | self.data.normalize_heights() | |
|
247 | self.x = self.data.times | |
|
248 | self.y = self.data.heights | |
|
249 | ||
|
250 | ||
|
251 | ||
|
252 | if self.showSNR: | |
|
253 | self.z = numpy.concatenate( | |
|
254 | (self.data[self.CODE], self.data['snr']) | |
|
255 | ) | |
|
256 | else: | |
|
257 | self.z = self.data[self.CODE] | |
|
258 | ||
|
259 | self.z = numpy.ma.masked_invalid(self.z) | |
|
260 | ||
|
261 | if self.decimation is None: | |
|
262 | x, y, z = self.fill_gaps(self.x, self.y, self.z) | |
|
263 | else: | |
|
264 | x, y, z = self.fill_gaps(*self.decimate()) | |
|
265 | ||
|
266 | for n, ax in enumerate(self.axes): | |
|
267 | ||
|
268 | self.zmax = self.zmax if self.zmax is not None else numpy.max( | |
|
269 | self.z[n]) | |
|
270 | self.zmin = self.zmin if self.zmin is not None else numpy.min( | |
|
271 | self.z[n]) | |
|
272 | ||
|
273 | if ax.firsttime: | |
|
274 | ||
|
275 | if self.zlimits is not None: | |
|
276 | self.zmin, self.zmax = self.zlimits[n] | |
|
277 | if numpy.log10(self.zmin)<0: | |
|
278 | self.zmin=1 | |
|
279 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], | |
|
280 | vmin=self.zmin, | |
|
281 | vmax=self.zmax, | |
|
282 | cmap=self.cmaps[n], | |
|
283 | norm=colors.LogNorm() | |
|
284 | ) | |
|
285 | #plt.tight_layout() | |
|
286 | ||
|
287 | else: | |
|
288 | if self.zlimits is not None: | |
|
289 | self.zmin, self.zmax = self.zlimits[n] | |
|
290 | ax.collections.remove(ax.collections[0]) | |
|
291 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], | |
|
292 | vmin=self.zmin, | |
|
293 | vmax=self.zmax, | |
|
294 | cmap=self.cmaps[n], | |
|
295 | norm=colors.LogNorm() | |
|
296 | ) | |
|
297 | #plt.tight_layout() | |
|
298 | ||
|
299 | ||
|
300 | ||
|
301 | class DenRTILPPlot(DenRTIPlot): | |
|
302 | ||
|
303 | ''' | |
|
304 | Plot for Electron Temperature | |
|
305 | ''' | |
|
306 | ||
|
307 | CODE = 'denrtiLP' | |
|
308 | colormap = 'jro' | |
|
309 | plot_name = 'Electron Density' | |
|
310 | ||
|
311 | ||
|
312 | class ETempRTIPlot(RTIPlot): | |
|
313 | ||
|
314 | ''' | |
|
315 | Plot for Electron Temperature | |
|
316 | ''' | |
|
317 | ||
|
318 | CODE = 'ETemp' | |
|
319 | colormap = 'jet' | |
|
320 | plot_name = 'Electron Temperature' | |
|
321 | ||
|
322 | #cb_label = 'Ne Electron Density (1/cm3)' | |
|
323 | ||
|
324 | def setup(self): | |
|
325 | self.xaxis = 'time' | |
|
326 | self.ncols = 1 | |
|
327 | self.nrows = self.data.shape(self.CODE)[0] | |
|
328 | self.nplots = self.nrows | |
|
329 | if self.showSNR: | |
|
330 | self.nrows += 1 | |
|
331 | self.nplots += 1 | |
|
332 | ||
|
333 | self.ylabel = 'Height [km]' | |
|
334 | self.xlabel = 'Time (LT)' | |
|
335 | self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18}) | |
|
336 | if self.CODE == 'ETemp' or self.CODE == 'ETempLP': | |
|
337 | self.cb_label = 'Electron Temperature (K)' | |
|
338 | if self.CODE == 'ITemp' or self.CODE == 'ITempLP': | |
|
339 | self.cb_label = 'Ion Temperature (K)' | |
|
340 | ||
|
341 | ||
|
342 | if not self.titles: | |
|
343 | self.titles = self.data.parameters \ | |
|
344 | if self.data.parameters else ['{}'.format(self.plot_name)] | |
|
345 | if self.showSNR: | |
|
346 | self.titles.append('SNR') | |
|
347 | ||
|
348 | def plot(self): | |
|
349 | ||
|
350 | self.data.normalize_heights() | |
|
351 | self.x = self.data.times | |
|
352 | self.y = self.data.heights | |
|
353 | ||
|
354 | if self.showSNR: | |
|
355 | self.z = numpy.concatenate( | |
|
356 | (self.data[self.CODE], self.data['snr']) | |
|
357 | ) | |
|
358 | else: | |
|
359 | self.z = self.data[self.CODE] | |
|
360 | ||
|
361 | self.z = numpy.ma.masked_invalid(self.z) | |
|
362 | ||
|
363 | if self.decimation is None: | |
|
364 | x, y, z = self.fill_gaps(self.x, self.y, self.z) | |
|
365 | else: | |
|
366 | x, y, z = self.fill_gaps(*self.decimate()) | |
|
367 | ||
|
368 | for n, ax in enumerate(self.axes): | |
|
369 | ||
|
370 | self.zmax = self.zmax if self.zmax is not None else numpy.max( | |
|
371 | self.z[n]) | |
|
372 | self.zmin = self.zmin if self.zmin is not None else numpy.min( | |
|
373 | self.z[n]) | |
|
374 | ||
|
375 | if ax.firsttime: | |
|
376 | ||
|
377 | if self.zlimits is not None: | |
|
378 | self.zmin, self.zmax = self.zlimits[n] | |
|
379 | ||
|
380 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], | |
|
381 | vmin=self.zmin, | |
|
382 | vmax=self.zmax, | |
|
383 | cmap=self.cmaps[n] | |
|
384 | ) | |
|
385 | #plt.tight_layout() | |
|
386 | ||
|
387 | else: | |
|
388 | if self.zlimits is not None: | |
|
389 | self.zmin, self.zmax = self.zlimits[n] | |
|
390 | ax.collections.remove(ax.collections[0]) | |
|
391 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], | |
|
392 | vmin=self.zmin, | |
|
393 | vmax=self.zmax, | |
|
394 | cmap=self.cmaps[n] | |
|
395 | ) | |
|
396 | #plt.tight_layout() | |
|
397 | ||
|
398 | ||
|
399 | ||
|
400 | class ITempRTIPlot(ETempRTIPlot): | |
|
401 | ||
|
402 | ''' | |
|
403 | Plot for Ion Temperature | |
|
404 | ''' | |
|
405 | ||
|
406 | CODE = 'ITemp' | |
|
407 | colormap = 'jet' | |
|
408 | plot_name = 'Ion Temperature' | |
|
409 | ||
|
410 | ||
|
411 | class ElectronTempLPPlot(ETempRTIPlot): | |
|
412 | ||
|
413 | ''' | |
|
414 | Plot for Electron Temperature LP | |
|
415 | ''' | |
|
416 | ||
|
417 | CODE = 'ETempLP' | |
|
418 | colormap = 'jet' | |
|
419 | plot_name = 'Electron Temperature' | |
|
420 | ||
|
421 | ||
|
422 | class IonTempLPPlot(ETempRTIPlot): | |
|
423 | ||
|
424 | ''' | |
|
425 | Plot for Ion Temperature LP | |
|
426 | ''' | |
|
427 | ||
|
428 | CODE = 'ITempLP' | |
|
429 | colormap = 'jet' | |
|
430 | plot_name = 'Ion Temperature' | |
|
431 | ||
|
432 | ||
|
433 | class HFracRTIPlot(ETempRTIPlot): | |
|
434 | ||
|
435 | ''' | |
|
436 | Plot for H+ LP | |
|
437 | ''' | |
|
438 | ||
|
439 | CODE = 'HFracLP' | |
|
440 | colormap = 'jet' | |
|
441 | plot_name = 'H+ Frac' | |
|
442 | ||
|
443 | ||
|
444 | class HeFracRTIPlot(ETempRTIPlot): | |
|
445 | ||
|
446 | ''' | |
|
447 | Plot for He+ LP | |
|
448 | ''' | |
|
449 | ||
|
450 | CODE = 'HeFracLP' | |
|
451 | colormap = 'jet' | |
|
452 | plot_name = 'He+ Frac' | |
|
453 | ||
|
454 | ||
|
455 | class TempsDPPlot(Plot): | |
|
456 | ''' | |
|
457 | Plot for Electron - Ion Temperatures | |
|
458 | ''' | |
|
459 | ||
|
460 | CODE = 'tempsDP' | |
|
461 | plot_name = 'Temperatures' | |
|
462 | plot_type = 'scatterbuffer' | |
|
463 | ||
|
464 | ||
|
465 | def setup(self): | |
|
466 | ||
|
467 | self.ncols = 1 | |
|
468 | self.nrows = 1 | |
|
469 | self.nplots = 1 | |
|
470 | self.ylabel = 'Range [km]' | |
|
471 | self.xlabel = 'Temperature (K)' | |
|
472 | self.width = 3.5 | |
|
473 | self.height = 5.5 | |
|
474 | self.colorbar = False | |
|
475 | self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18}) | |
|
476 | if not self.titles: | |
|
477 | self.titles = self.data.parameters \ | |
|
478 | if self.data.parameters else ['{}'.format(self.CODE.upper())] | |
|
479 | ||
|
480 | def plot(self): | |
|
481 | ||
|
482 | self.x = self.data['tempsDP'][:,-1] | |
|
483 | self.y = self.data.heights[0:self.data.NSHTS] | |
|
484 | ||
|
485 | self.xmin = -100 | |
|
486 | self.xmax = 5000 | |
|
487 | ax = self.axes[0] | |
|
488 | ||
|
489 | if ax.firsttime: | |
|
490 | ||
|
491 | ax.errorbar(self.x, self.y, xerr=self.data.ete2, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='Te') | |
|
492 | ax.errorbar(self.data.ti2, self.y, fmt='k^', xerr=self.data.eti2,elinewidth=1.0,color='b',linewidth=2.0, label='Ti') | |
|
493 | plt.legend(loc='lower right') | |
|
494 | self.ystep_given = 50 | |
|
495 | ax.yaxis.set_minor_locator(MultipleLocator(15)) | |
|
496 | ax.grid(which='minor') | |
|
497 | #plt.tight_layout() | |
|
498 | ||
|
499 | ||
|
500 | else: | |
|
501 | self.clear_figures() | |
|
502 | ax.errorbar(self.x, self.y, xerr=self.data.ete2, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='Te') | |
|
503 | ax.errorbar(self.data.ti2, self.y, fmt='k^', xerr=self.data.eti2,elinewidth=1.0,color='b',linewidth=2.0, label='Ti') | |
|
504 | plt.legend(loc='lower right') | |
|
505 | ax.yaxis.set_minor_locator(MultipleLocator(15)) | |
|
506 | #plt.tight_layout() | |
|
507 | ||
|
508 | ||
|
509 | class TempsHPPlot(Plot): | |
|
510 | ''' | |
|
511 | Plot for Temperatures Hybrid Experiment | |
|
512 | ''' | |
|
513 | ||
|
514 | CODE = 'temps_LP' | |
|
515 | plot_name = 'Temperatures' | |
|
516 | plot_type = 'scatterbuffer' | |
|
517 | ||
|
518 | ||
|
519 | def setup(self): | |
|
520 | ||
|
521 | self.ncols = 1 | |
|
522 | self.nrows = 1 | |
|
523 | self.nplots = 1 | |
|
524 | self.ylabel = 'Range [km]' | |
|
525 | self.xlabel = 'Temperature (K)' | |
|
526 | self.width = 3.5 | |
|
527 | self.height = 6.5 | |
|
528 | self.colorbar = False | |
|
529 | if not self.titles: | |
|
530 | self.titles = self.data.parameters \ | |
|
531 | if self.data.parameters else ['{}'.format(self.CODE.upper())] | |
|
532 | ||
|
533 | def plot(self): | |
|
534 | ||
|
535 | self.x = self.data['temps_LP'][:,-1] | |
|
536 | self.y = self.data.heights[0:self.data.NACF] | |
|
537 | self.xmin = -100 | |
|
538 | self.xmax = 4500 | |
|
539 | ax = self.axes[0] | |
|
540 | ||
|
541 | if ax.firsttime: | |
|
542 | ||
|
543 | ax.errorbar(self.x, self.y, xerr=self.data.ete, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='Te') | |
|
544 | ax.errorbar(self.data.ti, self.y, fmt='k^', xerr=self.data.eti,elinewidth=1.0,color='b',linewidth=2.0, label='Ti') | |
|
545 | plt.legend(loc='lower right') | |
|
546 | self.ystep_given = 200 | |
|
547 | ax.yaxis.set_minor_locator(MultipleLocator(15)) | |
|
548 | ax.grid(which='minor') | |
|
549 | #plt.tight_layout() | |
|
550 | ||
|
551 | ||
|
552 | else: | |
|
553 | self.clear_figures() | |
|
554 | ax.errorbar(self.x, self.y, xerr=self.data.ete, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='Te') | |
|
555 | ax.errorbar(self.data.ti, self.y, fmt='k^', xerr=self.data.eti,elinewidth=1.0,color='b',linewidth=2.0, label='Ti') | |
|
556 | plt.legend(loc='lower right') | |
|
557 | ax.yaxis.set_minor_locator(MultipleLocator(15)) | |
|
558 | #plt.tight_layout() | |
|
559 | ||
|
560 | ||
|
561 | class FracsHPPlot(Plot): | |
|
562 | ''' | |
|
563 | Plot for Composition LP | |
|
564 | ''' | |
|
565 | ||
|
566 | CODE = 'fracs_LP' | |
|
567 | plot_name = 'Composition' | |
|
568 | plot_type = 'scatterbuffer' | |
|
569 | ||
|
570 | ||
|
571 | def setup(self): | |
|
572 | ||
|
573 | self.ncols = 1 | |
|
574 | self.nrows = 1 | |
|
575 | self.nplots = 1 | |
|
576 | self.ylabel = 'Range [km]' | |
|
577 | self.xlabel = 'Frac' | |
|
578 | self.width = 3.5 | |
|
579 | self.height = 6.5 | |
|
580 | self.colorbar = False | |
|
581 | if not self.titles: | |
|
582 | self.titles = self.data.parameters \ | |
|
583 | if self.data.parameters else ['{}'.format(self.CODE.upper())] | |
|
584 | ||
|
585 | def plot(self): | |
|
586 | ||
|
587 | self.x = self.data['fracs_LP'][:,-1] | |
|
588 | self.y = self.data.heights[0:self.data.NACF] | |
|
589 | ||
|
590 | self.xmin = 0 | |
|
591 | self.xmax = 1 | |
|
592 | ax = self.axes[0] | |
|
593 | ||
|
594 | if ax.firsttime: | |
|
595 | ||
|
596 | ax.errorbar(self.x, self.y[self.data.cut:], xerr=self.data.eph, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='H+') | |
|
597 | ax.errorbar(self.data.phe, self.y[self.data.cut:], fmt='k^', xerr=self.data.ephe,elinewidth=1.0,color='b',linewidth=2.0, label='He+') | |
|
598 | plt.legend(loc='lower right') | |
|
599 | self.xstep_given = 0.2 | |
|
600 | self.ystep_given = 200 | |
|
601 | ax.yaxis.set_minor_locator(MultipleLocator(15)) | |
|
602 | ax.grid(which='minor') | |
|
603 | #plt.tight_layout() | |
|
604 | ||
|
605 | ||
|
606 | else: | |
|
607 | self.clear_figures() | |
|
608 | ax.errorbar(self.x, self.y[self.data.cut:], xerr=self.data.eph, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='H+') | |
|
609 | ax.errorbar(self.data.phe, self.y[self.data.cut:], fmt='k^', xerr=self.data.ephe,elinewidth=1.0,color='b',linewidth=2.0, label='He+') | |
|
610 | plt.legend(loc='lower right') | |
|
611 | ax.yaxis.set_minor_locator(MultipleLocator(15)) | |
|
612 | #plt.tight_layout() | |
|
613 | ||
|
614 | ||
|
615 | ||
|
616 | class EDensityPlot(Plot): | |
|
617 | ''' | |
|
618 | Plot for electron density | |
|
619 | ''' | |
|
620 | ||
|
621 | CODE = 'den' | |
|
622 | plot_name = 'Electron Density' | |
|
623 | plot_type = 'scatterbuffer' | |
|
624 | ||
|
625 | ||
|
626 | def setup(self): | |
|
627 | ||
|
628 | self.ncols = 1 | |
|
629 | self.nrows = 1 | |
|
630 | self.nplots = 1 | |
|
631 | self.ylabel = 'Range [km]' | |
|
632 | self.xlabel = r'$\mathrm{N_e}$ Electron Density ($\mathrm{1/cm^3}$)' | |
|
633 | self.width = 4 | |
|
634 | self.height = 6.5 | |
|
635 | self.colorbar = False | |
|
636 | self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18}) | |
|
637 | if not self.titles: | |
|
638 | self.titles = self.data.parameters \ | |
|
639 | if self.data.parameters else ['{}'.format(self.CODE.upper())] | |
|
640 | ||
|
641 | def plot(self): | |
|
642 | ||
|
643 | ||
|
644 | self.x = self.data[self.CODE] | |
|
645 | self.y = self.data.heights | |
|
646 | self.xmin = 1000 | |
|
647 | self.xmax = 10000000 | |
|
648 | ax = self.axes[0] | |
|
649 | ||
|
650 | if ax.firsttime: | |
|
651 | self.autoxticks=False | |
|
652 | #if self.CODE=='den': | |
|
653 | ax.errorbar(self.data.dphi, self.y[:self.data.NSHTS], xerr=1, fmt='h-',elinewidth=1.0,color='g',linewidth=1.0, label='Faraday Profile',markersize=2) | |
|
654 | #ax.errorbar(self.data.dphi, self.y[:self.data.NSHTS], xerr=self.data.sdn1, fmt='h-',elinewidth=1.0,color='g',linewidth=1.0, label='Faraday Profile',markersize=2) | |
|
655 | ||
|
656 | ax.errorbar(self.x[:,-1], self.y[:self.data.NSHTS], fmt='k^-', xerr=self.data.sdp2,elinewidth=1.0,color='b',linewidth=1.0, label='Power Profile',markersize=2) | |
|
657 | #else: | |
|
658 | #ax.errorbar(self.data.dphi[:self.data.cut], self.y[:self.data.cut], xerr=1, fmt='h-',elinewidth=1.0,color='g',linewidth=1.0, label='Faraday Profile',markersize=2) | |
|
659 | #ax.errorbar(self.x[:self.data.cut,-1], self.y[:self.data.cut], fmt='k^-', xerr=self.data.sdp2[:self.data.cut],elinewidth=1.0,color='b',linewidth=1.0, label='Power Profile',markersize=2) | |
|
660 | ||
|
661 | if self.CODE=='denLP': | |
|
662 | ax.errorbar(self.data.ne[self.data.cut:], self.y[self.data.cut:], xerr=self.data.ene[self.data.cut:], fmt='r^-',elinewidth=1.0,color='r',linewidth=1.0, label='LP Profile',markersize=2) | |
|
663 | ||
|
664 | plt.legend(loc='upper right') | |
|
665 | ax.set_xscale("log", nonposx='clip') | |
|
666 | grid_y_ticks=numpy.arange(numpy.nanmin(self.y),numpy.nanmax(self.y),50) | |
|
667 | self.ystep_given=100 | |
|
668 | if self.CODE=='denLP': | |
|
669 | self.ystep_given=200 | |
|
670 | ax.set_yticks(grid_y_ticks,minor=True) | |
|
671 | ax.grid(which='minor') | |
|
672 | #plt.tight_layout() | |
|
673 | ||
|
674 | ||
|
675 | ||
|
676 | else: | |
|
677 | ||
|
678 | self.clear_figures() | |
|
679 | #if self.CODE=='den': | |
|
680 | ax.errorbar(self.data.dphi, self.y[:self.data.NSHTS], xerr=1, fmt='h-',elinewidth=1.0,color='g',linewidth=1.0, label='Faraday Profile',markersize=2) | |
|
681 | #ax.errorbar(self.data.dphi, self.y[:self.data.NSHTS], xerr=self.data.sdn1, fmt='h-',elinewidth=1.0,color='g',linewidth=1.0, label='Faraday Profile',markersize=2) | |
|
682 | ||
|
683 | ax.errorbar(self.x[:,-1], self.y[:self.data.NSHTS], fmt='k^-', xerr=self.data.sdp2,elinewidth=1.0,color='b',linewidth=1.0, label='Power Profile',markersize=2) | |
|
684 | ax.errorbar(self.x[:,-2], self.y[:self.data.NSHTS], elinewidth=1.0,color='r',linewidth=0.5,linestyle="dashed") | |
|
685 | #else: | |
|
686 | #ax.errorbar(self.data.dphi[:self.data.cut], self.y[:self.data.cut], xerr=1, fmt='h-',elinewidth=1.0,color='g',linewidth=1.0, label='Faraday Profile',markersize=2) | |
|
687 | #ax.errorbar(self.x[:self.data.cut,-1], self.y[:self.data.cut], fmt='k^-', xerr=self.data.sdp2[:self.data.cut],elinewidth=1.0,color='b',linewidth=1.0, label='Power Profile',markersize=2) | |
|
688 | #ax.errorbar(self.x[:self.data.cut,-2], self.y[:self.data.cut], elinewidth=1.0,color='r',linewidth=0.5,linestyle="dashed") | |
|
689 | ||
|
690 | if self.CODE=='denLP': | |
|
691 | ax.errorbar(self.data.ne[self.data.cut:], self.y[self.data.cut:], fmt='r^-', xerr=self.data.ene[self.data.cut:],elinewidth=1.0,color='r',linewidth=1.0, label='LP Profile',markersize=2) | |
|
692 | ||
|
693 | ax.set_xscale("log", nonposx='clip') | |
|
694 | grid_y_ticks=numpy.arange(numpy.nanmin(self.y),numpy.nanmax(self.y),50) | |
|
695 | ax.set_yticks(grid_y_ticks,minor=True) | |
|
696 | ax.grid(which='minor') | |
|
697 | plt.legend(loc='upper right') | |
|
698 | #plt.tight_layout() | |
|
699 | ||
|
700 | class FaradayAnglePlot(Plot): | |
|
701 | ''' | |
|
702 | Plot for electron density | |
|
703 | ''' | |
|
704 | ||
|
705 | CODE = 'FaradayAngle' | |
|
706 | plot_name = 'Faraday Angle' | |
|
707 | plot_type = 'scatterbuffer' | |
|
708 | ||
|
709 | ||
|
710 | def setup(self): | |
|
711 | ||
|
712 | self.ncols = 1 | |
|
713 | self.nrows = 1 | |
|
714 | self.nplots = 1 | |
|
715 | self.ylabel = 'Range [km]' | |
|
716 | self.xlabel = 'Faraday Angle (º)' | |
|
717 | self.width = 4 | |
|
718 | self.height = 6.5 | |
|
719 | self.colorbar = False | |
|
720 | if not self.titles: | |
|
721 | self.titles = self.data.parameters \ | |
|
722 | if self.data.parameters else ['{}'.format(self.CODE.upper())] | |
|
723 | ||
|
724 | def plot(self): | |
|
725 | ||
|
726 | ||
|
727 | self.x = self.data[self.CODE] | |
|
728 | self.y = self.data.heights | |
|
729 | self.xmin = -180 | |
|
730 | self.xmax = 180 | |
|
731 | ax = self.axes[0] | |
|
732 | ||
|
733 | if ax.firsttime: | |
|
734 | self.autoxticks=False | |
|
735 | #if self.CODE=='den': | |
|
736 | ax.plot(self.x, self.y,marker='o',color='g',linewidth=1.0,markersize=2) | |
|
737 | ||
|
738 | grid_y_ticks=numpy.arange(numpy.nanmin(self.y),numpy.nanmax(self.y),50) | |
|
739 | self.ystep_given=100 | |
|
740 | if self.CODE=='denLP': | |
|
741 | self.ystep_given=200 | |
|
742 | ax.set_yticks(grid_y_ticks,minor=True) | |
|
743 | ax.grid(which='minor') | |
|
744 | #plt.tight_layout() | |
|
745 | else: | |
|
746 | ||
|
747 | self.clear_figures() | |
|
748 | #if self.CODE=='den': | |
|
749 | #print(numpy.shape(self.x)) | |
|
750 | ax.plot(self.x[:,-1], self.y, marker='o',color='g',linewidth=1.0, markersize=2) | |
|
751 | ||
|
752 | grid_y_ticks=numpy.arange(numpy.nanmin(self.y),numpy.nanmax(self.y),50) | |
|
753 | ax.set_yticks(grid_y_ticks,minor=True) | |
|
754 | ax.grid(which='minor') | |
|
755 | ||
|
756 | class EDensityHPPlot(EDensityPlot): | |
|
757 | ||
|
758 | ''' | |
|
759 | Plot for Electron Density Hybrid Experiment | |
|
760 | ''' | |
|
761 | ||
|
762 | CODE = 'denLP' | |
|
763 | plot_name = 'Electron Density' | |
|
764 | plot_type = 'scatterbuffer' | |
|
765 | ||
|
766 | ||
|
767 | class ACFsPlot(Plot): | |
|
768 | ''' | |
|
769 | Plot for ACFs Double Pulse Experiment | |
|
770 | ''' | |
|
771 | ||
|
772 | CODE = 'acfs' | |
|
773 | plot_name = 'ACF' | |
|
774 | plot_type = 'scatterbuffer' | |
|
775 | ||
|
776 | ||
|
777 | def setup(self): | |
|
778 | #self.xaxis = 'time' | |
|
779 | self.ncols = 1 | |
|
780 | self.nrows = 1 | |
|
781 | self.nplots = 1 | |
|
782 | self.ylabel = 'Range [km]' | |
|
783 | self.xlabel = 'lags (ms)' | |
|
784 | self.width = 3.5 | |
|
785 | self.height = 6 | |
|
786 | self.colorbar = False | |
|
787 | self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18}) | |
|
788 | if not self.titles: | |
|
789 | self.titles = self.data.parameters \ | |
|
790 | if self.data.parameters else ['{}'.format(self.CODE.upper())] | |
|
791 | ||
|
792 | def plot(self): | |
|
793 | ||
|
794 | self.x = self.data.lags_to_plot | |
|
795 | self.y = self.data['acfs'][:,-1] | |
|
796 | ||
|
797 | ||
|
798 | self.xmin = 0.0 | |
|
799 | self.xmax = 2.0 | |
|
800 | ||
|
801 | ax = self.axes[0] | |
|
802 | ||
|
803 | if ax.firsttime: | |
|
804 | ||
|
805 | for i in range(self.data.NSHTS): | |
|
806 | x_aux = numpy.isfinite(self.x[i,:]) | |
|
807 | y_aux = numpy.isfinite(self.y[i,:]) | |
|
808 | yerr_aux = numpy.isfinite(self.data.acfs_error_to_plot[i,:]) | |
|
809 | x_igcej_aux = numpy.isfinite(self.data.x_igcej_to_plot[i,:]) | |
|
810 | y_igcej_aux = numpy.isfinite(self.data.y_igcej_to_plot[i,:]) | |
|
811 | x_ibad_aux = numpy.isfinite(self.data.x_ibad_to_plot[i,:]) | |
|
812 | y_ibad_aux = numpy.isfinite(self.data.y_ibad_to_plot[i,:]) | |
|
813 | if self.x[i,:][~numpy.isnan(self.x[i,:])].shape[0]>2: | |
|
814 | ax.errorbar(self.x[i,x_aux], self.y[i,y_aux], yerr=self.data.acfs_error_to_plot[i,x_aux],color='b',marker='o',linewidth=1.0,markersize=2) | |
|
815 | ax.plot(self.data.x_igcej_to_plot[i,x_igcej_aux],self.data.y_igcej_to_plot[i,y_igcej_aux],'x',color='red',markersize=2) | |
|
816 | ax.plot(self.data.x_ibad_to_plot[i,x_ibad_aux],self.data.y_ibad_to_plot[i,y_ibad_aux],'X',color='red',markersize=2) | |
|
817 | ||
|
818 | self.xstep_given = (self.xmax-self.xmin)/(self.data.DPL-1) | |
|
819 | self.ystep_given = 50 | |
|
820 | ax.yaxis.set_minor_locator(MultipleLocator(15)) | |
|
821 | ax.grid(which='minor') | |
|
822 | ||
|
823 | ||
|
824 | ||
|
825 | else: | |
|
826 | self.clear_figures() | |
|
827 | ||
|
828 | for i in range(self.data.NSHTS): | |
|
829 | x_aux = numpy.isfinite(self.x[i,:]) | |
|
830 | y_aux = numpy.isfinite(self.y[i,:]) | |
|
831 | yerr_aux = numpy.isfinite(self.data.acfs_error_to_plot[i,:]) | |
|
832 | x_igcej_aux = numpy.isfinite(self.data.x_igcej_to_plot[i,:]) | |
|
833 | y_igcej_aux = numpy.isfinite(self.data.y_igcej_to_plot[i,:]) | |
|
834 | x_ibad_aux = numpy.isfinite(self.data.x_ibad_to_plot[i,:]) | |
|
835 | y_ibad_aux = numpy.isfinite(self.data.y_ibad_to_plot[i,:]) | |
|
836 | if self.x[i,:][~numpy.isnan(self.x[i,:])].shape[0]>2: | |
|
837 | ax.errorbar(self.x[i,x_aux], self.y[i,y_aux], yerr=self.data.acfs_error_to_plot[i,x_aux],linewidth=1.0,markersize=2,color='b',marker='o') | |
|
838 | ax.plot(self.data.x_igcej_to_plot[i,x_igcej_aux],self.data.y_igcej_to_plot[i,y_igcej_aux],'x',color='red',markersize=2) | |
|
839 | ax.plot(self.data.x_ibad_to_plot[i,x_ibad_aux],self.data.y_ibad_to_plot[i,y_ibad_aux],'X',color='red',markersize=2) | |
|
840 | ax.yaxis.set_minor_locator(MultipleLocator(15)) | |
|
841 | ||
|
842 | ||
|
843 | ||
|
844 | ||
|
845 | class ACFsLPPlot(Plot): | |
|
846 | ''' | |
|
847 | Plot for ACFs Double Pulse Experiment | |
|
848 | ''' | |
|
849 | ||
|
850 | CODE = 'acfs_LP' | |
|
851 | plot_name = 'ACF' | |
|
852 | plot_type = 'scatterbuffer' | |
|
853 | ||
|
854 | ||
|
855 | def setup(self): | |
|
856 | #self.xaxis = 'time' | |
|
857 | self.ncols = 1 | |
|
858 | self.nrows = 1 | |
|
859 | self.nplots = 1 | |
|
860 | self.ylabel = 'Range [km]' | |
|
861 | self.xlabel = 'lags (ms)' | |
|
862 | self.width = 3.5 | |
|
863 | self.height = 7 | |
|
864 | self.colorbar = False | |
|
865 | if not self.titles: | |
|
866 | self.titles = self.data.parameters \ | |
|
867 | if self.data.parameters else ['{}'.format(self.CODE.upper())] | |
|
868 | ||
|
869 | ||
|
870 | ||
|
871 | def plot(self): | |
|
872 | ||
|
873 | self.x = self.data.lags_LP_to_plot | |
|
874 | self.y = self.data['acfs_LP'][:,-1] | |
|
875 | ||
|
876 | self.xmin = 0.0 | |
|
877 | self.xmax = 1.5 | |
|
878 | ||
|
879 | ax = self.axes[0] | |
|
880 | ||
|
881 | if ax.firsttime: | |
|
882 | ||
|
883 | for i in range(self.data.NACF): | |
|
884 | x_aux = numpy.isfinite(self.x[i,:]) | |
|
885 | y_aux = numpy.isfinite(self.y[i,:]) | |
|
886 | yerr_aux = numpy.isfinite(self.data.errors[i,:]) | |
|
887 | ||
|
888 | if self.x[i,:][~numpy.isnan(self.x[i,:])].shape[0]>2: | |
|
889 | ax.errorbar(self.x[i,x_aux], self.y[i,y_aux], yerr=self.data.errors[i,x_aux],color='b',linewidth=1.0,markersize=2,ecolor='r') | |
|
890 | ||
|
891 | #self.xstep_given = (self.xmax-self.xmin)/(self.data.NLAG-1) | |
|
892 | self.xstep_given=0.3 | |
|
893 | self.ystep_given = 200 | |
|
894 | ax.yaxis.set_minor_locator(MultipleLocator(15)) | |
|
895 | ax.grid(which='minor') | |
|
896 | ||
|
897 | else: | |
|
898 | self.clear_figures() | |
|
899 | ||
|
900 | for i in range(self.data.NACF): | |
|
901 | x_aux = numpy.isfinite(self.x[i,:]) | |
|
902 | y_aux = numpy.isfinite(self.y[i,:]) | |
|
903 | yerr_aux = numpy.isfinite(self.data.errors[i,:]) | |
|
904 | ||
|
905 | if self.x[i,:][~numpy.isnan(self.x[i,:])].shape[0]>2: | |
|
906 | ax.errorbar(self.x[i,x_aux], self.y[i,y_aux], yerr=self.data.errors[i,x_aux],color='b',linewidth=1.0,markersize=2,ecolor='r') | |
|
907 | ||
|
908 | ax.yaxis.set_minor_locator(MultipleLocator(15)) | |
|
909 | ||
|
910 | ||
|
911 | class CrossProductsPlot(Plot): | |
|
912 | ''' | |
|
913 | Plot for cross products | |
|
914 | ''' | |
|
915 | ||
|
916 | CODE = 'crossprod' | |
|
917 | plot_name = 'Cross Products' | |
|
918 | plot_type = 'scatterbuffer' | |
|
919 | ||
|
920 | ||
|
921 | def setup(self): | |
|
922 | ||
|
923 | self.ncols = 3 | |
|
924 | self.nrows = 1 | |
|
925 | self.nplots = 3 | |
|
926 | self.ylabel = 'Range [km]' | |
|
927 | ||
|
928 | self.width = 3.5*self.nplots | |
|
929 | self.height = 5.5 | |
|
930 | self.colorbar = False | |
|
931 | self.titles = [] | |
|
932 | ||
|
933 | def plot(self): | |
|
934 | ||
|
935 | self.x = self.data['crossprod'][:,-1,:,:,:,:] | |
|
936 | ||
|
937 | ||
|
938 | ||
|
939 | ||
|
940 | self.y = self.data.heights[0:self.data.NDP] | |
|
941 | ||
|
942 | ||
|
943 | ||
|
944 | for n, ax in enumerate(self.axes): | |
|
945 | ||
|
946 | self.xmin=numpy.min(numpy.concatenate((self.x[n][0,20:30,0,0],self.x[n][1,20:30,0,0],self.x[n][2,20:30,0,0],self.x[n][3,20:30,0,0]))) | |
|
947 | self.xmax=numpy.max(numpy.concatenate((self.x[n][0,20:30,0,0],self.x[n][1,20:30,0,0],self.x[n][2,20:30,0,0],self.x[n][3,20:30,0,0]))) | |
|
948 | ||
|
949 | ||
|
950 | if ax.firsttime: | |
|
951 | ||
|
952 | self.autoxticks=False | |
|
953 | if n==0: | |
|
954 | label1='kax' | |
|
955 | label2='kay' | |
|
956 | label3='kbx' | |
|
957 | label4='kby' | |
|
958 | self.xlimits=[(self.xmin,self.xmax)] | |
|
959 | elif n==1: | |
|
960 | label1='kax2' | |
|
961 | label2='kay2' | |
|
962 | label3='kbx2' | |
|
963 | label4='kby2' | |
|
964 | self.xlimits.append((self.xmin,self.xmax)) | |
|
965 | elif n==2: | |
|
966 | label1='kaxay' | |
|
967 | label2='kbxby' | |
|
968 | label3='kaxbx' | |
|
969 | label4='kaxby' | |
|
970 | self.xlimits.append((self.xmin,self.xmax)) | |
|
971 | ||
|
972 | ||
|
973 | ax.plotline1 = ax.plot(self.x[n][0,:,0,0], self.y, color='r',linewidth=2.0, label=label1) | |
|
974 | ax.plotline2 = ax.plot(self.x[n][1,:,0,0], self.y, color='k',linewidth=2.0, label=label2) | |
|
975 | ax.plotline3 = ax.plot(self.x[n][2,:,0,0], self.y, color='b',linewidth=2.0, label=label3) | |
|
976 | ax.plotline4 = ax.plot(self.x[n][3,:,0,0], self.y, color='m',linewidth=2.0, label=label4) | |
|
977 | ax.legend(loc='upper right') | |
|
978 | ax.set_xlim(self.xmin, self.xmax) | |
|
979 | self.titles.append('{}'.format(self.plot_name.upper())) | |
|
980 | #plt.tight_layout() | |
|
981 | ||
|
982 | ||
|
983 | else: | |
|
984 | ||
|
985 | if n==0: | |
|
986 | self.xlimits=[(self.xmin,self.xmax)] | |
|
987 | else: | |
|
988 | self.xlimits.append((self.xmin,self.xmax)) | |
|
989 | ||
|
990 | ax.set_xlim(self.xmin, self.xmax) | |
|
991 | ||
|
992 | ||
|
993 | ax.plotline1[0].set_data(self.x[n][0,:,0,0],self.y) | |
|
994 | ax.plotline2[0].set_data(self.x[n][1,:,0,0],self.y) | |
|
995 | ax.plotline3[0].set_data(self.x[n][2,:,0,0],self.y) | |
|
996 | ax.plotline4[0].set_data(self.x[n][3,:,0,0],self.y) | |
|
997 | self.titles.append('{}'.format(self.plot_name.upper())) | |
|
998 | #plt.tight_layout() | |
|
999 | ||
|
1000 | ||
|
1001 | ||
|
1002 | class CrossProductsLPPlot(Plot): | |
|
1003 | ''' | |
|
1004 | Plot for cross products LP | |
|
1005 | ''' | |
|
1006 | ||
|
1007 | CODE = 'crossprodlp' | |
|
1008 | plot_name = 'Cross Products LP' | |
|
1009 | plot_type = 'scatterbuffer' | |
|
1010 | ||
|
1011 | ||
|
1012 | def setup(self): | |
|
1013 | ||
|
1014 | self.ncols = 2 | |
|
1015 | self.nrows = 1 | |
|
1016 | self.nplots = 2 | |
|
1017 | self.ylabel = 'Range [km]' | |
|
1018 | self.xlabel = 'dB' | |
|
1019 | self.width = 3.5*self.nplots | |
|
1020 | self.height = 5.5 | |
|
1021 | self.colorbar = False | |
|
1022 | self.titles = [] | |
|
1023 | self.plotline_array=numpy.zeros((2,self.data.NLAG),dtype=object) | |
|
1024 | def plot(self): | |
|
1025 | ||
|
1026 | ||
|
1027 | self.x = self.data[self.CODE][:,-1,:,:] | |
|
1028 | ||
|
1029 | ||
|
1030 | self.y = self.data.heights[0:self.data.NRANGE] | |
|
1031 | ||
|
1032 | ||
|
1033 | label_array=numpy.array(['lag '+ str(x) for x in range(self.data.NLAG)]) | |
|
1034 | color_array=['r','k','g','b','c','m','y','orange','steelblue','purple','peru','darksalmon','grey','limegreen','olive','midnightblue'] | |
|
1035 | ||
|
1036 | ||
|
1037 | for n, ax in enumerate(self.axes): | |
|
1038 | ||
|
1039 | self.xmin=30 | |
|
1040 | self.xmax=70 | |
|
1041 | #print(self.x[0,12:15,n]) | |
|
1042 | #input() | |
|
1043 | #self.xmin=numpy.min(numpy.concatenate((self.x[0,:,n],self.x[1,:,n]))) | |
|
1044 | #self.xmax=numpy.max(numpy.concatenate((self.x[0,:,n],self.x[1,:,n]))) | |
|
1045 | ||
|
1046 | #print("before",self.plotline_array) | |
|
1047 | ||
|
1048 | if ax.firsttime: | |
|
1049 | ||
|
1050 | self.autoxticks=False | |
|
1051 | ||
|
1052 | ||
|
1053 | for i in range(self.data.NLAG): | |
|
1054 | #print(i) | |
|
1055 | #print(numpy.shape(self.x)) | |
|
1056 | self.plotline_array[n,i], = ax.plot(self.x[i,:,n], self.y, color=color_array[i],linewidth=1.0, label=label_array[i]) | |
|
1057 | #ax.plotline1 = ax.plot(self.x[0,:,n], self.y, color='r',linewidth=2.0, label=label_array[0]) | |
|
1058 | #ax.plotline2 = ax.plot(self.x[n][1,:,0,0], self.y, color='k',linewidth=2.0, label=label2) | |
|
1059 | #ax.plotline3 = ax.plot(self.x[n][2,:,0,0], self.y, color='b',linewidth=2.0, label=label3) | |
|
1060 | #ax.plotline4 = ax.plot(self.x[n][3,:,0,0], self.y, color='m',linewidth=2.0, label=label4) | |
|
1061 | ||
|
1062 | ||
|
1063 | #print(self.plotline_array) | |
|
1064 | ||
|
1065 | ||
|
1066 | ||
|
1067 | ax.legend(loc='upper right') | |
|
1068 | ax.set_xlim(self.xmin, self.xmax) | |
|
1069 | if n==0: | |
|
1070 | self.titles.append('{} CH0'.format(self.plot_name.upper())) | |
|
1071 | if n==1: | |
|
1072 | self.titles.append('{} CH1'.format(self.plot_name.upper())) | |
|
1073 | ||
|
1074 | #plt.tight_layout() | |
|
1075 | ||
|
1076 | else: | |
|
1077 | #print(self.plotline_array) | |
|
1078 | for i in range(self.data.NLAG): | |
|
1079 | ||
|
1080 | self.plotline_array[n,i].set_data(self.x[i,:,n],self.y) | |
|
1081 | ||
|
1082 | ||
|
1083 | ||
|
1084 | #ax.plotline1[0].set_data(self.x[n][0,:,0,0],self.y) | |
|
1085 | #ax.plotline2[0].set_data(self.x[n][1,:,0,0],self.y) | |
|
1086 | #ax.plotline3[0].set_data(self.x[n][2,:,0,0],self.y) | |
|
1087 | #ax.plotline4[0].set_data(self.x[n][3,:,0,0],self.y) | |
|
1088 | ||
|
1089 | if n==0: | |
|
1090 | self.titles.append('{} CH0'.format(self.plot_name.upper())) | |
|
1091 | if n==1: | |
|
1092 | self.titles.append('{} CH1'.format(self.plot_name.upper())) | |
|
1093 | ||
|
1094 | #plt.tight_layout() | |
|
1095 | ||
|
1096 | ||
|
1097 | class NoiseDPPlot(NoisePlot): | |
|
1098 | ''' | |
|
1099 | Plot for noise Double Pulse | |
|
1100 | ''' | |
|
1101 | ||
|
1102 | CODE = 'noisedp' | |
|
1103 | plot_name = 'Noise' | |
|
1104 | plot_type = 'scatterbuffer' | |
|
1105 | ||
|
1106 | ||
|
1107 | class XmitWaveformPlot(Plot): | |
|
1108 | ''' | |
|
1109 | Plot for xmit waveform | |
|
1110 | ''' | |
|
1111 | ||
|
1112 | CODE = 'xmit' | |
|
1113 | plot_name = 'Xmit Waveform' | |
|
1114 | plot_type = 'scatterbuffer' | |
|
1115 | ||
|
1116 | ||
|
1117 | def setup(self): | |
|
1118 | ||
|
1119 | self.ncols = 1 | |
|
1120 | self.nrows = 1 | |
|
1121 | self.nplots = 1 | |
|
1122 | self.ylabel = '' | |
|
1123 | self.xlabel = 'Number of Lag' | |
|
1124 | self.width = 5.5 | |
|
1125 | self.height = 3.5 | |
|
1126 | self.colorbar = False | |
|
1127 | if not self.titles: | |
|
1128 | self.titles = self.data.parameters \ | |
|
1129 | if self.data.parameters else ['{}'.format(self.plot_name.upper())] | |
|
1130 | ||
|
1131 | def plot(self): | |
|
1132 | ||
|
1133 | self.x = numpy.arange(0,self.data.NLAG,1,'float32') | |
|
1134 | self.y = self.data['xmit'][:,-1,:] | |
|
1135 | ||
|
1136 | self.xmin = 0 | |
|
1137 | self.xmax = self.data.NLAG-1 | |
|
1138 | self.ymin = -1.0 | |
|
1139 | self.ymax = 1.0 | |
|
1140 | ax = self.axes[0] | |
|
1141 | ||
|
1142 | if ax.firsttime: | |
|
1143 | ax.plotline0=ax.plot(self.x,self.y[0,:],color='blue') | |
|
1144 | ax.plotline1=ax.plot(self.x,self.y[1,:],color='red') | |
|
1145 | secax=ax.secondary_xaxis(location=0.5) | |
|
1146 | secax.xaxis.tick_bottom() | |
|
1147 | secax.tick_params( labelleft=False, labeltop=False, | |
|
1148 | labelright=False, labelbottom=False) | |
|
1149 | ||
|
1150 | self.xstep_given = 3 | |
|
1151 | self.ystep_given = .25 | |
|
1152 | secax.set_xticks(numpy.linspace(self.xmin, self.xmax, 6)) #only works on matplotlib.version>3.2 | |
|
1153 | ||
|
1154 | else: | |
|
1155 | ax.plotline0[0].set_data(self.x,self.y[0,:]) | |
|
1156 | ax.plotline1[0].set_data(self.x,self.y[1,:]) |
This diff has been collapsed as it changes many lines, (683 lines changed) Show them Hide them | |||
@@ -0,0 +1,683 | |||
|
1 | ''' | |
|
2 | Created on Jun 9, 2020 | |
|
3 | ||
|
4 | @author: Roberto Flores | |
|
5 | ''' | |
|
6 | ||
|
7 | import os | |
|
8 | import sys | |
|
9 | import time | |
|
10 | ||
|
11 | import struct | |
|
12 | ||
|
13 | ||
|
14 | import datetime | |
|
15 | ||
|
16 | import numpy | |
|
17 | ||
|
18 | ||
|
19 | import schainpy.admin | |
|
20 | from schainpy.model.io.jroIO_base import LOCALTIME, Reader | |
|
21 | from schainpy.model.data.jroheaderIO import BasicHeader, SystemHeader, RadarControllerHeader, ProcessingHeader | |
|
22 | from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation, MPDecorator | |
|
23 | from schainpy.model.data.jrodata import Voltage, Parameters | |
|
24 | from schainpy.utils import log | |
|
25 | ||
|
26 | ||
|
27 | class DatReader(Reader, ProcessingUnit): | |
|
28 | ||
|
29 | def __init__(self): | |
|
30 | ||
|
31 | ProcessingUnit.__init__(self) | |
|
32 | self.basicHeaderObj = BasicHeader(LOCALTIME) | |
|
33 | self.systemHeaderObj = SystemHeader() | |
|
34 | self.radarControllerHeaderObj = RadarControllerHeader() | |
|
35 | self.processingHeaderObj = ProcessingHeader() | |
|
36 | self.dataOut = Parameters() | |
|
37 | #print(self.basicHeaderObj.timezone) | |
|
38 | #self.counter_block=0 | |
|
39 | self.format='dat' | |
|
40 | self.flagNoMoreFiles = 0 | |
|
41 | self.filename = None | |
|
42 | self.intervals = set() | |
|
43 | #self.datatime = datetime.datetime(1900,1,1) | |
|
44 | ||
|
45 | self.filefmt = "***%Y%m%d*******" | |
|
46 | ||
|
47 | self.padding=numpy.zeros(1,'int32') | |
|
48 | self.hsize=numpy.zeros(1,'int32') | |
|
49 | self.bufsize=numpy.zeros(1,'int32') | |
|
50 | self.nr=numpy.zeros(1,'int32') | |
|
51 | self.ngates=numpy.zeros(1,'int32') ### ### ### 2 | |
|
52 | self.time1=numpy.zeros(1,'uint64') # pos 3 | |
|
53 | self.time2=numpy.zeros(1,'uint64') # pos 4 | |
|
54 | self.lcounter=numpy.zeros(1,'int32') | |
|
55 | self.groups=numpy.zeros(1,'int32') | |
|
56 | self.system=numpy.zeros(4,'int8') # pos 7 | |
|
57 | self.h0=numpy.zeros(1,'float32') | |
|
58 | self.dh=numpy.zeros(1,'float32') | |
|
59 | self.ipp=numpy.zeros(1,'float32') | |
|
60 | self.process=numpy.zeros(1,'int32') | |
|
61 | self.tx=numpy.zeros(1,'int32') | |
|
62 | ||
|
63 | self.ngates1=numpy.zeros(1,'int32') ### ### ### 13 | |
|
64 | self.time0=numpy.zeros(1,'uint64') # pos 14 | |
|
65 | self.nlags=numpy.zeros(1,'int32') | |
|
66 | self.nlags1=numpy.zeros(1,'int32') | |
|
67 | self.txb=numpy.zeros(1,'float32') ### ### ### 17 | |
|
68 | self.time3=numpy.zeros(1,'uint64') # pos 18 | |
|
69 | self.time4=numpy.zeros(1,'uint64') # pos 19 | |
|
70 | self.h0_=numpy.zeros(1,'float32') | |
|
71 | self.dh_=numpy.zeros(1,'float32') | |
|
72 | self.ipp_=numpy.zeros(1,'float32') | |
|
73 | self.txa_=numpy.zeros(1,'float32') | |
|
74 | ||
|
75 | self.pad=numpy.zeros(100,'int32') | |
|
76 | ||
|
77 | self.nbytes=numpy.zeros(1,'int32') | |
|
78 | self.limits=numpy.zeros(1,'int32') | |
|
79 | self.ngroups=numpy.zeros(1,'int32') ### ### ### 27 | |
|
80 | #Make the header list | |
|
81 | #header=[hsize,bufsize,nr,ngates,time1,time2,lcounter,groups,system,h0,dh,ipp,process,tx,padding,ngates1,time0,nlags,nlags1,padding,txb,time3,time4,h0_,dh_,ipp_,txa_,pad,nbytes,limits,padding,ngroups] | |
|
82 | self.header=[self.hsize,self.bufsize,self.nr,self.ngates,self.time1,self.time2,self.lcounter,self.groups,self.system,self.h0,self.dh,self.ipp,self.process,self.tx,self.ngates1,self.padding,self.time0,self.nlags,self.nlags1,self.padding,self.txb,self.time3,self.time4,self.h0_,self.dh_,self.ipp_,self.txa_,self.pad,self.nbytes,self.limits,self.padding,self.ngroups] | |
|
83 | ||
|
84 | ||
|
85 | ||
|
86 | def setup(self, **kwargs): | |
|
87 | ||
|
88 | self.set_kwargs(**kwargs) | |
|
89 | ||
|
90 | ||
|
91 | if self.path is None: | |
|
92 | raise ValueError('The path is not valid') | |
|
93 | ||
|
94 | self.open_file = open | |
|
95 | self.open_mode = 'rb' | |
|
96 | ||
|
97 | ||
|
98 | ||
|
99 | if self.format is None: | |
|
100 | raise ValueError('The format is not valid') | |
|
101 | elif self.format.lower() in ('dat'): | |
|
102 | self.ext = '.dat' | |
|
103 | elif self.format.lower() in ('out'): | |
|
104 | self.ext = '.out' | |
|
105 | ||
|
106 | ||
|
107 | log.log("Searching files in {}".format(self.path), self.name) | |
|
108 | self.filenameList = self.searchFilesOffLine(self.path, self.startDate, | |
|
109 | self.endDate, self.expLabel, self.ext, self.walk, self.filefmt, self.folderfmt) | |
|
110 | #print(self.path) | |
|
111 | #print(self.filenameList) | |
|
112 | #input() | |
|
113 | ||
|
114 | ||
|
115 | self.setNextFile() | |
|
116 | ||
|
117 | def readFirstHeader(self): | |
|
118 | '''Read header and data''' | |
|
119 | ||
|
120 | #self.flag_same_file=1 | |
|
121 | self.counter_block=0 | |
|
122 | self.parseHeader() | |
|
123 | self.parseData() | |
|
124 | self.blockIndex = 0 | |
|
125 | ||
|
126 | return | |
|
127 | ||
|
128 | def parseHeader(self): | |
|
129 | ''' | |
|
130 | ''' | |
|
131 | ||
|
132 | for i in range(len(self.header)): | |
|
133 | for j in range(len(self.header[i])): | |
|
134 | #print("len(header[i]) ",len(header[i])) | |
|
135 | #input() | |
|
136 | temp=self.fp.read(int(self.header[i].itemsize)) | |
|
137 | if isinstance(self.header[i][0], numpy.int32): | |
|
138 | #print(struct.unpack('i', temp)[0]) | |
|
139 | self.header[i][0]=struct.unpack('i', temp)[0] | |
|
140 | if isinstance(self.header[i][0], numpy.uint64): | |
|
141 | self.header[i][0]=struct.unpack('q', temp)[0] | |
|
142 | if isinstance(self.header[i][0], numpy.int8): | |
|
143 | self.header[i][0]=struct.unpack('B', temp)[0] | |
|
144 | if isinstance(self.header[i][0], numpy.float32): | |
|
145 | self.header[i][0]=struct.unpack('f', temp)[0] | |
|
146 | ||
|
147 | self.fp.seek(0,0) | |
|
148 | if int(self.header[1][0])==int(81864): | |
|
149 | self.experiment='DP' | |
|
150 | ||
|
151 | elif int(self.header[1][0])==int(185504): | |
|
152 | self.experiment='HP' | |
|
153 | ||
|
154 | ||
|
155 | self.total_blocks=os.stat(self.filename).st_size//self.header[1][0] | |
|
156 | ||
|
157 | ||
|
158 | def parseData(self): | |
|
159 | ''' | |
|
160 | ''' | |
|
161 | if self.experiment=='DP': | |
|
162 | self.header[15][0]=66 | |
|
163 | self.header[18][0]=16 | |
|
164 | self.header[17][0]=11 | |
|
165 | self.header[2][0]=2 | |
|
166 | ||
|
167 | ||
|
168 | self.noise=numpy.zeros(self.header[2][0],'float32') #self.header[2][0] | |
|
169 | #tmpx=numpy.zeros((self.header[15][0],self.header[17][0],2),'float32') | |
|
170 | self.kax=numpy.zeros((self.header[15][0],self.header[17][0],2),'float32') | |
|
171 | self.kay=numpy.zeros((self.header[15][0],self.header[17][0],2),'float32') | |
|
172 | self.kbx=numpy.zeros((self.header[15][0],self.header[17][0],2),'float32') | |
|
173 | self.kby=numpy.zeros((self.header[15][0],self.header[17][0],2),'float32') | |
|
174 | self.kax2=numpy.zeros((self.header[15][0],self.header[17][0],2),'float32') | |
|
175 | self.kay2=numpy.zeros((self.header[15][0],self.header[17][0],2),'float32') | |
|
176 | self.kbx2=numpy.zeros((self.header[15][0],self.header[17][0],2),'float32') | |
|
177 | self.kby2=numpy.zeros((self.header[15][0],self.header[17][0],2),'float32') | |
|
178 | self.kaxbx=numpy.zeros((self.header[15][0],self.header[17][0],2),'float32') | |
|
179 | self.kaxby=numpy.zeros((self.header[15][0],self.header[17][0],2),'float32') | |
|
180 | self.kaybx=numpy.zeros((self.header[15][0],self.header[17][0],2),'float32') | |
|
181 | self.kayby=numpy.zeros((self.header[15][0],self.header[17][0],2),'float32') | |
|
182 | self.kaxay=numpy.zeros((self.header[15][0],self.header[17][0],2),'float32') | |
|
183 | self.kbxby=numpy.zeros((self.header[15][0],self.header[17][0],2),'float32') | |
|
184 | self.output_LP_real=numpy.zeros((self.header[18][0],200,self.header[2][0]),'float32') | |
|
185 | self.output_LP_imag=numpy.zeros((self.header[18][0],200,self.header[2][0]),'float32') | |
|
186 | self.final_cross_products=[self.kax,self.kay,self.kbx,self.kby,self.kax2,self.kay2,self.kbx2,self.kby2,self.kaxbx,self.kaxby,self.kaybx,self.kayby,self.kaxay,self.kbxby] | |
|
187 | #self.final_cross_products=[tmpx,tmpx,tmpx,tmpx,tmpx,tmpx,tmpx,tmpx,tmpx,tmpx,tmpx,tmpx,tmpx,tmpx] | |
|
188 | ||
|
189 | #print("pos: ",self.fp.tell()) | |
|
190 | ||
|
191 | ||
|
192 | def readNextBlock(self): | |
|
193 | ||
|
194 | while True: | |
|
195 | self.flagDiscontinuousBlock = 0 | |
|
196 | #print(os.stat(self.filename).st_size) | |
|
197 | #print(os.stat(self.filename).st_size//self.header[1][0]) | |
|
198 | #os.stat(self.fp) | |
|
199 | if self.counter_block == self.total_blocks: | |
|
200 | ||
|
201 | self.setNextFile() | |
|
202 | ||
|
203 | self.readBlock() | |
|
204 | #self.counter_block+=1 | |
|
205 | ||
|
206 | if (self.datatime < datetime.datetime.combine(self.startDate, self.startTime)) or \ | |
|
207 | (self.datatime > datetime.datetime.combine(self.endDate, self.endTime)): | |
|
208 | ||
|
209 | #print(self.datatime) | |
|
210 | #print(datetime.datetime.combine(self.startDate, self.startTime)) | |
|
211 | #print(datetime.datetime.combine(self.endDate, self.endTime)) | |
|
212 | #print("warning") | |
|
213 | log.warning( | |
|
214 | 'Reading Block No. {}/{} -> {} [Skipping]'.format( | |
|
215 | self.counter_block, | |
|
216 | self.total_blocks, | |
|
217 | self.datatime.ctime()), | |
|
218 | 'DATReader') | |
|
219 | continue | |
|
220 | break | |
|
221 | ||
|
222 | log.log( | |
|
223 | 'Reading Block No. {}/{} -> {}'.format( | |
|
224 | self.counter_block, | |
|
225 | self.total_blocks, | |
|
226 | self.datatime.ctime()), | |
|
227 | 'DATReader') | |
|
228 | ||
|
229 | return 1 | |
|
230 | ||
|
231 | def readBlock(self): | |
|
232 | ''' | |
|
233 | ''' | |
|
234 | ||
|
235 | self.npos=self.counter_block*self.header[1][0] | |
|
236 | #print(self.counter_block) | |
|
237 | self.fp.seek(self.npos, 0) | |
|
238 | self.counter_block+=1 | |
|
239 | #print("fpos1: ",self.fp.tell()) | |
|
240 | ||
|
241 | self.read_header() | |
|
242 | ||
|
243 | #put by hand because old files didn't save it in the header | |
|
244 | if self.experiment=='DP': | |
|
245 | self.header[15][0]=66 | |
|
246 | self.header[18][0]=16 | |
|
247 | self.header[17][0]=11 | |
|
248 | self.header[2][0]=2 | |
|
249 | ######################################### | |
|
250 | ||
|
251 | if self.experiment=="HP": | |
|
252 | self.long_pulse_products() | |
|
253 | ||
|
254 | self.read_cross_products() | |
|
255 | ||
|
256 | ||
|
257 | self.read_noise() | |
|
258 | ||
|
259 | ||
|
260 | return | |
|
261 | ||
|
262 | ||
|
263 | ||
|
264 | def read_header(self): | |
|
265 | ||
|
266 | ||
|
267 | for i in range(len(self.header)): | |
|
268 | for j in range(len(self.header[i])): | |
|
269 | #print("len(header[i]) ",len(header[i])) | |
|
270 | #input() | |
|
271 | temp=self.fp.read(int(self.header[i].itemsize)) | |
|
272 | #if(b''==temp): | |
|
273 | # self.setNextFile() | |
|
274 | # self.flag_same_file=0 | |
|
275 | if isinstance(self.header[i][0], numpy.int32): | |
|
276 | #print(struct.unpack('i', temp)[0]) | |
|
277 | self.header[i][0]=struct.unpack('i', temp)[0] | |
|
278 | if isinstance(self.header[i][0], numpy.uint64): | |
|
279 | self.header[i][0]=struct.unpack('q', temp)[0] | |
|
280 | if isinstance(self.header[i][0], numpy.int8): | |
|
281 | self.header[i][0]=struct.unpack('B', temp)[0] | |
|
282 | if isinstance(self.header[i][0], numpy.float32): | |
|
283 | self.header[i][0]=struct.unpack('f', temp)[0] | |
|
284 | #else: | |
|
285 | # continue | |
|
286 | #self.fp.seek(self.npos_aux, 0) | |
|
287 | # break | |
|
288 | ||
|
289 | #print("fpos2: ",self.fp.tell()) | |
|
290 | #log.success('Parameters found: {}'.format(self.parameters), | |
|
291 | # 'DATReader') | |
|
292 | #print("Success") | |
|
293 | #self.TimeBlockSeconds_for_dp_power = self.header[4][0]#-((self.dataOut.nint-1)*self.dataOut.NAVG*2) | |
|
294 | #print(dataOut.TimeBlockSeconds_for_dp_power) | |
|
295 | ||
|
296 | #self.datatime=datetime.datetime.fromtimestamp(self.header[4][0]).strftime("%Y-%m-%d %H:%M:%S") | |
|
297 | #print(self.header[4][0]) | |
|
298 | self.datatime=datetime.datetime.fromtimestamp(self.header[4][0]) | |
|
299 | #print(self.header[1][0]) | |
|
300 | ||
|
301 | def long_pulse_products(self): | |
|
302 | temp=self.fp.read(self.header[18][0]*self.header[2][0]*200*8) | |
|
303 | ii=0 | |
|
304 | ||
|
305 | for l in range(self.header[18][0]): #lag | |
|
306 | for r in range(self.header[2][0]): # channels | |
|
307 | for k in range(200): #RANGE## generalizar | |
|
308 | self.output_LP_real[l,k,r]=struct.unpack('f', temp[ii:ii+4])[0] | |
|
309 | ii=ii+4 | |
|
310 | self.output_LP_imag[l,k,r]=struct.unpack('f', temp[ii:ii+4])[0] | |
|
311 | ii=ii+4 | |
|
312 | ||
|
313 | #print(self.output_LP_real[1,1,1]) | |
|
314 | #print(self.output_LP_imag[1,1,1]) | |
|
315 | def read_cross_products(self): | |
|
316 | ||
|
317 | for ind in range(len(self.final_cross_products)): #final cross products | |
|
318 | temp=self.fp.read(self.header[17][0]*2*self.header[15][0]*4) #*4 bytes | |
|
319 | #if(b''==temp): | |
|
320 | # self.setNextFile() | |
|
321 | # self.flag_same_file=0 | |
|
322 | ii=0 | |
|
323 | #print("kabxys.shape ",kabxys.shape) | |
|
324 | #print(kabxys) | |
|
325 | #print("fpos3: ",self.fp.tell()) | |
|
326 | for l in range(self.header[17][0]): #lag | |
|
327 | #print("fpos3: ",self.fp.tell()) | |
|
328 | for fl in range(2): # unflip and flip | |
|
329 | for k in range(self.header[15][0]): #RANGE | |
|
330 | #print("fpos3: ",self.fp.tell()) | |
|
331 | self.final_cross_products[ind][k,l,fl]=struct.unpack('f', temp[ii:ii+4])[0] | |
|
332 | ii=ii+4 | |
|
333 | #print("fpos2: ",self.fp.tell()) | |
|
334 | ||
|
335 | ||
|
336 | ||
|
337 | def read_noise(self): | |
|
338 | ||
|
339 | temp=self.fp.read(self.header[2][0]*4) #*4 bytes self.header[2][0] | |
|
340 | for ii in range(self.header[2][0]): #self.header[2][0] | |
|
341 | self.noise[ii]=struct.unpack('f', temp[ii*4:(ii+1)*4])[0] | |
|
342 | ||
|
343 | #print("fpos5: ",self.fp.tell()) | |
|
344 | ||
|
345 | ||
|
346 | ||
|
347 | def set_output(self): | |
|
348 | ''' | |
|
349 | Storing data from buffer to dataOut object | |
|
350 | ''' | |
|
351 | #print("fpos2: ",self.fp.tell()) | |
|
352 | ##self.dataOut.header = self.header | |
|
353 | #this is put by hand because it isn't saved in the header | |
|
354 | if self.experiment=='DP': | |
|
355 | self.dataOut.NRANGE=0 | |
|
356 | self.dataOut.NSCAN=132 | |
|
357 | self.dataOut.heightList=self.header[10][0]*(numpy.arange(self.header[15][0])) | |
|
358 | elif self.experiment=='HP': | |
|
359 | self.dataOut.output_LP=self.output_LP_real+1.j*self.output_LP_imag | |
|
360 | self.dataOut.NRANGE=200 | |
|
361 | self.dataOut.NSCAN=128 | |
|
362 | self.dataOut.heightList=self.header[10][0]*(numpy.arange(90)) #NEEEDS TO BE GENERALIZED | |
|
363 | ######################################### | |
|
364 | #print(self.dataOut.output_LP[1,1,1]) | |
|
365 | self.dataOut.MAXNRANGENDT=self.header[3][0] | |
|
366 | self.dataOut.NDP=self.header[15][0] | |
|
367 | self.dataOut.DPL=self.header[17][0] | |
|
368 | self.dataOut.DH=self.header[10][0] | |
|
369 | self.dataOut.NAVG=self.header[7][0] | |
|
370 | self.dataOut.H0=self.header[9][0] | |
|
371 | self.dataOut.NR=self.header[2][0] | |
|
372 | self.dataOut.NLAG=self.header[18][0] | |
|
373 | #self.dataOut.tmpx=self.tmpx | |
|
374 | #self.dataOut.timeZone = 5 | |
|
375 | #self.dataOut.final_cross_products=self.final_cross_products | |
|
376 | self.dataOut.kax=self.kax | |
|
377 | #print(self.dataOut.kax[1,1,1]) | |
|
378 | self.dataOut.kay=self.kay | |
|
379 | self.dataOut.kbx=self.kbx | |
|
380 | self.dataOut.kby=self.kby | |
|
381 | self.dataOut.kax2=self.kax2 | |
|
382 | self.dataOut.kay2=self.kay2 | |
|
383 | self.dataOut.kbx2=self.kbx2 | |
|
384 | self.dataOut.kby2=self.kby2 | |
|
385 | self.dataOut.kaxbx=self.kaxbx | |
|
386 | self.dataOut.kaxby=self.kaxby | |
|
387 | self.dataOut.kaybx=self.kaybx | |
|
388 | self.dataOut.kayby=self.kayby | |
|
389 | self.dataOut.kaxay=self.kaxay | |
|
390 | self.dataOut.kbxby=self.kbxby | |
|
391 | self.dataOut.noise_final=self.noise | |
|
392 | #print("NOISE",self.noise) | |
|
393 | ||
|
394 | ||
|
395 | self.dataOut.useLocalTime=True | |
|
396 | ||
|
397 | #self.dataOut.experiment=self.experiment | |
|
398 | #print(self.datatime) | |
|
399 | #print(self.dataOut.datatime) | |
|
400 | ||
|
401 | ||
|
402 | #self.dataOut.utctime = (self.datatime - datetime.datetime(1970, 1, 1)).total_seconds() | |
|
403 | #self.dataOut.utctimeInit = self.dataOut.utctime | |
|
404 | ||
|
405 | ||
|
406 | ||
|
407 | self.dataOut.lt=self.datatime.hour | |
|
408 | ||
|
409 | ||
|
410 | #print(RadarControllerHeader().ippSeconds) | |
|
411 | #print(RadarControllerHeader().ipp) | |
|
412 | #self.dataOut.utctime=time.gmtime(self.header[4][0])- datetime.datetime(1970, 1, 1) | |
|
413 | #self.dataOut.utctime=self.dataOut.utctime.total_seconds() | |
|
414 | #time1 = self.header[4][0] # header.time1 | |
|
415 | #print("time1: ",time1) | |
|
416 | #print(self.header[4][0]) | |
|
417 | #date = time.ctime(time1) | |
|
418 | #print("DADSADA",time.strptime(date)) | |
|
419 | #print("date_before: ",date) | |
|
420 | #bd_time=time.gmtime(time1) | |
|
421 | #print(time.mktime(bd_time)) | |
|
422 | #self.dataOut.utctime=time.mktime(bd_time) | |
|
423 | self.dataOut.utctime = self.header[4][0] | |
|
424 | #self.dataOut.datatime=a | |
|
425 | #print(datetime.datetime.utcfromtimestamp(self.dataOut.utctime)) | |
|
426 | #self.dataOut.TimeBlockDate=self.datatime.ctime() | |
|
427 | self.dataOut.TimeBlockSeconds=time.mktime(time.strptime(self.dataOut.datatime.ctime())) | |
|
428 | ||
|
429 | #self.dataOut.heightList = self.ranges | |
|
430 | #self.dataOut.utctime = (self.datatime - datetime.datetime(1970, 1, 1)).total_seconds() | |
|
431 | #self.dataOut.utctimeInit = self.dataOut.utctime | |
|
432 | #self.dataOut.paramInterval = min(self.intervals) | |
|
433 | #self.dataOut.useLocalTime = False | |
|
434 | self.dataOut.flagNoData = False | |
|
435 | self.dataOut.flagDiscontinuousBlock = self.flagDiscontinuousBlock | |
|
436 | #print(self.dataOut.channelIndexList) | |
|
437 | self.dataOut.channelList=list(range(0,self.header[2][0])) | |
|
438 | #print(self.dataOut.channelList) | |
|
439 | #print(self.datatime) | |
|
440 | #print(self.dataOut.final_cross_products[0]) | |
|
441 | ||
|
442 | ||
|
443 | #self.dataOut.heightList=self.header[10][0]*(numpy.arange(self.header[15][0])) | |
|
444 | ||
|
445 | #print(numpy.shape(self.dataOut.heightList)) | |
|
446 | ||
|
447 | ||
|
448 | def getData(self): | |
|
449 | ''' | |
|
450 | Storing data from databuffer to dataOut object | |
|
451 | ''' | |
|
452 | ||
|
453 | if not self.readNextBlock(): | |
|
454 | self.dataOut.flagNoData = True | |
|
455 | return 0 | |
|
456 | ||
|
457 | self.set_output() | |
|
458 | ||
|
459 | return 1 | |
|
460 | ||
|
461 | def run(self, **kwargs): | |
|
462 | ||
|
463 | if not(self.isConfig): | |
|
464 | self.setup(**kwargs) | |
|
465 | self.isConfig = True | |
|
466 | #print("fpos1: ",self.fp.tell()) | |
|
467 | self.getData() | |
|
468 | ||
|
469 | return | |
|
470 | ||
|
471 | @MPDecorator | |
|
472 | class DatWriter(Operation): | |
|
473 | ||
|
474 | ||
|
475 | def __init__(self): | |
|
476 | ||
|
477 | Operation.__init__(self) | |
|
478 | #self.dataOut = Voltage() | |
|
479 | self.counter = 0 | |
|
480 | self.path = None | |
|
481 | self.fp = None | |
|
482 | return | |
|
483 | #self.ext= '.dat' | |
|
484 | ||
|
485 | def run(self, dataOut, path, format='dat', experiment=None, **kwargs): | |
|
486 | print(dataOut.flagNoData) | |
|
487 | print(dataOut.datatime.ctime()) | |
|
488 | print(dataOut.TimeBlockDate) | |
|
489 | input() | |
|
490 | #if dataOut.flag_save: | |
|
491 | self.experiment=experiment | |
|
492 | self.path=path | |
|
493 | if self.experiment=='DP': | |
|
494 | dataOut.header[1][0]=81864 | |
|
495 | elif self.experiment=='HP': | |
|
496 | dataOut.header[1][0]=185504#173216 | |
|
497 | #dataOut.header[1][0]=bufsize | |
|
498 | self.dataOut = dataOut | |
|
499 | #print(self.dataOut.nint) | |
|
500 | #self.bufsize=bufsize | |
|
501 | if format == 'dat': | |
|
502 | self.ext = '.dat' | |
|
503 | if format == 'out': | |
|
504 | self.ext = '.out' | |
|
505 | self.putData() | |
|
506 | ||
|
507 | return | |
|
508 | ||
|
509 | ||
|
510 | ||
|
511 | def setFile(self): | |
|
512 | ''' | |
|
513 | Create new out file object | |
|
514 | ''' | |
|
515 | ||
|
516 | #self.dataOut.TimeBlockSeconds=time.mktime(time.strptime(self.dataOut.TimeBlockDate)) | |
|
517 | date = datetime.datetime.fromtimestamp(self.dataOut.TimeBlockSeconds) | |
|
518 | ||
|
519 | #print("date",date) | |
|
520 | ||
|
521 | filename = '{}{}{}'.format('jro', | |
|
522 | date.strftime('%Y%m%d_%H%M%S'), | |
|
523 | self.ext) | |
|
524 | #print(filename) | |
|
525 | #print(self.path) | |
|
526 | ||
|
527 | self.fullname = os.path.join(self.path, filename) | |
|
528 | ||
|
529 | if os.path.isfile(self.fullname) : | |
|
530 | log.warning( | |
|
531 | 'Destination file {} already exists, previous file deleted.'.format( | |
|
532 | self.fullname), | |
|
533 | 'DatWriter') | |
|
534 | os.remove(self.fullname) | |
|
535 | ||
|
536 | try: | |
|
537 | log.success( | |
|
538 | 'Creating file: {}'.format(self.fullname), | |
|
539 | 'DatWriter') | |
|
540 | if not os.path.exists(self.path): | |
|
541 | os.makedirs(self.path) | |
|
542 | #self.fp = madrigal.cedar.MadrigalCedarFile(self.fullname, True) | |
|
543 | self.fp = open(self.fullname,'wb') | |
|
544 | ||
|
545 | except ValueError as e: | |
|
546 | log.error( | |
|
547 | 'Impossible to create *.out file', | |
|
548 | 'DatWriter') | |
|
549 | return | |
|
550 | ||
|
551 | return 1 | |
|
552 | ||
|
553 | def writeBlock(self): | |
|
554 | ||
|
555 | #self.dataOut.paramInterval=2 | |
|
556 | #startTime = datetime.datetime.utcfromtimestamp(self.dataOut.utctime) | |
|
557 | #print(startTime) | |
|
558 | #endTime = startTime + datetime.timedelta(seconds=self.dataOut.paramInterval) | |
|
559 | ||
|
560 | self.dataOut.header[0].astype('int32').tofile(self.fp) | |
|
561 | self.dataOut.header[1].astype('int32').tofile(self.fp) | |
|
562 | self.dataOut.header[2].astype('int32').tofile(self.fp) | |
|
563 | self.dataOut.header[3].astype('int32').tofile(self.fp) | |
|
564 | self.dataOut.header[4].astype('uint64').tofile(self.fp) | |
|
565 | self.dataOut.header[5].astype('uint64').tofile(self.fp) | |
|
566 | self.dataOut.header[6].astype('int32').tofile(self.fp) | |
|
567 | self.dataOut.header[7].astype('int32').tofile(self.fp) | |
|
568 | #print(dataOut.header[7]) | |
|
569 | self.dataOut.header[8].astype('int8').tofile(self.fp) | |
|
570 | self.dataOut.header[9].astype('float32').tofile(self.fp) | |
|
571 | self.dataOut.header[10].astype('float32').tofile(self.fp) | |
|
572 | self.dataOut.header[11].astype('float32').tofile(self.fp) | |
|
573 | self.dataOut.header[12].astype('int32').tofile(self.fp) | |
|
574 | self.dataOut.header[13].astype('int32').tofile(self.fp) | |
|
575 | self.dataOut.header[14].astype('int32').tofile(self.fp) | |
|
576 | self.dataOut.header[15].astype('int32').tofile(self.fp) | |
|
577 | self.dataOut.header[16].astype('uint64').tofile(self.fp) | |
|
578 | self.dataOut.header[17].astype('int32').tofile(self.fp) | |
|
579 | self.dataOut.header[18].astype('int32').tofile(self.fp) | |
|
580 | self.dataOut.header[19].astype('int32').tofile(self.fp) | |
|
581 | self.dataOut.header[20].astype('float32').tofile(self.fp) | |
|
582 | self.dataOut.header[21].astype('uint64').tofile(self.fp) | |
|
583 | self.dataOut.header[22].astype('uint64').tofile(self.fp) | |
|
584 | self.dataOut.header[23].astype('float32').tofile(self.fp) | |
|
585 | self.dataOut.header[24].astype('float32').tofile(self.fp) | |
|
586 | self.dataOut.header[25].astype('float32').tofile(self.fp) | |
|
587 | self.dataOut.header[26].astype('float32').tofile(self.fp) | |
|
588 | self.dataOut.header[27].astype('int32').tofile(self.fp) | |
|
589 | self.dataOut.header[28].astype('int32').tofile(self.fp) | |
|
590 | self.dataOut.header[29].astype('int32').tofile(self.fp) | |
|
591 | self.dataOut.header[30].astype('int32').tofile(self.fp) | |
|
592 | self.dataOut.header[31].astype('int32').tofile(self.fp) | |
|
593 | #print("tell before 1 ",self.fp.tell()) | |
|
594 | #input() | |
|
595 | ||
|
596 | if self.experiment=="HP": | |
|
597 | #print("INSIDE") | |
|
598 | #tmp=numpy.zeros(1,dtype='complex64') | |
|
599 | #print("tmp ",tmp) | |
|
600 | #input() | |
|
601 | #print(dataOut.NLAG) | |
|
602 | #print(dataOut.NR) | |
|
603 | #print(dataOut.NRANGE) | |
|
604 | for l in range(self.dataOut.NLAG): #lag | |
|
605 | for r in range(self.dataOut.NR): # unflip and flip | |
|
606 | for k in range(self.dataOut.NRANGE): #RANGE | |
|
607 | self.dataOut.output_LP.real[l,k,r].astype('float32').tofile(self.fp) | |
|
608 | self.dataOut.output_LP.imag[l,k,r].astype('float32').tofile(self.fp) | |
|
609 | ||
|
610 | ||
|
611 | #print("tell before 2 ",self.outputfile.tell()) | |
|
612 | ||
|
613 | ||
|
614 | ||
|
615 | ||
|
616 | ||
|
617 | #print(self.dataOut.output_LP[1,1,1]) | |
|
618 | ||
|
619 | #print(self.dataOut.kax) | |
|
620 | final_cross_products=[self.dataOut.kax,self.dataOut.kay,self.dataOut.kbx,self.dataOut.kby, | |
|
621 | self.dataOut.kax2,self.dataOut.kay2,self.dataOut.kbx2,self.dataOut.kby2, | |
|
622 | self.dataOut.kaxbx,self.dataOut.kaxby,self.dataOut.kaybx,self.dataOut.kayby, | |
|
623 | self.dataOut.kaxay,self.dataOut.kbxby] | |
|
624 | ||
|
625 | #print(self.dataOut.kax) | |
|
626 | #print("tell before crossp saving ",self.outputfile.tell()) | |
|
627 | for kabxys in final_cross_products: | |
|
628 | ||
|
629 | for l in range(self.dataOut.DPL): #lag | |
|
630 | for fl in range(2): # unflip and flip | |
|
631 | for k in range(self.dataOut.NDT): #RANGE | |
|
632 | kabxys[k,l,fl].astype('float32').tofile(self.fp) | |
|
633 | ||
|
634 | ||
|
635 | #print("tell before noise saving ",self.outputfile.tell()) | |
|
636 | ||
|
637 | ||
|
638 | for nch in range(self.dataOut.NR): | |
|
639 | self.dataOut.noise_final[nch].astype('float32').tofile(self.fp) | |
|
640 | ||
|
641 | #print("tell before noise saving ",self.fp.tell()) | |
|
642 | #input() | |
|
643 | ||
|
644 | ||
|
645 | ||
|
646 | ||
|
647 | log.log( | |
|
648 | 'Writing {} blocks'.format( | |
|
649 | self.counter+1), | |
|
650 | 'DatWriter') | |
|
651 | ||
|
652 | ||
|
653 | ||
|
654 | ||
|
655 | ||
|
656 | ||
|
657 | def putData(self): | |
|
658 | #print("flagNoData",self.dataOut.flagNoData) | |
|
659 | #print("flagDiscontinuousBlock",self.dataOut.flagDiscontinuousBlock) | |
|
660 | #print(self.dataOut.flagNoData) | |
|
661 | ||
|
662 | if self.dataOut.flagNoData: | |
|
663 | return 0 | |
|
664 | ||
|
665 | if self.dataOut.flagDiscontinuousBlock: | |
|
666 | ||
|
667 | self.counter = 0 | |
|
668 | ||
|
669 | if self.counter == 0: | |
|
670 | self.setFile() | |
|
671 | #if self.experiment=="HP": | |
|
672 | #if self.dataOut.debris_activated==0: | |
|
673 | #self.writeBlock() | |
|
674 | #self.counter += 1 | |
|
675 | #else: | |
|
676 | self.writeBlock() | |
|
677 | self.counter += 1 | |
|
678 | ||
|
679 | def close(self): | |
|
680 | ||
|
681 | if self.counter > 0: | |
|
682 | self.fp.close() | |
|
683 | log.success('Closing file {}'.format(self.fullname), 'DatWriter') |
This diff has been collapsed as it changes many lines, (2561 lines changed) Show them Hide them | |||
@@ -0,0 +1,2561 | |||
|
1 | ||
|
2 | import matplotlib.pyplot as plt | |
|
3 | ||
|
4 | ||
|
5 | ||
|
6 | import numpy | |
|
7 | import time | |
|
8 | import math | |
|
9 | ||
|
10 | from datetime import datetime | |
|
11 | ||
|
12 | from schainpy.utils import log | |
|
13 | ||
|
14 | import struct | |
|
15 | import os | |
|
16 | ||
|
17 | import sys | |
|
18 | ||
|
19 | from ctypes import * | |
|
20 | ||
|
21 | from schainpy.model.io.jroIO_voltage import VoltageReader,JRODataReader | |
|
22 | from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation, MPDecorator | |
|
23 | from schainpy.model.data.jrodata import Voltage | |
|
24 | ||
|
25 | ||
|
26 | ||
|
27 | ||
|
28 | @MPDecorator | |
|
29 | class VoltageLagsProc(ProcessingUnit): | |
|
30 | ||
|
31 | def __init__(self): | |
|
32 | ||
|
33 | ProcessingUnit.__init__(self) | |
|
34 | ||
|
35 | self.dataOut = Voltage() | |
|
36 | self.bcounter=0 | |
|
37 | self.dataOut.kax=None | |
|
38 | self.dataOut.kay=None | |
|
39 | self.dataOut.kbx=None | |
|
40 | self.dataOut.kby=None | |
|
41 | self.dataOut.kax2=None | |
|
42 | self.dataOut.kay2=None | |
|
43 | self.dataOut.kbx2=None | |
|
44 | self.dataOut.kby2=None | |
|
45 | self.dataOut.kaxbx=None | |
|
46 | self.dataOut.kaxby=None | |
|
47 | self.dataOut.kaybx=None | |
|
48 | self.dataOut.kayby=None | |
|
49 | self.dataOut.kaxay=None | |
|
50 | self.dataOut.kbxby=None | |
|
51 | self.aux=1 | |
|
52 | ||
|
53 | self.LP_products_aux=0 | |
|
54 | self.lag_products_LP_median_estimates_aux=0 | |
|
55 | ||
|
56 | #self.dataOut.input_dat_type=0 #06/04/2020 | |
|
57 | ||
|
58 | def get_products_cabxys(self): | |
|
59 | ||
|
60 | ||
|
61 | if self.aux==1: | |
|
62 | ||
|
63 | ||
|
64 | ||
|
65 | self.dataOut.read_samples=int(self.dataOut.systemHeaderObj.nSamples/self.dataOut.OSAMP) | |
|
66 | if self.dataOut.experiment=="DP": | |
|
67 | self.dataOut.nptsfft1=132 #30/03/2020 | |
|
68 | self.dataOut.nptsfft2=140 #30/03/2020 | |
|
69 | if self.dataOut.experiment=="HP": | |
|
70 | self.dataOut.nptsfft1=128 #30/03/2020 | |
|
71 | self.dataOut.nptsfft2=150 #30/03/2020 | |
|
72 | ||
|
73 | ||
|
74 | #self.dataOut.noise_final_list=[] #30/03/2020 | |
|
75 | ||
|
76 | padding=numpy.zeros(1,'int32') | |
|
77 | ||
|
78 | hsize=numpy.zeros(1,'int32') | |
|
79 | bufsize=numpy.zeros(1,'int32') | |
|
80 | nr=numpy.zeros(1,'int32') | |
|
81 | ngates=numpy.zeros(1,'int32') ### ### ### 2 | |
|
82 | time1=numpy.zeros(1,'uint64') # pos 3 | |
|
83 | time2=numpy.zeros(1,'uint64') # pos 4 | |
|
84 | lcounter=numpy.zeros(1,'int32') | |
|
85 | groups=numpy.zeros(1,'int32') | |
|
86 | system=numpy.zeros(4,'int8') # pos 7 | |
|
87 | h0=numpy.zeros(1,'float32') | |
|
88 | dh=numpy.zeros(1,'float32') | |
|
89 | ipp=numpy.zeros(1,'float32') | |
|
90 | process=numpy.zeros(1,'int32') | |
|
91 | tx=numpy.zeros(1,'int32') | |
|
92 | ||
|
93 | ngates1=numpy.zeros(1,'int32') ### ### ### 13 | |
|
94 | time0=numpy.zeros(1,'uint64') # pos 14 | |
|
95 | nlags=numpy.zeros(1,'int32') | |
|
96 | nlags1=numpy.zeros(1,'int32') | |
|
97 | txb=numpy.zeros(1,'float32') ### ### ### 17 | |
|
98 | time3=numpy.zeros(1,'uint64') # pos 18 | |
|
99 | time4=numpy.zeros(1,'uint64') # pos 19 | |
|
100 | h0_=numpy.zeros(1,'float32') | |
|
101 | dh_=numpy.zeros(1,'float32') | |
|
102 | ipp_=numpy.zeros(1,'float32') | |
|
103 | txa_=numpy.zeros(1,'float32') | |
|
104 | ||
|
105 | pad=numpy.zeros(100,'int32') | |
|
106 | ||
|
107 | nbytes=numpy.zeros(1,'int32') | |
|
108 | limits=numpy.zeros(1,'int32') | |
|
109 | ngroups=numpy.zeros(1,'int32') ### ### ### 27 | |
|
110 | ||
|
111 | ||
|
112 | self.dataOut.header=[hsize,bufsize,nr,ngates,time1,time2, | |
|
113 | lcounter,groups,system,h0,dh,ipp, | |
|
114 | process,tx,ngates1,padding,time0,nlags, | |
|
115 | nlags1,padding,txb,time3,time4,h0_,dh_, | |
|
116 | ipp_,txa_,pad,nbytes,limits,padding,ngroups] | |
|
117 | ||
|
118 | if self.dataOut.experiment == "DP": | |
|
119 | self.dataOut.header[1][0]=81864 | |
|
120 | if self.dataOut.experiment == "HP": | |
|
121 | self.dataOut.header[1][0]=173216 | |
|
122 | ||
|
123 | self.dataOut.header[3][0]=max(self.dataOut.NRANGE,self.dataOut.NDT) | |
|
124 | self.dataOut.header[7][0]=self.dataOut.NAVG | |
|
125 | self.dataOut.header[9][0]=int(self.dataOut.heightList[0]) | |
|
126 | self.dataOut.header[10][0]=self.dataOut.DH | |
|
127 | self.dataOut.header[17][0]=self.dataOut.DPL | |
|
128 | self.dataOut.header[18][0]=self.dataOut.NLAG | |
|
129 | #self.header[5][0]=0 | |
|
130 | self.dataOut.header[15][0]=self.dataOut.NDP | |
|
131 | self.dataOut.header[2][0]=self.dataOut.NR | |
|
132 | #time.mktime(time.strptime() | |
|
133 | ||
|
134 | ||
|
135 | ||
|
136 | ||
|
137 | self.aux=0 | |
|
138 | ||
|
139 | ||
|
140 | ||
|
141 | ||
|
142 | ||
|
143 | ||
|
144 | ||
|
145 | ||
|
146 | ||
|
147 | if self.dataOut.experiment=="DP": | |
|
148 | ||
|
149 | ||
|
150 | self.dataOut.lags_array=[x / self.dataOut.DH for x in self.dataOut.flags_array] | |
|
151 | self.cax=numpy.zeros((self.dataOut.NDP,self.dataOut.nlags_array,2)) | |
|
152 | self.cay=numpy.zeros((self.dataOut.NDP,self.dataOut.nlags_array,2)) | |
|
153 | self.cbx=numpy.zeros((self.dataOut.NDP,self.dataOut.nlags_array,2)) | |
|
154 | self.cby=numpy.zeros((self.dataOut.NDP,self.dataOut.nlags_array,2)) | |
|
155 | self.cax2=numpy.zeros((self.dataOut.NDP,self.dataOut.nlags_array,2)) | |
|
156 | self.cay2=numpy.zeros((self.dataOut.NDP,self.dataOut.nlags_array,2)) | |
|
157 | self.cbx2=numpy.zeros((self.dataOut.NDP,self.dataOut.nlags_array,2)) | |
|
158 | self.cby2=numpy.zeros((self.dataOut.NDP,self.dataOut.nlags_array,2)) | |
|
159 | self.caxbx=numpy.zeros((self.dataOut.NDP,self.dataOut.nlags_array,2)) | |
|
160 | self.caxby=numpy.zeros((self.dataOut.NDP,self.dataOut.nlags_array,2)) | |
|
161 | self.caybx=numpy.zeros((self.dataOut.NDP,self.dataOut.nlags_array,2)) | |
|
162 | self.cayby=numpy.zeros((self.dataOut.NDP,self.dataOut.nlags_array,2)) | |
|
163 | self.caxay=numpy.zeros((self.dataOut.NDP,self.dataOut.nlags_array,2)) | |
|
164 | self.cbxby=numpy.zeros((self.dataOut.NDP,self.dataOut.nlags_array,2)) | |
|
165 | ||
|
166 | for i in range(2): | |
|
167 | for j in range(self.dataOut.NDP): | |
|
168 | for k in range(int(self.dataOut.NSCAN/2)): | |
|
169 | n=k%self.dataOut.nlags_array | |
|
170 | ax=self.dataOut.data[0,2*k+i,j].real | |
|
171 | ay=self.dataOut.data[0,2*k+i,j].imag | |
|
172 | if j+self.dataOut.lags_array[n]<self.dataOut.NDP: | |
|
173 | bx=self.dataOut.data[1,2*k+i,j+int(self.dataOut.lags_array[n])].real | |
|
174 | by=self.dataOut.data[1,2*k+i,j+int(self.dataOut.lags_array[n])].imag | |
|
175 | else: | |
|
176 | if k+1<int(self.dataOut.NSCAN/2): | |
|
177 | bx=self.dataOut.data[1,2*(k+1)+i,(self.dataOut.NRANGE+self.dataOut.NCAL+j+int(self.dataOut.lags_array[n]))%self.dataOut.NDP].real | |
|
178 | by=self.dataOut.data[1,2*(k+1)+i,(self.dataOut.NRANGE+self.dataOut.NCAL+j+int(self.dataOut.lags_array[n]))%self.dataOut.NDP].imag | |
|
179 | ||
|
180 | if k+1==int(self.dataOut.NSCAN/2): | |
|
181 | bx=self.dataOut.data[1,2*k+i,(self.dataOut.NRANGE+self.dataOut.NCAL+j+int(self.dataOut.lags_array[n]))%self.dataOut.NDP].real | |
|
182 | by=self.dataOut.data[1,2*k+i,(self.dataOut.NRANGE+self.dataOut.NCAL+j+int(self.dataOut.lags_array[n]))%self.dataOut.NDP].imag | |
|
183 | ||
|
184 | if(k<self.dataOut.nlags_array): | |
|
185 | self.cax[j][n][i]=ax | |
|
186 | self.cay[j][n][i]=ay | |
|
187 | self.cbx[j][n][i]=bx | |
|
188 | self.cby[j][n][i]=by | |
|
189 | self.cax2[j][n][i]=ax*ax | |
|
190 | self.cay2[j][n][i]=ay*ay | |
|
191 | self.cbx2[j][n][i]=bx*bx | |
|
192 | self.cby2[j][n][i]=by*by | |
|
193 | self.caxbx[j][n][i]=ax*bx | |
|
194 | self.caxby[j][n][i]=ax*by | |
|
195 | self.caybx[j][n][i]=ay*bx | |
|
196 | self.cayby[j][n][i]=ay*by | |
|
197 | self.caxay[j][n][i]=ax*ay | |
|
198 | self.cbxby[j][n][i]=bx*by | |
|
199 | else: | |
|
200 | self.cax[j][n][i]+=ax | |
|
201 | self.cay[j][n][i]+=ay | |
|
202 | self.cbx[j][n][i]+=bx | |
|
203 | self.cby[j][n][i]+=by | |
|
204 | self.cax2[j][n][i]+=ax*ax | |
|
205 | self.cay2[j][n][i]+=ay*ay | |
|
206 | self.cbx2[j][n][i]+=bx*bx | |
|
207 | self.cby2[j][n][i]+=by*by | |
|
208 | self.caxbx[j][n][i]+=ax*bx | |
|
209 | self.caxby[j][n][i]+=ax*by | |
|
210 | self.caybx[j][n][i]+=ay*bx | |
|
211 | self.cayby[j][n][i]+=ay*by | |
|
212 | self.caxay[j][n][i]+=ax*ay | |
|
213 | self.cbxby[j][n][i]+=bx*by | |
|
214 | ||
|
215 | ||
|
216 | ||
|
217 | #return self.cax,self.cay,self.cbx,self.cby,self.cax2,self.cay2,self.cbx2,self.cby2,self.caxbx,self.caxby,self.caybx,self.cayby,self.caxay,self.cbxby | |
|
218 | ||
|
219 | if self.dataOut.experiment=="HP": | |
|
220 | ||
|
221 | #lagind=[0,1,2,3,4,5,6,7,0,3,4,5,6,8,9,10] | |
|
222 | #lagfirst=[1,1,1,1,1,1,1,1,0,0,0,0,0,1,1,1] | |
|
223 | ||
|
224 | self.cax=numpy.zeros((self.dataOut.NDP,self.dataOut.DPL,2))# hp:67x11x2 dp: 66x11x2 | |
|
225 | self.cay=numpy.zeros((self.dataOut.NDP,self.dataOut.DPL,2)) | |
|
226 | self.cbx=numpy.zeros((self.dataOut.NDP,self.dataOut.DPL,2)) | |
|
227 | self.cby=numpy.zeros((self.dataOut.NDP,self.dataOut.DPL,2)) | |
|
228 | self.cax2=numpy.zeros((self.dataOut.NDP,self.dataOut.DPL,2)) | |
|
229 | self.cay2=numpy.zeros((self.dataOut.NDP,self.dataOut.DPL,2)) | |
|
230 | self.cbx2=numpy.zeros((self.dataOut.NDP,self.dataOut.DPL,2)) | |
|
231 | self.cby2=numpy.zeros((self.dataOut.NDP,self.dataOut.DPL,2)) | |
|
232 | self.caxbx=numpy.zeros((self.dataOut.NDP,self.dataOut.DPL,2)) | |
|
233 | self.caxby=numpy.zeros((self.dataOut.NDP,self.dataOut.DPL,2)) | |
|
234 | self.caybx=numpy.zeros((self.dataOut.NDP,self.dataOut.DPL,2)) | |
|
235 | self.cayby=numpy.zeros((self.dataOut.NDP,self.dataOut.DPL,2)) | |
|
236 | self.caxay=numpy.zeros((self.dataOut.NDP,self.dataOut.DPL,2)) | |
|
237 | self.cbxby=numpy.zeros((self.dataOut.NDP,self.dataOut.DPL,2)) | |
|
238 | for i in range(2): # flipped and unflipped | |
|
239 | for j in range(self.dataOut.NDP): # loop over true ranges # 67 | |
|
240 | for k in range(int(self.dataOut.NSCAN)): # 128 | |
|
241 | #print("flip ",i," NDP ",j, " NSCAN ",k) | |
|
242 | #print("cdata ",cdata[i:NSCAN:2][k][:,0]) | |
|
243 | n=self.dataOut.lagind[k%self.dataOut.nlags_array] # 128=16x8 | |
|
244 | #print("n ",n) | |
|
245 | #ind1=nrx*(j+ngates_2*i+ngates_2*2*k)# scan has flip or unflip | |
|
246 | #ind2=ind1+(1)+nrx*lags_array[n]#jump each lagged | |
|
247 | #ax=cdata[i:NSCAN:2][k][:,0][NRANGE+NCAL+j].real #cdata[ind1].r | |
|
248 | #ay=cdata[i:NSCAN:2][k][:,0][NRANGE+NCAL+j].imag #cdata[ind1].i | |
|
249 | #input() | |
|
250 | ##ax=cdata[int(i*NSCAN):int((i+1)*NSCAN)][k][:,0][NRANGE+NCAL+j].real #cdata[ind1].r | |
|
251 | ##ay=cdata[int(i*NSCAN):int((i+1)*NSCAN)][k][:,0][NRANGE+NCAL+j].imag #cdata[ind1].i | |
|
252 | ||
|
253 | ax=self.dataOut.data[0,k,self.dataOut.NRANGE+self.dataOut.NCAL+j+i*self.dataOut.NDT].real | |
|
254 | ay=self.dataOut.data[0,k,self.dataOut.NRANGE+self.dataOut.NCAL+j+i*self.dataOut.NDT].imag | |
|
255 | ||
|
256 | #print("ax ",ax," ay",ay) | |
|
257 | if self.dataOut.NRANGE+self.dataOut.NCAL+j+i*self.dataOut.NDT+2*n<self.dataOut.read_samples: | |
|
258 | #bx=cdata[i:NSCAN:2][k][:,1][NRANGE+NCAL+j+n].real #cdata[ind2].r | |
|
259 | #by=cdata[i:NSCAN:2][k][:,1][NRANGE+NCAL+j+n].imag #cdata[ind2].i | |
|
260 | ##bx=cdata[int(i*NSCAN):int((i+1)*NSCAN)][k][:,1][NRANGE+NCAL+j+2*n].real #cdata[ind2].r | |
|
261 | ##by=cdata[int(i*NSCAN):int((i+1)*NSCAN)][k][:,1][NRANGE+NCAL+j+2*n].imag #cdata[ind2].i | |
|
262 | ||
|
263 | bx=self.dataOut.data[1,k,self.dataOut.NRANGE+self.dataOut.NCAL+j+i*self.dataOut.NDT+2*n].real | |
|
264 | by=self.dataOut.data[1,k,self.dataOut.NRANGE+self.dataOut.NCAL+j+i*self.dataOut.NDT+2*n].imag | |
|
265 | ||
|
266 | #bx=self.dataOut.data[0:NSCAN][k][:,1][NRANGE+NCAL+j+i*NDT+2*n].real #cdata[ind2].r | |
|
267 | #by=self.dataOut.data[0:NSCAN][k][:,1][NRANGE+NCAL+j+i*NDT+2*n].imag #cdata[ind2].i | |
|
268 | #print("bx ",bx, " by ",by) | |
|
269 | #input() | |
|
270 | else: | |
|
271 | #print("n ",n," k ",k," j ",j," i ",i, " n ",n) | |
|
272 | #input() | |
|
273 | if k+1<int(self.dataOut.NSCAN): | |
|
274 | #print("k+1 ",k+1) | |
|
275 | #print("int(NSCAN/2) ",int(NSCAN/2)) | |
|
276 | #bx=cdata[i:NSCAN:2][k+1][:,1][(NRANGE+NCAL+j+n)%NDP].real#np.nan | |
|
277 | #by=cdata[i:NSCAN:2][k+1][:,1][(NRANGE+NCAL+j+n)%NDP].imag#np.nan | |
|
278 | ##bx=cdata[int(i*NSCAN):int((i+1)*NSCAN)][k+1][:,1][(NRANGE+NCAL+j+2*n)%NDP].real#np.nan | |
|
279 | ##by=cdata[int(i*NSCAN):int((i+1)*NSCAN)][k+1][:,1][(NRANGE+NCAL+j+2*n)%NDP].imag#np.nan | |
|
280 | #bx=self.dataOut.data[0:NSCAN][k+1][:,1][(NRANGE+NCAL+j+i*NDT+2*n)%NDP].real#np.nan | |
|
281 | #by=self.dataOut.data[0:NSCAN][k+1][:,1][(NRANGE+NCAL+j+i*NDT+2*n)%NDP].imag#np.nan | |
|
282 | bx=self.dataOut.data[1,k+1,(self.dataOut.NRANGE+self.dataOut.NCAL+j+i*self.dataOut.NDT+2*n)%self.dataOut.NDP].real | |
|
283 | by=self.dataOut.data[1,k+1,(self.dataOut.NRANGE+self.dataOut.NCAL+j+i*self.dataOut.NDT+2*n)%self.dataOut.NDP].imag | |
|
284 | ||
|
285 | #print("n ",n," k ",k," j ",j," i ",i, " lags_array[n] ",lags_array[n]) | |
|
286 | #print("bx ",bx, " by ",by) | |
|
287 | #input() | |
|
288 | if k+1==int(self.dataOut.NSCAN):## ESTO ES UN PARCHE PUES NO SE TIENE EL SIGUIENTE BLOQUE | |
|
289 | #bx=cdata[i:NSCAN:2][k][:,1][(NRANGE+NCAL+j+n)%NDP].real#np.nan | |
|
290 | #by=cdata[i:NSCAN:2][k][:,1][(NRANGE+NCAL+j+n)%NDP].imag#np.nan | |
|
291 | ##bx=cdata[int(i*NSCAN):int((i+1)*NSCAN)][k][:,1][(NRANGE+NCAL+j+2*n)%NDP].real#np.nan | |
|
292 | ##by=cdata[int(i*NSCAN):int((i+1)*NSCAN)][k][:,1][(NRANGE+NCAL+j+2*n)%NDP].imag#np.nan | |
|
293 | #print("****n ",n," k ",k," j ",j," i ",i, " lags_array[n] ",lags_array[n]) | |
|
294 | #bx=self.dataOut.data[0:NSCAN][k][:,1][(NRANGE+NCAL+j+i*NDT+2*n)%NDP].real#np.nan | |
|
295 | #by=self.dataOut.data[0:NSCAN][k][:,1][(NRANGE+NCAL+j+i*NDT+2*n)%NDP].imag#np.nan | |
|
296 | bx=self.dataOut.data[1,k,(self.dataOut.NRANGE+self.dataOut.NCAL+j+i*self.dataOut.NDT+2*n)%self.dataOut.NDP].real | |
|
297 | by=self.dataOut.data[1,k,(self.dataOut.NRANGE+self.dataOut.NCAL+j+i*self.dataOut.NDT+2*n)%self.dataOut.NDP].imag | |
|
298 | ||
|
299 | #print("bx ",bx, " by ",by) | |
|
300 | #input() | |
|
301 | ||
|
302 | #print("i ",i," j ",j," k ",k," n ",n," ax ",ax) | |
|
303 | #input() | |
|
304 | #ip1=j+NDP*(i+2*n) | |
|
305 | #ip2=ip1*navg+iavg | |
|
306 | ##if(k<11): # PREVIOUS | |
|
307 | if(k<self.dataOut.nlags_array and self.dataOut.lagfirst[k%self.dataOut.nlags_array]==1):# if(k<16 && lagfirst[k%16]==1) | |
|
308 | self.cax[j][n][i]=ax#[int(k/nlags_array)*nlags_array+n] | |
|
309 | self.cay[j][n][i]=ay#[int(k/nlags_array)*nlags_array+n] | |
|
310 | self.cbx[j][n][i]=bx#[int(k/nlags_array)*nlags_array+n] | |
|
311 | self.cby[j][n][i]=by#[int(k/nlags_array)*nlags_array+n] | |
|
312 | self.cax2[j][n][i]=ax*ax#np.multiply(ax,ax)[int(k/nlags_array)*nlags_array+n] | |
|
313 | self.cay2[j][n][i]=ay*ay#np.multiply(ay,ay)[int(k/nlags_array)*nlags_array+n] | |
|
314 | self.cbx2[j][n][i]=bx*bx#np.multiply(bx,bx)[int(k/nlags_array)*nlags_array+n] | |
|
315 | self.cby2[j][n][i]=by*by#np.multiply(by,by)[int(k/nlags_array)*nlags_array+n] | |
|
316 | self.caxbx[j][n][i]=ax*bx#np.multiply(ax,bx)[int(k/nlags_array)*nlags_array+n] | |
|
317 | self.caxby[j][n][i]=ax*by#np.multiply(ax,by)[int(k/nlags_array)*nlags_array+n] | |
|
318 | self.caybx[j][n][i]=ay*bx#np.multiply(ay,bx)[int(k/nlags_array)*nlags_array+n] | |
|
319 | self.cayby[j][n][i]=ay*by#np.multiply(ay,by)[int(k/nlags_array)*nlags_array+n] | |
|
320 | self.caxay[j][n][i]=ax*ay#np.multiply(ax,ay)[int(k/nlags_array)*nlags_array+n] | |
|
321 | self.cbxby[j][n][i]=bx*by#np.multiply(bx,by)[int(k/nlags_array)*nlags_array+n] | |
|
322 | else: | |
|
323 | self.cax[j][n][i]+=ax#[int(k/nlags_array)*nlags_array+n] | |
|
324 | self.cay[j][n][i]+=ay#[int(k/nlags_array)*nlags_array+n] | |
|
325 | self.cbx[j][n][i]+=bx#[int(k/nlags_array)*nlags_array+n] | |
|
326 | self.cby[j][n][i]+=by#[int(k/nlags_array)*nlags_array+n] | |
|
327 | self.cax2[j][n][i]+=ax*ax#np.multiply(ax,ax)[int(k/nlags_array)*nlags_array+n] | |
|
328 | self.cay2[j][n][i]+=ay*ay#np.multiply(ay,ay)[int(k/nlags_array)*nlags_array+n] | |
|
329 | self.cbx2[j][n][i]+=bx*bx#np.multiply(bx,bx)[int(k/nlags_array)*nlags_array+n] | |
|
330 | self.cby2[j][n][i]+=by*by#np.multiply(by,by)[int(k/nlags_array)*nlags_array+n] | |
|
331 | self.caxbx[j][n][i]+=ax*bx#np.multiply(ax,bx)[int(k/nlags_array)*nlags_array+n] | |
|
332 | self.caxby[j][n][i]+=ax*by#np.multiply(ax,by)[int(k/nlags_array)*nlags_array+n] | |
|
333 | self.caybx[j][n][i]+=ay*bx#np.multiply(ay,bx)[int(k/nlags_array)*nlags_array+n] | |
|
334 | self.cayby[j][n][i]+=ay*by#np.multiply(ay,by)[int(k/nlags_array)*nlags_array+n] | |
|
335 | self.caxay[j][n][i]+=ax*ay#np.multiply(ax,ay)[int(k/nlags_array)*nlags_array+n] | |
|
336 | self.cbxby[j][n][i]+=bx*by#np.multiply(bx,by)[int(k/nlags_array)*nlags_array+n] | |
|
337 | ||
|
338 | ||
|
339 | ||
|
340 | ||
|
341 | ||
|
342 | ||
|
343 | ||
|
344 | ||
|
345 | ||
|
346 | def medi(self,data_navg): | |
|
347 | sorts=sorted(data_navg) | |
|
348 | rsorts=numpy.arange(self.dataOut.NAVG) | |
|
349 | result=0.0 | |
|
350 | for k in range(self.dataOut.NAVG): | |
|
351 | if k>=self.dataOut.nkill/2 and k<self.dataOut.NAVG-self.dataOut.nkill/2: | |
|
352 | result+=sorts[k]*float(self.dataOut.NAVG)/(float)(self.dataOut.NAVG-self.dataOut.nkill) | |
|
353 | return result | |
|
354 | ||
|
355 | ||
|
356 | ||
|
357 | ''' | |
|
358 | def range(self): | |
|
359 | Range=numpy.arange(0,990,self.DH) | |
|
360 | return Range | |
|
361 | ''' | |
|
362 | ||
|
363 | ||
|
364 | ||
|
365 | ||
|
366 | ||
|
367 | ||
|
368 | def cabxys_navg(self): | |
|
369 | ||
|
370 | #print("blocknow",self.dataOut.CurrentBlock) | |
|
371 | #bcounter=0 | |
|
372 | #print("self.bcounter",self.bcounter) | |
|
373 | self.get_products_cabxys() | |
|
374 | ||
|
375 | self.dataOut.header[5][0]=time.mktime(time.strptime(self.dataOut.TimeBlockDate)) | |
|
376 | ||
|
377 | #if salf.dataOut.CurrentBlock<NAVG: | |
|
378 | if self.bcounter==0: | |
|
379 | ||
|
380 | self.dataOut.header[4][0]=self.dataOut.header[5][0] | |
|
381 | if self.dataOut.CurrentBlock==1: | |
|
382 | self.dataOut.header[16][0]=self.dataOut.header[5][0] | |
|
383 | ||
|
384 | self.cax_navg=[] | |
|
385 | self.cay_navg=[] | |
|
386 | self.cbx_navg=[] | |
|
387 | self.cby_navg=[] | |
|
388 | self.cax2_navg=[] | |
|
389 | self.cay2_navg=[] | |
|
390 | self.cbx2_navg=[] | |
|
391 | self.cby2_navg=[] | |
|
392 | self.caxbx_navg=[] | |
|
393 | self.caxby_navg=[] | |
|
394 | self.caybx_navg=[] | |
|
395 | self.cayby_navg=[] | |
|
396 | self.caxay_navg=[] | |
|
397 | self.cbxby_navg=[] | |
|
398 | self.dataOut.kax=None | |
|
399 | self.dataOut.kay=None | |
|
400 | self.dataOut.kbx=None | |
|
401 | self.dataOut.kby=None | |
|
402 | self.dataOut.kax2=None | |
|
403 | self.dataOut.kay2=None | |
|
404 | self.dataOut.kbx2=None | |
|
405 | self.dataOut.kby2=None | |
|
406 | self.dataOut.kaxbx=None | |
|
407 | self.dataOut.kaxby=None | |
|
408 | self.dataOut.kaybx=None | |
|
409 | self.dataOut.kayby=None | |
|
410 | self.dataOut.kaxay=None | |
|
411 | self.dataOut.kbxby=None | |
|
412 | ||
|
413 | self.dataOut.noisevector=numpy.zeros((self.dataOut.read_samples,self.dataOut.NR,self.dataOut.NAVG),'float32') #30/03/2020 | |
|
414 | self.dataOut.noisevector_=numpy.zeros((self.dataOut.read_samples,self.dataOut.NR,self.dataOut.NAVG),'float32') | |
|
415 | self.dataOut.dc=numpy.zeros(self.dataOut.NR,dtype=numpy.complex_) #30/03/2020 | |
|
416 | #self.dataOut.noisevector=numpy.zeros((self.dataOut.read_samples,2,self.dataOut.NAVG),'float32') #31/03/2020 | |
|
417 | #self.dataOut.noisevector_=numpy.zeros((self.dataOut.read_samples,2,self.dataOut.NAVG),'float32') #31/03/2020 | |
|
418 | ||
|
419 | #self.dataOut.dc=numpy.zeros(2,dtype=numpy.complex_) #31/03/2020 | |
|
420 | #self.dataOut.processingHeaderObj.profilesPerBlock | |
|
421 | if self.dataOut.experiment=="DP": | |
|
422 | self.noisevectorizer(self.dataOut.nptsfft1,self.dataOut.nptsfft2) #30/03/2020 | |
|
423 | if self.dataOut.experiment=="HP": | |
|
424 | self.noisevectorizer(self.dataOut.nptsfft1,self.dataOut.nptsfftx1) #31/03/2020 | |
|
425 | #print(self.dataOut.noisevector[:,:,:]) | |
|
426 | #print("·················································") | |
|
427 | #print("CAX: ",self.cax) | |
|
428 | self.cax_navg.append(self.cax) | |
|
429 | self.cay_navg.append(self.cay) | |
|
430 | self.cbx_navg.append(self.cbx) | |
|
431 | self.cby_navg.append(self.cby) | |
|
432 | self.cax2_navg.append(self.cax2) | |
|
433 | self.cay2_navg.append(self.cay2) | |
|
434 | self.cbx2_navg.append(self.cbx2) | |
|
435 | self.cby2_navg.append(self.cby2) | |
|
436 | self.caxbx_navg.append(self.caxbx) | |
|
437 | self.caxby_navg.append(self.caxby) | |
|
438 | self.caybx_navg.append(self.caybx) | |
|
439 | self.cayby_navg.append(self.cayby) | |
|
440 | self.caxay_navg.append(self.caxay) | |
|
441 | self.cbxby_navg.append(self.cbxby) | |
|
442 | self.bcounter+=1 | |
|
443 | ||
|
444 | #self.dataOut.data=None | |
|
445 | #print("bcounter",bcounter) | |
|
446 | #/#/#/#if self.bcounter==NAVG: | |
|
447 | ||
|
448 | #/#/#/#print("cax_navg: ",self.cax_navg) | |
|
449 | #/#/#/#self.bcounter=0 | |
|
450 | #print("blocknow",self.dataOut.current) | |
|
451 | ||
|
452 | ||
|
453 | ||
|
454 | def kabxys(self,NAVG,nkill):#,NRANGE,NCAL,NDT): | |
|
455 | ||
|
456 | self.dataOut.NAVG=NAVG | |
|
457 | self.dataOut.nkill=nkill | |
|
458 | #print("bcounter_before: ",self.bcounter) | |
|
459 | #print("kabxys") | |
|
460 | ||
|
461 | #if self.dataOut.input_dat_type==0: | |
|
462 | #self.dataOut.NDP=NDP | |
|
463 | #self.dataOut.nlags_array=nlags_array | |
|
464 | #self.dataOut.NSCAN=NSCAN | |
|
465 | #self.dataOut.DH=float(DH) | |
|
466 | #self.dataOut.flags_array=flags_array | |
|
467 | ||
|
468 | #self.dataOut.DPL=DPL | |
|
469 | #self.dataOut.NRANGE=NRANGE | |
|
470 | #self.dataOut.NCAL=NCAL | |
|
471 | ||
|
472 | #self.dataOut.NDT=NDT | |
|
473 | #self.lag_products_LP() | |
|
474 | ####self.cabxys_navg(NDP,nlags_array,NSCAN,flags_array) | |
|
475 | self.cabxys_navg() | |
|
476 | #self.dataOut.kshape=numpy.zeros((numpy.shape(self.cax_navg[0])[0],numpy.shape(self.cax_navg[0])[1],numpy.shape(self.cax_navg[0])[2])) | |
|
477 | #print("Shape cavg",numpy.shape(self.cax_navg[0])[0]) | |
|
478 | self.dataOut.flag_save=0 | |
|
479 | #self.dataOut.flagNoData = True # new 1 | |
|
480 | ||
|
481 | ||
|
482 | if self.bcounter==self.dataOut.NAVG: | |
|
483 | ||
|
484 | #self.dataOut.flagNoData = False # new 2 | |
|
485 | self.dataOut.flag_save=1 | |
|
486 | #self.dataOut.kax=None | |
|
487 | ||
|
488 | ||
|
489 | self.dataOut.noise_final=numpy.zeros(self.dataOut.NR,'float32') #30/03/2020 | |
|
490 | #self.dataOut.noise_final=numpy.zeros(2,'float32') #31/03/2020 | |
|
491 | ||
|
492 | #print("self.dataOut.nChannels: ",self.dataOut.systemHeaderObj.nChannels) | |
|
493 | self.kax=numpy.zeros((self.dataOut.NDP,self.dataOut.DPL,2),'float32') | |
|
494 | self.kay=numpy.zeros((self.dataOut.NDP,self.dataOut.DPL,2),'float32') | |
|
495 | self.kbx=numpy.zeros((self.dataOut.NDP,self.dataOut.DPL,2),'float32') | |
|
496 | self.kby=numpy.zeros((self.dataOut.NDP,self.dataOut.DPL,2),'float32') | |
|
497 | self.kax2=numpy.zeros((self.dataOut.NDP,self.dataOut.DPL,2),'float32') | |
|
498 | self.kay2=numpy.zeros((self.dataOut.NDP,self.dataOut.DPL,2),'float32') | |
|
499 | self.kbx2=numpy.zeros((self.dataOut.NDP,self.dataOut.DPL,2),'float32') | |
|
500 | self.kby2=numpy.zeros((self.dataOut.NDP,self.dataOut.DPL,2),'float32') | |
|
501 | self.kaxbx=numpy.zeros((self.dataOut.NDP,self.dataOut.DPL,2),'float32') | |
|
502 | self.kaxby=numpy.zeros((self.dataOut.NDP,self.dataOut.DPL,2),'float32') | |
|
503 | self.kaybx=numpy.zeros((self.dataOut.NDP,self.dataOut.DPL,2),'float32') | |
|
504 | self.kayby=numpy.zeros((self.dataOut.NDP,self.dataOut.DPL,2),'float32') | |
|
505 | self.kaxay=numpy.zeros((self.dataOut.NDP,self.dataOut.DPL,2),'float32') | |
|
506 | self.kbxby=numpy.zeros((self.dataOut.NDP,self.dataOut.DPL,2),'float32') | |
|
507 | #print("Shape K",numpy.shape(self.kax)) | |
|
508 | for i in range(self.cax_navg[0].shape[0]): | |
|
509 | for j in range(self.cax_navg[0].shape[1]): | |
|
510 | for k in range(self.cax_navg[0].shape[2]): | |
|
511 | data_navg=[item[i,j,k] for item in self.cax_navg] | |
|
512 | self.kax[i,j,k]=self.medi(data_navg) | |
|
513 | data_navg=[item[i,j,k] for item in self.cay_navg] | |
|
514 | self.kay[i,j,k]=self.medi(data_navg) | |
|
515 | data_navg=[item[i,j,k] for item in self.cbx_navg] | |
|
516 | self.kbx[i,j,k]=self.medi(data_navg) | |
|
517 | data_navg=[item[i,j,k] for item in self.cby_navg] | |
|
518 | self.kby[i,j,k]=self.medi(data_navg) | |
|
519 | data_navg=[item[i,j,k] for item in self.cax2_navg] | |
|
520 | self.kax2[i,j,k]=self.medi(data_navg) | |
|
521 | data_navg=[item[i,j,k] for item in self.cay2_navg] | |
|
522 | self.kay2[i,j,k]=self.medi(data_navg) | |
|
523 | data_navg=[item[i,j,k] for item in self.cbx2_navg] | |
|
524 | self.kbx2[i,j,k]=self.medi(data_navg) | |
|
525 | data_navg=[item[i,j,k] for item in self.cby2_navg] | |
|
526 | self.kby2[i,j,k]=self.medi(data_navg) | |
|
527 | data_navg=[item[i,j,k] for item in self.caxbx_navg] | |
|
528 | self.kaxbx[i,j,k]=self.medi(data_navg) | |
|
529 | data_navg=[item[i,j,k] for item in self.caxby_navg] | |
|
530 | self.kaxby[i,j,k]=self.medi(data_navg) | |
|
531 | data_navg=[item[i,j,k] for item in self.caybx_navg] | |
|
532 | self.kaybx[i,j,k]=self.medi(data_navg) | |
|
533 | data_navg=[item[i,j,k] for item in self.cayby_navg] | |
|
534 | self.kayby[i,j,k]=self.medi(data_navg) | |
|
535 | data_navg=[item[i,j,k] for item in self.caxay_navg] | |
|
536 | self.kaxay[i,j,k]=self.medi(data_navg) | |
|
537 | data_navg=[item[i,j,k] for item in self.cbxby_navg] | |
|
538 | self.kbxby[i,j,k]=self.medi(data_navg) | |
|
539 | #self.bcounter=0 | |
|
540 | #print("KAX",self.kax) | |
|
541 | #self.__buffer=self.kax | |
|
542 | #print("CurrentBlock: ", self.dataOut.CurrentBlock) | |
|
543 | ||
|
544 | self.dataOut.kax=self.kax | |
|
545 | self.dataOut.kay=self.kay | |
|
546 | self.dataOut.kbx=self.kbx | |
|
547 | self.dataOut.kby=self.kby | |
|
548 | self.dataOut.kax2=self.kax2 | |
|
549 | self.dataOut.kay2=self.kay2 | |
|
550 | self.dataOut.kbx2=self.kbx2 | |
|
551 | self.dataOut.kby2=self.kby2 | |
|
552 | self.dataOut.kaxbx=self.kaxbx | |
|
553 | self.dataOut.kaxby=self.kaxby | |
|
554 | self.dataOut.kaybx=self.kaybx | |
|
555 | self.dataOut.kayby=self.kayby | |
|
556 | self.dataOut.kaxay=self.kaxay | |
|
557 | self.dataOut.kbxby=self.kbxby | |
|
558 | self.bcounter=0 | |
|
559 | ||
|
560 | #print("before: ",self.dataOut.noise_final) | |
|
561 | ||
|
562 | self.noise_estimation4x() #30/03/2020 | |
|
563 | ||
|
564 | #print("after: ", self.dataOut.noise_final) | |
|
565 | #print(numpy.shape(self.dataOut.data)) | |
|
566 | #input() | |
|
567 | #self.dataOut.noise_final_list.append(self.dataOut.noise_final[0]) #30/03/2020 | |
|
568 | ||
|
569 | ||
|
570 | ''' | |
|
571 | print("hsize[0] ",self.dataOut.header[0]) | |
|
572 | print("bufsize[1] ",self.dataOut.header[1]) | |
|
573 | print("nr[2] ",self.dataOut.header[2]) | |
|
574 | print("ngates[3] ",self.dataOut.header[3]) | |
|
575 | print("time1[4] ",self.dataOut.header[4]) | |
|
576 | print("time2[5] ",self.dataOut.header[5]) | |
|
577 | print("lcounter[6] ",self.dataOut.header[6]) | |
|
578 | print("groups[7] ",self.dataOut.header[7]) | |
|
579 | print("system[8] ",self.dataOut.header[8]) | |
|
580 | print("h0[9] ",self.dataOut.header[9]) | |
|
581 | print("dh[10] ",self.dataOut.header[10]) | |
|
582 | print("ipp[11] ",self.dataOut.header[11]) | |
|
583 | print("process[12] ",self.dataOut.header[12]) | |
|
584 | print("tx[13] ",self.dataOut.header[13]) | |
|
585 | print("padding[14] ",self.dataOut.header[14]) | |
|
586 | print("ngates1[15] ",self.dataOut.header[15]) | |
|
587 | print("header[16] ",self.dataOut.header[16]) | |
|
588 | print("header[17] ",self.dataOut.header[17]) | |
|
589 | print("header[18] ",self.dataOut.header[18]) | |
|
590 | print("header[19] ",self.dataOut.header[19]) | |
|
591 | print("header[20] ",self.dataOut.header[20]) | |
|
592 | print("header[21] ",self.dataOut.header[21]) | |
|
593 | print("header[22] ",self.dataOut.header[22]) | |
|
594 | print("header[23] ",self.dataOut.header[23]) | |
|
595 | print("header[24] ",self.dataOut.header[24]) | |
|
596 | print("header[25] ",self.dataOut.header[25]) | |
|
597 | print("header[26] ",self.dataOut.header[26]) | |
|
598 | print("header[27] ",self.dataOut.header[27]) | |
|
599 | print("header[28] ",self.dataOut.header[28]) | |
|
600 | print("header[29] ",self.dataOut.header[29]) | |
|
601 | print("header[30] ",self.dataOut.header[30]) | |
|
602 | print("header[31] ",self.dataOut.header[31]) | |
|
603 | ''' | |
|
604 | ||
|
605 | ||
|
606 | ||
|
607 | #print("CurrentBlock: ",self.dataOut.CurrentBlock) | |
|
608 | ##print("KAX: ",self.dataOut.kax) | |
|
609 | ||
|
610 | ||
|
611 | ''' | |
|
612 | plt.plot(self.kaxby[:,0,0],self.range(),'m',linewidth=2.0) | |
|
613 | plt.xlim(min(self.kaxby[12::,0,0]), max(self.kaxby[12::,0,0])) | |
|
614 | plt.show() | |
|
615 | ''' | |
|
616 | ||
|
617 | ||
|
618 | ||
|
619 | ||
|
620 | ||
|
621 | #/#/#/#print("CurrentBlock: ",self.dataOut.CurrentBlock) | |
|
622 | ####self.newdataOut=self.kax | |
|
623 | #print("shapedataout",numpy.shape(self.dataOut.data)) | |
|
624 | #print("kax",numpy.shape(self.kax)) | |
|
625 | ## return 1 | |
|
626 | ||
|
627 | ||
|
628 | ####def NewData(self): | |
|
629 | ####print("NewData",self.dataOut.kaxby) | |
|
630 | ####print("CurrentBlock: ",self.dataOut.CurrentBlock) | |
|
631 | ||
|
632 | ||
|
633 | ''' | |
|
634 | def PlotVoltageLag(self): | |
|
635 | ||
|
636 | plt.plot(self.dataOut.data[:,0,0],self.range(),'m',linewidth=2.0) | |
|
637 | plt.xlim(min(self.dataOut.data[12::,0,0]), max(self.dataOut.data[12::,0,0])) | |
|
638 | plt.show() | |
|
639 | ||
|
640 | ||
|
641 | if self.bcounter==self.NAVG: | |
|
642 | #print("shapedataout",self.dataOut.data) | |
|
643 | print("CurrentBlock: ",self.dataOut.CurrentBlock) | |
|
644 | self.bcounter=0 | |
|
645 | ''' | |
|
646 | ||
|
647 | #print("Newdataout",self.dataOut.data) | |
|
648 | ## | |
|
649 | ||
|
650 | ||
|
651 | #30/03/2020: | |
|
652 | def noisevectorizer(self,nptsfft1,nptsfft2): | |
|
653 | ||
|
654 | rnormalizer= 1./float(nptsfft2 - nptsfft1) | |
|
655 | for i in range(self.dataOut.NR): | |
|
656 | for j in range(self.dataOut.read_samples): | |
|
657 | for k in range(nptsfft1,nptsfft2): | |
|
658 | #TODO:integrate just 2nd quartile gates | |
|
659 | if k==nptsfft1: | |
|
660 | self.dataOut.noisevector[j][i][self.bcounter]=(abs(self.dataOut.data[i][k][j]-self.dataOut.dc[i])**2)*rnormalizer | |
|
661 | ##noisevector[j][i][iavg]=(abs(cdata[k][j][i])**2)*rnormalizer | |
|
662 | else: | |
|
663 | self.dataOut.noisevector[j][i][self.bcounter]+=(abs(self.dataOut.data[i][k][j]-self.dataOut.dc[i])**2)*rnormalizer | |
|
664 | ||
|
665 | #30/03/2020: | |
|
666 | def noise_estimation4x(self): | |
|
667 | snoise=numpy.zeros((self.dataOut.NR,self.dataOut.NAVG),'float32') | |
|
668 | nvector1=numpy.zeros((self.dataOut.NR,self.dataOut.NAVG,self.dataOut.read_samples),'float32') | |
|
669 | for i in range(self.dataOut.NR): | |
|
670 | self.dataOut.noise_final[i]=0.0 | |
|
671 | for k in range(self.dataOut.NAVG): | |
|
672 | snoise[i][k]=0.0 | |
|
673 | for j in range(self.dataOut.read_samples): | |
|
674 | nvector1[i][k][j]= self.dataOut.noisevector[j][i][k]; | |
|
675 | snoise[i][k]=self.noise_hs4x(self.dataOut.read_samples, nvector1[i][k]) | |
|
676 | self.dataOut.noise_final[i]=self.noise_hs4x(self.dataOut.NAVG, snoise[i]) | |
|
677 | ||
|
678 | ||
|
679 | #30/03/2020: | |
|
680 | def noise_hs4x(self, ndatax, datax): | |
|
681 | #print("datax ",datax) | |
|
682 | divider=10#divider was originally 10 | |
|
683 | noise=0.0 | |
|
684 | data=numpy.zeros(ndatax,'float32') | |
|
685 | ndata1=int(ndatax/4) | |
|
686 | ndata2=int(2.5*(ndatax/4.)) | |
|
687 | ndata=int(ndata2-ndata1) | |
|
688 | sorts=sorted(datax) | |
|
689 | for k in range(ndata2): # select just second quartile | |
|
690 | data[k]=sorts[k+ndata1] | |
|
691 | nums_min= int(ndata/divider) | |
|
692 | if(int(ndata/divider)> 2): | |
|
693 | nums_min= int(ndata/divider) | |
|
694 | else: | |
|
695 | nums_min=2 | |
|
696 | sump=0.0 | |
|
697 | sumq=0.0 | |
|
698 | j=0 | |
|
699 | cont=1 | |
|
700 | while ( (cont==1) and (j<ndata)): | |
|
701 | sump+=data[j] | |
|
702 | sumq+= data[j]*data[j] | |
|
703 | j=j+1 | |
|
704 | if (j> nums_min): | |
|
705 | rtest= float(j/(j-1)) +1.0/ndata | |
|
706 | if( (sumq*j) > (rtest*sump*sump ) ): | |
|
707 | j=j-1 | |
|
708 | sump-= data[j] | |
|
709 | sumq-=data[j]*data[j] | |
|
710 | cont= 0 | |
|
711 | noise= (sump/j) | |
|
712 | ||
|
713 | return noise | |
|
714 | ||
|
715 | ||
|
716 | ||
|
717 | def test(self): | |
|
718 | ||
|
719 | #print("LP_init") | |
|
720 | #self.dataOut.flagNoData=1 | |
|
721 | buffer=self.dataOut.data | |
|
722 | #self.dataOut.flagNoData=0 | |
|
723 | if self.LP_products_aux==0: | |
|
724 | ||
|
725 | #self.dataOut.nptsfft2=150 | |
|
726 | self.cnorm=float((self.dataOut.nptsfft2LP-self.dataOut.NSCAN)/self.dataOut.NSCAN) | |
|
727 | ||
|
728 | ||
|
729 | #print("self.bcounter",self.bcounter) | |
|
730 | self.lagp0=numpy.zeros((self.dataOut.NLAG,self.dataOut.NRANGE,self.dataOut.NAVG),'complex64') | |
|
731 | self.lagp1=numpy.zeros((self.dataOut.NLAG,self.dataOut.NRANGE,self.dataOut.NAVG),'complex64') | |
|
732 | self.lagp2=numpy.zeros((self.dataOut.NLAG,self.dataOut.NRANGE,self.dataOut.NAVG),'complex64') | |
|
733 | self.lagp3=numpy.zeros((self.dataOut.NLAG,self.dataOut.NRANGE,self.dataOut.NAVG),'complex64') | |
|
734 | self.lagp4=numpy.zeros((self.dataOut.NLAG,self.dataOut.NRANGE,self.dataOut.NAVG),'complex64') | |
|
735 | self.LP_products_aux=1 | |
|
736 | ||
|
737 | #print(self.dataOut.data[0,0,0]) | |
|
738 | #self.dataOut.flagNoData =False | |
|
739 | for i in range(self.dataOut.NR-1): | |
|
740 | #print("inside i",i) | |
|
741 | buffer_dc=self.dataOut.dc[i] | |
|
742 | for j in range(self.dataOut.NRANGE): | |
|
743 | #print("inside j",j) | |
|
744 | #print(self.dataOut.read_samples) | |
|
745 | #input() | |
|
746 | range_for_n=numpy.min((self.dataOut.NRANGE-j,self.dataOut.NLAG)) | |
|
747 | for k in range(self.dataOut.nptsfft2LP): | |
|
748 | #print(self.dataOut.data[i][k][j]) | |
|
749 | #input() | |
|
750 | #print(self.dataOut.dc) | |
|
751 | #input() | |
|
752 | #aux_ac=0 | |
|
753 | buffer_aux=numpy.conj(buffer[i][k][j]-buffer_dc) | |
|
754 | #self.dataOut.flagNoData=0 | |
|
755 | for n in range(range_for_n): | |
|
756 | ||
|
757 | ||
|
758 | #for n in range(numpy.min((self.dataOut.NRANGE-j,self.dataOut.NLAG))): | |
|
759 | #print(numpy.shape(self.dataOut.data)) | |
|
760 | #input() | |
|
761 | #pass | |
|
762 | #self.dataOut.flagNoData=1 | |
|
763 | #c=2*buffer_aux | |
|
764 | #c=(self.dataOut.data[i][k][j]-self.dataOut.dc[i])*(numpy.conj(self.dataOut.data[i][k][j+n]-self.dataOut.dc[i])) | |
|
765 | #c=(buffer[i][k][j]-buffer_dc)*(numpy.conj(buffer[i][k][j+n])-buffer_dc) | |
|
766 | ||
|
767 | c=(buffer_aux)*(buffer[i][k][j+n]-buffer_dc) | |
|
768 | #c=(buffer[i][k][j])*(buffer[i][k][j+n]) | |
|
769 | #print("first: ",self.dataOut.data[i][k][j]-self.dataOut.dc[i]) | |
|
770 | #print("second: ",numpy.conj(self.dataOut.data[i][k][j+n]-self.dataOut.dc[i])) | |
|
771 | ||
|
772 | #print("c: ",c) | |
|
773 | #input() | |
|
774 | #print("n: ",n) | |
|
775 | #print("aux_ac",aux_ac) | |
|
776 | #print("data1:",self.dataOut.data[i][k][j]) | |
|
777 | #print("data2:",self.dataOut.data[i][k][j+n]) | |
|
778 | #print("dc: ",self.dataOut.dc[i]) | |
|
779 | #if aux_ac==2: | |
|
780 | #input() | |
|
781 | #aux_ac+=1 | |
|
782 | #print("GG") | |
|
783 | #print("inside n",n) | |
|
784 | #pass | |
|
785 | ||
|
786 | if k<self.dataOut.NSCAN: | |
|
787 | if k==0: | |
|
788 | ||
|
789 | while True: | |
|
790 | if i==0: | |
|
791 | self.lagp0[n][j][self.bcounter-1]=c | |
|
792 | break | |
|
793 | elif i==1: | |
|
794 | self.lagp1[n][j][self.bcounter-1]=c | |
|
795 | break | |
|
796 | elif i==2: | |
|
797 | self.lagp2[n][j][self.bcounter-1]=c | |
|
798 | break | |
|
799 | else: | |
|
800 | break | |
|
801 | ||
|
802 | else: | |
|
803 | ||
|
804 | while True: | |
|
805 | if i==0: | |
|
806 | self.lagp0[n][j][self.bcounter-1]=c+self.lagp0[n][j][self.bcounter-1] | |
|
807 | break | |
|
808 | elif i==1: | |
|
809 | self.lagp1[n][j][self.bcounter-1]=c+self.lagp1[n][j][self.bcounter-1] | |
|
810 | break | |
|
811 | elif i==2: | |
|
812 | self.lagp2[n][j][self.bcounter-1]=c+self.lagp2[n][j][self.bcounter-1] | |
|
813 | break | |
|
814 | else: | |
|
815 | break | |
|
816 | ||
|
817 | else: | |
|
818 | #c=c/self.cnorm | |
|
819 | if i==0: | |
|
820 | c=c/self.cnorm | |
|
821 | if k==self.dataOut.NSCAN: | |
|
822 | #if i==0: | |
|
823 | self.lagp3[n][j][self.bcounter-1]=c | |
|
824 | #print("n: ",n,"j: ",j,"iavg: ",self.bcounter-1) | |
|
825 | #print("lagp3_inside: ",self.lagp3[n][j][self.bcounter-1]) | |
|
826 | else: | |
|
827 | #if i==0: | |
|
828 | self.lagp3[n][j][self.bcounter-1]=c+self.lagp3[n][j][self.bcounter-1] | |
|
829 | ||
|
830 | ||
|
831 | ||
|
832 | ||
|
833 | #print("lagp2: ",self.lagp2[:,0,0]) | |
|
834 | self.lagp0[:,:,self.bcounter-1]=numpy.conj(self.lagp0[:,:,self.bcounter-1]) | |
|
835 | self.lagp1[:,:,self.bcounter-1]=numpy.conj(self.lagp1[:,:,self.bcounter-1]) | |
|
836 | self.lagp2[:,:,self.bcounter-1]=numpy.conj(self.lagp2[:,:,self.bcounter-1]) | |
|
837 | self.lagp3[:,:,self.bcounter-1]=numpy.conj(self.lagp3[:,:,self.bcounter-1]) | |
|
838 | #self.dataOut.flagNoData=0 | |
|
839 | #print(self.bcounter-1) | |
|
840 | #print("lagp2_conj: ",self.lagp2[:,0,self.bcounter-1]) | |
|
841 | #input() | |
|
842 | #self.dataOut.lagp3=self.lagp3 | |
|
843 | print("TEST") | |
|
844 | ||
|
845 | ||
|
846 | ||
|
847 | def lag_products_LP(self): | |
|
848 | ||
|
849 | #print("LP_init") | |
|
850 | #self.dataOut.flagNoData=1 | |
|
851 | buffer=self.dataOut.data | |
|
852 | #self.dataOut.flagNoData=0 | |
|
853 | if self.LP_products_aux==0: | |
|
854 | ||
|
855 | #self.dataOut.nptsfft2=150 | |
|
856 | self.cnorm=float((self.dataOut.nptsfft2LP-self.dataOut.NSCAN)/self.dataOut.NSCAN) | |
|
857 | ||
|
858 | ||
|
859 | #print("self.bcounter",self.bcounter) | |
|
860 | self.lagp0=numpy.zeros((self.dataOut.NLAG,self.dataOut.NRANGE,self.dataOut.NAVG),'complex64') | |
|
861 | self.lagp1=numpy.zeros((self.dataOut.NLAG,self.dataOut.NRANGE,self.dataOut.NAVG),'complex64') | |
|
862 | self.lagp2=numpy.zeros((self.dataOut.NLAG,self.dataOut.NRANGE,self.dataOut.NAVG),'complex64') | |
|
863 | self.lagp3=numpy.zeros((self.dataOut.NLAG,self.dataOut.NRANGE,self.dataOut.NAVG),'complex64') | |
|
864 | self.lagp4=numpy.zeros((self.dataOut.NLAG,self.dataOut.NRANGE,self.dataOut.NAVG),'complex64') | |
|
865 | self.LP_products_aux=1 | |
|
866 | ||
|
867 | #print(self.dataOut.data[0,0,0]) | |
|
868 | #self.dataOut.flagNoData =False | |
|
869 | for i in range(self.dataOut.NR): | |
|
870 | #print("inside i",i) | |
|
871 | buffer_dc=self.dataOut.dc[i] | |
|
872 | for j in range(self.dataOut.NRANGE): | |
|
873 | #print("inside j",j) | |
|
874 | #print(self.dataOut.read_samples) | |
|
875 | #input() | |
|
876 | range_for_n=numpy.min((self.dataOut.NRANGE-j,self.dataOut.NLAG)) | |
|
877 | for k in range(self.dataOut.nptsfft2LP): | |
|
878 | #print(self.dataOut.data[i][k][j]) | |
|
879 | #input() | |
|
880 | #print(self.dataOut.dc) | |
|
881 | #input() | |
|
882 | #aux_ac=0 | |
|
883 | buffer_aux=numpy.conj(buffer[i][k][j]-buffer_dc) | |
|
884 | #self.dataOut.flagNoData=0 | |
|
885 | for n in range(range_for_n): | |
|
886 | #for n in range(numpy.min((self.dataOut.NRANGE-j,self.dataOut.NLAG))): | |
|
887 | #print(numpy.shape(self.dataOut.data)) | |
|
888 | #input() | |
|
889 | #pass | |
|
890 | #self.dataOut.flagNoData=1 | |
|
891 | #c=2*buffer_aux | |
|
892 | #c=(self.dataOut.data[i][k][j]-self.dataOut.dc[i])*(numpy.conj(self.dataOut.data[i][k][j+n]-self.dataOut.dc[i])) | |
|
893 | #c=(buffer[i][k][j]-buffer_dc)*(numpy.conj(buffer[i][k][j+n])-buffer_dc) | |
|
894 | ||
|
895 | c=(buffer_aux)*(buffer[i][k][j+n]-buffer_dc) | |
|
896 | #c=(buffer[i][k][j])*(buffer[i][k][j+n]) | |
|
897 | #print("first: ",self.dataOut.data[i][k][j]-self.dataOut.dc[i]) | |
|
898 | #print("second: ",numpy.conj(self.dataOut.data[i][k][j+n]-self.dataOut.dc[i])) | |
|
899 | ||
|
900 | #print("c: ",c) | |
|
901 | #input() | |
|
902 | #print("n: ",n) | |
|
903 | #print("aux_ac",aux_ac) | |
|
904 | #print("data1:",self.dataOut.data[i][k][j]) | |
|
905 | #print("data2:",self.dataOut.data[i][k][j+n]) | |
|
906 | #print("dc: ",self.dataOut.dc[i]) | |
|
907 | #if aux_ac==2: | |
|
908 | #input() | |
|
909 | #aux_ac+=1 | |
|
910 | #print("GG") | |
|
911 | #print("inside n",n) | |
|
912 | #pass | |
|
913 | ||
|
914 | if k<self.dataOut.NSCAN: | |
|
915 | if k==0: | |
|
916 | if i==0: | |
|
917 | self.lagp0[n][j][self.bcounter-1]=c | |
|
918 | elif i==1: | |
|
919 | self.lagp1[n][j][self.bcounter-1]=c | |
|
920 | elif i==2: | |
|
921 | self.lagp2[n][j][self.bcounter-1]=c | |
|
922 | else: | |
|
923 | if i==0: | |
|
924 | self.lagp0[n][j][self.bcounter-1]=c+self.lagp0[n][j][self.bcounter-1] | |
|
925 | elif i==1: | |
|
926 | self.lagp1[n][j][self.bcounter-1]=c+self.lagp1[n][j][self.bcounter-1] | |
|
927 | elif i==2: | |
|
928 | self.lagp2[n][j][self.bcounter-1]=c+self.lagp2[n][j][self.bcounter-1] | |
|
929 | ||
|
930 | else: | |
|
931 | c=c/self.cnorm | |
|
932 | if k==self.dataOut.NSCAN: | |
|
933 | if i==0: | |
|
934 | self.lagp3[n][j][self.bcounter-1]=c | |
|
935 | #print("n: ",n,"j: ",j,"iavg: ",self.bcounter-1) | |
|
936 | #print("lagp3_inside: ",self.lagp3[n][j][self.bcounter-1]) | |
|
937 | else: | |
|
938 | if i==0: | |
|
939 | self.lagp3[n][j][self.bcounter-1]=c+self.lagp3[n][j][self.bcounter-1] | |
|
940 | ||
|
941 | ||
|
942 | ||
|
943 | #print("lagp2: ",self.lagp2[:,0,0]) | |
|
944 | self.lagp0[:,:,self.bcounter-1]=numpy.conj(self.lagp0[:,:,self.bcounter-1]) | |
|
945 | self.lagp1[:,:,self.bcounter-1]=numpy.conj(self.lagp1[:,:,self.bcounter-1]) | |
|
946 | self.lagp2[:,:,self.bcounter-1]=numpy.conj(self.lagp2[:,:,self.bcounter-1]) | |
|
947 | self.lagp3[:,:,self.bcounter-1]=numpy.conj(self.lagp3[:,:,self.bcounter-1]) | |
|
948 | #self.dataOut.flagNoData=0 | |
|
949 | #print(self.bcounter-1) | |
|
950 | #print("lagp2_conj: ",self.lagp2[:,0,self.bcounter-1]) | |
|
951 | #input() | |
|
952 | #self.dataOut.lagp3=self.lagp3 | |
|
953 | print("LP") | |
|
954 | ||
|
955 | ||
|
956 | def test_2(self): | |
|
957 | ||
|
958 | #print("LP_init") | |
|
959 | #self.dataOut.flagNoData=1 | |
|
960 | ||
|
961 | #self.dataOut.flagNoData=0 | |
|
962 | if self.LP_products_aux==0: | |
|
963 | ||
|
964 | #self.dataOut.nptsfft2=150 | |
|
965 | self.cnorm=float((self.dataOut.nptsfft2LP-self.dataOut.NSCAN)/self.dataOut.NSCAN) | |
|
966 | ||
|
967 | ||
|
968 | #print("self.bcounter",self.bcounter) | |
|
969 | self.lagp0=numpy.zeros((self.dataOut.NLAG,self.dataOut.NRANGE,self.dataOut.NAVG),'complex64') | |
|
970 | self.lagp1=numpy.zeros((self.dataOut.NLAG,self.dataOut.NRANGE,self.dataOut.NAVG),'complex64') | |
|
971 | self.lagp2=numpy.zeros((self.dataOut.NLAG,self.dataOut.NRANGE,self.dataOut.NAVG),'complex64') | |
|
972 | self.lagp3=numpy.zeros((self.dataOut.NLAG,self.dataOut.NRANGE,self.dataOut.NAVG),'complex64') | |
|
973 | self.lagp4=numpy.zeros((self.dataOut.NLAG,self.dataOut.NRANGE,self.dataOut.NAVG),'complex64') | |
|
974 | self.LP_products_aux=1 | |
|
975 | ||
|
976 | #print(self.dataOut.data[0,0,0]) | |
|
977 | #self.dataOut.flagNoData =False | |
|
978 | for i in range(self.dataOut.NR): | |
|
979 | #print("inside i",i) | |
|
980 | ||
|
981 | for j in range(self.dataOut.NRANGE): | |
|
982 | #print("inside j",j) | |
|
983 | #print(self.dataOut.read_samples) | |
|
984 | #input() | |
|
985 | ||
|
986 | for k in range(self.dataOut.nptsfft2LP): | |
|
987 | #print(self.dataOut.data[i][k][j]) | |
|
988 | #input() | |
|
989 | #print(self.dataOut.dc) | |
|
990 | #input() | |
|
991 | #aux_ac=0 | |
|
992 | ||
|
993 | #self.dataOut.flagNoData=0 | |
|
994 | ||
|
995 | for n in range(numpy.min((self.dataOut.NRANGE-j,self.dataOut.NLAG))): | |
|
996 | #print(numpy.shape(self.dataOut.data)) | |
|
997 | #input() | |
|
998 | #pass | |
|
999 | #self.dataOut.flagNoData=1 | |
|
1000 | #c=2*buffer_aux | |
|
1001 | c=(self.dataOut.data[i][k][j]-self.dataOut.dc[i])*(numpy.conj(self.dataOut.data[i][k][j+n]-self.dataOut.dc[i])) | |
|
1002 | #c=(buffer[i][k][j]-buffer_dc)*(numpy.conj(buffer[i][k][j+n])-buffer_dc) | |
|
1003 | ||
|
1004 | ||
|
1005 | #c=(buffer[i][k][j])*(buffer[i][k][j+n]) | |
|
1006 | #print("first: ",self.dataOut.data[i][k][j]-self.dataOut.dc[i]) | |
|
1007 | #print("second: ",numpy.conj(self.dataOut.data[i][k][j+n]-self.dataOut.dc[i])) | |
|
1008 | ||
|
1009 | #print("c: ",c) | |
|
1010 | #input() | |
|
1011 | #print("n: ",n) | |
|
1012 | #print("aux_ac",aux_ac) | |
|
1013 | #print("data1:",self.dataOut.data[i][k][j]) | |
|
1014 | #print("data2:",self.dataOut.data[i][k][j+n]) | |
|
1015 | #print("dc: ",self.dataOut.dc[i]) | |
|
1016 | #if aux_ac==2: | |
|
1017 | #input() | |
|
1018 | #aux_ac+=1 | |
|
1019 | #print("GG") | |
|
1020 | #print("inside n",n) | |
|
1021 | #pass | |
|
1022 | ||
|
1023 | if k<self.dataOut.NSCAN: | |
|
1024 | if k==0: | |
|
1025 | if i==0: | |
|
1026 | self.lagp0[n][j][self.bcounter-1]=c | |
|
1027 | elif i==1: | |
|
1028 | self.lagp1[n][j][self.bcounter-1]=c | |
|
1029 | elif i==2: | |
|
1030 | self.lagp2[n][j][self.bcounter-1]=c | |
|
1031 | else: | |
|
1032 | if i==0: | |
|
1033 | self.lagp0[n][j][self.bcounter-1]=c+self.lagp0[n][j][self.bcounter-1] | |
|
1034 | elif i==1: | |
|
1035 | self.lagp1[n][j][self.bcounter-1]=c+self.lagp1[n][j][self.bcounter-1] | |
|
1036 | elif i==2: | |
|
1037 | self.lagp2[n][j][self.bcounter-1]=c+self.lagp2[n][j][self.bcounter-1] | |
|
1038 | ||
|
1039 | else: | |
|
1040 | c=c/self.cnorm | |
|
1041 | if k==self.dataOut.NSCAN: | |
|
1042 | if i==0: | |
|
1043 | self.lagp3[n][j][self.bcounter-1]=c | |
|
1044 | #print("n: ",n,"j: ",j,"iavg: ",self.bcounter-1) | |
|
1045 | #print("lagp3_inside: ",self.lagp3[n][j][self.bcounter-1]) | |
|
1046 | else: | |
|
1047 | if i==0: | |
|
1048 | self.lagp3[n][j][self.bcounter-1]=c+self.lagp3[n][j][self.bcounter-1] | |
|
1049 | ||
|
1050 | ||
|
1051 | ||
|
1052 | #print("lagp2: ",self.lagp2[:,0,0]) | |
|
1053 | ||
|
1054 | #self.dataOut.flagNoData=0 | |
|
1055 | #print(self.bcounter-1) | |
|
1056 | #print("lagp2_conj: ",self.lagp2[:,0,self.bcounter-1]) | |
|
1057 | #input() | |
|
1058 | #self.dataOut.lagp3=self.lagp3 | |
|
1059 | print("LP") | |
|
1060 | ||
|
1061 | ||
|
1062 | def LP_median_estimates(self): | |
|
1063 | #print("lagp3: ",self.lagp3[:,0,0]) | |
|
1064 | #print("self.bcounter: ",self.bcounter) | |
|
1065 | if self.dataOut.flag_save==1: | |
|
1066 | ||
|
1067 | #print("lagp1: ",self.lagp1[0,0,:]) | |
|
1068 | #input() | |
|
1069 | ||
|
1070 | if self.lag_products_LP_median_estimates_aux==0: | |
|
1071 | self.output=numpy.zeros((self.dataOut.NLAG,self.dataOut.NRANGE,self.dataOut.NR),'complex64') | |
|
1072 | #sorts=numpy.zeros(128,'float32') | |
|
1073 | #self.dataOut.output_LP=None | |
|
1074 | self.lag_products_LP_median_estimates_aux=1 | |
|
1075 | ||
|
1076 | ||
|
1077 | for i in range(self.dataOut.NLAG): | |
|
1078 | for j in range(self.dataOut.NRANGE): | |
|
1079 | for l in range(4): #four outputs | |
|
1080 | ''' | |
|
1081 | for k in range(self.dataOut.NAVG): | |
|
1082 | #rsorts[k]=float(k) | |
|
1083 | if l==0: | |
|
1084 | #sorts[k]=self.lagp0[i,j,k].real | |
|
1085 | self.lagp0[i,j,k].real=sorted(self.lagp0[i,j,k].real) | |
|
1086 | if l==1: | |
|
1087 | #sorts[k]=self.lagp1[i,j,k].real | |
|
1088 | self.lagp1[i,j,k].real=sorted(self.lagp1[i,j,k].real) | |
|
1089 | if l==2: | |
|
1090 | #sorts[k]=self.lagp2[i,j,k].real | |
|
1091 | self.lagp2[i,j,k].real=sorted(self.lagp2[i,j,k].real) | |
|
1092 | if l==3: | |
|
1093 | #sorts[k]=self.lagp3[i,j,k].real | |
|
1094 | self.lagp3[i,j,k].real=sorted(self.lagp3[i,j,k].real) | |
|
1095 | ''' | |
|
1096 | ||
|
1097 | #sorts=sorted(sorts) | |
|
1098 | #self.lagp0[i,j,k].real=sorted(self.lagp0[i,j,k].real) | |
|
1099 | #self.lagp1[i,j,k].real=sorted(self.lagp1[i,j,k].real) | |
|
1100 | #self.lagp2[i,j,k].real=sorted(self.lagp2[i,j,k].real) | |
|
1101 | #self.lagp3[i,j,k].real=sorted(self.lagp3[i,j,k].real) | |
|
1102 | ||
|
1103 | for k in range(self.dataOut.NAVG): | |
|
1104 | ||
|
1105 | ||
|
1106 | ||
|
1107 | if k==0: | |
|
1108 | self.output[i,j,l]=0.0+0.j | |
|
1109 | ||
|
1110 | if l==0: | |
|
1111 | self.lagp0[i,j,:]=sorted(self.lagp0[i,j,:], key=lambda x: x.real) #sorted(self.lagp0[i,j,:].real) | |
|
1112 | ||
|
1113 | if l==1: | |
|
1114 | self.lagp1[i,j,:]=sorted(self.lagp1[i,j,:], key=lambda x: x.real) #sorted(self.lagp1[i,j,:].real) | |
|
1115 | if l==2: | |
|
1116 | self.lagp2[i,j,:]=sorted(self.lagp2[i,j,:], key=lambda x: x.real) #sorted(self.lagp2[i,j,:].real) | |
|
1117 | if l==3: | |
|
1118 | self.lagp3[i,j,:]=sorted(self.lagp3[i,j,:], key=lambda x: x.real) #sorted(self.lagp3[i,j,:].real) | |
|
1119 | ||
|
1120 | ||
|
1121 | if k>=self.dataOut.nkill/2 and k<self.dataOut.NAVG-self.dataOut.nkill/2: | |
|
1122 | if l==0: | |
|
1123 | ||
|
1124 | self.output[i,j,l]=self.output[i,j,l]+((float(self.dataOut.NAVG)/(float)(self.dataOut.NAVG-self.dataOut.nkill))*self.lagp0[i,j,k]) | |
|
1125 | if l==1: | |
|
1126 | #print("lagp1: ",self.lagp1[0,0,:]) | |
|
1127 | #input() | |
|
1128 | self.output[i,j,l]=self.output[i,j,l]+((float(self.dataOut.NAVG)/(float)(self.dataOut.NAVG-self.dataOut.nkill))*self.lagp1[i,j,k]) | |
|
1129 | #print("self.lagp1[i,j,k]: ",self.lagp1[i,j,k]) | |
|
1130 | #input() | |
|
1131 | if l==2: | |
|
1132 | self.output[i,j,l]=self.output[i,j,l]+((float(self.dataOut.NAVG)/(float)(self.dataOut.NAVG-self.dataOut.nkill))*self.lagp2[i,j,k]) | |
|
1133 | if l==3: | |
|
1134 | #print(numpy.shape(output)) | |
|
1135 | #print(numpy.shape(self.lagp3)) | |
|
1136 | #print("i: ",i,"j: ",j,"k: ",k) | |
|
1137 | ||
|
1138 | #a=((float(self.dataOut.NAVG)/(float)(self.dataOut.NAVG-self.dataOut.nkill))*self.lagp3[i,j,k]) | |
|
1139 | #print("self.lagp3[i,j,k]: ",self.lagp3[i,j,k]) | |
|
1140 | #input() | |
|
1141 | self.output[i,j,l]=self.output[i,j,l]+((float(self.dataOut.NAVG)/(float)(self.dataOut.NAVG-self.dataOut.nkill))*self.lagp3[i,j,k]) | |
|
1142 | #print(a) | |
|
1143 | #print("output[i,j,l]: ",output[i,j,l]) | |
|
1144 | #input() | |
|
1145 | ||
|
1146 | ||
|
1147 | self.dataOut.output_LP=self.output | |
|
1148 | #print(numpy.shape(sefl.dataOut.output_LP)) | |
|
1149 | #input() | |
|
1150 | #print("output: ",self.dataOut.output_LP[:,0,0]) | |
|
1151 | #input() | |
|
1152 | ||
|
1153 | ||
|
1154 | def remove_debris_LP(self): | |
|
1155 | ||
|
1156 | if self.dataOut.flag_save==1: | |
|
1157 | debris=numpy.zeros(self.dataOut.NRANGE,'float32') | |
|
1158 | #self.dataOut.debris_activated=0 | |
|
1159 | for j in range(0,3): | |
|
1160 | for i in range(self.dataOut.NRANGE): | |
|
1161 | if j==0: | |
|
1162 | debris[i]=10*numpy.log10(numpy.abs(self.dataOut.output_LP[j,i,0])) | |
|
1163 | else: | |
|
1164 | debris[i]+=10*numpy.log10(numpy.abs(self.dataOut.output_LP[j,i,0])) | |
|
1165 | ||
|
1166 | ''' | |
|
1167 | debris=10*numpy.log10(numpy.abs(self.dataOut.output_LP[0,:,0])) | |
|
1168 | ||
|
1169 | for j in range(1,3): | |
|
1170 | for i in range(self.dataOut.NRANGE): | |
|
1171 | debris[i]+=debris[i] | |
|
1172 | ''' | |
|
1173 | ||
|
1174 | thresh=8.0+4+4+4 | |
|
1175 | for i in range(47,100): | |
|
1176 | if ((debris[i-2]+debris[i-1]+debris[i]+debris[i+1])> | |
|
1177 | ((debris[i-12]+debris[i-11]+debris[i-10]+debris[i-9]+ | |
|
1178 | debris[i+12]+debris[i+11]+debris[i+10]+debris[i+9])/2.0+ | |
|
1179 | thresh)): | |
|
1180 | ||
|
1181 | self.dataOut.debris_activated=1 | |
|
1182 | #print("LP debris",i) | |
|
1183 | ||
|
1184 | ||
|
1185 | #print("self.debris",debris) | |
|
1186 | ||
|
1187 | ||
|
1188 | def remove_debris_DP(self): | |
|
1189 | ||
|
1190 | if self.dataOut.flag_save==1: | |
|
1191 | debris=numpy.zeros(self.dataOut.NDP,dtype='float32') | |
|
1192 | Range=numpy.arange(0,3000,15) | |
|
1193 | for k in range(2): #flip | |
|
1194 | for i in range(self.dataOut.NDP): # | |
|
1195 | debris[i]+=numpy.sqrt((self.dataOut.kaxbx[i,0,k]+self.dataOut.kayby[i,0,k])**2+(self.dataOut.kaybx[i,0,k]-self.dataOut.kaxby[i,0,k])**2) | |
|
1196 | ||
|
1197 | #print("debris: ",debris) | |
|
1198 | ||
|
1199 | if time.gmtime(self.dataOut.utctime).tm_hour > 11: | |
|
1200 | for i in range(2,self.dataOut.NDP-2): | |
|
1201 | if (debris[i]>3.0*debris[i-2] and | |
|
1202 | debris[i]>3.0*debris[i+2] and | |
|
1203 | Range[i]>200.0 and Range[i]<=540.0): | |
|
1204 | ||
|
1205 | self.dataOut.debris_activated=1 | |
|
1206 | #print("DP debris") | |
|
1207 | ||
|
1208 | ||
|
1209 | ||
|
1210 | ||
|
1211 | ||
|
1212 | ||
|
1213 | def run(self, experiment="", nlags_array=None, NLAG=None, NR=None, NRANGE=None, NCAL=None, DPL=None, | |
|
1214 | NDN=None, NDT=None, NDP=None, NLP=None, NSCAN=None, HDR_SIZE=None, DH=15, H0=None, LPMASK=None, | |
|
1215 | flags_array=None, | |
|
1216 | NPROFILE1=None, NPROFILE2=None, NPROFILES=None, NPROFILE=None, | |
|
1217 | lagind=None, lagfirst=None, | |
|
1218 | nptsfftx1=None): | |
|
1219 | ||
|
1220 | #self.dataOut.input_dat_type=input_dat_type | |
|
1221 | ||
|
1222 | self.dataOut.experiment=experiment | |
|
1223 | ||
|
1224 | #print(self.dataOut.experiment) | |
|
1225 | self.dataOut.nlags_array=nlags_array | |
|
1226 | self.dataOut.NLAG=NLAG | |
|
1227 | self.dataOut.NR=NR | |
|
1228 | self.dataOut.NRANGE=NRANGE | |
|
1229 | #print(self.dataOut.NRANGE) | |
|
1230 | self.dataOut.NCAL=NCAL | |
|
1231 | self.dataOut.DPL=DPL | |
|
1232 | self.dataOut.NDN=NDN | |
|
1233 | self.dataOut.NDT=NDT | |
|
1234 | self.dataOut.NDP=NDP | |
|
1235 | self.dataOut.NLP=NLP | |
|
1236 | self.dataOut.NSCAN=NSCAN | |
|
1237 | self.dataOut.HDR_SIZE=HDR_SIZE | |
|
1238 | self.dataOut.DH=float(DH) | |
|
1239 | self.dataOut.H0=H0 | |
|
1240 | self.dataOut.LPMASK=LPMASK | |
|
1241 | self.dataOut.flags_array=flags_array | |
|
1242 | ||
|
1243 | self.dataOut.NPROFILE1=NPROFILE1 | |
|
1244 | self.dataOut.NPROFILE2=NPROFILE2 | |
|
1245 | self.dataOut.NPROFILES=NPROFILES | |
|
1246 | self.dataOut.NPROFILE=NPROFILE | |
|
1247 | self.dataOut.lagind=lagind | |
|
1248 | self.dataOut.lagfirst=lagfirst | |
|
1249 | self.dataOut.nptsfftx1=nptsfftx1 | |
|
1250 | ||
|
1251 | ||
|
1252 | self.dataOut.copy(self.dataIn) | |
|
1253 | #print(self.dataOut.datatime) | |
|
1254 | #print(self.dataOut.ippSeconds_general) | |
|
1255 | #print("Data: ",numpy.shape(self.dataOut.data)) | |
|
1256 | #print("Data_after: ",self.dataOut.data[0,0,1]) | |
|
1257 | ## (4, 150, 334) | |
|
1258 | #print(self.dataOut.channelIndexList) | |
|
1259 | ||
|
1260 | #print(self.dataOut.timeInterval) | |
|
1261 | ||
|
1262 | ###NEWWWWWWW | |
|
1263 | self.dataOut.lat=-11.95 | |
|
1264 | self.dataOut.lon=-7687 | |
|
1265 | self.dataOut.debris_activated=0 | |
|
1266 | ||
|
1267 | #print(time.gmtime(self.dataOut.utctime).tm_hour) | |
|
1268 | #print(numpy.shape(self.dataOut.heightList)) | |
|
1269 | ||
|
1270 | ||
|
1271 | ||
|
1272 | class NewData(Operation): | |
|
1273 | def __init__(self, **kwargs): | |
|
1274 | ||
|
1275 | Operation.__init__(self, **kwargs) | |
|
1276 | ||
|
1277 | ||
|
1278 | ||
|
1279 | ||
|
1280 | ||
|
1281 | def run(self,dataOut): | |
|
1282 | ||
|
1283 | #print("SHAPE",numpy.shape(dataOut.kaxby)) | |
|
1284 | print("CurrentBlock",dataOut.CurrentBlock) | |
|
1285 | #print("DATAOUT",dataOut.kaxby) | |
|
1286 | #print("TRUE OR FALSE",numpy.shape(dataOut.kaxby)==()) | |
|
1287 | #print("SHAPE",numpy.shape(dataOut.kaxby)) | |
|
1288 | if numpy.shape(dataOutF.kax)!=(): ############VER SI SE PUEDE TRABAJAR CON dataOut.kaxby==None ##Puede ser cualquier k... | |
|
1289 | ||
|
1290 | print("NEWDATA",dataOut.kaxby) | |
|
1291 | ||
|
1292 | ||
|
1293 | ||
|
1294 | ||
|
1295 | ||
|
1296 | return dataOut | |
|
1297 | ||
|
1298 | ||
|
1299 | ||
|
1300 | ||
|
1301 | ||
|
1302 | ||
|
1303 | ||
|
1304 | ||
|
1305 | ||
|
1306 | ||
|
1307 | ||
|
1308 | ''' | |
|
1309 | ||
|
1310 | class PlotVoltageLag(Operation): | |
|
1311 | def __init__(self, **kwargs): | |
|
1312 | ||
|
1313 | Operation.__init__(self, **kwargs) | |
|
1314 | ||
|
1315 | ||
|
1316 | ||
|
1317 | self.kax=numpy.zeros((self.NDP,self.nlags_array,2),'float32') | |
|
1318 | def range(self,DH): | |
|
1319 | Range=numpy.arange(0,990,DH) | |
|
1320 | return Range | |
|
1321 | ||
|
1322 | ||
|
1323 | ||
|
1324 | def run(self,dataOut): | |
|
1325 | ||
|
1326 | ||
|
1327 | ||
|
1328 | #plt.subplot(1, 4, 1) | |
|
1329 | plt.plot(kax[:,0,0],Range,'r',linewidth=2.0) | |
|
1330 | plt.xlim(min(limit_min_plot1[12::,0,0]), max(limit_max_plot1[12::,0,0])) | |
|
1331 | plt.show() | |
|
1332 | ||
|
1333 | self.kax=numpy.zeros((self.NDP,self.nlags_array,2),'float32') | |
|
1334 | ||
|
1335 | return dataOut | |
|
1336 | ''' | |
|
1337 | ||
|
1338 | ||
|
1339 | ||
|
1340 | ||
|
1341 | ||
|
1342 | ||
|
1343 | ||
|
1344 | ||
|
1345 | ||
|
1346 | ||
|
1347 | ||
|
1348 | ||
|
1349 | ||
|
1350 | ||
|
1351 | ||
|
1352 | ||
|
1353 | ||
|
1354 | ||
|
1355 | ||
|
1356 | ||
|
1357 | ||
|
1358 | ||
|
1359 | ||
|
1360 | ||
|
1361 | ||
|
1362 | ||
|
1363 | ||
|
1364 | ||
|
1365 | ||
|
1366 | class Integration(Operation): | |
|
1367 | def __init__(self, **kwargs): | |
|
1368 | ||
|
1369 | Operation.__init__(self, **kwargs) | |
|
1370 | ||
|
1371 | ||
|
1372 | ||
|
1373 | self.counter=0 | |
|
1374 | self.aux=0 | |
|
1375 | self.aux2=1 | |
|
1376 | ||
|
1377 | def run(self,dataOut,nint=None): | |
|
1378 | ||
|
1379 | dataOut.nint=nint | |
|
1380 | dataOut.AUX=0 | |
|
1381 | dataOut.paramInterval=dataOut.nint*dataOut.header[7][0]*2 #GENERALIZAR EL 2 | |
|
1382 | #print("CurrentBlock: ",dataOut.CurrentBlock) | |
|
1383 | #print("date: ",dataOut.datatime) | |
|
1384 | #print("self.aux: ",self.aux) | |
|
1385 | #print("CurrentBlockAAAAAA: ",dataOut.CurrentBlock) | |
|
1386 | #print(dataOut.input_dat_type) | |
|
1387 | #print(dataOut.heightList) | |
|
1388 | ||
|
1389 | #print(dataOut.blocktime.ctime()) | |
|
1390 | ''' | |
|
1391 | if dataOut.input_dat_type: #when .dat data is read | |
|
1392 | #print(dataOut.realtime) | |
|
1393 | #print("OKODOKO") | |
|
1394 | #dataOut.flagNoData = False | |
|
1395 | #print(dataOut.flagNoData) | |
|
1396 | if self.aux2: | |
|
1397 | ||
|
1398 | self.noise=numpy.zeros(dataOut.NR,'float32') | |
|
1399 | ||
|
1400 | ||
|
1401 | padding=numpy.zeros(1,'int32') | |
|
1402 | ||
|
1403 | hsize=numpy.zeros(1,'int32') | |
|
1404 | bufsize=numpy.zeros(1,'int32') | |
|
1405 | nr=numpy.zeros(1,'int32') | |
|
1406 | ngates=numpy.zeros(1,'int32') ### ### ### 2 | |
|
1407 | time1=numpy.zeros(1,'uint64') # pos 3 | |
|
1408 | time2=numpy.zeros(1,'uint64') # pos 4 | |
|
1409 | lcounter=numpy.zeros(1,'int32') | |
|
1410 | groups=numpy.zeros(1,'int32') | |
|
1411 | system=numpy.zeros(4,'int8') # pos 7 | |
|
1412 | h0=numpy.zeros(1,'float32') | |
|
1413 | dh=numpy.zeros(1,'float32') | |
|
1414 | ipp=numpy.zeros(1,'float32') | |
|
1415 | process=numpy.zeros(1,'int32') | |
|
1416 | tx=numpy.zeros(1,'int32') | |
|
1417 | ||
|
1418 | ngates1=numpy.zeros(1,'int32') ### ### ### 13 | |
|
1419 | time0=numpy.zeros(1,'uint64') # pos 14 | |
|
1420 | nlags=numpy.zeros(1,'int32') | |
|
1421 | nlags1=numpy.zeros(1,'int32') | |
|
1422 | txb=numpy.zeros(1,'float32') ### ### ### 17 | |
|
1423 | time3=numpy.zeros(1,'uint64') # pos 18 | |
|
1424 | time4=numpy.zeros(1,'uint64') # pos 19 | |
|
1425 | h0_=numpy.zeros(1,'float32') | |
|
1426 | dh_=numpy.zeros(1,'float32') | |
|
1427 | ipp_=numpy.zeros(1,'float32') | |
|
1428 | txa_=numpy.zeros(1,'float32') | |
|
1429 | ||
|
1430 | pad=numpy.zeros(100,'int32') | |
|
1431 | ||
|
1432 | nbytes=numpy.zeros(1,'int32') | |
|
1433 | limits=numpy.zeros(1,'int32') | |
|
1434 | ngroups=numpy.zeros(1,'int32') ### ### ### 27 | |
|
1435 | #Make the header list | |
|
1436 | #header=[hsize,bufsize,nr,ngates,time1,time2,lcounter,groups,system,h0,dh,ipp,process,tx,padding,ngates1,time0,nlags,nlags1,padding,txb,time3,time4,h0_,dh_,ipp_,txa_,pad,nbytes,limits,padding,ngroups] | |
|
1437 | dataOut.header=[hsize,bufsize,nr,ngates,time1,time2,lcounter,groups,system,h0,dh,ipp,process,tx,ngates1,padding,time0,nlags,nlags1,padding,txb,time3,time4,h0_,dh_,ipp_,txa_,pad,nbytes,limits,padding,ngroups] | |
|
1438 | ||
|
1439 | ||
|
1440 | ||
|
1441 | dataOut.kax=numpy.zeros((dataOut.NDP,dataOut.DPL,2),'float32') | |
|
1442 | dataOut.kay=numpy.zeros((dataOut.NDP,dataOut.DPL,2),'float32') | |
|
1443 | dataOut.kbx=numpy.zeros((dataOut.NDP,dataOut.DPL,2),'float32') | |
|
1444 | dataOut.kby=numpy.zeros((dataOut.NDP,dataOut.DPL,2),'float32') | |
|
1445 | dataOut.kax2=numpy.zeros((dataOut.NDP,dataOut.DPL,2),'float32') | |
|
1446 | dataOut.kay2=numpy.zeros((dataOut.NDP,dataOut.DPL,2),'float32') | |
|
1447 | dataOut.kbx2=numpy.zeros((dataOut.NDP,dataOut.DPL,2),'float32') | |
|
1448 | dataOut.kby2=numpy.zeros((dataOut.NDP,dataOut.DPL,2),'float32') | |
|
1449 | dataOut.kaxbx=numpy.zeros((dataOut.NDP,dataOut.DPL,2),'float32') | |
|
1450 | dataOut.kaxby=numpy.zeros((dataOut.NDP,dataOut.DPL,2),'float32') | |
|
1451 | dataOut.kaybx=numpy.zeros((dataOut.NDP,dataOut.DPL,2),'float32') | |
|
1452 | dataOut.kayby=numpy.zeros((dataOut.NDP,dataOut.DPL,2),'float32') | |
|
1453 | dataOut.kaxay=numpy.zeros((dataOut.NDP,dataOut.DPL,2),'float32') | |
|
1454 | dataOut.kbxby=numpy.zeros((dataOut.NDP,dataOut.DPL,2),'float32') | |
|
1455 | ||
|
1456 | self.dataOut.final_cross_products=[dataOut.kax,dataOut.kay,dataOut.kbx,dataOut.kby,dataOut.kax2,dataOut.kay2,dataOut.kbx2,dataOut.kby2,dataOut.kaxbx,dataOut.kaxby,dataOut.kaybx,dataOut.kayby,dataOut.kaxay,dataOut.kbxby] | |
|
1457 | ||
|
1458 | self.inputfile_DP = open(dataOut.fname,"rb") | |
|
1459 | ||
|
1460 | ## read header the header first time | |
|
1461 | for i in range(len(dataOut.header)): | |
|
1462 | for j in range(len(dataOut.header[i])): | |
|
1463 | #print("len(header[i]) ",len(header[i])) | |
|
1464 | #input() | |
|
1465 | temp=self.inputfile_DP.read(int(dataOut.header[i].itemsize)) | |
|
1466 | if isinstance(dataOut.header[i][0], numpy.int32): | |
|
1467 | #print(struct.unpack('i', temp)[0]) | |
|
1468 | dataOut.header[i][0]=struct.unpack('i', temp)[0] | |
|
1469 | if isinstance(dataOut.header[i][0], numpy.uint64): | |
|
1470 | dataOut.header[i][0]=struct.unpack('q', temp)[0] | |
|
1471 | if isinstance(dataOut.header[i][0], numpy.int8): | |
|
1472 | dataOut.header[i][0]=struct.unpack('B', temp)[0] | |
|
1473 | if isinstance(dataOut.header[i][0], numpy.float32): | |
|
1474 | dataOut.header[i][0]=struct.unpack('f', temp)[0] | |
|
1475 | ||
|
1476 | ||
|
1477 | ||
|
1478 | ||
|
1479 | self.activator_No_Data=1 | |
|
1480 | ||
|
1481 | self.inputfile_DP.seek(0,0) | |
|
1482 | ||
|
1483 | #print("Repositioning to",self.npos," bytes, bufsize ", self.header[1][0]) | |
|
1484 | #self.inputfile.seek(self.npos, 0) | |
|
1485 | #print("inputfile.tell() ",self.inputfile.tell() ," npos : ", self.npos) | |
|
1486 | ||
|
1487 | self.npos=0 | |
|
1488 | ||
|
1489 | #if dataOut.nint < 0: | |
|
1490 | # dataOut.nint=-dataOut.nint | |
|
1491 | # sfile=os.stat(dataOut.fname) | |
|
1492 | # if (os.path.exists(dataOut.fname)==0): | |
|
1493 | # print("ERROR on STAT file: %s\n", dataOut.fname) | |
|
1494 | # self.npos=sfile.st_size - dataOut.nint*dataOut.header[1][0]# sfile.st_size - nint*header.bufsize | |
|
1495 | ||
|
1496 | self.start_another_day=False | |
|
1497 | if dataOut.new_time_date!=" ": | |
|
1498 | self.start_another_day=True | |
|
1499 | ||
|
1500 | ||
|
1501 | if self.start_another_day: | |
|
1502 | #print("Starting_at_another_day") | |
|
1503 | #new_time_date = "16/08/2013 09:51:43" | |
|
1504 | #new_time_seconds=time.mktime(time.strptime(new_time_date)) | |
|
1505 | #dataOut.new_time_date = "04/12/2019 09:21:21" | |
|
1506 | d = datetime.strptime(dataOut.new_time_date, "%d/%m/%Y %H:%M:%S") | |
|
1507 | new_time_seconds=time.mktime(d.timetuple()) | |
|
1508 | ||
|
1509 | d_2 = datetime.strptime(dataOut.new_ending_time, "%d/%m/%Y %H:%M:%S") | |
|
1510 | self.new_ending_time_seconds=time.mktime(d_2.timetuple()) | |
|
1511 | #print("new_time_seconds: ",new_time_seconds) | |
|
1512 | #input() | |
|
1513 | jumper=0 | |
|
1514 | ||
|
1515 | #if jumper>0 and nint>0: | |
|
1516 | while True: | |
|
1517 | sfile=os.stat(dataOut.fname) | |
|
1518 | ||
|
1519 | if (os.path.exists(dataOut.fname)==0): | |
|
1520 | print("ERROR on STAT file: %s\n",dataOut.fname) | |
|
1521 | self.npos=jumper*dataOut.nint*dataOut.header[1][0] #jump_blocks*header,bufsize | |
|
1522 | self.npos_next=(jumper+1)*dataOut.nint*dataOut.header[1][0] | |
|
1523 | self.inputfile_DP.seek(self.npos, 0) | |
|
1524 | jumper+=1 | |
|
1525 | for i in range(len(dataOut.header)): | |
|
1526 | for j in range(len(dataOut.header[i])): | |
|
1527 | #print("len(header[i]) ",len(header[i])) | |
|
1528 | #input() | |
|
1529 | temp=self.inputfile_DP.read(int(dataOut.header[i].itemsize)) | |
|
1530 | if isinstance(dataOut.header[i][0], numpy.int32): | |
|
1531 | #print(struct.unpack('i', temp)[0]) | |
|
1532 | dataOut.header[i][0]=struct.unpack('i', temp)[0] | |
|
1533 | if isinstance(dataOut.header[i][0], numpy.uint64): | |
|
1534 | dataOut.header[i][0]=struct.unpack('q', temp)[0] | |
|
1535 | if isinstance(dataOut.header[i][0], numpy.int8): | |
|
1536 | dataOut.header[i][0]=struct.unpack('B', temp)[0] | |
|
1537 | if isinstance(dataOut.header[i][0], numpy.float32): | |
|
1538 | dataOut.header[i][0]=struct.unpack('f', temp)[0] | |
|
1539 | ||
|
1540 | if self.npos==0: | |
|
1541 | if new_time_seconds<dataOut.header[4][0]: | |
|
1542 | break | |
|
1543 | #dataOut.flagNoData=1 | |
|
1544 | #return dataOut.flagNoData | |
|
1545 | ||
|
1546 | self.npos_aux=sfile.st_size - dataOut.nint*dataOut.header[1][0] | |
|
1547 | self.inputfile_DP.seek(self.npos_aux, 0) | |
|
1548 | ||
|
1549 | for i in range(len(dataOut.header)): | |
|
1550 | for j in range(len(dataOut.header[i])): | |
|
1551 | #print("len(header[i]) ",len(header[i])) | |
|
1552 | #input() | |
|
1553 | temp=self.inputfile_DP.read(int(dataOut.header[i].itemsize)) | |
|
1554 | if isinstance(dataOut.header[i][0], numpy.int32): | |
|
1555 | #print(struct.unpack('i', temp)[0]) | |
|
1556 | dataOut.header[i][0]=struct.unpack('i', temp)[0] | |
|
1557 | if isinstance(dataOut.header[i][0], numpy.uint64): | |
|
1558 | dataOut.header[i][0]=struct.unpack('q', temp)[0] | |
|
1559 | if isinstance(dataOut.header[i][0], numpy.int8): | |
|
1560 | dataOut.header[i][0]=struct.unpack('B', temp)[0] | |
|
1561 | if isinstance(dataOut.header[i][0], numpy.float32): | |
|
1562 | dataOut.header[i][0]=struct.unpack('f', temp)[0] | |
|
1563 | ||
|
1564 | if new_time_seconds>dataOut.header[4][0]: | |
|
1565 | print("No Data") | |
|
1566 | self.inputfile_DP.close() | |
|
1567 | sys.exit(1) | |
|
1568 | ||
|
1569 | self.inputfile_DP.seek(self.npos, 0) | |
|
1570 | ||
|
1571 | ||
|
1572 | ||
|
1573 | ||
|
1574 | if new_time_seconds==dataOut.header[4][0]: | |
|
1575 | #print("EQUALS") | |
|
1576 | break | |
|
1577 | ||
|
1578 | self.inputfile_DP.seek(self.npos_next, 0) | |
|
1579 | ||
|
1580 | for i in range(len(dataOut.header)): | |
|
1581 | for j in range(len(dataOut.header[i])): | |
|
1582 | #print("len(header[i]) ",len(header[i])) | |
|
1583 | #input() | |
|
1584 | temp=self.inputfile_DP.read(int(dataOut.header[i].itemsize)) | |
|
1585 | if isinstance(dataOut.header[i][0], numpy.int32): | |
|
1586 | #print(struct.unpack('i', temp)[0]) | |
|
1587 | dataOut.header[i][0]=struct.unpack('i', temp)[0] | |
|
1588 | if isinstance(dataOut.header[i][0], numpy.uint64): | |
|
1589 | dataOut.header[i][0]=struct.unpack('q', temp)[0] | |
|
1590 | if isinstance(dataOut.header[i][0], numpy.int8): | |
|
1591 | dataOut.header[i][0]=struct.unpack('B', temp)[0] | |
|
1592 | if isinstance(dataOut.header[i][0], numpy.float32): | |
|
1593 | dataOut.header[i][0]=struct.unpack('f', temp)[0] | |
|
1594 | ||
|
1595 | ||
|
1596 | if new_time_seconds<dataOut.header[4][0]: | |
|
1597 | break | |
|
1598 | ||
|
1599 | ||
|
1600 | ||
|
1601 | ||
|
1602 | ||
|
1603 | ||
|
1604 | ||
|
1605 | ||
|
1606 | #print("Repositioning to",self.npos," bytes, bufsize ", dataOut.header[1][0]) | |
|
1607 | self.inputfile_DP.seek(self.npos, 0) | |
|
1608 | #print("inputfile.tell() ",self.inputfile_DP.tell() ," npos : ", self.npos) | |
|
1609 | ||
|
1610 | self.aux2=0 | |
|
1611 | ||
|
1612 | ||
|
1613 | for ii in range(len(dataOut.header)): | |
|
1614 | for j in range(len(dataOut.header[ii])): | |
|
1615 | temp=self.inputfile_DP.read(int(dataOut.header[ii].itemsize)) | |
|
1616 | ||
|
1617 | if(b''==temp):# sizeof(header) | |
|
1618 | dataOut.flagDiscontinuousBlock=1 | |
|
1619 | #print("EOF \n\n\n\n") | |
|
1620 | #log.success("") | |
|
1621 | #self.inputfile_DP.close() | |
|
1622 | dataOut.error = True | |
|
1623 | #dataOut.flagNoData = True | |
|
1624 | #dataOut.stop=True | |
|
1625 | #return dataOut | |
|
1626 | #dataOut. | |
|
1627 | return dataOut | |
|
1628 | ||
|
1629 | #return dataOut.flagNoData | |
|
1630 | #writedb_head() | |
|
1631 | #outputfile.close() | |
|
1632 | #sys.exit(0) | |
|
1633 | #THE PROGRAM SHOULD END HERE | |
|
1634 | ||
|
1635 | if isinstance(dataOut.header[ii][0], numpy.int32): | |
|
1636 | #print(struct.unpack('i', temp)[0]) | |
|
1637 | dataOut.header[ii][0]=struct.unpack('i', temp)[0] | |
|
1638 | if isinstance(dataOut.header[ii][0], numpy.uint64): | |
|
1639 | dataOut.header[ii][0]=struct.unpack('q', temp)[0] | |
|
1640 | if isinstance(dataOut.header[ii][0], numpy.int8): | |
|
1641 | dataOut.header[ii][0]=struct.unpack('B', temp)[0] | |
|
1642 | if isinstance(dataOut.header[ii][0], numpy.float32): | |
|
1643 | dataOut.header[ii][0]=struct.unpack('f', temp)[0] | |
|
1644 | ||
|
1645 | ||
|
1646 | if self.start_another_day: | |
|
1647 | ||
|
1648 | if dataOut.header[4][0]>self.new_ending_time_seconds: | |
|
1649 | print("EOF \n") | |
|
1650 | if self.activator_No_Data: | |
|
1651 | print("No Data") | |
|
1652 | self.inputfile_DP.close() | |
|
1653 | #sys.exit(0) | |
|
1654 | dataOut.error = True | |
|
1655 | return dataOut | |
|
1656 | #print(self.activator_No_Data) | |
|
1657 | self.activator_No_Data=0 | |
|
1658 | #dataOut.TimeBlockDate_for_dp_power=dataOut.TimeBlockDate | |
|
1659 | #dataOut.TimeBlockSeconds_for_dp_power=time.mktime(time.strptime(dataOut.TimeBlockDate_for_dp_power)) | |
|
1660 | dataOut.TimeBlockSeconds_for_dp_power = dataOut.header[4][0]-((dataOut.nint-1)*dataOut.NAVG*2) | |
|
1661 | #print(dataOut.TimeBlockSeconds_for_dp_power) | |
|
1662 | dataOut.TimeBlockDate_for_dp_power=datetime.fromtimestamp(dataOut.TimeBlockSeconds_for_dp_power).strftime("%a %b %-d %H:%M:%S %Y") | |
|
1663 | #print("Date: ",dataOut.TimeBlockDate_for_dp_power) | |
|
1664 | #print("Seconds: ",dataOut.TimeBlockSeconds_for_dp_power) | |
|
1665 | dataOut.bd_time=time.gmtime(dataOut.TimeBlockSeconds_for_dp_power) | |
|
1666 | dataOut.year=dataOut.bd_time.tm_year+(dataOut.bd_time.tm_yday-1)/364.0 | |
|
1667 | dataOut.ut=dataOut.bd_time.tm_hour+dataOut.bd_time.tm_min/60.0+dataOut.bd_time.tm_sec/3600.0 | |
|
1668 | ||
|
1669 | ||
|
1670 | if dataOut.experiment=="HP": # NRANGE*NLAG*NR # np.zeros([total_samples*nprofiles],dtype='complex64') | |
|
1671 | temp=self.inputfile_DP.read(dataOut.NLAG*dataOut.NR*176*8) | |
|
1672 | ii=0 | |
|
1673 | for l in range(dataOut.NLAG): #lag | |
|
1674 | for r in range(dataOut.NR): # unflip and flip | |
|
1675 | for k in range(176): #RANGE## generalizar | |
|
1676 | struct.unpack('q', temp[ii:ii+8])[0] | |
|
1677 | ii=ii+8 | |
|
1678 | ||
|
1679 | ||
|
1680 | ||
|
1681 | #print("A: ",dataOut.kax) | |
|
1682 | for ind in range(len(self.dataOut.final_cross_products)): #final cross products | |
|
1683 | temp=self.inputfile_DP.read(dataOut.DPL*2*dataOut.NDT*4) #*4 bytes | |
|
1684 | ii=0 | |
|
1685 | #print("kabxys.shape ",kabxys.shape) | |
|
1686 | #print(kabxys) | |
|
1687 | for l in range(dataOut.DPL): #lag | |
|
1688 | for fl in range(2): # unflip and flip | |
|
1689 | for k in range(dataOut.NDT): #RANGE | |
|
1690 | self.dataOut.final_cross_products[ind][k,l,fl]=struct.unpack('f', temp[ii:ii+4])[0] | |
|
1691 | ii=ii+4 | |
|
1692 | #print("DPL*2*NDT*4 es: ", DPL*2*NDT*4) | |
|
1693 | #print("B: ",dataOut.kax) | |
|
1694 | ## read noise | |
|
1695 | temp=self.inputfile_DP.read(dataOut.NR*4) #*4 bytes | |
|
1696 | for ii in range(dataOut.NR): | |
|
1697 | self.noise[ii]=struct.unpack('f', temp[ii*4:(ii+1)*4])[0] | |
|
1698 | #print("NR*4 es: ", NR*4) | |
|
1699 | ||
|
1700 | ||
|
1701 | ################################END input_dat_type################################ | |
|
1702 | ''' | |
|
1703 | ||
|
1704 | #if dataOut.input_dat_type==0: | |
|
1705 | ||
|
1706 | if self.aux==1: | |
|
1707 | #print("CurrentBlockBBBBB: ",dataOut.CurrentBlock) | |
|
1708 | #print(dataOut.datatime) | |
|
1709 | dataOut.TimeBlockDate_for_dp_power=dataOut.TimeBlockDate | |
|
1710 | ||
|
1711 | #print("Date: ",dataOut.TimeBlockDate_for_dp_power) | |
|
1712 | dataOut.TimeBlockSeconds_for_dp_power=time.mktime(time.strptime(dataOut.TimeBlockDate_for_dp_power)) | |
|
1713 | #print("Seconds: ",dataOut.TimeBlockSeconds_for_dp_power) | |
|
1714 | dataOut.bd_time=time.gmtime(dataOut.TimeBlockSeconds_for_dp_power) | |
|
1715 | dataOut.year=dataOut.bd_time.tm_year+(dataOut.bd_time.tm_yday-1)/364.0 | |
|
1716 | dataOut.ut=dataOut.bd_time.tm_hour+dataOut.bd_time.tm_min/60.0+dataOut.bd_time.tm_sec/3600.0 | |
|
1717 | #print("date: ", dataOut.TimeBlockDate) | |
|
1718 | self.aux=0 | |
|
1719 | ||
|
1720 | if numpy.shape(dataOut.kax)!=(): | |
|
1721 | #print("SELFCOUNTER",self.counter) | |
|
1722 | #dataOut.flagNoData =True | |
|
1723 | if self.counter==0: | |
|
1724 | ''' | |
|
1725 | dataOut.kax_integrated=numpy.zeros((dataOut.NDP,dataOut.DPL,2),'float32') | |
|
1726 | dataOut.kay_integrated=numpy.zeros((dataOut.NDP,dataOut.DPL,2),'float32') | |
|
1727 | dataOut.kax2_integrated=numpy.zeros((dataOut.NDP,dataOut.DPL,2),'float32') | |
|
1728 | dataOut.kay2_integrated=numpy.zeros((dataOut.NDP,dataOut.DPL,2),'float32') | |
|
1729 | dataOut.kbx_integrated=numpy.zeros((dataOut.NDP,dataOut.DPL,2),'float32') | |
|
1730 | dataOut.kby_integrated=numpy.zeros((dataOut.NDP,dataOut.DPL,2),'float32') | |
|
1731 | dataOut.kbx2_integrated=numpy.zeros((dataOut.NDP,dataOut.DPL,2),'float32') | |
|
1732 | dataOut.kby2_integrated=numpy.zeros((dataOut.NDP,dataOut.DPL,2),'float32') | |
|
1733 | dataOut.kaxbx_integrated=numpy.zeros((dataOut.NDP,dataOut.DPL,2),'float32') | |
|
1734 | dataOut.kaxby_integrated=numpy.zeros((dataOut.NDP,dataOut.DPL,2),'float32') | |
|
1735 | dataOut.kaybx_integrated=numpy.zeros((dataOut.NDP,dataOut.DPL,2),'float32') | |
|
1736 | dataOut.kayby_integrated=numpy.zeros((dataOut.NDP,dataOut.DPL,2),'float32') | |
|
1737 | dataOut.kaxay_integrated=numpy.zeros((dataOut.NDP,dataOut.DPL,2),'float32') | |
|
1738 | dataOut.kbxby_integrated=numpy.zeros((dataOut.NDP,dataOut.DPL,2),'float32') | |
|
1739 | ''' | |
|
1740 | ||
|
1741 | tmpx=numpy.zeros((dataOut.header[15][0],dataOut.header[17][0],2),'float32') | |
|
1742 | dataOut.kabxys_integrated=[tmpx,tmpx,tmpx,tmpx,tmpx,tmpx,tmpx,tmpx,tmpx,tmpx,tmpx,tmpx,tmpx,tmpx] | |
|
1743 | #self.final_cross_products=[dataOut.kax,dataOut.kay,dataOut.kbx,dataOut.kby,dataOut.kax2,dataOut.kay2,dataOut.kbx2,dataOut.kby2,dataOut.kaxbx,dataOut.kaxby,dataOut.kaybx,dataOut.kayby,dataOut.kaxay,dataOut.kbxby] | |
|
1744 | ||
|
1745 | #print(numpy.shape(tmpx)) | |
|
1746 | if self.counter < dataOut.nint: | |
|
1747 | #if dataOut.input_dat_type==0: | |
|
1748 | dataOut.final_cross_products=[dataOut.kax,dataOut.kay,dataOut.kbx,dataOut.kby,dataOut.kax2,dataOut.kay2,dataOut.kbx2,dataOut.kby2,dataOut.kaxbx,dataOut.kaxby,dataOut.kaybx,dataOut.kayby,dataOut.kaxay,dataOut.kbxby] | |
|
1749 | ||
|
1750 | ''' | |
|
1751 | dataOut.kax_integrated=dataOut.kax_integrated+dataOut.kax | |
|
1752 | dataOut.kay_integrated=dataOut.kay_integrated+dataOut.kay | |
|
1753 | dataOut.kax2_integrated=dataOut.kax2_integrated+dataOut.kax2 | |
|
1754 | dataOut.kay2_integrated=dataOut.kay2_integrated+dataOut.kay2 | |
|
1755 | dataOut.kbx_integrated=dataOut.kbx_integrated+dataOut.kbx | |
|
1756 | dataOut.kby_integrated=dataOut.kby_integrated+dataOut.kby | |
|
1757 | dataOut.kbx2_integrated=dataOut.kbx2_integrated+dataOut.kbx2 | |
|
1758 | dataOut.kby2_integrated=dataOut.kby2_integrated+dataOut.kby2 | |
|
1759 | dataOut.kaxbx_integrated=dataOut.kaxbx_integrated+dataOut.kaxbx | |
|
1760 | dataOut.kaxby_integrated=dataOut.kaxby_integrated+dataOut.kaxby | |
|
1761 | dataOut.kaybx_integrated=dataOut.kaybx_integrated+dataOut.kaybx | |
|
1762 | dataOut.kayby_integrated=dataOut.kayby_integrated+dataOut.kayby | |
|
1763 | dataOut.kaxay_integrated=dataOut.kaxay_integrated+dataOut.kaxbx | |
|
1764 | dataOut.kbxby_integrated=dataOut.kbxby_integrated+dataOut.kbxby | |
|
1765 | #print("KAX_BEFORE: ",self.kax_integrated) | |
|
1766 | ''' | |
|
1767 | #print("self.final_cross_products[0]: ",self.final_cross_products[0]) | |
|
1768 | ||
|
1769 | for ind in range(len(dataOut.kabxys_integrated)): #final cross products | |
|
1770 | dataOut.kabxys_integrated[ind]=dataOut.kabxys_integrated[ind]+dataOut.final_cross_products[ind] | |
|
1771 | #print("ataOut.kabxys_integrated[0]: ",dataOut.kabxys_integrated[0]) | |
|
1772 | ||
|
1773 | self.counter+=1 | |
|
1774 | if self.counter==dataOut.nint-1: | |
|
1775 | self.aux=1 | |
|
1776 | #dataOut.TimeBlockDate_for_dp_power=dataOut.TimeBlockDate | |
|
1777 | if self.counter==dataOut.nint: | |
|
1778 | ||
|
1779 | #dataOut.flagNoData =False | |
|
1780 | ||
|
1781 | self.counter=0 | |
|
1782 | dataOut.AUX=1 | |
|
1783 | #self.aux=1 | |
|
1784 | #print("KAXBY_INTEGRATED: ",dataOut.kaxby_integrated) | |
|
1785 | ||
|
1786 | ''' | |
|
1787 | else : | |
|
1788 | #dataOut.kax_integrated=self.kax_integrated | |
|
1789 | self.counter=0 | |
|
1790 | ||
|
1791 | ||
|
1792 | #print("CurrentBlock: ", dataOut.CurrentBlock) | |
|
1793 | print("KAX_INTEGRATED: ",self.kax_integrated) | |
|
1794 | #print("nint: ",nint) | |
|
1795 | ''' | |
|
1796 | ||
|
1797 | ##print("CurrentBlock: ", dataOut.CurrentBlock) | |
|
1798 | ##print("KAX_INTEGRATED: ",dataOut.kax_integrated) | |
|
1799 | ||
|
1800 | ||
|
1801 | return dataOut | |
|
1802 | ||
|
1803 | ||
|
1804 | ||
|
1805 | ||
|
1806 | ||
|
1807 | ||
|
1808 | ||
|
1809 | ||
|
1810 | class SumLagProducts_Old(Operation): | |
|
1811 | def __init__(self, **kwargs): | |
|
1812 | ||
|
1813 | Operation.__init__(self, **kwargs) | |
|
1814 | #dataOut.rnint2=numpy.zeros(dataOut.nlags_array,'float32') | |
|
1815 | ||
|
1816 | ||
|
1817 | def run(self,dataOut): | |
|
1818 | ||
|
1819 | if dataOut.AUX: #Solo cuando ya hizo la intregacion se ejecuta | |
|
1820 | ||
|
1821 | ||
|
1822 | dataOut.rnint2=numpy.zeros(dataOut.header[17][0],'float32') | |
|
1823 | #print(dataOut.experiment) | |
|
1824 | if dataOut.experiment=="DP": | |
|
1825 | for l in range(dataOut.header[17][0]): | |
|
1826 | dataOut.rnint2[l]=1.0/(dataOut.nint*dataOut.header[7][0]*12.0) | |
|
1827 | ||
|
1828 | ||
|
1829 | if dataOut.experiment=="HP": | |
|
1830 | for l in range(dataOut.header[17][0]): | |
|
1831 | if(l==0 or (l>=3 and l <=6)): | |
|
1832 | dataOut.rnint2[l]=0.5/float(dataOut.nint*dataOut.header[7][0]*16.0) | |
|
1833 | else: | |
|
1834 | dataOut.rnint2[l]=0.5/float(dataOut.nint*dataOut.header[7][0]*8.0) | |
|
1835 | #print(dataOut.rnint2) | |
|
1836 | for l in range(dataOut.header[17][0]): | |
|
1837 | ||
|
1838 | dataOut.kabxys_integrated[4][:,l,0]=(dataOut.kabxys_integrated[4][:,l,0]+dataOut.kabxys_integrated[4][:,l,1])*dataOut.rnint2[l] | |
|
1839 | dataOut.kabxys_integrated[5][:,l,0]=(dataOut.kabxys_integrated[5][:,l,0]+dataOut.kabxys_integrated[5][:,l,1])*dataOut.rnint2[l] | |
|
1840 | dataOut.kabxys_integrated[6][:,l,0]=(dataOut.kabxys_integrated[6][:,l,0]+dataOut.kabxys_integrated[6][:,l,1])*dataOut.rnint2[l] | |
|
1841 | dataOut.kabxys_integrated[7][:,l,0]=(dataOut.kabxys_integrated[7][:,l,0]+dataOut.kabxys_integrated[7][:,l,1])*dataOut.rnint2[l] | |
|
1842 | ||
|
1843 | dataOut.kabxys_integrated[8][:,l,0]=(dataOut.kabxys_integrated[8][:,l,0]-dataOut.kabxys_integrated[8][:,l,1])*dataOut.rnint2[l] | |
|
1844 | dataOut.kabxys_integrated[9][:,l,0]=(dataOut.kabxys_integrated[9][:,l,0]-dataOut.kabxys_integrated[9][:,l,1])*dataOut.rnint2[l] | |
|
1845 | dataOut.kabxys_integrated[10][:,l,0]=(dataOut.kabxys_integrated[10][:,l,0]-dataOut.kabxys_integrated[10][:,l,1])*dataOut.rnint2[l] | |
|
1846 | dataOut.kabxys_integrated[11][:,l,0]=(dataOut.kabxys_integrated[11][:,l,0]-dataOut.kabxys_integrated[11][:,l,1])*dataOut.rnint2[l] | |
|
1847 | ||
|
1848 | ||
|
1849 | #print("Final Integration: ",dataOut.kabxys_integrated[4][:,l,0]) | |
|
1850 | ||
|
1851 | ||
|
1852 | ||
|
1853 | ||
|
1854 | ||
|
1855 | ||
|
1856 | return dataOut | |
|
1857 | ||
|
1858 | ||
|
1859 | ||
|
1860 | ||
|
1861 | ||
|
1862 | ||
|
1863 | ||
|
1864 | ||
|
1865 | ||
|
1866 | class BadHeights_Old(Operation): | |
|
1867 | def __init__(self, **kwargs): | |
|
1868 | ||
|
1869 | Operation.__init__(self, **kwargs) | |
|
1870 | ||
|
1871 | ||
|
1872 | ||
|
1873 | def run(self,dataOut): | |
|
1874 | ||
|
1875 | ||
|
1876 | if dataOut.AUX==1: | |
|
1877 | dataOut.ibad=numpy.zeros((dataOut.header[15][0],dataOut.header[17][0]),'int32') | |
|
1878 | ||
|
1879 | for j in range(dataOut.header[15][0]): | |
|
1880 | for l in range(dataOut.header[17][0]): | |
|
1881 | ip1=j+dataOut.header[15][0]*(0+2*l) | |
|
1882 | if( (dataOut.kabxys_integrated[5][j,l,0] <= 0.) or (dataOut.kabxys_integrated[4][j,l,0] <= 0.) or (dataOut.kabxys_integrated[7][j,l,0] <= 0.) or (dataOut.kabxys_integrated[6][j,l,0] <= 0.)): | |
|
1883 | dataOut.ibad[j][l]=1 | |
|
1884 | else: | |
|
1885 | dataOut.ibad[j][l]=0 | |
|
1886 | #print("ibad: ",dataOut.ibad) | |
|
1887 | ||
|
1888 | ||
|
1889 | ||
|
1890 | return dataOut | |
|
1891 | ||
|
1892 | ||
|
1893 | ||
|
1894 | ||
|
1895 | ||
|
1896 | ||
|
1897 | ||
|
1898 | ||
|
1899 | ||
|
1900 | ||
|
1901 | ||
|
1902 | ||
|
1903 | ||
|
1904 | ||
|
1905 | ||
|
1906 | ||
|
1907 | class NoisePower_old(Operation): | |
|
1908 | def __init__(self, **kwargs): | |
|
1909 | ||
|
1910 | Operation.__init__(self, **kwargs) | |
|
1911 | ||
|
1912 | def hildebrand(self,dataOut,data): | |
|
1913 | #print("data ",data ) | |
|
1914 | divider=10 # divider was originally 10 | |
|
1915 | noise=0.0 | |
|
1916 | n1=0 | |
|
1917 | n2=int(dataOut.header[15][0]/2) | |
|
1918 | sorts= sorted(data) | |
|
1919 | ||
|
1920 | nums_min= dataOut.header[15][0]/divider | |
|
1921 | if((dataOut.header[15][0]/divider)> 2): | |
|
1922 | nums_min= int(dataOut.header[15][0]/divider) | |
|
1923 | else: | |
|
1924 | nums_min=2 | |
|
1925 | sump=0.0 | |
|
1926 | sumq=0.0 | |
|
1927 | j=0 | |
|
1928 | cont=1 | |
|
1929 | while( (cont==1) and (j<n2)): | |
|
1930 | sump+=sorts[j+n1] | |
|
1931 | sumq+= sorts[j+n1]*sorts[j+n1] | |
|
1932 | t3= sump/(j+1) | |
|
1933 | j=j+1 | |
|
1934 | if(j> nums_min): | |
|
1935 | rtest= float(j/(j-1)) +1.0/dataOut.header[7][0] | |
|
1936 | t1= (sumq*j) | |
|
1937 | t2=(rtest*sump*sump) | |
|
1938 | if( (t1/t2) > 0.990): | |
|
1939 | j=j-1 | |
|
1940 | sump-= sorts[j+n1] | |
|
1941 | sumq-=sorts[j+n1]*sorts[j+n1] | |
|
1942 | cont= 0 | |
|
1943 | ||
|
1944 | noise= sump/j | |
|
1945 | stdv=numpy.sqrt((sumq- noise*noise)/(j-1)) | |
|
1946 | return noise | |
|
1947 | ||
|
1948 | def run(self,dataOut): | |
|
1949 | ||
|
1950 | if dataOut.AUX==1: | |
|
1951 | ||
|
1952 | #print("ax2 shape ",ax2.shape) | |
|
1953 | p=numpy.zeros((dataOut.header[2][0],dataOut.header[15][0],dataOut.header[17][0]),'float32') | |
|
1954 | av=numpy.zeros(dataOut.header[15][0],'float32') | |
|
1955 | dataOut.pnoise=numpy.zeros(dataOut.header[2][0],'float32') | |
|
1956 | ||
|
1957 | p[0,:,:]=dataOut.kabxys_integrated[4][:,:,0]+dataOut.kabxys_integrated[5][:,:,0] #total power for channel 0, just pulse with non-flip | |
|
1958 | p[1,:,:]=dataOut.kabxys_integrated[6][:,:,0]+dataOut.kabxys_integrated[7][:,:,0] #total power for channel 1 | |
|
1959 | ||
|
1960 | #print("p[0,:,:] ",p[0,:,:]) | |
|
1961 | #print("p[1,:,:] ",p[1,:,:]) | |
|
1962 | ||
|
1963 | for i in range(dataOut.header[2][0]): | |
|
1964 | dataOut.pnoise[i]=0.0 | |
|
1965 | for k in range(dataOut.header[17][0]): | |
|
1966 | dataOut.pnoise[i]+= self.hildebrand(dataOut,p[i,:,k]) | |
|
1967 | #print("dpl ",k, "pnoise[",i,"] ",pnoise[i] ) | |
|
1968 | dataOut.pnoise[i]=dataOut.pnoise[i]/dataOut.header[17][0] | |
|
1969 | ||
|
1970 | ||
|
1971 | #print("POWERNOISE: ",dataOut.pnoise) | |
|
1972 | dataOut.pan=1.0*dataOut.pnoise[0] # weights could change | |
|
1973 | dataOut.pbn=1.0*dataOut.pnoise[1] # weights could change | |
|
1974 | #print("dataOut.pan ",dataOut.pan, " dataOut.pbn ",dataOut.pbn) | |
|
1975 | #print("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAa") | |
|
1976 | ||
|
1977 | #print("POWERNOISE: ",dataOut.pnoise) | |
|
1978 | ||
|
1979 | ||
|
1980 | return dataOut | |
|
1981 | ||
|
1982 | ||
|
1983 | ||
|
1984 | ||
|
1985 | ||
|
1986 | ||
|
1987 | ||
|
1988 | ||
|
1989 | class double_pulse_ACFs(Operation): | |
|
1990 | def __init__(self, **kwargs): | |
|
1991 | ||
|
1992 | Operation.__init__(self, **kwargs) | |
|
1993 | self.aux=1 | |
|
1994 | ||
|
1995 | def run(self,dataOut): | |
|
1996 | dataOut.pairsList=None | |
|
1997 | if dataOut.AUX==1: | |
|
1998 | dataOut.igcej=numpy.zeros((dataOut.header[15][0],dataOut.header[17][0]),'int32') | |
|
1999 | ||
|
2000 | if self.aux==1: | |
|
2001 | dataOut.rhor=numpy.zeros((dataOut.header[15][0],dataOut.header[17][0]), dtype=float) | |
|
2002 | dataOut.rhoi=numpy.zeros((dataOut.header[15][0],dataOut.header[17][0]), dtype=float) | |
|
2003 | dataOut.sdp=numpy.zeros((dataOut.header[15][0],dataOut.header[17][0]), dtype=float) | |
|
2004 | dataOut.sd=numpy.zeros((dataOut.header[15][0],dataOut.header[17][0]), dtype=float) | |
|
2005 | #dataOut.igcej=numpy.zeros((dataOut.NDP,dataOut.nlags_array),'int32') | |
|
2006 | dataOut.p=numpy.zeros((dataOut.header[15][0],dataOut.header[17][0]), dtype=float) | |
|
2007 | dataOut.alag=numpy.zeros(dataOut.header[15][0],'float32') | |
|
2008 | for l in range(dataOut.header[17][0]): | |
|
2009 | dataOut.alag[l]=l*dataOut.header[10][0]*2.0/150.0 | |
|
2010 | self.aux=0 | |
|
2011 | sn4=dataOut.pan*dataOut.pbn | |
|
2012 | rhorn=0 | |
|
2013 | rhoin=0 | |
|
2014 | #p=np.zeros((ndt,dpl), dtype=float) | |
|
2015 | panrm=numpy.zeros((dataOut.header[15][0],dataOut.header[17][0]), dtype=float) | |
|
2016 | ||
|
2017 | ||
|
2018 | for i in range(dataOut.header[15][0]): | |
|
2019 | for j in range(dataOut.header[17][0]): | |
|
2020 | ################# Total power | |
|
2021 | pa=numpy.abs(dataOut.kabxys_integrated[4][i,j,0]+dataOut.kabxys_integrated[5][i,j,0]) | |
|
2022 | pb=numpy.abs(dataOut.kabxys_integrated[6][i,j,0]+dataOut.kabxys_integrated[7][i,j,0]) | |
|
2023 | #print("PA",pb) | |
|
2024 | st4=pa*pb | |
|
2025 | dataOut.p[i,j]=pa+pb-(dataOut.pan+dataOut.pbn) | |
|
2026 | dataOut.sdp[i,j]=2*dataOut.rnint2[j]*((pa+pb)*(pa+pb)) | |
|
2027 | ## ACF | |
|
2028 | rhorp=dataOut.kabxys_integrated[8][i,j,0]+dataOut.kabxys_integrated[11][i,j,0] | |
|
2029 | rhoip=dataOut.kabxys_integrated[10][i,j,0]-dataOut.kabxys_integrated[9][i,j,0] | |
|
2030 | if ((pa>dataOut.pan)&(pb>dataOut.pbn)): | |
|
2031 | #print("dataOut.pnoise[0]: ",dataOut.pnoise[0]) | |
|
2032 | #print("dataOut.pnoise[1]: ",dataOut.pnoise[1]) | |
|
2033 | #print("OKKKKKKKKKKKKKKK") | |
|
2034 | ss4=numpy.abs((pa-dataOut.pan)*(pb-dataOut.pbn)) | |
|
2035 | #print("ss4: ",ss4) | |
|
2036 | #print("OKKKKKKKKKKKKKKK") | |
|
2037 | panrm[i,j]=math.sqrt(ss4) | |
|
2038 | rnorm=1/panrm[i,j] | |
|
2039 | #print("rnorm: ",rnorm)get_number_density | |
|
2040 | #print("OKKKKKKKKKKKKKKK") | |
|
2041 | ||
|
2042 | ## ACF | |
|
2043 | dataOut.rhor[i,j]=rhorp*rnorm | |
|
2044 | dataOut.rhoi[i,j]=rhoip*rnorm | |
|
2045 | #print("rhoi: ",dataOut.rhoi) | |
|
2046 | #print("OKKKKKKKKKKKKKKK") | |
|
2047 | ############# Compute standard error for ACF | |
|
2048 | stoss4=st4/ss4 | |
|
2049 | snoss4=sn4/ss4 | |
|
2050 | rp2=((rhorp*rhorp)+(rhoip*rhoip))/st4 | |
|
2051 | rn2=((rhorn*rhorn)+(rhoin*rhoin))/sn4 | |
|
2052 | rs2=(dataOut.rhor[i,j]*dataOut.rhor[i,j])+(dataOut.rhoi[i,j]*dataOut.rhoi[i,j]) | |
|
2053 | st=1.0+rs2*(stoss4-(2*math.sqrt(stoss4*snoss4))) | |
|
2054 | stn=1.0+rs2*(snoss4-(2*math.sqrt(stoss4*snoss4))) | |
|
2055 | dataOut.sd[i,j]=((stoss4*((1.0+rp2)*st+(2.0*rp2*rs2*snoss4)-4.0*math.sqrt(rs2*rp2)))+(0.25*snoss4*((1.0+rn2)*stn+(2.0*rn2*rs2*stoss4)-4.0*math.sqrt(rs2*rn2))))*dataOut.rnint2[j] | |
|
2056 | dataOut.sd[i,j]=numpy.abs(dataOut.sd[i,j]) | |
|
2057 | #print("sd: ",dataOut.sd) | |
|
2058 | #print("OKKKKKKKKKKKKKKK") | |
|
2059 | else: #default values for bad points | |
|
2060 | rnorm=1/math.sqrt(st4) | |
|
2061 | dataOut.sd[i,j]=1.e30 | |
|
2062 | dataOut.ibad[i,j]=4 | |
|
2063 | dataOut.rhor[i,j]=rhorp*rnorm | |
|
2064 | dataOut.rhoi[i,j]=rhoip*rnorm | |
|
2065 | if ((pa/dataOut.pan-1.0)>2.25*(pb/dataOut.pbn-1.0)): | |
|
2066 | dataOut.igcej[i,j]=1 | |
|
2067 | ||
|
2068 | #print("sdp",dataOut.sdp) | |
|
2069 | ||
|
2070 | return dataOut | |
|
2071 | ||
|
2072 | ||
|
2073 | ||
|
2074 | ||
|
2075 | ||
|
2076 | ||
|
2077 | ||
|
2078 | class faraday_angle_and_power_double_pulse(Operation): | |
|
2079 | def __init__(self, **kwargs): | |
|
2080 | ||
|
2081 | Operation.__init__(self, **kwargs) | |
|
2082 | self.aux=1 | |
|
2083 | ||
|
2084 | def run(self,dataOut): | |
|
2085 | #dataOut.NRANGE=NRANGE | |
|
2086 | #dataOut.H0=H0 | |
|
2087 | ######### H0 Y NRANGE SON PARAMETROS? | |
|
2088 | ||
|
2089 | if dataOut.AUX==1: | |
|
2090 | if self.aux==1: | |
|
2091 | dataOut.h2=numpy.zeros(dataOut.header[15][0],'float32') | |
|
2092 | dataOut.range1=numpy.zeros(dataOut.header[15][0],order='F',dtype='float32') | |
|
2093 | dataOut.sdn2=numpy.zeros(dataOut.header[15][0],'float32') | |
|
2094 | dataOut.ph2=numpy.zeros(dataOut.header[15][0],'float32') | |
|
2095 | dataOut.sdp2=numpy.zeros(dataOut.header[15][0],'float32') | |
|
2096 | dataOut.ibd=numpy.zeros(dataOut.header[15][0],'float32') | |
|
2097 | dataOut.phi=numpy.zeros(dataOut.header[15][0],'float32') | |
|
2098 | self.aux=0 | |
|
2099 | #print("p: ",dataOut.p) | |
|
2100 | ||
|
2101 | ||
|
2102 | for i in range(dataOut.header[15][0]): | |
|
2103 | dataOut.range1[i]=dataOut.header[9][0] + i*dataOut.header[10][0] # (float) header.h0 + (float)i * header.dh | |
|
2104 | dataOut.h2[i]=dataOut.range1[i]**2 | |
|
2105 | ||
|
2106 | #print("sd: ",dataOut.sd) | |
|
2107 | #print("OIKKKKKKKKKKKKKKK") | |
|
2108 | #print("ibad: ",dataOut.ibad) | |
|
2109 | #print("igcej: ",dataOut.igcej) | |
|
2110 | for j in range(dataOut.header[15][0]): | |
|
2111 | dataOut.ph2[j]=0. | |
|
2112 | dataOut.sdp2[j]=0. | |
|
2113 | ri=dataOut.rhoi[j][0]/dataOut.sd[j][0] | |
|
2114 | rr=dataOut.rhor[j][0]/dataOut.sd[j][0] | |
|
2115 | dataOut.sdn2[j]=1./dataOut.sd[j][0] | |
|
2116 | #print("sdn2: ",dataOut.sdn2) | |
|
2117 | #print("OIKKKKKKKKKKKKKKK") | |
|
2118 | pt=0.# // total power | |
|
2119 | st=0.# // total signal | |
|
2120 | ibt=0# // bad lags | |
|
2121 | ns=0# // no. good lags | |
|
2122 | for l in range(dataOut.header[17][0]): | |
|
2123 | #add in other lags if outside of e-jet contamination | |
|
2124 | if( (dataOut.igcej[j][l] == 0) and (dataOut.ibad[j][l] == 0) ): | |
|
2125 | #print("dataOut.p[j][l]: ",dataOut.p[j][l]) | |
|
2126 | dataOut.ph2[j]+=dataOut.p[j][l]/dataOut.sdp[j][l] | |
|
2127 | dataOut.sdp2[j]=dataOut.sdp2[j]+1./dataOut.sdp[j][l] | |
|
2128 | ns+=1 | |
|
2129 | ||
|
2130 | pt+=dataOut.p[j][l]/dataOut.sdp[j][l] | |
|
2131 | st+=1./dataOut.sdp[j][l] | |
|
2132 | ibt|=dataOut.ibad[j][l]; | |
|
2133 | #print("pt: ",pt) | |
|
2134 | #print("st: ",st) | |
|
2135 | if(ns!= 0): | |
|
2136 | dataOut.ibd[j]=0 | |
|
2137 | dataOut.ph2[j]=dataOut.ph2[j]/dataOut.sdp2[j] | |
|
2138 | dataOut.sdp2[j]=1./dataOut.sdp2[j] | |
|
2139 | else: | |
|
2140 | dataOut.ibd[j]=ibt | |
|
2141 | dataOut.ph2[j]=pt/st | |
|
2142 | #print("ph2: ",dataOut.ph2) | |
|
2143 | dataOut.sdp2[j]=1./st | |
|
2144 | #print("ph2: ",dataOut.ph2) | |
|
2145 | dataOut.ph2[j]=dataOut.ph2[j]*dataOut.h2[j] | |
|
2146 | dataOut.sdp2[j]=numpy.sqrt(dataOut.sdp2[j])*dataOut.h2[j] | |
|
2147 | rr=rr/dataOut.sdn2[j] | |
|
2148 | ri=ri/dataOut.sdn2[j] | |
|
2149 | #rm[j]=np.sqrt(rr*rr + ri*ri) it is not used in c program | |
|
2150 | dataOut.sdn2[j]=1./(dataOut.sdn2[j]*(rr*rr + ri*ri)) | |
|
2151 | if( (ri == 0.) and (rr == 0.) ): | |
|
2152 | dataOut.phi[j]=0. | |
|
2153 | else: | |
|
2154 | dataOut.phi[j]=math.atan2( ri , rr ) | |
|
2155 | ||
|
2156 | #print("ph2: ",dataOut.ph2) | |
|
2157 | #print("sdp2: ",dataOut.sdp2) | |
|
2158 | #print("sdn2",dataOut.sdn2) | |
|
2159 | ||
|
2160 | ||
|
2161 | return dataOut | |
|
2162 | ||
|
2163 | ||
|
2164 | ||
|
2165 | ||
|
2166 | ||
|
2167 | ||
|
2168 | class get_number_density(Operation): | |
|
2169 | def __init__(self, **kwargs): | |
|
2170 | ||
|
2171 | Operation.__init__(self, **kwargs) | |
|
2172 | self.aux=1 | |
|
2173 | ||
|
2174 | def run(self,dataOut,NSHTS=None,RATE=None): | |
|
2175 | dataOut.NSHTS=NSHTS | |
|
2176 | dataOut.RATE=RATE | |
|
2177 | if dataOut.AUX==1: | |
|
2178 | #dataOut.TimeBlockSeconds=time.mktime(time.strptime(dataOut.TimeBlockDate)) | |
|
2179 | #dataOut.bd_time=time.gmtime(dataOut.TimeBlockSeconds) | |
|
2180 | #dataOut.ut=dataOut.bd_time.tm_hour+dataOut.bd_time.tm_min/60.0+dataOut.bd_time.tm_sec/3600.0 | |
|
2181 | if self.aux==1: | |
|
2182 | dataOut.dphi=numpy.zeros(dataOut.header[15][0],'float32') | |
|
2183 | dataOut.sdn1=numpy.zeros(dataOut.header[15][0],'float32') | |
|
2184 | self.aux=0 | |
|
2185 | theta=numpy.zeros(dataOut.header[15][0],dtype=numpy.complex_) | |
|
2186 | thetai=numpy.zeros(dataOut.header[15][0],dtype=numpy.complex_) | |
|
2187 | # use complex numbers for phase | |
|
2188 | for i in range(dataOut.NSHTS): | |
|
2189 | theta[i]=math.cos(dataOut.phi[i])+math.sin(dataOut.phi[i])*1j | |
|
2190 | thetai[i]=-math.sin(dataOut.phi[i])+math.cos(dataOut.phi[i])*1j | |
|
2191 | ||
|
2192 | # differentiate and convert to number density | |
|
2193 | ndphi=dataOut.NSHTS-4 | |
|
2194 | #print("dataOut.dphiBEFORE: ",dataOut.dphi) | |
|
2195 | for i in range(2,dataOut.NSHTS-2): | |
|
2196 | fact=(-0.5/(dataOut.RATE*dataOut.header[10][0]))*dataOut.bki[i] | |
|
2197 | #four-point derivative, no phase unwrapping necessary | |
|
2198 | dataOut.dphi[i]=((((theta[i+1]-theta[i-1])+(2.0*(theta[i+2]-theta[i-2])))/thetai[i])).real/10.0 | |
|
2199 | #print("dataOut.dphi[i]AFTER: ",dataOut.dphi[i]) | |
|
2200 | dataOut.dphi[i]=abs(dataOut.dphi[i]*fact) | |
|
2201 | dataOut.sdn1[i]=(4.*(dataOut.sdn2[i-2]+dataOut.sdn2[i+2])+dataOut.sdn2[i-1]+dataOut.sdn2[i+1]) | |
|
2202 | dataOut.sdn1[i]=numpy.sqrt(dataOut.sdn1[i])*fact | |
|
2203 | ''' | |
|
2204 | #print("date: ",dataOut.TimeBlockDate) | |
|
2205 | #print("CurrentBlock: ", dataOut.CurrentBlock) | |
|
2206 | #print("NSHTS: ",dataOut.NSHTS) | |
|
2207 | print("phi: ",dataOut.phi) | |
|
2208 | #print("header[10][0]: ",dataOut.DH) | |
|
2209 | print("bkibki: ",dataOut.bki) | |
|
2210 | #print("RATE: ",dataOut.RATE) | |
|
2211 | print("sdn2: ",dataOut.sdn2) | |
|
2212 | print("dphi: ",dataOut.dphi) | |
|
2213 | print("sdn1: ",dataOut.sdn1) | |
|
2214 | print("ph2: ",dataOut.ph2) | |
|
2215 | print("sdp2: ",dataOut.sdp2) | |
|
2216 | print("sdn1: ",dataOut.sdn1) | |
|
2217 | ''' | |
|
2218 | ||
|
2219 | ''' | |
|
2220 | Al finallllllllllllllllllllllllllllllllllllllllllllllllllllllllll | |
|
2221 | for i in range(dataOut.NSHTS): | |
|
2222 | dataOut.ph2[i]=(max(1.0, dataOut.ph2[i])) | |
|
2223 | dataOut.dphi[i]=(max(1.0, dataOut.dphi[i])) | |
|
2224 | #print("dphi ",dphi) | |
|
2225 | # threshold - values less than 10⁴ | |
|
2226 | for i in range(dataOut.NSHTS): | |
|
2227 | if dataOut.ph2[i]<10000: | |
|
2228 | dataOut.ph2[i]=10000 | |
|
2229 | ||
|
2230 | # threshold values more than 10⁷ | |
|
2231 | for i in range(dataOut.NSHTS): | |
|
2232 | if dataOut.ph2[i]>10000000:# | |
|
2233 | dataOut.ph2[i]=10000000 | |
|
2234 | ||
|
2235 | ## filter for errors | |
|
2236 | for i in range(dataOut.NSHTS): | |
|
2237 | if dataOut.sdp2[i]>100000:# | |
|
2238 | dataOut.ph2[i]=10000 | |
|
2239 | ''' | |
|
2240 | ||
|
2241 | ||
|
2242 | ||
|
2243 | ||
|
2244 | return dataOut | |
|
2245 | ||
|
2246 | ||
|
2247 | ||
|
2248 | ||
|
2249 | ||
|
2250 | ||
|
2251 | ||
|
2252 | ||
|
2253 | ||
|
2254 | ||
|
2255 | ||
|
2256 | class normalize_dp_power2(Operation): | |
|
2257 | def __init__(self, **kwargs): | |
|
2258 | ||
|
2259 | Operation.__init__(self, **kwargs) | |
|
2260 | self.aux=1 | |
|
2261 | ||
|
2262 | def normal(self,a,b,n,m): | |
|
2263 | chmin=1.0e30 | |
|
2264 | chisq=numpy.zeros(150,'float32') | |
|
2265 | temp=numpy.zeros(150,'float32') | |
|
2266 | ||
|
2267 | for i in range(2*m-1): | |
|
2268 | an=al=be=chisq[i]=0.0 | |
|
2269 | for j in range(int(n/m)): | |
|
2270 | k=int(j+i*n/(2*m)) | |
|
2271 | if(a[k]>0.0 and b[k]>0.0): | |
|
2272 | al+=a[k]*b[k] | |
|
2273 | be+=b[k]*b[k] | |
|
2274 | ||
|
2275 | if(be>0.0): | |
|
2276 | temp[i]=al/be | |
|
2277 | else: | |
|
2278 | temp[i]=1.0 | |
|
2279 | ||
|
2280 | for j in range(int(n/m)): | |
|
2281 | k=int(j+i*n/(2*m)) | |
|
2282 | if(a[k]>0.0 and b[k]>0.0): | |
|
2283 | chisq[i]+=(numpy.log10(b[k]*temp[i]/a[k]))**2 | |
|
2284 | an=an+1 | |
|
2285 | ||
|
2286 | if(chisq[i]>0.0): | |
|
2287 | chisq[i]/=an | |
|
2288 | ||
|
2289 | ||
|
2290 | for i in range(int(2*m-1)): | |
|
2291 | if(chisq[i]<chmin and chisq[i]>1.0e-6): | |
|
2292 | chmin=chisq[i] | |
|
2293 | cf=temp[i] | |
|
2294 | return cf | |
|
2295 | ||
|
2296 | ||
|
2297 | ||
|
2298 | def run(self,dataOut,cut0=None,cut1=None): | |
|
2299 | dataOut.cut0=float(cut0) | |
|
2300 | dataOut.cut1=float(cut1) | |
|
2301 | if dataOut.AUX==1: | |
|
2302 | #print("dateBefore: ",dataOut.TimeBlockDate_for_dp_power) | |
|
2303 | #print("dateNow: ",dataOut.TimeBlockDate) | |
|
2304 | if self.aux==1: | |
|
2305 | dataOut.cf=numpy.zeros(1,'float32') | |
|
2306 | dataOut.cflast=numpy.zeros(1,'float32') | |
|
2307 | self.aux=0 | |
|
2308 | ||
|
2309 | night_first=300.0 | |
|
2310 | night_first1= 310.0 | |
|
2311 | night_end= 450.0 | |
|
2312 | day_first=250.0 | |
|
2313 | day_end=400.0 | |
|
2314 | day_first_sunrise=190.0 | |
|
2315 | day_end_sunrise=280.0 | |
|
2316 | ||
|
2317 | if(dataOut.ut>4.0 and dataOut.ut<11.0): #early | |
|
2318 | i2=(night_end-dataOut.range1[0])/dataOut.header[10][0] | |
|
2319 | i1=(night_first -dataOut.range1[0])/dataOut.header[10][0] | |
|
2320 | elif (dataOut.ut>0.0 and dataOut.ut<4.0): #night | |
|
2321 | i2=(night_end-dataOut.range1[0])/dataOut.header[10][0] | |
|
2322 | i1=(night_first1 -dataOut.range1[0])/dataOut.header[10][0] | |
|
2323 | elif (dataOut.ut>=11.0 and dataOut.ut<13.5): #sunrise | |
|
2324 | i2=( day_end_sunrise-dataOut.range1[0])/dataOut.header[10][0] | |
|
2325 | i1=(day_first_sunrise - dataOut.range1[0])/dataOut.header[10][0] | |
|
2326 | else: | |
|
2327 | i2=(day_end-dataOut.range1[0])/dataOut.header[10][0] | |
|
2328 | i1=(day_first -dataOut.range1[0])/dataOut.header[10][0] | |
|
2329 | ||
|
2330 | i1=int(i1) | |
|
2331 | i2=int(i2) | |
|
2332 | #print("ph2: ",dataOut.ph2) | |
|
2333 | dataOut.cf=self.normal(dataOut.dphi[i1::], dataOut.ph2[i1::], i2-i1, 1) | |
|
2334 | ||
|
2335 | #print("n in:",i1,"(",dataOut.range1[i1],"), i2=",i2,"(",dataOut.range1[i2],"), ut=",dataOut.ut,", cf=",dataOut.cf,", cf_last=", | |
|
2336 | #dataOut.cflast) | |
|
2337 | # in case of spread F, normalize much higher | |
|
2338 | if(dataOut.cf<dataOut.cflast[0]/10.0): | |
|
2339 | i1=(night_first1+100.-dataOut.range1[0])/dataOut.header[10][0] | |
|
2340 | i2=(night_end+100.0-dataOut.range1[0])/dataOut.header[10][0] | |
|
2341 | i1=int(i1) | |
|
2342 | i2=int(i2) | |
|
2343 | #print("normal over: ",i1,"(",dataOut.range1[i1],") ",i2,"(",dataOut.range1[i2],") => cf: ",dataOut.cf," cflast: ", dataOut.cflast) | |
|
2344 | dataOut.cf=self.normal(dataOut.dphi[int(i1)::], dataOut.ph2[int(i1)::], int(i2-i1), 1) | |
|
2345 | dataOut.cf=dataOut.cflast[0] | |
|
2346 | ||
|
2347 | #print(">>>i1=",i1,"(",dataOut.range1[i1],"), i2=",i2,"(",dataOut.range1[i2],"), ut=",dataOut.ut,", cf=",dataOut.cf,", cf_last=", | |
|
2348 | # dataOut.cflast," (",dataOut.cf/dataOut.cflast,"), cut=",dataOut.cut0," ",dataOut.cut1) | |
|
2349 | dataOut.cflast[0]=dataOut.cf | |
|
2350 | ||
|
2351 | ## normalize double pulse power and error bars to Faraday | |
|
2352 | for i in range(dataOut.NSHTS): | |
|
2353 | dataOut.ph2[i]*=dataOut.cf | |
|
2354 | dataOut.sdp2[i]*=dataOut.cf | |
|
2355 | #print("******* correction factor: ",dataOut.cf) | |
|
2356 | ||
|
2357 | #print(dataOut.ph2) | |
|
2358 | ||
|
2359 | for i in range(dataOut.NSHTS): | |
|
2360 | dataOut.ph2[i]=(max(1.0, dataOut.ph2[i])) | |
|
2361 | dataOut.dphi[i]=(max(1.0, dataOut.dphi[i])) | |
|
2362 | #print("dphi ",dphi) | |
|
2363 | # threshold - values less than 10⁴ | |
|
2364 | ||
|
2365 | ''' | |
|
2366 | for i in range(dataOut.NSHTS): | |
|
2367 | if dataOut.ph2[i]<10000: | |
|
2368 | dataOut.ph2[i]=10000 | |
|
2369 | ||
|
2370 | # threshold values more than 10⁷ | |
|
2371 | for i in range(dataOut.NSHTS): | |
|
2372 | if dataOut.ph2[i]>10000000:# | |
|
2373 | dataOut.ph2[i]=10000000 | |
|
2374 | ||
|
2375 | ## filter for errors | |
|
2376 | for i in range(dataOut.NSHTS): | |
|
2377 | if dataOut.sdp2[i]>100000:# | |
|
2378 | dataOut.ph2[i]=10000 | |
|
2379 | ''' | |
|
2380 | ||
|
2381 | ||
|
2382 | ||
|
2383 | ||
|
2384 | ||
|
2385 | ''' | |
|
2386 | #print("date: ",dataOut.TimeBlockDate) | |
|
2387 | #print("CurrentBlock: ", dataOut.CurrentBlock) | |
|
2388 | #print("NSHTS: ",dataOut.NSHTS) | |
|
2389 | print("phi: ",dataOut.phi) | |
|
2390 | #print("header[10][0]: ",dataOut.DH) | |
|
2391 | print("bkibki: ",dataOut.bki) | |
|
2392 | #print("RATE: ",dataOut.RATE) | |
|
2393 | print("sdn2: ",dataOut.sdn2) | |
|
2394 | print("dphi: ",dataOut.dphi) | |
|
2395 | print("sdn1: ",dataOut.sdn1) | |
|
2396 | print("ph2: ",dataOut.ph2) | |
|
2397 | print("sdp2: ",dataOut.sdp2) | |
|
2398 | print("sdn1: ",dataOut.sdn1) | |
|
2399 | ''' | |
|
2400 | ||
|
2401 | ||
|
2402 | ||
|
2403 | ||
|
2404 | ||
|
2405 | ||
|
2406 | ||
|
2407 | return dataOut | |
|
2408 | ||
|
2409 | ||
|
2410 | ||
|
2411 | ||
|
2412 | ||
|
2413 | ||
|
2414 | ||
|
2415 | ||
|
2416 | ||
|
2417 | ||
|
2418 | ||
|
2419 | ||
|
2420 | ||
|
2421 | ||
|
2422 | ||
|
2423 | ''' | |
|
2424 | from ctypes import * | |
|
2425 | class IDATE(Structure): | |
|
2426 | _fields_ = [ | |
|
2427 | ("year", c_int), | |
|
2428 | ("moda", c_int), | |
|
2429 | ("hrmn", c_int), | |
|
2430 | ("sec", c_int), | |
|
2431 | ("secs", c_int), | |
|
2432 | ] | |
|
2433 | #typedef struct IDATE {int year,moda,hrmn,sec,secs;} idate; | |
|
2434 | ''' | |
|
2435 | ||
|
2436 | ||
|
2437 | ||
|
2438 | ||
|
2439 | ''' | |
|
2440 | class get_number_density(Operation): | |
|
2441 | def __init__(self, **kwargs): | |
|
2442 | ||
|
2443 | Operation.__init__(self, **kwargs) | |
|
2444 | ||
|
2445 | #self.aux=1 | |
|
2446 | ''' | |
|
2447 | ||
|
2448 | ''' | |
|
2449 | def IDATE(Structure): | |
|
2450 | ||
|
2451 | _fields_ = [ | |
|
2452 | ("year", c_int), | |
|
2453 | ("moda", c_int), | |
|
2454 | ("hrmn", c_int), | |
|
2455 | ("sec", c_int), | |
|
2456 | ("secs", c_int), | |
|
2457 | ] | |
|
2458 | ||
|
2459 | ''' | |
|
2460 | ||
|
2461 | ||
|
2462 | ||
|
2463 | ||
|
2464 | ''' | |
|
2465 | def run(self,dataOut): | |
|
2466 | ''' | |
|
2467 | ''' | |
|
2468 | if dataOut.CurrentBlock==1 and self.aux==1: | |
|
2469 | ||
|
2470 | #print("CurrentBlock: ",dataOut.CurrentBlock) | |
|
2471 | ||
|
2472 | dataOut.TimeBlockSeconds=time.mktime(time.strptime(dataOut.TimeBlockDate)) | |
|
2473 | #print("time1: ",dataOut.TimeBlockSeconds) | |
|
2474 | ||
|
2475 | #print("date: ",dataOut.TimeBlockDate) | |
|
2476 | dataOut.bd_time=time.gmtime(dataOut.TimeBlockSeconds) | |
|
2477 | #print("bd_time: ",dataOut.bd_time) | |
|
2478 | dataOut.year=dataOut.bd_time.tm_year+(dataOut.bd_time.tm_yday-1)/364.0 | |
|
2479 | #print("year: ",dataOut.year) | |
|
2480 | dataOut.ut=dataOut.bd_time.tm_hour+dataOut.bd_time.tm_min/60.0+dataOut.bd_time.tm_sec/3600.0 | |
|
2481 | #print("ut: ",dataOut.ut) | |
|
2482 | self.aux=0 | |
|
2483 | ||
|
2484 | ||
|
2485 | ||
|
2486 | ||
|
2487 | ''' | |
|
2488 | #print("CurrentBlock: ",dataOut.CurrentBlock) | |
|
2489 | #print("date: ",dataOut.firsttime) | |
|
2490 | #print("bd_time: ",time.strptime(dataOut.datatime.ctime())) | |
|
2491 | #mkfact_short.mkfact(year,h,bfm,thb,bki,dataOut.NDP) | |
|
2492 | #print("CurrentBlock: ",dataOut.CurrentBlock) | |
|
2493 | ''' | |
|
2494 | if dataOut.AUX==1: | |
|
2495 | ''' | |
|
2496 | ''' | |
|
2497 | #begin=IDATE() | |
|
2498 | #begin.year=dataOut.bd_time.tm_year | |
|
2499 | #begin.moda=100*(dataOut.bd_time.tm_mon)+dataOut.bd_time.tm_mday | |
|
2500 | #begin.hrmn=100*dataOut.bd_time.tm_hour+dataOut.bd_time.tm_min | |
|
2501 | #begin.sec=dataOut.bd_time.tm_sec | |
|
2502 | #begin.secs=dataOut.bd_time.tm_sec+60*(dataOut.bd_time.tm_min+60*(dataOut.bd_time.tm_hour+24*(dataOut.bd_time.tm_yday-1))) | |
|
2503 | h=numpy.arange(0.0,15.0*dataOut.NDP,15.0,dtype='float32') | |
|
2504 | bfm=numpy.zeros(dataOut.NDP,dtype='float32') | |
|
2505 | bfm=numpy.array(bfm,order='F') | |
|
2506 | thb=numpy.zeros(dataOut.NDP,dtype='float32') | |
|
2507 | thb=numpy.array(thb,order='F') | |
|
2508 | bki=numpy.zeros(dataOut.NDP,dtype='float32') | |
|
2509 | bki=numpy.array(thb,order='F') | |
|
2510 | #yearmanually=2019.9285714285713 | |
|
2511 | #print("year manually: ",yearmanually) | |
|
2512 | #print("year: ",dataOut.year) | |
|
2513 | mkfact_short.mkfact(dataOut.year,h,bfm,thb,bki,dataOut.NDP) | |
|
2514 | #print("tm ",tm) | |
|
2515 | ''' | |
|
2516 | ''' | |
|
2517 | print("year ",dataOut.year) | |
|
2518 | print("h ", dataOut.h) | |
|
2519 | print("bfm ", dataOut.bfm) | |
|
2520 | print("thb ", dataOut.thb) | |
|
2521 | print("bki ", dataOut.bki) | |
|
2522 | ''' | |
|
2523 | ||
|
2524 | ||
|
2525 | ||
|
2526 | ||
|
2527 | ''' | |
|
2528 | print("CurrentBlock: ",dataOut.CurrentBlock) | |
|
2529 | ||
|
2530 | ||
|
2531 | ||
|
2532 | ||
|
2533 | ||
|
2534 | ||
|
2535 | ||
|
2536 | ||
|
2537 | ||
|
2538 | ||
|
2539 | return dataOut | |
|
2540 | ''' | |
|
2541 | ||
|
2542 | ||
|
2543 | ||
|
2544 | ||
|
2545 | ||
|
2546 | ||
|
2547 | class test(Operation): | |
|
2548 | def __init__(self, **kwargs): | |
|
2549 | ||
|
2550 | Operation.__init__(self, **kwargs) | |
|
2551 | ||
|
2552 | ||
|
2553 | ||
|
2554 | ||
|
2555 | def run(self,dataOut,tt=10): | |
|
2556 | ||
|
2557 | print("tt: ",tt) | |
|
2558 | ||
|
2559 | ||
|
2560 | ||
|
2561 | return dataOut |
@@ -76,6 +76,8 def hildebrand_sekhon(data, navg): | |||
|
76 | 76 | """ |
|
77 | 77 | |
|
78 | 78 | sortdata = numpy.sort(data, axis=None) |
|
79 | #print(numpy.shape(data)) | |
|
80 | #exit() | |
|
79 | 81 | ''' |
|
80 | 82 | lenOfData = len(sortdata) |
|
81 | 83 | nums_min = lenOfData*0.2 |
@@ -273,13 +275,13 class JROData(GenericData): | |||
|
273 | 275 | ''' |
|
274 | 276 | ''' |
|
275 | 277 | return self.radarControllerHeaderObj.ippSeconds |
|
276 | ||
|
278 | ||
|
277 | 279 | @ippSeconds.setter |
|
278 | 280 | def ippSeconds(self, ippSeconds): |
|
279 | 281 | ''' |
|
280 | 282 | ''' |
|
281 | 283 | self.radarControllerHeaderObj.ippSeconds = ippSeconds |
|
282 | ||
|
284 | ||
|
283 | 285 | @property |
|
284 | 286 | def code(self): |
|
285 | 287 | ''' |
@@ -370,7 +372,7 class Voltage(JROData): | |||
|
370 | 372 | self.flagShiftFFT = False |
|
371 | 373 | self.flagDataAsBlock = False # Asumo que la data es leida perfil a perfil |
|
372 | 374 | self.profileIndex = 0 |
|
373 |
self.metadata_list = ['type', 'heightList', 'timeZone', 'nProfiles', 'channelList', 'nCohInt', |
|
|
375 | self.metadata_list = ['type', 'heightList', 'timeZone', 'nProfiles', 'channelList', 'nCohInt', | |
|
374 | 376 | 'code', 'nCode', 'nBaud', 'ippSeconds', 'ipp'] |
|
375 | 377 | |
|
376 | 378 | def getNoisebyHildebrand(self, channel=None): |
@@ -428,6 +430,103 class Voltage(JROData): | |||
|
428 | 430 | noise = property(getNoise, "I'm the 'nHeights' property.") |
|
429 | 431 | |
|
430 | 432 | |
|
433 | class CrossProds(JROData): | |
|
434 | ||
|
435 | # data es un numpy array de 2 dmensiones (canales, alturas) | |
|
436 | data = None | |
|
437 | ||
|
438 | def __init__(self): | |
|
439 | ''' | |
|
440 | Constructor | |
|
441 | ''' | |
|
442 | ||
|
443 | self.useLocalTime = True | |
|
444 | ''' | |
|
445 | self.radarControllerHeaderObj = RadarControllerHeader() | |
|
446 | self.systemHeaderObj = SystemHeader() | |
|
447 | self.type = "Voltage" | |
|
448 | self.data = None | |
|
449 | # self.dtype = None | |
|
450 | # self.nChannels = 0 | |
|
451 | # self.nHeights = 0 | |
|
452 | self.nProfiles = None | |
|
453 | self.heightList = None | |
|
454 | self.channelList = None | |
|
455 | # self.channelIndexList = None | |
|
456 | self.flagNoData = True | |
|
457 | self.flagDiscontinuousBlock = False | |
|
458 | self.utctime = None | |
|
459 | self.timeZone = None | |
|
460 | self.dstFlag = None | |
|
461 | self.errorCount = None | |
|
462 | self.nCohInt = None | |
|
463 | self.blocksize = None | |
|
464 | self.flagDecodeData = False # asumo q la data no esta decodificada | |
|
465 | self.flagDeflipData = False # asumo q la data no esta sin flip | |
|
466 | self.flagShiftFFT = False | |
|
467 | self.flagDataAsBlock = False # Asumo que la data es leida perfil a perfil | |
|
468 | self.profileIndex = 0 | |
|
469 | ||
|
470 | ||
|
471 | def getNoisebyHildebrand(self, channel=None): | |
|
472 | ||
|
473 | ||
|
474 | if channel != None: | |
|
475 | data = self.data[channel] | |
|
476 | nChannels = 1 | |
|
477 | else: | |
|
478 | data = self.data | |
|
479 | nChannels = self.nChannels | |
|
480 | ||
|
481 | noise = numpy.zeros(nChannels) | |
|
482 | power = data * numpy.conjugate(data) | |
|
483 | ||
|
484 | for thisChannel in range(nChannels): | |
|
485 | if nChannels == 1: | |
|
486 | daux = power[:].real | |
|
487 | else: | |
|
488 | daux = power[thisChannel, :].real | |
|
489 | noise[thisChannel] = hildebrand_sekhon(daux, self.nCohInt) | |
|
490 | ||
|
491 | return noise | |
|
492 | ||
|
493 | def getNoise(self, type=1, channel=None): | |
|
494 | ||
|
495 | if type == 1: | |
|
496 | noise = self.getNoisebyHildebrand(channel) | |
|
497 | ||
|
498 | return noise | |
|
499 | ||
|
500 | def getPower(self, channel=None): | |
|
501 | ||
|
502 | if channel != None: | |
|
503 | data = self.data[channel] | |
|
504 | else: | |
|
505 | data = self.data | |
|
506 | ||
|
507 | power = data * numpy.conjugate(data) | |
|
508 | powerdB = 10 * numpy.log10(power.real) | |
|
509 | powerdB = numpy.squeeze(powerdB) | |
|
510 | ||
|
511 | return powerdB | |
|
512 | ||
|
513 | def getTimeInterval(self): | |
|
514 | ||
|
515 | timeInterval = self.ippSeconds * self.nCohInt | |
|
516 | ||
|
517 | return timeInterval | |
|
518 | ||
|
519 | noise = property(getNoise, "I'm the 'nHeights' property.") | |
|
520 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") | |
|
521 | ''' | |
|
522 | def getTimeInterval(self): | |
|
523 | ||
|
524 | timeInterval = self.ippSeconds * self.nCohInt | |
|
525 | ||
|
526 | return timeInterval | |
|
527 | ||
|
528 | ||
|
529 | ||
|
431 | 530 | class Spectra(JROData): |
|
432 | 531 | |
|
433 | 532 | def __init__(self): |
@@ -461,7 +560,7 class Spectra(JROData): | |||
|
461 | 560 | self.ippFactor = 1 |
|
462 | 561 | self.beacon_heiIndexList = [] |
|
463 | 562 | self.noise_estimation = None |
|
464 |
self.metadata_list = ['type', 'heightList', 'timeZone', 'pairsList', 'channelList', 'nCohInt', |
|
|
563 | self.metadata_list = ['type', 'heightList', 'timeZone', 'pairsList', 'channelList', 'nCohInt', | |
|
465 | 564 | 'code', 'nCode', 'nBaud', 'ippSeconds', 'ipp','nIncohInt', 'nFFTPoints', 'nProfiles'] |
|
466 | 565 | |
|
467 | 566 | def getNoisebyHildebrand(self, xmin_index=None, xmax_index=None, ymin_index=None, ymax_index=None): |
@@ -611,7 +710,7 class Spectra(JROData): | |||
|
611 | 710 | print("This property should not be initialized") |
|
612 | 711 | |
|
613 | 712 | return |
|
614 | ||
|
713 | ||
|
615 | 714 | noise = property(getNoise, setValue, "I'm the 'nHeights' property.") |
|
616 | 715 | |
|
617 | 716 | |
@@ -708,7 +807,7 class Fits(JROData): | |||
|
708 | 807 | return self.ipp_sec |
|
709 | 808 | |
|
710 | 809 | noise = property(getNoise, "I'm the 'nHeights' property.") |
|
711 | ||
|
810 | ||
|
712 | 811 | |
|
713 | 812 | class Correlation(JROData): |
|
714 | 813 | |
@@ -889,6 +988,7 class Parameters(Spectra): | |||
|
889 | 988 | else: |
|
890 | 989 | return self.paramInterval |
|
891 | 990 | |
|
991 | ||
|
892 | 992 | def setValue(self, value): |
|
893 | 993 | |
|
894 | 994 | print("This property should not be initialized") |
@@ -137,7 +137,7 class BasicHeader(Header): | |||
|
137 | 137 | timeZone = None |
|
138 | 138 | dstFlag = None |
|
139 | 139 | errorCount = None |
|
140 |
|
|
|
140 | F = None | |
|
141 | 141 | structure = BASIC_STRUCTURE |
|
142 | 142 | __LOCALTIME = None |
|
143 | 143 | |
@@ -363,6 +363,7 class RadarControllerHeader(Header): | |||
|
363 | 363 | self.expType = int(header['nExpType'][0]) |
|
364 | 364 | self.nTx = int(header['nNTx'][0]) |
|
365 | 365 | self.ipp = float(header['fIpp'][0]) |
|
366 | #print(self.ipp) | |
|
366 | 367 | self.txA = float(header['fTxA'][0]) |
|
367 | 368 | self.txB = float(header['fTxB'][0]) |
|
368 | 369 | self.nWindows = int(header['nNumWindows'][0]) |
@@ -534,6 +535,7 class RadarControllerHeader(Header): | |||
|
534 | 535 | def get_ippSeconds(self): |
|
535 | 536 | ''' |
|
536 | 537 | ''' |
|
538 | ||
|
537 | 539 | ippSeconds = 2.0 * 1000 * self.ipp / SPEED_OF_LIGHT |
|
538 | 540 | |
|
539 | 541 | return ippSeconds |
@@ -640,6 +642,7 class ProcessingHeader(Header): | |||
|
640 | 642 | self.nWindows = int(header['nNumWindows'][0]) |
|
641 | 643 | self.processFlags = header['nProcessFlags'] |
|
642 | 644 | self.nCohInt = int(header['nCoherentIntegrations'][0]) |
|
645 | ||
|
643 | 646 | self.nIncohInt = int(header['nIncoherentIntegrations'][0]) |
|
644 | 647 | self.totalSpectra = int(header['nTotalSpectra'][0]) |
|
645 | 648 | |
@@ -903,4 +906,4 def get_procflag_dtype(index): | |||
|
903 | 906 | |
|
904 | 907 | def get_dtype_width(index): |
|
905 | 908 | |
|
906 | return DTYPE_WIDTH[index] No newline at end of file | |
|
909 | return DTYPE_WIDTH[index] |
@@ -3,3 +3,4 from .jroplot_spectra import * | |||
|
3 | 3 | from .jroplot_heispectra import * |
|
4 | 4 | from .jroplot_correlation import * |
|
5 | 5 | from .jroplot_parameters import * |
|
6 | from .jroplot_voltage_lags import * |
@@ -220,6 +220,10 class Plot(Operation): | |||
|
220 | 220 | self.zmin = kwargs.get('zmin', None) |
|
221 | 221 | self.zmax = kwargs.get('zmax', None) |
|
222 | 222 | self.zlimits = kwargs.get('zlimits', None) |
|
223 | self.xlimits = kwargs.get('xlimits', None) | |
|
224 | self.xstep_given = kwargs.get('xstep_given', None) | |
|
225 | self.ystep_given = kwargs.get('ystep_given', None) | |
|
226 | self.autoxticks = kwargs.get('autoxticks', True) | |
|
223 | 227 | self.xmin = kwargs.get('xmin', None) |
|
224 | 228 | self.xmax = kwargs.get('xmax', None) |
|
225 | 229 | self.xrange = kwargs.get('xrange', 12) |
@@ -271,7 +275,7 class Plot(Operation): | |||
|
271 | 275 | |
|
272 | 276 | self.setup() |
|
273 | 277 | |
|
274 |
self.time_label = 'LT' if self.localtime else 'UTC' |
|
|
278 | self.time_label = 'LT' if self.localtime else 'UTC' | |
|
275 | 279 | |
|
276 | 280 | if self.width is None: |
|
277 | 281 | self.width = 8 |
@@ -376,7 +380,7 class Plot(Operation): | |||
|
376 | 380 | ''' |
|
377 | 381 | Set min and max values, labels, ticks and titles |
|
378 | 382 | ''' |
|
379 | ||
|
383 | ||
|
380 | 384 | for n, ax in enumerate(self.axes): |
|
381 | 385 | if ax.firsttime: |
|
382 | 386 | if self.xaxis != 'time': |
@@ -459,14 +463,14 class Plot(Operation): | |||
|
459 | 463 | |
|
460 | 464 | self.plot() |
|
461 | 465 | self.format() |
|
462 | ||
|
466 | ||
|
463 | 467 | for n, fig in enumerate(self.figures): |
|
464 | 468 | if self.nrows == 0 or self.nplots == 0: |
|
465 | 469 | log.warning('No data', self.name) |
|
466 | 470 | fig.text(0.5, 0.5, 'No Data', fontsize='large', ha='center') |
|
467 | 471 | fig.canvas.manager.set_window_title(self.CODE) |
|
468 | 472 | continue |
|
469 | ||
|
473 | ||
|
470 | 474 | fig.canvas.manager.set_window_title('{} - {}'.format(self.title, |
|
471 | 475 | self.getDateTime(self.data.max_time).strftime('%Y/%m/%d'))) |
|
472 | 476 | fig.canvas.draw() |
@@ -476,7 +480,7 class Plot(Operation): | |||
|
476 | 480 | |
|
477 | 481 | if self.save: |
|
478 | 482 | self.save_figure(n) |
|
479 | ||
|
483 | ||
|
480 | 484 | if self.server: |
|
481 | 485 | self.send_to_server() |
|
482 | 486 | |
@@ -523,6 +527,7 class Plot(Operation): | |||
|
523 | 527 | |
|
524 | 528 | figname = os.path.join( |
|
525 | 529 | self.save, |
|
530 | self.save_code, | |
|
526 | 531 | '{}_{}.png'.format( |
|
527 | 532 | self.save_code, |
|
528 | 533 | self.getDateTime(self.data.min_time).strftime( |
@@ -604,7 +609,7 class Plot(Operation): | |||
|
604 | 609 | self.ncols: number of cols |
|
605 | 610 | self.nplots: number of plots (channels or pairs) |
|
606 | 611 | self.ylabel: label for Y axes |
|
607 |
self.titles: list of axes title |
|
|
612 | self.titles: list of axes title | |
|
608 | 613 | |
|
609 | 614 | ''' |
|
610 | 615 | raise NotImplementedError |
@@ -631,7 +636,7 class Plot(Operation): | |||
|
631 | 636 | ''' |
|
632 | 637 | Main plotting routine |
|
633 | 638 | ''' |
|
634 | ||
|
639 | ||
|
635 | 640 | if self.isConfig is False: |
|
636 | 641 | self.__setup(**kwargs) |
|
637 | 642 | |
@@ -667,7 +672,7 class Plot(Operation): | |||
|
667 | 672 | dt = self.getDateTime(tm) |
|
668 | 673 | if self.xmin is None: |
|
669 | 674 | self.tmin = tm |
|
670 |
self.xmin = dt.hour |
|
|
675 | self.xmin = dt.hour | |
|
671 | 676 | minutes = (self.xmin-int(self.xmin)) * 60 |
|
672 | 677 | seconds = (minutes - int(minutes)) * 60 |
|
673 | 678 | self.tmin = (dt.replace(hour=int(self.xmin), minute=int(minutes), second=int(seconds)) - |
@@ -690,4 +695,3 class Plot(Operation): | |||
|
690 | 695 | self.__plot() |
|
691 | 696 | if self.data and not self.data.flagNoData and self.pause: |
|
692 | 697 | figpause(10) |
|
693 |
@@ -46,12 +46,24 class DobleGaussianPlot(SpectraPlot): | |||
|
46 | 46 | # colormap = 'jet' |
|
47 | 47 | # plot_type = 'pcolor' |
|
48 | 48 | |
|
49 | ||
|
49 | 50 | class DoubleGaussianSpectraCutPlot(SpectraCutPlot): |
|
50 | 51 | ''' |
|
51 | 52 | Plot SpectraCut with Double Gaussian Fit |
|
52 | 53 | ''' |
|
53 | 54 | CODE = 'cut_gaussian_fit' |
|
54 | 55 | |
|
56 | ||
|
57 | class SpectralFitObliquePlot(SpectraPlot): | |
|
58 | ''' | |
|
59 | Plot for Spectral Oblique | |
|
60 | ''' | |
|
61 | CODE = 'spc_moments' | |
|
62 | colormap = 'jet' | |
|
63 | plot_type = 'pcolor' | |
|
64 | ||
|
65 | ||
|
66 | ||
|
55 | 67 | class SnrPlot(RTIPlot): |
|
56 | 68 | ''' |
|
57 | 69 | Plot for SNR Data |
@@ -179,7 +191,7 class GenericRTIPlot(Plot): | |||
|
179 | 191 | self.nrows = self.data.shape('param')[0] |
|
180 | 192 | self.nplots = self.nrows |
|
181 | 193 | self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.08, 'right':0.95, 'top': 0.95}) |
|
182 | ||
|
194 | ||
|
183 | 195 | if not self.xlabel: |
|
184 | 196 | self.xlabel = 'Time' |
|
185 | 197 | |
@@ -367,4 +379,3 class PolarMapPlot(Plot): | |||
|
367 | 379 | self.save_labels = ['{}-{}'.format(lbl, label) for lbl in self.labels] |
|
368 | 380 | self.titles = ['{} {}'.format( |
|
369 | 381 | self.data.parameters[x], title) for x in self.channels] |
|
370 |
This diff has been collapsed as it changes many lines, (535 lines changed) Show them Hide them | |||
@@ -23,6 +23,7 class SpectraPlot(Plot): | |||
|
23 | 23 | buffering = False |
|
24 | 24 | |
|
25 | 25 | def setup(self): |
|
26 | ||
|
26 | 27 | self.nplots = len(self.data.channels) |
|
27 | 28 | self.ncols = int(numpy.sqrt(self.nplots) + 0.9) |
|
28 | 29 | self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9) |
@@ -32,7 +33,7 class SpectraPlot(Plot): | |||
|
32 | 33 | self.width = 4 * self.ncols |
|
33 | 34 | else: |
|
34 | 35 | self.width = 3.5 * self.ncols |
|
35 |
self.plots_adjust.update({'wspace': 0. |
|
|
36 | self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18}) | |
|
36 | 37 | self.ylabel = 'Range [km]' |
|
37 | 38 | |
|
38 | 39 | def update(self, dataOut): |
@@ -56,6 +57,9 class SpectraPlot(Plot): | |||
|
56 | 57 | return data, meta |
|
57 | 58 | |
|
58 | 59 | def plot(self): |
|
60 | ||
|
61 | #print(self.xaxis) | |
|
62 | #exit(1) | |
|
59 | 63 | if self.xaxis == "frequency": |
|
60 | 64 | x = self.data.xrange[0] |
|
61 | 65 | self.xlabel = "Frequency (kHz)" |
@@ -78,6 +82,9 class SpectraPlot(Plot): | |||
|
78 | 82 | data = self.data[-1] |
|
79 | 83 | z = data['spc'] |
|
80 | 84 | |
|
85 | self.CODE2 = 'spc_oblique' | |
|
86 | ||
|
87 | ||
|
81 | 88 | for n, ax in enumerate(self.axes): |
|
82 | 89 | noise = data['noise'][n] |
|
83 | 90 | if self.CODE == 'spc_moments': |
@@ -91,6 +98,7 class SpectraPlot(Plot): | |||
|
91 | 98 | self.xmin = self.xmin if self.xmin else -self.xmax |
|
92 | 99 | self.zmin = self.zmin if self.zmin else numpy.nanmin(z) |
|
93 | 100 | self.zmax = self.zmax if self.zmax else numpy.nanmax(z) |
|
101 | #print(numpy.shape(x)) | |
|
94 | 102 | ax.plt = ax.pcolormesh(x, y, z[n].T, |
|
95 | 103 | vmin=self.zmin, |
|
96 | 104 | vmax=self.zmax, |
@@ -105,7 +113,6 class SpectraPlot(Plot): | |||
|
105 | 113 | if self.CODE == 'spc_moments': |
|
106 | 114 | ax.plt_mean = ax.plot(mean, y, color='k', lw=1)[0] |
|
107 | 115 | if self.CODE == 'gaussian_fit': |
|
108 | # ax.plt_mean = ax.plot(mean, y, color='k', lw=1)[0] | |
|
109 | 116 | ax.plt_gau0 = ax.plot(gau0, y, color='r', lw=1)[0] |
|
110 | 117 | ax.plt_gau1 = ax.plot(gau1, y, color='y', lw=1)[0] |
|
111 | 118 | else: |
@@ -116,11 +123,114 class SpectraPlot(Plot): | |||
|
116 | 123 | if self.CODE == 'spc_moments': |
|
117 | 124 | ax.plt_mean.set_data(mean, y) |
|
118 | 125 | if self.CODE == 'gaussian_fit': |
|
119 | # ax.plt_mean.set_data(mean, y) | |
|
120 | 126 | ax.plt_gau0.set_data(gau0, y) |
|
121 | 127 | ax.plt_gau1.set_data(gau1, y) |
|
122 | 128 | self.titles.append('CH {}: {:3.2f}dB'.format(n, noise)) |
|
123 | 129 | |
|
130 | class SpectraObliquePlot(Plot): | |
|
131 | ''' | |
|
132 | Plot for Spectra data | |
|
133 | ''' | |
|
134 | ||
|
135 | CODE = 'spc' | |
|
136 | colormap = 'jet' | |
|
137 | plot_type = 'pcolor' | |
|
138 | ||
|
139 | def setup(self): | |
|
140 | self.xaxis = "oblique" | |
|
141 | self.nplots = len(self.data.channels) | |
|
142 | self.ncols = int(numpy.sqrt(self.nplots) + 0.9) | |
|
143 | self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9) | |
|
144 | self.height = 2.6 * self.nrows | |
|
145 | self.cb_label = 'dB' | |
|
146 | if self.showprofile: | |
|
147 | self.width = 4 * self.ncols | |
|
148 | else: | |
|
149 | self.width = 3.5 * self.ncols | |
|
150 | self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18}) | |
|
151 | self.ylabel = 'Range [km]' | |
|
152 | ||
|
153 | def plot(self): | |
|
154 | ||
|
155 | #print(self.xaxis) | |
|
156 | #exit(1) | |
|
157 | if self.xaxis == "frequency": | |
|
158 | x = self.data.xrange[0] | |
|
159 | self.xlabel = "Frequency (kHz)" | |
|
160 | elif self.xaxis == "time": | |
|
161 | x = self.data.xrange[1] | |
|
162 | self.xlabel = "Time (ms)" | |
|
163 | else: | |
|
164 | x = self.data.xrange[2] | |
|
165 | self.xlabel = "Velocity (m/s)" | |
|
166 | ||
|
167 | if self.CODE == 'spc_moments': | |
|
168 | x = self.data.xrange[2] | |
|
169 | self.xlabel = "Velocity (m/s)" | |
|
170 | ||
|
171 | self.titles = [] | |
|
172 | #self.xlabel = "Velocidad (m/s)" | |
|
173 | #self.ylabel = 'Rango (km)' | |
|
174 | ||
|
175 | ||
|
176 | y = self.data.heights | |
|
177 | self.y = y | |
|
178 | z = self.data['spc'] | |
|
179 | ||
|
180 | self.CODE2 = 'spc_oblique' | |
|
181 | ||
|
182 | ||
|
183 | for n, ax in enumerate(self.axes): | |
|
184 | noise = self.data['noise'][n][-1] | |
|
185 | if self.CODE == 'spc_moments': | |
|
186 | mean = self.data['moments'][n, :, 1, :][-1] | |
|
187 | if self.CODE2 == 'spc_oblique': | |
|
188 | shift1 = self.data.shift1 | |
|
189 | shift2 = self.data.shift2 | |
|
190 | if ax.firsttime: | |
|
191 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) | |
|
192 | self.xmin = self.xmin if self.xmin else -self.xmax | |
|
193 | self.zmin = self.zmin if self.zmin else numpy.nanmin(z) | |
|
194 | self.zmax = self.zmax if self.zmax else numpy.nanmax(z) | |
|
195 | #print(numpy.shape(x)) | |
|
196 | ax.plt = ax.pcolormesh(x, y, z[n].T, | |
|
197 | vmin=self.zmin, | |
|
198 | vmax=self.zmax, | |
|
199 | cmap=plt.get_cmap(self.colormap) | |
|
200 | ) | |
|
201 | ||
|
202 | if self.showprofile: | |
|
203 | ax.plt_profile = self.pf_axes[n].plot( | |
|
204 | self.data['rti'][n][-1], y)[0] | |
|
205 | ax.plt_noise = self.pf_axes[n].plot(numpy.repeat(noise, len(y)), y, | |
|
206 | color="k", linestyle="dashed", lw=1)[0] | |
|
207 | if self.CODE == 'spc_moments': | |
|
208 | ax.plt_mean = ax.plot(mean, y, color='k')[0] | |
|
209 | ||
|
210 | if self.CODE2 == 'spc_oblique': | |
|
211 | #ax.plt_shift1 = ax.plot(shift1, y, color='k', marker='x', linestyle='None', markersize=0.5)[0] | |
|
212 | #ax.plt_shift2 = ax.plot(shift2, y, color='m', marker='x', linestyle='None', markersize=0.5)[0] | |
|
213 | self.ploterr1 = ax.errorbar(shift1, y, xerr=self.data.shift1_error,fmt='k^',elinewidth=0.2,marker='x',linestyle='None',markersize=0.5,capsize=0.3,markeredgewidth=0.2) | |
|
214 | self.ploterr2 = ax.errorbar(shift2, y, xerr=self.data.shift2_error,fmt='m^',elinewidth=0.2,marker='x',linestyle='None',markersize=0.5,capsize=0.3,markeredgewidth=0.2) | |
|
215 | ||
|
216 | else: | |
|
217 | self.ploterr1.remove() | |
|
218 | self.ploterr2.remove() | |
|
219 | ax.plt.set_array(z[n].T.ravel()) | |
|
220 | if self.showprofile: | |
|
221 | ax.plt_profile.set_data(self.data['rti'][n][-1], y) | |
|
222 | ax.plt_noise.set_data(numpy.repeat(noise, len(y)), y) | |
|
223 | if self.CODE == 'spc_moments': | |
|
224 | ax.plt_mean.set_data(mean, y) | |
|
225 | if self.CODE2 == 'spc_oblique': | |
|
226 | #ax.plt_shift1.set_data(shift1, y) | |
|
227 | #ax.plt_shift2.set_data(shift2, y) | |
|
228 | #ax.clf() | |
|
229 | self.ploterr1 = ax.errorbar(shift1, y, xerr=self.data.shift1_error,fmt='k^',elinewidth=0.2,marker='x',linestyle='None',markersize=0.5,capsize=0.3,markeredgewidth=0.2) | |
|
230 | self.ploterr2 = ax.errorbar(shift2, y, xerr=self.data.shift2_error,fmt='m^',elinewidth=0.2,marker='x',linestyle='None',markersize=0.5,capsize=0.3,markeredgewidth=0.2) | |
|
231 | ||
|
232 | self.titles.append('CH {}: {:3.2f}dB'.format(n, noise)) | |
|
233 | #self.titles.append('{}'.format('Velocidad Doppler')) | |
|
124 | 234 | |
|
125 | 235 | class CrossSpectraPlot(Plot): |
|
126 | 236 | |
@@ -138,7 +248,7 class CrossSpectraPlot(Plot): | |||
|
138 | 248 | self.nplots = len(self.data.pairs) * 2 |
|
139 | 249 | self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9) |
|
140 | 250 | self.width = 3.1 * self.ncols |
|
141 |
self.height = |
|
|
251 | self.height = 5 * self.nrows | |
|
142 | 252 | self.ylabel = 'Range [km]' |
|
143 | 253 | self.showprofile = False |
|
144 | 254 | self.plots_adjust.update({'left': 0.08, 'right': 0.92, 'wspace': 0.5, 'hspace':0.4, 'top':0.95, 'bottom': 0.08}) |
@@ -177,7 +287,7 class CrossSpectraPlot(Plot): | |||
|
177 | 287 | else: |
|
178 | 288 | x = self.data.xrange[2] |
|
179 | 289 | self.xlabel = "Velocity (m/s)" |
|
180 | ||
|
290 | ||
|
181 | 291 | self.titles = [] |
|
182 | 292 | |
|
183 | 293 | y = self.data.yrange |
@@ -207,13 +317,339 class CrossSpectraPlot(Plot): | |||
|
207 | 317 | ax.plt = ax.pcolormesh(x, y, phase.T, |
|
208 | 318 | vmin=-180, |
|
209 | 319 | vmax=180, |
|
210 |
cmap=plt.get_cmap(self.colormap_phase) |
|
|
320 | cmap=plt.get_cmap(self.colormap_phase) | |
|
211 | 321 | ) |
|
212 | 322 | else: |
|
213 | 323 | ax.plt.set_array(phase.T.ravel()) |
|
214 | 324 | self.titles.append('Phase CH{} * CH{}'.format(pair[0], pair[1])) |
|
215 | 325 | |
|
216 | 326 | |
|
327 | class CrossSpectra4Plot(Plot): | |
|
328 | ||
|
329 | CODE = 'cspc' | |
|
330 | colormap = 'jet' | |
|
331 | plot_type = 'pcolor' | |
|
332 | zmin_coh = None | |
|
333 | zmax_coh = None | |
|
334 | zmin_phase = None | |
|
335 | zmax_phase = None | |
|
336 | ||
|
337 | def setup(self): | |
|
338 | ||
|
339 | self.ncols = 4 | |
|
340 | self.nrows = len(self.data.pairs) | |
|
341 | self.nplots = self.nrows * 4 | |
|
342 | self.width = 3.1 * self.ncols | |
|
343 | self.height = 5 * self.nrows | |
|
344 | self.ylabel = 'Range [km]' | |
|
345 | self.showprofile = False | |
|
346 | self.plots_adjust.update({'left': 0.08, 'right': 0.92, 'wspace': 0.5, 'hspace':0.4, 'top':0.95, 'bottom': 0.08}) | |
|
347 | ||
|
348 | def plot(self): | |
|
349 | ||
|
350 | if self.xaxis == "frequency": | |
|
351 | x = self.data.xrange[0] | |
|
352 | self.xlabel = "Frequency (kHz)" | |
|
353 | elif self.xaxis == "time": | |
|
354 | x = self.data.xrange[1] | |
|
355 | self.xlabel = "Time (ms)" | |
|
356 | else: | |
|
357 | x = self.data.xrange[2] | |
|
358 | self.xlabel = "Velocity (m/s)" | |
|
359 | ||
|
360 | self.titles = [] | |
|
361 | ||
|
362 | ||
|
363 | y = self.data.heights | |
|
364 | self.y = y | |
|
365 | nspc = self.data['spc'] | |
|
366 | #print(numpy.shape(self.data['spc'])) | |
|
367 | spc = self.data['cspc'][0] | |
|
368 | #print(numpy.shape(nspc)) | |
|
369 | #exit() | |
|
370 | #nspc[1,:,:] = numpy.flip(nspc[1,:,:],axis=0) | |
|
371 | #print(numpy.shape(spc)) | |
|
372 | #exit() | |
|
373 | cspc = self.data['cspc'][1] | |
|
374 | ||
|
375 | #xflip=numpy.flip(x) | |
|
376 | #print(numpy.shape(cspc)) | |
|
377 | #exit() | |
|
378 | ||
|
379 | for n in range(self.nrows): | |
|
380 | noise = self.data['noise'][:,-1] | |
|
381 | pair = self.data.pairs[n] | |
|
382 | #print(pair) | |
|
383 | #exit() | |
|
384 | ax = self.axes[4 * n] | |
|
385 | if ax.firsttime: | |
|
386 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) | |
|
387 | self.xmin = self.xmin if self.xmin else -self.xmax | |
|
388 | self.zmin = self.zmin if self.zmin else numpy.nanmin(nspc) | |
|
389 | self.zmax = self.zmax if self.zmax else numpy.nanmax(nspc) | |
|
390 | ax.plt = ax.pcolormesh(x , y , nspc[pair[0]].T, | |
|
391 | vmin=self.zmin, | |
|
392 | vmax=self.zmax, | |
|
393 | cmap=plt.get_cmap(self.colormap) | |
|
394 | ) | |
|
395 | else: | |
|
396 | #print(numpy.shape(nspc[pair[0]].T)) | |
|
397 | #exit() | |
|
398 | ax.plt.set_array(nspc[pair[0]].T.ravel()) | |
|
399 | self.titles.append('CH {}: {:3.2f}dB'.format(pair[0], noise[pair[0]])) | |
|
400 | ||
|
401 | ax = self.axes[4 * n + 1] | |
|
402 | ||
|
403 | if ax.firsttime: | |
|
404 | ax.plt = ax.pcolormesh(x , y, numpy.flip(nspc[pair[1]],axis=0).T, | |
|
405 | vmin=self.zmin, | |
|
406 | vmax=self.zmax, | |
|
407 | cmap=plt.get_cmap(self.colormap) | |
|
408 | ) | |
|
409 | else: | |
|
410 | ||
|
411 | ax.plt.set_array(numpy.flip(nspc[pair[1]],axis=0).T.ravel()) | |
|
412 | self.titles.append('CH {}: {:3.2f}dB'.format(pair[1], noise[pair[1]])) | |
|
413 | ||
|
414 | out = cspc[n] / numpy.sqrt(spc[pair[0]] * spc[pair[1]]) | |
|
415 | coh = numpy.abs(out) | |
|
416 | phase = numpy.arctan2(out.imag, out.real) * 180 / numpy.pi | |
|
417 | ||
|
418 | ax = self.axes[4 * n + 2] | |
|
419 | if ax.firsttime: | |
|
420 | ax.plt = ax.pcolormesh(x, y, numpy.flip(coh,axis=0).T, | |
|
421 | vmin=0, | |
|
422 | vmax=1, | |
|
423 | cmap=plt.get_cmap(self.colormap_coh) | |
|
424 | ) | |
|
425 | else: | |
|
426 | ax.plt.set_array(numpy.flip(coh,axis=0).T.ravel()) | |
|
427 | self.titles.append( | |
|
428 | 'Coherence Ch{} * Ch{}'.format(pair[0], pair[1])) | |
|
429 | ||
|
430 | ax = self.axes[4 * n + 3] | |
|
431 | if ax.firsttime: | |
|
432 | ax.plt = ax.pcolormesh(x, y, numpy.flip(phase,axis=0).T, | |
|
433 | vmin=-180, | |
|
434 | vmax=180, | |
|
435 | cmap=plt.get_cmap(self.colormap_phase) | |
|
436 | ) | |
|
437 | else: | |
|
438 | ax.plt.set_array(numpy.flip(phase,axis=0).T.ravel()) | |
|
439 | self.titles.append('Phase CH{} * CH{}'.format(pair[0], pair[1])) | |
|
440 | ||
|
441 | ||
|
442 | class CrossSpectra2Plot(Plot): | |
|
443 | ||
|
444 | CODE = 'cspc' | |
|
445 | colormap = 'jet' | |
|
446 | plot_type = 'pcolor' | |
|
447 | zmin_coh = None | |
|
448 | zmax_coh = None | |
|
449 | zmin_phase = None | |
|
450 | zmax_phase = None | |
|
451 | ||
|
452 | def setup(self): | |
|
453 | ||
|
454 | self.ncols = 1 | |
|
455 | self.nrows = len(self.data.pairs) | |
|
456 | self.nplots = self.nrows * 1 | |
|
457 | self.width = 3.1 * self.ncols | |
|
458 | self.height = 5 * self.nrows | |
|
459 | self.ylabel = 'Range [km]' | |
|
460 | self.showprofile = False | |
|
461 | self.plots_adjust.update({'left': 0.22, 'right': .90, 'wspace': 0.5, 'hspace':0.4, 'top':0.95, 'bottom': 0.08}) | |
|
462 | ||
|
463 | def plot(self): | |
|
464 | ||
|
465 | if self.xaxis == "frequency": | |
|
466 | x = self.data.xrange[0] | |
|
467 | self.xlabel = "Frequency (kHz)" | |
|
468 | elif self.xaxis == "time": | |
|
469 | x = self.data.xrange[1] | |
|
470 | self.xlabel = "Time (ms)" | |
|
471 | else: | |
|
472 | x = self.data.xrange[2] | |
|
473 | self.xlabel = "Velocity (m/s)" | |
|
474 | ||
|
475 | self.titles = [] | |
|
476 | ||
|
477 | ||
|
478 | y = self.data.heights | |
|
479 | self.y = y | |
|
480 | #nspc = self.data['spc'] | |
|
481 | #print(numpy.shape(self.data['spc'])) | |
|
482 | #spc = self.data['cspc'][0] | |
|
483 | #print(numpy.shape(spc)) | |
|
484 | #exit() | |
|
485 | cspc = self.data['cspc'][1] | |
|
486 | #print(numpy.shape(cspc)) | |
|
487 | #exit() | |
|
488 | ||
|
489 | for n in range(self.nrows): | |
|
490 | noise = self.data['noise'][:,-1] | |
|
491 | pair = self.data.pairs[n] | |
|
492 | #print(pair) #exit() | |
|
493 | ||
|
494 | ||
|
495 | ||
|
496 | out = cspc[n]# / numpy.sqrt(spc[pair[0]] * spc[pair[1]]) | |
|
497 | ||
|
498 | #print(out[:,53]) | |
|
499 | #exit() | |
|
500 | cross = numpy.abs(out) | |
|
501 | z = cross/self.data.nFactor | |
|
502 | #print("here") | |
|
503 | #print(dataOut.data_spc[0,0,0]) | |
|
504 | #exit() | |
|
505 | ||
|
506 | cross = 10*numpy.log10(z) | |
|
507 | #print(numpy.shape(cross)) | |
|
508 | #print(cross[0,:]) | |
|
509 | #print(self.data.nFactor) | |
|
510 | #exit() | |
|
511 | #phase = numpy.arctan2(out.imag, out.real) * 180 / numpy.pi | |
|
512 | ||
|
513 | ax = self.axes[1 * n] | |
|
514 | if ax.firsttime: | |
|
515 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) | |
|
516 | self.xmin = self.xmin if self.xmin else -self.xmax | |
|
517 | self.zmin = self.zmin if self.zmin else numpy.nanmin(cross) | |
|
518 | self.zmax = self.zmax if self.zmax else numpy.nanmax(cross) | |
|
519 | ax.plt = ax.pcolormesh(x, y, cross.T, | |
|
520 | vmin=self.zmin, | |
|
521 | vmax=self.zmax, | |
|
522 | cmap=plt.get_cmap(self.colormap) | |
|
523 | ) | |
|
524 | else: | |
|
525 | ax.plt.set_array(cross.T.ravel()) | |
|
526 | self.titles.append( | |
|
527 | 'Cross Spectra Power Ch{} * Ch{}'.format(pair[0], pair[1])) | |
|
528 | ||
|
529 | ||
|
530 | class CrossSpectra3Plot(Plot): | |
|
531 | ||
|
532 | CODE = 'cspc' | |
|
533 | colormap = 'jet' | |
|
534 | plot_type = 'pcolor' | |
|
535 | zmin_coh = None | |
|
536 | zmax_coh = None | |
|
537 | zmin_phase = None | |
|
538 | zmax_phase = None | |
|
539 | ||
|
540 | def setup(self): | |
|
541 | ||
|
542 | self.ncols = 3 | |
|
543 | self.nrows = len(self.data.pairs) | |
|
544 | self.nplots = self.nrows * 3 | |
|
545 | self.width = 3.1 * self.ncols | |
|
546 | self.height = 5 * self.nrows | |
|
547 | self.ylabel = 'Range [km]' | |
|
548 | self.showprofile = False | |
|
549 | self.plots_adjust.update({'left': 0.22, 'right': .90, 'wspace': 0.5, 'hspace':0.4, 'top':0.95, 'bottom': 0.08}) | |
|
550 | ||
|
551 | def plot(self): | |
|
552 | ||
|
553 | if self.xaxis == "frequency": | |
|
554 | x = self.data.xrange[0] | |
|
555 | self.xlabel = "Frequency (kHz)" | |
|
556 | elif self.xaxis == "time": | |
|
557 | x = self.data.xrange[1] | |
|
558 | self.xlabel = "Time (ms)" | |
|
559 | else: | |
|
560 | x = self.data.xrange[2] | |
|
561 | self.xlabel = "Velocity (m/s)" | |
|
562 | ||
|
563 | self.titles = [] | |
|
564 | ||
|
565 | ||
|
566 | y = self.data.heights | |
|
567 | self.y = y | |
|
568 | #nspc = self.data['spc'] | |
|
569 | #print(numpy.shape(self.data['spc'])) | |
|
570 | #spc = self.data['cspc'][0] | |
|
571 | #print(numpy.shape(spc)) | |
|
572 | #exit() | |
|
573 | cspc = self.data['cspc'][1] | |
|
574 | #print(numpy.shape(cspc)) | |
|
575 | #exit() | |
|
576 | ||
|
577 | for n in range(self.nrows): | |
|
578 | noise = self.data['noise'][:,-1] | |
|
579 | pair = self.data.pairs[n] | |
|
580 | #print(pair) #exit() | |
|
581 | ||
|
582 | ||
|
583 | ||
|
584 | out = cspc[n]# / numpy.sqrt(spc[pair[0]] * spc[pair[1]]) | |
|
585 | ||
|
586 | #print(out[:,53]) | |
|
587 | #exit() | |
|
588 | cross = numpy.abs(out) | |
|
589 | z = cross/self.data.nFactor | |
|
590 | cross = 10*numpy.log10(z) | |
|
591 | ||
|
592 | out_r= out.real/self.data.nFactor | |
|
593 | #out_r = 10*numpy.log10(out_r) | |
|
594 | ||
|
595 | out_i= out.imag/self.data.nFactor | |
|
596 | #out_i = 10*numpy.log10(out_i) | |
|
597 | #print(numpy.shape(cross)) | |
|
598 | #print(cross[0,:]) | |
|
599 | #print(self.data.nFactor) | |
|
600 | #exit() | |
|
601 | #phase = numpy.arctan2(out.imag, out.real) * 180 / numpy.pi | |
|
602 | ||
|
603 | ax = self.axes[3 * n] | |
|
604 | if ax.firsttime: | |
|
605 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) | |
|
606 | self.xmin = self.xmin if self.xmin else -self.xmax | |
|
607 | self.zmin = self.zmin if self.zmin else numpy.nanmin(cross) | |
|
608 | self.zmax = self.zmax if self.zmax else numpy.nanmax(cross) | |
|
609 | ax.plt = ax.pcolormesh(x, y, cross.T, | |
|
610 | vmin=self.zmin, | |
|
611 | vmax=self.zmax, | |
|
612 | cmap=plt.get_cmap(self.colormap) | |
|
613 | ) | |
|
614 | else: | |
|
615 | ax.plt.set_array(cross.T.ravel()) | |
|
616 | self.titles.append( | |
|
617 | 'Cross Spectra Power Ch{} * Ch{}'.format(pair[0], pair[1])) | |
|
618 | ||
|
619 | ax = self.axes[3 * n + 1] | |
|
620 | if ax.firsttime: | |
|
621 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) | |
|
622 | self.xmin = self.xmin if self.xmin else -self.xmax | |
|
623 | self.zmin = self.zmin if self.zmin else numpy.nanmin(cross) | |
|
624 | self.zmax = self.zmax if self.zmax else numpy.nanmax(cross) | |
|
625 | ax.plt = ax.pcolormesh(x, y, out_r.T, | |
|
626 | vmin=-1.e6, | |
|
627 | vmax=0, | |
|
628 | cmap=plt.get_cmap(self.colormap) | |
|
629 | ) | |
|
630 | else: | |
|
631 | ax.plt.set_array(out_r.T.ravel()) | |
|
632 | self.titles.append( | |
|
633 | 'Cross Spectra Real Ch{} * Ch{}'.format(pair[0], pair[1])) | |
|
634 | ||
|
635 | ax = self.axes[3 * n + 2] | |
|
636 | ||
|
637 | ||
|
638 | if ax.firsttime: | |
|
639 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) | |
|
640 | self.xmin = self.xmin if self.xmin else -self.xmax | |
|
641 | self.zmin = self.zmin if self.zmin else numpy.nanmin(cross) | |
|
642 | self.zmax = self.zmax if self.zmax else numpy.nanmax(cross) | |
|
643 | ax.plt = ax.pcolormesh(x, y, out_i.T, | |
|
644 | vmin=-1.e6, | |
|
645 | vmax=1.e6, | |
|
646 | cmap=plt.get_cmap(self.colormap) | |
|
647 | ) | |
|
648 | else: | |
|
649 | ax.plt.set_array(out_i.T.ravel()) | |
|
650 | self.titles.append( | |
|
651 | 'Cross Spectra Imag Ch{} * Ch{}'.format(pair[0], pair[1])) | |
|
652 | ||
|
217 | 653 | class RTIPlot(Plot): |
|
218 | 654 | ''' |
|
219 | 655 | Plot for RTI data |
@@ -231,7 +667,7 class RTIPlot(Plot): | |||
|
231 | 667 | self.ylabel = 'Range [km]' |
|
232 | 668 | self.xlabel = 'Time' |
|
233 | 669 | self.cb_label = 'dB' |
|
234 |
self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0. |
|
|
670 | self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.1, 'right':0.95}) | |
|
235 | 671 | self.titles = ['{} Channel {}'.format( |
|
236 | 672 | self.CODE.upper(), x) for x in range(self.nrows)] |
|
237 | 673 | |
@@ -248,6 +684,78 class RTIPlot(Plot): | |||
|
248 | 684 | self.x = self.data.times |
|
249 | 685 | self.y = self.data.yrange |
|
250 | 686 | self.z = self.data[self.CODE] |
|
687 | ||
|
688 | self.z = numpy.ma.masked_invalid(self.z) | |
|
689 | ||
|
690 | if self.decimation is None: | |
|
691 | x, y, z = self.fill_gaps(self.x, self.y, self.z) | |
|
692 | else: | |
|
693 | x, y, z = self.fill_gaps(*self.decimate()) | |
|
694 | ||
|
695 | for n, ax in enumerate(self.axes): | |
|
696 | self.zmin = self.zmin if self.zmin else numpy.min(self.z) | |
|
697 | self.zmax = self.zmax if self.zmax else numpy.max(self.z) | |
|
698 | if ax.firsttime: | |
|
699 | ax.plt = ax.pcolormesh(x, y, z[n].T, | |
|
700 | vmin=self.zmin, | |
|
701 | vmax=self.zmax, | |
|
702 | cmap=plt.get_cmap(self.colormap) | |
|
703 | ) | |
|
704 | if self.showprofile: | |
|
705 | ax.plot_profile = self.pf_axes[n].plot( | |
|
706 | self.data['rti'][n][-1], self.y)[0] | |
|
707 | ax.plot_noise = self.pf_axes[n].plot(numpy.repeat(self.data['noise'][n][-1], len(self.y)), self.y, | |
|
708 | color="k", linestyle="dashed", lw=1)[0] | |
|
709 | else: | |
|
710 | ax.collections.remove(ax.collections[0]) | |
|
711 | ax.plt = ax.pcolormesh(x, y, z[n].T, | |
|
712 | vmin=self.zmin, | |
|
713 | vmax=self.zmax, | |
|
714 | cmap=plt.get_cmap(self.colormap) | |
|
715 | ) | |
|
716 | if self.showprofile: | |
|
717 | ax.plot_profile.set_data(self.data['rti'][n][-1], self.y) | |
|
718 | ax.plot_noise.set_data(numpy.repeat( | |
|
719 | self.data['noise'][n][-1], len(self.y)), self.y) | |
|
720 | ||
|
721 | ||
|
722 | class SpectrogramPlot(Plot): | |
|
723 | ''' | |
|
724 | Plot for Spectrogram data | |
|
725 | ''' | |
|
726 | ||
|
727 | CODE = 'spectrogram' | |
|
728 | colormap = 'binary' | |
|
729 | plot_type = 'pcolorbuffer' | |
|
730 | ||
|
731 | def setup(self): | |
|
732 | self.xaxis = 'time' | |
|
733 | self.ncols = 1 | |
|
734 | self.nrows = len(self.data.channels) | |
|
735 | self.nplots = len(self.data.channels) | |
|
736 | #print(self.dataOut.heightList) | |
|
737 | #self.ylabel = 'Range [km]' | |
|
738 | self.xlabel = 'Time' | |
|
739 | self.cb_label = 'dB' | |
|
740 | self.plots_adjust.update({'hspace':1.2, 'left': 0.1, 'bottom': 0.12, 'right':0.95}) | |
|
741 | self.titles = ['{} Channel {} \n H = {} km ({} - {})'.format( | |
|
742 | self.CODE.upper(), x, self.data.heightList[self.data.hei], self.data.heightList[self.data.hei],self.data.heightList[self.data.hei]+(self.data.DH*self.data.nProfiles)) for x in range(self.nrows)] | |
|
743 | ||
|
744 | def plot(self): | |
|
745 | self.x = self.data.times | |
|
746 | #self.y = self.data.heights | |
|
747 | self.z = self.data[self.CODE] | |
|
748 | self.y = self.data.xrange[0] | |
|
749 | #import time | |
|
750 | #print(time.ctime(self.x)) | |
|
751 | ||
|
752 | ''' | |
|
753 | print(numpy.shape(self.x)) | |
|
754 | print(numpy.shape(self.y)) | |
|
755 | print(numpy.shape(self.z)) | |
|
756 | ''' | |
|
757 | self.ylabel = "Frequency (kHz)" | |
|
758 | ||
|
251 | 759 | self.z = numpy.ma.masked_invalid(self.z) |
|
252 | 760 | |
|
253 | 761 | if self.decimation is None: |
@@ -335,7 +843,7 class PhasePlot(CoherencePlot): | |||
|
335 | 843 | |
|
336 | 844 | class NoisePlot(Plot): |
|
337 | 845 | ''' |
|
338 |
Plot for noise |
|
|
846 | Plot for noise | |
|
339 | 847 | ''' |
|
340 | 848 | |
|
341 | 849 | CODE = 'noise' |
@@ -380,7 +888,10 class NoisePlot(Plot): | |||
|
380 | 888 | y = Y[ch] |
|
381 | 889 | self.axes[0].lines[ch].set_data(x, y) |
|
382 | 890 | |
|
383 | ||
|
891 | self.ymin = numpy.nanmin(Y) - 5 | |
|
892 | self.ymax = numpy.nanmax(Y) + 10 | |
|
893 | ||
|
894 | ||
|
384 | 895 | class PowerProfilePlot(Plot): |
|
385 | 896 | |
|
386 | 897 | CODE = 'pow_profile' |
@@ -415,7 +926,7 class PowerProfilePlot(Plot): | |||
|
415 | 926 | |
|
416 | 927 | if self.xmin is None: self.xmin = numpy.nanmin(x)*0.9 |
|
417 | 928 | if self.xmax is None: self.xmax = numpy.nanmax(x)*1.1 |
|
418 | ||
|
929 | ||
|
419 | 930 | if self.axes[0].firsttime: |
|
420 | 931 | for ch in self.data.channels: |
|
421 | 932 | self.axes[0].plot(x[ch], y, lw=1, label='Ch{}'.format(ch)) |
@@ -600,7 +1111,7 class BeaconPhase(Plot): | |||
|
600 | 1111 | server=None, folder=None, username=None, password=None, |
|
601 | 1112 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): |
|
602 | 1113 | |
|
603 |
if dataOut.flagNoData: |
|
|
1114 | if dataOut.flagNoData: | |
|
604 | 1115 | return dataOut |
|
605 | 1116 | |
|
606 | 1117 | if not isTimeInHourRange(dataOut.datatime, xmin, xmax): |
@@ -740,4 +1251,4 class BeaconPhase(Plot): | |||
|
740 | 1251 | thisDatetime=thisDatetime, |
|
741 | 1252 | update_figfile=update_figfile) |
|
742 | 1253 | |
|
743 | return dataOut No newline at end of file | |
|
1254 | return dataOut |
@@ -21,4 +21,9 from .jroIO_mira35c import * | |||
|
21 | 21 | from .julIO_param import * |
|
22 | 22 | |
|
23 | 23 | from .pxIO_param import * |
|
24 | from .jroIO_simulator import * No newline at end of file | |
|
24 | from .jroIO_simulator import * | |
|
25 | ||
|
26 | ############DP############ | |
|
27 | from .jroIO_dat import * | |
|
28 | ||
|
29 | ############DP############ |
@@ -78,6 +78,7 def isFileInEpoch(filename, startUTSeconds, endUTSeconds): | |||
|
78 | 78 | basicHeaderObj = BasicHeader(LOCALTIME) |
|
79 | 79 | |
|
80 | 80 | try: |
|
81 | ||
|
81 | 82 | fp = open(filename, 'rb') |
|
82 | 83 | except IOError: |
|
83 | 84 | print("The file %s can't be opened" % (filename)) |
@@ -140,6 +141,7 def isFileInTimeRange(filename, startDate, endDate, startTime, endTime): | |||
|
140 | 141 | |
|
141 | 142 | firstBasicHeaderObj = BasicHeader(LOCALTIME) |
|
142 | 143 | systemHeaderObj = SystemHeader() |
|
144 | ||
|
143 | 145 | radarControllerHeaderObj = RadarControllerHeader() |
|
144 | 146 | processingHeaderObj = ProcessingHeader() |
|
145 | 147 | |
@@ -384,7 +386,7 def isRadarFolder(folder): | |||
|
384 | 386 | |
|
385 | 387 | |
|
386 | 388 | def isRadarFile(file): |
|
387 |
try: |
|
|
389 | try: | |
|
388 | 390 | year = int(file[1:5]) |
|
389 | 391 | doy = int(file[5:8]) |
|
390 | 392 | set = int(file[8:11]) |
@@ -395,10 +397,10 def isRadarFile(file): | |||
|
395 | 397 | |
|
396 | 398 | |
|
397 | 399 | def getDateFromRadarFile(file): |
|
398 |
try: |
|
|
400 | try: | |
|
399 | 401 | year = int(file[1:5]) |
|
400 | 402 | doy = int(file[5:8]) |
|
401 |
set = int(file[8:11]) |
|
|
403 | set = int(file[8:11]) | |
|
402 | 404 | except: |
|
403 | 405 | return None |
|
404 | 406 | |
@@ -417,7 +419,7 def getDateFromRadarFolder(folder): | |||
|
417 | 419 | return thisDate |
|
418 | 420 | |
|
419 | 421 | def parse_format(s, fmt): |
|
420 | ||
|
422 | ||
|
421 | 423 | for i in range(fmt.count('%')): |
|
422 | 424 | x = fmt.index('%') |
|
423 | 425 | d = DT_DIRECTIVES[fmt[x:x+2]] |
@@ -484,7 +486,7 class Reader(object): | |||
|
484 | 486 | |
|
485 | 487 | def run(self): |
|
486 | 488 | |
|
487 |
raise NotImplementedError |
|
|
489 | raise NotImplementedError | |
|
488 | 490 | |
|
489 | 491 | def getAllowedArgs(self): |
|
490 | 492 | if hasattr(self, '__attrs__'): |
@@ -496,19 +498,19 class Reader(object): | |||
|
496 | 498 | |
|
497 | 499 | for key, value in kwargs.items(): |
|
498 | 500 | setattr(self, key, value) |
|
499 | ||
|
501 | ||
|
500 | 502 | def find_folders(self, path, startDate, endDate, folderfmt, last=False): |
|
501 | 503 | |
|
502 |
folders = [x for f in path.split(',') |
|
|
504 | folders = [x for f in path.split(',') | |
|
503 | 505 | for x in os.listdir(f) if os.path.isdir(os.path.join(f, x))] |
|
504 | 506 | folders.sort() |
|
505 | 507 | |
|
506 | 508 | if last: |
|
507 | 509 | folders = [folders[-1]] |
|
508 | 510 | |
|
509 |
for folder in folders: |
|
|
510 |
try: |
|
|
511 |
dt = datetime.datetime.strptime(parse_format(folder, folderfmt), folderfmt).date() |
|
|
511 | for folder in folders: | |
|
512 | try: | |
|
513 | dt = datetime.datetime.strptime(parse_format(folder, folderfmt), folderfmt).date() | |
|
512 | 514 | if dt >= startDate and dt <= endDate: |
|
513 | 515 | yield os.path.join(path, folder) |
|
514 | 516 | else: |
@@ -517,38 +519,44 class Reader(object): | |||
|
517 | 519 | log.log('Skiping folder {}'.format(folder), self.name) |
|
518 | 520 | continue |
|
519 | 521 | return |
|
520 | ||
|
521 |
def find_files(self, folders, ext, filefmt, startDate=None, endDate=None, |
|
|
522 | ||
|
523 | def find_files(self, folders, ext, filefmt, startDate=None, endDate=None, | |
|
522 | 524 | expLabel='', last=False): |
|
523 | ||
|
524 |
for path in folders: |
|
|
525 | ||
|
526 | for path in folders: | |
|
525 | 527 | files = glob.glob1(path, '*{}'.format(ext)) |
|
526 | 528 | files.sort() |
|
527 | 529 | if last: |
|
528 |
if files: |
|
|
530 | if files: | |
|
529 | 531 | fo = files[-1] |
|
530 |
try: |
|
|
532 | try: | |
|
531 | 533 | dt = datetime.datetime.strptime(parse_format(fo, filefmt), filefmt).date() |
|
532 |
yield os.path.join(path, expLabel, fo) |
|
|
533 |
except Exception as e: |
|
|
534 | yield os.path.join(path, expLabel, fo) | |
|
535 | except Exception as e: | |
|
534 | 536 | pass |
|
535 | 537 | return |
|
536 | 538 | else: |
|
537 | 539 | return |
|
538 | 540 | |
|
539 | 541 | for fo in files: |
|
540 |
try: |
|
|
541 |
dt = datetime.datetime.strptime(parse_format(fo, filefmt), filefmt).date() |
|
|
542 | try: | |
|
543 | dt = datetime.datetime.strptime(parse_format(fo, filefmt), filefmt).date() | |
|
544 | #print(dt) | |
|
545 | #print(startDate) | |
|
546 | #print(endDate) | |
|
542 | 547 | if dt >= startDate and dt <= endDate: |
|
548 | ||
|
543 | 549 | yield os.path.join(path, expLabel, fo) |
|
550 | ||
|
544 | 551 | else: |
|
552 | ||
|
545 | 553 | log.log('Skiping file {}'.format(fo), self.name) |
|
546 | 554 | except Exception as e: |
|
547 | 555 | log.log('Skiping file {}'.format(fo), self.name) |
|
548 |
continue |
|
|
556 | continue | |
|
549 | 557 | |
|
550 | 558 | def searchFilesOffLine(self, path, startDate, endDate, |
|
551 |
expLabel, ext, walk, |
|
|
559 | expLabel, ext, walk, | |
|
552 | 560 | filefmt, folderfmt): |
|
553 | 561 | """Search files in offline mode for the given arguments |
|
554 | 562 | |
@@ -561,12 +569,12 class Reader(object): | |||
|
561 | 569 | path, startDate, endDate, folderfmt) |
|
562 | 570 | else: |
|
563 | 571 | folders = path.split(',') |
|
564 | ||
|
572 | ||
|
565 | 573 | return self.find_files( |
|
566 |
folders, ext, filefmt, startDate, endDate, expLabel) |
|
|
574 | folders, ext, filefmt, startDate, endDate, expLabel) | |
|
567 | 575 | |
|
568 | 576 | def searchFilesOnLine(self, path, startDate, endDate, |
|
569 |
expLabel, ext, walk, |
|
|
577 | expLabel, ext, walk, | |
|
570 | 578 | filefmt, folderfmt): |
|
571 | 579 | """Search for the last file of the last folder |
|
572 | 580 | |
@@ -579,40 +587,54 class Reader(object): | |||
|
579 | 587 | Return: |
|
580 | 588 | generator with the full path of last filename |
|
581 | 589 | """ |
|
582 | ||
|
590 | ||
|
583 | 591 | if walk: |
|
584 | 592 | folders = self.find_folders( |
|
585 | 593 | path, startDate, endDate, folderfmt, last=True) |
|
586 | 594 | else: |
|
587 | 595 | folders = path.split(',') |
|
588 | ||
|
596 | ||
|
589 | 597 | return self.find_files( |
|
590 | 598 | folders, ext, filefmt, startDate, endDate, expLabel, last=True) |
|
591 | 599 | |
|
592 | 600 | def setNextFile(self): |
|
593 | 601 | """Set the next file to be readed open it and parse de file header""" |
|
594 | 602 | |
|
603 | #print("fp: ",self.fp) | |
|
595 | 604 | while True: |
|
605 | ||
|
606 | #print(self.fp) | |
|
596 | 607 | if self.fp != None: |
|
597 |
self.fp.close() |
|
|
608 | self.fp.close() | |
|
598 | 609 | |
|
610 | #print("setNextFile") | |
|
611 | #print("BEFORE OPENING",self.filename) | |
|
599 | 612 | if self.online: |
|
600 | 613 | newFile = self.setNextFileOnline() |
|
614 | ||
|
601 | 615 | else: |
|
616 | ||
|
602 | 617 | newFile = self.setNextFileOffline() |
|
603 | ||
|
618 | ||
|
619 | #print("newFile: ",newFile) | |
|
604 | 620 | if not(newFile): |
|
621 | ||
|
605 | 622 | if self.online: |
|
606 | 623 | raise schainpy.admin.SchainError('Time to wait for new files reach') |
|
607 | 624 | else: |
|
608 | 625 | if self.fileIndex == -1: |
|
626 | #print("OKK") | |
|
609 | 627 | raise schainpy.admin.SchainWarning('No files found in the given path') |
|
610 | 628 | else: |
|
629 | ||
|
611 | 630 | raise schainpy.admin.SchainWarning('No more files to read') |
|
612 | ||
|
631 | ||
|
613 | 632 | if self.verifyFile(self.filename): |
|
633 | ||
|
614 | 634 | break |
|
615 | ||
|
635 | ||
|
636 | ##print("BEFORE OPENING",self.filename) | |
|
637 | ||
|
616 | 638 | log.log('Opening file: %s' % self.filename, self.name) |
|
617 | 639 | |
|
618 | 640 | self.readFirstHeader() |
@@ -625,15 +647,16 class Reader(object): | |||
|
625 | 647 | self.filename |
|
626 | 648 | self.fp |
|
627 | 649 | self.filesize |
|
628 | ||
|
650 | ||
|
629 | 651 | Return: |
|
630 | 652 | boolean |
|
631 | 653 | |
|
632 | 654 | """ |
|
655 | ||
|
633 | 656 | nextFile = True |
|
634 | 657 | nextDay = False |
|
635 | 658 | |
|
636 |
for nFiles in range(self.nFiles+1): |
|
|
659 | for nFiles in range(self.nFiles+1): | |
|
637 | 660 | for nTries in range(self.nTries): |
|
638 | 661 | fullfilename, filename = self.checkForRealPath(nextFile, nextDay) |
|
639 | 662 | if fullfilename is not None: |
@@ -643,18 +666,18 class Reader(object): | |||
|
643 | 666 | self.name) |
|
644 | 667 | time.sleep(self.delay) |
|
645 | 668 | nextFile = False |
|
646 |
continue |
|
|
647 | ||
|
669 | continue | |
|
670 | ||
|
648 | 671 | if fullfilename is not None: |
|
649 | 672 | break |
|
650 | ||
|
651 | self.nTries = 1 | |
|
652 |
nextFile = True |
|
|
673 | ||
|
674 | #self.nTries = 1 | |
|
675 | nextFile = True | |
|
653 | 676 | |
|
654 | 677 | if nFiles == (self.nFiles - 1): |
|
655 | 678 | log.log('Trying with next day...', self.name) |
|
656 | 679 | nextDay = True |
|
657 |
self.nTries = 3 |
|
|
680 | self.nTries = 3 | |
|
658 | 681 | |
|
659 | 682 | if fullfilename: |
|
660 | 683 | self.fileSize = os.path.getsize(fullfilename) |
@@ -662,45 +685,48 class Reader(object): | |||
|
662 | 685 | self.flagIsNewFile = 1 |
|
663 | 686 | if self.fp != None: |
|
664 | 687 | self.fp.close() |
|
688 | #print(fullfilename) | |
|
665 | 689 | self.fp = self.open_file(fullfilename, self.open_mode) |
|
690 | ||
|
666 | 691 | self.flagNoMoreFiles = 0 |
|
667 | 692 | self.fileIndex += 1 |
|
668 | 693 | return 1 |
|
669 |
else: |
|
|
694 | else: | |
|
670 | 695 | return 0 |
|
671 | ||
|
696 | ||
|
672 | 697 | def setNextFileOffline(self): |
|
673 | 698 | """Open the next file to be readed in offline mode""" |
|
674 | ||
|
699 | ||
|
675 | 700 | try: |
|
676 | 701 | filename = next(self.filenameList) |
|
677 | 702 | self.fileIndex +=1 |
|
678 | 703 | except StopIteration: |
|
679 | 704 | self.flagNoMoreFiles = 1 |
|
680 |
return 0 |
|
|
681 | ||
|
705 | return 0 | |
|
706 | #print(self.fileIndex) | |
|
707 | #print(filename) | |
|
682 | 708 | self.filename = filename |
|
683 | 709 | self.fileSize = os.path.getsize(filename) |
|
684 | 710 | self.fp = self.open_file(filename, self.open_mode) |
|
685 | 711 | self.flagIsNewFile = 1 |
|
686 | 712 | |
|
687 | 713 | return 1 |
|
688 | ||
|
714 | ||
|
689 | 715 | @staticmethod |
|
690 | 716 | def isDateTimeInRange(dt, startDate, endDate, startTime, endTime): |
|
691 | 717 | """Check if the given datetime is in range""" |
|
692 | ||
|
718 | ||
|
693 | 719 | if startDate <= dt.date() <= endDate: |
|
694 | 720 | if startTime <= dt.time() <= endTime: |
|
695 | 721 | return True |
|
696 | 722 | return False |
|
697 | ||
|
723 | ||
|
698 | 724 | def verifyFile(self, filename): |
|
699 | 725 | """Check for a valid file |
|
700 | ||
|
726 | ||
|
701 | 727 | Arguments: |
|
702 | 728 | filename -- full path filename |
|
703 | ||
|
729 | ||
|
704 | 730 | Return: |
|
705 | 731 | boolean |
|
706 | 732 | """ |
@@ -711,10 +737,11 class Reader(object): | |||
|
711 | 737 | """Check if the next file to be readed exists""" |
|
712 | 738 | |
|
713 | 739 | raise NotImplementedError |
|
714 | ||
|
740 | ||
|
715 | 741 | def readFirstHeader(self): |
|
716 | 742 | """Parse the file header""" |
|
717 | 743 | |
|
744 | ||
|
718 | 745 | pass |
|
719 | 746 | |
|
720 | 747 | def waitDataBlock(self, pointer_location, blocksize=None): |
@@ -783,8 +810,8 class JRODataReader(Reader): | |||
|
783 | 810 | Return: |
|
784 | 811 | str -- fullpath of the file |
|
785 | 812 | """ |
|
786 | ||
|
787 | ||
|
813 | ||
|
814 | ||
|
788 | 815 | if nextFile: |
|
789 | 816 | self.set += 1 |
|
790 | 817 | if nextDay: |
@@ -796,7 +823,15 class JRODataReader(Reader): | |||
|
796 | 823 | prefixFileList = ['d', 'D'] |
|
797 | 824 | elif self.ext.lower() == ".pdata": # spectra |
|
798 | 825 | prefixFileList = ['p', 'P'] |
|
799 | ||
|
826 | ||
|
827 | ##############DP############## | |
|
828 | ||
|
829 | elif self.ext.lower() == ".dat": # dat | |
|
830 | prefixFileList = ['z', 'Z'] | |
|
831 | ||
|
832 | ||
|
833 | ||
|
834 | ##############DP############## | |
|
800 | 835 | # barrido por las combinaciones posibles |
|
801 | 836 | for prefixDir in prefixDirList: |
|
802 | 837 | thispath = self.path |
@@ -816,9 +851,9 class JRODataReader(Reader): | |||
|
816 | 851 | |
|
817 | 852 | if os.path.exists(fullfilename): |
|
818 | 853 | return fullfilename, filename |
|
819 | ||
|
820 |
return None, filename |
|
|
821 | ||
|
854 | ||
|
855 | return None, filename | |
|
856 | ||
|
822 | 857 | def __waitNewBlock(self): |
|
823 | 858 | """ |
|
824 | 859 | Return 1 si se encontro un nuevo bloque de datos, 0 de otra forma. |
@@ -853,6 +888,7 class JRODataReader(Reader): | |||
|
853 | 888 | return 0 |
|
854 | 889 | |
|
855 | 890 | print("[Reading] Waiting %0.2f seconds for the next block, try %03d ..." % (self.delay, nTries + 1)) |
|
891 | #print(self.filename) | |
|
856 | 892 | time.sleep(self.delay) |
|
857 | 893 | |
|
858 | 894 | return 0 |
@@ -860,9 +896,9 class JRODataReader(Reader): | |||
|
860 | 896 | def __setNewBlock(self): |
|
861 | 897 | |
|
862 | 898 | if self.fp == None: |
|
863 |
return 0 |
|
|
864 | ||
|
865 |
if self.flagIsNewFile: |
|
|
899 | return 0 | |
|
900 | ||
|
901 | if self.flagIsNewFile: | |
|
866 | 902 | self.lastUTTime = self.basicHeaderObj.utc |
|
867 | 903 | return 1 |
|
868 | 904 | |
@@ -875,12 +911,12 class JRODataReader(Reader): | |||
|
875 | 911 | |
|
876 | 912 | currentSize = self.fileSize - self.fp.tell() |
|
877 | 913 | neededSize = self.processingHeaderObj.blockSize + self.basicHeaderSize |
|
878 | ||
|
914 | ||
|
879 | 915 | if (currentSize >= neededSize): |
|
880 | 916 | self.basicHeaderObj.read(self.fp) |
|
881 | 917 | self.lastUTTime = self.basicHeaderObj.utc |
|
882 | 918 | return 1 |
|
883 | ||
|
919 | ||
|
884 | 920 | if self.__waitNewBlock(): |
|
885 | 921 | self.lastUTTime = self.basicHeaderObj.utc |
|
886 | 922 | return 1 |
@@ -921,6 +957,10 class JRODataReader(Reader): | |||
|
921 | 957 | print("[Reading] Block No. %d/%d -> %s" % (self.nReadBlocks, |
|
922 | 958 | self.processingHeaderObj.dataBlocksPerFile, |
|
923 | 959 | self.dataOut.datatime.ctime())) |
|
960 | #################DP################# | |
|
961 | self.dataOut.TimeBlockDate=self.dataOut.datatime.ctime() | |
|
962 | self.dataOut.TimeBlockSeconds=time.mktime(time.strptime(self.dataOut.datatime.ctime())) | |
|
963 | #################DP################# | |
|
924 | 964 | return 1 |
|
925 | 965 | |
|
926 | 966 | def readFirstHeader(self): |
@@ -966,10 +1006,10 class JRODataReader(Reader): | |||
|
966 | 1006 | except IOError: |
|
967 | 1007 | log.error("File {} can't be opened".format(filename), self.name) |
|
968 | 1008 | return False |
|
969 | ||
|
1009 | ||
|
970 | 1010 | if self.online and self.waitDataBlock(0): |
|
971 | 1011 | pass |
|
972 | ||
|
1012 | ||
|
973 | 1013 | basicHeaderObj = BasicHeader(LOCALTIME) |
|
974 | 1014 | systemHeaderObj = SystemHeader() |
|
975 | 1015 | radarControllerHeaderObj = RadarControllerHeader() |
@@ -996,7 +1036,7 class JRODataReader(Reader): | |||
|
996 | 1036 | dt2 = basicHeaderObj.datatime |
|
997 | 1037 | if not self.isDateTimeInRange(dt1, self.startDate, self.endDate, self.startTime, self.endTime) and not \ |
|
998 | 1038 | self.isDateTimeInRange(dt2, self.startDate, self.endDate, self.startTime, self.endTime): |
|
999 |
flag = False |
|
|
1039 | flag = False | |
|
1000 | 1040 | |
|
1001 | 1041 | fp.close() |
|
1002 | 1042 | return flag |
@@ -1105,11 +1145,11 class JRODataReader(Reader): | |||
|
1105 | 1145 | return dateList |
|
1106 | 1146 | |
|
1107 | 1147 | def setup(self, **kwargs): |
|
1108 | ||
|
1148 | ||
|
1109 | 1149 | self.set_kwargs(**kwargs) |
|
1110 | 1150 | if not self.ext.startswith('.'): |
|
1111 | 1151 | self.ext = '.{}'.format(self.ext) |
|
1112 | ||
|
1152 | ||
|
1113 | 1153 | if self.server is not None: |
|
1114 | 1154 | if 'tcp://' in self.server: |
|
1115 | 1155 | address = server |
@@ -1131,36 +1171,36 class JRODataReader(Reader): | |||
|
1131 | 1171 | |
|
1132 | 1172 | for nTries in range(self.nTries): |
|
1133 | 1173 | fullpath = self.searchFilesOnLine(self.path, self.startDate, |
|
1134 |
self.endDate, self.expLabel, self.ext, self.walk, |
|
|
1174 | self.endDate, self.expLabel, self.ext, self.walk, | |
|
1135 | 1175 | self.filefmt, self.folderfmt) |
|
1136 | 1176 | |
|
1137 | 1177 | try: |
|
1138 | 1178 | fullpath = next(fullpath) |
|
1139 | 1179 | except: |
|
1140 | 1180 | fullpath = None |
|
1141 | ||
|
1181 | ||
|
1142 | 1182 | if fullpath: |
|
1143 | 1183 | break |
|
1144 | 1184 | |
|
1145 | 1185 | log.warning( |
|
1146 | 1186 | 'Waiting {} sec for a valid file in {}: try {} ...'.format( |
|
1147 |
self.delay, self.path, nTries + 1), |
|
|
1187 | self.delay, self.path, nTries + 1), | |
|
1148 | 1188 | self.name) |
|
1149 | 1189 | time.sleep(self.delay) |
|
1150 | 1190 | |
|
1151 | 1191 | if not(fullpath): |
|
1152 | 1192 | raise schainpy.admin.SchainError( |
|
1153 |
'There isn\'t any valid file in {}'.format(self.path)) |
|
|
1193 | 'There isn\'t any valid file in {}'.format(self.path)) | |
|
1154 | 1194 | |
|
1155 | 1195 | pathname, filename = os.path.split(fullpath) |
|
1156 | 1196 | self.year = int(filename[1:5]) |
|
1157 | 1197 | self.doy = int(filename[5:8]) |
|
1158 |
self.set = int(filename[8:11]) - 1 |
|
|
1198 | self.set = int(filename[8:11]) - 1 | |
|
1159 | 1199 | else: |
|
1160 | 1200 | log.log("Searching files in {}".format(self.path), self.name) |
|
1161 |
self.filenameList = self.searchFilesOffLine(self.path, self.startDate, |
|
|
1201 | self.filenameList = self.searchFilesOffLine(self.path, self.startDate, | |
|
1162 | 1202 | self.endDate, self.expLabel, self.ext, self.walk, self.filefmt, self.folderfmt) |
|
1163 | ||
|
1203 | ||
|
1164 | 1204 | self.setNextFile() |
|
1165 | 1205 | |
|
1166 | 1206 | return |
@@ -1181,7 +1221,7 class JRODataReader(Reader): | |||
|
1181 | 1221 | self.dataOut.useLocalTime = self.basicHeaderObj.useLocalTime |
|
1182 | 1222 | |
|
1183 | 1223 | self.dataOut.ippSeconds = self.radarControllerHeaderObj.ippSeconds / self.nTxs |
|
1184 | ||
|
1224 | ||
|
1185 | 1225 | def getFirstHeader(self): |
|
1186 | 1226 | |
|
1187 | 1227 | raise NotImplementedError |
@@ -1214,8 +1254,8 class JRODataReader(Reader): | |||
|
1214 | 1254 | """ |
|
1215 | 1255 | |
|
1216 | 1256 | Arguments: |
|
1217 |
path : |
|
|
1218 |
startDate : |
|
|
1257 | path : | |
|
1258 | startDate : | |
|
1219 | 1259 | endDate : |
|
1220 | 1260 | startTime : |
|
1221 | 1261 | endTime : |
@@ -1284,7 +1324,7 class JRODataWriter(Reader): | |||
|
1284 | 1324 | dtype_width = get_dtype_width(dtype_index) |
|
1285 | 1325 | |
|
1286 | 1326 | return dtype_width |
|
1287 | ||
|
1327 | ||
|
1288 | 1328 | def getProcessFlags(self): |
|
1289 | 1329 | |
|
1290 | 1330 | processFlags = 0 |
@@ -1322,9 +1362,9 class JRODataWriter(Reader): | |||
|
1322 | 1362 | |
|
1323 | 1363 | self.basicHeaderObj.size = self.basicHeaderSize # bytes |
|
1324 | 1364 | self.basicHeaderObj.version = self.versionFile |
|
1325 |
self.basicHeaderObj.dataBlock = self.nTotalBlocks |
|
|
1365 | self.basicHeaderObj.dataBlock = self.nTotalBlocks | |
|
1326 | 1366 | utc = numpy.floor(self.dataOut.utctime) |
|
1327 |
milisecond = (self.dataOut.utctime - utc) * 1000.0 |
|
|
1367 | milisecond = (self.dataOut.utctime - utc) * 1000.0 | |
|
1328 | 1368 | self.basicHeaderObj.utc = utc |
|
1329 | 1369 | self.basicHeaderObj.miliSecond = milisecond |
|
1330 | 1370 | self.basicHeaderObj.timeZone = self.dataOut.timeZone |
@@ -1465,9 +1505,9 class JRODataWriter(Reader): | |||
|
1465 | 1505 | if self.dataOut.datatime.date() > self.fileDate: |
|
1466 | 1506 | setFile = 0 |
|
1467 | 1507 | self.nTotalBlocks = 0 |
|
1468 | ||
|
1508 | ||
|
1469 | 1509 | filen = '{}{:04d}{:03d}{:03d}{}'.format( |
|
1470 |
self.optchar, timeTuple.tm_year, timeTuple.tm_yday, setFile, ext) |
|
|
1510 | self.optchar, timeTuple.tm_year, timeTuple.tm_yday, setFile, ext) | |
|
1471 | 1511 | |
|
1472 | 1512 | filename = os.path.join(path, subfolder, filen) |
|
1473 | 1513 | |
@@ -1515,11 +1555,11 class JRODataWriter(Reader): | |||
|
1515 | 1555 | self.ext = ext.lower() |
|
1516 | 1556 | |
|
1517 | 1557 | self.path = path |
|
1518 | ||
|
1558 | ||
|
1519 | 1559 | if set is None: |
|
1520 | 1560 | self.setFile = -1 |
|
1521 | 1561 | else: |
|
1522 |
self.setFile = set - 1 |
|
|
1562 | self.setFile = set - 1 | |
|
1523 | 1563 | |
|
1524 | 1564 | self.blocksPerFile = blocksPerFile |
|
1525 | 1565 | self.profilesPerBlock = profilesPerBlock |
@@ -38,7 +38,7 DEF_CATALOG = { | |||
|
38 | 38 | 'sciRemarks': '', |
|
39 | 39 | 'instRemarks': '' |
|
40 | 40 | } |
|
41 | ||
|
41 | ||
|
42 | 42 | DEF_HEADER = { |
|
43 | 43 | 'kindatDesc': '', |
|
44 | 44 | 'analyst': 'Jicamarca User', |
@@ -75,7 +75,7 def load_json(obj): | |||
|
75 | 75 | for k, v in list(iterable.items())} |
|
76 | 76 | elif isinstance(iterable, (list, tuple)): |
|
77 | 77 | return [str(v) if isinstance(v, basestring) else v for v in iterable] |
|
78 | ||
|
78 | ||
|
79 | 79 | return iterable |
|
80 | 80 | |
|
81 | 81 | |
@@ -85,18 +85,18 class MADReader(Reader, ProcessingUnit): | |||
|
85 | 85 | |
|
86 | 86 | ProcessingUnit.__init__(self) |
|
87 | 87 | |
|
88 |
self.dataOut = Parameters() |
|
|
88 | self.dataOut = Parameters() | |
|
89 | 89 | self.counter_records = 0 |
|
90 | 90 | self.nrecords = None |
|
91 | 91 | self.flagNoMoreFiles = 0 |
|
92 |
self.filename = None |
|
|
92 | self.filename = None | |
|
93 | 93 | self.intervals = set() |
|
94 | 94 | self.datatime = datetime.datetime(1900,1,1) |
|
95 | 95 | self.format = None |
|
96 | 96 | self.filefmt = "***%Y%m%d*******" |
|
97 | ||
|
97 | ||
|
98 | 98 | def setup(self, **kwargs): |
|
99 | ||
|
99 | ||
|
100 | 100 | self.set_kwargs(**kwargs) |
|
101 | 101 | self.oneDDict = load_json(self.oneDDict) |
|
102 | 102 | self.twoDDict = load_json(self.twoDDict) |
@@ -125,32 +125,32 class MADReader(Reader, ProcessingUnit): | |||
|
125 | 125 | |
|
126 | 126 | for nTries in range(self.nTries): |
|
127 | 127 | fullpath = self.searchFilesOnLine(self.path, self.startDate, |
|
128 |
self.endDate, self.expLabel, self.ext, self.walk, |
|
|
128 | self.endDate, self.expLabel, self.ext, self.walk, | |
|
129 | 129 | self.filefmt, self.folderfmt) |
|
130 | 130 | |
|
131 | 131 | try: |
|
132 | 132 | fullpath = next(fullpath) |
|
133 | 133 | except: |
|
134 | 134 | fullpath = None |
|
135 | ||
|
135 | ||
|
136 | 136 | if fullpath: |
|
137 | 137 | break |
|
138 | 138 | |
|
139 | 139 | log.warning( |
|
140 | 140 | 'Waiting {} sec for a valid file in {}: try {} ...'.format( |
|
141 |
self.delay, self.path, nTries + 1), |
|
|
141 | self.delay, self.path, nTries + 1), | |
|
142 | 142 | self.name) |
|
143 | 143 | time.sleep(self.delay) |
|
144 | 144 | |
|
145 | 145 | if not(fullpath): |
|
146 | 146 | raise schainpy.admin.SchainError( |
|
147 |
'There isn\'t any valid file in {}'.format(self.path)) |
|
|
148 | ||
|
147 | 'There isn\'t any valid file in {}'.format(self.path)) | |
|
148 | ||
|
149 | 149 | else: |
|
150 | 150 | log.log("Searching files in {}".format(self.path), self.name) |
|
151 |
self.filenameList = self.searchFilesOffLine(self.path, self.startDate, |
|
|
151 | self.filenameList = self.searchFilesOffLine(self.path, self.startDate, | |
|
152 | 152 | self.endDate, self.expLabel, self.ext, self.walk, self.filefmt, self.folderfmt) |
|
153 | ||
|
153 | ||
|
154 | 154 | self.setNextFile() |
|
155 | 155 | |
|
156 | 156 | def readFirstHeader(self): |
@@ -159,8 +159,8 class MADReader(Reader, ProcessingUnit): | |||
|
159 | 159 | self.parseHeader() |
|
160 | 160 | self.parseData() |
|
161 | 161 | self.blockIndex = 0 |
|
162 | ||
|
163 |
return |
|
|
162 | ||
|
163 | return | |
|
164 | 164 | |
|
165 | 165 | def parseHeader(self): |
|
166 | 166 | ''' |
@@ -183,7 +183,7 class MADReader(Reader, ProcessingUnit): | |||
|
183 | 183 | if s_parameters: |
|
184 | 184 | log.success('Spatial parameters found: {}'.format(s_parameters), |
|
185 | 185 | 'MADReader') |
|
186 | ||
|
186 | ||
|
187 | 187 | for param in list(self.oneDDict.keys()): |
|
188 | 188 | if param.lower() not in self.parameters: |
|
189 | 189 | log.warning( |
@@ -191,7 +191,7 class MADReader(Reader, ProcessingUnit): | |||
|
191 | 191 | param), |
|
192 | 192 | 'MADReader') |
|
193 | 193 | self.oneDDict.pop(param, None) |
|
194 | ||
|
194 | ||
|
195 | 195 | for param, value in list(self.twoDDict.items()): |
|
196 | 196 | if param.lower() not in self.parameters: |
|
197 | 197 | log.warning( |
@@ -226,10 +226,10 class MADReader(Reader, ProcessingUnit): | |||
|
226 | 226 | while True: |
|
227 | 227 | self.flagDiscontinuousBlock = 0 |
|
228 | 228 | if self.counter_records == self.nrecords: |
|
229 |
self.setNextFile() |
|
|
229 | self.setNextFile() | |
|
230 | 230 | |
|
231 | 231 | self.readBlock() |
|
232 | ||
|
232 | ||
|
233 | 233 | if (self.datatime < datetime.datetime.combine(self.startDate, self.startTime)) or \ |
|
234 | 234 | (self.datatime > datetime.datetime.combine(self.endDate, self.endTime)): |
|
235 | 235 | log.warning( |
@@ -268,7 +268,7 class MADReader(Reader, ProcessingUnit): | |||
|
268 | 268 | if self.counter_records == self.nrecords: |
|
269 | 269 | break |
|
270 | 270 | continue |
|
271 |
self.intervals.add((datatime-self.datatime).seconds) |
|
|
271 | self.intervals.add((datatime-self.datatime).seconds) | |
|
272 | 272 | break |
|
273 | 273 | elif self.ext == '.hdf5': |
|
274 | 274 | datatime = datetime.datetime.utcfromtimestamp( |
@@ -278,27 +278,27 class MADReader(Reader, ProcessingUnit): | |||
|
278 | 278 | if datatime.date()>self.datatime.date(): |
|
279 | 279 | self.flagDiscontinuousBlock = 1 |
|
280 | 280 | self.datatime = datatime |
|
281 |
self.counter_records += 1 |
|
|
282 | ||
|
281 | self.counter_records += 1 | |
|
282 | ||
|
283 | 283 | self.buffer = numpy.array(dum) |
|
284 | 284 | return |
|
285 | 285 | |
|
286 | 286 | def set_output(self): |
|
287 | 287 | ''' |
|
288 | 288 | Storing data from buffer to dataOut object |
|
289 |
''' |
|
|
289 | ''' | |
|
290 | 290 | |
|
291 | 291 | parameters = [None for __ in self.parameters] |
|
292 | 292 | |
|
293 |
for param, attr in list(self.oneDDict.items()): |
|
|
293 | for param, attr in list(self.oneDDict.items()): | |
|
294 | 294 | x = self.parameters.index(param.lower()) |
|
295 | 295 | setattr(self.dataOut, attr, self.buffer[0][x]) |
|
296 | 296 | |
|
297 | 297 | for param, value in list(self.twoDDict.items()): |
|
298 |
dummy = numpy.zeros(self.ranges.shape) + numpy.nan |
|
|
298 | dummy = numpy.zeros(self.ranges.shape) + numpy.nan | |
|
299 | 299 | if self.ext == '.txt': |
|
300 | 300 | x = self.parameters.index(param.lower()) |
|
301 |
y = self.parameters.index(self.independentParam.lower()) |
|
|
301 | y = self.parameters.index(self.independentParam.lower()) | |
|
302 | 302 | ranges = self.buffer[:,y] |
|
303 | 303 | #if self.ranges.size == ranges.size: |
|
304 | 304 | # continue |
@@ -308,23 +308,23 class MADReader(Reader, ProcessingUnit): | |||
|
308 | 308 | ranges = self.buffer[self.independentParam.lower()] |
|
309 | 309 | index = numpy.where(numpy.in1d(self.ranges, ranges))[0] |
|
310 | 310 | dummy[index] = self.buffer[param.lower()] |
|
311 | ||
|
311 | ||
|
312 | 312 | if isinstance(value, str): |
|
313 |
if value not in self.independentParam: |
|
|
313 | if value not in self.independentParam: | |
|
314 | 314 | setattr(self.dataOut, value, dummy.reshape(1,-1)) |
|
315 |
elif isinstance(value, list): |
|
|
315 | elif isinstance(value, list): | |
|
316 | 316 | self.output[value[0]][value[1]] = dummy |
|
317 | 317 | parameters[value[1]] = param |
|
318 | 318 | for key, value in list(self.output.items()): |
|
319 | 319 | setattr(self.dataOut, key, numpy.array(value)) |
|
320 | ||
|
320 | ||
|
321 | 321 | self.dataOut.parameters = [s for s in parameters if s] |
|
322 | 322 | self.dataOut.heightList = self.ranges |
|
323 | 323 | self.dataOut.utctime = (self.datatime - datetime.datetime(1970, 1, 1)).total_seconds() |
|
324 |
self.dataOut.utctimeInit = self.dataOut.utctime |
|
|
324 | self.dataOut.utctimeInit = self.dataOut.utctime | |
|
325 | 325 | self.dataOut.paramInterval = min(self.intervals) |
|
326 |
self.dataOut.useLocalTime = False |
|
|
327 |
self.dataOut.flagNoData = False |
|
|
326 | self.dataOut.useLocalTime = False | |
|
327 | self.dataOut.flagNoData = False | |
|
328 | 328 | self.dataOut.nrecords = self.nrecords |
|
329 | 329 | self.dataOut.flagDiscontinuousBlock = self.flagDiscontinuousBlock |
|
330 | 330 | |
@@ -354,7 +354,7 class MADReader(Reader, ProcessingUnit): | |||
|
354 | 354 | @MPDecorator |
|
355 | 355 | class MADWriter(Operation): |
|
356 | 356 | '''Writing module for Madrigal files |
|
357 | ||
|
357 | ||
|
358 | 358 | type: external |
|
359 | 359 | |
|
360 | 360 | Inputs: |
@@ -384,7 +384,7 Inputs: | |||
|
384 | 384 | |
|
385 | 385 | __attrs__ = ['path', 'oneDDict', 'ind2DList', 'twoDDict','metadata', 'format', 'blocks'] |
|
386 | 386 | missing = -32767 |
|
387 | ||
|
387 | ||
|
388 | 388 | def __init__(self): |
|
389 | 389 | |
|
390 | 390 | Operation.__init__(self) |
@@ -395,27 +395,31 Inputs: | |||
|
395 | 395 | |
|
396 | 396 | def run(self, dataOut, path, oneDDict, ind2DList='[]', twoDDict='{}', |
|
397 | 397 | metadata='{}', format='cedar', **kwargs): |
|
398 | ||
|
398 | ||
|
399 | ||
|
400 | #if dataOut.AUX==1: #Modified | |
|
401 | ||
|
399 | 402 | if not self.isConfig: |
|
400 | 403 | self.setup(path, oneDDict, ind2DList, twoDDict, metadata, format, **kwargs) |
|
401 | 404 | self.isConfig = True |
|
402 | ||
|
403 |
self.dataOut = dataOut |
|
|
404 |
self.putData() |
|
|
405 | ||
|
406 | self.dataOut = dataOut | |
|
407 | self.putData() | |
|
408 | ||
|
405 | 409 | return 1 |
|
406 | ||
|
410 | ||
|
407 | 411 | def setup(self, path, oneDDict, ind2DList, twoDDict, metadata, format, **kwargs): |
|
408 | 412 | ''' |
|
409 |
Configure Operation |
|
|
413 | Configure Operation | |
|
410 | 414 | ''' |
|
411 | ||
|
415 | ||
|
412 | 416 | self.path = path |
|
413 | 417 | self.blocks = kwargs.get('blocks', None) |
|
414 | 418 | self.counter = 0 |
|
415 | 419 | self.oneDDict = load_json(oneDDict) |
|
416 | 420 | self.twoDDict = load_json(twoDDict) |
|
417 | 421 | self.ind2DList = load_json(ind2DList) |
|
418 |
meta = load_json(metadata) |
|
|
422 | meta = load_json(metadata) | |
|
419 | 423 | self.kinst = meta.get('kinst') |
|
420 | 424 | self.kindat = meta.get('kindat') |
|
421 | 425 | self.catalog = meta.get('catalog', DEF_CATALOG) |
@@ -426,8 +430,8 Inputs: | |||
|
426 | 430 | elif format == 'hdf5': |
|
427 | 431 | self.ext = '.hdf5' |
|
428 | 432 | self.extra_args = {'ind2DList': self.ind2DList} |
|
429 | ||
|
430 |
self.keys = [k.lower() for k in self.twoDDict] |
|
|
433 | ||
|
434 | self.keys = [k.lower() for k in self.twoDDict] | |
|
431 | 435 | if 'range' in self.keys: |
|
432 | 436 | self.keys.remove('range') |
|
433 | 437 | if 'gdalt' in self.keys: |
@@ -440,20 +444,23 Inputs: | |||
|
440 | 444 | |
|
441 | 445 | self.mnemonic = MNEMONICS[self.kinst] #TODO get mnemonic from madrigal |
|
442 | 446 | date = datetime.datetime.utcfromtimestamp(self.dataOut.utctime) |
|
447 | #if self.dataOut.input_dat_type: | |
|
448 | #date=datetime.datetime.fromtimestamp(self.dataOut.TimeBlockSeconds_for_dp_power) | |
|
449 | #print("date",date) | |
|
443 | 450 | |
|
444 | 451 | filename = '{}{}{}'.format(self.mnemonic, |
|
445 | 452 | date.strftime('%Y%m%d_%H%M%S'), |
|
446 | 453 | self.ext) |
|
447 | ||
|
454 | ||
|
448 | 455 | self.fullname = os.path.join(self.path, filename) |
|
449 | ||
|
450 |
if os.path.isfile(self.fullname) : |
|
|
456 | ||
|
457 | if os.path.isfile(self.fullname) : | |
|
451 | 458 | log.warning( |
|
452 | 459 | 'Destination file {} already exists, previous file deleted.'.format( |
|
453 | 460 | self.fullname), |
|
454 | 461 | 'MADWriter') |
|
455 | 462 | os.remove(self.fullname) |
|
456 | ||
|
463 | ||
|
457 | 464 | try: |
|
458 | 465 | log.success( |
|
459 | 466 | 'Creating file: {}'.format(self.fullname), |
@@ -461,6 +468,8 Inputs: | |||
|
461 | 468 | if not os.path.exists(self.path): |
|
462 | 469 | os.makedirs(self.path) |
|
463 | 470 | self.fp = madrigal.cedar.MadrigalCedarFile(self.fullname, True) |
|
471 | ||
|
472 | ||
|
464 | 473 | except ValueError as e: |
|
465 | 474 | log.error( |
|
466 | 475 | 'Impossible to create a cedar object with "madrigal.cedar.MadrigalCedarFile"', |
@@ -475,11 +484,26 Inputs: | |||
|
475 | 484 | attributes. |
|
476 | 485 | Allowed parameters in: parcodes.tab |
|
477 | 486 | ''' |
|
478 | ||
|
487 | #self.dataOut.paramInterval=2 | |
|
479 | 488 | startTime = datetime.datetime.utcfromtimestamp(self.dataOut.utctime) |
|
489 | ||
|
480 | 490 | endTime = startTime + datetime.timedelta(seconds=self.dataOut.paramInterval) |
|
491 | ||
|
492 | #if self.dataOut.input_dat_type: | |
|
493 | #if self.dataOut.experiment=="DP": | |
|
494 | #startTime=datetime.datetime.fromtimestamp(self.dataOut.TimeBlockSeconds_for_dp_power) | |
|
495 | #endTime = startTime + datetime.timedelta(seconds=self.dataOut.paramInterval) | |
|
496 | ||
|
497 | ||
|
498 | #print("2: ",startTime) | |
|
499 | #print(endTime) | |
|
481 | 500 | heights = self.dataOut.heightList |
|
482 | 501 | |
|
502 | #print(self.blocks) | |
|
503 | #print(startTime) | |
|
504 | #print(endTime) | |
|
505 | #print(heights) | |
|
506 | #input() | |
|
483 | 507 | if self.ext == '.dat': |
|
484 | 508 | for key, value in list(self.twoDDict.items()): |
|
485 | 509 | if isinstance(value, str): |
@@ -505,13 +529,21 Inputs: | |||
|
505 | 529 | out[key] = tmp.flatten()[:len(heights)] |
|
506 | 530 | elif isinstance(value, (tuple, list)): |
|
507 | 531 | attr, x = value |
|
508 |
data = getattr(self.dataOut, attr) |
|
|
532 | data = getattr(self.dataOut, attr) | |
|
533 | #print(x) | |
|
534 | #print(len(heights)) | |
|
535 | #print(data[int(x)][:len(heights)]) | |
|
536 | #print(numpy.shape(out)) | |
|
537 | #print(numpy.shape(data)) | |
|
538 | ||
|
509 | 539 | out[key] = data[int(x)][:len(heights)] |
|
510 | ||
|
540 | ||
|
511 | 541 | a = numpy.array([out[k] for k in self.keys]) |
|
542 | #print(a) | |
|
512 | 543 | nrows = numpy.array([numpy.isnan(a[:, x]).all() for x in range(len(heights))]) |
|
513 | 544 | index = numpy.where(nrows == False)[0] |
|
514 | 545 | |
|
546 | #print(startTime.minute) | |
|
515 | 547 | rec = madrigal.cedar.MadrigalDataRecord( |
|
516 | 548 | self.kinst, |
|
517 | 549 | self.kindat, |
@@ -534,22 +566,24 Inputs: | |||
|
534 | 566 | len(index), |
|
535 | 567 | **self.extra_args |
|
536 | 568 | ) |
|
537 | ||
|
538 |
# Setting 1d values |
|
|
569 | #print("rec",rec) | |
|
570 | # Setting 1d values | |
|
539 | 571 | for key in self.oneDDict: |
|
540 | 572 | rec.set1D(key, getattr(self.dataOut, self.oneDDict[key])) |
|
541 | 573 | |
|
542 | 574 | # Setting 2d values |
|
543 | 575 | nrec = 0 |
|
544 |
for n in index: |
|
|
576 | for n in index: | |
|
545 | 577 | for key in out: |
|
546 | 578 | rec.set2D(key, nrec, out[key][n]) |
|
547 |
nrec += 1 |
|
|
579 | nrec += 1 | |
|
548 | 580 | |
|
549 | 581 | self.fp.append(rec) |
|
550 |
if self.ext == '.hdf5' and self.counter % |
|
|
582 | if self.ext == '.hdf5' and self.counter %2 == 0 and self.counter > 0: | |
|
583 | #print("here") | |
|
551 | 584 | self.fp.dump() |
|
552 | 585 | if self.counter % 20 == 0 and self.counter > 0: |
|
586 | #self.fp.write() | |
|
553 | 587 | log.log( |
|
554 | 588 | 'Writing {} records'.format( |
|
555 | 589 | self.counter), |
@@ -558,8 +592,8 Inputs: | |||
|
558 | 592 | def setHeader(self): |
|
559 | 593 | ''' |
|
560 | 594 | Create an add catalog and header to cedar file |
|
561 |
''' |
|
|
562 | ||
|
595 | ''' | |
|
596 | ||
|
563 | 597 | log.success('Closing file {}'.format(self.fullname), 'MADWriter') |
|
564 | 598 | |
|
565 | 599 | if self.ext == '.dat': |
@@ -567,17 +601,17 Inputs: | |||
|
567 | 601 | else: |
|
568 | 602 | self.fp.dump() |
|
569 | 603 | self.fp.close() |
|
570 | ||
|
571 |
header = madrigal.cedar.CatalogHeaderCreator(self.fullname) |
|
|
604 | ||
|
605 | header = madrigal.cedar.CatalogHeaderCreator(self.fullname) | |
|
572 | 606 | header.createCatalog(**self.catalog) |
|
573 | 607 | header.createHeader(**self.header) |
|
574 | 608 | header.write() |
|
575 | ||
|
609 | ||
|
576 | 610 | def putData(self): |
|
577 | 611 | |
|
578 | 612 | if self.dataOut.flagNoData: |
|
579 |
return 0 |
|
|
580 | ||
|
613 | return 0 | |
|
614 | ||
|
581 | 615 | if self.dataOut.flagDiscontinuousBlock or self.counter == self.blocks: |
|
582 | 616 | if self.counter > 0: |
|
583 | 617 | self.setHeader() |
@@ -585,11 +619,11 Inputs: | |||
|
585 | 619 | |
|
586 | 620 | if self.counter == 0: |
|
587 | 621 | self.setFile() |
|
588 | ||
|
622 | ||
|
589 | 623 | self.writeBlock() |
|
590 |
self.counter += 1 |
|
|
591 | ||
|
624 | self.counter += 1 | |
|
625 | ||
|
592 | 626 | def close(self): |
|
593 | ||
|
594 |
if self.counter > 0: |
|
|
595 | self.setHeader() No newline at end of file | |
|
627 | ||
|
628 | if self.counter > 0: | |
|
629 | self.setHeader() |
@@ -17,7 +17,7 class HDFReader(Reader, ProcessingUnit): | |||
|
17 | 17 | |
|
18 | 18 | This unit reads HDF5 files created with `HDFWriter` operation contains |
|
19 | 19 | by default two groups Data and Metadata all variables would be saved as `dataOut` |
|
20 |
attributes. |
|
|
20 | attributes. | |
|
21 | 21 | It is possible to read any HDF5 file by given the structure in the `description` |
|
22 | 22 | parameter, also you can add extra values to metadata with the parameter `extras`. |
|
23 | 23 | |
@@ -37,10 +37,10 class HDFReader(Reader, ProcessingUnit): | |||
|
37 | 37 | Dictionary with the description of the HDF5 file |
|
38 | 38 | extras : dict, optional |
|
39 | 39 | Dictionary with extra metadata to be be added to `dataOut` |
|
40 | ||
|
40 | ||
|
41 | 41 | Examples |
|
42 | 42 | -------- |
|
43 | ||
|
43 | ||
|
44 | 44 | desc = { |
|
45 | 45 | 'Data': { |
|
46 | 46 | 'data_output': ['u', 'v', 'w'], |
@@ -64,7 +64,7 class HDFReader(Reader, ProcessingUnit): | |||
|
64 | 64 | extras = { |
|
65 | 65 | 'timeZone': 300 |
|
66 | 66 | } |
|
67 | ||
|
67 | ||
|
68 | 68 | reader = project.addReadUnit( |
|
69 | 69 | name='HDFReader', |
|
70 | 70 | path='/path/to/files', |
@@ -99,42 +99,42 class HDFReader(Reader, ProcessingUnit): | |||
|
99 | 99 | |
|
100 | 100 | self.set_kwargs(**kwargs) |
|
101 | 101 | if not self.ext.startswith('.'): |
|
102 |
self.ext = '.{}'.format(self.ext) |
|
|
102 | self.ext = '.{}'.format(self.ext) | |
|
103 | 103 | |
|
104 | 104 | if self.online: |
|
105 | 105 | log.log("Searching files in online mode...", self.name) |
|
106 | 106 | |
|
107 | 107 | for nTries in range(self.nTries): |
|
108 | 108 | fullpath = self.searchFilesOnLine(self.path, self.startDate, |
|
109 |
self.endDate, self.expLabel, self.ext, self.walk, |
|
|
109 | self.endDate, self.expLabel, self.ext, self.walk, | |
|
110 | 110 | self.filefmt, self.folderfmt) |
|
111 | 111 | try: |
|
112 | 112 | fullpath = next(fullpath) |
|
113 | 113 | except: |
|
114 | 114 | fullpath = None |
|
115 | ||
|
115 | ||
|
116 | 116 | if fullpath: |
|
117 | 117 | break |
|
118 | 118 | |
|
119 | 119 | log.warning( |
|
120 | 120 | 'Waiting {} sec for a valid file in {}: try {} ...'.format( |
|
121 |
self.delay, self.path, nTries + 1), |
|
|
121 | self.delay, self.path, nTries + 1), | |
|
122 | 122 | self.name) |
|
123 | 123 | time.sleep(self.delay) |
|
124 | 124 | |
|
125 | 125 | if not(fullpath): |
|
126 | 126 | raise schainpy.admin.SchainError( |
|
127 |
'There isn\'t any valid file in {}'.format(self.path)) |
|
|
127 | 'There isn\'t any valid file in {}'.format(self.path)) | |
|
128 | 128 | |
|
129 | 129 | pathname, filename = os.path.split(fullpath) |
|
130 | 130 | self.year = int(filename[1:5]) |
|
131 | 131 | self.doy = int(filename[5:8]) |
|
132 |
self.set = int(filename[8:11]) - 1 |
|
|
132 | self.set = int(filename[8:11]) - 1 | |
|
133 | 133 | else: |
|
134 | 134 | log.log("Searching files in {}".format(self.path), self.name) |
|
135 |
self.filenameList = self.searchFilesOffLine(self.path, self.startDate, |
|
|
135 | self.filenameList = self.searchFilesOffLine(self.path, self.startDate, | |
|
136 | 136 | self.endDate, self.expLabel, self.ext, self.walk, self.filefmt, self.folderfmt) |
|
137 | ||
|
137 | ||
|
138 | 138 | self.setNextFile() |
|
139 | 139 | |
|
140 | 140 | return |
@@ -142,18 +142,18 class HDFReader(Reader, ProcessingUnit): | |||
|
142 | 142 | def readFirstHeader(self): |
|
143 | 143 | '''Read metadata and data''' |
|
144 | 144 | |
|
145 |
self.__readMetadata() |
|
|
145 | self.__readMetadata() | |
|
146 | 146 | self.__readData() |
|
147 | 147 | self.__setBlockList() |
|
148 | ||
|
148 | ||
|
149 | 149 | if 'type' in self.meta: |
|
150 | 150 | self.dataOut = eval(self.meta['type'])() |
|
151 | ||
|
151 | ||
|
152 | 152 | for attr in self.meta: |
|
153 | 153 | setattr(self.dataOut, attr, self.meta[attr]) |
|
154 | ||
|
154 | ||
|
155 | 155 | self.blockIndex = 0 |
|
156 | ||
|
156 | ||
|
157 | 157 | return |
|
158 | 158 | |
|
159 | 159 | def __setBlockList(self): |
@@ -211,7 +211,7 class HDFReader(Reader, ProcessingUnit): | |||
|
211 | 211 | def __readData(self): |
|
212 | 212 | |
|
213 | 213 | data = {} |
|
214 | ||
|
214 | ||
|
215 | 215 | if self.description: |
|
216 | 216 | for key, value in self.description['Data'].items(): |
|
217 | 217 | if isinstance(value, str): |
@@ -239,7 +239,7 class HDFReader(Reader, ProcessingUnit): | |||
|
239 | 239 | array = numpy.array(array) |
|
240 | 240 | else: |
|
241 | 241 | log.warning('Unknown type: {}'.format(name)) |
|
242 | ||
|
242 | ||
|
243 | 243 | if name in self.description: |
|
244 | 244 | key = self.description[name] |
|
245 | 245 | else: |
@@ -248,7 +248,7 class HDFReader(Reader, ProcessingUnit): | |||
|
248 | 248 | |
|
249 | 249 | self.data = data |
|
250 | 250 | return |
|
251 | ||
|
251 | ||
|
252 | 252 | def getData(self): |
|
253 | 253 | |
|
254 | 254 | for attr in self.data: |
@@ -287,8 +287,8 class HDFWriter(Operation): | |||
|
287 | 287 | The HDF5 file contains by default two groups Data and Metadata where |
|
288 | 288 | you can save any `dataOut` attribute specified by `dataList` and `metadataList` |
|
289 | 289 | parameters, data attributes are normaly time dependent where the metadata |
|
290 |
are not. |
|
|
291 |
It is possible to customize the structure of the HDF5 file with the |
|
|
290 | are not. | |
|
291 | It is possible to customize the structure of the HDF5 file with the | |
|
292 | 292 | optional description parameter see the examples. |
|
293 | 293 | |
|
294 | 294 | Parameters: |
@@ -305,10 +305,10 class HDFWriter(Operation): | |||
|
305 | 305 | If True the name of the files corresponds to the timestamp of the data |
|
306 | 306 | description : dict, optional |
|
307 | 307 | Dictionary with the desired description of the HDF5 file |
|
308 | ||
|
308 | ||
|
309 | 309 | Examples |
|
310 | 310 | -------- |
|
311 | ||
|
311 | ||
|
312 | 312 | desc = { |
|
313 | 313 | 'data_output': {'winds': ['z', 'w', 'v']}, |
|
314 | 314 | 'utctime': 'timestamps', |
@@ -328,7 +328,7 class HDFWriter(Operation): | |||
|
328 | 328 | 'heightList': 'heights' |
|
329 | 329 | } |
|
330 | 330 | } |
|
331 | ||
|
331 | ||
|
332 | 332 | writer = proc_unit.addOperation(name='HDFWriter') |
|
333 | 333 | writer.addParameter(name='path', value='/path/to/file') |
|
334 | 334 | writer.addParameter(name='blocksPerFile', value='32') |
@@ -356,7 +356,7 class HDFWriter(Operation): | |||
|
356 | 356 | lastTime = None |
|
357 | 357 | |
|
358 | 358 | def __init__(self): |
|
359 | ||
|
359 | ||
|
360 | 360 | Operation.__init__(self) |
|
361 | 361 | return |
|
362 | 362 | |
@@ -392,7 +392,7 class HDFWriter(Operation): | |||
|
392 | 392 | dsDict['shape'] = dataAux.shape |
|
393 | 393 | dsDict['dsNumber'] = dataAux.shape[0] |
|
394 | 394 | dsDict['dtype'] = dataAux.dtype |
|
395 | ||
|
395 | ||
|
396 | 396 | dsList.append(dsDict) |
|
397 | 397 | |
|
398 | 398 | self.dsList = dsList |
@@ -407,7 +407,7 class HDFWriter(Operation): | |||
|
407 | 407 | self.lastTime = currentTime |
|
408 | 408 | self.currentDay = dataDay |
|
409 | 409 | return False |
|
410 | ||
|
410 | ||
|
411 | 411 | timeDiff = currentTime - self.lastTime |
|
412 | 412 | |
|
413 | 413 | #Si el dia es diferente o si la diferencia entre un dato y otro supera la hora |
@@ -426,7 +426,7 class HDFWriter(Operation): | |||
|
426 | 426 | |
|
427 | 427 | self.dataOut = dataOut |
|
428 | 428 | if not(self.isConfig): |
|
429 |
self.setup(path=path, blocksPerFile=blocksPerFile, |
|
|
429 | self.setup(path=path, blocksPerFile=blocksPerFile, | |
|
430 | 430 | metadataList=metadataList, dataList=dataList, |
|
431 | 431 | setType=setType, description=description) |
|
432 | 432 | |
@@ -435,9 +435,9 class HDFWriter(Operation): | |||
|
435 | 435 | |
|
436 | 436 | self.putData() |
|
437 | 437 | return |
|
438 | ||
|
438 | ||
|
439 | 439 | def setNextFile(self): |
|
440 | ||
|
440 | ||
|
441 | 441 | ext = self.ext |
|
442 | 442 | path = self.path |
|
443 | 443 | setFile = self.setFile |
@@ -522,7 +522,7 class HDFWriter(Operation): | |||
|
522 | 522 | return 'pair{:02d}'.format(x) |
|
523 | 523 | else: |
|
524 | 524 | return 'channel{:02d}'.format(x) |
|
525 | ||
|
525 | ||
|
526 | 526 | def writeMetadata(self, fp): |
|
527 | 527 | |
|
528 | 528 | if self.description: |
@@ -547,7 +547,7 class HDFWriter(Operation): | |||
|
547 | 547 | return |
|
548 | 548 | |
|
549 | 549 | def writeData(self, fp): |
|
550 | ||
|
550 | ||
|
551 | 551 | if self.description: |
|
552 | 552 | if 'Data' in self.description: |
|
553 | 553 | grp = fp.create_group('Data') |
@@ -558,13 +558,13 class HDFWriter(Operation): | |||
|
558 | 558 | |
|
559 | 559 | dtsets = [] |
|
560 | 560 | data = [] |
|
561 | ||
|
561 | ||
|
562 | 562 | for dsInfo in self.dsList: |
|
563 | 563 | if dsInfo['nDim'] == 0: |
|
564 | 564 | ds = grp.create_dataset( |
|
565 |
self.getLabel(dsInfo['variable']), |
|
|
565 | self.getLabel(dsInfo['variable']), | |
|
566 | 566 | (self.blocksPerFile, ), |
|
567 |
chunks=True, |
|
|
567 | chunks=True, | |
|
568 | 568 | dtype=numpy.float64) |
|
569 | 569 | dtsets.append(ds) |
|
570 | 570 | data.append((dsInfo['variable'], -1)) |
@@ -576,7 +576,7 class HDFWriter(Operation): | |||
|
576 | 576 | sgrp = grp |
|
577 | 577 | for i in range(dsInfo['dsNumber']): |
|
578 | 578 | ds = sgrp.create_dataset( |
|
579 |
self.getLabel(dsInfo['variable'], i), |
|
|
579 | self.getLabel(dsInfo['variable'], i), | |
|
580 | 580 | (self.blocksPerFile, ) + dsInfo['shape'][1:], |
|
581 | 581 | chunks=True, |
|
582 | 582 | dtype=dsInfo['dtype']) |
@@ -585,7 +585,7 class HDFWriter(Operation): | |||
|
585 | 585 | fp.flush() |
|
586 | 586 | |
|
587 | 587 | log.log('Creating file: {}'.format(fp.filename), self.name) |
|
588 | ||
|
588 | ||
|
589 | 589 | self.ds = dtsets |
|
590 | 590 | self.data = data |
|
591 | 591 | self.firsttime = True |
@@ -73,27 +73,28 class VoltageReader(JRODataReader, ProcessingUnit): | |||
|
73 | 73 | """ |
|
74 | 74 | |
|
75 | 75 | ProcessingUnit.__init__(self) |
|
76 | ||
|
76 | ||
|
77 | 77 | self.ext = ".r" |
|
78 | 78 | self.optchar = "D" |
|
79 | 79 | self.basicHeaderObj = BasicHeader(LOCALTIME) |
|
80 | 80 | self.systemHeaderObj = SystemHeader() |
|
81 | 81 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
82 | ||
|
82 | 83 | self.processingHeaderObj = ProcessingHeader() |
|
83 | 84 | self.lastUTTime = 0 |
|
84 |
self.profileIndex = 2**32 - 1 |
|
|
85 | self.profileIndex = 2**32 - 1 | |
|
85 | 86 | self.dataOut = Voltage() |
|
86 | 87 | self.selBlocksize = None |
|
87 | 88 | self.selBlocktime = None |
|
88 | ||
|
89 | ##print("1--OKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK") | |
|
89 | 90 | def createObjByDefault(self): |
|
90 | ||
|
91 | ##print("2--OKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK") | |
|
91 | 92 | dataObj = Voltage() |
|
92 | 93 | |
|
93 | 94 | return dataObj |
|
94 | 95 | |
|
95 | 96 | def __hasNotDataInBuffer(self): |
|
96 | ||
|
97 | ##print("3--OKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK") | |
|
97 | 98 | if self.profileIndex >= self.processingHeaderObj.profilesPerBlock * self.nTxs: |
|
98 | 99 | return 1 |
|
99 | 100 | |
@@ -109,11 +110,13 class VoltageReader(JRODataReader, ProcessingUnit): | |||
|
109 | 110 | Return: |
|
110 | 111 | None |
|
111 | 112 | """ |
|
113 | ##print("4--OKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK") | |
|
112 | 114 | pts2read = self.processingHeaderObj.profilesPerBlock * \ |
|
113 | 115 | self.processingHeaderObj.nHeights * self.systemHeaderObj.nChannels |
|
114 | 116 | self.blocksize = pts2read |
|
115 | 117 | |
|
116 | 118 | def readBlock(self): |
|
119 | ||
|
117 | 120 | """ |
|
118 | 121 | readBlock lee el bloque de datos desde la posicion actual del puntero del archivo |
|
119 | 122 | (self.fp) y actualiza todos los parametros relacionados al bloque de datos |
@@ -133,10 +136,10 class VoltageReader(JRODataReader, ProcessingUnit): | |||
|
133 | 136 | self.flagIsNewBlock |
|
134 | 137 | self.nTotalBlocks |
|
135 | 138 | |
|
136 |
Exceptions: |
|
|
139 | Exceptions: | |
|
137 | 140 | Si un bloque leido no es un bloque valido |
|
138 | 141 | """ |
|
139 | ||
|
142 | ##print("5--OKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK") | |
|
140 | 143 | # if self.server is not None: |
|
141 | 144 | # self.zBlock = self.receiver.recv() |
|
142 | 145 | # self.zHeader = self.zBlock[:24] |
@@ -177,6 +180,7 class VoltageReader(JRODataReader, ProcessingUnit): | |||
|
177 | 180 | return 1 |
|
178 | 181 | |
|
179 | 182 | def getFirstHeader(self): |
|
183 | ##print("6--OKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK") | |
|
180 | 184 | |
|
181 | 185 | self.getBasicHeader() |
|
182 | 186 | |
@@ -186,8 +190,12 class VoltageReader(JRODataReader, ProcessingUnit): | |||
|
186 | 190 | |
|
187 | 191 | self.dataOut.radarControllerHeaderObj = self.radarControllerHeaderObj.copy() |
|
188 | 192 | |
|
193 | #self.dataOut.ippSeconds_general=self.radarControllerHeaderObj.ippSeconds | |
|
194 | #print(self.nTxs) | |
|
189 | 195 | if self.nTxs > 1: |
|
196 | #print(self.radarControllerHeaderObj.ippSeconds) | |
|
190 | 197 | self.dataOut.radarControllerHeaderObj.ippSeconds = self.radarControllerHeaderObj.ippSeconds / self.nTxs |
|
198 | #print(self.radarControllerHeaderObj.ippSeconds) | |
|
191 | 199 | # Time interval and code are propierties of dataOut. Its value depends of radarControllerHeaderObj. |
|
192 | 200 | |
|
193 | 201 | # self.dataOut.timeInterval = self.radarControllerHeaderObj.ippSeconds * self.processingHeaderObj.nCohInt |
@@ -220,7 +228,7 class VoltageReader(JRODataReader, ProcessingUnit): | |||
|
220 | 228 | self.dataOut.flagShiftFFT = self.processingHeaderObj.shif_fft |
|
221 | 229 | |
|
222 | 230 | def reshapeData(self): |
|
223 | ||
|
231 | ##print("7--OKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK") | |
|
224 | 232 | if self.nTxs < 0: |
|
225 | 233 | return |
|
226 | 234 | |
@@ -247,6 +255,7 class VoltageReader(JRODataReader, ProcessingUnit): | |||
|
247 | 255 | |
|
248 | 256 | def readFirstHeaderFromServer(self): |
|
249 | 257 | |
|
258 | ##print("8--OKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK") | |
|
250 | 259 | self.getFirstHeader() |
|
251 | 260 | |
|
252 | 261 | self.firstHeaderSize = self.basicHeaderObj.size |
@@ -278,6 +287,7 class VoltageReader(JRODataReader, ProcessingUnit): | |||
|
278 | 287 | self.getBlockDimension() |
|
279 | 288 | |
|
280 | 289 | def getFromServer(self): |
|
290 | ##print("9--OKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK") | |
|
281 | 291 | self.flagDiscontinuousBlock = 0 |
|
282 | 292 | self.profileIndex = 0 |
|
283 | 293 | self.flagIsNewBlock = 1 |
@@ -382,6 +392,8 class VoltageReader(JRODataReader, ProcessingUnit): | |||
|
382 | 392 | self.flagDiscontinuousBlock |
|
383 | 393 | self.flagIsNewBlock |
|
384 | 394 | """ |
|
395 | ||
|
396 | ##print("10--OKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK") | |
|
385 | 397 | if self.flagNoMoreFiles: |
|
386 | 398 | self.dataOut.flagNoData = True |
|
387 | 399 | return 0 |
@@ -410,6 +422,7 class VoltageReader(JRODataReader, ProcessingUnit): | |||
|
410 | 422 | self.dataOut.data = self.datablock[:, self.profileIndex, :] |
|
411 | 423 | self.dataOut.profileIndex = self.profileIndex |
|
412 | 424 | |
|
425 | ||
|
413 | 426 | self.profileIndex += 1 |
|
414 | 427 | |
|
415 | 428 | else: |
@@ -458,9 +471,13 class VoltageReader(JRODataReader, ProcessingUnit): | |||
|
458 | 471 | self.dataOut.flagDataAsBlock = True |
|
459 | 472 | self.dataOut.nProfiles = self.dataOut.data.shape[1] |
|
460 | 473 | |
|
474 | #######################DP####################### | |
|
475 | self.dataOut.CurrentBlock=self.nReadBlocks | |
|
476 | self.dataOut.LastBlock=self.processingHeaderObj.dataBlocksPerFile | |
|
477 | #######################DP####################### | |
|
461 | 478 | self.dataOut.flagNoData = False |
|
462 | 479 | |
|
463 | self.getBasicHeader() | |
|
480 | #self.getBasicHeader() | |
|
464 | 481 | |
|
465 | 482 | self.dataOut.realtime = self.online |
|
466 | 483 | |
@@ -673,4 +690,3 class VoltageWriter(JRODataWriter, Operation): | |||
|
673 | 690 | self.processingHeaderObj.processFlags = self.getProcessFlags() |
|
674 | 691 | |
|
675 | 692 | self.setBasicHeader() |
|
676 | No newline at end of file |
@@ -14,3 +14,9 from .jroproc_spectra_lags import * | |||
|
14 | 14 | from .jroproc_spectra_acf import * |
|
15 | 15 | from .bltrproc_parameters import * |
|
16 | 16 | from .pxproc_parameters import * |
|
17 | ||
|
18 | ||
|
19 | ###########DP########### | |
|
20 | from .jroproc_voltage_lags import * | |
|
21 | ###########DP########### | |
|
22 | from .jroproc_spectra_lags_faraday import * |
@@ -172,7 +172,7 def MPDecorator(BaseClass): | |||
|
172 | 172 | self.op_type = 'external' |
|
173 | 173 | self.name = BaseClass.__name__ |
|
174 | 174 | self.__doc__ = BaseClass.__doc__ |
|
175 | ||
|
175 | ||
|
176 | 176 | if 'plot' in self.name.lower() and not self.name.endswith('_'): |
|
177 | 177 | self.name = '{}{}'.format(self.CODE.upper(), 'Plot') |
|
178 | 178 |
@@ -319,6 +319,12 class SpectralFilters(Operation): | |||
|
319 | 319 | dataOut.data_pre[0] = self.spc |
|
320 | 320 | return dataOut |
|
321 | 321 | |
|
322 | ||
|
323 | from scipy.optimize import fmin | |
|
324 | import itertools | |
|
325 | from scipy.optimize import curve_fit | |
|
326 | ||
|
327 | ||
|
322 | 328 | class GaussianFit(Operation): |
|
323 | 329 | |
|
324 | 330 | ''' |
@@ -378,18 +384,17 class GaussianFit(Operation): | |||
|
378 | 384 | v1 = numpy.transpose(numpy.transpose([dataOut.DGauFitParams[iCh][2,:,1]] * self.Num_Bin)) |
|
379 | 385 | s0 = numpy.transpose(numpy.transpose([dataOut.DGauFitParams[iCh][3,:,0]] * self.Num_Bin)) |
|
380 | 386 | s1 = numpy.transpose(numpy.transpose([dataOut.DGauFitParams[iCh][3,:,1]] * self.Num_Bin)) |
|
381 | if method == 'genealized': | |
|
387 | if method == 'generalized': | |
|
382 | 388 | p0 = numpy.transpose(numpy.transpose([dataOut.DGauFitParams[iCh][4,:,0]] * self.Num_Bin)) |
|
383 | 389 | p1 = numpy.transpose(numpy.transpose([dataOut.DGauFitParams[iCh][4,:,1]] * self.Num_Bin)) |
|
384 | 390 | elif method == 'squared': |
|
385 | 391 | p0 = 2. |
|
386 |
p1 = 2. |
|
|
392 | p1 = 2. | |
|
387 | 393 | gau0[iCh] = A0*numpy.exp(-0.5*numpy.abs((x_mtr-v0)/s0)**p0)+N0 |
|
388 | 394 | gau1[iCh] = A1*numpy.exp(-0.5*numpy.abs((x_mtr-v1)/s1)**p1)+N1 |
|
389 | 395 | dataOut.GaussFit0 = gau0 |
|
390 | 396 | dataOut.GaussFit1 = gau1 |
|
391 | ||
|
392 | print('Leaving ',method ,' double Gaussian fit') | |
|
397 | ||
|
393 | 398 | return dataOut |
|
394 | 399 | |
|
395 | 400 | def FitGau(self, X): |
@@ -493,7 +498,7 class GaussianFit(Operation): | |||
|
493 | 498 | if powerwidth <= 1: |
|
494 | 499 | # print('powerwidth <= 1') |
|
495 | 500 | continue |
|
496 | ||
|
501 | ||
|
497 | 502 | # print ('stop 6') |
|
498 | 503 | firstpeak = powerlo + powerwidth/10.# first gaussian energy location |
|
499 | 504 | secondpeak = powerhi - powerwidth/10. #second gaussian energy location |
@@ -531,7 +536,6 class GaussianFit(Operation): | |||
|
531 | 536 | noise=lsq1[0][4] |
|
532 | 537 | #return (numpy.array([shift0,width0,Amplitude0,p0]), |
|
533 | 538 | # numpy.array([shift1,width1,Amplitude1,p1]),noise,snrdB,chiSq1,6.,sigmas1,[None,]*9,choice) |
|
534 | ||
|
535 | 539 | # print ('stop 9') |
|
536 | 540 | ''' two Gaussians ''' |
|
537 | 541 | #shift0=numpy.mod(firstpeak+minx,64); shift1=numpy.mod(secondpeak+minx,64) |
@@ -628,7 +632,7 class GaussianFit(Operation): | |||
|
628 | 632 | if Amplitude1<0.05: |
|
629 | 633 | shift1,width1,Amplitude1,p1 = 4*[numpy.NaN] |
|
630 | 634 | |
|
631 |
# print ('stop 16 ') |
|
|
635 | # print ('stop 16 ') | |
|
632 | 636 | # SPC_ch1[:,ht] = noise + Amplitude0*numpy.exp(-0.5*(abs(x-shift0)/width0)**p0) |
|
633 | 637 | # SPC_ch2[:,ht] = noise + Amplitude1*numpy.exp(-0.5*(abs(x-shift1)/width1)**p1) |
|
634 | 638 | # SPCparam = (SPC_ch1,SPC_ch2) |
@@ -644,8 +648,6 class GaussianFit(Operation): | |||
|
644 | 648 | DGauFitParam[4,ht,0] = p0 |
|
645 | 649 | DGauFitParam[4,ht,1] = p1 |
|
646 | 650 | |
|
647 | # print (DGauFitParam.shape) | |
|
648 | # print ('Leaving FitGau') | |
|
649 | 651 | return DGauFitParam |
|
650 | 652 | # return SPCparam |
|
651 | 653 | # return GauSPC |
@@ -662,7 +664,7 class GaussianFit(Operation): | |||
|
662 | 664 | model0 = amplitude0*numpy.exp(-0.5*abs((x-shift0)/width0)**power0) |
|
663 | 665 | model0u = amplitude0*numpy.exp(-0.5*abs((x - shift0 - self.Num_Bin)/width0)**power0) |
|
664 | 666 | model0d = amplitude0*numpy.exp(-0.5*abs((x - shift0 + self.Num_Bin)/width0)**power0) |
|
665 | ||
|
667 | ||
|
666 | 668 | model1 = amplitude1*numpy.exp(-0.5*abs((x - shift1)/width1)**power1) |
|
667 | 669 | model1u = amplitude1*numpy.exp(-0.5*abs((x - shift1 - self.Num_Bin)/width1)**power1) |
|
668 | 670 | model1d = amplitude1*numpy.exp(-0.5*abs((x - shift1 + self.Num_Bin)/width1)**power1) |
@@ -676,6 +678,206 class GaussianFit(Operation): | |||
|
676 | 678 | return num_intg*sum((numpy.log(y_data)-numpy.log(self.y_model2(x,state)))**2)#/(64-9.) |
|
677 | 679 | |
|
678 | 680 | |
|
681 | class Oblique_Gauss_Fit(Operation): | |
|
682 | ||
|
683 | def __init__(self): | |
|
684 | Operation.__init__(self) | |
|
685 | ||
|
686 | def Gauss_fit(self,spc,x,nGauss): | |
|
687 | ||
|
688 | ||
|
689 | def gaussian(x, a, b, c, d): | |
|
690 | val = a * numpy.exp(-(x - b)**2 / (2*c**2)) + d | |
|
691 | return val | |
|
692 | ||
|
693 | if nGauss == 'first': | |
|
694 | spc_1_aux = numpy.copy(spc[:numpy.argmax(spc)+1]) | |
|
695 | spc_2_aux = numpy.flip(spc_1_aux) | |
|
696 | spc_3_aux = numpy.concatenate((spc_1_aux,spc_2_aux[1:])) | |
|
697 | ||
|
698 | len_dif = len(x)-len(spc_3_aux) | |
|
699 | ||
|
700 | spc_zeros = numpy.ones(len_dif)*spc_1_aux[0] | |
|
701 | ||
|
702 | spc_new = numpy.concatenate((spc_3_aux,spc_zeros)) | |
|
703 | ||
|
704 | y = spc_new | |
|
705 | ||
|
706 | elif nGauss == 'second': | |
|
707 | y = spc | |
|
708 | ||
|
709 | ||
|
710 | # estimate starting values from the data | |
|
711 | a = y.max() | |
|
712 | b = x[numpy.argmax(y)] | |
|
713 | if nGauss == 'first': | |
|
714 | c = 1.#b#b#numpy.std(spc) | |
|
715 | elif nGauss == 'second': | |
|
716 | c = b | |
|
717 | else: | |
|
718 | print("ERROR") | |
|
719 | ||
|
720 | d = numpy.mean(y[-100:]) | |
|
721 | ||
|
722 | # define a least squares function to optimize | |
|
723 | def minfunc(params): | |
|
724 | return sum((y-gaussian(x,params[0],params[1],params[2],params[3]))**2) | |
|
725 | ||
|
726 | # fit | |
|
727 | popt = fmin(minfunc,[a,b,c,d],disp=False) | |
|
728 | #popt,fopt,niter,funcalls = fmin(minfunc,[a,b,c,d]) | |
|
729 | ||
|
730 | ||
|
731 | return gaussian(x, popt[0], popt[1], popt[2], popt[3]), popt[0], popt[1], popt[2], popt[3] | |
|
732 | ||
|
733 | ||
|
734 | def Gauss_fit_2(self,spc,x,nGauss): | |
|
735 | ||
|
736 | ||
|
737 | def gaussian(x, a, b, c, d): | |
|
738 | val = a * numpy.exp(-(x - b)**2 / (2*c**2)) + d | |
|
739 | return val | |
|
740 | ||
|
741 | if nGauss == 'first': | |
|
742 | spc_1_aux = numpy.copy(spc[:numpy.argmax(spc)+1]) | |
|
743 | spc_2_aux = numpy.flip(spc_1_aux) | |
|
744 | spc_3_aux = numpy.concatenate((spc_1_aux,spc_2_aux[1:])) | |
|
745 | ||
|
746 | len_dif = len(x)-len(spc_3_aux) | |
|
747 | ||
|
748 | spc_zeros = numpy.ones(len_dif)*spc_1_aux[0] | |
|
749 | ||
|
750 | spc_new = numpy.concatenate((spc_3_aux,spc_zeros)) | |
|
751 | ||
|
752 | y = spc_new | |
|
753 | ||
|
754 | elif nGauss == 'second': | |
|
755 | y = spc | |
|
756 | ||
|
757 | ||
|
758 | # estimate starting values from the data | |
|
759 | a = y.max() | |
|
760 | b = x[numpy.argmax(y)] | |
|
761 | if nGauss == 'first': | |
|
762 | c = 1.#b#b#numpy.std(spc) | |
|
763 | elif nGauss == 'second': | |
|
764 | c = b | |
|
765 | else: | |
|
766 | print("ERROR") | |
|
767 | ||
|
768 | d = numpy.mean(y[-100:]) | |
|
769 | ||
|
770 | # define a least squares function to optimize | |
|
771 | popt,pcov = curve_fit(gaussian,x,y,p0=[a,b,c,d]) | |
|
772 | #popt,fopt,niter,funcalls = fmin(minfunc,[a,b,c,d]) | |
|
773 | ||
|
774 | ||
|
775 | #return gaussian(x, popt[0], popt[1], popt[2], popt[3]), popt[0], popt[1], popt[2], popt[3] | |
|
776 | return gaussian(x, popt[0], popt[1], popt[2], popt[3]),popt[0], popt[1], popt[2], popt[3] | |
|
777 | ||
|
778 | def Double_Gauss_fit(self,spc,x,A1,B1,C1,A2,B2,C2,D): | |
|
779 | ||
|
780 | def double_gaussian(x, a1, b1, c1, a2, b2, c2, d): | |
|
781 | val = a1 * numpy.exp(-(x - b1)**2 / (2*c1**2)) + a2 * numpy.exp(-(x - b2)**2 / (2*c2**2)) + d | |
|
782 | return val | |
|
783 | ||
|
784 | ||
|
785 | y = spc | |
|
786 | ||
|
787 | # estimate starting values from the data | |
|
788 | a1 = A1 | |
|
789 | b1 = B1 | |
|
790 | c1 = C1#numpy.std(spc) | |
|
791 | ||
|
792 | a2 = A2#y.max() | |
|
793 | b2 = B2#x[numpy.argmax(y)] | |
|
794 | c2 = C2#numpy.std(spc) | |
|
795 | d = D | |
|
796 | ||
|
797 | # define a least squares function to optimize | |
|
798 | def minfunc(params): | |
|
799 | return sum((y-double_gaussian(x,params[0],params[1],params[2],params[3],params[4],params[5],params[6]))**2) | |
|
800 | ||
|
801 | # fit | |
|
802 | popt = fmin(minfunc,[a1,b1,c1,a2,b2,c2,d],disp=False) | |
|
803 | ||
|
804 | return double_gaussian(x, popt[0], popt[1], popt[2], popt[3], popt[4], popt[5], popt[6]), popt[0], popt[1], popt[2], popt[3], popt[4], popt[5], popt[6] | |
|
805 | ||
|
806 | def Double_Gauss_fit_2(self,spc,x,A1,B1,C1,A2,B2,C2,D): | |
|
807 | ||
|
808 | def double_gaussian(x, a1, b1, c1, a2, b2, c2, d): | |
|
809 | val = a1 * numpy.exp(-(x - b1)**2 / (2*c1**2)) + a2 * numpy.exp(-(x - b2)**2 / (2*c2**2)) + d | |
|
810 | return val | |
|
811 | ||
|
812 | ||
|
813 | y = spc | |
|
814 | ||
|
815 | # estimate starting values from the data | |
|
816 | a1 = A1 | |
|
817 | b1 = B1 | |
|
818 | c1 = C1#numpy.std(spc) | |
|
819 | ||
|
820 | a2 = A2#y.max() | |
|
821 | b2 = B2#x[numpy.argmax(y)] | |
|
822 | c2 = C2#numpy.std(spc) | |
|
823 | d = D | |
|
824 | ||
|
825 | # fit | |
|
826 | ||
|
827 | popt,pcov = curve_fit(double_gaussian,x,y,p0=[a1,b1,c1,a2,b2,c2,d]) | |
|
828 | ||
|
829 | error = numpy.sqrt(numpy.diag(pcov)) | |
|
830 | ||
|
831 | return popt[0], popt[1], popt[2], popt[3], popt[4], popt[5], popt[6], error[0], error[1], error[2], error[3], error[4], error[5], error[6] | |
|
832 | ||
|
833 | def run(self, dataOut): | |
|
834 | ||
|
835 | pwcode = 1 | |
|
836 | ||
|
837 | if dataOut.flagDecodeData: | |
|
838 | pwcode = numpy.sum(dataOut.code[0]**2) | |
|
839 | #normFactor = min(self.nFFTPoints,self.nProfiles)*self.nIncohInt*self.nCohInt*pwcode*self.windowOfFilter | |
|
840 | normFactor = dataOut.nProfiles * dataOut.nIncohInt * dataOut.nCohInt * pwcode * dataOut.windowOfFilter | |
|
841 | factor = normFactor | |
|
842 | z = dataOut.data_spc / factor | |
|
843 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
|
844 | dataOut.power = numpy.average(z, axis=1) | |
|
845 | dataOut.powerdB = 10 * numpy.log10(dataOut.power) | |
|
846 | ||
|
847 | ||
|
848 | x = dataOut.getVelRange(0) | |
|
849 | ||
|
850 | dataOut.Oblique_params = numpy.ones((1,7,dataOut.nHeights))*numpy.NAN | |
|
851 | dataOut.Oblique_param_errors = numpy.ones((1,7,dataOut.nHeights))*numpy.NAN | |
|
852 | ||
|
853 | dataOut.VelRange = x | |
|
854 | ||
|
855 | ||
|
856 | l1=range(22,36) | |
|
857 | l2=range(58,99) | |
|
858 | ||
|
859 | for hei in itertools.chain(l1, l2): | |
|
860 | ||
|
861 | try: | |
|
862 | spc = dataOut.data_spc[0,:,hei] | |
|
863 | ||
|
864 | spc_fit, A1, B1, C1, D1 = self.Gauss_fit_2(spc,x,'first') | |
|
865 | ||
|
866 | spc_diff = spc - spc_fit | |
|
867 | spc_diff[spc_diff < 0] = 0 | |
|
868 | ||
|
869 | spc_fit_diff, A2, B2, C2, D2 = self.Gauss_fit_2(spc_diff,x,'second') | |
|
870 | ||
|
871 | D = (D1+D2) | |
|
872 | ||
|
873 | dataOut.Oblique_params[0,0,hei],dataOut.Oblique_params[0,1,hei],dataOut.Oblique_params[0,2,hei],dataOut.Oblique_params[0,3,hei],dataOut.Oblique_params[0,4,hei],dataOut.Oblique_params[0,5,hei],dataOut.Oblique_params[0,6,hei],dataOut.Oblique_param_errors[0,0,hei],dataOut.Oblique_param_errors[0,1,hei],dataOut.Oblique_param_errors[0,2,hei],dataOut.Oblique_param_errors[0,3,hei],dataOut.Oblique_param_errors[0,4,hei],dataOut.Oblique_param_errors[0,5,hei],dataOut.Oblique_param_errors[0,6,hei] = self.Double_Gauss_fit_2(spc,x,A1,B1,C1,A2,B2,C2,D) | |
|
874 | #spc_double_fit,dataOut.Oblique_params = self.Double_Gauss_fit(spc,x,A1,B1,C1,A2,B2,C2,D) | |
|
875 | ||
|
876 | except: | |
|
877 | ###dataOut.Oblique_params[0,:,hei] = dataOut.Oblique_params[0,:,hei]*numpy.NAN | |
|
878 | pass | |
|
879 | ||
|
880 | return dataOut | |
|
679 | 881 | |
|
680 | 882 | class PrecipitationProc(Operation): |
|
681 | 883 | |
@@ -3884,3 +4086,55 class SMOperations(): | |||
|
3884 | 4086 | # error[indInvalid1] = 13 |
|
3885 | 4087 | # |
|
3886 | 4088 | # return heights, error |
|
4089 | ||
|
4090 | ||
|
4091 | ||
|
4092 | class IGRFModel(Operation): | |
|
4093 | """Operation to calculate Geomagnetic parameters. | |
|
4094 | ||
|
4095 | Parameters: | |
|
4096 | ----------- | |
|
4097 | None | |
|
4098 | ||
|
4099 | Example | |
|
4100 | -------- | |
|
4101 | ||
|
4102 | op = proc_unit.addOperation(name='IGRFModel', optype='other') | |
|
4103 | ||
|
4104 | """ | |
|
4105 | ||
|
4106 | def __init__(self, **kwargs): | |
|
4107 | ||
|
4108 | Operation.__init__(self, **kwargs) | |
|
4109 | ||
|
4110 | self.aux=1 | |
|
4111 | ||
|
4112 | def run(self,dataOut): | |
|
4113 | ||
|
4114 | try: | |
|
4115 | from schainpy.model.proc import mkfact_short_2020 | |
|
4116 | except: | |
|
4117 | log.warning('You should install "mkfact_short_2020" module to process IGRF Model') | |
|
4118 | ||
|
4119 | if self.aux==1: | |
|
4120 | ||
|
4121 | #dataOut.TimeBlockSeconds_First_Time=time.mktime(time.strptime(dataOut.TimeBlockDate)) | |
|
4122 | #### we do not use dataOut.datatime.ctime() because it's the time of the second (next) block | |
|
4123 | dataOut.TimeBlockSeconds_First_Time=dataOut.TimeBlockSeconds | |
|
4124 | dataOut.bd_time=time.gmtime(dataOut.TimeBlockSeconds_First_Time) | |
|
4125 | dataOut.year=dataOut.bd_time.tm_year+(dataOut.bd_time.tm_yday-1)/364.0 | |
|
4126 | dataOut.ut=dataOut.bd_time.tm_hour+dataOut.bd_time.tm_min/60.0+dataOut.bd_time.tm_sec/3600.0 | |
|
4127 | ||
|
4128 | self.aux=0 | |
|
4129 | ||
|
4130 | dataOut.h=numpy.arange(0.0,15.0*dataOut.MAXNRANGENDT,15.0,dtype='float32') | |
|
4131 | dataOut.bfm=numpy.zeros(dataOut.MAXNRANGENDT,dtype='float32') | |
|
4132 | dataOut.bfm=numpy.array(dataOut.bfm,order='F') | |
|
4133 | dataOut.thb=numpy.zeros(dataOut.MAXNRANGENDT,dtype='float32') | |
|
4134 | dataOut.thb=numpy.array(dataOut.thb,order='F') | |
|
4135 | dataOut.bki=numpy.zeros(dataOut.MAXNRANGENDT,dtype='float32') | |
|
4136 | dataOut.bki=numpy.array(dataOut.bki,order='F') | |
|
4137 | ||
|
4138 | mkfact_short_2020.mkfact(dataOut.year,dataOut.h,dataOut.bfm,dataOut.thb,dataOut.bki,dataOut.MAXNRANGENDT) | |
|
4139 | ||
|
4140 | return dataOut |
@@ -895,4 +895,4 class dopplerFlip(Operation): | |||
|
895 | 895 | # canal modificado es re-escrito en el arreglo de canales |
|
896 | 896 | self.dataOut.data_spc[2] = jspectra_tmp |
|
897 | 897 | |
|
898 | return self.dataOut No newline at end of file | |
|
898 | return self.dataOut |
@@ -736,4 +736,4 class SpectraLagsProc(ProcessingUnit): | |||
|
736 | 736 | |
|
737 | 737 | self.dataOut.noise_estimation = noise.copy() |
|
738 | 738 | |
|
739 | return 1 No newline at end of file | |
|
739 | return 1 |
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
General Comments 0
You need to be logged in to leave comments.
Login now