diff --git a/schainpy/model/graphics/jroplot_base.py b/schainpy/model/graphics/jroplot_base.py index 04ed2e6..02b68cd 100644 --- a/schainpy/model/graphics/jroplot_base.py +++ b/schainpy/model/graphics/jroplot_base.py @@ -202,6 +202,7 @@ class Plot(Operation): self.figures = [] self.axes = [] self.cb_axes = [] + self.pf_axes = [] self.localtime = kwargs.pop('localtime', True) self.show = kwargs.get('show', True) self.save = kwargs.get('save', False) @@ -252,6 +253,7 @@ class Plot(Operation): self.__throttle_plot = apply_throttle(self.throttle) code = self.attr_data if self.attr_data else self.CODE self.data = PlotterData(self.CODE, self.exp_code, self.localtime) + self.tmin = kwargs.get('tmin', None) if self.server: if not self.server.startswith('tcp://'): diff --git a/schainpy/model/graphics/jroplot_parameters.py b/schainpy/model/graphics/jroplot_parameters.py index 06032b4..fecc7b7 100644 --- a/schainpy/model/graphics/jroplot_parameters.py +++ b/schainpy/model/graphics/jroplot_parameters.py @@ -50,7 +50,7 @@ class SnrPlot(RTIPlot): def update(self, dataOut): data = { - 'snr': 10*numpy.log10(dataOut.data_snr) + 'snr': 10*numpy.log10(dataOut.data_snr) } return data, {} @@ -66,7 +66,7 @@ class DopplerPlot(RTIPlot): def update(self, dataOut): data = { - 'dop': 10*numpy.log10(dataOut.data_dop) + 'dop': 10*numpy.log10(dataOut.data_dop) } return data, {} @@ -82,9 +82,9 @@ class PowerPlot(RTIPlot): def update(self, dataOut): data = { - 'pow': 10*numpy.log10(dataOut.data_pow) + 'pow': 10*numpy.log10(dataOut.data_pow) } - + print("data",data) return data, {} class SpectralWidthPlot(RTIPlot): @@ -166,7 +166,7 @@ class GenericRTIPlot(Plot): self.nrows = self.data.shape('param')[0] self.nplots = self.nrows self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.08, 'right':0.95, 'top': 0.95}) - + if not self.xlabel: self.xlabel = 'Time' @@ -183,7 +183,7 @@ class GenericRTIPlot(Plot): meta = {} return data, meta - + def plot(self): # self.data.normalize_heights() self.x = self.data.times @@ -354,4 +354,3 @@ class PolarMapPlot(Plot): self.save_labels = ['{}-{}'.format(lbl, label) for lbl in self.labels] self.titles = ['{} {}'.format( self.data.parameters[x], title) for x in self.channels] - diff --git a/schainpy/model/graphics/jroplot_spectra.py b/schainpy/model/graphics/jroplot_spectra.py index 28aaddc..17b9192 100644 --- a/schainpy/model/graphics/jroplot_spectra.py +++ b/schainpy/model/graphics/jroplot_spectra.py @@ -21,7 +21,7 @@ class SpectraPlot(Plot): colormap = 'jet' plot_type = 'pcolor' buffering = False - channelList = None + channelList = [] def setup(self): self.nplots = len(self.data.channels) @@ -208,11 +208,12 @@ class RTIPlot(Plot): colormap = 'jet' plot_type = 'pcolorbuffer' titles = None - channelList = None + channelList = [] def setup(self): self.xaxis = 'time' self.ncols = 1 + print("dataChannels ",self.data.channels) self.nrows = len(self.data.channels) self.nplots = len(self.data.channels) self.ylabel = 'Range [km]' @@ -221,9 +222,9 @@ class RTIPlot(Plot): self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.08, 'right':0.95}) self.titles = ['{} Channel {}'.format( self.CODE.upper(), x) for x in range(self.nplots)] - + print("SETUP") def update(self, dataOut): - if self.channelList == None: + if len(self.channelList) == 0: self.channelList = dataOut.channelList data = {} meta = {} diff --git a/schainpy/model/io/jroIO_base.py b/schainpy/model/io/jroIO_base.py index f3fadec..5bbb175 100644 --- a/schainpy/model/io/jroIO_base.py +++ b/schainpy/model/io/jroIO_base.py @@ -585,7 +585,7 @@ class Reader(object): path, startDate, endDate, folderfmt, last=True) else: folders = path.split(',') - + return self.find_files( folders, ext, filefmt, startDate, endDate, expLabel, last=True) @@ -692,7 +692,7 @@ class Reader(object): startDateTime= datetime.datetime.combine(startDate,startTime) endDateTime = datetime.datetime.combine(endDate,endTime) if startDateTime <= dt <= endDateTime: - return True + return True return False def verifyFile(self, filename): diff --git a/schainpy/model/io/jroIO_kamisr.py b/schainpy/model/io/jroIO_kamisr.py index a511d07..b8e74ca 100644 --- a/schainpy/model/io/jroIO_kamisr.py +++ b/schainpy/model/io/jroIO_kamisr.py @@ -646,7 +646,7 @@ class AMISRReader(ProcessingUnit): self.profileIndex += 1 - #return self.dataOut.data + return self.dataOut.data def run(self, **kwargs): @@ -659,5 +659,3 @@ class AMISRReader(ProcessingUnit): self.isConfig = True self.getData() - #return(self.dataOut.data) - return(self.dataOut) diff --git a/schainpy/model/io/jroIO_param.py b/schainpy/model/io/jroIO_param.py index 9c37353..4102a20 100644 --- a/schainpy/model/io/jroIO_param.py +++ b/schainpy/model/io/jroIO_param.py @@ -108,8 +108,11 @@ class HDFReader(Reader, ProcessingUnit): fullpath = self.searchFilesOnLine(self.path, self.startDate, self.endDate, self.expLabel, self.ext, self.walk, self.filefmt, self.folderfmt) + pathname, filename = os.path.split(fullpath) + print(pathname,filename) try: fullpath = next(fullpath) + except: fullpath = None @@ -139,6 +142,7 @@ class HDFReader(Reader, ProcessingUnit): return + def readFirstHeader(self): '''Read metadata and data''' @@ -150,8 +154,10 @@ class HDFReader(Reader, ProcessingUnit): self.dataOut = eval(self.meta['type'])() for attr in self.meta: + print("attr: ", attr) setattr(self.dataOut, attr, self.meta[attr]) + self.blockIndex = 0 return @@ -173,7 +179,8 @@ class HDFReader(Reader, ProcessingUnit): thisUtcTime = self.data['utctime'] + self.utcoffset self.interval = numpy.min(thisUtcTime[1:] - thisUtcTime[:-1]) thisDatetime = datetime.datetime.utcfromtimestamp(thisUtcTime[0]) - + self.startFileDatetime = thisDatetime + print("datee ",self.startFileDatetime) thisDate = thisDatetime.date() thisTime = thisDatetime.time() @@ -184,6 +191,7 @@ class HDFReader(Reader, ProcessingUnit): self.blockList = ind self.blocksPerFile = len(ind) + self.blocksPerFile = len(thisUtcTime) return def __readMetadata(self): @@ -208,6 +216,20 @@ class HDFReader(Reader, ProcessingUnit): return + + + def checkForRealPath(self, nextFile, nextDay): + + # print("check FRP") + # dt = self.startFileDatetime + datetime.timedelta(1) + # filename = '{}.{}{}'.format(self.path, dt.strftime('%Y%m%d'), self.ext) + # fullfilename = os.path.join(self.path, filename) + # print("check Path ",fullfilename,filename) + # if os.path.exists(fullfilename): + # return fullfilename, filename + # return None, filename + return None,None + def __readData(self): data = {} @@ -250,7 +272,10 @@ class HDFReader(Reader, ProcessingUnit): return def getData(self): - + if not self.isDateTimeInRange(self.startFileDatetime, self.startDate, self.endDate, self.startTime, self.endTime): + self.dataOut.flagNoData = True + self.dataOut.error = True + return for attr in self.data: if self.data[attr].ndim == 1: setattr(self.dataOut, attr, self.data[attr][self.blockIndex]) diff --git a/schainpy/model/proc/jroproc_parameters.py b/schainpy/model/proc/jroproc_parameters.py index a647562..aeeecf7 100755 --- a/schainpy/model/proc/jroproc_parameters.py +++ b/schainpy/model/proc/jroproc_parameters.py @@ -60,7 +60,7 @@ class ParametersProc(ProcessingUnit): self.profIndex = 0 self.dataOut = Parameters() self.setupReq = False #Agregar a todas las unidades de proc - + print("INIT PROC") def __updateObjFromInput(self): self.dataOut.inputUnit = self.dataIn.type @@ -99,8 +99,7 @@ class ParametersProc(ProcessingUnit): self.dataOut.elevationList = self.dataIn.elevationList def run(self): - - + print("run proc param") #---------------------- Voltage Data --------------------------- @@ -185,7 +184,7 @@ class ParametersProc(ProcessingUnit): if self.dataIn.type == "Parameters": self.dataOut.copy(self.dataIn) self.dataOut.flagNoData = False - + self.prin("DAta In") return True self.__updateObjFromInput() diff --git a/schainpy/model/proc/jroproc_spectra.py b/schainpy/model/proc/jroproc_spectra.py index b744e97..dcb4528 100644 --- a/schainpy/model/proc/jroproc_spectra.py +++ b/schainpy/model/proc/jroproc_spectra.py @@ -544,7 +544,7 @@ class CleanRayleigh(Operation): self.currentTime = self.__initime self.pairsArray = numpy.array(dataOut.pairsList) self.factor_stdv = factor_stdv - print("CHANNELS: ",[x for x in self.channels]) + #print("CHANNELS: ",[x for x in self.channels]) if n != None : self.byProfiles = True @@ -577,7 +577,7 @@ class CleanRayleigh(Operation): #if (tini.tm_min % 2) == 0 and (tini.tm_sec < 5 and self.fint==0): if self.__dataReady: - print("Data ready",self.__profIndex) + #print("Data ready",self.__profIndex) self.__profIndex = 0 jspc = self.buffer jcspc = self.buffer2 @@ -620,14 +620,13 @@ class CleanRayleigh(Operation): # jcspc = jcspc/self.nFFTPoints/self.normFactor - #dataOut.data_spc,dataOut.data_cspc = self.CleanRayleigh(dataOut,jspc,jcspc,crosspairs,heights,channels,nProf,nHei,nChan,nPairs,nIncohInt,nBlocks=nBlocks) - #tmp_spectra,tmp_cspectra,sat_spectra,sat_cspectra = self.cleanRayleigh(dataOut,jspc,jcspc,self.min_hei,self.max_hei) - tmp_spectra,tmp_cspectra = self.cleanRayleigh(dataOut,jspc,jcspc,self.factor_stdv) - #jspectra = tmp_spectra*len(jspc[:,0,0,0]) - #jcspectra = tmp_cspectra*len(jspc[:,0,0,0]) + tmp_spectra,tmp_cspectra = self.cleanRayleigh(dataOut,jspc,jcspc,self.factor_stdv) dataOut.data_spc = tmp_spectra dataOut.data_cspc = tmp_cspectra + + #dataOut.data_spc,dataOut.data_cspc = self.cleanRayleigh(dataOut,jspc,jcspc,self.factor_stdv) + dataOut.data_dc = self.buffer3 dataOut.nIncohInt *= self.nIntProfiles dataOut.utctime = self.currentTime #tiempo promediado @@ -641,32 +640,35 @@ class CleanRayleigh(Operation): return dataOut def cleanRayleigh(self,dataOut,spectra,cspectra,factor_stdv): - print("OP cleanRayleigh") + #print("OP cleanRayleigh") #import matplotlib.pyplot as plt #for k in range(149): rfunc = cspectra.copy() #self.bloques - val_spc = spectra*0.0 #self.bloque0*0.0 - val_cspc = cspectra*0.0 #self.bloques*0.0 - in_sat_spectra = spectra.copy() #self.bloque0 - in_sat_cspectra = cspectra.copy() #self.bloques + #rfunc = cspectra + #val_spc = spectra*0.0 #self.bloque0*0.0 + #val_cspc = cspectra*0.0 #self.bloques*0.0 + #in_sat_spectra = spectra.copy() #self.bloque0 + #in_sat_cspectra = cspectra.copy() #self.bloques - raxs = math.ceil(math.sqrt(self.nPairs)) - caxs = math.ceil(self.nPairs/raxs) + #raxs = math.ceil(math.sqrt(self.nPairs)) + #caxs = math.ceil(self.nPairs/raxs) #print(self.hval) #print numpy.absolute(rfunc[:,0,0,14]) + gauss_fit, covariance = None, None for ih in range(self.minAltInd,self.maxAltInd): for ifreq in range(self.nFFTPoints): # fig, axs = plt.subplots(raxs, caxs) # fig2, axs2 = plt.subplots(raxs, caxs) - col_ax = 0 - row_ax = 0 + # col_ax = 0 + # row_ax = 0 + #print(len(self.nPairs)) for ii in range(self.nPairs): #PARES DE CANALES SELF y CROSS #print("ii: ",ii) - if (col_ax%caxs==0 and col_ax!=0): - col_ax = 0 - row_ax += 1 + # if (col_ax%caxs==0 and col_ax!=0): + # col_ax = 0 + # row_ax += 1 func2clean = 10*numpy.log10(numpy.absolute(rfunc[:,ii,ifreq,ih])) #Potencia? #print(func2clean.shape) val = (numpy.isfinite(func2clean)==True).nonzero() @@ -689,8 +691,9 @@ class CleanRayleigh(Operation): mean = numpy.sum(x_dist * y_dist) / numpy.sum(y_dist) sigma = numpy.sqrt(numpy.sum(y_dist * (x_dist - mean)**2) / numpy.sum(y_dist)) parg = [numpy.amax(y_dist),mean,sigma] - gauss_fit, covariance = None, None - newY = None + + #newY = None + try : gauss_fit, covariance = curve_fit(fit_func, x_dist, y_dist,p0=parg) mode = gauss_fit[1] @@ -708,8 +711,7 @@ class CleanRayleigh(Operation): #print(mode,stdv) - #Removing echoes greater than mode + 3*stdv - #factor_stdv = 2 + #Removing echoes greater than mode + std_factor*stdv noval = (abs(func2clean - mode)>=(factor_stdv*stdv)).nonzero() #noval tiene los indices que se van a remover #print("Pair ",ii," novals: ",len(noval[0])) @@ -730,14 +732,12 @@ class CleanRayleigh(Operation): chB = self.channels.index(cross_pairs[1]) new_a = numpy.delete(cspectra[:,ii,ifreq,ih], noval[0]) - mean_cspc = numpy.mean(new_a) + cspectra[noval,ii,ifreq,ih] = numpy.mean(new_a) #mean CrossSpectra new_b = numpy.delete(spectra[:,chA,ifreq,ih], noval[0]) - mean_spc0 = numpy.mean(new_b) + spectra[noval,chA,ifreq,ih] = numpy.mean(new_b) #mean Spectra Pair A new_c = numpy.delete(spectra[:,chB,ifreq,ih], noval[0]) - mean_spc1 = numpy.mean(new_c) - spectra[noval,chA,ifreq,ih] = mean_spc0 - spectra[noval,chB,ifreq,ih] = mean_spc1 - cspectra[noval,ii,ifreq,ih] = mean_cspc + spectra[noval,chB,ifreq,ih] = numpy.mean(new_c) #mean Spectra Pair B + ''' func2clean = 10*numpy.log10(numpy.absolute(cspectra[:,ii,ifreq,ih])) @@ -747,7 +747,7 @@ class CleanRayleigh(Operation): axs2[row_ax,col_ax].set_title("Pair "+str(self.crosspairs[ii])) ''' - col_ax += 1 #contador de ploteo columnas + #col_ax += 1 #contador de ploteo columnas ##print(col_ax) ''' title = str(dataOut.datatime)+" nFFT: "+str(ifreq)+" Alt: "+str(self.heights[ih])+ " km" @@ -778,7 +778,7 @@ class CleanRayleigh(Operation): self.bloques[vcross,ifreq,ih,noval] = numpy.nan ''' - print("Getting average of the spectra and cross-spectra from incoherent echoes.") + #print("Getting average of the spectra and cross-spectra from incoherent echoes.") out_spectra = numpy.zeros([self.nChan,self.nFFTPoints,self.nHeights], dtype=float) #+numpy.nan out_cspectra = numpy.zeros([self.nPairs,self.nFFTPoints,self.nHeights], dtype=complex) #+numpy.nan for ih in range(self.nHeights):