##// END OF EJS Templates
Operando clean Rayleigh con crossSpectra
joabAM -
r1392:e987b2f0c1da
parent child
Show More
@@ -1,712 +1,727
1 1 # Copyright (c) 2012-2020 Jicamarca Radio Observatory
2 2 # All rights reserved.
3 3 #
4 4 # Distributed under the terms of the BSD 3-clause license.
5 5 """Classes to plot Spectra data
6 6
7 7 """
8 8
9 9 import os
10 10 import numpy
11 11
12 12 from schainpy.model.graphics.jroplot_base import Plot, plt, log
13 13
14 14
15 15 class SpectraPlot(Plot):
16 16 '''
17 17 Plot for Spectra data
18 18 '''
19 19
20 20 CODE = 'spc'
21 21 colormap = 'jet'
22 22 plot_type = 'pcolor'
23 23 buffering = False
24 24 channelList = []
25 25
26 26 def setup(self):
27 27 self.nplots = len(self.data.channels)
28 28 self.ncols = int(numpy.sqrt(self.nplots) + 0.9)
29 29 self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9)
30 30 self.height = 2.6 * self.nrows
31 31
32 32 self.cb_label = 'dB'
33 33 if self.showprofile:
34 34 self.width = 4 * self.ncols
35 35 else:
36 36 self.width = 3.5 * self.ncols
37 37 self.plots_adjust.update({'wspace': 0.4, 'hspace':0.4, 'left': 0.1, 'right': 0.9, 'bottom': 0.08})
38 38 self.ylabel = 'Range [km]'
39 39
40 40 def update(self, dataOut):
41 41 if self.channelList == None:
42 42 self.channelList = dataOut.channelList
43 43 data = {}
44 44 meta = {}
45 45 spc = 10*numpy.log10(dataOut.data_spc/dataOut.normFactor)
46 46 data['spc'] = spc
47 47 data['rti'] = dataOut.getPower()
48 48 data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor)
49 49 meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1))
50 50 if self.CODE == 'spc_moments':
51 51 data['moments'] = dataOut.moments
52 52
53 53 return data, meta
54 54
55 55 def plot(self):
56 56 if self.xaxis == "frequency":
57 57 x = self.data.xrange[0]
58 58 self.xlabel = "Frequency (kHz)"
59 59 elif self.xaxis == "time":
60 60 x = self.data.xrange[1]
61 61 self.xlabel = "Time (ms)"
62 62 else:
63 63 x = self.data.xrange[2]
64 64 self.xlabel = "Velocity (m/s)"
65 65
66 66 if self.CODE == 'spc_moments':
67 67 x = self.data.xrange[2]
68 68 self.xlabel = "Velocity (m/s)"
69 69
70 70 self.titles = []
71 71
72 72 y = self.data.yrange
73 73 self.y = y
74 74
75 75 data = self.data[-1]
76 76 z = data['spc']
77 77
78 78 for n, ax in enumerate(self.axes):
79 79 noise = data['noise'][n]
80 80 if self.CODE == 'spc_moments':
81 81 mean = data['moments'][n, 1]
82 82 if ax.firsttime:
83 83 self.xmax = self.xmax if self.xmax else numpy.nanmax(x)
84 84 self.xmin = self.xmin if self.xmin else -self.xmax
85 85 self.zmin = self.zmin if self.zmin else numpy.nanmin(z)
86 86 self.zmax = self.zmax if self.zmax else numpy.nanmax(z)
87 87 ax.plt = ax.pcolormesh(x, y, z[n].T,
88 88 vmin=self.zmin,
89 89 vmax=self.zmax,
90 90 cmap=plt.get_cmap(self.colormap)
91 91 )
92 92
93 93 if self.showprofile:
94 94 ax.plt_profile = self.pf_axes[n].plot(
95 95 data['rti'][n], y)[0]
96 96 ax.plt_noise = self.pf_axes[n].plot(numpy.repeat(noise, len(y)), y,
97 97 color="k", linestyle="dashed", lw=1)[0]
98 98 if self.CODE == 'spc_moments':
99 99 ax.plt_mean = ax.plot(mean, y, color='k')[0]
100 100 else:
101 101 ax.plt.set_array(z[n].T.ravel())
102 102 if self.showprofile:
103 103 ax.plt_profile.set_data(data['rti'][n], y)
104 104 ax.plt_noise.set_data(numpy.repeat(noise, len(y)), y)
105 105 if self.CODE == 'spc_moments':
106 106 ax.plt_mean.set_data(mean, y)
107 107 self.titles.append('CH {}: {:3.2f}dB'.format(self.channelList[n], noise))
108 108
109 109
110 110 class CrossSpectraPlot(Plot):
111 111
112 112 CODE = 'cspc'
113 113 colormap = 'jet'
114 114 plot_type = 'pcolor'
115 115 zmin_coh = None
116 116 zmax_coh = None
117 117 zmin_phase = None
118 118 zmax_phase = None
119 realChannels = None
120 crossPairs = None
119 121
120 122 def setup(self):
121 123
122 124 self.ncols = 4
123 125 self.nplots = len(self.data.pairs) * 2
124 126 self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9)
125 127 self.width = 3.1 * self.ncols
126 128 self.height = 2.6 * self.nrows
127 129 self.ylabel = 'Range [km]'
128 130 self.showprofile = False
129 131 self.plots_adjust.update({'left': 0.08, 'right': 0.92, 'wspace': 0.5, 'hspace':0.4, 'top':0.95, 'bottom': 0.08})
130 132
131 133 def update(self, dataOut):
132 134
133 135 data = {}
134 136 meta = {}
135 137
136 138 spc = dataOut.data_spc
137 139 cspc = dataOut.data_cspc
138 140 meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1))
139 meta['pairs'] = dataOut.pairsList
141 rawPairs = list(combinations(list(range(dataOut.nChannels)), 2))
142 #print(rawPairs)
143 meta['pairs'] = rawPairs
144
145 if self.crossPairs == None:
146 self.crossPairs = dataOut.pairsList
140 147
141 148 tmp = []
142 149
143 150 for n, pair in enumerate(meta['pairs']):
151
144 152 out = cspc[n] / numpy.sqrt(spc[pair[0]] * spc[pair[1]])
145 153 coh = numpy.abs(out)
146 154 phase = numpy.arctan2(out.imag, out.real) * 180 / numpy.pi
147 155 tmp.append(coh)
148 156 tmp.append(phase)
149 157
150 158 data['cspc'] = numpy.array(tmp)
151 159
152 160 return data, meta
153 161
154 162 def plot(self):
155 163
156 164 if self.xaxis == "frequency":
157 165 x = self.data.xrange[0]
158 166 self.xlabel = "Frequency (kHz)"
159 167 elif self.xaxis == "time":
160 168 x = self.data.xrange[1]
161 169 self.xlabel = "Time (ms)"
162 170 else:
163 171 x = self.data.xrange[2]
164 172 self.xlabel = "Velocity (m/s)"
165 173
166 174 self.titles = []
167 175
168 176 y = self.data.yrange
169 177 self.y = y
170 178
171 179 data = self.data[-1]
172 180 cspc = data['cspc']
173
181 #print(self.crossPairs)
174 182 for n in range(len(self.data.pairs)):
175 pair = self.data.pairs[n]
183 #pair = self.data.pairs[n]
184 pair = self.crossPairs[n]
185
176 186 coh = cspc[n*2]
177 187 phase = cspc[n*2+1]
178 188 ax = self.axes[2 * n]
189
179 190 if ax.firsttime:
180 191 ax.plt = ax.pcolormesh(x, y, coh.T,
181 192 vmin=0,
182 193 vmax=1,
183 194 cmap=plt.get_cmap(self.colormap_coh)
184 195 )
185 196 else:
186 197 ax.plt.set_array(coh.T.ravel())
187 198 self.titles.append(
188 199 'Coherence Ch{} * Ch{}'.format(pair[0], pair[1]))
189 200
190 201 ax = self.axes[2 * n + 1]
191 202 if ax.firsttime:
192 203 ax.plt = ax.pcolormesh(x, y, phase.T,
193 204 vmin=-180,
194 205 vmax=180,
195 206 cmap=plt.get_cmap(self.colormap_phase)
196 207 )
197 208 else:
198 209 ax.plt.set_array(phase.T.ravel())
199 210 self.titles.append('Phase CH{} * CH{}'.format(pair[0], pair[1]))
200 211
201 212
202 213 class RTIPlot(Plot):
203 214 '''
204 215 Plot for RTI data
205 216 '''
206 217
207 218 CODE = 'rti'
208 219 colormap = 'jet'
209 220 plot_type = 'pcolorbuffer'
210 221 titles = None
211 222 channelList = []
212 223
213 224 def setup(self):
214 225 self.xaxis = 'time'
215 226 self.ncols = 1
216 227 print("dataChannels ",self.data.channels)
217 228 self.nrows = len(self.data.channels)
218 229 self.nplots = len(self.data.channels)
219 230 self.ylabel = 'Range [km]'
220 231 self.xlabel = 'Time'
221 232 self.cb_label = 'dB'
222 233 self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.08, 'right':0.95})
223 234 self.titles = ['{} Channel {}'.format(
224 235 self.CODE.upper(), x) for x in range(self.nplots)]
225 236 print("SETUP")
226 237 def update(self, dataOut):
227 238 if len(self.channelList) == 0:
228 239 self.channelList = dataOut.channelList
229 240 data = {}
230 241 meta = {}
231 242 data['rti'] = dataOut.getPower()
232 243 data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor)
233 244
234 245 return data, meta
235 246
236 247 def plot(self):
237 248 self.x = self.data.times
238 249 self.y = self.data.yrange
239 250 self.z = self.data[self.CODE]
240 251 self.z = numpy.ma.masked_invalid(self.z)
241 if self.channelList != None:
242 self.titles = ['{} Channel {}'.format(
243 self.CODE.upper(), x) for x in self.channelList]
244
252 try:
253 if self.channelList != None:
254 self.titles = ['{} Channel {}'.format(
255 self.CODE.upper(), x) for x in self.channelList]
256 except:
257 if self.channelList.any() != None:
258 self.titles = ['{} Channel {}'.format(
259 self.CODE.upper(), x) for x in self.channelList]
245 260 if self.decimation is None:
246 261 x, y, z = self.fill_gaps(self.x, self.y, self.z)
247 262 else:
248 263 x, y, z = self.fill_gaps(*self.decimate())
249 264
250 265 for n, ax in enumerate(self.axes):
251 266 self.zmin = self.zmin if self.zmin else numpy.min(self.z)
252 267 self.zmax = self.zmax if self.zmax else numpy.max(self.z)
253 268 data = self.data[-1]
254 269 if ax.firsttime:
255 270 ax.plt = ax.pcolormesh(x, y, z[n].T,
256 271 vmin=self.zmin,
257 272 vmax=self.zmax,
258 273 cmap=plt.get_cmap(self.colormap)
259 274 )
260 275 if self.showprofile:
261 276 ax.plot_profile = self.pf_axes[n].plot(
262 277 data['rti'][n], self.y)[0]
263 278 ax.plot_noise = self.pf_axes[n].plot(numpy.repeat(data['noise'][n], len(self.y)), self.y,
264 279 color="k", linestyle="dashed", lw=1)[0]
265 280 else:
266 281 ax.collections.remove(ax.collections[0])
267 282 ax.plt = ax.pcolormesh(x, y, z[n].T,
268 283 vmin=self.zmin,
269 284 vmax=self.zmax,
270 285 cmap=plt.get_cmap(self.colormap)
271 286 )
272 287 if self.showprofile:
273 288 ax.plot_profile.set_data(data['rti'][n], self.y)
274 289 ax.plot_noise.set_data(numpy.repeat(
275 290 data['noise'][n], len(self.y)), self.y)
276 291
277 292
278 293 class CoherencePlot(RTIPlot):
279 294 '''
280 295 Plot for Coherence data
281 296 '''
282 297
283 298 CODE = 'coh'
284 299
285 300 def setup(self):
286 301 self.xaxis = 'time'
287 302 self.ncols = 1
288 303 self.nrows = len(self.data.pairs)
289 304 self.nplots = len(self.data.pairs)
290 305 self.ylabel = 'Range [km]'
291 306 self.xlabel = 'Time'
292 307 self.plots_adjust.update({'hspace':0.6, 'left': 0.1, 'bottom': 0.1,'right':0.95})
293 308 if self.CODE == 'coh':
294 309 self.cb_label = ''
295 310 self.titles = [
296 311 'Coherence Map Ch{} * Ch{}'.format(x[0], x[1]) for x in self.data.pairs]
297 312 else:
298 313 self.cb_label = 'Degrees'
299 314 self.titles = [
300 315 'Phase Map Ch{} * Ch{}'.format(x[0], x[1]) for x in self.data.pairs]
301 316
302 317 def update(self, dataOut):
303 318
304 319 data = {}
305 320 meta = {}
306 321 data['coh'] = dataOut.getCoherence()
307 322 meta['pairs'] = dataOut.pairsList
308 323
309 324 return data, meta
310 325
311 326 class PhasePlot(CoherencePlot):
312 327 '''
313 328 Plot for Phase map data
314 329 '''
315 330
316 331 CODE = 'phase'
317 332 colormap = 'seismic'
318 333
319 334 def update(self, dataOut):
320 335
321 336 data = {}
322 337 meta = {}
323 338 data['phase'] = dataOut.getCoherence(phase=True)
324 339 meta['pairs'] = dataOut.pairsList
325 340
326 341 return data, meta
327 342
328 343 class NoisePlot(Plot):
329 344 '''
330 345 Plot for noise
331 346 '''
332 347
333 348 CODE = 'noise'
334 349 plot_type = 'scatterbuffer'
335 350
336 351 def setup(self):
337 352 self.xaxis = 'time'
338 353 self.ncols = 1
339 354 self.nrows = 1
340 355 self.nplots = 1
341 356 self.ylabel = 'Intensity [dB]'
342 357 self.xlabel = 'Time'
343 358 self.titles = ['Noise']
344 359 self.colorbar = False
345 360 self.plots_adjust.update({'right': 0.85 })
346 361
347 362 def update(self, dataOut):
348 363
349 364 data = {}
350 365 meta = {}
351 366 data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor).reshape(dataOut.nChannels, 1)
352 367 meta['yrange'] = numpy.array([])
353 368
354 369 return data, meta
355 370
356 371 def plot(self):
357 372
358 373 x = self.data.times
359 374 xmin = self.data.min_time
360 375 xmax = xmin + self.xrange * 60 * 60
361 376 Y = self.data['noise']
362 377
363 378 if self.axes[0].firsttime:
364 379 self.ymin = numpy.nanmin(Y) - 5
365 380 self.ymax = numpy.nanmax(Y) + 5
366 381 for ch in self.data.channels:
367 382 y = Y[ch]
368 383 self.axes[0].plot(x, y, lw=1, label='Ch{}'.format(ch))
369 384 plt.legend(bbox_to_anchor=(1.18, 1.0))
370 385 else:
371 386 for ch in self.data.channels:
372 387 y = Y[ch]
373 388 self.axes[0].lines[ch].set_data(x, y)
374 389
375 390
376 391 class PowerProfilePlot(Plot):
377 392
378 393 CODE = 'pow_profile'
379 394 plot_type = 'scatter'
380 395
381 396 def setup(self):
382 397
383 398 self.ncols = 1
384 399 self.nrows = 1
385 400 self.nplots = 1
386 401 self.height = 4
387 402 self.width = 3
388 403 self.ylabel = 'Range [km]'
389 404 self.xlabel = 'Intensity [dB]'
390 405 self.titles = ['Power Profile']
391 406 self.colorbar = False
392 407
393 408 def update(self, dataOut):
394 409
395 410 data = {}
396 411 meta = {}
397 412 data[self.CODE] = dataOut.getPower()
398 413
399 414 return data, meta
400 415
401 416 def plot(self):
402 417
403 418 y = self.data.yrange
404 419 self.y = y
405 420
406 421 x = self.data[-1][self.CODE]
407 422
408 423 if self.xmin is None: self.xmin = numpy.nanmin(x)*0.9
409 424 if self.xmax is None: self.xmax = numpy.nanmax(x)*1.1
410 425
411 426 if self.axes[0].firsttime:
412 427 for ch in self.data.channels:
413 428 self.axes[0].plot(x[ch], y, lw=1, label='Ch{}'.format(ch))
414 429 plt.legend()
415 430 else:
416 431 for ch in self.data.channels:
417 432 self.axes[0].lines[ch].set_data(x[ch], y)
418 433
419 434
420 435 class SpectraCutPlot(Plot):
421 436
422 437 CODE = 'spc_cut'
423 438 plot_type = 'scatter'
424 439 buffering = False
425 440
426 441 def setup(self):
427 442
428 443 self.nplots = len(self.data.channels)
429 444 self.ncols = int(numpy.sqrt(self.nplots) + 0.9)
430 445 self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9)
431 446 self.width = 3.4 * self.ncols + 1.5
432 447 self.height = 3 * self.nrows
433 448 self.ylabel = 'Power [dB]'
434 449 self.colorbar = False
435 450 self.plots_adjust.update({'left':0.1, 'hspace':0.3, 'right': 0.75, 'bottom':0.08})
436 451
437 452 def update(self, dataOut):
438 453
439 454 data = {}
440 455 meta = {}
441 456 spc = 10*numpy.log10(dataOut.data_spc/dataOut.normFactor)
442 457 data['spc'] = spc
443 458 meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1))
444 459
445 460 return data, meta
446 461
447 462 def plot(self):
448 463 if self.xaxis == "frequency":
449 464 x = self.data.xrange[0][1:]
450 465 self.xlabel = "Frequency (kHz)"
451 466 elif self.xaxis == "time":
452 467 x = self.data.xrange[1]
453 468 self.xlabel = "Time (ms)"
454 469 else:
455 470 x = self.data.xrange[2]
456 471 self.xlabel = "Velocity (m/s)"
457 472
458 473 self.titles = []
459 474
460 475 y = self.data.yrange
461 476 z = self.data[-1]['spc']
462 477
463 478 if self.height_index:
464 479 index = numpy.array(self.height_index)
465 480 else:
466 481 index = numpy.arange(0, len(y), int((len(y))/9))
467 482
468 483 for n, ax in enumerate(self.axes):
469 484 if ax.firsttime:
470 485 self.xmax = self.xmax if self.xmax else numpy.nanmax(x)
471 486 self.xmin = self.xmin if self.xmin else -self.xmax
472 487 self.ymin = self.ymin if self.ymin else numpy.nanmin(z)
473 488 self.ymax = self.ymax if self.ymax else numpy.nanmax(z)
474 489 ax.plt = ax.plot(x, z[n, :, index].T)
475 490 labels = ['Range = {:2.1f}km'.format(y[i]) for i in index]
476 491 self.figures[0].legend(ax.plt, labels, loc='center right')
477 492 else:
478 493 for i, line in enumerate(ax.plt):
479 494 line.set_data(x, z[n, :, index[i]])
480 495 self.titles.append('CH {}'.format(n))
481 496
482 497
483 498 class BeaconPhase(Plot):
484 499
485 500 __isConfig = None
486 501 __nsubplots = None
487 502
488 503 PREFIX = 'beacon_phase'
489 504
490 505 def __init__(self):
491 506 Plot.__init__(self)
492 507 self.timerange = 24*60*60
493 508 self.isConfig = False
494 509 self.__nsubplots = 1
495 510 self.counter_imagwr = 0
496 511 self.WIDTH = 800
497 512 self.HEIGHT = 400
498 513 self.WIDTHPROF = 120
499 514 self.HEIGHTPROF = 0
500 515 self.xdata = None
501 516 self.ydata = None
502 517
503 518 self.PLOT_CODE = BEACON_CODE
504 519
505 520 self.FTP_WEI = None
506 521 self.EXP_CODE = None
507 522 self.SUB_EXP_CODE = None
508 523 self.PLOT_POS = None
509 524
510 525 self.filename_phase = None
511 526
512 527 self.figfile = None
513 528
514 529 self.xmin = None
515 530 self.xmax = None
516 531
517 532 def getSubplots(self):
518 533
519 534 ncol = 1
520 535 nrow = 1
521 536
522 537 return nrow, ncol
523 538
524 539 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
525 540
526 541 self.__showprofile = showprofile
527 542 self.nplots = nplots
528 543
529 544 ncolspan = 7
530 545 colspan = 6
531 546 self.__nsubplots = 2
532 547
533 548 self.createFigure(id = id,
534 549 wintitle = wintitle,
535 550 widthplot = self.WIDTH+self.WIDTHPROF,
536 551 heightplot = self.HEIGHT+self.HEIGHTPROF,
537 552 show=show)
538 553
539 554 nrow, ncol = self.getSubplots()
540 555
541 556 self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1)
542 557
543 558 def save_phase(self, filename_phase):
544 559 f = open(filename_phase,'w+')
545 560 f.write('\n\n')
546 561 f.write('JICAMARCA RADIO OBSERVATORY - Beacon Phase \n')
547 562 f.write('DD MM YYYY HH MM SS pair(2,0) pair(2,1) pair(2,3) pair(2,4)\n\n' )
548 563 f.close()
549 564
550 565 def save_data(self, filename_phase, data, data_datetime):
551 566 f=open(filename_phase,'a')
552 567 timetuple_data = data_datetime.timetuple()
553 568 day = str(timetuple_data.tm_mday)
554 569 month = str(timetuple_data.tm_mon)
555 570 year = str(timetuple_data.tm_year)
556 571 hour = str(timetuple_data.tm_hour)
557 572 minute = str(timetuple_data.tm_min)
558 573 second = str(timetuple_data.tm_sec)
559 574 f.write(day+' '+month+' '+year+' '+hour+' '+minute+' '+second+' '+str(data[0])+' '+str(data[1])+' '+str(data[2])+' '+str(data[3])+'\n')
560 575 f.close()
561 576
562 577 def plot(self):
563 578 log.warning('TODO: Not yet implemented...')
564 579
565 580 def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True',
566 581 xmin=None, xmax=None, ymin=None, ymax=None, hmin=None, hmax=None,
567 582 timerange=None,
568 583 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
569 584 server=None, folder=None, username=None, password=None,
570 585 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
571 586
572 587 if dataOut.flagNoData:
573 588 return dataOut
574 589
575 590 if not isTimeInHourRange(dataOut.datatime, xmin, xmax):
576 591 return
577 592
578 593 if pairsList == None:
579 594 pairsIndexList = dataOut.pairsIndexList[:10]
580 595 else:
581 596 pairsIndexList = []
582 597 for pair in pairsList:
583 598 if pair not in dataOut.pairsList:
584 599 raise ValueError("Pair %s is not in dataOut.pairsList" %(pair))
585 600 pairsIndexList.append(dataOut.pairsList.index(pair))
586 601
587 602 if pairsIndexList == []:
588 603 return
589 604
590 605 # if len(pairsIndexList) > 4:
591 606 # pairsIndexList = pairsIndexList[0:4]
592 607
593 608 hmin_index = None
594 609 hmax_index = None
595 610
596 611 if hmin != None and hmax != None:
597 612 indexes = numpy.arange(dataOut.nHeights)
598 613 hmin_list = indexes[dataOut.heightList >= hmin]
599 614 hmax_list = indexes[dataOut.heightList <= hmax]
600 615
601 616 if hmin_list.any():
602 617 hmin_index = hmin_list[0]
603 618
604 619 if hmax_list.any():
605 620 hmax_index = hmax_list[-1]+1
606 621
607 622 x = dataOut.getTimeRange()
608 623
609 624 thisDatetime = dataOut.datatime
610 625
611 626 title = wintitle + " Signal Phase" # : %s" %(thisDatetime.strftime("%d-%b-%Y"))
612 627 xlabel = "Local Time"
613 628 ylabel = "Phase (degrees)"
614 629
615 630 update_figfile = False
616 631
617 632 nplots = len(pairsIndexList)
618 633 #phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList)))
619 634 phase_beacon = numpy.zeros(len(pairsIndexList))
620 635 for i in range(nplots):
621 636 pair = dataOut.pairsList[pairsIndexList[i]]
622 637 ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i], :, hmin_index:hmax_index], axis=0)
623 638 powa = numpy.average(dataOut.data_spc[pair[0], :, hmin_index:hmax_index], axis=0)
624 639 powb = numpy.average(dataOut.data_spc[pair[1], :, hmin_index:hmax_index], axis=0)
625 640 avgcoherenceComplex = ccf/numpy.sqrt(powa*powb)
626 641 phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi
627 642
628 643 if dataOut.beacon_heiIndexList:
629 644 phase_beacon[i] = numpy.average(phase[dataOut.beacon_heiIndexList])
630 645 else:
631 646 phase_beacon[i] = numpy.average(phase)
632 647
633 648 if not self.isConfig:
634 649
635 650 nplots = len(pairsIndexList)
636 651
637 652 self.setup(id=id,
638 653 nplots=nplots,
639 654 wintitle=wintitle,
640 655 showprofile=showprofile,
641 656 show=show)
642 657
643 658 if timerange != None:
644 659 self.timerange = timerange
645 660
646 661 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
647 662
648 663 if ymin == None: ymin = 0
649 664 if ymax == None: ymax = 360
650 665
651 666 self.FTP_WEI = ftp_wei
652 667 self.EXP_CODE = exp_code
653 668 self.SUB_EXP_CODE = sub_exp_code
654 669 self.PLOT_POS = plot_pos
655 670
656 671 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
657 672 self.isConfig = True
658 673 self.figfile = figfile
659 674 self.xdata = numpy.array([])
660 675 self.ydata = numpy.array([])
661 676
662 677 update_figfile = True
663 678
664 679 #open file beacon phase
665 680 path = '%s%03d' %(self.PREFIX, self.id)
666 681 beacon_file = os.path.join(path,'%s.txt'%self.name)
667 682 self.filename_phase = os.path.join(figpath,beacon_file)
668 683 #self.save_phase(self.filename_phase)
669 684
670 685
671 686 #store data beacon phase
672 687 #self.save_data(self.filename_phase, phase_beacon, thisDatetime)
673 688
674 689 self.setWinTitle(title)
675 690
676 691
677 692 title = "Phase Plot %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
678 693
679 694 legendlabels = ["Pair (%d,%d)"%(pair[0], pair[1]) for pair in dataOut.pairsList]
680 695
681 696 axes = self.axesList[0]
682 697
683 698 self.xdata = numpy.hstack((self.xdata, x[0:1]))
684 699
685 700 if len(self.ydata)==0:
686 701 self.ydata = phase_beacon.reshape(-1,1)
687 702 else:
688 703 self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1)))
689 704
690 705
691 706 axes.pmultilineyaxis(x=self.xdata, y=self.ydata,
692 707 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax,
693 708 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid",
694 709 XAxisAsTime=True, grid='both'
695 710 )
696 711
697 712 self.draw()
698 713
699 714 if dataOut.ltctime >= self.xmax:
700 715 self.counter_imagwr = wr_period
701 716 self.isConfig = False
702 717 update_figfile = True
703 718
704 719 self.save(figpath=figpath,
705 720 figfile=figfile,
706 721 save=save,
707 722 ftp=ftp,
708 723 wr_period=wr_period,
709 724 thisDatetime=thisDatetime,
710 725 update_figfile=update_figfile)
711 726
712 727 return dataOut
@@ -1,1411 +1,1439
1 1 # Copyright (c) 2012-2020 Jicamarca Radio Observatory
2 2 # All rights reserved.
3 3 #
4 4 # Distributed under the terms of the BSD 3-clause license.
5 5 """Spectra processing Unit and operations
6 6
7 7 Here you will find the processing unit `SpectraProc` and several operations
8 8 to work with Spectra data type
9 9 """
10 10
11 11 import time
12 12 import itertools
13 13
14 14 import numpy
15 15 import math
16 16
17 17 from schainpy.model.proc.jroproc_base import ProcessingUnit, MPDecorator, Operation
18 18 from schainpy.model.data.jrodata import Spectra
19 19 from schainpy.model.data.jrodata import hildebrand_sekhon
20 20 from schainpy.utils import log
21 21
22 22 from scipy.optimize import curve_fit
23 23
24 24
25 25 class SpectraProc(ProcessingUnit):
26 26
27 27 def __init__(self):
28 28
29 29 ProcessingUnit.__init__(self)
30 30
31 31 self.buffer = None
32 32 self.firstdatatime = None
33 33 self.profIndex = 0
34 34 self.dataOut = Spectra()
35 35 self.id_min = None
36 36 self.id_max = None
37 37 self.setupReq = False #Agregar a todas las unidades de proc
38 38
39 39 def __updateSpecFromVoltage(self):
40 40
41 41 self.dataOut.timeZone = self.dataIn.timeZone
42 42 self.dataOut.dstFlag = self.dataIn.dstFlag
43 43 self.dataOut.errorCount = self.dataIn.errorCount
44 44 self.dataOut.useLocalTime = self.dataIn.useLocalTime
45 45 try:
46 46 self.dataOut.processingHeaderObj = self.dataIn.processingHeaderObj.copy()
47 47 except:
48 48 pass
49 49 self.dataOut.radarControllerHeaderObj = self.dataIn.radarControllerHeaderObj.copy()
50 50 self.dataOut.systemHeaderObj = self.dataIn.systemHeaderObj.copy()
51 51 self.dataOut.channelList = self.dataIn.channelList
52 52 self.dataOut.heightList = self.dataIn.heightList
53 53 self.dataOut.dtype = numpy.dtype([('real', '<f4'), ('imag', '<f4')])
54 54 self.dataOut.nProfiles = self.dataOut.nFFTPoints
55 55 self.dataOut.flagDiscontinuousBlock = self.dataIn.flagDiscontinuousBlock
56 56 self.dataOut.utctime = self.firstdatatime
57 57 self.dataOut.flagDecodeData = self.dataIn.flagDecodeData
58 58 self.dataOut.flagDeflipData = self.dataIn.flagDeflipData
59 59 self.dataOut.flagShiftFFT = False
60 60 self.dataOut.nCohInt = self.dataIn.nCohInt
61 61 self.dataOut.nIncohInt = 1
62 62 self.dataOut.windowOfFilter = self.dataIn.windowOfFilter
63 63 self.dataOut.frequency = self.dataIn.frequency
64 64 self.dataOut.realtime = self.dataIn.realtime
65 65 self.dataOut.azimuth = self.dataIn.azimuth
66 66 self.dataOut.zenith = self.dataIn.zenith
67 67 self.dataOut.codeList = self.dataIn.codeList
68 68 self.dataOut.azimuthList = self.dataIn.azimuthList
69 69 self.dataOut.elevationList = self.dataIn.elevationList
70 70
71 71 def __getFft(self):
72 72 """
73 73 Convierte valores de Voltaje a Spectra
74 74
75 75 Affected:
76 76 self.dataOut.data_spc
77 77 self.dataOut.data_cspc
78 78 self.dataOut.data_dc
79 79 self.dataOut.heightList
80 80 self.profIndex
81 81 self.buffer
82 82 self.dataOut.flagNoData
83 83 """
84 84 fft_volt = numpy.fft.fft(
85 85 self.buffer, n=self.dataOut.nFFTPoints, axis=1)
86 86 fft_volt = fft_volt.astype(numpy.dtype('complex'))
87 87 dc = fft_volt[:, 0, :]
88 88
89 89 # calculo de self-spectra
90 90 fft_volt = numpy.fft.fftshift(fft_volt, axes=(1,))
91 91 spc = fft_volt * numpy.conjugate(fft_volt)
92 92 spc = spc.real
93 93
94 94 blocksize = 0
95 95 blocksize += dc.size
96 96 blocksize += spc.size
97 97
98 98 cspc = None
99 99 pairIndex = 0
100 100 if self.dataOut.pairsList != None:
101 101 # calculo de cross-spectra
102 102 cspc = numpy.zeros(
103 103 (self.dataOut.nPairs, self.dataOut.nFFTPoints, self.dataOut.nHeights), dtype='complex')
104 104 for pair in self.dataOut.pairsList:
105 105 if pair[0] not in self.dataOut.channelList:
106 106 raise ValueError("Error getting CrossSpectra: pair 0 of %s is not in channelList = %s" % (
107 107 str(pair), str(self.dataOut.channelList)))
108 108 if pair[1] not in self.dataOut.channelList:
109 109 raise ValueError("Error getting CrossSpectra: pair 1 of %s is not in channelList = %s" % (
110 110 str(pair), str(self.dataOut.channelList)))
111 111
112 112 cspc[pairIndex, :, :] = fft_volt[pair[0], :, :] * \
113 113 numpy.conjugate(fft_volt[pair[1], :, :])
114 114 pairIndex += 1
115 115 blocksize += cspc.size
116 116
117 117 self.dataOut.data_spc = spc
118 118 self.dataOut.data_cspc = cspc
119 119 self.dataOut.data_dc = dc
120 120 self.dataOut.blockSize = blocksize
121 121 self.dataOut.flagShiftFFT = False
122 122
123 123 def run(self, nProfiles=None, nFFTPoints=None, pairsList=None, ippFactor=None, shift_fft=False):
124 124
125 125 if self.dataIn.type == "Spectra":
126 126 self.dataOut.copy(self.dataIn)
127 127 if shift_fft:
128 128 #desplaza a la derecha en el eje 2 determinadas posiciones
129 129 shift = int(self.dataOut.nFFTPoints/2)
130 130 self.dataOut.data_spc = numpy.roll(self.dataOut.data_spc, shift , axis=1)
131 131
132 132 if self.dataOut.data_cspc is not None:
133 133 #desplaza a la derecha en el eje 2 determinadas posiciones
134 134 self.dataOut.data_cspc = numpy.roll(self.dataOut.data_cspc, shift, axis=1)
135 135 if pairsList:
136 136 self.__selectPairs(pairsList)
137 137
138 138 elif self.dataIn.type == "Voltage":
139 139
140 140 self.dataOut.flagNoData = True
141 141
142 142 if nFFTPoints == None:
143 143 raise ValueError("This SpectraProc.run() need nFFTPoints input variable")
144 144
145 145 if nProfiles == None:
146 146 nProfiles = nFFTPoints
147 147
148 148 if ippFactor == None:
149 149 self.dataOut.ippFactor = 1
150 150
151 151 self.dataOut.nFFTPoints = nFFTPoints
152 152
153 153 if self.buffer is None:
154 154 self.buffer = numpy.zeros((self.dataIn.nChannels,
155 155 nProfiles,
156 156 self.dataIn.nHeights),
157 157 dtype='complex')
158 158
159 159 if self.dataIn.flagDataAsBlock:
160 160 nVoltProfiles = self.dataIn.data.shape[1]
161 161
162 162 if nVoltProfiles == nProfiles:
163 163 self.buffer = self.dataIn.data.copy()
164 164 self.profIndex = nVoltProfiles
165 165
166 166 elif nVoltProfiles < nProfiles:
167 167
168 168 if self.profIndex == 0:
169 169 self.id_min = 0
170 170 self.id_max = nVoltProfiles
171 171
172 172 self.buffer[:, self.id_min:self.id_max,
173 173 :] = self.dataIn.data
174 174 self.profIndex += nVoltProfiles
175 175 self.id_min += nVoltProfiles
176 176 self.id_max += nVoltProfiles
177 177 else:
178 178 raise ValueError("The type object %s has %d profiles, it should just has %d profiles" % (
179 179 self.dataIn.type, self.dataIn.data.shape[1], nProfiles))
180 180 self.dataOut.flagNoData = True
181 181 else:
182 182 self.buffer[:, self.profIndex, :] = self.dataIn.data.copy()
183 183 self.profIndex += 1
184 184
185 185 if self.firstdatatime == None:
186 186 self.firstdatatime = self.dataIn.utctime
187 187
188 188 if self.profIndex == nProfiles:
189 189 self.__updateSpecFromVoltage()
190 190 if pairsList == None:
191 191 self.dataOut.pairsList = [pair for pair in itertools.combinations(self.dataOut.channelList, 2)]
192 192 else:
193 193 self.dataOut.pairsList = pairsList
194 194 self.__getFft()
195 195 self.dataOut.flagNoData = False
196 196 self.firstdatatime = None
197 197 self.profIndex = 0
198 198 else:
199 199 raise ValueError("The type of input object '%s' is not valid".format(
200 200 self.dataIn.type))
201 201
202 202 def __selectPairs(self, pairsList):
203 203
204 204 if not pairsList:
205 205 return
206 206
207 207 pairs = []
208 208 pairsIndex = []
209 209
210 210 for pair in pairsList:
211 211 if pair[0] not in self.dataOut.channelList or pair[1] not in self.dataOut.channelList:
212 212 continue
213 213 pairs.append(pair)
214 214 pairsIndex.append(pairs.index(pair))
215 215
216 216 self.dataOut.data_cspc = self.dataOut.data_cspc[pairsIndex]
217 217 self.dataOut.pairsList = pairs
218 218
219 219 return
220 220
221 221 def selectFFTs(self, minFFT, maxFFT ):
222 222 """
223 223 Selecciona un bloque de datos en base a un grupo de valores de puntos FFTs segun el rango
224 224 minFFT<= FFT <= maxFFT
225 225 """
226 226
227 227 if (minFFT > maxFFT):
228 228 raise ValueError("Error selecting heights: Height range (%d,%d) is not valid" % (minFFT, maxFFT))
229 229
230 230 if (minFFT < self.dataOut.getFreqRange()[0]):
231 231 minFFT = self.dataOut.getFreqRange()[0]
232 232
233 233 if (maxFFT > self.dataOut.getFreqRange()[-1]):
234 234 maxFFT = self.dataOut.getFreqRange()[-1]
235 235
236 236 minIndex = 0
237 237 maxIndex = 0
238 238 FFTs = self.dataOut.getFreqRange()
239 239
240 240 inda = numpy.where(FFTs >= minFFT)
241 241 indb = numpy.where(FFTs <= maxFFT)
242 242
243 243 try:
244 244 minIndex = inda[0][0]
245 245 except:
246 246 minIndex = 0
247 247
248 248 try:
249 249 maxIndex = indb[0][-1]
250 250 except:
251 251 maxIndex = len(FFTs)
252 252
253 253 self.selectFFTsByIndex(minIndex, maxIndex)
254 254
255 255 return 1
256 256
257 257 def getBeaconSignal(self, tauindex=0, channelindex=0, hei_ref=None):
258 258 newheis = numpy.where(
259 259 self.dataOut.heightList > self.dataOut.radarControllerHeaderObj.Taus[tauindex])
260 260
261 261 if hei_ref != None:
262 262 newheis = numpy.where(self.dataOut.heightList > hei_ref)
263 263
264 264 minIndex = min(newheis[0])
265 265 maxIndex = max(newheis[0])
266 266 data_spc = self.dataOut.data_spc[:, :, minIndex:maxIndex + 1]
267 267 heightList = self.dataOut.heightList[minIndex:maxIndex + 1]
268 268
269 269 # determina indices
270 270 nheis = int(self.dataOut.radarControllerHeaderObj.txB /
271 271 (self.dataOut.heightList[1] - self.dataOut.heightList[0]))
272 272 avg_dB = 10 * \
273 273 numpy.log10(numpy.sum(data_spc[channelindex, :, :], axis=0))
274 274 beacon_dB = numpy.sort(avg_dB)[-nheis:]
275 275 beacon_heiIndexList = []
276 276 for val in avg_dB.tolist():
277 277 if val >= beacon_dB[0]:
278 278 beacon_heiIndexList.append(avg_dB.tolist().index(val))
279 279
280 280 #data_spc = data_spc[:,:,beacon_heiIndexList]
281 281 data_cspc = None
282 282 if self.dataOut.data_cspc is not None:
283 283 data_cspc = self.dataOut.data_cspc[:, :, minIndex:maxIndex + 1]
284 284 #data_cspc = data_cspc[:,:,beacon_heiIndexList]
285 285
286 286 data_dc = None
287 287 if self.dataOut.data_dc is not None:
288 288 data_dc = self.dataOut.data_dc[:, minIndex:maxIndex + 1]
289 289 #data_dc = data_dc[:,beacon_heiIndexList]
290 290
291 291 self.dataOut.data_spc = data_spc
292 292 self.dataOut.data_cspc = data_cspc
293 293 self.dataOut.data_dc = data_dc
294 294 self.dataOut.heightList = heightList
295 295 self.dataOut.beacon_heiIndexList = beacon_heiIndexList
296 296
297 297 return 1
298 298
299 299 def selectFFTsByIndex(self, minIndex, maxIndex):
300 300 """
301 301
302 302 """
303 303
304 304 if (minIndex < 0) or (minIndex > maxIndex):
305 305 raise ValueError("Error selecting heights: Index range (%d,%d) is not valid" % (minIndex, maxIndex))
306 306
307 307 if (maxIndex >= self.dataOut.nProfiles):
308 308 maxIndex = self.dataOut.nProfiles-1
309 309
310 310 #Spectra
311 311 data_spc = self.dataOut.data_spc[:,minIndex:maxIndex+1,:]
312 312
313 313 data_cspc = None
314 314 if self.dataOut.data_cspc is not None:
315 315 data_cspc = self.dataOut.data_cspc[:,minIndex:maxIndex+1,:]
316 316
317 317 data_dc = None
318 318 if self.dataOut.data_dc is not None:
319 319 data_dc = self.dataOut.data_dc[minIndex:maxIndex+1,:]
320 320
321 321 self.dataOut.data_spc = data_spc
322 322 self.dataOut.data_cspc = data_cspc
323 323 self.dataOut.data_dc = data_dc
324 324
325 325 self.dataOut.ippSeconds = self.dataOut.ippSeconds*(self.dataOut.nFFTPoints / numpy.shape(data_cspc)[1])
326 326 self.dataOut.nFFTPoints = numpy.shape(data_cspc)[1]
327 327 self.dataOut.profilesPerBlock = numpy.shape(data_cspc)[1]
328 328
329 329 return 1
330 330
331 331 def getNoise(self, minHei=None, maxHei=None, minVel=None, maxVel=None):
332 332 # validacion de rango
333 333 if minHei == None:
334 334 minHei = self.dataOut.heightList[0]
335 335
336 336 if maxHei == None:
337 337 maxHei = self.dataOut.heightList[-1]
338 338
339 339 if (minHei < self.dataOut.heightList[0]) or (minHei > maxHei):
340 340 print('minHei: %.2f is out of the heights range' % (minHei))
341 341 print('minHei is setting to %.2f' % (self.dataOut.heightList[0]))
342 342 minHei = self.dataOut.heightList[0]
343 343
344 344 if (maxHei > self.dataOut.heightList[-1]) or (maxHei < minHei):
345 345 print('maxHei: %.2f is out of the heights range' % (maxHei))
346 346 print('maxHei is setting to %.2f' % (self.dataOut.heightList[-1]))
347 347 maxHei = self.dataOut.heightList[-1]
348 348
349 349 # validacion de velocidades
350 350 velrange = self.dataOut.getVelRange(1)
351 351
352 352 if minVel == None:
353 353 minVel = velrange[0]
354 354
355 355 if maxVel == None:
356 356 maxVel = velrange[-1]
357 357
358 358 if (minVel < velrange[0]) or (minVel > maxVel):
359 359 print('minVel: %.2f is out of the velocity range' % (minVel))
360 360 print('minVel is setting to %.2f' % (velrange[0]))
361 361 minVel = velrange[0]
362 362
363 363 if (maxVel > velrange[-1]) or (maxVel < minVel):
364 364 print('maxVel: %.2f is out of the velocity range' % (maxVel))
365 365 print('maxVel is setting to %.2f' % (velrange[-1]))
366 366 maxVel = velrange[-1]
367 367
368 368 # seleccion de indices para rango
369 369 minIndex = 0
370 370 maxIndex = 0
371 371 heights = self.dataOut.heightList
372 372
373 373 inda = numpy.where(heights >= minHei)
374 374 indb = numpy.where(heights <= maxHei)
375 375
376 376 try:
377 377 minIndex = inda[0][0]
378 378 except:
379 379 minIndex = 0
380 380
381 381 try:
382 382 maxIndex = indb[0][-1]
383 383 except:
384 384 maxIndex = len(heights)
385 385
386 386 if (minIndex < 0) or (minIndex > maxIndex):
387 387 raise ValueError("some value in (%d,%d) is not valid" % (
388 388 minIndex, maxIndex))
389 389
390 390 if (maxIndex >= self.dataOut.nHeights):
391 391 maxIndex = self.dataOut.nHeights - 1
392 392
393 393 # seleccion de indices para velocidades
394 394 indminvel = numpy.where(velrange >= minVel)
395 395 indmaxvel = numpy.where(velrange <= maxVel)
396 396 try:
397 397 minIndexVel = indminvel[0][0]
398 398 except:
399 399 minIndexVel = 0
400 400
401 401 try:
402 402 maxIndexVel = indmaxvel[0][-1]
403 403 except:
404 404 maxIndexVel = len(velrange)
405 405
406 406 # seleccion del espectro
407 407 data_spc = self.dataOut.data_spc[:,
408 408 minIndexVel:maxIndexVel + 1, minIndex:maxIndex + 1]
409 409 # estimacion de ruido
410 410 noise = numpy.zeros(self.dataOut.nChannels)
411 411
412 412 for channel in range(self.dataOut.nChannels):
413 413 daux = data_spc[channel, :, :]
414 414 sortdata = numpy.sort(daux, axis=None)
415 415 noise[channel] = hildebrand_sekhon(sortdata, self.dataOut.nIncohInt)
416 416
417 417 self.dataOut.noise_estimation = noise.copy()
418 418
419 419 return 1
420 420
421 421 class removeDC(Operation):
422 422
423 423 def run(self, dataOut, mode=2):
424 424 self.dataOut = dataOut
425 425 jspectra = self.dataOut.data_spc
426 426 jcspectra = self.dataOut.data_cspc
427 427
428 428 num_chan = jspectra.shape[0]
429 429 num_hei = jspectra.shape[2]
430 430
431 431 if jcspectra is not None:
432 432 jcspectraExist = True
433 433 num_pairs = jcspectra.shape[0]
434 434 else:
435 435 jcspectraExist = False
436 436
437 437 freq_dc = int(jspectra.shape[1] / 2)
438 438 ind_vel = numpy.array([-2, -1, 1, 2]) + freq_dc
439 439 ind_vel = ind_vel.astype(int)
440 440
441 441 if ind_vel[0] < 0:
442 442 ind_vel[list(range(0, 1))] = ind_vel[list(range(0, 1))] + self.num_prof
443 443
444 444 if mode == 1:
445 445 jspectra[:, freq_dc, :] = (
446 446 jspectra[:, ind_vel[1], :] + jspectra[:, ind_vel[2], :]) / 2 # CORRECCION
447 447
448 448 if jcspectraExist:
449 449 jcspectra[:, freq_dc, :] = (
450 450 jcspectra[:, ind_vel[1], :] + jcspectra[:, ind_vel[2], :]) / 2
451 451
452 452 if mode == 2:
453 453
454 454 vel = numpy.array([-2, -1, 1, 2])
455 455 xx = numpy.zeros([4, 4])
456 456
457 457 for fil in range(4):
458 458 xx[fil, :] = vel[fil]**numpy.asarray(list(range(4)))
459 459
460 460 xx_inv = numpy.linalg.inv(xx)
461 461 xx_aux = xx_inv[0, :]
462 462
463 463 for ich in range(num_chan):
464 464 yy = jspectra[ich, ind_vel, :]
465 465 jspectra[ich, freq_dc, :] = numpy.dot(xx_aux, yy)
466 466
467 467 junkid = jspectra[ich, freq_dc, :] <= 0
468 468 cjunkid = sum(junkid)
469 469
470 470 if cjunkid.any():
471 471 jspectra[ich, freq_dc, junkid.nonzero()] = (
472 472 jspectra[ich, ind_vel[1], junkid] + jspectra[ich, ind_vel[2], junkid]) / 2
473 473
474 474 if jcspectraExist:
475 475 for ip in range(num_pairs):
476 476 yy = jcspectra[ip, ind_vel, :]
477 477 jcspectra[ip, freq_dc, :] = numpy.dot(xx_aux, yy)
478 478
479 479 self.dataOut.data_spc = jspectra
480 480 self.dataOut.data_cspc = jcspectra
481 481
482 482 return self.dataOut
483 483
484 484 # import matplotlib.pyplot as plt
485 485
486 486 def fit_func( x, a0, a1, a2): #, a3, a4, a5):
487 487 z = (x - a1) / a2
488 488 y = a0 * numpy.exp(-z**2 / a2) #+ a3 + a4 * x + a5 * x**2
489 489 return y
490
491
490 492 class CleanRayleigh(Operation):
491 493
492 494 def __init__(self):
493 495
494 496 Operation.__init__(self)
495 497 self.i=0
496 498 self.isConfig = False
497 499 self.__dataReady = False
498 500 self.__profIndex = 0
499 501 self.byTime = False
500 502 self.byProfiles = False
501 503
502 504 self.bloques = None
503 505 self.bloque0 = None
504 506
505 507 self.index = 0
506 508
507 509 self.buffer = 0
508 510 self.buffer2 = 0
509 511 self.buffer3 = 0
510 512
511 513
512 514 def setup(self,dataOut,min_hei,max_hei,n, timeInterval,factor_stdv):
513 515
514 516 self.nChannels = dataOut.nChannels
515 517 self.nProf = dataOut.nProfiles
516 518 self.nPairs = dataOut.data_cspc.shape[0]
517 519 self.pairsArray = numpy.array(dataOut.pairsList)
518 520 self.spectra = dataOut.data_spc
519 521 self.cspectra = dataOut.data_cspc
520 522 self.heights = dataOut.heightList #alturas totales
521 523 self.nHeights = len(self.heights)
522 524 self.min_hei = min_hei
523 525 self.max_hei = max_hei
524 526 if (self.min_hei == None):
525 527 self.min_hei = 0
526 528 if (self.max_hei == None):
527 529 self.max_hei = dataOut.heightList[-1]
528 530 self.hval = ((self.max_hei>=self.heights) & (self.heights >= self.min_hei)).nonzero()
529 531 self.heightsClean = self.heights[self.hval] #alturas filtradas
530 532 self.hval = self.hval[0] # forma (N,), an solo N elementos -> Indices de alturas
531 533 self.nHeightsClean = len(self.heightsClean)
532 534 self.channels = dataOut.channelList
533 535 self.nChan = len(self.channels)
534 536 self.nIncohInt = dataOut.nIncohInt
535 537 self.__initime = dataOut.utctime
536 538 self.maxAltInd = self.hval[-1]+1
537 539 self.minAltInd = self.hval[0]
538 540
539 541 self.crosspairs = dataOut.pairsList
540 542 self.nPairs = len(self.crosspairs)
541 543 self.normFactor = dataOut.normFactor
542 544 self.nFFTPoints = dataOut.nFFTPoints
543 545 self.ippSeconds = dataOut.ippSeconds
544 546 self.currentTime = self.__initime
545 547 self.pairsArray = numpy.array(dataOut.pairsList)
546 548 self.factor_stdv = factor_stdv
547 549 #print("CHANNELS: ",[x for x in self.channels])
548 550
549 551 if n != None :
550 552 self.byProfiles = True
551 553 self.nIntProfiles = n
552 554 else:
553 555 self.__integrationtime = timeInterval
554 556
555 557 self.__dataReady = False
556 558 self.isConfig = True
557 559
558 560
559 561
560 562 def run(self, dataOut,min_hei=None,max_hei=None, n=None, timeInterval=10,factor_stdv=2.5):
561 563 #print (dataOut.utctime)
562 564 if not self.isConfig :
563 565 #print("Setting config")
564 566 self.setup(dataOut, min_hei,max_hei,n,timeInterval,factor_stdv)
565 567 #print("Config Done")
566 568 tini=dataOut.utctime
567 569
568 570 if self.byProfiles:
569 571 if self.__profIndex == self.nIntProfiles:
570 572 self.__dataReady = True
571 573 else:
572 574 if (tini - self.__initime) >= self.__integrationtime:
573 575 #print(tini - self.__initime,self.__profIndex)
574 576 self.__dataReady = True
575 577 self.__initime = tini
576 578
577 579 #if (tini.tm_min % 2) == 0 and (tini.tm_sec < 5 and self.fint==0):
578 580
579 581 if self.__dataReady:
580 582 #print("Data ready",self.__profIndex)
581 583 self.__profIndex = 0
582 584 jspc = self.buffer
583 585 jcspc = self.buffer2
584 586 #jnoise = self.buffer3
585 587 self.buffer = dataOut.data_spc
586 588 self.buffer2 = dataOut.data_cspc
587 589 #self.buffer3 = dataOut.noise
588 590 self.currentTime = dataOut.utctime
589 591 if numpy.any(jspc) :
590 592 #print( jspc.shape, jcspc.shape)
591 593 jspc = numpy.reshape(jspc,(int(len(jspc)/self.nChannels),self.nChannels,self.nFFTPoints,self.nHeights))
592 594 jcspc= numpy.reshape(jcspc,(int(len(jcspc)/self.nPairs),self.nPairs,self.nFFTPoints,self.nHeights))
593 595 self.__dataReady = False
594 596 #print( jspc.shape, jcspc.shape)
595 597 dataOut.flagNoData = False
596 598 else:
597 599 dataOut.flagNoData = True
598 600 self.__dataReady = False
599 601 return dataOut
600 602 else:
601 603 #print( len(self.buffer))
602 604 if numpy.any(self.buffer):
603 605 self.buffer = numpy.concatenate((self.buffer,dataOut.data_spc), axis=0)
604 606 self.buffer2 = numpy.concatenate((self.buffer2,dataOut.data_cspc), axis=0)
605 607 self.buffer3 += dataOut.data_dc
606 608 else:
607 609 self.buffer = dataOut.data_spc
608 610 self.buffer2 = dataOut.data_cspc
609 611 self.buffer3 = dataOut.data_dc
610 612 #print self.index, self.fint
611 613 #print self.buffer2.shape
612 614 dataOut.flagNoData = True ## NOTE: ?? revisar LUEGO
613 615 self.__profIndex += 1
614 616 return dataOut ## NOTE: REV
615 617
616 618
617 619 #index = tini.tm_hour*12+tini.tm_min/5
618 620 '''REVISAR'''
619 621 # jspc = jspc/self.nFFTPoints/self.normFactor
620 622 # jcspc = jcspc/self.nFFTPoints/self.normFactor
621 623
622 624
623 625
624 626 tmp_spectra,tmp_cspectra = self.cleanRayleigh(dataOut,jspc,jcspc,self.factor_stdv)
625 627 dataOut.data_spc = tmp_spectra
626 628 dataOut.data_cspc = tmp_cspectra
627 629
628 630 #dataOut.data_spc,dataOut.data_cspc = self.cleanRayleigh(dataOut,jspc,jcspc,self.factor_stdv)
629 631
630 632 dataOut.data_dc = self.buffer3
631 633 dataOut.nIncohInt *= self.nIntProfiles
632 634 dataOut.utctime = self.currentTime #tiempo promediado
633 635 #print("Time: ",time.localtime(dataOut.utctime))
634 636 # dataOut.data_spc = sat_spectra
635 637 # dataOut.data_cspc = sat_cspectra
636 638 self.buffer = 0
637 639 self.buffer2 = 0
638 640 self.buffer3 = 0
639 641
640 642 return dataOut
641 643
642 644 def cleanRayleigh(self,dataOut,spectra,cspectra,factor_stdv):
643 645 #print("OP cleanRayleigh")
644 #import matplotlib.pyplot as plt
646 import matplotlib.pyplot as plt
645 647 #for k in range(149):
646
648 channelsProcssd = []
649 channelA_ok = False
647 650 rfunc = cspectra.copy() #self.bloques
648 651 #rfunc = cspectra
649 652 #val_spc = spectra*0.0 #self.bloque0*0.0
650 653 #val_cspc = cspectra*0.0 #self.bloques*0.0
651 654 #in_sat_spectra = spectra.copy() #self.bloque0
652 655 #in_sat_cspectra = cspectra.copy() #self.bloques
653 656
654 #raxs = math.ceil(math.sqrt(self.nPairs))
655 #caxs = math.ceil(self.nPairs/raxs)
656 657
657 #print(self.hval)
658 ###ONLY FOR TEST:
659 raxs = math.ceil(math.sqrt(self.nPairs))
660 caxs = math.ceil(self.nPairs/raxs)
661 if self.nPairs <4:
662 raxs = 2
663 caxs = 2
664 #print(raxs, caxs)
665 fft_rev = 14 #nFFT to plot
666 hei_rev = ((self.heights >= 550) & (self.heights <= 551)).nonzero() #hei to plot
667 hei_rev = hei_rev[0]
668 #print(hei_rev)
669
658 670 #print numpy.absolute(rfunc[:,0,0,14])
671
659 672 gauss_fit, covariance = None, None
660 673 for ih in range(self.minAltInd,self.maxAltInd):
661 674 for ifreq in range(self.nFFTPoints):
662 # fig, axs = plt.subplots(raxs, caxs)
663 # fig2, axs2 = plt.subplots(raxs, caxs)
664 # col_ax = 0
665 # row_ax = 0
666 #print(len(self.nPairs))
667 for ii in range(self.nPairs): #PARES DE CANALES SELF y CROSS
668 #print("ii: ",ii)
669 # if (col_ax%caxs==0 and col_ax!=0):
670 # col_ax = 0
671 # row_ax += 1
675 ###ONLY FOR TEST:
676 if ifreq ==fft_rev and ih==hei_rev: #TO VIEW A SIGNLE FREQUENCY
677 fig, axs = plt.subplots(raxs, caxs)
678 fig2, axs2 = plt.subplots(raxs, caxs)
679 col_ax = 0
680 row_ax = 0
681 #print(self.nPairs)
682 for ii in range(self.nPairs): #PARES DE CANALES SELF y CROSS
683 if self.crosspairs[ii][1]-self.crosspairs[ii][0] > 1: # APLICAR SOLO EN PARES CONTIGUOS
684 continue
685 if not self.crosspairs[ii][0] in channelsProcssd:
686 channelA_ok = True
687 #print("pair: ",self.crosspairs[ii])
688 if (col_ax%caxs==0 and col_ax!=0 and self.nPairs !=1): ###ONLY FOR TEST:
689 col_ax = 0
690 row_ax += 1
672 691 func2clean = 10*numpy.log10(numpy.absolute(rfunc[:,ii,ifreq,ih])) #Potencia?
673 692 #print(func2clean.shape)
674 693 val = (numpy.isfinite(func2clean)==True).nonzero()
675 694
676 695 if len(val)>0: #limitador
677 696 min_val = numpy.around(numpy.amin(func2clean)-2) #> (-40)
678 697 if min_val <= -40 :
679 698 min_val = -40
680 699 max_val = numpy.around(numpy.amax(func2clean)+2) #< 200
681 700 if max_val >= 200 :
682 701 max_val = 200
683 702 #print min_val, max_val
684 703 step = 1
685 704 #print("Getting bins and the histogram")
686 705 x_dist = min_val + numpy.arange(1 + ((max_val-(min_val))/step))*step
687 706 y_dist,binstep = numpy.histogram(func2clean,bins=range(int(min_val),int(max_val+2),step))
688 707 #print(len(y_dist),len(binstep[:-1]))
689 708 #print(row_ax,col_ax, " ..")
690 709 #print(self.pairsArray[ii][0],self.pairsArray[ii][1])
691 710 mean = numpy.sum(x_dist * y_dist) / numpy.sum(y_dist)
692 711 sigma = numpy.sqrt(numpy.sum(y_dist * (x_dist - mean)**2) / numpy.sum(y_dist))
693 712 parg = [numpy.amax(y_dist),mean,sigma]
694 713
695 #newY = None
714 newY = None
696 715
697 716 try :
698 717 gauss_fit, covariance = curve_fit(fit_func, x_dist, y_dist,p0=parg)
699 718 mode = gauss_fit[1]
700 719 stdv = gauss_fit[2]
701 720 #print(" FIT OK",gauss_fit)
702 '''
703 newY = fit_func(x_dist,gauss_fit[0],gauss_fit[1],gauss_fit[2])
704 axs[row_ax,col_ax].plot(binstep[:-1],y_dist,color='green')
705 axs[row_ax,col_ax].plot(binstep[:-1],newY,color='red')
706 axs[row_ax,col_ax].set_title("Pair "+str(self.crosspairs[ii]))'''
721
722 ###ONLY FOR TEST:
723 if ifreq ==fft_rev and ih==hei_rev: #TO VIEW A SIGNLE FREQUENCY
724 newY = fit_func(x_dist,gauss_fit[0],gauss_fit[1],gauss_fit[2])
725 axs[row_ax,col_ax].plot(binstep[:-1],y_dist,color='green')
726 axs[row_ax,col_ax].plot(binstep[:-1],newY,color='red')
727 axs[row_ax,col_ax].set_title("Pair "+str(self.crosspairs[ii]))
728
707 729 except:
708 730 mode = mean
709 731 stdv = sigma
710 732 #print("FIT FAIL")
733 continue
711 734
712 735
713 736 #print(mode,stdv)
714 737 #Removing echoes greater than mode + std_factor*stdv
715 738 noval = (abs(func2clean - mode)>=(factor_stdv*stdv)).nonzero()
716 739 #noval tiene los indices que se van a remover
717 740 #print("Pair ",ii," novals: ",len(noval[0]))
718 741 if len(noval[0]) > 0: #forma de array (N,) es igual a longitud (N)
719 742 novall = ((func2clean - mode) >= (factor_stdv*stdv)).nonzero()
720 743 #print(novall)
721 744 #print(" ",self.pairsArray[ii])
722 745 cross_pairs = self.pairsArray[ii]
723 746 #Getting coherent echoes which are removed.
724 747 # if len(novall[0]) > 0:
725 748 #
726 749 # val_spc[novall[0],cross_pairs[0],ifreq,ih] = 1
727 750 # val_spc[novall[0],cross_pairs[1],ifreq,ih] = 1
728 751 # val_cspc[novall[0],ii,ifreq,ih] = 1
729 752 #print("OUT NOVALL 1")
730 #Removing coherent from ISR data
731 chA = self.channels.index(cross_pairs[0])
732 chB = self.channels.index(cross_pairs[1])
733 753
734 754 new_a = numpy.delete(cspectra[:,ii,ifreq,ih], noval[0])
735 755 cspectra[noval,ii,ifreq,ih] = numpy.mean(new_a) #mean CrossSpectra
736 new_b = numpy.delete(spectra[:,chA,ifreq,ih], noval[0])
737 spectra[noval,chA,ifreq,ih] = numpy.mean(new_b) #mean Spectra Pair A
756
757 if channelA_ok:
758 chA = self.channels.index(cross_pairs[0])
759 new_b = numpy.delete(spectra[:,chA,ifreq,ih], noval[0])
760 spectra[noval,chA,ifreq,ih] = numpy.mean(new_b) #mean Spectra Pair A
761 channelA_ok = False
762 chB = self.channels.index(cross_pairs[1])
738 763 new_c = numpy.delete(spectra[:,chB,ifreq,ih], noval[0])
739 764 spectra[noval,chB,ifreq,ih] = numpy.mean(new_c) #mean Spectra Pair B
740 765
766 channelsProcssd.append(self.crosspairs[ii][0]) # save channel A
767 channelsProcssd.append(self.crosspairs[ii][1]) # save channel B
741 768
742 '''
743 func2clean = 10*numpy.log10(numpy.absolute(cspectra[:,ii,ifreq,ih]))
744 y_dist,binstep = numpy.histogram(func2clean,bins=range(int(min_val),int(max_val+2),step))
745 axs2[row_ax,col_ax].plot(binstep[:-1],newY,color='red')
746 axs2[row_ax,col_ax].plot(binstep[:-1],y_dist,color='green')
747 axs2[row_ax,col_ax].set_title("Pair "+str(self.crosspairs[ii]))
748 '''
769 ###ONLY FOR TEST:
770 if ifreq ==fft_rev and ih==hei_rev: #TO VIEW A SIGNLE FREQUENCY
771 func2clean = 10*numpy.log10(numpy.absolute(cspectra[:,ii,ifreq,ih]))
772 y_dist,binstep = numpy.histogram(func2clean,bins=range(int(min_val),int(max_val+2),step))
773 axs2[row_ax,col_ax].plot(binstep[:-1],newY,color='red')
774 axs2[row_ax,col_ax].plot(binstep[:-1],y_dist,color='green')
775 axs2[row_ax,col_ax].set_title("Pair "+str(self.crosspairs[ii]))
749 776
750 #col_ax += 1 #contador de ploteo columnas
777 ###ONLY FOR TEST:
778 col_ax += 1 #contador de ploteo columnas
751 779 ##print(col_ax)
752 '''
753 title = str(dataOut.datatime)+" nFFT: "+str(ifreq)+" Alt: "+str(self.heights[ih])+ " km"
754 title2 = str(dataOut.datatime)+" nFFT: "+str(ifreq)+" Alt: "+str(self.heights[ih])+ " km CLEANED"
755 fig.suptitle(title)
756 fig2.suptitle(title2)
757 plt.show()'''
758
759 ''' channels = channels
780 ###ONLY FOR TEST:
781 if ifreq ==fft_rev and ih==hei_rev: #TO VIEW A SIGNLE FREQUENCY
782 title = str(dataOut.datatime)+" nFFT: "+str(ifreq)+" Alt: "+str(self.heights[ih])+ " km"
783 title2 = str(dataOut.datatime)+" nFFT: "+str(ifreq)+" Alt: "+str(self.heights[ih])+ " km CLEANED"
784 fig.suptitle(title)
785 fig2.suptitle(title2)
786 plt.show()
787
788
789 '''
790
791 channels = channels
760 792 cross_pairs = cross_pairs
761 793 #print("OUT NOVALL 2")
762 794
763 795 vcross0 = (cross_pairs[0] == channels[ii]).nonzero()
764 796 vcross1 = (cross_pairs[1] == channels[ii]).nonzero()
765 797 vcross = numpy.concatenate((vcross0,vcross1),axis=None)
766 798 #print('vcros =', vcross)
767 799
768 800 #Getting coherent echoes which are removed.
769 801 if len(novall) > 0:
770 802 #val_spc[novall,ii,ifreq,ih] = 1
771 803 val_spc[ii,ifreq,ih,novall] = 1
772 804 if len(vcross) > 0:
773 805 val_cspc[vcross,ifreq,ih,novall] = 1
774 806
775 807 #Removing coherent from ISR data.
776 808 self.bloque0[ii,ifreq,ih,noval] = numpy.nan
777 809 if len(vcross) > 0:
778 810 self.bloques[vcross,ifreq,ih,noval] = numpy.nan
779 811 '''
780 812
781 813 #print("Getting average of the spectra and cross-spectra from incoherent echoes.")
782 814 out_spectra = numpy.zeros([self.nChan,self.nFFTPoints,self.nHeights], dtype=float) #+numpy.nan
783 815 out_cspectra = numpy.zeros([self.nPairs,self.nFFTPoints,self.nHeights], dtype=complex) #+numpy.nan
784 816 for ih in range(self.nHeights):
785 817 for ifreq in range(self.nFFTPoints):
786 818 for ich in range(self.nChan):
787 819 tmp = spectra[:,ich,ifreq,ih]
788 820 valid = (numpy.isfinite(tmp[:])==True).nonzero()
789 # if ich == 0 and ifreq == 0 and ih == 17 :
790 # print tmp
791 # print valid
792 # print len(valid[0])
793 #print('TMP',tmp)
821
794 822 if len(valid[0]) >0 :
795 823 out_spectra[ich,ifreq,ih] = numpy.nansum(tmp)#/len(valid[0])
796 #for icr in range(nPairs):
824
797 825 for icr in range(self.nPairs):
798 826 tmp = numpy.squeeze(cspectra[:,icr,ifreq,ih])
799 827 valid = (numpy.isfinite(tmp)==True).nonzero()
800 828 if len(valid[0]) > 0:
801 829 out_cspectra[icr,ifreq,ih] = numpy.nansum(tmp)#/len(valid[0])
802 830 '''
803 831 # print('##########################################################')
804 832 print("Removing fake coherent echoes (at least 4 points around the point)")
805 833
806 834 val_spectra = numpy.sum(val_spc,0)
807 835 val_cspectra = numpy.sum(val_cspc,0)
808 836
809 837 val_spectra = self.REM_ISOLATED_POINTS(val_spectra,4)
810 838 val_cspectra = self.REM_ISOLATED_POINTS(val_cspectra,4)
811 839
812 840 for i in range(nChan):
813 841 for j in range(nProf):
814 842 for k in range(nHeights):
815 843 if numpy.isfinite(val_spectra[i,j,k]) and val_spectra[i,j,k] < 1 :
816 844 val_spc[:,i,j,k] = 0.0
817 845 for i in range(nPairs):
818 846 for j in range(nProf):
819 847 for k in range(nHeights):
820 848 if numpy.isfinite(val_cspectra[i,j,k]) and val_cspectra[i,j,k] < 1 :
821 849 val_cspc[:,i,j,k] = 0.0
822 850
823 851 # val_spc = numpy.reshape(val_spc, (len(spectra[:,0,0,0]),nProf*nHeights*nChan))
824 852 # if numpy.isfinite(val_spectra)==str(True):
825 853 # noval = (val_spectra<1).nonzero()
826 854 # if len(noval) > 0:
827 855 # val_spc[:,noval] = 0.0
828 856 # val_spc = numpy.reshape(val_spc, (149,nChan,nProf,nHeights))
829 857
830 858 #val_cspc = numpy.reshape(val_spc, (149,nChan*nHeights*nProf))
831 859 #if numpy.isfinite(val_cspectra)==str(True):
832 860 # noval = (val_cspectra<1).nonzero()
833 861 # if len(noval) > 0:
834 862 # val_cspc[:,noval] = 0.0
835 863 # val_cspc = numpy.reshape(val_cspc, (149,nChan,nProf,nHeights))
836 864 tmp_sat_spectra = spectra.copy()
837 865 tmp_sat_spectra = tmp_sat_spectra*numpy.nan
838 866 tmp_sat_cspectra = cspectra.copy()
839 867 tmp_sat_cspectra = tmp_sat_cspectra*numpy.nan
840 868 '''
841 869 # fig = plt.figure(figsize=(6,5))
842 870 # left, bottom, width, height = 0.1, 0.1, 0.8, 0.8
843 871 # ax = fig.add_axes([left, bottom, width, height])
844 872 # cp = ax.contour(10*numpy.log10(numpy.absolute(spectra[0,0,:,:])))
845 873 # ax.clabel(cp, inline=True,fontsize=10)
846 874 # plt.show()
847 875 '''
848 876 val = (val_spc > 0).nonzero()
849 877 if len(val[0]) > 0:
850 878 tmp_sat_spectra[val] = in_sat_spectra[val]
851 879 val = (val_cspc > 0).nonzero()
852 880 if len(val[0]) > 0:
853 881 tmp_sat_cspectra[val] = in_sat_cspectra[val]
854 882
855 883 print("Getting average of the spectra and cross-spectra from incoherent echoes 2")
856 884 sat_spectra = numpy.zeros((nChan,nProf,nHeights), dtype=float)
857 885 sat_cspectra = numpy.zeros((nPairs,nProf,nHeights), dtype=complex)
858 886 for ih in range(nHeights):
859 887 for ifreq in range(nProf):
860 888 for ich in range(nChan):
861 889 tmp = numpy.squeeze(tmp_sat_spectra[:,ich,ifreq,ih])
862 890 valid = (numpy.isfinite(tmp)).nonzero()
863 891 if len(valid[0]) > 0:
864 892 sat_spectra[ich,ifreq,ih] = numpy.nansum(tmp)/len(valid[0])
865 893
866 894 for icr in range(nPairs):
867 895 tmp = numpy.squeeze(tmp_sat_cspectra[:,icr,ifreq,ih])
868 896 valid = (numpy.isfinite(tmp)).nonzero()
869 897 if len(valid[0]) > 0:
870 898 sat_cspectra[icr,ifreq,ih] = numpy.nansum(tmp)/len(valid[0])
871 899 '''
872 900 #self.__dataReady= True
873 901 #sat_spectra, sat_cspectra= sat_spectra, sat_cspectra
874 902 #if not self.__dataReady:
875 903 #return None, None
876 904 #return out_spectra, out_cspectra ,sat_spectra,sat_cspectra
877 905 return out_spectra, out_cspectra
878 906
879 907 def REM_ISOLATED_POINTS(self,array,rth):
880 908 # import matplotlib.pyplot as plt
881 909 if rth == None :
882 910 rth = 4
883 911 print("REM ISO")
884 912 num_prof = len(array[0,:,0])
885 913 num_hei = len(array[0,0,:])
886 914 n2d = len(array[:,0,0])
887 915
888 916 for ii in range(n2d) :
889 917 #print ii,n2d
890 918 tmp = array[ii,:,:]
891 919 #print tmp.shape, array[ii,101,:],array[ii,102,:]
892 920
893 921 # fig = plt.figure(figsize=(6,5))
894 922 # left, bottom, width, height = 0.1, 0.1, 0.8, 0.8
895 923 # ax = fig.add_axes([left, bottom, width, height])
896 924 # x = range(num_prof)
897 925 # y = range(num_hei)
898 926 # cp = ax.contour(y,x,tmp)
899 927 # ax.clabel(cp, inline=True,fontsize=10)
900 928 # plt.show()
901 929
902 930 #indxs = WHERE(FINITE(tmp) AND tmp GT 0,cindxs)
903 931 tmp = numpy.reshape(tmp,num_prof*num_hei)
904 932 indxs1 = (numpy.isfinite(tmp)==True).nonzero()
905 933 indxs2 = (tmp > 0).nonzero()
906 934
907 935 indxs1 = (indxs1[0])
908 936 indxs2 = indxs2[0]
909 937 #indxs1 = numpy.array(indxs1[0])
910 938 #indxs2 = numpy.array(indxs2[0])
911 939 indxs = None
912 940 #print indxs1 , indxs2
913 941 for iv in range(len(indxs2)):
914 942 indv = numpy.array((indxs1 == indxs2[iv]).nonzero())
915 943 #print len(indxs2), indv
916 944 if len(indv[0]) > 0 :
917 945 indxs = numpy.concatenate((indxs,indxs2[iv]), axis=None)
918 946 # print indxs
919 947 indxs = indxs[1:]
920 948 #print(indxs, len(indxs))
921 949 if len(indxs) < 4 :
922 950 array[ii,:,:] = 0.
923 951 return
924 952
925 953 xpos = numpy.mod(indxs ,num_hei)
926 954 ypos = (indxs / num_hei)
927 955 sx = numpy.argsort(xpos) # Ordering respect to "x" (time)
928 956 #print sx
929 957 xpos = xpos[sx]
930 958 ypos = ypos[sx]
931 959
932 960 # *********************************** Cleaning isolated points **********************************
933 961 ic = 0
934 962 while True :
935 963 r = numpy.sqrt(list(numpy.power((xpos[ic]-xpos),2)+ numpy.power((ypos[ic]-ypos),2)))
936 964 #no_coh = WHERE(FINITE(r) AND (r LE rth),cno_coh)
937 965 #plt.plot(r)
938 966 #plt.show()
939 967 no_coh1 = (numpy.isfinite(r)==True).nonzero()
940 968 no_coh2 = (r <= rth).nonzero()
941 969 #print r, no_coh1, no_coh2
942 970 no_coh1 = numpy.array(no_coh1[0])
943 971 no_coh2 = numpy.array(no_coh2[0])
944 972 no_coh = None
945 973 #print valid1 , valid2
946 974 for iv in range(len(no_coh2)):
947 975 indv = numpy.array((no_coh1 == no_coh2[iv]).nonzero())
948 976 if len(indv[0]) > 0 :
949 977 no_coh = numpy.concatenate((no_coh,no_coh2[iv]), axis=None)
950 978 no_coh = no_coh[1:]
951 979 #print len(no_coh), no_coh
952 980 if len(no_coh) < 4 :
953 981 #print xpos[ic], ypos[ic], ic
954 982 # plt.plot(r)
955 983 # plt.show()
956 984 xpos[ic] = numpy.nan
957 985 ypos[ic] = numpy.nan
958 986
959 987 ic = ic + 1
960 988 if (ic == len(indxs)) :
961 989 break
962 990 #print( xpos, ypos)
963 991
964 992 indxs = (numpy.isfinite(list(xpos))==True).nonzero()
965 993 #print indxs[0]
966 994 if len(indxs[0]) < 4 :
967 995 array[ii,:,:] = 0.
968 996 return
969 997
970 998 xpos = xpos[indxs[0]]
971 999 ypos = ypos[indxs[0]]
972 1000 for i in range(0,len(ypos)):
973 1001 ypos[i]=int(ypos[i])
974 1002 junk = tmp
975 1003 tmp = junk*0.0
976 1004
977 1005 tmp[list(xpos + (ypos*num_hei))] = junk[list(xpos + (ypos*num_hei))]
978 1006 array[ii,:,:] = numpy.reshape(tmp,(num_prof,num_hei))
979 1007
980 1008 #print array.shape
981 1009 #tmp = numpy.reshape(tmp,(num_prof,num_hei))
982 1010 #print tmp.shape
983 1011
984 1012 # fig = plt.figure(figsize=(6,5))
985 1013 # left, bottom, width, height = 0.1, 0.1, 0.8, 0.8
986 1014 # ax = fig.add_axes([left, bottom, width, height])
987 1015 # x = range(num_prof)
988 1016 # y = range(num_hei)
989 1017 # cp = ax.contour(y,x,array[ii,:,:])
990 1018 # ax.clabel(cp, inline=True,fontsize=10)
991 1019 # plt.show()
992 1020 return array
993 1021
994 1022 class removeInterference(Operation):
995 1023
996 1024 def removeInterference2(self):
997 1025
998 1026 cspc = self.dataOut.data_cspc
999 1027 spc = self.dataOut.data_spc
1000 1028 Heights = numpy.arange(cspc.shape[2])
1001 1029 realCspc = numpy.abs(cspc)
1002 1030
1003 1031 for i in range(cspc.shape[0]):
1004 1032 LinePower= numpy.sum(realCspc[i], axis=0)
1005 1033 Threshold = numpy.amax(LinePower)-numpy.sort(LinePower)[len(Heights)-int(len(Heights)*0.1)]
1006 1034 SelectedHeights = Heights[ numpy.where( LinePower < Threshold ) ]
1007 1035 InterferenceSum = numpy.sum( realCspc[i,:,SelectedHeights], axis=0 )
1008 1036 InterferenceThresholdMin = numpy.sort(InterferenceSum)[int(len(InterferenceSum)*0.98)]
1009 1037 InterferenceThresholdMax = numpy.sort(InterferenceSum)[int(len(InterferenceSum)*0.99)]
1010 1038
1011 1039
1012 1040 InterferenceRange = numpy.where( ([InterferenceSum > InterferenceThresholdMin]))# , InterferenceSum < InterferenceThresholdMax]) )
1013 1041 #InterferenceRange = numpy.where( ([InterferenceRange < InterferenceThresholdMax]))
1014 1042 if len(InterferenceRange)<int(cspc.shape[1]*0.3):
1015 1043 cspc[i,InterferenceRange,:] = numpy.NaN
1016 1044
1017 1045 self.dataOut.data_cspc = cspc
1018 1046
1019 1047 def removeInterference(self, interf = 2, hei_interf = None, nhei_interf = None, offhei_interf = None):
1020 1048
1021 1049 jspectra = self.dataOut.data_spc
1022 1050 jcspectra = self.dataOut.data_cspc
1023 1051 jnoise = self.dataOut.getNoise()
1024 1052 num_incoh = self.dataOut.nIncohInt
1025 1053
1026 1054 num_channel = jspectra.shape[0]
1027 1055 num_prof = jspectra.shape[1]
1028 1056 num_hei = jspectra.shape[2]
1029 1057
1030 1058 # hei_interf
1031 1059 if hei_interf is None:
1032 1060 count_hei = int(num_hei / 2)
1033 1061 hei_interf = numpy.asmatrix(list(range(count_hei))) + num_hei - count_hei
1034 1062 hei_interf = numpy.asarray(hei_interf)[0]
1035 1063 # nhei_interf
1036 1064 if (nhei_interf == None):
1037 1065 nhei_interf = 5
1038 1066 if (nhei_interf < 1):
1039 1067 nhei_interf = 1
1040 1068 if (nhei_interf > count_hei):
1041 1069 nhei_interf = count_hei
1042 1070 if (offhei_interf == None):
1043 1071 offhei_interf = 0
1044 1072
1045 1073 ind_hei = list(range(num_hei))
1046 1074 # mask_prof = numpy.asarray(range(num_prof - 2)) + 1
1047 1075 # mask_prof[range(num_prof/2 - 1,len(mask_prof))] += 1
1048 1076 mask_prof = numpy.asarray(list(range(num_prof)))
1049 1077 num_mask_prof = mask_prof.size
1050 1078 comp_mask_prof = [0, num_prof / 2]
1051 1079
1052 1080 # noise_exist: Determina si la variable jnoise ha sido definida y contiene la informacion del ruido de cada canal
1053 1081 if (jnoise.size < num_channel or numpy.isnan(jnoise).any()):
1054 1082 jnoise = numpy.nan
1055 1083 noise_exist = jnoise[0] < numpy.Inf
1056 1084
1057 1085 # Subrutina de Remocion de la Interferencia
1058 1086 for ich in range(num_channel):
1059 1087 # Se ordena los espectros segun su potencia (menor a mayor)
1060 1088 power = jspectra[ich, mask_prof, :]
1061 1089 power = power[:, hei_interf]
1062 1090 power = power.sum(axis=0)
1063 1091 psort = power.ravel().argsort()
1064 1092
1065 1093 # Se estima la interferencia promedio en los Espectros de Potencia empleando
1066 1094 junkspc_interf = jspectra[ich, :, hei_interf[psort[list(range(
1067 1095 offhei_interf, nhei_interf + offhei_interf))]]]
1068 1096
1069 1097 if noise_exist:
1070 1098 # tmp_noise = jnoise[ich] / num_prof
1071 1099 tmp_noise = jnoise[ich]
1072 1100 junkspc_interf = junkspc_interf - tmp_noise
1073 1101 #junkspc_interf[:,comp_mask_prof] = 0
1074 1102
1075 1103 jspc_interf = junkspc_interf.sum(axis=0) / nhei_interf
1076 1104 jspc_interf = jspc_interf.transpose()
1077 1105 # Calculando el espectro de interferencia promedio
1078 1106 noiseid = numpy.where(
1079 1107 jspc_interf <= tmp_noise / numpy.sqrt(num_incoh))
1080 1108 noiseid = noiseid[0]
1081 1109 cnoiseid = noiseid.size
1082 1110 interfid = numpy.where(
1083 1111 jspc_interf > tmp_noise / numpy.sqrt(num_incoh))
1084 1112 interfid = interfid[0]
1085 1113 cinterfid = interfid.size
1086 1114
1087 1115 if (cnoiseid > 0):
1088 1116 jspc_interf[noiseid] = 0
1089 1117
1090 1118 # Expandiendo los perfiles a limpiar
1091 1119 if (cinterfid > 0):
1092 1120 new_interfid = (
1093 1121 numpy.r_[interfid - 1, interfid, interfid + 1] + num_prof) % num_prof
1094 1122 new_interfid = numpy.asarray(new_interfid)
1095 1123 new_interfid = {x for x in new_interfid}
1096 1124 new_interfid = numpy.array(list(new_interfid))
1097 1125 new_cinterfid = new_interfid.size
1098 1126 else:
1099 1127 new_cinterfid = 0
1100 1128
1101 1129 for ip in range(new_cinterfid):
1102 1130 ind = junkspc_interf[:, new_interfid[ip]].ravel().argsort()
1103 1131 jspc_interf[new_interfid[ip]
1104 1132 ] = junkspc_interf[ind[nhei_interf // 2], new_interfid[ip]]
1105 1133
1106 1134 jspectra[ich, :, ind_hei] = jspectra[ich, :,
1107 1135 ind_hei] - jspc_interf # Corregir indices
1108 1136
1109 1137 # Removiendo la interferencia del punto de mayor interferencia
1110 1138 ListAux = jspc_interf[mask_prof].tolist()
1111 1139 maxid = ListAux.index(max(ListAux))
1112 1140
1113 1141 if cinterfid > 0:
1114 1142 for ip in range(cinterfid * (interf == 2) - 1):
1115 1143 ind = (jspectra[ich, interfid[ip], :] < tmp_noise *
1116 1144 (1 + 1 / numpy.sqrt(num_incoh))).nonzero()
1117 1145 cind = len(ind)
1118 1146
1119 1147 if (cind > 0):
1120 1148 jspectra[ich, interfid[ip], ind] = tmp_noise * \
1121 1149 (1 + (numpy.random.uniform(cind) - 0.5) /
1122 1150 numpy.sqrt(num_incoh))
1123 1151
1124 1152 ind = numpy.array([-2, -1, 1, 2])
1125 1153 xx = numpy.zeros([4, 4])
1126 1154
1127 1155 for id1 in range(4):
1128 1156 xx[:, id1] = ind[id1]**numpy.asarray(list(range(4)))
1129 1157
1130 1158 xx_inv = numpy.linalg.inv(xx)
1131 1159 xx = xx_inv[:, 0]
1132 1160 ind = (ind + maxid + num_mask_prof) % num_mask_prof
1133 1161 yy = jspectra[ich, mask_prof[ind], :]
1134 1162 jspectra[ich, mask_prof[maxid], :] = numpy.dot(
1135 1163 yy.transpose(), xx)
1136 1164
1137 1165 indAux = (jspectra[ich, :, :] < tmp_noise *
1138 1166 (1 - 1 / numpy.sqrt(num_incoh))).nonzero()
1139 1167 jspectra[ich, indAux[0], indAux[1]] = tmp_noise * \
1140 1168 (1 - 1 / numpy.sqrt(num_incoh))
1141 1169
1142 1170 # Remocion de Interferencia en el Cross Spectra
1143 1171 if jcspectra is None:
1144 1172 return jspectra, jcspectra
1145 1173 num_pairs = int(jcspectra.size / (num_prof * num_hei))
1146 1174 jcspectra = jcspectra.reshape(num_pairs, num_prof, num_hei)
1147 1175
1148 1176 for ip in range(num_pairs):
1149 1177
1150 1178 #-------------------------------------------
1151 1179
1152 1180 cspower = numpy.abs(jcspectra[ip, mask_prof, :])
1153 1181 cspower = cspower[:, hei_interf]
1154 1182 cspower = cspower.sum(axis=0)
1155 1183
1156 1184 cspsort = cspower.ravel().argsort()
1157 1185 junkcspc_interf = jcspectra[ip, :, hei_interf[cspsort[list(range(
1158 1186 offhei_interf, nhei_interf + offhei_interf))]]]
1159 1187 junkcspc_interf = junkcspc_interf.transpose()
1160 1188 jcspc_interf = junkcspc_interf.sum(axis=1) / nhei_interf
1161 1189
1162 1190 ind = numpy.abs(jcspc_interf[mask_prof]).ravel().argsort()
1163 1191
1164 1192 median_real = int(numpy.median(numpy.real(
1165 1193 junkcspc_interf[mask_prof[ind[list(range(3 * num_prof // 4))]], :])))
1166 1194 median_imag = int(numpy.median(numpy.imag(
1167 1195 junkcspc_interf[mask_prof[ind[list(range(3 * num_prof // 4))]], :])))
1168 1196 comp_mask_prof = [int(e) for e in comp_mask_prof]
1169 1197 junkcspc_interf[comp_mask_prof, :] = numpy.complex(
1170 1198 median_real, median_imag)
1171 1199
1172 1200 for iprof in range(num_prof):
1173 1201 ind = numpy.abs(junkcspc_interf[iprof, :]).ravel().argsort()
1174 1202 jcspc_interf[iprof] = junkcspc_interf[iprof, ind[nhei_interf // 2]]
1175 1203
1176 1204 # Removiendo la Interferencia
1177 1205 jcspectra[ip, :, ind_hei] = jcspectra[ip,
1178 1206 :, ind_hei] - jcspc_interf
1179 1207
1180 1208 ListAux = numpy.abs(jcspc_interf[mask_prof]).tolist()
1181 1209 maxid = ListAux.index(max(ListAux))
1182 1210
1183 1211 ind = numpy.array([-2, -1, 1, 2])
1184 1212 xx = numpy.zeros([4, 4])
1185 1213
1186 1214 for id1 in range(4):
1187 1215 xx[:, id1] = ind[id1]**numpy.asarray(list(range(4)))
1188 1216
1189 1217 xx_inv = numpy.linalg.inv(xx)
1190 1218 xx = xx_inv[:, 0]
1191 1219
1192 1220 ind = (ind + maxid + num_mask_prof) % num_mask_prof
1193 1221 yy = jcspectra[ip, mask_prof[ind], :]
1194 1222 jcspectra[ip, mask_prof[maxid], :] = numpy.dot(yy.transpose(), xx)
1195 1223
1196 1224 # Guardar Resultados
1197 1225 self.dataOut.data_spc = jspectra
1198 1226 self.dataOut.data_cspc = jcspectra
1199 1227
1200 1228 return 1
1201 1229
1202 1230 def run(self, dataOut, interf = 2,hei_interf = None, nhei_interf = None, offhei_interf = None, mode=1):
1203 1231
1204 1232 self.dataOut = dataOut
1205 1233
1206 1234 if mode == 1:
1207 1235 self.removeInterference(interf = 2,hei_interf = None, nhei_interf = None, offhei_interf = None)
1208 1236 elif mode == 2:
1209 1237 self.removeInterference2()
1210 1238
1211 1239 return self.dataOut
1212 1240
1213 1241
1214 1242 class IncohInt(Operation):
1215 1243
1216 1244 __profIndex = 0
1217 1245 __withOverapping = False
1218 1246
1219 1247 __byTime = False
1220 1248 __initime = None
1221 1249 __lastdatatime = None
1222 1250 __integrationtime = None
1223 1251
1224 1252 __buffer_spc = None
1225 1253 __buffer_cspc = None
1226 1254 __buffer_dc = None
1227 1255
1228 1256 __dataReady = False
1229 1257
1230 1258 __timeInterval = None
1231 1259
1232 1260 n = None
1233 1261
1234 1262 def __init__(self):
1235 1263
1236 1264 Operation.__init__(self)
1237 1265
1238 1266 def setup(self, n=None, timeInterval=None, overlapping=False):
1239 1267 """
1240 1268 Set the parameters of the integration class.
1241 1269
1242 1270 Inputs:
1243 1271
1244 1272 n : Number of coherent integrations
1245 1273 timeInterval : Time of integration. If the parameter "n" is selected this one does not work
1246 1274 overlapping :
1247 1275
1248 1276 """
1249 1277
1250 1278 self.__initime = None
1251 1279 self.__lastdatatime = 0
1252 1280
1253 1281 self.__buffer_spc = 0
1254 1282 self.__buffer_cspc = 0
1255 1283 self.__buffer_dc = 0
1256 1284
1257 1285 self.__profIndex = 0
1258 1286 self.__dataReady = False
1259 1287 self.__byTime = False
1260 1288
1261 1289 if n is None and timeInterval is None:
1262 1290 raise ValueError("n or timeInterval should be specified ...")
1263 1291
1264 1292 if n is not None:
1265 1293 self.n = int(n)
1266 1294 else:
1267 1295
1268 1296 self.__integrationtime = int(timeInterval)
1269 1297 self.n = None
1270 1298 self.__byTime = True
1271 1299
1272 1300 def putData(self, data_spc, data_cspc, data_dc):
1273 1301 """
1274 1302 Add a profile to the __buffer_spc and increase in one the __profileIndex
1275 1303
1276 1304 """
1277 1305
1278 1306 self.__buffer_spc += data_spc
1279 1307
1280 1308 if data_cspc is None:
1281 1309 self.__buffer_cspc = None
1282 1310 else:
1283 1311 self.__buffer_cspc += data_cspc
1284 1312
1285 1313 if data_dc is None:
1286 1314 self.__buffer_dc = None
1287 1315 else:
1288 1316 self.__buffer_dc += data_dc
1289 1317
1290 1318 self.__profIndex += 1
1291 1319
1292 1320 return
1293 1321
1294 1322 def pushData(self):
1295 1323 """
1296 1324 Return the sum of the last profiles and the profiles used in the sum.
1297 1325
1298 1326 Affected:
1299 1327
1300 1328 self.__profileIndex
1301 1329
1302 1330 """
1303 1331
1304 1332 data_spc = self.__buffer_spc
1305 1333 data_cspc = self.__buffer_cspc
1306 1334 data_dc = self.__buffer_dc
1307 1335 n = self.__profIndex
1308 1336
1309 1337 self.__buffer_spc = 0
1310 1338 self.__buffer_cspc = 0
1311 1339 self.__buffer_dc = 0
1312 1340 self.__profIndex = 0
1313 1341
1314 1342 return data_spc, data_cspc, data_dc, n
1315 1343
1316 1344 def byProfiles(self, *args):
1317 1345
1318 1346 self.__dataReady = False
1319 1347 avgdata_spc = None
1320 1348 avgdata_cspc = None
1321 1349 avgdata_dc = None
1322 1350
1323 1351 self.putData(*args)
1324 1352
1325 1353 if self.__profIndex == self.n:
1326 1354
1327 1355 avgdata_spc, avgdata_cspc, avgdata_dc, n = self.pushData()
1328 1356 self.n = n
1329 1357 self.__dataReady = True
1330 1358
1331 1359 return avgdata_spc, avgdata_cspc, avgdata_dc
1332 1360
1333 1361 def byTime(self, datatime, *args):
1334 1362
1335 1363 self.__dataReady = False
1336 1364 avgdata_spc = None
1337 1365 avgdata_cspc = None
1338 1366 avgdata_dc = None
1339 1367
1340 1368 self.putData(*args)
1341 1369
1342 1370 if (datatime - self.__initime) >= self.__integrationtime:
1343 1371 avgdata_spc, avgdata_cspc, avgdata_dc, n = self.pushData()
1344 1372 self.n = n
1345 1373 self.__dataReady = True
1346 1374
1347 1375 return avgdata_spc, avgdata_cspc, avgdata_dc
1348 1376
1349 1377 def integrate(self, datatime, *args):
1350 1378
1351 1379 if self.__profIndex == 0:
1352 1380 self.__initime = datatime
1353 1381
1354 1382 if self.__byTime:
1355 1383 avgdata_spc, avgdata_cspc, avgdata_dc = self.byTime(
1356 1384 datatime, *args)
1357 1385 else:
1358 1386 avgdata_spc, avgdata_cspc, avgdata_dc = self.byProfiles(*args)
1359 1387
1360 1388 if not self.__dataReady:
1361 1389 return None, None, None, None
1362 1390
1363 1391 return self.__initime, avgdata_spc, avgdata_cspc, avgdata_dc
1364 1392
1365 1393 def run(self, dataOut, n=None, timeInterval=None, overlapping=False):
1366 1394 if n == 1:
1367 1395 return dataOut
1368 1396
1369 1397 dataOut.flagNoData = True
1370 1398
1371 1399 if not self.isConfig:
1372 1400 self.setup(n, timeInterval, overlapping)
1373 1401 self.isConfig = True
1374 1402
1375 1403 avgdatatime, avgdata_spc, avgdata_cspc, avgdata_dc = self.integrate(dataOut.utctime,
1376 1404 dataOut.data_spc,
1377 1405 dataOut.data_cspc,
1378 1406 dataOut.data_dc)
1379 1407
1380 1408 if self.__dataReady:
1381 1409
1382 1410 dataOut.data_spc = avgdata_spc
1383 1411 dataOut.data_cspc = avgdata_cspc
1384 1412 dataOut.data_dc = avgdata_dc
1385 1413 dataOut.nIncohInt *= self.n
1386 1414 dataOut.utctime = avgdatatime
1387 1415 dataOut.flagNoData = False
1388 1416
1389 1417 return dataOut
1390 1418
1391 1419 class dopplerFlip(Operation):
1392 1420
1393 1421 def run(self, dataOut):
1394 1422 # arreglo 1: (num_chan, num_profiles, num_heights)
1395 1423 self.dataOut = dataOut
1396 1424 # JULIA-oblicua, indice 2
1397 1425 # arreglo 2: (num_profiles, num_heights)
1398 1426 jspectra = self.dataOut.data_spc[2]
1399 1427 jspectra_tmp = numpy.zeros(jspectra.shape)
1400 1428 num_profiles = jspectra.shape[0]
1401 1429 freq_dc = int(num_profiles / 2)
1402 1430 # Flip con for
1403 1431 for j in range(num_profiles):
1404 1432 jspectra_tmp[num_profiles-j-1]= jspectra[j]
1405 1433 # Intercambio perfil de DC con perfil inmediato anterior
1406 1434 jspectra_tmp[freq_dc-1]= jspectra[freq_dc-1]
1407 1435 jspectra_tmp[freq_dc]= jspectra[freq_dc]
1408 1436 # canal modificado es re-escrito en el arreglo de canales
1409 1437 self.dataOut.data_spc[2] = jspectra_tmp
1410 1438
1411 1439 return self.dataOut
General Comments 0
You need to be logged in to leave comments. Login now