From 318977a743a93907e14bfa32b1b55800a5c49f51 2014-03-24 10:15:59 From: Daniel Valdez Date: 2014-03-24 10:15:59 Subject: [PATCH] jrodata.py: el atributo ippFactor se inicia en 1 jroplot.py: no se considera el factor de normalizacion para el ploteo de datos jroprocessing.py: se agrega el metodo getnoise() a la clase Spectra, este metodo reliza la estimacion del ruido usando seleccion de alturas y hildebrand-sekon --- diff --git a/schainpy/model/jrodata.py b/schainpy/model/jrodata.py index 97b526d..05737ba 100644 --- a/schainpy/model/jrodata.py +++ b/schainpy/model/jrodata.py @@ -420,6 +420,8 @@ class Spectra(JROData): self.flagDeflipData = False #asumo q la data no esta sin flip self.flagShiftFFT = False + + self.ippFactor = 1 def getNoisebyHildebrand(self): """ @@ -464,19 +466,19 @@ class Spectra(JROData): return self.noise def getNoise(self, type = 1): + if self.noise == None: + self.noise = numpy.zeros(self.nChannels) + + if type == 1: + self.noise = self.getNoisebyHildebrand() + + if type == 2: + self.noise = self.getNoisebySort() + + if type == 3: + self.noise = self.getNoisebyWindow() - self.noise = numpy.zeros(self.nChannels) - - if type == 1: - noise = self.getNoisebyHildebrand() - - if type == 2: - noise = self.getNoisebySort() - - if type == 3: - noise = self.getNoisebyWindow() - - return noise + return self.noise def getFreqRange(self, extrapoints=0): diff --git a/schainpy/model/jroplot.py b/schainpy/model/jroplot.py index 946f32e..e98ae90 100644 --- a/schainpy/model/jroplot.py +++ b/schainpy/model/jroplot.py @@ -102,13 +102,13 @@ class CrossSpectraPlot(Figure): if len(pairsIndexList) > 4: pairsIndexList = pairsIndexList[0:4] - factor = dataOut.normFactor + #factor = dataOut.normFactor x = dataOut.getVelRange(1) y = dataOut.getHeiRange() - z = dataOut.data_spc[:,:,:]/factor + z = dataOut.data_spc[:,:,:]#/factor # z = numpy.where(numpy.isfinite(z), z, numpy.NAN) avg = numpy.abs(numpy.average(z, axis=1)) - noise = dataOut.getNoise()/factor + noise = dataOut.getNoise()#/factor zdB = 10*numpy.log10(z) avgdB = 10*numpy.log10(avg) @@ -151,7 +151,7 @@ class CrossSpectraPlot(Figure): pair = dataOut.pairsList[pairsIndexList[i]] str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) title = "Ch%d: %4.2fdB: %s" %(pair[0], noisedB[pair[0]], str_datetime) - zdB = 10.*numpy.log10(dataOut.data_spc[pair[0],:,:]/factor) + zdB = 10.*numpy.log10(dataOut.data_spc[pair[0],:,:]) axes0 = self.axesList[i*self.__nsubplots] axes0.pcolor(x, y, zdB, xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, @@ -159,7 +159,7 @@ class CrossSpectraPlot(Figure): ticksize=9, colormap=power_cmap, cblabel='') title = "Ch%d: %4.2fdB: %s" %(pair[1], noisedB[pair[1]], str_datetime) - zdB = 10.*numpy.log10(dataOut.data_spc[pair[1],:,:]/factor) + zdB = 10.*numpy.log10(dataOut.data_spc[pair[1],:,:]) axes0 = self.axesList[i*self.__nsubplots+1] axes0.pcolor(x, y, zdB, xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, @@ -318,11 +318,11 @@ class RTIPlot(Figure): tmin = None tmax = None - factor = dataOut.normFactor + #factor = dataOut.normFactor x = dataOut.getTimeRange() y = dataOut.getHeiRange() - z = dataOut.data_spc[channelIndexList,:,:]/factor + z = dataOut.data_spc[channelIndexList,:,:]#/factor z = numpy.where(numpy.isfinite(z), z, numpy.NAN) avg = numpy.average(z, axis=1) @@ -506,14 +506,14 @@ class SpectraPlot(Figure): if channel not in dataOut.channelList: raise ValueError, "Channel %d is not in dataOut.channelList" channelIndexList.append(dataOut.channelList.index(channel)) - factor = dataOut.normFactor + #factor = dataOut.normFactor x = dataOut.getVelRange(1) y = dataOut.getHeiRange() - z = dataOut.data_spc[channelIndexList,:,:]/factor + z = dataOut.data_spc[channelIndexList,:,:]#/factor z = numpy.where(numpy.isfinite(z), z, numpy.NAN) avg = numpy.average(z, axis=1) - noise = dataOut.getNoise()/factor + noise = dataOut.getNoise()#/factor zdB = 10*numpy.log10(z) avgdB = 10*numpy.log10(avg) @@ -765,9 +765,9 @@ class PowerProfilePlot(Figure): raise ValueError, "Channel %d is not in dataOut.channelList" channelIndexList.append(dataOut.channelList.index(channel)) - factor = dataOut.normFactor + #factor = dataOut.normFactor y = dataOut.getHeiRange() - x = dataOut.data_spc[channelIndexList,:,:]/factor + x = dataOut.data_spc[channelIndexList,:,:]#/factor x = numpy.where(numpy.isfinite(x), x, numpy.NAN) avg = numpy.average(x, axis=1) @@ -1107,8 +1107,8 @@ class Noise(Figure): tmax = None x = dataOut.getTimeRange() y = dataOut.getHeiRange() - factor = dataOut.normFactor - noise = dataOut.getNoise()/factor + #factor = dataOut.normFactor + noise = dataOut.getNoise()#/factor noisedB = 10*numpy.log10(noise) #thisDatetime = dataOut.datatime @@ -1433,8 +1433,8 @@ class RTIfromSpectraHeis(Figure): x = dataOut.getTimeRange() y = dataOut.getHeiRange() - factor = 1 - data = dataOut.data_spc/factor + #factor = 1 + data = dataOut.data_spc#/factor data = numpy.average(data,axis=1) datadB = 10*numpy.log10(data) diff --git a/schainpy/model/jroprocessing.py b/schainpy/model/jroprocessing.py index 749a7f6..169bfb3 100644 --- a/schainpy/model/jroprocessing.py +++ b/schainpy/model/jroprocessing.py @@ -1194,6 +1194,49 @@ class SpectraProc(ProcessingUnit): self.dataOut.frequency = frequency return 1 + + def getNoise(self, minHei, maxHei): + + if (minHei < self.dataOut.heightList[0]) or (minHei > maxHei): + raise ValueError, "some value in (%d,%d) is not valid" % (minHei, maxHei) + + if (maxHei > self.dataOut.heightList[-1]): + maxHei = self.dataOut.heightList[-1] + + minIndex = 0 + maxIndex = 0 + heights = self.dataOut.heightList + + inda = numpy.where(heights >= minHei) + indb = numpy.where(heights <= maxHei) + + try: + minIndex = inda[0][0] + except: + minIndex = 0 + + try: + maxIndex = indb[0][-1] + except: + maxIndex = len(heights) + + if (minIndex < 0) or (minIndex > maxIndex): + raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex) + + if (maxIndex >= self.dataOut.nHeights): + maxIndex = self.dataOut.nHeights-1 + + data_spc = self.dataOut.data_spc[:,:,minIndex:maxIndex+1] + + noise = numpy.zeros(self.dataOut.nChannels) + + for channel in range(self.dataOut.nChannels): + daux = data_spc[channel,:,:] + noise[channel] = hildebrand_sekhon(daux, self.dataOut.nIncohInt) + + self.dataOut.noise = noise.copy() + + return 1 class IncohInt(Operation):