diff --git a/schainpy/model/data/jrodata.py b/schainpy/model/data/jrodata.py index 8ab8ebd..8872571 100644 --- a/schainpy/model/data/jrodata.py +++ b/schainpy/model/data/jrodata.py @@ -242,14 +242,18 @@ the parameters related to distances such as heightList, or heightResolution wich @property def ltctime(self): - + try: + self.timeZone = self.timeZone.decode("utf-8") + except Exception as e: + pass + if self.useLocalTime: if self.timeZone =='lt': return self.utctime - 300 * 60 elif self.timeZone =='ut': return self.utctime else: - log.error("No valid timeZone detected") + log.error("No valid timeZone detected:{}".format(self.timeZone)) return self.utctime @property diff --git a/schainpy/model/graphics/jroplot_parameters.py b/schainpy/model/graphics/jroplot_parameters.py index 7856081..cd7ef10 100644 --- a/schainpy/model/graphics/jroplot_parameters.py +++ b/schainpy/model/graphics/jroplot_parameters.py @@ -107,7 +107,7 @@ class PowerPlot(RTIPlot): def update(self, dataOut): self.update_list(dataOut) data = { - 'pow': 10*numpy.log10(dataOut.data_pow/dataOut.normFactor) + 'pow': 10*numpy.log10(dataOut.data_pow) } try: data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor) diff --git a/schainpy/model/graphics/jroplot_spectra.py b/schainpy/model/graphics/jroplot_spectra.py index 29a1270..f35d4e8 100644 --- a/schainpy/model/graphics/jroplot_spectra.py +++ b/schainpy/model/graphics/jroplot_spectra.py @@ -728,13 +728,13 @@ class RTIPlot(Plot): cmap=plt.get_cmap(self.colormap) ) if self.showprofile: - ax.plot_profile = self.pf_axes[n].plot( - data[self.CODE][n], self.y)[0] + ax.plot_profile = self.pf_axes[n].plot(data[self.CODE][n], self.y)[0] if "noise" in self.data: + ax.plot_noise = self.pf_axes[n].plot(numpy.repeat(data['noise'][n], len(self.y)), self.y, color="k", linestyle="dashed", lw=1)[0] else: - ax.collections.remove(ax.collections[0]) # error while running in 3.12 + ax.collections.remove(ax.collections[0]) ax.plt = ax.pcolormesh(x, y, z[n].T, vmin=self.zmin, vmax=self.zmax, @@ -743,8 +743,7 @@ class RTIPlot(Plot): if self.showprofile: ax.plot_profile.set_data(data[self.CODE][n], self.y) if "noise" in self.data: - ax.plot_noise = self.pf_axes[n].plot(numpy.repeat(data['noise'][n], len(self.y)), self.y, - color="k", linestyle="dashed", lw=1)[0] + ax.plot_noise.set_data(numpy.repeat(data['noise'][n], len(self.y)), self.y) class SpectrogramPlot(Plot): ''' @@ -819,7 +818,7 @@ class SpectrogramPlot(Plot): cmap=plt.get_cmap(self.colormap) ) else: - # ax.collections.remove(ax.collections[0]) # error while running + ax.collections.remove(ax.collections[0]) # error while running ax.plt = ax.pcolormesh(x, y, z[n].T, vmin=self.zmin, vmax=self.zmax, @@ -1541,7 +1540,7 @@ class NoiselessRTIPlot(RTIPlot): ax.plot_profile = self.pf_axes[n].plot(data['noiseless_rti'][n], self.y)[0] else: - # ax.collections.remove(ax.collections[0]) # error while running + ax.collections.remove(ax.collections[0]) # error while running ax.plt = ax.pcolormesh(x, y, z[n].T, vmin=self.zmin, vmax=self.zmax, @@ -1622,7 +1621,7 @@ class OutliersRTIPlot(Plot): else: if self.zlimits is not None: self.zmin, self.zmax = self.zlimits[n] - # ax.collections.remove(ax.collections[0]) # error while running + ax.collections.remove(ax.collections[0]) # error while running ax.plt = ax.pcolormesh(x, y, z[n].T , vmin=self.zmin, vmax=self.zmax, @@ -1700,7 +1699,7 @@ class NIncohIntRTIPlot(Plot): else: if self.zlimits is not None: self.zmin, self.zmax = self.zlimits[n] - # ax.collections.remove(ax.collections[0]) # error while running + ax.collections.remove(ax.collections[0]) # error while running ax.plt = ax.pcolormesh(x, y, z[n].T , vmin=self.zmin, vmax=self.zmax, diff --git a/schainpy/model/io/jroIO_param.py b/schainpy/model/io/jroIO_param.py index d73eec1..c123b5e 100644 --- a/schainpy/model/io/jroIO_param.py +++ b/schainpy/model/io/jroIO_param.py @@ -174,8 +174,8 @@ class HDFReader(Reader, ProcessingUnit): self.__readMetadata2() self.__readData() self.__setBlockList() - if 'type' in self.meta: - self.dataOut = eval(self.meta['type'])() + # if 'type' in self.meta: + # self.dataOut = eval(self.meta['type'])() for attr in self.meta: if "processingHeaderObj" in attr: @@ -268,6 +268,7 @@ class HDFReader(Reader, ProcessingUnit): Reads Metadata ''' meta = {} + if self.description: for key, value in self.description['Metadata'].items(): meta[key] = self.fp[value][()] diff --git a/schainpy/model/io/utilsIO.py b/schainpy/model/io/utilsIO.py index 5c044c7..f46bab1 100644 --- a/schainpy/model/io/utilsIO.py +++ b/schainpy/model/io/utilsIO.py @@ -165,7 +165,7 @@ class MergeH5(object): def readFile(self,fp,ch): '''Read metadata and data''' self.readMetadata(fp,ch) - #print(self.metadataList) + # print(self.metadataList) data = self.readData(fp) for attr in self.meta: if "processingHeaderObj" in attr: @@ -173,7 +173,7 @@ class MergeH5(object): if "radarControllerHeaderObj" in attr: self.flagControllerHeader=True at = attr.split('.') - #print("AT ", at) + # print("AT ", at) if len(at) > 1: setattr(eval("self.ch_dataIn[ch]."+at[0]),at[1], self.meta[attr]) else: @@ -229,7 +229,7 @@ class MergeH5(object): setattr(dataIn, attr, data[attr][:]) else: setattr(dataIn, attr, numpy.squeeze(data[attr][:,:])) - #print("shape in", dataIn.data_spc.shape, len(dataIn.data_spc)) + # print("shape in", dataIn.data_spc.shape, len(dataIn.data_spc)) if self.flag_spc: if dataIn.data_spc.ndim > 3: dataIn.data_spc = dataIn.data_spc[0] @@ -256,6 +256,7 @@ class MergeH5(object): setattr(self.ch_dataIn[ich], self.dataList[i], dataAux[0:self.blocksPerFile]) # print(getattr(self.ch_dataIn[ich], self.dataList[i]).shape) else: + # log.error("Channels number error,iresh_ch=", iresh_ch) return def getLabel(self, name, x=None): if x is None: @@ -289,8 +290,9 @@ class MergeH5(object): return 'pair{:02d}'.format(x) else: return 'channel{:02d}'.format(x) + def readData(self, fp): - #print("read fp: ", fp) + # print("read fp: ", fp) data = {} grp = fp['Data'] for name in grp: @@ -302,7 +304,7 @@ class MergeH5(object): self.flag_snr = True if "nIncohInt" in name: self.flag_nIcoh = True - + # print("spc:",self.flag_spc," pow:",self.flag_pow," snr:", self.flag_snr) if isinstance(grp[name], h5py.Dataset): array = grp[name][()] elif isinstance(grp[name], h5py.Group): @@ -314,7 +316,9 @@ class MergeH5(object): print('Unknown type: {}'.format(name)) data[name] = array return data + def getDataOut(self): + # print("Getting DataOut") self.dataOut = self.ch_dataIn[0].copy() #dataIn #blocks, fft, hei for metadata if self.flagProcessingHeader: self.dataOut.processingHeaderObj = self.ch_dataIn[0].processingHeaderObj.copy() @@ -381,8 +385,8 @@ class MergeH5(object): else: self.dataOut.nIncohInt = self.ch_dataIn[0].nIncohInt #-------------------------------------------------------------------- - #print("utcTime: ", time.shape) - #print("data_spc ",self.dataOut.data_spc.shape) + # print("utcTime: ", time.shape) + # print("data_spc ",self.dataOut.data_spc.shape) if "data_cspc" in self.dataList: pairsList = [pair for pair in itertools.combinations(self.channelList, 2)] #print("PairsList: ", pairsList) @@ -452,8 +456,11 @@ class MergeH5(object): grp.create_dataset(self.getLabel(attribute), data=value) return + def getDsList(self): + # print("Getting DS List", self.dataList) dsList =[] + dataAux = None for i in range(len(self.dataList)): dsDict = {} if hasattr(self.dataOut, self.dataList[i]): @@ -464,7 +471,7 @@ class MergeH5(object): continue if dataAux is None: continue - elif isinstance(dataAux, (int, float, numpy.integer, numpy.float)): + elif isinstance(dataAux, (int, float, numpy.int_, numpy.float_)): dsDict['nDim'] = 0 else: dsDict['nDim'] = len(dataAux.shape) -1 @@ -485,8 +492,9 @@ class MergeH5(object): # dsDict['dsNumber'] = dataAux.shape[0] # dsDict['dtype'] = dataAux.dtype dsList.append(dsDict) - #print(dsList) + # print("dsList: ", dsList) self.dsList = dsList + def clean_dataIn(self): for ch in range(self.nChannels): self.ch_dataIn[ch].data_spc = None @@ -494,9 +502,11 @@ class MergeH5(object): self.ch_dataIn[ch].nIncohInt = None self.meta ={} self.blocksPerFile = None + def writeData(self, outFilename): self.getDsList() fp = h5py.File(outFilename, 'w') + # print("--> Merged file: ",fp) self.writeMetadata(fp) grp = fp.create_group('Data') dtsets = [] @@ -514,7 +524,7 @@ class MergeH5(object): else: sgrp = grp k = -1*(dsInfo['nDim'] - 1) - #print(k, dsInfo['shape'], dsInfo['shape'][k:]) + # print(k, dsInfo['shape'], dsInfo['shape'][k:]) for i in range(dsInfo['dsNumber']): ds = sgrp.create_dataset( self.getLabel(dsInfo['variable'], i),(self.blocksPerFile, ) + dsInfo['shape'][k:], @@ -539,6 +549,7 @@ class MergeH5(object): fp.close() self.clean_dataIn() return + def run(self): if not(self.isConfig): self.setup() @@ -549,7 +560,7 @@ class MergeH5(object): name = self.filenameList[ch][nf] filename = os.path.join(self.inPaths[ch], name) fp = h5py.File(filename, 'r') - #print("Opening file: ",filename) + print("Opening file: ",filename) self.readFile(fp,ch) fp.close() if self.blocksPerFile == None: @@ -559,7 +570,7 @@ class MergeH5(object): print("Error getting DataOut invalid number of blocks") return name = name[-16:] - #print("Final name out: ", name) + # print("Final name out: ", name) outFile = os.path.join(self.pathOut, name) - #print("Outfile: ", outFile) + # print("Outfile: ", outFile) self.writeData(outFile) \ No newline at end of file diff --git a/schainpy/model/proc/jroproc_spectra.py b/schainpy/model/proc/jroproc_spectra.py index c897a75..23d36cd 100644 --- a/schainpy/model/proc/jroproc_spectra.py +++ b/schainpy/model/proc/jroproc_spectra.py @@ -137,12 +137,13 @@ class SpectraProc(ProcessingUnit): def run(self, nProfiles=None, nFFTPoints=None, pairsList=None, ippFactor=None, shift_fft=False, zeroPad=False, zeroPoints=0, runNextUnit=0): + self.dataIn.runNextUnit = runNextUnit try: - type = self.dataIn.type.decode("utf-8") - self.dataIn.type = type + _type = self.dataIn.type.decode("utf-8") + self.dataIn.type = _type except Exception as e: - # print("spc -> ",e) + #print("spc -> ",self.dataIn.type, e) pass if self.dataIn.type == "Spectra":