diff --git a/schainpy/model/data/jrodata.py b/schainpy/model/data/jrodata.py index 5f3f4e2..870e322 100644 --- a/schainpy/model/data/jrodata.py +++ b/schainpy/model/data/jrodata.py @@ -599,7 +599,7 @@ class Spectra(JROData): normFactor = self.nProfiles * self.nIncohInt * self.nCohInt * pwcode * self.windowOfFilter if self.flagProfilesByRange: normFactor *= (self.nProfilesByRange/self.nProfilesByRange.max()) - + #print("normFactor: ", normFactor) return normFactor @property diff --git a/schainpy/model/graphics/jroplot_spectra.py b/schainpy/model/graphics/jroplot_spectra.py index 70e5a5f..fd922ed 100644 --- a/schainpy/model/graphics/jroplot_spectra.py +++ b/schainpy/model/graphics/jroplot_spectra.py @@ -1062,7 +1062,7 @@ class NoiselessRTIPlot(RTIPlot): data = {} meta = {} #print(dataOut.max_nIncohInt, dataOut.nIncohInt) - #print(dataOut.windowOfFilter,dataOut.nCohInt,dataOut.nProfiles,dataOut.max_nIncohInt,dataOut.nIncohInt) + #print(dataOut.windowOfFilter,dataOut.nCohInt,dataOut.nProfiles,dataOut.max_nIncohInt,dataOut.nIncohInt norm = dataOut.nProfiles * dataOut.max_nIncohInt * dataOut.nCohInt * dataOut.windowOfFilter n0 = 10*numpy.log10(dataOut.getNoise()/norm) data['noise'] = n0 @@ -1342,20 +1342,19 @@ class NoiselessRTILinePlot(Plot): #print(dataOut.windowOfFilter,dataOut.nCohInt,dataOut.nProfiles,dataOut.max_nIncohInt,dataOut.nIncohInt) norm = dataOut.nProfiles * dataOut.max_nIncohInt * dataOut.nCohInt * dataOut.windowOfFilter - n0 = 10*numpy.log10(dataOut.getNoise()/norm) data['noise'] = n0 noise = numpy.repeat(n0,dataOut.nHeights).reshape(dataOut.nChannels,dataOut.nHeights) noiseless_data = dataOut.getPower() - noise - + #print("power, noise:", dataOut.getPower(), n0) #print(noise) #print(noiseless_data) data['noiseless_rtiLine'] = noiseless_data - print(noiseless_data.shape, self.name) + #print(noiseless_data.shape, self.name) data['time'] = dataOut.utctime return data, meta @@ -1364,7 +1363,7 @@ class NoiselessRTILinePlot(Plot): self.x = self.data.times self.y = self.data.yrange - print(self.data['noiseless_rtiLine'].shape, self.y.shape, self.name) + #print(self.data['noiseless_rtiLine'].shape, self.y.shape, self.name) #ts = self.data['time'][0].squeeze() if len(self.data['noiseless_rtiLine'])>2 : self.z = self.data['noiseless_rtiLine'][:, -1,:] @@ -1435,7 +1434,7 @@ class GeneralProfilePlot(Plot): data['noiseless_rtiLine'] = noiseless_data - print(noiseless_data.shape, self.name) + #print(noiseless_data.shape, self.name) data['time'] = dataOut.utctime return data, meta @@ -1444,7 +1443,7 @@ class GeneralProfilePlot(Plot): self.x = self.data.times self.y = self.data.yrange - print(self.data['noiseless_rtiLine'].shape, self.y.shape, self.name) + #print(self.data['noiseless_rtiLine'].shape, self.y.shape, self.name) #ts = self.data['time'][0].squeeze() if len(self.data['noiseless_rtiLine'])>2 : self.z = self.data['noiseless_rtiLine'][:, -1,:] diff --git a/schainpy/model/proc/jroproc_spectra.py b/schainpy/model/proc/jroproc_spectra.py index c2f563d..3ce5773 100644 --- a/schainpy/model/proc/jroproc_spectra.py +++ b/schainpy/model/proc/jroproc_spectra.py @@ -727,6 +727,7 @@ class getNoiseB(Operation): norm = 1 else: norm = self.dataOut.max_nIncohInt[channel]/self.dataOut.nIncohInt[channel, self.minIndex:self.maxIndex] + #print("norm nIncoh: ", norm ,self.dataOut.data_spc.shape, self.dataOut.max_nIncohInt) daux = self.dataOut.data_spc[channel,self.minIndexFFT:self.maxIndexFFT, self.minIndex:self.maxIndex] daux = numpy.multiply(daux, norm) @@ -742,11 +743,12 @@ class getNoiseB(Operation): #noise = self.dataOut.getNoise(xmin_index=self.minIndexFFT, xmax_index=self.maxIndexFFT, ymin_index=self.minIndex, ymax_index=self.maxIndex) else: noise = self.dataOut.getNoise(xmin_index=self.minIndexFFT, xmax_index=self.maxIndexFFT, ymin_index=self.minIndex, ymax_index=self.maxIndex) + self.dataOut.noise_estimation = noise.copy() # dataOut.noise #print("2: ",10*numpy.log10(self.dataOut.noise_estimation/64)) #print("2: ",self.dataOut.noise_estimation) #print(self.dataOut.flagNoData) - #print("getNoise Done", noise, self.dataOut.nProfiles ,self.dataOut.ippFactor) + #print("getNoise Done", 10*numpy.log10(noise)) return self.dataOut def getNoiseByMean(self,data): @@ -1381,7 +1383,6 @@ class IntegrationFaradaySpectra(Operation): self.minHei_ind = ind_list1[0][0] self.maxHei_ind = ind_list2[0][-1] - def putData(self, data_spc, data_cspc, data_dc): """ Add a profile to the __buffer_spc and increase in one the __profileIndex @@ -1637,7 +1638,7 @@ class IntegrationFaradaySpectra(Operation): return self.dataOut self.dataOut.processingHeaderObj.timeIncohInt = timeInterval - if dataOut.flagProfilesByRange == True: + if dataOut.flagProfilesByRange: self._flagProfilesByRange = True if self.dataOut.nChannels == 1: @@ -1700,7 +1701,7 @@ class IntegrationFaradaySpectra(Operation): self.dataOut.flagNoData = False dataOut.nProfilesByRange = self._nProfilesByRange - self._nProfilesByRange = 0 + self._nProfilesByRange = numpy.zeros(len(dataOut.heightList)) self._flagProfilesByRange = False # #update Processing Header: @@ -1849,7 +1850,7 @@ class removeInterference(Operation): power = power[:, hei_interf] power = power.sum(axis=0) psort = power.ravel().argsort() - print(hei_interf[psort[list(range(offhei_interf, nhei_interf + offhei_interf))]]) + #print(hei_interf[psort[list(range(offhei_interf, nhei_interf + offhei_interf))]]) # Se estima la interferencia promedio en los Espectros de Potencia empleando junkspc_interf = jspectra[ich, :, hei_interf[psort[list(range( offhei_interf, nhei_interf + offhei_interf))]]] @@ -1859,7 +1860,7 @@ class removeInterference(Operation): tmp_noise = jnoise[ich] junkspc_interf = junkspc_interf - tmp_noise #junkspc_interf[:,comp_mask_prof] = 0 - print(junkspc_interf.shape) + #print(junkspc_interf.shape) jspc_interf = junkspc_interf.sum(axis=0) / nhei_interf jspc_interf = jspc_interf.transpose() # Calculando el espectro de interferencia promedio @@ -1892,7 +1893,7 @@ class removeInterference(Operation): # Removiendo la interferencia del punto de mayor interferencia ListAux = jspc_interf[mask_prof].tolist() maxid = ListAux.index(max(ListAux)) - print(cinterfid) + #print(cinterfid) if cinterfid > 0: for ip in range(cinterfid * (interf == 2) - 1): ind = (jspectra[ich, interfid[ip], :] < tmp_noise * @@ -1917,7 +1918,7 @@ class removeInterference(Operation): indAux = (jspectra[ich, :, :] < tmp_noise * (1 - 1 / numpy.sqrt(num_incoh))).nonzero() - print(indAux) + #print(indAux) jspectra[ich, indAux[0], indAux[1]] = tmp_noise * \ (1 - 1 / numpy.sqrt(num_incoh)) @@ -2056,6 +2057,7 @@ class IncohInt(Operation): self.n = None self.__byTime = True + def putData(self, data_spc, data_cspc, data_dc): """ @@ -2165,6 +2167,7 @@ class IncohInt(Operation): dataOut.flagNoData = True dataOut.processingHeaderObj.timeIncohInt = timeInterval if not self.isConfig: + self._nProfilesByRange = numpy.zeros(len(dataOut.heightList)) self.setup(n, timeInterval, overlapping) self.isConfig = True @@ -2197,7 +2200,7 @@ class IncohInt(Operation): self.nOutliers = 0 self.__profIndex = 0 dataOut.nProfilesByRange = self._nProfilesByRange - self._nProfilesByRange = 0 + self._nProfilesByRange = numpy.zeros(len(dataOut.heightList)) self._flagProfilesByRange = False #print("IncohInt Done") return dataOut diff --git a/schainpy/model/proc/jroproc_voltage.py b/schainpy/model/proc/jroproc_voltage.py index b8e5565..ec6ae96 100644 --- a/schainpy/model/proc/jroproc_voltage.py +++ b/schainpy/model/proc/jroproc_voltage.py @@ -2024,10 +2024,8 @@ class SSheightProfiles2(Operation): # #assuming the same remotion for all channels aux = [ self.nsamples - numpy.count_nonzero(dataOut.data[0, :, h]==0) for h in range(len(dataOut.heightList))] dataOut.nProfilesByRange = numpy.asarray(aux) - #print(dataOut.nProfilesByRange) else: dataOut.nProfilesByRange = numpy.ones(len(dataOut.heightList))*dataOut.nProfiles - print(dataOut.nProfilesByRange) return dataOut @@ -3581,9 +3579,12 @@ class RemoveProfileSats2(Operation): class remHeightsIppInterf(Operation): - def __init__(self): + def __init__(self, **kwargs): + - self.config = False + Operation.__init__(self, **kwargs) + + self.isConfig = False self.heights_indx = None self.heightsList = [] @@ -3618,12 +3619,15 @@ class remHeightsIppInterf(Operation): self.heights_indx = [ numpy.asarray([k for k in range(_n_hIntf+2)])+(getHei_index(h,h,heiList)[0] -1) for h in self.heightsList] self.heights_indx = numpy.asarray(self.heights_indx ) - self.config = True + self.isConfig = True self.startTime = datetime.datetime.combine(idate,startH) self.endTime = datetime.datetime.combine(idate,endH) #print(self.startTime, self.endTime) #print("nrepeats: ", _n_repeats, " _nH: ",_n_hIntf ) - #print("H interf:",self.heightsList, dataOut.heightList[self.heights_indx] ) + + log.warning("Heights set to zero (km): ", self.name) + log.warning(str((dataOut.heightList[self.heights_indx].flatten())), self.name) + log.warning("Be careful with the selection of heights for noise calculation!") def run(self, dataOut, ipp1=None, ipp2=None, tx1=None, tx2=None, dh1=None, idate=None, startH=None, endH=None): @@ -3633,17 +3637,16 @@ class remHeightsIppInterf(Operation): return dataOut - if not self.config: + if not self.isConfig: self.setup(dataOut, ipp1=ipp1, ipp2=ipp2, tx1=tx1, tx2=tx2, dh1=dh1, idate=idate, startH=startH, endH=endH) - flagProfilesByRange = False + dataOut.flagProfilesByRange = False currentTime = datetime.datetime.fromtimestamp(dataOut.utctime) if currentTime < self.startTime or currentTime > self.endTime: return dataOut - for ch in range(dataOut.data.shape[0]): for hk in self.heights_indx.flatten(): @@ -3653,5 +3656,5 @@ class remHeightsIppInterf(Operation): dataOut.data[ch,:,hk] = 0 + 0j dataOut.flagProfilesByRange = True - + return dataOut \ No newline at end of file