##// END OF EJS Templates
adicion de escritura de datos, calculo de ancho espectral y graficos pulsepair
avaldez -
r1303:ddb038395553
parent child
Show More
@@ -362,6 +362,7 class Voltage(JROData):
362 362 data = None
363 363 data_intensity = None
364 364 data_velocity = None
365 data_specwidth = None
365 366 def __init__(self):
366 367 '''
367 368 Constructor
@@ -1268,6 +1269,10 class PlotterData(object):
1268 1269 buffer = dataOut.data_velocity
1269 1270 self.flagDataAsBlock = dataOut.flagDataAsBlock
1270 1271 self.nProfiles = dataOut.nProfiles
1272 if plot == 'pp_specwidth':
1273 buffer = dataOut.data_specwidth
1274 self.flagDataAsBlock = dataOut.flagDataAsBlock
1275 self.nProfiles = dataOut.nProfiles
1271 1276
1272 1277 if plot == 'spc':
1273 1278 self.data['spc'] = buffer
@@ -32,7 +32,7 class SimulatorReader(JRODataReader, ProcessingUnit):
32 32 #Dyn_snCode = numpy.array([Num_Codes,Bauds])
33 33 Dyn_snCode = None
34 34 Samples = 200
35 channels = 5
35 channels = 2
36 36 pulses = None
37 37 Reference = None
38 38 pulse_size = None
@@ -91,12 +91,14 class SimulatorReader(JRODataReader, ProcessingUnit):
91 91
92 92 if (self.nReadBlocks >= self.processingHeaderObj.dataBlocksPerFile):
93 93 self.nReadFiles=self.nReadFiles+1
94 if self.nReadFiles ==self.nTotalReadFiles:
94 if self.nReadFiles > self.nTotalReadFiles:
95 95 self.flagNoMoreFiles=1
96 96 raise schainpy.admin.SchainWarning('No more files to read')
97 97
98 98 print('------------------- [Opening file] ------------------------------',self.nReadFiles)
99 99 self.nReadBlocks = 0
100 #if self.nReadBlocks==0:
101 # self.readFirstHeader()
100 102
101 103 def __setNewBlock(self):
102 104 self.setNextFile()
@@ -121,6 +123,7 class SimulatorReader(JRODataReader, ProcessingUnit):
121 123 self.dataOut.processingHeaderObj = self.processingHeaderObj.copy()
122 124 self.dataOut.systemHeaderObj = self.systemHeaderObj.copy()
123 125 self.dataOut.radarControllerHeaderObj = self.radarControllerHeaderObj.copy()
126 self.dataOut.dtype = self.dtype
124 127
125 128 self.dataOut.nProfiles = self.processingHeaderObj.profilesPerBlock
126 129 self.dataOut.heightList = numpy.arange(self.processingHeaderObj.nHeights) * self.processingHeaderObj.deltaHeight + self.processingHeaderObj.firstHeight
@@ -144,20 +147,42 class SimulatorReader(JRODataReader, ProcessingUnit):
144 147 self.dataOut.useLocalTime = self.basicHeaderObj.useLocalTime
145 148 self.dataOut.ippSeconds = self.radarControllerHeaderObj.ippSeconds / self.nTxs
146 149
150 def readFirstHeader(self):
151
152 datatype = int(numpy.log2((self.processingHeaderObj.processFlags &
153 PROCFLAG.DATATYPE_MASK)) - numpy.log2(PROCFLAG.DATATYPE_CHAR))
154 if datatype == 0:
155 datatype_str = numpy.dtype([('real', '<i1'), ('imag', '<i1')])
156 elif datatype == 1:
157 datatype_str = numpy.dtype([('real', '<i2'), ('imag', '<i2')])
158 elif datatype == 2:
159 datatype_str = numpy.dtype([('real', '<i4'), ('imag', '<i4')])
160 elif datatype == 3:
161 datatype_str = numpy.dtype([('real', '<i8'), ('imag', '<i8')])
162 elif datatype == 4:
163 datatype_str = numpy.dtype([('real', '<f4'), ('imag', '<f4')])
164 elif datatype == 5:
165 datatype_str = numpy.dtype([('real', '<f8'), ('imag', '<f8')])
166 else:
167 raise ValueError('Data type was not defined')
168
169 self.dtype = datatype_str
170
171
147 172 def set_RCH(self, expType=2, nTx=1,ipp=None, txA=0, txB=0,
148 173 nWindows=None, nHeights=None, firstHeight=None, deltaHeight=None,
149 174 numTaus=0, line6Function=0, line5Function=0, fClock=None,
150 175 prePulseBefore=0, prePulseAfter=0,
151 176 codeType=0, nCode=0, nBaud=0, code=None,
152 flip1=0, flip2=0):
177 flip1=0, flip2=0,Taus=0):
153 178 self.radarControllerHeaderObj.expType = expType
154 179 self.radarControllerHeaderObj.nTx = nTx
155 180 self.radarControllerHeaderObj.ipp = float(ipp)
156 181 self.radarControllerHeaderObj.txA = float(txA)
157 182 self.radarControllerHeaderObj.txB = float(txB)
158 self.radarControllerHeaderObj.rangeIPP = ipp
159 self.radarControllerHeaderObj.rangeTxA = txA
160 self.radarControllerHeaderObj.rangeTxB = txB
183 self.radarControllerHeaderObj.rangeIpp = b'A\n'#ipp
184 self.radarControllerHeaderObj.rangeTxA = b''
185 self.radarControllerHeaderObj.rangeTxB = b''
161 186
162 187 self.radarControllerHeaderObj.nHeights = int(nHeights)
163 188 self.radarControllerHeaderObj.firstHeight = numpy.array([firstHeight])
@@ -170,20 +195,27 class SimulatorReader(JRODataReader, ProcessingUnit):
170 195 self.radarControllerHeaderObj.codeType = codeType
171 196 self.radarControllerHeaderObj.line6Function = line6Function
172 197 self.radarControllerHeaderObj.line5Function = line5Function
173 self.radarControllerHeaderObj.fclock = fClock
198 #self.radarControllerHeaderObj.fClock = fClock
174 199 self.radarControllerHeaderObj.prePulseBefore= prePulseBefore
175 200 self.radarControllerHeaderObj.prePulseAfter = prePulseAfter
176 201
177 self.radarControllerHeaderObj.nCode = nCode
178 self.radarControllerHeaderObj.nBaud = nBaud
179 self.radarControllerHeaderObj.code = code
180 202 self.radarControllerHeaderObj.flip1 = flip1
181 203 self.radarControllerHeaderObj.flip2 = flip2
182 204
183 self.radarControllerHeaderObj.code_size = int(numpy.ceil(nBaud / 32.)) * nCode * 4
205 self.radarControllerHeaderObj.code_size = 0
206 if self.radarControllerHeaderObj.codeType != 0:
207 self.radarControllerHeaderObj.nCode = nCode
208 self.radarControllerHeaderObj.nBaud = nBaud
209 self.radarControllerHeaderObj.code = code
210 self.radarControllerHeaderObj.code_size = int(numpy.ceil(nBaud / 32.)) * nCode * 4
184 211
185 212 if fClock is None and deltaHeight is not None:
186 213 self.fClock = 0.15 / (deltaHeight * 1e-6)
214 self.radarControllerHeaderObj.fClock = self.fClock
215 if numTaus==0:
216 self.radarControllerHeaderObj.Taus = numpy.array(0,'<f4')
217 else:
218 self.radarControllerHeaderObj.Taus = numpy.array(Taus,'<f4')
187 219
188 220 def set_PH(self, dtype=0, blockSize=0, profilesPerBlock=0,
189 221 dataBlocksPerFile=0, nWindows=0, processFlags=0, nCohInt=0,
@@ -192,23 +224,27 class SimulatorReader(JRODataReader, ProcessingUnit):
192 224 code=0, nBaud=None, shif_fft=False, flag_dc=False,
193 225 flag_cspc=False, flag_decode=False, flag_deflip=False):
194 226
227 self.processingHeaderObj.dtype = dtype
195 228 self.processingHeaderObj.profilesPerBlock = profilesPerBlock
196 229 self.processingHeaderObj.dataBlocksPerFile = dataBlocksPerFile
197 230 self.processingHeaderObj.nWindows = nWindows
231 self.processingHeaderObj.processFlags = processFlags
198 232 self.processingHeaderObj.nCohInt = nCohInt
199 233 self.processingHeaderObj.nIncohInt = nIncohInt
200 234 self.processingHeaderObj.totalSpectra = totalSpectra
235
201 236 self.processingHeaderObj.nHeights = int(nHeights)
202 self.processingHeaderObj.firstHeight = firstHeight
203 self.processingHeaderObj.deltaHeight = deltaHeight
204 self.processingHeaderObj.samplesWin = nHeights
237 self.processingHeaderObj.firstHeight = firstHeight#numpy.array([firstHeight])#firstHeight
238 self.processingHeaderObj.deltaHeight = deltaHeight#numpy.array([deltaHeight])#deltaHeight
239 self.processingHeaderObj.samplesWin = nHeights#numpy.array([nHeights])#nHeights
205 240
206 241 def set_BH(self, utc = 0, miliSecond = 0, timeZone = 0):
207 242 self.basicHeaderObj.utc = utc
208 243 self.basicHeaderObj.miliSecond = miliSecond
209 244 self.basicHeaderObj.timeZone = timeZone
210 245
211 def set_SH(self, nSamples=0, nProfiles=0, nChannels=0, adcResolution=14, pciDioBusWidth=0):
246 def set_SH(self, nSamples=0, nProfiles=0, nChannels=0, adcResolution=14, pciDioBusWidth=32):
247 #self.systemHeaderObj.size = size
212 248 self.systemHeaderObj.nSamples = nSamples
213 249 self.systemHeaderObj.nProfiles = nProfiles
214 250 self.systemHeaderObj.nChannels = nChannels
@@ -325,10 +361,27 class SimulatorReader(JRODataReader, ProcessingUnit):
325 361 time_vec = numpy.linspace(0,(prof_gen-1)*ippSec,int(prof_gen))+self.nReadBlocks*ippSec*prof_gen+(self.nReadFiles-1)*ippSec*prof_gen
326 362 fd = Fdoppler #+(600.0/120)*self.nReadBlocks
327 363 d_signal = Adoppler*numpy.array(numpy.exp(1.0j*2.0*math.pi*fd*time_vec),dtype=numpy.complex64)
328 #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· DATABLOCK + DOPPLERΒ·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·...........................
364 #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·SeΓ±al con ancho espectralΒ·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·
365 #specw_sig = numpy.zeros(int(prof_gen),dtype=complex)
366 #specw_sig.real[200:200+100] = 1*numpy.ones(100)
367 #specw_sig.imag[200:200+100] = 1*numpy.ones(100)
368 # w=2
369 specw_sig = numpy.linspace(-149,150,300)
370 w = 3
371 A = 10
372 specw_sig = specw_sig/w
373 specw_sig = numpy.sinc(specw_sig)
374 specw_sig = A*numpy.array(specw_sig,dtype=numpy.complex64)
375 #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· DATABLOCK + DOPPLERΒ·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·
329 376 HD=int(Hdoppler/self.AcqDH_0)
330 377 for i in range(12):
331 self.datablock[:,:,HD+i]=self.datablock[:,:,HD+i]+ d_signal # RESULT
378 self.datablock[0,:,HD+i]=self.datablock[0,:,HD+i]+ d_signal# RESULT
379
380 HD=int(Hdoppler/self.AcqDH_0)
381 HD=int(HD/2)
382 for i in range(12):
383 self.datablock[0,:,HD+i]=self.datablock[0,:,HD+i]+ specw_sig*d_signal# RESULT
384
332 385 '''
333 386 a= numpy.zeros(10)
334 387 for i in range(10):
@@ -401,16 +454,15 class SimulatorReader(JRODataReader, ProcessingUnit):
401 454
402 455
403 456 self.set_BH(utc= tmp_utc,miliSecond= tmp_milisecond,timeZone=300 )
404
405 457 self.set_RCH( expType=0, nTx=150,ipp=FixRCP_IPP, txA=FixRCP_TXA, txB= FixRCP_TXB,
406 458 nWindows=1 , nHeights=samples, firstHeight=AcqH0_0, deltaHeight=AcqDH_0,
407 459 numTaus=1, line6Function=0, line5Function=0, fClock=None,
408 460 prePulseBefore=0, prePulseAfter=0,
409 codeType=14, nCode=Num_Codes, nBaud=32, code=Dyn_snCode,
410 flip1=0, flip2=0)
461 codeType=0, nCode=Num_Codes, nBaud=32, code=Dyn_snCode,
462 flip1=0, flip2=0,Taus=Tau_0)
411 463
412 464 self.set_PH(dtype=0, blockSize=0, profilesPerBlock=300,
413 dataBlocksPerFile=120, nWindows=1, processFlags=0, nCohInt=1,
465 dataBlocksPerFile=120, nWindows=1, processFlags=numpy.array([1024]), nCohInt=1,
414 466 nIncohInt=1, totalSpectra=0, nHeights=samples, firstHeight=AcqH0_0,
415 467 deltaHeight=AcqDH_0, samplesWin=samples, spectraComb=0, nCode=0,
416 468 code=0, nBaud=None, shif_fft=False, flag_dc=False,
@@ -418,6 +470,7 class SimulatorReader(JRODataReader, ProcessingUnit):
418 470
419 471 self.set_SH(nSamples=samples, nProfiles=300, nChannels=channels)
420 472
473 self.readFirstHeader()
421 474
422 475 self.frequency = frequency
423 476 self.incIntFactor = incIntFactor
@@ -1293,8 +1293,7 class PulsePairVoltage(Operation):
1293 1293 __initime = None
1294 1294 __lastdatatime = None
1295 1295 __buffer = None
1296 __buffer2 = []
1297 __buffer3 = None
1296 noise = None
1298 1297 __dataReady = False
1299 1298 n = None
1300 1299 __nch = 0
@@ -1314,10 +1313,8 class PulsePairVoltage(Operation):
1314 1313 self.__lastdatatime = 0
1315 1314 self.__dataReady = False
1316 1315 self.__buffer = 0
1317 self.__buffer2 = []
1318 self.__buffer3 = 0
1319 1316 self.__profIndex = 0
1320
1317 self.noise = None
1321 1318 self.__nch = dataOut.nChannels
1322 1319 self.__nHeis = dataOut.nHeights
1323 1320 self.removeDC = removeDC
@@ -1341,6 +1338,9 class PulsePairVoltage(Operation):
1341 1338 n,
1342 1339 dataOut.nHeights),
1343 1340 dtype='complex')
1341 self.noise = numpy.zeros([self.__nch,self.__nHeis])
1342 for i in range(self.__nch):
1343 self.noise[i]=dataOut.getNoise(channel=i)
1344 1344
1345 1345 def putData(self,data):
1346 1346 '''
@@ -1362,58 +1362,82 class PulsePairVoltage(Operation):
1362 1362 dc= numpy.tile(tmp,[1,self.__nProf,1])
1363 1363 self.__buffer = self.__buffer - dc
1364 1364
1365 data_intensity = numpy.sum(self.__buffer*numpy.conj(self.__buffer),1)/(self.n*self.nCohInt)#*self.nCohInt)
1366 pair1 = self.__buffer[:,1:,:]*numpy.conjugate(self.__buffer[:,:-1,:])
1367 angle = numpy.angle(numpy.sum(pair1,1))*180/(math.pi)
1368 #print(angle.shape)#print("__ANGLE__") #print("angle",angle[:,:10])
1369 data_velocity = (self.lambda_/(4*math.pi*self.ippSec))*numpy.angle(numpy.sum(pair1,1))#self.ippSec*self.nCohInt
1365 lag_0 = numpy.sum(self.__buffer*numpy.conj(self.__buffer),1)
1366 data_intensity = lag_0/(self.n*self.nCohInt)#*self.nCohInt)
1367
1368 pair1 = self.__buffer[:,:-1,:]*numpy.conjugate(self.__buffer[:,1:,:])
1369 lag_1 = numpy.sum(pair1,1)
1370 #angle = numpy.angle(numpy.sum(pair1,1))*180/(math.pi)
1371 data_velocity = (-1.0*self.lambda_/(4*math.pi*self.ippSec))*numpy.angle(lag_1)#self.ippSec*self.nCohInt
1372
1373 lag_0 = lag_0.real/(self.n)
1374 lag_1 = lag_1/(self.n-1)
1375 R1 = numpy.abs(lag_1)
1376 S = (lag_0-self.noise)
1377 #k = R1/S
1378 #k = 1-k
1379 #k =numpy.absolute(k)
1380 #k =numpy.sqrt(k)
1381 L = S/R1
1382 #print("L",L[0])
1383 L = numpy.where(L<0,1,L)
1384 L = numpy.log(L)
1385 tmp = numpy.sqrt(numpy.absolute(L))
1386 data_specwidth = (self.lambda_/(2*math.sqrt(2)*math.pi*self.ippSec))*tmp*numpy.sign(L)
1387 #data_specwidth = (self.lambda_/(2*math.sqrt(2)*math.pi*self.ippSec))*k
1370 1388 n = self.__profIndex
1371 1389
1372 1390 self.__buffer = numpy.zeros((self.__nch, self.__nProf,self.__nHeis), dtype='complex')
1373 1391 self.__profIndex = 0
1374 return data_intensity,data_velocity,n
1392 return data_intensity,data_velocity,data_specwidth,n
1375 1393
1376 1394 def pulsePairbyProfiles(self,data):
1377 1395
1378 1396 self.__dataReady = False
1379 1397 data_intensity = None
1380 1398 data_velocity = None
1399 data_specwidth = None
1381 1400 self.putData(data)
1382 1401 if self.__profIndex == self.n:
1383 data_intensity, data_velocity, n = self.pushData()
1402 #self.noise = numpy.zeros([self.__nch,self.__nHeis])
1403 #for i in range(self.__nch):
1404 # self.noise[i]=data.getNoise(channel=i)
1405 #print(self.noise.shape)
1406 data_intensity, data_velocity,data_specwidth, n = self.pushData()
1384 1407 self.__dataReady = True
1385 1408
1386 return data_intensity, data_velocity
1409 return data_intensity, data_velocity,data_specwidth
1387 1410
1388 1411 def pulsePairOp(self, data, datatime= None):
1389 1412
1390 1413 if self.__initime == None:
1391 1414 self.__initime = datatime
1392 1415
1393 data_intensity, data_velocity = self.pulsePairbyProfiles(data)
1416 data_intensity, data_velocity,data_specwidth = self.pulsePairbyProfiles(data)
1394 1417 self.__lastdatatime = datatime
1395 1418
1396 1419 if data_intensity is None:
1397 return None, None, None
1420 return None, None,None, None
1398 1421
1399 1422 avgdatatime = self.__initime
1400 1423 deltatime = datatime - self.__lastdatatime
1401 1424 self.__initime = datatime
1402 1425
1403 return data_intensity, data_velocity, avgdatatime
1426 return data_intensity, data_velocity,data_specwidth,avgdatatime
1404 1427
1405 1428 def run(self, dataOut,n = None,removeDC= False, overlapping= False,**kwargs):
1406 1429
1407 1430 if not self.isConfig:
1408 1431 self.setup(dataOut = dataOut, n = n , removeDC=removeDC , **kwargs)
1409 1432 self.isConfig = True
1410 data_intensity, data_velocity, avgdatatime = self.pulsePairOp(dataOut.data, dataOut.utctime)
1433 data_intensity, data_velocity,data_specwidth, avgdatatime = self.pulsePairOp(dataOut.data, dataOut.utctime)
1411 1434 dataOut.flagNoData = True
1412 1435
1413 1436 if self.__dataReady:
1414 1437 dataOut.nCohInt *= self.n
1415 1438 dataOut.data_intensity = data_intensity #valor para intensidad
1416 1439 dataOut.data_velocity = data_velocity #valor para velocidad
1440 dataOut.data_specwidth = data_specwidth
1417 1441 dataOut.PRFbyAngle = self.n #numero de PRF*cada angulo rotado que equivale a un tiempo.
1418 1442 dataOut.utctime = avgdatatime
1419 1443 dataOut.flagNoData = False
General Comments 0
You need to be logged in to leave comments. Login now