From d0a641be5ae378e9e7dc9c3cbbe31c187e565028 2015-08-25 14:46:57 From: Miguel Valdez Date: 2015-08-25 14:46:57 Subject: [PATCH] -Bug fixed: selecting channels and cross pairs -"numpy.array == None:" was replaced by "numpy.array is None:" --- diff --git a/schainpy/model/graphics/jroplot_parameters.py b/schainpy/model/graphics/jroplot_parameters.py index 6b7cc9f..614f685 100644 --- a/schainpy/model/graphics/jroplot_parameters.py +++ b/schainpy/model/graphics/jroplot_parameters.py @@ -424,7 +424,7 @@ class WindProfilerPlot(Figure): raise ValueError, "Channel %d is not in dataOut.channelList" channelIndexList.append(dataOut.channelList.index(channel)) -# if timerange != None: +# if timerange is not None: # self.timerange = timerange # # tmin = None @@ -439,7 +439,7 @@ class WindProfilerPlot(Figure): nplotsw = nplots #If there is a SNR function defined - if dataOut.data_SNR != None: + if dataOut.data_SNR is not None: nplots += 1 SNR = dataOut.data_SNR SNRavg = numpy.average(SNR, axis=0) @@ -469,7 +469,7 @@ class WindProfilerPlot(Figure): showprofile=showprofile, show=show) - if timerange != None: + if timerange is not None: self.timerange = timerange self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) @@ -485,7 +485,7 @@ class WindProfilerPlot(Figure): if zmax_ver == None: zmax_ver = numpy.nanmax(abs(z[2,:])) if zmin_ver == None: zmin_ver = -zmax_ver - if dataOut.data_SNR != None: + if dataOut.data_SNR is not None: if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB) if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB) @@ -522,7 +522,7 @@ class WindProfilerPlot(Figure): xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, ticksize=9, cblabel=strCb[i], cbsize="1%", colormap="RdBu_r" ) - if dataOut.data_SNR != None: + if dataOut.data_SNR is not None: i += 1 title = "Signal Noise Ratio (SNR): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) axes = self.axesList[i*self.__nsubplots] @@ -672,7 +672,7 @@ class ParametersPlot(Figure): nplots = nGraphsByChannel*nchan - if timerange != None: + if timerange is not None: self.timerange = timerange #tmin = None @@ -688,7 +688,7 @@ class ParametersPlot(Figure): # nChannels = z.shape[0] #Number of wind dimensions estimated # thisDatetime = dataOut.datatime - if dataOut.data_SNR != None: + if dataOut.data_SNR is not None: SNRarray = dataOut.data_SNR[channelIndexList,:] SNRdB = 10*numpy.log10(SNRarray) # SNRavgdB = 10*numpy.log10(SNRavg) @@ -1067,7 +1067,7 @@ class EWDriftsPlot(Figure): zmax : None """ - if timerange != None: + if timerange is not None: self.timerange = timerange tmin = None @@ -1082,7 +1082,7 @@ class EWDriftsPlot(Figure): nplotsw = nplots #If there is a SNR function defined - if dataOut.data_SNR != None: + if dataOut.data_SNR is not None: nplots += 1 SNR = dataOut.data_SNR @@ -1125,7 +1125,7 @@ class EWDriftsPlot(Figure): if zmaxVertical == None: zmaxVertical = numpy.nanmax(abs(z[1,:])) if zminVertical == None: zminVertical = -zmaxVertical - if dataOut.data_SNR != None: + if dataOut.data_SNR is not None: if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB) if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB) @@ -1160,7 +1160,7 @@ class EWDriftsPlot(Figure): xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, ticksize=9, cblabel=strCb, cbsize="1%", colormap="RdBu_r") - if dataOut.data_SNR != None: + if dataOut.data_SNR is not None: i += 1 if SNR_1: title = "Signal Noise Ratio + 1 (SNR+1): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) @@ -1278,7 +1278,7 @@ class PhasePlot(Figure): showprofile=showprofile, show=show) - if timerange != None: + if timerange is not None: self.timerange = timerange self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) diff --git a/schainpy/model/io/jroIO_spectra.py b/schainpy/model/io/jroIO_spectra.py index a512bf2..084108f 100644 --- a/schainpy/model/io/jroIO_spectra.py +++ b/schainpy/model/io/jroIO_spectra.py @@ -332,7 +332,7 @@ class SpectraReader(JRODataReader, ProcessingUnit): self.dataOut.flagDeflipData = False #asumo q la data esta sin flip - if self.radarControllerHeaderObj.code != None: + if self.radarControllerHeaderObj.code is not None: # self.dataOut.nCode = self.radarControllerHeaderObj.nCode # @@ -377,7 +377,7 @@ class SpectraReader(JRODataReader, ProcessingUnit): #data es un numpy array de 3 dmensiones (perfiles, alturas y canales) - if self.data_dc == None: + if self.data_dc is None: self.dataOut.flagNoData = True return 0 @@ -525,7 +525,7 @@ class SpectraWriter(JRODataWriter, Operation): data = data.astype(self.dtype[0]) data.tofile(self.fp) - if self.data_cspc != None: + if self.data_cspc is not None: data = numpy.zeros( self.shape_cspc_Buffer, self.dtype ) cspc = numpy.transpose( self.data_cspc, (0,2,1) ) if not( self.processingHeaderObj.shif_fft ): @@ -535,7 +535,7 @@ class SpectraWriter(JRODataWriter, Operation): data = data.reshape((-1)) data.tofile(self.fp) - if self.data_dc != None: + if self.data_dc is not None: data = numpy.zeros( self.shape_dc_Buffer, self.dtype ) dc = self.data_dc data['real'] = dc.real @@ -545,10 +545,10 @@ class SpectraWriter(JRODataWriter, Operation): self.data_spc.fill(0) - if self.data_dc != None: + if self.data_dc is not None: self.data_dc.fill(0) - if self.data_cspc != None: + if self.data_cspc is not None: self.data_cspc.fill(0) self.flagIsNewFile = 0 @@ -588,7 +588,7 @@ class SpectraWriter(JRODataWriter, Operation): self.setBasicHeader() self.data_spc = self.dataOut.data_spc.copy() - if self.dataOut.data_cspc != None: + if self.dataOut.data_cspc is not None: self.data_cspc = self.dataOut.data_cspc.copy() self.data_dc = self.dataOut.data_dc.copy() @@ -636,13 +636,13 @@ class SpectraWriter(JRODataWriter, Operation): if self.dataOut.flagDeflipData: processFlags += PROCFLAG.DEFLIP_DATA - if self.dataOut.code != None: + if self.dataOut.code is not None: processFlags += PROCFLAG.DEFINE_PROCESS_CODE if self.dataOut.nIncohInt > 1: processFlags += PROCFLAG.INCOHERENT_INTEGRATION - if self.dataOut.data_dc != None: + if self.dataOut.data_dc is not None: processFlags += PROCFLAG.SAVE_CHANNELS_DC return processFlags @@ -673,11 +673,11 @@ class SpectraWriter(JRODataWriter, Operation): pts2write_SelfSpectra = int(self.dataOut.nChannels * pts2write) blocksize = (pts2write_SelfSpectra*datatypeValue) - if self.dataOut.data_cspc != None: + if self.dataOut.data_cspc is not None: pts2write_CrossSpectra = int(self.dataOut.nPairs * pts2write) blocksize += (pts2write_CrossSpectra*datatypeValue*2) - if self.dataOut.data_dc != None: + if self.dataOut.data_dc is not None: pts2write_DCchannels = int(self.dataOut.nChannels * self.dataOut.nHeights) blocksize += (pts2write_DCchannels*datatypeValue*2) @@ -739,7 +739,7 @@ class SpectraWriter(JRODataWriter, Operation): processingHeaderSize += sizeOfSpcComb # The processing header should not have information about code -# if self.dataOut.code != None: +# if self.dataOut.code is not None: # self.processingHeaderObj.code = self.dataOut.code # self.processingHeaderObj.nCode = self.dataOut.nCode # self.processingHeaderObj.nBaud = self.dataOut.nBaud diff --git a/schainpy/model/io/jroIO_voltage.py b/schainpy/model/io/jroIO_voltage.py index 6b35992..5ffd46a 100644 --- a/schainpy/model/io/jroIO_voltage.py +++ b/schainpy/model/io/jroIO_voltage.py @@ -249,7 +249,7 @@ class VoltageReader(JRODataReader, ProcessingUnit): # self.dataOut.timeInterval = self.radarControllerHeaderObj.ippSeconds * self.processingHeaderObj.nCohInt # -# if self.radarControllerHeaderObj.code != None: +# if self.radarControllerHeaderObj.code is not None: # # self.dataOut.nCode = self.radarControllerHeaderObj.nCode # @@ -572,7 +572,7 @@ class VoltageWriter(JRODataWriter, Operation): if self.dataOut.flagDeflipData: processFlags += PROCFLAG.DEFLIP_DATA - if self.dataOut.code != None: + if self.dataOut.code is not None: processFlags += PROCFLAG.DEFINE_PROCESS_CODE if self.dataOut.nCohInt > 1: @@ -635,7 +635,7 @@ class VoltageWriter(JRODataWriter, Operation): self.processingHeaderObj.nIncohInt = 1 # Cuando la data de origen es de tipo Voltage self.processingHeaderObj.totalSpectra = 0 # Cuando la data de origen es de tipo Voltage -# if self.dataOut.code != None: +# if self.dataOut.code is not None: # self.processingHeaderObj.code = self.dataOut.code # self.processingHeaderObj.nCode = self.dataOut.nCode # self.processingHeaderObj.nBaud = self.dataOut.nBaud diff --git a/schainpy/model/proc/jroproc_spectra.py b/schainpy/model/proc/jroproc_spectra.py index d6e71ae..deb38cf 100644 --- a/schainpy/model/proc/jroproc_spectra.py +++ b/schainpy/model/proc/jroproc_spectra.py @@ -195,8 +195,8 @@ class SpectraProc(ProcessingUnit): return self.dataOut.data_cspc = self.dataOut.data_cspc[pairsIndexListSelected] - self.dataOut.pairsList = self.dataOut.pairsList[pairsIndexListSelected] - + self.dataOut.pairsList = [self.dataOut.pairsList[i] for i in pairsIndexListSelected] + return def selectChannels(self, channelList): @@ -316,12 +316,12 @@ class SpectraProc(ProcessingUnit): #data_spc = data_spc[:,:,beacon_heiIndexList] data_cspc = None - if self.dataOut.data_cspc != None: + if self.dataOut.data_cspc is not None: data_cspc = self.dataOut.data_cspc[:,:,minIndex:maxIndex+1] #data_cspc = data_cspc[:,:,beacon_heiIndexList] data_dc = None - if self.dataOut.data_dc != None: + if self.dataOut.data_dc is not None: data_dc = self.dataOut.data_dc[:,minIndex:maxIndex+1] #data_dc = data_dc[:,beacon_heiIndexList] @@ -366,11 +366,11 @@ class SpectraProc(ProcessingUnit): data_spc = self.dataOut.data_spc[:,:,minIndex:maxIndex+1] data_cspc = None - if self.dataOut.data_cspc != None: + if self.dataOut.data_cspc is not None: data_cspc = self.dataOut.data_cspc[:,:,minIndex:maxIndex+1] data_dc = None - if self.dataOut.data_dc != None: + if self.dataOut.data_dc is not None: data_dc = self.dataOut.data_dc[:,minIndex:maxIndex+1] self.dataOut.data_spc = data_spc @@ -389,7 +389,7 @@ class SpectraProc(ProcessingUnit): num_chan = jspectra.shape[0] num_hei = jspectra.shape[2] - if jcspectra != None: + if jcspectra is not None: jcspectraExist = True num_pairs = jcspectra.shape[0] else: jcspectraExist = False @@ -450,7 +450,7 @@ class SpectraProc(ProcessingUnit): num_hei = jspectra.shape[2] #hei_interf - if hei_interf == None: + if hei_interf is None: count_hei = num_hei/2 #Como es entero no importa hei_interf = numpy.asmatrix(range(count_hei)) + num_hei - count_hei hei_interf = numpy.asarray(hei_interf)[0] @@ -552,7 +552,7 @@ class SpectraProc(ProcessingUnit): jspectra[ich,indAux[0],indAux[1]] = tmp_noise * (1 - 1/math.sqrt(num_incoh)) #Remocion de Interferencia en el Cross Spectra - if jcspectra == None: return jspectra, jcspectra + if jcspectra is None: return jspectra, jcspectra num_pairs = jcspectra.size/(num_prof*num_hei) jcspectra = jcspectra.reshape(num_pairs, num_prof, num_hei) @@ -792,9 +792,9 @@ class IncohInt(Operation): #Overlapping data nChannels, nFFTPoints, nHeis = data_spc.shape data_spc = numpy.reshape(data_spc, (1, nChannels, nFFTPoints, nHeis)) - if data_cspc != None: + if data_cspc is not None: data_cspc = numpy.reshape(data_cspc, (1, -1, nFFTPoints, nHeis)) - if data_dc != None: + if data_dc is not None: data_dc = numpy.reshape(data_dc, (1, -1, nHeis)) #If the buffer is empty then it takes the data value @@ -818,10 +818,10 @@ class IncohInt(Operation): if self.__profIndex < self.n: self.__buffer_spc = numpy.vstack((self.__buffer_spc, data_spc)) - if data_cspc != None: + if data_cspc is not None: self.__buffer_cspc = numpy.vstack((self.__buffer_cspc, data_cspc)) - if data_dc != None: + if data_dc is not None: self.__buffer_dc = numpy.vstack((self.__buffer_dc, data_dc)) self.__profIndex += 1 @@ -831,11 +831,11 @@ class IncohInt(Operation): self.__buffer_spc = numpy.roll(self.__buffer_spc, -1, axis=0) self.__buffer_spc[self.n-1] = data_spc - if data_cspc != None: + if data_cspc is not None: self.__buffer_cspc = numpy.roll(self.__buffer_cspc, -1, axis=0) self.__buffer_cspc[self.n-1] = data_cspc - if data_dc != None: + if data_dc is not None: self.__buffer_dc = numpy.roll(self.__buffer_dc, -1, axis=0) self.__buffer_dc[self.n-1] = data_dc @@ -873,10 +873,10 @@ class IncohInt(Operation): #Integration with Overlapping data_spc = numpy.sum(self.__buffer_spc, axis=0) - if self.__buffer_cspc != None: + if self.__buffer_cspc is not None: data_cspc = numpy.sum(self.__buffer_cspc, axis=0) - if self.__buffer_dc != None: + if self.__buffer_dc is not None: data_dc = numpy.sum(self.__buffer_dc, axis=0) n = self.__profIndex diff --git a/setup.py b/setup.py index 41c7890..61e1bb2 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ Created on Jul 16, 2014 from distutils.core import setup, Extension setup(name="schainpy", - version="2.0", + version="2.1.0", description="Python tools to read, write and process Jicamarca data", author="Miguel Urco", author_email="miguel.urco@jro.igp.gob.pe",