##// END OF EJS Templates
Ultimo avance simulador y pruebas de procesaiento Weather Radar
avaldez -
r1294:575339b32691 v3.0-devel-wrc
parent child
Show More
@@ -267,7 +267,7 class JROData(GenericData):
267 return fmax
267 return fmax
268
268
269 def getVmax(self):
269 def getVmax(self):
270
270 #print("frequency",self.frequency)
271 _lambda = self.C / self.frequency
271 _lambda = self.C / self.frequency
272
272
273 vmax = self.getFmax() * _lambda / 2
273 vmax = self.getFmax() * _lambda / 2
@@ -100,6 +100,7 class Scope_(Figure):
100 if ymin == None: ymin = numpy.nanmin(yreal)
100 if ymin == None: ymin = numpy.nanmin(yreal)
101 if ymax == None: ymax = numpy.nanmax(yreal)
101 if ymax == None: ymax = numpy.nanmax(yreal)
102
102
103
103 self.isConfig = True
104 self.isConfig = True
104
105
105 self.setWinTitle(title)
106 self.setWinTitle(title)
@@ -113,9 +114,10 class Scope_(Figure):
113 xlabel=xlabel, ylabel=ylabel, title=title)
114 xlabel=xlabel, ylabel=ylabel, title=title)
114
115
115 def plot_weatherpower(self, x, y, id, channelIndexList, thisDatetime, wintitle, show, xmin, xmax, ymin, ymax):
116 def plot_weatherpower(self, x, y, id, channelIndexList, thisDatetime, wintitle, show, xmin, xmax, ymin, ymax):
116 y = y[channelIndexList,:]
117 yreal = y
118
117
118 #x = x[channelIndexList,:]
119 y = y[channelIndexList,:].real
120 y = 10*numpy.log10(y)
119 title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
121 title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
120 xlabel = "Range (Km)"
122 xlabel = "Range (Km)"
121 ylabel = "Intensity"
123 ylabel = "Intensity"
@@ -130,8 +132,9 class Scope_(Figure):
130
132
131 if xmin == None: xmin = numpy.nanmin(x)
133 if xmin == None: xmin = numpy.nanmin(x)
132 if xmax == None: xmax = numpy.nanmax(x)
134 if xmax == None: xmax = numpy.nanmax(x)
133 if ymin == None: ymin = numpy.nanmin(yreal)
135 if ymin == None: ymin = numpy.nanmin(y)
134 if ymax == None: ymax = numpy.nanmax(yreal)
136 if ymax == None: ymax = numpy.nanmax(y)
137 #print (xmin,xmax)
135
138
136 self.isConfig = True
139 self.isConfig = True
137
140
@@ -140,11 +143,48 class Scope_(Figure):
140 for i in range(len(self.axesList)):
143 for i in range(len(self.axesList)):
141 title = "Channel %d" %(i)
144 title = "Channel %d" %(i)
142 axes = self.axesList[i]
145 axes = self.axesList[i]
143 ychannel = yreal[i,:]
146 #print(numpy.nanmax(x))
147 ychannel = y[i,:]
148 #ychannel = yreal[i,:]
144 axes.pline(x, ychannel,
149 axes.pline(x, ychannel,
145 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
150 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
146 xlabel=xlabel, ylabel=ylabel, title=title)
151 xlabel=xlabel, ylabel=ylabel, title=title)
147
152
153 def plot_weathervelocity(self, x, y, id, channelIndexList, thisDatetime, wintitle, show, xmin, xmax, ymin, ymax):
154 #print(channelIndexList)
155 x = x[channelIndexList,:]
156
157 title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
158 xlabel = "Velocity (m/s)"
159 ylabel = "Range (Km)"
160
161 if not self.isConfig:
162 nplots = len(channelIndexList)
163
164 self.setup(id=id,
165 nplots=nplots,
166 wintitle='',
167 show=show)
168
169 if xmin == None: xmin = numpy.nanmin(x)
170 if xmax == None: xmax = numpy.nanmax(x)
171 if ymin == None: ymin = numpy.nanmin(y)
172 if ymax == None: ymax = numpy.nanmax(y)
173 print (xmin,xmax)
174
175 self.isConfig = True
176
177 self.setWinTitle(title)
178
179 for i in range(len(self.axesList)):
180 title = "Channel %d" %(i)
181 axes = self.axesList[i]
182 #print(numpy.nanmax(x))
183 xchannel = x[i,:]
184 #ychannel = yreal[i,:]
185 axes.pline(xchannel, y,
186 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
187 xlabel=xlabel, ylabel=ylabel, title=title)
148
188
149
189
150 def run(self, dataOut, id, wintitle="", channelList=None,
190 def run(self, dataOut, id, wintitle="", channelList=None,
@@ -206,7 +246,7 class Scope_(Figure):
206 id,
246 id,
207 channelIndexList,
247 channelIndexList,
208 thisDatetime,
248 thisDatetime,
209 wintitle1,
249 wintitle,
210 show,
250 show,
211 xmin,
251 xmin,
212 xmax,
252 xmax,
@@ -214,8 +254,8 class Scope_(Figure):
214 ymax)
254 ymax)
215
255
216 if type == "weathervelocity":
256 if type == "weathervelocity":
217 self.plot_weatherpower(dataOut.heightList,
257 self.plot_weathervelocity(dataOut.data_velocity[:,i,:],
218 dataOut.data_velocity[:,i,:],
258 dataOut.heightList,
219 id,
259 id,
220 channelIndexList,
260 channelIndexList,
221 thisDatetime,
261 thisDatetime,
@@ -280,6 +320,31 class Scope_(Figure):
280 ymin,
320 ymin,
281 ymax)
321 ymax)
282
322
323 if type== "weatherpower":
324 self.plot_weatherpower(dataOut.heightList,
325 dataOut.data,
326 id,
327 channelIndexList,
328 thisDatetime,
329 wintitle,
330 show,
331 xmin,
332 xmax,
333 ymin,
334 ymax)
335 if type== "weathervelocity":
336 self.plot_weathervelocity(dataOut.data_velocity,
337 dataOut.heightList,
338 id,
339 channelIndexList,
340 thisDatetime,
341 wintitle,
342 show,
343 xmin,
344 xmax,
345 ymin,
346 ymax)
347
283 self.draw()
348 self.draw()
284
349
285 str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") + "_" + str(dataOut.profileIndex)
350 str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") + "_" + str(dataOut.profileIndex)
@@ -293,3 +358,224 class Scope_(Figure):
293 thisDatetime=thisDatetime)
358 thisDatetime=thisDatetime)
294
359
295 return dataOut
360 return dataOut
361
362
363
364 @MPDecorator
365 class TimePlot_(Figure):
366
367 __isConfig = None
368 __nsubplots = None
369
370 WIDTHPROF = None
371 HEIGHTPROF = None
372 PREFIX = 'time'
373
374 def __init__(self):
375
376 Figure.__init__(self)
377 self.timerange = None
378 self.isConfig = False
379 self.__nsubplots = 1
380
381 self.WIDTH = 800
382 self.HEIGHT = 250
383 self.WIDTHPROF = 120
384 self.HEIGHTPROF = 0
385 self.counter_imagwr = 0
386
387 self.PLOT_CODE = RTIVOLT_CODE
388
389 self.FTP_WEI = None
390 self.EXP_CODE = None
391 self.SUB_EXP_CODE = None
392 self.PLOT_POS = None
393 self.tmin = None
394 self.tmax = None
395
396 self.xmin = None
397 self.xmax = None
398
399 self.figfile = None
400
401 def getSubplots(self):
402
403 ncol = 1
404 nrow = self.nplots
405
406 return nrow, ncol
407
408 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
409
410 self.__showprofile = showprofile
411 self.nplots = nplots
412
413 ncolspan = 1
414 colspan = 1
415 if showprofile:
416 ncolspan = 7
417 colspan = 6
418 self.__nsubplots = 2
419
420 self.createFigure(id = id,
421 wintitle = wintitle,
422 widthplot = self.WIDTH + self.WIDTHPROF,
423 heightplot = self.HEIGHT + self.HEIGHTPROF,
424 show=show)
425
426 nrow, ncol = self.getSubplots()
427
428 counter = 0
429 for y in range(nrow):
430 for x in range(ncol):
431
432 if counter >= self.nplots:
433 break
434
435 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
436
437 if showprofile:
438 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
439
440 counter += 1
441
442 def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True',
443 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,type="intensity",
444 timerange=None, colormap='jet',
445 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
446 server=None, folder=None, username=None, password=None,
447 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, normFactor=None, HEIGHT=None):
448
449 """
450
451 Input:
452 dataOut :
453 id :
454 wintitle :
455 channelList :
456 showProfile :
457 xmin : None,
458 xmax : None,
459 ymin : None,
460 ymax : None,
461 zmin : None,
462 zmax : None
463 """
464 print("estoy aqui :D")
465 if dataOut.flagNoData:
466 return dataOut
467
468 #colormap = kwargs.get('colormap', 'jet')
469 if HEIGHT is not None:
470 self.HEIGHT = HEIGHT
471
472 if not isTimeInHourRange(dataOut.datatime, xmin, xmax):
473 return
474
475 if channelList == None:
476 channelIndexList = dataOut.channelIndexList
477 else:
478 channelIndexList = []
479 for channel in channelList:
480 if channel not in dataOut.channelList:
481 raise ValueError("Channel %d is not in dataOut.channelList")
482 channelIndexList.append(dataOut.channelList.index(channel))
483
484 if normFactor is None:
485 factor = dataOut.normFactor
486 else:
487 factor = normFactor
488
489 #factor = dataOut.normFactor
490 x = dataOut.getTimeRange()
491 y = dataOut.getHeiRange()
492 if type=="intensity":
493 z = dataOut.data_intensity/factor
494 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
495 avgdB = numpy.average(z, axis=1)
496 avgdB = 10.*numpy.log10(avg)
497 else:
498 z= dataOut.data_velocity
499 avgdB = numpy.average(z, axis=1)
500
501 # avgdB = dataOut.getPower()
502
503
504 thisDatetime = dataOut.datatime
505 #thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
506 title = wintitle + " RTI" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
507 xlabel = ""
508 ylabel = "Range (Km)"
509
510 update_figfile = False
511
512 if self.xmax is not None and dataOut.ltctime >= self.xmax: #yong
513 self.counter_imagwr = wr_period
514 self.isConfig = False
515 update_figfile = True
516
517 if not self.isConfig:
518
519 nplots = len(channelIndexList)
520
521 self.setup(id=id,
522 nplots=nplots,
523 wintitle=wintitle,
524 showprofile=showprofile,
525 show=show)
526
527 if timerange != None:
528 self.timerange = timerange
529
530 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
531
532 noise = dataOut.noise/factor
533 noisedB = 10*numpy.log10(noise)
534
535 if ymin == None: ymin = numpy.nanmin(y)
536 if ymax == None: ymax = numpy.nanmax(y)
537 if zmin == None: zmin = numpy.floor(numpy.nanmin(noisedB)) - 3
538 if zmax == None: zmax = numpy.ceil(numpy.nanmax(avgdB)) + 3
539
540 self.FTP_WEI = ftp_wei
541 self.EXP_CODE = exp_code
542 self.SUB_EXP_CODE = sub_exp_code
543 self.PLOT_POS = plot_pos
544
545 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
546 self.isConfig = True
547 self.figfile = figfile
548 update_figfile = True
549
550 self.setWinTitle(title)
551
552 for i in range(self.nplots):
553 index = channelIndexList[i]
554 title = "Channel %d: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
555 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
556 title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith)
557 axes = self.axesList[i*self.__nsubplots]
558 zdB = avgdB[index].reshape((1,-1))
559 axes.pcolorbuffer(x, y, zdB,
560 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
561 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
562 ticksize=9, cblabel='', cbsize="1%", colormap=colormap)
563
564 if self.__showprofile:
565 axes = self.axesList[i*self.__nsubplots +1]
566 axes.pline(avgdB[index], y,
567 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
568 xlabel='dB', ylabel='', title='',
569 ytick_visible=False,
570 grid='x')
571
572 self.draw()
573
574 self.save(figpath=figpath,
575 figfile=figfile,
576 save=save,
577 ftp=ftp,
578 wr_period=wr_period,
579 thisDatetime=thisDatetime,
580 update_figfile=update_figfile)
581 return dataOut
@@ -28,3 +28,4 SPECFIT_CODE = 27
28 EWDRIFT_CODE = 28
28 EWDRIFT_CODE = 28
29
29
30 WPO_CODE = 29 #Weather Intensity - Power
30 WPO_CODE = 29 #Weather Intensity - Power
31 RTIVOLT_CODE = 30
@@ -43,6 +43,8 class SimulatorReader(JRODataReader, ProcessingUnit):
43 prof_gen = None
43 prof_gen = None
44 Fdoppler = 100
44 Fdoppler = 100
45 Hdoppler = 36
45 Hdoppler = 36
46 Adoppler = 300
47 frequency = 9345
46 def __init__(self):
48 def __init__(self):
47 """
49 """
48 Inicializador de la clases SimulatorReader para
50 Inicializador de la clases SimulatorReader para
@@ -89,7 +91,8 class SimulatorReader(JRODataReader, ProcessingUnit):
89 """Set the next file to be readed open it and parse de file header"""
91 """Set the next file to be readed open it and parse de file header"""
90
92
91 if (self.nReadBlocks >= self.processingHeaderObj.dataBlocksPerFile):
93 if (self.nReadBlocks >= self.processingHeaderObj.dataBlocksPerFile):
92 print('------------------- [Opening file] ------------------------------')
94 self.nReadFiles=self.nReadFiles+1
95 print('------------------- [Opening file] ------------------------------',self.nReadFiles)
93 self.nReadBlocks = 0
96 self.nReadBlocks = 0
94
97
95 def __setNewBlock(self):
98 def __setNewBlock(self):
@@ -126,6 +129,8 class SimulatorReader(JRODataReader, ProcessingUnit):
126 # asumo q la data no esta sin flip
129 # asumo q la data no esta sin flip
127 self.dataOut.flagDeflipData = self.processingHeaderObj.flag_deflip
130 self.dataOut.flagDeflipData = self.processingHeaderObj.flag_deflip
128 self.dataOut.flagShiftFFT = self.processingHeaderObj.shif_fft
131 self.dataOut.flagShiftFFT = self.processingHeaderObj.shif_fft
132 #
133 self.dataOut.frequency = self.frequency
129
134
130 def getBasicHeader(self):
135 def getBasicHeader(self):
131
136
@@ -265,14 +270,18 class SimulatorReader(JRODataReader, ProcessingUnit):
265 self.systemHeaderObj.adcResolution = adcResolution
270 self.systemHeaderObj.adcResolution = adcResolution
266 self.systemHeaderObj.pciDioBusWidth = pciDioBusWidth
271 self.systemHeaderObj.pciDioBusWidth = pciDioBusWidth
267
272
268 def setup(self,incIntFactor= 1, nFFTPoints = 0, FixPP_IncInt=1,FixRCP_IPP=1000,
273 def setup(self,frequency=49.92e6,incIntFactor= 1, nFFTPoints = 0, FixPP_IncInt=1,FixRCP_IPP=1000,
269 FixPP_CohInt= 1,Tau_0= 250,AcqH0_0 = 70 ,AcqDH_0=1.25, Bauds= 32,
274 FixPP_CohInt= 1,Tau_0= 250,AcqH0_0 = 70 ,AcqDH_0=1.25, Bauds= 32,
270 FixRCP_TXA = 40, FixRCP_TXB = 50, fAngle = 2.0*math.pi*(1/16),DC_level= 500,
275 FixRCP_TXA = 40, FixRCP_TXB = 50, fAngle = 2.0*math.pi*(1/16),DC_level= 50,
271 stdev= 8,Num_Codes = 1 , Dyn_snCode = None, samples=200,channels=1,Fdoppler=20,Hdoppler=36,
276 stdev= 8,Num_Codes = 1 , Dyn_snCode = None, samples=200,
277 channels=2,Fdoppler=20,Hdoppler=36,Adoppler=500,
272 **kwargs):
278 **kwargs):
273
279
274 self.set_kwargs(**kwargs)
280 self.set_kwargs(**kwargs)
275 self.nReadBlocks = 0
281 self.nReadBlocks = 0
282 self.nReadFiles = 1
283 print('------------------- [Opening file: ] ------------------------------',self.nReadFiles)
284
276 tmp = time.time()
285 tmp = time.time()
277 tmp_utc = int(tmp)
286 tmp_utc = int(tmp)
278 tmp_milisecond = int((tmp-tmp_utc)*1000)
287 tmp_milisecond = int((tmp-tmp_utc)*1000)
@@ -301,6 +310,8 class SimulatorReader(JRODataReader, ProcessingUnit):
301
310
302 self.set_SH(nSamples=samples, nProfiles=300, nChannels=channels)
311 self.set_SH(nSamples=samples, nProfiles=300, nChannels=channels)
303
312
313
314 self.frequency = frequency
304 self.incIntFactor = incIntFactor
315 self.incIntFactor = incIntFactor
305 self.nFFTPoints = nFFTPoints
316 self.nFFTPoints = nFFTPoints
306 self.FixPP_IncInt = FixPP_IncInt
317 self.FixPP_IncInt = FixPP_IncInt
@@ -326,6 +337,7 class SimulatorReader(JRODataReader, ProcessingUnit):
326 self.Baudwidth = None
337 self.Baudwidth = None
327 self.Fdoppler = Fdoppler
338 self.Fdoppler = Fdoppler
328 self.Hdoppler = Hdoppler
339 self.Hdoppler = Hdoppler
340 self.Adoppler = Adoppler
329
341
330 print("IPP ", self.FixRCP_IPP)
342 print("IPP ", self.FixRCP_IPP)
331 print("Tau_0 ",self.Tau_0)
343 print("Tau_0 ",self.Tau_0)
@@ -337,6 +349,7 class SimulatorReader(JRODataReader, ProcessingUnit):
337 print("Dyn_snCode",Dyn_snCode)
349 print("Dyn_snCode",Dyn_snCode)
338 print("Fdoppler", Fdoppler)
350 print("Fdoppler", Fdoppler)
339 print("Hdoppler",Hdoppler)
351 print("Hdoppler",Hdoppler)
352 print("Vdopplermax",Fdoppler*(3.0e8/self.frequency)/2.0)
340
353
341 self.init_acquisition()
354 self.init_acquisition()
342 self.pulses,self.pulse_size=self.init_pulse(Num_Codes=self.Num_Codes,Bauds=self.Bauds,BaudWidth=self.BaudWidth,Dyn_snCode=Dyn_snCode)
355 self.pulses,self.pulse_size=self.init_pulse(Num_Codes=self.Num_Codes,Bauds=self.Bauds,BaudWidth=self.BaudWidth,Dyn_snCode=Dyn_snCode)
@@ -423,7 +436,8 class SimulatorReader(JRODataReader, ProcessingUnit):
423 def jro_GenerateBlockOfData(self,Samples=Samples,DC_level= DC_level,stdev=stdev,
436 def jro_GenerateBlockOfData(self,Samples=Samples,DC_level= DC_level,stdev=stdev,
424 Reference= Reference,pulses= pulses,
437 Reference= Reference,pulses= pulses,
425 Num_Codes= Num_Codes,pulse_size=pulse_size,
438 Num_Codes= Num_Codes,pulse_size=pulse_size,
426 prof_gen= prof_gen,H0 = H0,DH0=DH0,Fdoppler= Fdoppler,Hdoppler=Hdoppler):
439 prof_gen= prof_gen,H0 = H0,DH0=DH0,
440 Adoppler=Adoppler,Fdoppler= Fdoppler,Hdoppler=Hdoppler):
427 Samples = Samples
441 Samples = Samples
428 DC_level = DC_level
442 DC_level = DC_level
429 stdev = stdev
443 stdev = stdev
@@ -438,6 +452,7 class SimulatorReader(JRODataReader, ProcessingUnit):
438 ippSec = self.radarControllerHeaderObj.ippSeconds
452 ippSec = self.radarControllerHeaderObj.ippSeconds
439 Fdoppler = self.Fdoppler
453 Fdoppler = self.Fdoppler
440 Hdoppler = self.Hdoppler
454 Hdoppler = self.Hdoppler
455 Adoppler = self.Adoppler
441
456
442 self.datablock = numpy.zeros([channels,prof_gen,Samples],dtype= numpy.complex64)
457 self.datablock = numpy.zeros([channels,prof_gen,Samples],dtype= numpy.complex64)
443 for i in range(channels):
458 for i in range(channels):
@@ -455,7 +470,7 class SimulatorReader(JRODataReader, ProcessingUnit):
455 #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· PULSES+NOISEΒ·Β·Β·Β·Β·Β·Β·Β·Β·Β·
470 #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· PULSES+NOISEΒ·Β·Β·Β·Β·Β·Β·Β·Β·Β·
456 InBuffer = numpy.zeros(Samples,dtype=complex)
471 InBuffer = numpy.zeros(Samples,dtype=complex)
457 InBuffer[m_nR:m_nR+ps] = Pulso
472 InBuffer[m_nR:m_nR+ps] = Pulso
458 InBuffer = Noise+ InBuffer
473 InBuffer = InBuffer+Noise
459 #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· ANGLE Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·
474 #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· ANGLE Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·
460 InBuffer.real[m_nR:m_nR+ps] = InBuffer.real[m_nR:m_nR+ps]*(math.cos( self.fAngle)*5)
475 InBuffer.real[m_nR:m_nR+ps] = InBuffer.real[m_nR:m_nR+ps]*(math.cos( self.fAngle)*5)
461 InBuffer.imag[m_nR:m_nR+ps] = InBuffer.imag[m_nR:m_nR+ps]*(math.sin( self.fAngle)*5)
476 InBuffer.imag[m_nR:m_nR+ps] = InBuffer.imag[m_nR:m_nR+ps]*(math.sin( self.fAngle)*5)
@@ -465,12 +480,13 class SimulatorReader(JRODataReader, ProcessingUnit):
465 #wave_fft(x=InBuffer,plot_show=True)
480 #wave_fft(x=InBuffer,plot_show=True)
466 #time.sleep(1)
481 #time.sleep(1)
467 #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·DOPPLER SIGNAL...............................................
482 #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·DOPPLER SIGNAL...............................................
468 time_vec = numpy.linspace(0,(prof_gen-1)*ippSec,int(prof_gen))+self.nReadBlocks*ippSec*prof_gen
483 time_vec = numpy.linspace(0,(prof_gen-1)*ippSec,int(prof_gen))+self.nReadBlocks*ippSec*prof_gen+(self.nReadFiles-1)*ippSec*prof_gen
469 fd = Fdoppler #+(600.0/120)*self.nReadBlocks
484 fd = Fdoppler #+(600.0/120)*self.nReadBlocks
470 d_signal = 650*numpy.array(numpy.exp(1.0j*2.0*math.pi*fd*time_vec),dtype=numpy.complex64)
485 d_signal = Adoppler*numpy.array(numpy.exp(1.0j*2.0*math.pi*fd*time_vec),dtype=numpy.complex64)
471 #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· DATABLOCK + DOPPLERΒ·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·...........................
486 #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· DATABLOCK + DOPPLERΒ·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·...........................
472 HD=int(Hdoppler/self.AcqDH_0)
487 HD=int(Hdoppler/self.AcqDH_0)
473 self.datablock[0,:,HD]=self.datablock[0,:,HD]+ d_signal # RESULT
488 for i in range(12):
489 self.datablock[:,:,HD+i]=self.datablock[:,:,HD+i]+ d_signal # RESULT
474 '''
490 '''
475 a= numpy.zeros(10)
491 a= numpy.zeros(10)
476 for i in range(10):
492 for i in range(10):
@@ -98,7 +98,7 class SpectraProc(ProcessingUnit):
98 #print("spc :",spc.shape)
98 #print("spc :",spc.shape)
99 data_wr = None
99 data_wr = None
100 if self.dataOut.flagWR:
100 if self.dataOut.flagWR:
101 data_wr = fft_volt
101 data_wr = self.buffer
102 blocksize = fft_volt.size
102 blocksize = fft_volt.size
103
103
104 cspc = None
104 cspc = None
@@ -1,5 +1,6
1 import sys
1 import sys
2 import numpy
2 import time
3 import numpy,math
3 from scipy import interpolate
4 from scipy import interpolate
4 from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation, MPDecorator
5 from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation, MPDecorator
5 from schainpy.model.data.jrodata import Voltage
6 from schainpy.model.data.jrodata import Voltage
@@ -384,16 +385,16 class CohInt(Operation):
384 """
385 """
385
386
386 if not self.__withOverlapping:
387 if not self.__withOverlapping:
387 print("inside over")
388 #print("inside over")
388 self.__buffer += data.copy()
389 self.__buffer += data.copy()
389 self.__profIndex += 1
390 self.__profIndex += 1
390 return
391 return
391
392
392 #Overlapping data
393 #Overlapping data
393 nChannels, nHeis = data.shape
394 nChannels, nHeis = data.shape
394 print("show me the light",data.shape)
395 #print("show me the light",data.shape)
395 data = numpy.reshape(data, (1, nChannels, nHeis))
396 data = numpy.reshape(data, (1, nChannels, nHeis))
396 print(data.shape)
397 #print(data.shape)
397 #If the buffer is empty then it takes the data value
398 #If the buffer is empty then it takes the data value
398 if self.__buffer is None:
399 if self.__buffer is None:
399 self.__buffer = data
400 self.__buffer = data
@@ -424,7 +425,7 class CohInt(Operation):
424 """
425 """
425
426
426 if not self.__withOverlapping:
427 if not self.__withOverlapping:
427 #print("ahora que fue")
428 print("ahora que fue")
428 data = self.__buffer
429 data = self.__buffer
429 n = self.__profIndex
430 n = self.__profIndex
430
431
@@ -1233,8 +1234,8 class CreateBlockVoltage(Operation):
1233 #print("new numberSamples",numberSamples)
1234 #print("new numberSamples",numberSamples)
1234
1235
1235 self.bufferShape = shape[0], numberProfile, numberSamples # nchannels,nprofiles,nsamples
1236 self.bufferShape = shape[0], numberProfile, numberSamples # nchannels,nprofiles,nsamples
1236 self.buffer = numpy.zeros((self.bufferShape))
1237 self.buffer = numpy.zeros([shape[0], numberProfile, numberSamples])
1237 self.bufferVel = numpy.zeros((self.bufferShape))
1238 self.bufferVel = numpy.zeros([shape[0], numberProfile, numberSamples])
1238
1239
1239 def run(self, dataOut, m=None):
1240 def run(self, dataOut, m=None):
1240 #print("RUN")
1241 #print("RUN")
@@ -1248,6 +1249,7 class CreateBlockVoltage(Operation):
1248 if self.__Index < m:
1249 if self.__Index < m:
1249 #print("PROFINDEX BLOCK CBV",self.__Index)
1250 #print("PROFINDEX BLOCK CBV",self.__Index)
1250 self.buffer[:,self.__Index,:] = dataOut.data
1251 self.buffer[:,self.__Index,:] = dataOut.data
1252 #corregir porque debe tener un perfil menos ojo
1251 self.bufferVel[:,self.__Index,:] = dataOut.data_velocity
1253 self.bufferVel[:,self.__Index,:] = dataOut.data_velocity
1252 self.__Index += 1
1254 self.__Index += 1
1253 dataOut.flagNoData = True
1255 dataOut.flagNoData = True
@@ -1302,11 +1304,14 class PulsePairVoltage(Operation):
1302 n = None
1304 n = None
1303 __nch = 0
1305 __nch = 0
1304 __nHeis = 0
1306 __nHeis = 0
1307 removeDC = False
1308 ipp = None
1309 lambda_ = 0
1305
1310
1306 def __init__(self,**kwargs):
1311 def __init__(self,**kwargs):
1307 Operation.__init__(self,**kwargs)
1312 Operation.__init__(self,**kwargs)
1308
1313
1309 def setup(self, dataOut, n = None ):
1314 def setup(self, dataOut, n = None, removeDC=False):
1310 '''
1315 '''
1311 n= Numero de PRF's de entrada
1316 n= Numero de PRF's de entrada
1312 '''
1317 '''
@@ -1320,6 +1325,10 class PulsePairVoltage(Operation):
1320
1325
1321 self.__nch = dataOut.nChannels
1326 self.__nch = dataOut.nChannels
1322 self.__nHeis = dataOut.nHeights
1327 self.__nHeis = dataOut.nHeights
1328 self.removeDC = removeDC
1329 self.lambda_ = 3.0e8/(9345.0e6)
1330 self.ippSec = dataOut.ippSeconds
1331 print("IPPseconds",dataOut.ippSeconds)
1323
1332
1324 print("ELVALOR DE n es:", n)
1333 print("ELVALOR DE n es:", n)
1325 if n == None:
1334 if n == None:
@@ -1331,115 +1340,55 class PulsePairVoltage(Operation):
1331
1340
1332 self.n = n
1341 self.n = n
1333 self.__nProf = n
1342 self.__nProf = n
1334 '''
1335 if overlapping:
1336 self.__withOverlapping = True
1337 self.__buffer = None
1338
1343
1339 else:
1344 self.__buffer = numpy.zeros((dataOut.nChannels,
1340 #print ("estoy sin __withO")
1345 n,
1341 self.__withOverlapping = False
1346 dataOut.nHeights),
1342 self.__buffer = 0
1347 dtype='complex')
1343 self.__buffer2 = []
1348
1344 self.__buffer3 = 0
1349
1345 '''
1346
1350
1347 def putData(self,data):
1351 def putData(self,data):
1348 '''
1352 '''
1349 Add a profile to he __buffer and increase in one the __profiel Index
1353 Add a profile to he __buffer and increase in one the __profiel Index
1350 '''
1354 '''
1351 #print("self.__profIndex :",self.__profIndex)
1355 self.__buffer[:,self.__profIndex,:]= data
1352 self.__buffer += data*numpy.conjugate(data)
1353 self.__buffer2.append(numpy.conjugate(data))
1354 if self.__profIndex > 0:
1355 self.__buffer3 += self.__buffer2[self.__profIndex-1]*data
1356 self.__profIndex += 1
1356 self.__profIndex += 1
1357 return
1357 return
1358 '''
1359 if not self.__withOverlapping:
1360 #print("Putdata inside over")
1361 self.__buffer += data* numpy.conjugate(data)
1362 self.__buffer2.append(numpy.conjugate(data))
1363
1364 if self.__profIndex >0:
1365 self.__buffer3 += self.__buffer2[self.__profIndex-1]*data
1366 self.__profIndex += 1
1367 return
1368
1369 if self.__buffer is None:
1370 #print("aqui bro")
1371 self.__buffer = data* numpy.conjugate(data)
1372 self.__buffer2.append(numpy.conjugate(data))
1373 self.__profIndex += 1
1374
1375 return
1376
1377 if self.__profIndex < self.n:
1378 self.__buffer = numpy.vstack(self.__buffer,data* numpy.conjugate(data))
1379 self.__buffer2.append(numpy.conjugate(data))
1380
1381 if self.__profIndex == 1:
1382 self.__buffer3 = self.__buffer2[self.__profIndex -1] * data
1383 else:
1384 self.__buffer3 = numpy.vstack(self.__buffer3, self.__buffer2[self.profIndex-1]*data)
1385
1386 self.__profIndex += 1
1387 return
1388 '''
1389
1358
1390 def pushData(self):
1359 def pushData(self):
1391 '''
1360 '''
1392 Return the PULSEPAIR and the profiles used in the operation
1361 Return the PULSEPAIR and the profiles used in the operation
1393 Affected : self.__profileIndex
1362 Affected : self.__profileIndex
1394 '''
1363 '''
1395 #print("************************************************")
1364
1396 #print("push data int vel n")
1365 if self.removeDC==True:
1397 data_intensity = self.__buffer/self.n
1366 mean = numpy.mean(self.__buffer,1)
1398 data_velocity = self.__buffer3/(self.n-1)
1367 tmp = mean.reshape(self.__nch,1,self.__nHeis)
1368 dc= numpy.tile(tmp,[1,self.__nProf,1])
1369 self.__buffer = self.__buffer - dc
1370
1371 data_intensity = numpy.sum(self.__buffer*numpy.conj(self.__buffer),1)/self.n
1372 pair1 = self.__buffer[:,1:,:]*numpy.conjugate(self.__buffer[:,:-1,:])
1373 angle=numpy.angle(numpy.sum(pair1,1))*180/(math.pi)
1374 #print(angle.shape)#print("__ANGLE__") #print("angle",angle[:,:10])
1375 data_velocity = (self.lambda_/(4*math.pi*self.ippSec))*numpy.angle(numpy.sum(pair1,1))
1399 n = self.__profIndex
1376 n = self.__profIndex
1400
1377
1401 self.__buffer = 0
1378 self.__buffer = numpy.zeros((self.__nch, self.__nProf,self.__nHeis), dtype='complex')
1402 self.__buffer2 = []
1403 self.__buffer3 = 0
1404 self.__profIndex = 0
1379 self.__profIndex = 0
1405
1380 return data_intensity,data_velocity,n
1406 return data_intensity, data_velocity,n
1407 '''
1408 if not self.__withOverlapping:
1409 #print("ahora que fue")
1410 data_intensity = self.__buffer/self.n
1411 data_velocity = self.__buffer3/(self.n-1)
1412 n = self.__profIndex
1413
1414 self.__buffer = 0
1415 self.__buffer2 = []
1416 self.__buffer3 = 0
1417 self.__profIndex = 0
1418 return data_intensity, data_velocity,n
1419
1420 data_intensity = numpy.sum(self.__buffer,axis = 0)
1421 data_velocity = numpy.sum(self.__buffer3,axis = 0)
1422 n = self.__profIndex
1423 #self.__buffer = 0
1424 #self.__buffer2 = []
1425 #self.__buffer3 = 0
1426 #self.__profIndex = 0
1427 return data_intensity, data_velocity,n
1428 '''
1429
1381
1430 def pulsePairbyProfiles(self,data):
1382 def pulsePairbyProfiles(self,data):
1431
1383
1432 self.__dataReady = False
1384 self.__dataReady = False
1433 data_intensity = None
1385 data_intensity = None
1434 data_velocity = None
1386 data_velocity = None
1435 #print("beforeputada")
1436 self.putData(data)
1387 self.putData(data)
1437 #print("ProfileIndex:",self.__profIndex)
1438 if self.__profIndex == self.n:
1388 if self.__profIndex == self.n:
1439 data_intensity, data_velocity, n = self.pushData()
1389 data_intensity, data_velocity, n = self.pushData()
1440 self.__dataReady = True
1390 self.__dataReady = True
1441 #print("-----------------------------------------------")
1391
1442 #print("data_intensity",data_intensity.shape,"data_velocity",data_velocity.shape)
1443 return data_intensity, data_velocity
1392 return data_intensity, data_velocity
1444
1393
1445 def pulsePairOp(self, data, datatime= None):
1394 def pulsePairOp(self, data, datatime= None):
@@ -1456,18 +1405,13 class PulsePairVoltage(Operation):
1456 avgdatatime = self.__initime
1405 avgdatatime = self.__initime
1457 deltatime = datatime - self.__lastdatatime
1406 deltatime = datatime - self.__lastdatatime
1458 self.__initime = datatime
1407 self.__initime = datatime
1459 '''
1408
1460 if not self.__withOverlapping:
1461 self.__initime = datatime
1462 else:
1463 self.__initime += deltatime
1464 '''
1465 return data_intensity, data_velocity, avgdatatime
1409 return data_intensity, data_velocity, avgdatatime
1466
1410
1467 def run(self, dataOut,n = None, overlapping= False,**kwargs):
1411 def run(self, dataOut,n = None,removeDC= False, overlapping= False,**kwargs):
1468
1412
1469 if not self.isConfig:
1413 if not self.isConfig:
1470 self.setup(dataOut = dataOut, n = n , **kwargs)
1414 self.setup(dataOut = dataOut, n = n , removeDC=removeDC , **kwargs)
1471 self.isConfig = True
1415 self.isConfig = True
1472 #print("*******************")
1416 #print("*******************")
1473 #print("print Shape input data:",dataOut.data.shape)
1417 #print("print Shape input data:",dataOut.data.shape)
@@ -1485,139 +1429,3 class PulsePairVoltage(Operation):
1485 dataOut.utctime = avgdatatime
1429 dataOut.utctime = avgdatatime
1486 dataOut.flagNoData = False
1430 dataOut.flagNoData = False
1487 return dataOut
1431 return dataOut
1488
1489 # import collections
1490 # from scipy.stats import mode
1491 #
1492 # class Synchronize(Operation):
1493 #
1494 # isConfig = False
1495 # __profIndex = 0
1496 #
1497 # def __init__(self, **kwargs):
1498 #
1499 # Operation.__init__(self, **kwargs)
1500 # # self.isConfig = False
1501 # self.__powBuffer = None
1502 # self.__startIndex = 0
1503 # self.__pulseFound = False
1504 #
1505 # def __findTxPulse(self, dataOut, channel=0, pulse_with = None):
1506 #
1507 # #Read data
1508 #
1509 # powerdB = dataOut.getPower(channel = channel)
1510 # noisedB = dataOut.getNoise(channel = channel)[0]
1511 #
1512 # self.__powBuffer.extend(powerdB.flatten())
1513 #
1514 # dataArray = numpy.array(self.__powBuffer)
1515 #
1516 # filteredPower = numpy.correlate(dataArray, dataArray[0:self.__nSamples], "same")
1517 #
1518 # maxValue = numpy.nanmax(filteredPower)
1519 #
1520 # if maxValue < noisedB + 10:
1521 # #No se encuentra ningun pulso de transmision
1522 # return None
1523 #
1524 # maxValuesIndex = numpy.where(filteredPower > maxValue - 0.1*abs(maxValue))[0]
1525 #
1526 # if len(maxValuesIndex) < 2:
1527 # #Solo se encontro un solo pulso de transmision de un baudio, esperando por el siguiente TX
1528 # return None
1529 #
1530 # phasedMaxValuesIndex = maxValuesIndex - self.__nSamples
1531 #
1532 # #Seleccionar solo valores con un espaciamiento de nSamples
1533 # pulseIndex = numpy.intersect1d(maxValuesIndex, phasedMaxValuesIndex)
1534 #
1535 # if len(pulseIndex) < 2:
1536 # #Solo se encontro un pulso de transmision con ancho mayor a 1
1537 # return None
1538 #
1539 # spacing = pulseIndex[1:] - pulseIndex[:-1]
1540 #
1541 # #remover senales que se distancien menos de 10 unidades o muestras
1542 # #(No deberian existir IPP menor a 10 unidades)
1543 #
1544 # realIndex = numpy.where(spacing > 10 )[0]
1545 #
1546 # if len(realIndex) < 2:
1547 # #Solo se encontro un pulso de transmision con ancho mayor a 1
1548 # return None
1549 #
1550 # #Eliminar pulsos anchos (deja solo la diferencia entre IPPs)
1551 # realPulseIndex = pulseIndex[realIndex]
1552 #
1553 # period = mode(realPulseIndex[1:] - realPulseIndex[:-1])[0][0]
1554 #
1555 # print "IPP = %d samples" %period
1556 #
1557 # self.__newNSamples = dataOut.nHeights #int(period)
1558 # self.__startIndex = int(realPulseIndex[0])
1559 #
1560 # return 1
1561 #
1562 #
1563 # def setup(self, nSamples, nChannels, buffer_size = 4):
1564 #
1565 # self.__powBuffer = collections.deque(numpy.zeros( buffer_size*nSamples,dtype=numpy.float),
1566 # maxlen = buffer_size*nSamples)
1567 #
1568 # bufferList = []
1569 #
1570 # for i in range(nChannels):
1571 # bufferByChannel = collections.deque(numpy.zeros( buffer_size*nSamples, dtype=numpy.complex) + numpy.NAN,
1572 # maxlen = buffer_size*nSamples)
1573 #
1574 # bufferList.append(bufferByChannel)
1575 #
1576 # self.__nSamples = nSamples
1577 # self.__nChannels = nChannels
1578 # self.__bufferList = bufferList
1579 #
1580 # def run(self, dataOut, channel = 0):
1581 #
1582 # if not self.isConfig:
1583 # nSamples = dataOut.nHeights
1584 # nChannels = dataOut.nChannels
1585 # self.setup(nSamples, nChannels)
1586 # self.isConfig = True
1587 #
1588 # #Append new data to internal buffer
1589 # for thisChannel in range(self.__nChannels):
1590 # bufferByChannel = self.__bufferList[thisChannel]
1591 # bufferByChannel.extend(dataOut.data[thisChannel])
1592 #
1593 # if self.__pulseFound:
1594 # self.__startIndex -= self.__nSamples
1595 #
1596 # #Finding Tx Pulse
1597 # if not self.__pulseFound:
1598 # indexFound = self.__findTxPulse(dataOut, channel)
1599 #
1600 # if indexFound == None:
1601 # dataOut.flagNoData = True
1602 # return
1603 #
1604 # self.__arrayBuffer = numpy.zeros((self.__nChannels, self.__newNSamples), dtype = numpy.complex)
1605 # self.__pulseFound = True
1606 # self.__startIndex = indexFound
1607 #
1608 # #If pulse was found ...
1609 # for thisChannel in range(self.__nChannels):
1610 # bufferByChannel = self.__bufferList[thisChannel]
1611 # #print self.__startIndex
1612 # x = numpy.array(bufferByChannel)
1613 # self.__arrayBuffer[thisChannel] = x[self.__startIndex:self.__startIndex+self.__newNSamples]
1614 #
1615 # deltaHeight = dataOut.heightList[1] - dataOut.heightList[0]
1616 # dataOut.heightList = numpy.arange(self.__newNSamples)*deltaHeight
1617 # # dataOut.ippSeconds = (self.__newNSamples / deltaHeight)/1e6
1618 #
1619 # dataOut.data = self.__arrayBuffer
1620 #
1621 # self.__startIndex += self.__newNSamples
1622 #
1623 # return
General Comments 0
You need to be logged in to leave comments. Login now