##// END OF EJS Templates
Miguel Valdez -
r232:13e5ede6a371
parent child
Show More
@@ -147,9 +147,9 class JROData:
147 147
148 148 code = None
149 149
150 flagDecodeData = True #asumo q la data esta decodificada
150 flagDecodeData = False #asumo q la data no esta decodificada
151 151
152 flagDeflipData = True #asumo q la data esta sin flip
152 flagDeflipData = False #asumo q la data no esta sin flip
153 153
154 154 flagShiftFFT = False
155 155
@@ -290,6 +290,13 class Voltage(JROData):
290 290 self.nCohInt = None
291 291
292 292 self.blocksize = None
293
294 self.flagDecodeData = False #asumo q la data no esta decodificada
295
296 self.flagDeflipData = False #asumo q la data no esta sin flip
297
298 self.flagShiftFFT = False
299
293 300
294 301 def getNoisebyHildebrand(self):
295 302 """
@@ -379,6 +386,12 class Spectra(JROData):
379 386 self.nFFTPoints = None
380 387
381 388 self.wavelength = None
389
390 self.flagDecodeData = False #asumo q la data no esta decodificada
391
392 self.flagDeflipData = False #asumo q la data no esta sin flip
393
394 self.flagShiftFFT = False
382 395
383 396 def getNoisebyHildebrand(self):
384 397 """
@@ -1399,6 +1399,7 class VoltageReader(JRODataReader):
1399 1399 self.dataOut.flagShiftFFT = False
1400 1400
1401 1401 if self.processingHeaderObj.code != None:
1402
1402 1403 self.dataOut.nCode = self.processingHeaderObj.nCode
1403 1404
1404 1405 self.dataOut.nBaud = self.processingHeaderObj.nBaud
@@ -1408,6 +1409,13 class VoltageReader(JRODataReader):
1408 1409 self.dataOut.systemHeaderObj = self.systemHeaderObj.copy()
1409 1410
1410 1411 self.dataOut.radarControllerHeaderObj = self.radarControllerHeaderObj.copy()
1412
1413 self.dataOut.flagDecodeData = False #asumo q la data no esta decodificada
1414
1415 self.dataOut.flagDeflipData = False #asumo q la data no esta sin flip
1416
1417 self.dataOut.flagShiftFFT = False
1418
1411 1419
1412 1420 # self.updateDataHeader()
1413 1421
@@ -2059,13 +2067,18 class SpectraReader(JRODataReader):
2059 2067
2060 2068 self.dataOut.timeInterval = self.ippSeconds * self.processingHeaderObj.nCohInt * self.processingHeaderObj.nIncohInt * self.dataOut.nFFTPoints
2061 2069
2062 self.dataOut.flagShiftFFT = self.processingHeaderObj.shif_fft
2063
2064 2070 # self.profileIndex += 1
2065 2071
2066 2072 self.dataOut.systemHeaderObj = self.systemHeaderObj.copy()
2067 2073
2068 2074 self.dataOut.radarControllerHeaderObj = self.radarControllerHeaderObj.copy()
2075
2076 self.dataOut.flagShiftFFT = self.processingHeaderObj.shif_fft
2077
2078 self.dataOut.flagDecodeData = True #asumo q la data no esta decodificada
2079
2080 self.dataOut.flagDeflipData = True #asumo q la data no esta sin flip
2081
2069 2082
2070 2083 return self.dataOut.data_spc
2071 2084
@@ -369,7 +369,7 class ProcessingHeader(Header):
369 369 self.profilesPerBlock = int(header['nProfilesperBlock'][0])
370 370 self.dataBlocksPerFile = int(header['nDataBlocksperFile'][0])
371 371 self.nWindows = int(header['nNumWindows'][0])
372 self.processFlags = int(header['nProcessFlags'])
372 self.processFlags = header['nProcessFlags']
373 373 self.nCohInt = int(header['nCoherentIntegrations'][0])
374 374 self.nIncohInt = int(header['nIncoherentIntegrations'][0])
375 375 self.totalSpectra = int(header['nTotalSpectra'][0])
@@ -88,6 +88,7 class CrossSpectraPlot(Figure):
88 88 x = dataOut.getFreqRange(1)
89 89 y = dataOut.getHeiRange()
90 90 z = 10.*numpy.log10(dataOut.data_spc[:,:,:])
91 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
91 92 avg = numpy.average(numpy.abs(z), axis=1)
92 93
93 94 noise = dataOut.getNoise()
@@ -265,10 +266,11 class RTIPlot(Figure):
265 266 x = dataOut.getTimeRange()
266 267 y = dataOut.getHeiRange()
267 268 z = 10.*numpy.log10(dataOut.data_spc[channelIndexList,:,:])
269 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
268 270 avg = numpy.average(z, axis=1)
269 271
270 272 noise = dataOut.getNoise()
271
273
272 274 if not self.__isConfig:
273 275
274 276 nplots = len(channelIndexList)
@@ -284,6 +286,7 class RTIPlot(Figure):
284 286 if zmin == None: zmin = numpy.nanmin(avg)*0.9
285 287 if zmax == None: zmax = numpy.nanmax(avg)*0.9
286 288
289 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
287 290 self.__isConfig = True
288 291
289 292 thisDatetime = dataOut.datatime
@@ -313,9 +316,9 class RTIPlot(Figure):
313 316 self.draw()
314 317
315 318 if save:
316 date = thisDatetime.strftime("%Y%m%d")
319
317 320 if figfile == None:
318 figfile = self.getFilename(name = date)
321 figfile = self.getFilename(name = self.name)
319 322
320 323 self.saveFigure(figpath, figfile)
321 324
@@ -412,7 +415,9 class SpectraPlot(Figure):
412 415
413 416 x = dataOut.getVelRange(1)
414 417 y = dataOut.getHeiRange()
418
415 419 z = 10.*numpy.log10(dataOut.data_spc[channelIndexList,:,:])
420 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
416 421 avg = numpy.average(z, axis=1)
417 422
418 423 noise = dataOut.getNoise()
@@ -485,6 +490,8 class Scope(Figure):
485 490
486 491 def setup(self, idfigure, nplots, wintitle):
487 492
493 self.nplots = nplots
494
488 495 self.createFigure(idfigure, wintitle)
489 496
490 497 nrow,ncol = self.getSubplots()
@@ -494,7 +501,7 class Scope(Figure):
494 501 for i in range(nplots):
495 502 self.addAxes(nrow, ncol, i, 0, colspan, rowspan)
496 503
497 self.nplots = nplots
504
498 505
499 506 def run(self, dataOut, idfigure, wintitle="", channelList=None,
500 507 xmin=None, xmax=None, ymin=None, ymax=None, save=False, filename=None):
@@ -522,13 +529,11 class Scope(Figure):
522 529 channelIndexList.append(dataOut.channelList.index(channel))
523 530
524 531 x = dataOut.heightList
525 y = dataOut.data[channelList,:] * numpy.conjugate(dataOut.data[channelList,:])
532 y = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:])
526 533 y = y.real
527 534
528 noise = dataOut.getNoise()
529
530 535 if not self.__isConfig:
531 nplots = len(channelList)
536 nplots = len(channelIndexList)
532 537
533 538 self.setup(idfigure=idfigure,
534 539 nplots=nplots,
@@ -550,7 +555,7 class Scope(Figure):
550 555 self.setWinTitle(title)
551 556
552 557 for i in range(len(self.axesList)):
553 title = "Channel %d: %4.2fdB" %(i, noise[i])
558 title = "Channel %d" %(i)
554 559 axes = self.axesList[i]
555 560 ychannel = y[i,:]
556 561 axes.pline(x, ychannel,
@@ -62,7 +62,7 class ProcessingUnit:
62 62 def operation(self, **kwargs):
63 63
64 64 """
65 Operacion directa sobre la data (dataout.data). Es necesario actualizar los valores de los
65 Operacion directa sobre la data (dataOut.data). Es necesario actualizar los valores de los
66 66 atributos del objeto dataOut
67 67
68 68 Input:
@@ -347,24 +347,11 class VoltageProc(ProcessingUnit):
347 347
348 348 return 1
349 349
350
351 def filterByHeights(self, window):
352 deltaHeight = self.dataOut.heightList[1] - self.dataOut.heightList[0]
353
354 if window == None:
355 window = self.dataOut.radarControllerHeaderObj.txA / deltaHeight
356
357 newdelta = deltaHeight * window
358 r = self.dataOut.data.shape[1] % window
359 buffer = self.dataOut.data[:,0:self.dataOut.data.shape[1]-r]
360 buffer = buffer.reshape(self.dataOut.data.shape[0],self.dataOut.data.shape[1]/window,window)
361 buffer = numpy.sum(buffer,2)
362 self.dataOut.data = buffer
363 self.dataOut.heightList = numpy.arange(self.dataOut.heightList[0],newdelta*self.dataOut.nHeights/window,newdelta)
364
365 350
366 351 class CohInt(Operation):
367 352
353 __isConfig = False
354
368 355 __profIndex = 0
369 356 __withOverapping = False
370 357
@@ -539,10 +526,10 class CohInt(Operation):
539 526
540 527 return avgdata, avgdatatime
541 528
542 def run(self, dataOut, n=None, timeInterval=None, overlapping=False):
529 def run(self, dataOut, **kwargs):
543 530
544 531 if not self.__isConfig:
545 self.setup(n, timeInterval, overlapping)
532 self.setup(**kwargs)
546 533 self.__isConfig = True
547 534
548 535 avgdata, avgdatatime = self.integrate(dataOut.data, dataOut.utctime)
@@ -556,7 +543,102 class CohInt(Operation):
556 543 dataOut.utctime = avgdatatime
557 544 dataOut.timeInterval = dataOut.ippSeconds * dataOut.nCohInt
558 545 dataOut.flagNoData = False
546
547 class Decoder(Operation):
548
549 __isConfig = False
550 __profIndex = 0
551
552 code = None
553
554 nCode = None
555 nBaud = None
556
557 def __init__(self):
558
559 self.__isConfig = False
560
561 def setup(self, code):
562
563 self.__profIndex = 0
564
565 self.code = code
566
567 self.nCode = len(code)
568 self.nBaud = len(code[0])
569
570 def convolutionInFreq(self, data):
571
572 ndata = data.shape[1]
573 newcode = numpy.zeros(ndata)
574 newcode[0:self.nBaud] = self.code[self.__profIndex]
575
576 fft_data = numpy.fft.fft(data, axis=1)
577 fft_code = numpy.conj(numpy.fft.fft(newcode))
578 fft_code = fft_code.reshape(1,len(fft_code))
579
580 # conv = fft_data.copy()
581 # conv.fill(0)
582
583 conv = fft_data*fft_code
584
585 data = numpy.fft.ifft(conv,axis=1)
586
587 datadec = data[:,:-self.nBaud+1]
588 ndatadec = ndata - self.nBaud + 1
589
590 if self.__profIndex == self.nCode:
591 self.__profIndex = 0
592
593 self.__profIndex += 1
594
595 return ndatadec, datadec
596
597
598 def convolutionInTime(self, data):
599
600 nchannel = data.shape[1]
601 newcode = self.code[self.__profIndex]
602
603 datadec = data.copy()
604
605 for i in range(nchannel):
606 datadec[i,:] = numpy.correlate(data[i,:], newcode)
607
608 ndatadec = ndata - self.nBaud + 1
609
610 if self.__profIndex == self.nCode:
611 self.__profIndex = 0
612
613 self.__profIndex += 1
614
615 return ndatadec, datadec
616
617 def run(self, dataOut, code=None, mode = 0):
618
619 if not self.__isConfig:
559 620
621 if code == None:
622 code = dataOut.code
623
624 self.setup(code)
625 self.__isConfig = True
626
627 if mode == 0:
628 ndatadec, datadec = self.convolutionInFreq(data)
629
630 if mode == 1:
631 ndatadec, datadec = self.convolutionInTime(data)
632
633 dataOut.data = datadec
634
635 dataOut.heightList = dataOut.heightList[0:ndatadec+1]
636
637 dataOut.flagDecodeData = True #asumo q la data no esta decodificada
638
639 # dataOut.flagDeflipData = True #asumo q la data no esta sin flip
640
641
560 642
561 643 class SpectraProc(ProcessingUnit):
562 644
@@ -606,7 +688,7 class SpectraProc(ProcessingUnit):
606 688 self.buffer
607 689 self.dataOut.flagNoData
608 690 """
609 fft_volt = numpy.fft.fft(self.buffer,axis=1)/numpy.sqrt(self.dataOut.nFFTPoints)
691 fft_volt = numpy.fft.fft(self.buffer,axis=1)
610 692 dc = fft_volt[:,0,:]
611 693
612 694 #calculo de self-spectra
@@ -635,6 +717,8 class SpectraProc(ProcessingUnit):
635 717
636 718 def init(self, nFFTPoints=None, pairsList=None):
637 719
720 self.dataOut.flagNoData = True
721
638 722 if self.dataIn.type == "Spectra":
639 723 self.dataOut.copy(self.dataIn)
640 724 return
@@ -660,7 +744,7 class SpectraProc(ProcessingUnit):
660 744 dtype='complex')
661 745
662 746
663 self.buffer[:,self.profIndex,:] = self.dataIn.data
747 self.buffer[:,self.profIndex,:] = self.dataIn.data.copy()
664 748 self.profIndex += 1
665 749
666 750 if self.firstdatatime == None:
@@ -987,159 +1071,4 class IncohInt(Operation):
987 1071 dataOut.utctime = avgdatatime
988 1072 dataOut.timeInterval = dataOut.ippSeconds * dataOut.nCohInt * dataOut.nIncohInt * dataOut.nFFTPoints
989 1073 dataOut.flagNoData = False
990
991
992 class ProfileSelector(Operation):
993
994 profileIndex = None
995 # Tamanho total de los perfiles
996 nProfiles = None
997
998 def __init__(self):
999
1000 self.profileIndex = 0
1001
1002 def incIndex(self):
1003 self.profileIndex += 1
1004
1005 if self.profileIndex >= self.nProfiles:
1006 self.profileIndex = 0
1007
1008 def isProfileInRange(self, minIndex, maxIndex):
1009
1010 if self.profileIndex < minIndex:
1011 return False
1012
1013 if self.profileIndex > maxIndex:
1014 return False
1015
1016 return True
1017
1018 def isProfileInList(self, profileList):
1019
1020 if self.profileIndex not in profileList:
1021 return False
1022
1023 return True
1024
1025 def run(self, dataOut, profileList=None, profileRangeList=None):
1026
1027 self.nProfiles = dataOut.nProfiles
1028
1029 if profileList != None:
1030 if not(self.isProfileInList(profileList)):
1031 dataOut.flagNoData = True
1032 else:
1033 dataOut.flagNoData = False
1034 self.incIndex()
1035 return 1
1036
1037
1038 elif profileRangeList != None:
1039 minIndex = profileRangeList[0]
1040 maxIndex = profileRangeList[1]
1041 if not(self.isProfileInRange(minIndex, maxIndex)):
1042 dataOut.flagNoData = True
1043 else:
1044 dataOut.flagNoData = False
1045 self.incIndex()
1046 return 1
1047 else:
1048 raise ValueError, "ProfileSelector needs profileList or profileRangeList"
1049
1050 return 0
1051
1052 class Decoder:
1053
1054 data = None
1055 profCounter = None
1056 code = None
1057 ncode = None
1058 nbaud = None
1059 codeIndex = None
1060 flag = False
1061
1062 def __init__(self):
1063
1064 self.data = None
1065 self.ndata = None
1066 self.profCounter = 1
1067 self.codeIndex = 0
1068 self.flag = False
1069 self.code = None
1070 self.ncode = None
1071 self.nbaud = None
1072 self.__isConfig = False
1073
1074 def convolutionInFreq(self, data, ndata):
1075
1076 newcode = numpy.zeros(ndata)
1077 newcode[0:self.nbaud] = self.code[self.codeIndex]
1078
1079 self.codeIndex += 1
1080
1081 fft_data = numpy.fft.fft(data, axis=1)
1082 fft_code = numpy.conj(numpy.fft.fft(newcode))
1083 fft_code = fft_code.reshape(1,len(fft_code))
1084
1085 conv = fft_data.copy()
1086 conv.fill(0)
1087
1088 conv = fft_data*fft_code
1089
1090 data = numpy.fft.ifft(conv,axis=1)
1091 self.data = data[:,:-self.nbaud+1]
1092 self.flag = True
1093
1094 if self.profCounter == self.ncode:
1095 self.profCounter = 0
1096 self.codeIndex = 0
1097
1098 self.profCounter += 1
1099
1100 def convolutionInTime(self, data, ndata):
1101
1102 nchannel = data.shape[1]
1103 newcode = self.code[self.codeIndex]
1104 self.codeIndex += 1
1105 conv = data.copy()
1106 for i in range(nchannel):
1107 conv[i,:] = numpy.correlate(data[i,:], newcode)
1108
1109 self.data = conv
1110 self.flag = True
1111
1112 if self.profCounter == self.ncode:
1113 self.profCounter = 0
1114 self.codeIndex = 0
1115
1116 self.profCounter += 1
1117
1118 def run(self, dataOut, code=None, mode = 0):
1119
1120 if not(self.__isConfig):
1121 if code == None:
1122 code = dataOut.radarControllerHeaderObj.code
1123 # code = dataOut.code
1124
1125 ncode, nbaud = code.shape
1126 self.code = code
1127 self.ncode = ncode
1128 self.nbaud = nbaud
1129 self.__isConfig = True
1130
1131 ndata = dataOut.data.shape[1]
1132
1133 if mode == 0:
1134 self.convolutionInFreq(dataOut.data, ndata)
1135
1136 if mode == 1:
1137 self.convolutionInTime(dataOut.data, ndata)
1138
1139 self.ndata = ndata - self.nbaud + 1
1140
1141 dataOut.data = self.data
1142
1143 dataOut.heightList = dataOut.heightList[:self.ndata]
1144
1145 dataOut.flagNoData = False No newline at end of file
1074 No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now