From 087ce30f3ac50671ec23829b998b70589571fa53 2014-06-19 10:32:18 From: Daniel Valdez Date: 2014-06-19 10:32:18 Subject: [PATCH] Se corrigen bugs en el eje x de los graficos RTI y CoherenceMap, se reduce el numero de puntos o pixeles en X e Y. Al metodo 'getBeaconSignal' se agrega un parametro de entrada 'hei_ref' que indica un rango de referencia. --- diff --git a/schainpy/model/graphics/figure.py b/schainpy/model/graphics/figure.py index dfb06db..a30badd 100644 --- a/schainpy/model/graphics/figure.py +++ b/schainpy/model/graphics/figure.py @@ -64,6 +64,9 @@ class Figure: HEIGHT = None PREFIX = 'fig' + xmin = None + xmax = None + def __init__(self): raise ValueError, "This method is not implemented" @@ -95,39 +98,73 @@ class Figure: return widthscreen, heightscreen - def getTimeLim(self, x, xmin, xmax): + def getTimeLim(self, x, xmin=None, xmax=None, timerange=None): - if self.timerange != None: - txmin = x[0] - x[0]%self.timerange - else: - txmin = numpy.min(x) - - thisdatetime = datetime.datetime.utcfromtimestamp(txmin) - thisdate = datetime.datetime.combine(thisdatetime.date(), datetime.time(0,0,0)) + if self.xmin != None and self.xmax != None: + if timerange == None: + timerange = self.xmax - self.xmin + xmin = self.xmin + timerange + xmax = self.xmax + timerange + + return xmin, xmax - #################################################### - #If the x is out of xrange - if xmax != None: - if xmax < (thisdatetime - thisdate).seconds/(60*60.): - xmin = None - xmax = None - if xmin == None: - td = thisdatetime - thisdate - xmin = td.seconds/(60*60.) + if timerange != None and self.xmin == None and self.xmax == None: + txmin = x[0] - x[0]%timerange + thisdatetime = datetime.datetime.utcfromtimestamp(txmin) + thisdate = datetime.datetime.combine(thisdatetime.date(), datetime.time(0,0,0)) + xmin = (thisdatetime - thisdate).seconds/(60*60.) + xmax = xmin + timerange/(60*60.) - if xmax == None: - xmax = xmin + self.timerange/(60*60.) + + if timerange == None: + txmin = numpy.min(x) + thisdatetime = datetime.datetime.utcfromtimestamp(txmin) + thisdate = datetime.datetime.combine(thisdatetime.date(), datetime.time(0,0,0)) mindt = thisdate + datetime.timedelta(hours=xmin) - datetime.timedelta(seconds=time.timezone) - tmin = time.mktime(mindt.timetuple()) + xmin_sec = time.mktime(mindt.timetuple()) maxdt = thisdate + datetime.timedelta(hours=xmax) - datetime.timedelta(seconds=time.timezone) - tmax = time.mktime(maxdt.timetuple()) - - self.timerange = tmax - tmin - - return tmin, tmax + xmax_sec = time.mktime(maxdt.timetuple()) + + return xmin_sec, xmax_sec + + + + + +# if timerange != None: +# txmin = x[0] - x[0]%timerange +# else: +# txmin = numpy.min(x) +# +# thisdatetime = datetime.datetime.utcfromtimestamp(txmin) +# thisdate = datetime.datetime.combine(thisdatetime.date(), datetime.time(0,0,0)) +# +# #################################################### +# #If the x is out of xrange +# if xmax != None: +# 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(hours=xmin) - datetime.timedelta(seconds=time.timezone) +# tmin = time.mktime(mindt.timetuple()) +# +# maxdt = thisdate + datetime.timedelta(hours=xmax) - datetime.timedelta(seconds=time.timezone) +# tmax = time.mktime(maxdt.timetuple()) +# +# #self.timerange = tmax - tmin +# +# return tmin, tmax def init(self, id, nplots, wintitle): @@ -278,8 +315,8 @@ class Axes: decimationx = None decimationy = None - __MAXNUMX = 1000 - __MAXNUMY = 500 + __MAXNUMX = 300 + __MAXNUMY = 150 def __init__(self, *args): diff --git a/schainpy/model/jroplot.py b/schainpy/model/jroplot.py index 3296503..9d45a2d 100644 --- a/schainpy/model/jroplot.py +++ b/schainpy/model/jroplot.py @@ -459,6 +459,11 @@ class RTIPlot(Figure): self.EXP_CODE = None self.SUB_EXP_CODE = None self.PLOT_POS = None + self.tmin = None + self.tmax = None + + self.xmin = None + self.xmax = None def getSubplots(self): @@ -536,8 +541,8 @@ class RTIPlot(Figure): if timerange != None: self.timerange = timerange - tmin = None - tmax = None + #tmin = None + #tmax = None factor = dataOut.normFactor x = dataOut.getTimeRange() y = dataOut.getHeiRange() @@ -565,7 +570,14 @@ class RTIPlot(Figure): showprofile=showprofile, show=show) - tmin, tmax = self.getTimeLim(x, xmin, xmax) + self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) + +# if timerange != None: +# self.timerange = timerange +# self.xmin, self.tmax = self.getTimeLim(x, xmin, xmax, timerange) + + + if ymin == None: ymin = numpy.nanmin(y) if ymax == None: ymax = numpy.nanmax(y) if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 @@ -581,13 +593,16 @@ class RTIPlot(Figure): self.setWinTitle(title) - + + if ((self.xmax - x[1]) < (x[1]-x[0])): + x[1] = self.xmax + for i in range(self.nplots): title = "Channel %d: %s" %(dataOut.channelList[i]+1, thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) axes = self.axesList[i*self.__nsubplots] zdB = avgdB[i].reshape((1,-1)) axes.pcolorbuffer(x, y, zdB, - xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, + xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, ticksize=9, cblabel='', cbsize="1%") @@ -601,49 +616,54 @@ class RTIPlot(Figure): self.draw() - if lastone: - if dataOut.blocknow >= dataOut.last_block: - if figfile == None: - figfile = self.getFilename(name = self.name) - self.saveFigure(figpath, figfile) - - if (save and not(lastone)): - - self.counter_imagwr += 1 - if (self.counter_imagwr==wr_period): - if figfile == None: - figfile = self.getFilename(name = self.name) - self.saveFigure(figpath, figfile) - - if ftp: - #provisionalmente envia archivos en el formato de la web en tiempo real - name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) - path = '%s%03d' %(self.PREFIX, self.id) - ftp_file = os.path.join(path,'ftp','%s.png'%name) - self.saveFigure(figpath, ftp_file) - ftp_filename = os.path.join(figpath,ftp_file) - self.sendByFTP_Thread(ftp_filename, server, folder, username, password) - self.counter_imagwr = 0 +# if lastone: +# if dataOut.blocknow >= dataOut.last_block: +# if figfile == None: +# figfile = self.getFilename(name = self.name) +# self.saveFigure(figpath, figfile) +# +# if (save and not(lastone)): +# +# self.counter_imagwr += 1 +# if (self.counter_imagwr==wr_period): +# if figfile == None: +# figfile = self.getFilename(name = self.name) +# self.saveFigure(figpath, figfile) +# +# if ftp: +# #provisionalmente envia archivos en el formato de la web en tiempo real +# name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) +# path = '%s%03d' %(self.PREFIX, self.id) +# ftp_file = os.path.join(path,'ftp','%s.png'%name) +# self.saveFigure(figpath, ftp_file) +# ftp_filename = os.path.join(figpath,ftp_file) +# self.sendByFTP_Thread(ftp_filename, server, folder, username, password) +# self.counter_imagwr = 0 +# +# self.counter_imagwr = 0 - self.counter_imagwr = 0 - - if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: - + #if ((dataOut.utctime-time.timezone) >= self.axesList[0].xmax): + if x[1] >= self.axesList[0].xmax: + self.saveFigure(figpath, figfile) self.__isConfig = False - if lastone: - if figfile == None: - figfile = self.getFilename(name = self.name) - self.saveFigure(figpath, figfile) - - if ftp: - #provisionalmente envia archivos en el formato de la web en tiempo real - name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) - path = '%s%03d' %(self.PREFIX, self.id) - ftp_file = os.path.join(path,'ftp','%s.png'%name) - self.saveFigure(figpath, ftp_file) - ftp_filename = os.path.join(figpath,ftp_file) - self.sendByFTP_Thread(ftp_filename, server, folder, username, password) +# if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: +# +# self.__isConfig = False + +# if lastone: +# if figfile == None: +# figfile = self.getFilename(name = self.name) +# self.saveFigure(figpath, figfile) +# +# if ftp: +# #provisionalmente envia archivos en el formato de la web en tiempo real +# name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) +# path = '%s%03d' %(self.PREFIX, self.id) +# ftp_file = os.path.join(path,'ftp','%s.png'%name) +# self.saveFigure(figpath, ftp_file) +# ftp_filename = os.path.join(figpath,ftp_file) +# self.sendByFTP_Thread(ftp_filename, server, folder, username, password) class SpectraPlot(Figure): @@ -1090,6 +1110,9 @@ class CoherenceMap(Figure): self.SUB_EXP_CODE = None self.PLOT_POS = None self.counter_imagwr = 0 + + self.xmin = None + self.xmax = None def getSubplots(self): ncol = 1 @@ -1150,8 +1173,8 @@ class CoherenceMap(Figure): if len(pairsIndexList) > 4: pairsIndexList = pairsIndexList[0:4] - tmin = None - tmax = None +# tmin = None +# tmax = None x = dataOut.getTimeRange() y = dataOut.getHeiRange() @@ -1169,7 +1192,10 @@ class CoherenceMap(Figure): showprofile=showprofile, show=show) - tmin, tmax = self.getTimeLim(x, xmin, xmax) + #tmin, tmax = self.getTimeLim(x, xmin, xmax) + + self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) + if ymin == None: ymin = numpy.nanmin(y) if ymax == None: ymax = numpy.nanmax(y) if zmin == None: zmin = 0. @@ -1186,6 +1212,9 @@ class CoherenceMap(Figure): self.setWinTitle(title) + if ((self.xmax - x[1]) < (x[1]-x[0])): + x[1] = self.xmax + for i in range(self.nplots): pair = dataOut.pairsList[pairsIndexList[i]] @@ -1211,7 +1240,7 @@ class CoherenceMap(Figure): title = "Coherence %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) axes = self.axesList[i*self.__nsubplots*2] axes.pcolorbuffer(x, y, z, - xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, + xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, ticksize=9, cblabel='', colormap=coherence_cmap, cbsize="1%") @@ -1233,7 +1262,7 @@ class CoherenceMap(Figure): title = "Phase %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) axes = self.axesList[i*self.__nsubplots*2 + counter] axes.pcolorbuffer(x, y, z, - xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180, + xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180, xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, ticksize=9, cblabel='', colormap=phase_cmap, cbsize="1%") @@ -1248,29 +1277,33 @@ class CoherenceMap(Figure): self.draw() - if save: - - self.counter_imagwr += 1 - if (self.counter_imagwr==wr_period): - if figfile == None: - figfile = self.getFilename(name = self.name) - self.saveFigure(figpath, figfile) - - if ftp: - #provisionalmente envia archivos en el formato de la web en tiempo real - name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) - path = '%s%03d' %(self.PREFIX, self.id) - ftp_file = os.path.join(path,'ftp','%s.png'%name) - self.saveFigure(figpath, ftp_file) - ftp_filename = os.path.join(figpath,ftp_file) - self.sendByFTP_Thread(ftp_filename, server, folder, username, password) - self.counter_imagwr = 0 - - self.counter_imagwr = 0 - - - if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: + if x[1] >= self.axesList[0].xmax: + self.saveFigure(figpath, figfile) self.__isConfig = False + +# if save: +# +# self.counter_imagwr += 1 +# if (self.counter_imagwr==wr_period): +# if figfile == None: +# figfile = self.getFilename(name = self.name) +# self.saveFigure(figpath, figfile) +# +# if ftp: +# #provisionalmente envia archivos en el formato de la web en tiempo real +# name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) +# path = '%s%03d' %(self.PREFIX, self.id) +# ftp_file = os.path.join(path,'ftp','%s.png'%name) +# self.saveFigure(figpath, ftp_file) +# ftp_filename = os.path.join(figpath,ftp_file) +# self.sendByFTP_Thread(ftp_filename, server, folder, username, password) +# self.counter_imagwr = 0 +# +# self.counter_imagwr = 0 +# +# +# if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: +# self.__isConfig = False class BeaconPhase(Figure): @@ -1428,11 +1461,11 @@ class BeaconPhase(Figure): path = '%s%03d' %(self.PREFIX, self.id) beacon_file = os.path.join(path,'%s.txt'%self.name) self.filename_phase = os.path.join(figpath,beacon_file) - self.save_phase(self.filename_phase) + #self.save_phase(self.filename_phase) #store data beacon phase - self.save_data(self.filename_phase, phase_beacon, thisDatetime) + #self.save_data(self.filename_phase, phase_beacon, thisDatetime) self.setWinTitle(title) diff --git a/schainpy/model/jroprocessing.py b/schainpy/model/jroprocessing.py index 2371486..aef86cd 100644 --- a/schainpy/model/jroprocessing.py +++ b/schainpy/model/jroprocessing.py @@ -919,8 +919,12 @@ class SpectraProc(ProcessingUnit): return 1 - def getBeaconSignal(self, tauindex = 0, channelindex = 0): + def getBeaconSignal(self, tauindex = 0, channelindex = 0, hei_ref=None): newheis = numpy.where(self.dataOut.heightList>self.dataOut.radarControllerHeaderObj.Taus[tauindex]) + + if hei_ref != None: + newheis = numpy.where(self.dataOut.heightList>hei_ref) + minIndex = min(newheis[0]) maxIndex = max(newheis[0]) data_spc = self.dataOut.data_spc[:,:,minIndex:maxIndex+1]