diff --git a/schainpy/model/jroplot.py b/schainpy/model/jroplot.py index 58c9e2d..12166df 100644 --- a/schainpy/model/jroplot.py +++ b/schainpy/model/jroplot.py @@ -820,4 +820,148 @@ class CoherencePlot(Figure): if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: self.__isConfig = False - \ No newline at end of file +class RTIfromNoise(Figure): + + __isConfig = None + __nsubplots = None + + WIDTHPROF = None + HEIGHTPROF = None + PREFIX = 'rti' + + def __init__(self): + + self.__timerange = 24*60*60 + self.__isConfig = False + self.__nsubplots = 1 + + self.WIDTH = 800 + self.HEIGHT = 200 + + def getSubplots(self): + + ncol = 1 + nrow = self.nplots + + return nrow, ncol + + def setup(self, idfigure, nplots, wintitle, showprofile=True): + + self.__showprofile = showprofile + self.nplots = nplots + + ncolspan = 1 + colspan = 1 + + self.createFigure(idfigure = idfigure, + wintitle = wintitle, + widthplot = self.WIDTH + self.WIDTHPROF, + heightplot = self.HEIGHT + self.HEIGHTPROF) + + nrow, ncol = self.getSubplots() + + self.addAxes(nrow, ncol, 0, 0, 1, 1) + + + + def __getTimeLim(self, x, xmin, xmax): + + thisdatetime = datetime.datetime.fromtimestamp(numpy.min(x)) + thisdate = datetime.datetime.combine(thisdatetime.date(), datetime.time(0,0,0)) + + #################################################### + #If the x is out of xrange + if xmax < (thisdatetime - thisdate).seconds/(60*60.): + xmin = None + xmax = None + + if xmin == None: + td = thisdatetime - thisdate + xmin = td.seconds/(60*60.) + + if xmax == None: + xmax = xmin + self.__timerange/(60*60.) + + mindt = thisdate + datetime.timedelta(0,0,0,0,0, xmin) + tmin = time.mktime(mindt.timetuple()) + + maxdt = thisdate + datetime.timedelta(0,0,0,0,0, xmax) + tmax = time.mktime(maxdt.timetuple()) + + self.__timerange = tmax - tmin + + return tmin, tmax + + def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', + xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, + timerange=None, + save=False, figpath='./', figfile=None): + + if channelList == None: + channelIndexList = dataOut.channelIndexList + else: + channelIndexList = [] + for channel in channelList: + if channel not in dataOut.channelList: + raise ValueError, "Channel %d is not in dataOut.channelList" + channelIndexList.append(dataOut.channelList.index(channel)) + + if timerange != None: + self.__timerange = timerange + + tmin = None + tmax = None + x = dataOut.getTimeRange() + y = dataOut.getHeiRange() + x1 = dataOut.datatime +# z = 10.*numpy.log10(dataOut.data_spc[channelIndexList,:,:]) +# avg = numpy.average(z, axis=1) + + noise = dataOut.getNoise() + + if not self.__isConfig: + + nplots = len(channelIndexList) + + self.setup(idfigure=idfigure, + nplots=nplots, + wintitle=wintitle, + showprofile=showprofile) + + tmin, tmax = self.__getTimeLim(x, xmin, xmax) + if ymin == None: ymin = numpy.nanmin(y) + if ymax == None: ymax = numpy.nanmax(y) + if zmin == None: zmin = numpy.nanmin(avg)*0.9 + if zmax == None: zmax = numpy.nanmax(avg)*0.9 + + self.__isConfig = True + + thisDatetime = dataOut.datatime + title = "RTI: %s" %(thisDatetime.strftime("%d-%b-%Y")) + xlabel = "Velocity (m/s)" + ylabel = "Range (Km)" + + self.setWinTitle(title) + + for i in range(self.nplots): + title = "Channel %d: %s" %(dataOut.channelList[i], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) + axes = self.axesList[i*self.__nsubplots] + z = avg[i].reshape((1,-1)) + axes.pcolor(x, y, z, + xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, + xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, + ticksize=9, cblabel='', cbsize="1%") + + + self.draw() + + if save: + date = thisDatetime.strftime("%Y%m%d") + if figfile == None: + figfile = self.getFilename(name = date) + + self.saveFigure(figpath, figfile) + + if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: + self.__isConfig = False + \ No newline at end of file diff --git a/schainpy/model/jroprocessing.py b/schainpy/model/jroprocessing.py index 26edf5e..ecd9357 100644 --- a/schainpy/model/jroprocessing.py +++ b/schainpy/model/jroprocessing.py @@ -347,6 +347,22 @@ class VoltageProc(ProcessingUnit): return 1 + + def filterByHeights(self, window): + deltaHeight = self.dataOut.heightList[1] - self.dataOut.heightList[0] + + if window == None: + window = self.dataOut.radarControllerHeaderObj.txA / deltaHeight + + newdelta = deltaHeight * window + r = self.dataOut.data.shape[1] % window + buffer = self.dataOut.data[:,0:self.dataOut.data.shape[1]-r] + buffer = buffer.reshape(self.dataOut.data.shape[0],self.dataOut.data.shape[1]/window,window) + buffer = numpy.average(buffer,2) + self.dataOut.data = buffer + self.dataOut.heightList = numpy.arange(self.dataOut.heightList[0],newdelta*self.dataOut.nHeights/window,newdelta) + + class CohInt(Operation): @@ -544,6 +560,7 @@ class CohInt(Operation): dataOut.timeInterval = dataOut.ippSeconds * dataOut.nCohInt dataOut.flagNoData = False + class Decoder(Operation): __isConfig = False @@ -629,7 +646,7 @@ class Decoder(Operation): if mode == 1: ndatadec, datadec = self.convolutionInTime(data) - + dataOut.data = datadec dataOut.heightList = dataOut.heightList[0:ndatadec+1] @@ -638,7 +655,6 @@ class Decoder(Operation): # dataOut.flagDeflipData = True #asumo q la data no esta sin flip - class SpectraProc(ProcessingUnit): @@ -1071,4 +1087,64 @@ class IncohInt(Operation): dataOut.utctime = avgdatatime dataOut.timeInterval = dataOut.ippSeconds * dataOut.nCohInt * dataOut.nIncohInt * dataOut.nFFTPoints dataOut.flagNoData = False - \ No newline at end of file + +class ProfileSelector(Operation): + + profileIndex = None + # Tamanho total de los perfiles + nProfiles = None + + def __init__(self): + + self.profileIndex = 0 + + def incIndex(self): + self.profileIndex += 1 + + if self.profileIndex >= self.nProfiles: + self.profileIndex = 0 + + def isProfileInRange(self, minIndex, maxIndex): + + if self.profileIndex < minIndex: + return False + + if self.profileIndex > maxIndex: + return False + + return True + + def isProfileInList(self, profileList): + + if self.profileIndex not in profileList: + return False + + return True + + def run(self, dataOut, profileList=None, profileRangeList=None): + + self.nProfiles = dataOut.nProfiles + + if profileList != None: + if not(self.isProfileInList(profileList)): + dataOut.flagNoData = True + else: + dataOut.flagNoData = False + self.incIndex() + return 1 + + + elif profileRangeList != None: + minIndex = profileRangeList[0] + maxIndex = profileRangeList[1] + if not(self.isProfileInRange(minIndex, maxIndex)): + dataOut.flagNoData = True + else: + dataOut.flagNoData = False + self.incIndex() + return 1 + else: + raise ValueError, "ProfileSelector needs profileList or profileRangeList" + + return 0 +