diff --git a/schainpy/model/data/jrodata.py b/schainpy/model/data/jrodata.py index 76e926e..e762c46 100644 --- a/schainpy/model/data/jrodata.py +++ b/schainpy/model/data/jrodata.py @@ -446,6 +446,8 @@ class Voltage(JROData): self.flagDataAsBlock = False # Asumo que la data es leida perfil a perfil + self.ippFactor = 1 + self.profileIndex = 0 def getNoisebyHildebrand(self, channel=None): @@ -501,6 +503,21 @@ class Voltage(JROData): return timeInterval + def getAcfRange(self, extrapoints=0): + #print "GET ACF RANGE" + #print "NFFTPoints",self.nFFTPoints + #print "IPPFactor", self.ippFactor + #deltafreq = 10. / ( self.getFmax() / (self.nFFTPoints * self.ippFactor) ) + deltatime = 1./(self.getFmax()/ self.ippFactor) + #print "getFmax",self.getFmax() + #import time + #time.sleep(30) + timerange = deltatime * \ + (numpy.arange(self.nProfiles + extrapoints))#- self.nProfiles / 2.) + #- deltafreq / 2 + #print "timerange",timerange + return timerange + noise = property(getNoise, "I'm the 'nHeights' property.") timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") diff --git a/schainpy/model/graphics/jroplot_voltage.py b/schainpy/model/graphics/jroplot_voltage.py index ed4dfc5..9e08d6e 100644 --- a/schainpy/model/graphics/jroplot_voltage.py +++ b/schainpy/model/graphics/jroplot_voltage.py @@ -8,6 +8,7 @@ import datetime import numpy from figure import Figure +from plotting_codes import * class Scope(Figure): @@ -223,3 +224,203 @@ class Scope(Figure): ftp=ftp, wr_period=wr_period, thisDatetime=thisDatetime) + + +class VoltACFPLot(Figure): + + isConfig = None + __nsubplots = None + PREFIX = 'voltacf' + + def __init__(self, **kwargs): + Figure.__init__(self,**kwargs) + self.isConfig = False + self.__nsubplots = 1 + self.PLOT_CODE = VOLT_ACF_CODE + self.WIDTH = 900 + self.HEIGHT = 700 + self.counter_imagwr= 0 + self.FTP_WEI = None + self.EXP_CODE = None + self.SUB_EXP_CODE = None + self.PLOT_POS = None + + def getSubplots(self) : + ncol = 1 + nrow = 1 + return nrow, ncol + + def setup(self,id, nplots,wintitle,show): + self.nplots = nplots + ncolspan = 1 + colspan = 1 + self.createFigure(id=id, + wintitle = wintitle, + widthplot = self.WIDTH, + heightplot = self.HEIGHT, + show = show) + nrow, ncol = self.getSubplots() + counter = 0 + for y in range(nrow): + for x in range(ncol): + self.addAxes(nrow, ncol*ncolspan,y, x*ncolspan, colspan, 1) + + def run(self,dataOut, id, wintitle="",channelList = None , channel =None, nSamples = None, + nSampleList= None, resolutionFactor=None, xmin= None, xmax = None, ymin=None, ymax=None, + save= False, figpath='./', figfile= None,show= True, ftp= False, wr_period=1, server= None, + folder= None, username =None, password= None, ftp_wei=0 , exp_code=0,sub_exp_code=0,plot_pos=0, + xaxis="time"): + + channel0 = channel + nSamples = nSamples + resFactor = resolutionFactor + + if nSamples == None: + nSamples = 20 + + if resFactor == None: + resFactor = 5 + + if channel0 == None: + channel0 = 0 + else: + if channel0 not in dataOut.channelList: + raise ValueError, "Channel %d is not in %s dataOut.channelList"%(channel0, dataOut.channelList) + + if channelList == None: + channelIndexList = dataOut.channelIndexList + channelList = dataOut.channelList + + 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)) + + + #factor = dataOut.normFactor + y = dataOut.getHeiRange() + #print y, dataOut.heightList[0] + #print "pause" + #import time + #time.sleep(10) + deltaHeight = dataOut.heightList[1]-dataOut.heightList[0] + z = dataOut.data + + shape = dataOut.data.shape + hei_index = numpy.arange(shape[2]) + hei_plot = numpy.arange(nSamples)*resFactor + + if nSampleList is not None: + for nsample in nSampleList: + if nsample not in dataOut.heightList/deltaHeight: + print "Lista available : %s "%(dataOut.heightList/deltaHeight) + raise ValueError, "nsample %d is not in %s dataOut.heightList"%(nsample,dataOut.heightList) + + if nSampleList is not None: + hei_plot = numpy.array(nSampleList)*resFactor + + if hei_plot[-1] >= hei_index[-1]: + print ("La cantidad de puntos en altura es %d y la resolucion es %f Km"%(hei_plot.shape[0],deltaHeight*resFactor )) + raise ValueError, "resFactor %d multiplicado por el valor de %d nSamples es mayor a %d cantidad total de puntos"%(resFactor,nSamples,hei_index[-1]) + + #escalamiento -1 a 1 a resolucion (factor de resolucion en altura)* deltaHeight + #min = numpy.min(z[0,:,0]) + #max =numpy.max(z[0,:,0]) + for i in range(shape[0]): + for j in range(shape[2]): + min = numpy.min(z[i,:,j]) + max = numpy.max(z[i,:,j]) + z[i,:,j]= (((z[i,:,j]-min)/(max-min))*deltaHeight*resFactor + j*deltaHeight+dataOut.heightList[0]) + + + if xaxis == "time": + x = dataOut.getAcfRange()*1000 + zdB = z[channel0,:,hei_plot] + xlabel = "Time (ms)" + ylabel = "VOLT_ACF" + + + thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) + title = wintitle + "VOLT ACF Plot Ch %s %s" %(channel0,thisDatetime.strftime("%d-%b-%Y")) + + if not self.isConfig: + + nplots = 1 + + self.setup(id=id, + nplots=nplots, + wintitle=wintitle, + show=show) + + if xmin == None: xmin = numpy.nanmin(x)#*0.9 + if xmax == None: xmax = numpy.nanmax(x)#*1.1 + if ymin == None: ymin = numpy.nanmin(zdB) + if ymax == None: ymax = numpy.nanmax(zdB) + + print ("El parametro resFactor es %d y la resolucion en altura es %f"%(resFactor,deltaHeight )) + print ("La cantidad de puntos en altura es %d y la nueva resolucion es %f Km"%(hei_plot.shape[0],deltaHeight*resFactor )) + print ("La altura maxima es %d Km"%(hei_plot[-1]*deltaHeight )) + + self.FTP_WEI = ftp_wei + self.EXP_CODE = exp_code + self.SUB_EXP_CODE = sub_exp_code + self.PLOT_POS = plot_pos + + self.isConfig = True + + self.setWinTitle(title) + + title = "VOLT ACF Plot: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) + axes = self.axesList[0] + + legendlabels = ["Range = %dKm" %y[i] for i in hei_plot] + + axes.pmultilineyaxis( x, zdB, + xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, + xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, + ytick_visible=True, nxticks=5, + grid='x') + + self.draw() + + if figfile == None: + str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") + name = str_datetime + if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): + name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith) + figfile = self.getFilename(name) + + self.save(figpath=figpath, + figfile=figfile, + save=save, + ftp=ftp, + wr_period=wr_period, + thisDatetime=thisDatetime) + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/schainpy/model/graphics/plotting_codes.py b/schainpy/model/graphics/plotting_codes.py index dfcc9bd..e83931d 100644 --- a/schainpy/model/graphics/plotting_codes.py +++ b/schainpy/model/graphics/plotting_codes.py @@ -1,6 +1,9 @@ ''' @author: roj-idl71 ''' +#USED IN jroplot_voltage.py +VOLT_ACF_CODE =11 # Volt Autocorrelation function + #USED IN jroplot_spectra.py RTI_CODE = 0 #Range time intensity (RTI). SPEC_CODE = 1 #Spectra (and Cross-spectra) information. @@ -14,6 +17,7 @@ HEIGHT_CODE = 8 #Height profile. PHASE_CODE = 9 #Signal Phase. ACF_CODE = 10 #Autocorrelation function. + POWER_CODE = 16 NOISE_CODE = 17 BEACON_CODE = 18 diff --git a/schainpy/model/proc/jroproc_voltage.py b/schainpy/model/proc/jroproc_voltage.py index 09a0ddb..1262dcc 100644 --- a/schainpy/model/proc/jroproc_voltage.py +++ b/schainpy/model/proc/jroproc_voltage.py @@ -1462,6 +1462,7 @@ class voltACFLags(Operation): dataOut.data = self.tmp dataOut.mode = self.mode dataOut.nLags = len(self.lags) + dataOut.nProfiles = len(self.lags) dataOut.pairsList = pairsList dataOut.nPairs = len(pairsList) dataOut.lagRange = numpy.array(self.lags)*delta diff --git a/schainpy/scripts/test_0001.py b/schainpy/scripts/test_0001.py index bdc8ee9..b6ff8a9 100644 --- a/schainpy/scripts/test_0001.py +++ b/schainpy/scripts/test_0001.py @@ -16,7 +16,7 @@ if __name__ == '__main__': desc = "High altitude experiment SHORT " filename = "schain.xml" - dpath = '/home/soporte/test_avp' + dpath = '/media/soporte/APOLLO/hybrid'#'/home/soporte/test_avp' figpath = "/home/soporte/pics" remotefolder = "/home/wmaster/graficos" t=['0','24'] @@ -31,11 +31,11 @@ if __name__ == '__main__': readUnitConfObj = controllerObj.addReadUnit(datatype='Voltage', path=dpath, - startDate='2019/10/14', + startDate='2019/10/16', # startDate='2018/06/18', - endDate='2019/10/14', + endDate='2019/10/16', # endDate='2018/06/18', - startTime='14:00:00', + startTime='00:00:00', endTime='23:59:59', online=0, walk=0,