jroplot_parameters.py
2161 lines
| 67.4 KiB
| text/x-python
|
PythonLexer
|
r502 | import os | ||
import datetime | ||||
import numpy | ||||
|
r929 | import inspect | ||
|
r832 | from figure import Figure, isRealtime, isTimeInHourRange | ||
|
r573 | from plotting_codes import * | ||
|
r877 | |||
|
r860 | |||
|
r1148 | class SpcParamPlot(Figure): | ||
|
r1001 | |||
isConfig = None | ||||
__nsubplots = None | ||||
WIDTHPROF = None | ||||
HEIGHTPROF = None | ||||
|
r1148 | PREFIX = 'SpcParam' | ||
|
r1001 | |||
def __init__(self, **kwargs): | ||||
Figure.__init__(self, **kwargs) | ||||
self.isConfig = False | ||||
self.__nsubplots = 1 | ||||
self.WIDTH = 250 | ||||
self.HEIGHT = 250 | ||||
self.WIDTHPROF = 120 | ||||
self.HEIGHTPROF = 0 | ||||
self.counter_imagwr = 0 | ||||
self.PLOT_CODE = SPEC_CODE | ||||
self.FTP_WEI = None | ||||
self.EXP_CODE = None | ||||
self.SUB_EXP_CODE = None | ||||
self.PLOT_POS = None | ||||
self.__xfilter_ena = False | ||||
self.__yfilter_ena = False | ||||
def getSubplots(self): | ||||
ncol = int(numpy.sqrt(self.nplots)+0.9) | ||||
nrow = int(self.nplots*1./ncol + 0.9) | ||||
return nrow, ncol | ||||
def setup(self, id, nplots, wintitle, showprofile=True, show=True): | ||||
self.__showprofile = showprofile | ||||
self.nplots = nplots | ||||
ncolspan = 1 | ||||
colspan = 1 | ||||
if showprofile: | ||||
ncolspan = 3 | ||||
colspan = 2 | ||||
self.__nsubplots = 2 | ||||
self.createFigure(id = id, | ||||
wintitle = wintitle, | ||||
widthplot = self.WIDTH + self.WIDTHPROF, | ||||
heightplot = self.HEIGHT + self.HEIGHTPROF, | ||||
show=show) | ||||
nrow, ncol = self.getSubplots() | ||||
counter = 0 | ||||
for y in range(nrow): | ||||
for x in range(ncol): | ||||
if counter >= self.nplots: | ||||
break | ||||
self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | ||||
if showprofile: | ||||
self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | ||||
counter += 1 | ||||
def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True, | ||||
xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=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, realtime=False, | ||||
|
r1148 | xaxis="frequency", colormap='jet', normFactor=None , Selector = 0): | ||
|
r1001 | |||
""" | ||||
Input: | ||||
dataOut : | ||||
id : | ||||
wintitle : | ||||
channelList : | ||||
showProfile : | ||||
xmin : None, | ||||
xmax : None, | ||||
ymin : None, | ||||
ymax : None, | ||||
zmin : None, | ||||
zmax : None | ||||
""" | ||||
if realtime: | ||||
if not(isRealtime(utcdatatime = dataOut.utctime)): | ||||
print 'Skipping this plot function' | ||||
return | ||||
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" %channel | ||||
channelIndexList.append(dataOut.channelList.index(channel)) | ||||
# if normFactor is None: | ||||
# factor = dataOut.normFactor | ||||
# else: | ||||
# factor = normFactor | ||||
if xaxis == "frequency": | ||||
|
r1148 | x = dataOut.spcparam_range[0] | ||
|
r1001 | xlabel = "Frequency (kHz)" | ||
elif xaxis == "time": | ||||
|
r1148 | x = dataOut.spcparam_range[1] | ||
|
r1001 | xlabel = "Time (ms)" | ||
|
r1123 | else: | ||
|
r1148 | x = dataOut.spcparam_range[2] | ||
|
r1001 | xlabel = "Velocity (m/s)" | ||
|
r1149 | print "Vmax=",x[-1] | ||
|
r1001 | |||
ylabel = "Range (Km)" | ||||
y = dataOut.getHeiRange() | ||||
|
r1149 | z = dataOut.SPCparam[Selector] /1966080.0#/ dataOut.normFactor#GauSelector] #dataOut.data_spc/factor | ||
|
r1148 | #print 'GausSPC', z[0,32,10:40] | ||
|
r1001 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | ||
zdB = 10*numpy.log10(z) | ||||
avg = numpy.average(z, axis=1) | ||||
avgdB = 10*numpy.log10(avg) | ||||
noise = dataOut.spc_noise | ||||
noisedB = 10*numpy.log10(noise) | ||||
thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) | ||||
title = wintitle + " Spectra" | ||||
if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): | ||||
title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith) | ||||
if not self.isConfig: | ||||
nplots = len(channelIndexList) | ||||
self.setup(id=id, | ||||
nplots=nplots, | ||||
wintitle=wintitle, | ||||
showprofile=showprofile, | ||||
show=show) | ||||
if xmin == None: xmin = numpy.nanmin(x) | ||||
if xmax == None: xmax = numpy.nanmax(x) | ||||
if ymin == None: ymin = numpy.nanmin(y) | ||||
if ymax == None: ymax = numpy.nanmax(y) | ||||
if zmin == None: zmin = numpy.floor(numpy.nanmin(noisedB)) - 3 | ||||
if zmax == None: zmax = numpy.ceil(numpy.nanmax(avgdB)) + 3 | ||||
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) | ||||
for i in range(self.nplots): | ||||
index = channelIndexList[i] | ||||
str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) | ||||
title = "Channel %d: %4.2fdB: %s" %(dataOut.channelList[index], noisedB[index], str_datetime) | ||||
if len(dataOut.beam.codeList) != 0: | ||||
title = "Ch%d:%4.2fdB,%2.2f,%2.2f:%s" %(dataOut.channelList[index], noisedB[index], dataOut.beam.azimuthList[index], dataOut.beam.zenithList[index], str_datetime) | ||||
axes = self.axesList[i*self.__nsubplots] | ||||
axes.pcolor(x, y, zdB[index,:,:], | ||||
xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | ||||
xlabel=xlabel, ylabel=ylabel, title=title, colormap=colormap, | ||||
ticksize=9, cblabel='') | ||||
if self.__showprofile: | ||||
axes = self.axesList[i*self.__nsubplots +1] | ||||
axes.pline(avgdB[index,:], y, | ||||
xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, | ||||
xlabel='dB', ylabel='', title='', | ||||
ytick_visible=False, | ||||
grid='x') | ||||
noiseline = numpy.repeat(noisedB[index], len(y)) | ||||
axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2) | ||||
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) | ||||
|
r502 | class MomentsPlot(Figure): | ||
|
r897 | |||
|
r502 | isConfig = None | ||
__nsubplots = None | ||||
|
r897 | |||
|
r502 | WIDTHPROF = None | ||
HEIGHTPROF = None | ||||
PREFIX = 'prm' | ||||
|
r897 | |||
def __init__(self, **kwargs): | ||||
Figure.__init__(self, **kwargs) | ||||
|
r502 | self.isConfig = False | ||
self.__nsubplots = 1 | ||||
|
r897 | |||
|
r502 | self.WIDTH = 280 | ||
self.HEIGHT = 250 | ||||
self.WIDTHPROF = 120 | ||||
self.HEIGHTPROF = 0 | ||||
self.counter_imagwr = 0 | ||||
|
r897 | |||
|
r573 | self.PLOT_CODE = MOMENTS_CODE | ||
|
r897 | |||
|
r502 | self.FTP_WEI = None | ||
self.EXP_CODE = None | ||||
self.SUB_EXP_CODE = None | ||||
self.PLOT_POS = None | ||||
|
r897 | |||
|
r502 | def getSubplots(self): | ||
|
r897 | |||
|
r502 | ncol = int(numpy.sqrt(self.nplots)+0.9) | ||
nrow = int(self.nplots*1./ncol + 0.9) | ||||
|
r897 | |||
|
r502 | return nrow, ncol | ||
|
r897 | |||
|
r502 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | ||
|
r897 | |||
|
r502 | self.__showprofile = showprofile | ||
self.nplots = nplots | ||||
|
r897 | |||
|
r502 | ncolspan = 1 | ||
colspan = 1 | ||||
if showprofile: | ||||
ncolspan = 3 | ||||
colspan = 2 | ||||
self.__nsubplots = 2 | ||||
|
r897 | |||
|
r502 | self.createFigure(id = id, | ||
wintitle = wintitle, | ||||
widthplot = self.WIDTH + self.WIDTHPROF, | ||||
heightplot = self.HEIGHT + self.HEIGHTPROF, | ||||
show=show) | ||||
|
r897 | |||
|
r502 | nrow, ncol = self.getSubplots() | ||
|
r897 | |||
|
r502 | counter = 0 | ||
for y in range(nrow): | ||||
for x in range(ncol): | ||||
|
r897 | |||
|
r502 | if counter >= self.nplots: | ||
break | ||||
|
r897 | |||
|
r502 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | ||
|
r897 | |||
|
r502 | if showprofile: | ||
self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | ||||
|
r897 | |||
|
r502 | counter += 1 | ||
|
r897 | |||
|
r502 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True, | ||
xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | ||||
|
r568 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, | ||
|
r502 | server=None, folder=None, username=None, password=None, | ||
ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False): | ||||
|
r897 | |||
|
r502 | """ | ||
|
r897 | |||
|
r502 | Input: | ||
dataOut : | ||||
id : | ||||
wintitle : | ||||
channelList : | ||||
showProfile : | ||||
xmin : None, | ||||
xmax : None, | ||||
ymin : None, | ||||
ymax : None, | ||||
zmin : None, | ||||
zmax : None | ||||
""" | ||||
|
r897 | |||
|
r502 | if dataOut.flagNoData: | ||
return None | ||||
|
r897 | |||
|
r502 | if realtime: | ||
if not(isRealtime(utcdatatime = dataOut.utctime)): | ||||
print 'Skipping this plot function' | ||||
return | ||||
|
r897 | |||
|
r502 | 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)) | ||||
|
r897 | |||
|
r502 | factor = dataOut.normFactor | ||
|
r543 | x = dataOut.abscissaList | ||
y = dataOut.heightList | ||||
|
r897 | |||
|
r502 | z = dataOut.data_pre[channelIndexList,:,:]/factor | ||
|
r897 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | ||
|
r502 | avg = numpy.average(z, axis=1) | ||
noise = dataOut.noise/factor | ||||
|
r897 | |||
|
r502 | zdB = 10*numpy.log10(z) | ||
avgdB = 10*numpy.log10(avg) | ||||
noisedB = 10*numpy.log10(noise) | ||||
|
r897 | |||
|
r502 | #thisDatetime = dataOut.datatime | ||
|
r568 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) | ||
|
r897 | title = wintitle + " Parameters" | ||
|
r502 | xlabel = "Velocity (m/s)" | ||
ylabel = "Range (Km)" | ||||
|
r897 | |||
|
r786 | update_figfile = False | ||
|
r897 | |||
|
r502 | if not self.isConfig: | ||
|
r897 | |||
|
r502 | nplots = len(channelIndexList) | ||
|
r897 | |||
|
r502 | self.setup(id=id, | ||
nplots=nplots, | ||||
wintitle=wintitle, | ||||
showprofile=showprofile, | ||||
show=show) | ||||
|
r897 | |||
|
r502 | if xmin == None: xmin = numpy.nanmin(x) | ||
if xmax == None: xmax = numpy.nanmax(x) | ||||
if ymin == None: ymin = numpy.nanmin(y) | ||||
if ymax == None: ymax = numpy.nanmax(y) | ||||
if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 | ||||
if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 | ||||
|
r897 | |||
|
r502 | self.FTP_WEI = ftp_wei | ||
self.EXP_CODE = exp_code | ||||
self.SUB_EXP_CODE = sub_exp_code | ||||
self.PLOT_POS = plot_pos | ||||
|
r897 | |||
|
r502 | self.isConfig = True | ||
|
r786 | update_figfile = True | ||
|
r897 | |||
|
r502 | self.setWinTitle(title) | ||
|
r897 | |||
|
r502 | for i in range(self.nplots): | ||
str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) | ||||
|
r713 | title = "Channel %d: %4.2fdB: %s" %(dataOut.channelList[i], noisedB[i], str_datetime) | ||
|
r502 | axes = self.axesList[i*self.__nsubplots] | ||
axes.pcolor(x, y, zdB[i,:,:], | ||||
xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | ||||
xlabel=xlabel, ylabel=ylabel, title=title, | ||||
ticksize=9, cblabel='') | ||||
#Mean Line | ||||
mean = dataOut.data_param[i, 1, :] | ||||
axes.addpline(mean, y, idline=0, color="black", linestyle="solid", lw=1) | ||||
|
r897 | |||
|
r502 | if self.__showprofile: | ||
axes = self.axesList[i*self.__nsubplots +1] | ||||
axes.pline(avgdB[i], y, | ||||
xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, | ||||
xlabel='dB', ylabel='', title='', | ||||
ytick_visible=False, | ||||
grid='x') | ||||
|
r897 | |||
|
r502 | noiseline = numpy.repeat(noisedB[i], len(y)) | ||
axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2) | ||||
|
r897 | |||
|
r502 | self.draw() | ||
|
r897 | |||
|
r573 | self.save(figpath=figpath, | ||
figfile=figfile, | ||||
save=save, | ||||
ftp=ftp, | ||||
wr_period=wr_period, | ||||
thisDatetime=thisDatetime) | ||||
|
r897 | |||
|
r502 | |||
class SkyMapPlot(Figure): | ||||
|
r897 | |||
|
r502 | __isConfig = None | ||
__nsubplots = None | ||||
|
r897 | |||
|
r502 | WIDTHPROF = None | ||
HEIGHTPROF = None | ||||
|
r608 | PREFIX = 'mmap' | ||
|
r897 | |||
def __init__(self, **kwargs): | ||||
Figure.__init__(self, **kwargs) | ||||
|
r793 | self.isConfig = False | ||
|
r502 | self.__nsubplots = 1 | ||
|
r897 | |||
|
r502 | # self.WIDTH = 280 | ||
# self.HEIGHT = 250 | ||||
self.WIDTH = 600 | ||||
self.HEIGHT = 600 | ||||
self.WIDTHPROF = 120 | ||||
self.HEIGHTPROF = 0 | ||||
self.counter_imagwr = 0 | ||||
|
r897 | |||
|
r608 | self.PLOT_CODE = MSKYMAP_CODE | ||
|
r897 | |||
|
r502 | self.FTP_WEI = None | ||
self.EXP_CODE = None | ||||
self.SUB_EXP_CODE = None | ||||
self.PLOT_POS = None | ||||
|
r897 | |||
|
r502 | def getSubplots(self): | ||
|
r897 | |||
|
r502 | ncol = int(numpy.sqrt(self.nplots)+0.9) | ||
nrow = int(self.nplots*1./ncol + 0.9) | ||||
|
r897 | |||
|
r502 | return nrow, ncol | ||
|
r897 | |||
|
r502 | def setup(self, id, nplots, wintitle, showprofile=False, show=True): | ||
|
r897 | |||
|
r502 | self.__showprofile = showprofile | ||
self.nplots = nplots | ||||
|
r897 | |||
|
r502 | ncolspan = 1 | ||
colspan = 1 | ||||
|
r897 | |||
|
r502 | self.createFigure(id = id, | ||
wintitle = wintitle, | ||||
widthplot = self.WIDTH, #+ self.WIDTHPROF, | ||||
heightplot = self.HEIGHT,# + self.HEIGHTPROF, | ||||
show=show) | ||||
|
r897 | |||
nrow, ncol = 1,1 | ||||
|
r502 | counter = 0 | ||
x = 0 | ||||
y = 0 | ||||
self.addAxes(1, 1, 0, 0, 1, 1, True) | ||||
def run(self, dataOut, id, wintitle="", channelList=None, showprofile=False, | ||||
|
r804 | tmin=0, tmax=24, timerange=None, | ||
|
r502 | 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, realtime=False): | ||||
|
r897 | |||
|
r502 | """ | ||
|
r897 | |||
|
r502 | Input: | ||
dataOut : | ||||
id : | ||||
wintitle : | ||||
channelList : | ||||
showProfile : | ||||
xmin : None, | ||||
xmax : None, | ||||
ymin : None, | ||||
ymax : None, | ||||
zmin : None, | ||||
zmax : None | ||||
""" | ||||
|
r897 | |||
|
r804 | arrayParameters = dataOut.data_param | ||
|
r502 | error = arrayParameters[:,-1] | ||
indValid = numpy.where(error == 0)[0] | ||||
finalMeteor = arrayParameters[indValid,:] | ||||
|
r804 | finalAzimuth = finalMeteor[:,3] | ||
finalZenith = finalMeteor[:,4] | ||||
|
r897 | |||
|
r502 | x = finalAzimuth*numpy.pi/180 | ||
y = finalZenith | ||||
|
r897 | x1 = [dataOut.ltctime, dataOut.ltctime] | ||
|
r502 | #thisDatetime = dataOut.datatime | ||
|
r804 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime) | ||
|
r897 | title = wintitle + " Parameters" | ||
|
r502 | xlabel = "Zonal Zenith Angle (deg) " | ||
ylabel = "Meridional Zenith Angle (deg)" | ||||
|
r786 | update_figfile = False | ||
|
r897 | |||
|
r793 | if not self.isConfig: | ||
|
r897 | |||
|
r502 | nplots = 1 | ||
|
r897 | |||
|
r502 | self.setup(id=id, | ||
nplots=nplots, | ||||
wintitle=wintitle, | ||||
showprofile=showprofile, | ||||
show=show) | ||||
|
r897 | |||
|
r787 | if self.xmin is None and self.xmax is None: | ||
self.xmin, self.xmax = self.getTimeLim(x1, tmin, tmax, timerange) | ||||
|
r897 | |||
|
r786 | if timerange != None: | ||
self.timerange = timerange | ||||
else: | ||||
self.timerange = self.xmax - self.xmin | ||||
|
r897 | |||
|
r502 | self.FTP_WEI = ftp_wei | ||
self.EXP_CODE = exp_code | ||||
self.SUB_EXP_CODE = sub_exp_code | ||||
self.PLOT_POS = plot_pos | ||||
self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | ||||
self.firstdate = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) | ||||
|
r793 | self.isConfig = True | ||
|
r786 | update_figfile = True | ||
|
r897 | |||
|
r502 | self.setWinTitle(title) | ||
|
r897 | |||
|
r502 | i = 0 | ||
str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) | ||||
axes = self.axesList[i*self.__nsubplots] | ||||
nevents = axes.x_buffer.shape[0] + x.shape[0] | ||||
title = "Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n" %(self.firstdate,str_datetime,nevents) | ||||
|
r897 | axes.polar(x, y, | ||
|
r502 | title=title, xlabel=xlabel, ylabel=ylabel, | ||
ticksize=9, cblabel='') | ||||
|
r897 | |||
|
r502 | self.draw() | ||
|
r897 | |||
|
r573 | self.save(figpath=figpath, | ||
figfile=figfile, | ||||
save=save, | ||||
ftp=ftp, | ||||
wr_period=wr_period, | ||||
|
r785 | thisDatetime=thisDatetime, | ||
|
r786 | update_figfile=update_figfile) | ||
|
r897 | |||
|
r786 | if dataOut.ltctime >= self.xmax: | ||
|
r797 | self.isConfigmagwr = wr_period | ||
|
r793 | self.isConfig = False | ||
|
r786 | update_figfile = True | ||
axes.__firsttime = True | ||||
self.xmin += self.timerange | ||||
self.xmax += self.timerange | ||||
|
r608 | |||
|
r897 | |||
|
r502 | class WindProfilerPlot(Figure): | ||
|
r897 | |||
|
r502 | __isConfig = None | ||
__nsubplots = None | ||||
|
r897 | |||
|
r502 | WIDTHPROF = None | ||
HEIGHTPROF = None | ||||
PREFIX = 'wind' | ||||
|
r897 | |||
def __init__(self, **kwargs): | ||||
Figure.__init__(self, **kwargs) | ||||
|
r608 | self.timerange = None | ||
|
r793 | self.isConfig = False | ||
|
r502 | self.__nsubplots = 1 | ||
|
r897 | |||
|
r502 | self.WIDTH = 800 | ||
|
r841 | self.HEIGHT = 300 | ||
|
r502 | self.WIDTHPROF = 120 | ||
self.HEIGHTPROF = 0 | ||||
self.counter_imagwr = 0 | ||||
|
r897 | |||
|
r573 | self.PLOT_CODE = WIND_CODE | ||
|
r897 | |||
|
r502 | self.FTP_WEI = None | ||
self.EXP_CODE = None | ||||
self.SUB_EXP_CODE = None | ||||
self.PLOT_POS = None | ||||
|
r897 | self.tmin = None | ||
|
r502 | self.tmax = None | ||
|
r897 | |||
|
r502 | self.xmin = None | ||
self.xmax = None | ||||
|
r897 | |||
|
r502 | self.figfile = None | ||
|
r897 | |||
|
r502 | def getSubplots(self): | ||
|
r897 | |||
|
r502 | ncol = 1 | ||
nrow = self.nplots | ||||
|
r897 | |||
|
r502 | return nrow, ncol | ||
|
r897 | |||
|
r502 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | ||
|
r897 | |||
|
r502 | self.__showprofile = showprofile | ||
self.nplots = nplots | ||||
|
r897 | |||
|
r502 | ncolspan = 1 | ||
colspan = 1 | ||||
|
r897 | |||
|
r502 | self.createFigure(id = id, | ||
wintitle = wintitle, | ||||
widthplot = self.WIDTH + self.WIDTHPROF, | ||||
heightplot = self.HEIGHT + self.HEIGHTPROF, | ||||
show=show) | ||||
|
r897 | |||
|
r502 | nrow, ncol = self.getSubplots() | ||
|
r897 | |||
|
r502 | counter = 0 | ||
for y in range(nrow): | ||||
if counter >= self.nplots: | ||||
break | ||||
|
r897 | |||
self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1) | ||||
|
r502 | counter += 1 | ||
|
r897 | |||
|
r608 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile='False', | ||
|
r502 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | ||
zmax_ver = None, zmin_ver = None, SNRmin = None, SNRmax = None, | ||||
timerange=None, SNRthresh = None, | ||||
|
r568 | save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True, | ||
|
r502 | server=None, folder=None, username=None, password=None, | ||
|
r897 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): | ||
|
r502 | """ | ||
|
r897 | |||
|
r502 | Input: | ||
dataOut : | ||||
id : | ||||
wintitle : | ||||
channelList : | ||||
showProfile : | ||||
xmin : None, | ||||
xmax : None, | ||||
ymin : None, | ||||
ymax : None, | ||||
zmin : None, | ||||
zmax : None | ||||
""" | ||||
|
r897 | |||
|
r612 | # if timerange is not None: | ||
|
r608 | # self.timerange = timerange | ||
|
r897 | # | ||
|
r608 | # tmin = None | ||
# tmax = None | ||||
|
r870 | |||
|
r1001 | x = dataOut.getTimeRange1(dataOut.paramInterval) | ||
|
r1146 | y = dataOut.heightList | ||
|
r1018 | z = dataOut.data_output.copy() | ||
|
r502 | nplots = z.shape[0] #Number of wind dimensions estimated | ||
nplotsw = nplots | ||||
|
r897 | |||
|
r502 | #If there is a SNR function defined | ||
|
r612 | if dataOut.data_SNR is not None: | ||
|
r502 | nplots += 1 | ||
|
r1123 | SNR = dataOut.data_SNR[0] | ||
SNRavg = SNR#numpy.average(SNR, axis=0) | ||||
|
r897 | |||
|
r502 | SNRdB = 10*numpy.log10(SNR) | ||
SNRavgdB = 10*numpy.log10(SNRavg) | ||||
|
r897 | |||
|
r1123 | if SNRthresh == None: | ||
SNRthresh = -5.0 | ||||
|
r502 | ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0] | ||
|
r897 | |||
|
r502 | for i in range(nplotsw): | ||
z[i,ind] = numpy.nan | ||||
|
r877 | |||
|
r870 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime) | ||
|
r877 | #thisDatetime = datetime.datetime.now() | ||
|
r502 | title = wintitle + "Wind" | ||
xlabel = "" | ||||
|
r841 | ylabel = "Height (km)" | ||
|
r897 | update_figfile = False | ||
|
r793 | if not self.isConfig: | ||
|
r897 | |||
|
r502 | self.setup(id=id, | ||
nplots=nplots, | ||||
wintitle=wintitle, | ||||
showprofile=showprofile, | ||||
show=show) | ||||
|
r897 | |||
|
r612 | if timerange is not None: | ||
|
r608 | self.timerange = timerange | ||
|
r897 | |||
|
r567 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) | ||
|
r897 | |||
|
r870 | if ymin == None: ymin = numpy.nanmin(y) | ||
if ymax == None: ymax = numpy.nanmax(y) | ||||
|
r897 | |||
|
r502 | if zmax == None: zmax = numpy.nanmax(abs(z[range(2),:])) | ||
#if numpy.isnan(zmax): zmax = 50 | ||||
if zmin == None: zmin = -zmax | ||||
|
r897 | |||
|
r502 | if nplotsw == 3: | ||
if zmax_ver == None: zmax_ver = numpy.nanmax(abs(z[2,:])) | ||||
if zmin_ver == None: zmin_ver = -zmax_ver | ||||
|
r897 | |||
|
r870 | if dataOut.data_SNR is not None: | ||
if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB) | ||||
|
r897 | if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB) | ||
|
r502 | self.FTP_WEI = ftp_wei | ||
self.EXP_CODE = exp_code | ||||
self.SUB_EXP_CODE = sub_exp_code | ||||
self.PLOT_POS = plot_pos | ||||
|
r897 | |||
|
r502 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | ||
|
r793 | self.isConfig = True | ||
|
r608 | self.figfile = figfile | ||
|
r786 | update_figfile = True | ||
|
r897 | |||
|
r502 | self.setWinTitle(title) | ||
|
r897 | |||
|
r870 | if ((self.xmax - x[1]) < (x[1]-x[0])): | ||
x[1] = self.xmax | ||||
|
r897 | |||
|
r502 | strWind = ['Zonal', 'Meridional', 'Vertical'] | ||
strCb = ['Velocity (m/s)','Velocity (m/s)','Velocity (cm/s)'] | ||||
zmaxVector = [zmax, zmax, zmax_ver] | ||||
zminVector = [zmin, zmin, zmin_ver] | ||||
windFactor = [1,1,100] | ||||
|
r897 | |||
|
r502 | for i in range(nplotsw): | ||
|
r897 | |||
|
r502 | title = "%s Wind: %s" %(strWind[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | ||
axes = self.axesList[i*self.__nsubplots] | ||||
|
r897 | |||
|
r870 | z1 = z[i,:].reshape((1,-1))*windFactor[i] | ||
|
r1146 | |||
print 'x', x | ||||
print datetime.datetime.utcfromtimestamp(x[0]) | ||||
print datetime.datetime.utcfromtimestamp(x[1]) | ||||
|
r897 | #z1=numpy.ma.masked_where(z1==0.,z1) | ||
|
r877 | |||
|
r502 | axes.pcolorbuffer(x, y, z1, | ||
xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zminVector[i], zmax=zmaxVector[i], | ||||
xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | ||||
|
r870 | ticksize=9, cblabel=strCb[i], cbsize="1%", colormap="seismic" ) | ||
|
r897 | |||
|
r612 | if dataOut.data_SNR is not None: | ||
|
r897 | i += 1 | ||
|
r502 | title = "Signal Noise Ratio (SNR): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | ||
axes = self.axesList[i*self.__nsubplots] | ||||
|
r877 | SNRavgdB = SNRavgdB.reshape((1,-1)) | ||
|
r502 | axes.pcolorbuffer(x, y, SNRavgdB, | ||
xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax, | ||||
xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | ||||
ticksize=9, cblabel='', cbsize="1%", colormap="jet") | ||||
|
r897 | |||
|
r502 | self.draw() | ||
|
r897 | |||
|
r573 | self.save(figpath=figpath, | ||
figfile=figfile, | ||||
save=save, | ||||
ftp=ftp, | ||||
wr_period=wr_period, | ||||
thisDatetime=thisDatetime, | ||||
|
r786 | update_figfile=update_figfile) | ||
|
r897 | |||
|
r1001 | if dataOut.ltctime + dataOut.paramInterval >= self.xmax: | ||
|
r870 | self.counter_imagwr = wr_period | ||
|
r852 | self.isConfig = False | ||
update_figfile = True | ||||
|
r897 | |||
|
r786 | |||
|
r832 | class ParametersPlot(Figure): | ||
|
r897 | |||
|
r832 | __isConfig = None | ||
__nsubplots = None | ||||
|
r897 | |||
|
r832 | WIDTHPROF = None | ||
HEIGHTPROF = None | ||||
PREFIX = 'param' | ||||
nplots = None | ||||
nchan = None | ||||
|
r897 | |||
def __init__(self, **kwargs): | ||||
Figure.__init__(self, **kwargs) | ||||
|
r832 | self.timerange = None | ||
self.isConfig = False | ||||
self.__nsubplots = 1 | ||||
|
r897 | |||
|
r832 | self.WIDTH = 800 | ||
self.HEIGHT = 180 | ||||
self.WIDTHPROF = 120 | ||||
self.HEIGHTPROF = 0 | ||||
self.counter_imagwr = 0 | ||||
|
r897 | |||
|
r832 | self.PLOT_CODE = RTI_CODE | ||
|
r897 | |||
|
r832 | self.FTP_WEI = None | ||
self.EXP_CODE = None | ||||
self.SUB_EXP_CODE = None | ||||
self.PLOT_POS = None | ||||
|
r897 | self.tmin = None | ||
|
r832 | self.tmax = None | ||
|
r897 | |||
|
r832 | self.xmin = None | ||
self.xmax = None | ||||
|
r897 | |||
|
r832 | self.figfile = None | ||
|
r897 | |||
|
r832 | def getSubplots(self): | ||
|
r897 | |||
|
r832 | ncol = 1 | ||
nrow = self.nplots | ||||
|
r897 | |||
|
r832 | return nrow, ncol | ||
|
r897 | |||
|
r832 | def setup(self, id, nplots, wintitle, show=True): | ||
self.nplots = nplots | ||||
|
r897 | |||
|
r832 | ncolspan = 1 | ||
colspan = 1 | ||||
|
r897 | |||
|
r832 | self.createFigure(id = id, | ||
wintitle = wintitle, | ||||
widthplot = self.WIDTH + self.WIDTHPROF, | ||||
heightplot = self.HEIGHT + self.HEIGHTPROF, | ||||
show=show) | ||||
|
r897 | |||
|
r832 | nrow, ncol = self.getSubplots() | ||
|
r897 | |||
|
r832 | counter = 0 | ||
for y in range(nrow): | ||||
for x in range(ncol): | ||||
|
r897 | |||
|
r832 | if counter >= self.nplots: | ||
break | ||||
|
r897 | |||
|
r832 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | ||
|
r897 | |||
|
r832 | counter += 1 | ||
|
r897 | |||
|
r1001 | def run(self, dataOut, id, wintitle="", channelList=None, paramIndex = 0, colormap="jet", | ||
|
r832 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, timerange=None, | ||
showSNR=False, SNRthresh = -numpy.inf, SNRmin=None, SNRmax=None, | ||||
save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True, | ||||
server=None, folder=None, username=None, password=None, | ||||
|
r1001 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, HEIGHT=None): | ||
|
r832 | """ | ||
|
r897 | |||
|
r832 | Input: | ||
dataOut : | ||||
id : | ||||
wintitle : | ||||
channelList : | ||||
showProfile : | ||||
xmin : None, | ||||
xmax : None, | ||||
ymin : None, | ||||
ymax : None, | ||||
zmin : None, | ||||
zmax : None | ||||
""" | ||||
|
r1001 | |||
if HEIGHT is not None: | ||||
self.HEIGHT = HEIGHT | ||||
|
r832 | if not isTimeInHourRange(dataOut.datatime, xmin, xmax): | ||
return | ||||
|
r897 | |||
|
r832 | if channelList == None: | ||
|
r841 | channelIndexList = range(dataOut.data_param.shape[0]) | ||
|
r832 | 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)) | ||||
|
r897 | |||
|
r832 | x = dataOut.getTimeRange1(dataOut.paramInterval) | ||
y = dataOut.getHeiRange() | ||||
|
r897 | |||
|
r841 | if dataOut.data_param.ndim == 3: | ||
z = dataOut.data_param[channelIndexList,paramIndex,:] | ||||
else: | ||||
z = dataOut.data_param[channelIndexList,:] | ||||
|
r897 | |||
|
r832 | if showSNR: | ||
#SNR data | ||||
SNRarray = dataOut.data_SNR[channelIndexList,:] | ||||
SNRdB = 10*numpy.log10(SNRarray) | ||||
ind = numpy.where(SNRdB < SNRthresh) | ||||
z[ind] = numpy.nan | ||||
|
r897 | |||
|
r832 | thisDatetime = dataOut.datatime | ||
# thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) | ||||
title = wintitle + " Parameters Plot" #: %s" %(thisDatetime.strftime("%d-%b-%Y")) | ||||
xlabel = "" | ||||
ylabel = "Range (Km)" | ||||
|
r897 | |||
|
r832 | update_figfile = False | ||
|
r897 | |||
|
r832 | if not self.isConfig: | ||
|
r897 | |||
|
r832 | nchan = len(channelIndexList) | ||
self.nchan = nchan | ||||
self.plotFact = 1 | ||||
nplots = nchan | ||||
|
r897 | |||
|
r832 | if showSNR: | ||
nplots = nchan*2 | ||||
self.plotFact = 2 | ||||
if SNRmin == None: SNRmin = numpy.nanmin(SNRdB) | ||||
|
r897 | if SNRmax == None: SNRmax = numpy.nanmax(SNRdB) | ||
|
r832 | self.setup(id=id, | ||
nplots=nplots, | ||||
wintitle=wintitle, | ||||
show=show) | ||||
|
r897 | |||
|
r832 | if timerange != None: | ||
self.timerange = timerange | ||||
|
r897 | |||
|
r832 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) | ||
|
r897 | |||
|
r832 | if ymin == None: ymin = numpy.nanmin(y) | ||
if ymax == None: ymax = numpy.nanmax(y) | ||||
|
r841 | if zmin == None: zmin = numpy.nanmin(z) | ||
if zmax == None: zmax = numpy.nanmax(z) | ||||
|
r897 | |||
|
r832 | self.FTP_WEI = ftp_wei | ||
self.EXP_CODE = exp_code | ||||
self.SUB_EXP_CODE = sub_exp_code | ||||
self.PLOT_POS = plot_pos | ||||
|
r897 | |||
|
r832 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | ||
self.isConfig = True | ||||
self.figfile = figfile | ||||
update_figfile = True | ||||
|
r897 | |||
|
r832 | self.setWinTitle(title) | ||
|
r897 | |||
|
r832 | for i in range(self.nchan): | ||
index = channelIndexList[i] | ||||
title = "Channel %d: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | ||||
axes = self.axesList[i*self.plotFact] | ||||
z1 = z[i,:].reshape((1,-1)) | ||||
axes.pcolorbuffer(x, y, z1, | ||||
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%",colormap=colormap) | ||||
|
r897 | |||
|
r832 | if showSNR: | ||
title = "Channel %d SNR: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | ||||
axes = self.axesList[i*self.plotFact + 1] | ||||
SNRdB1 = SNRdB[i,:].reshape((1,-1)) | ||||
axes.pcolorbuffer(x, y, SNRdB1, | ||||
xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax, | ||||
xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | ||||
ticksize=9, cblabel='', cbsize="1%",colormap='jet') | ||||
|
r897 | |||
|
r832 | self.draw() | ||
|
r897 | |||
|
r832 | if dataOut.ltctime >= self.xmax: | ||
self.counter_imagwr = wr_period | ||||
self.isConfig = False | ||||
update_figfile = True | ||||
|
r897 | |||
|
r832 | self.save(figpath=figpath, | ||
figfile=figfile, | ||||
save=save, | ||||
ftp=ftp, | ||||
wr_period=wr_period, | ||||
thisDatetime=thisDatetime, | ||||
update_figfile=update_figfile) | ||||
|
r897 | |||
|
r870 | class Parameters1Plot(Figure): | ||
|
r897 | |||
|
r511 | __isConfig = None | ||
__nsubplots = None | ||||
|
r897 | |||
|
r511 | WIDTHPROF = None | ||
HEIGHTPROF = None | ||||
|
r512 | PREFIX = 'prm' | ||
|
r897 | |||
def __init__(self, **kwargs): | ||||
Figure.__init__(self, **kwargs) | ||||
|
r511 | self.timerange = 2*60*60 | ||
|
r793 | self.isConfig = False | ||
|
r511 | self.__nsubplots = 1 | ||
|
r897 | |||
|
r511 | self.WIDTH = 800 | ||
|
r929 | self.HEIGHT = 180 | ||
|
r511 | self.WIDTHPROF = 120 | ||
self.HEIGHTPROF = 0 | ||||
self.counter_imagwr = 0 | ||||
|
r897 | |||
|
r573 | self.PLOT_CODE = PARMS_CODE | ||
|
r897 | |||
|
r511 | self.FTP_WEI = None | ||
self.EXP_CODE = None | ||||
self.SUB_EXP_CODE = None | ||||
self.PLOT_POS = None | ||||
|
r897 | self.tmin = None | ||
|
r511 | self.tmax = None | ||
|
r897 | |||
|
r511 | self.xmin = None | ||
self.xmax = None | ||||
|
r897 | |||
|
r511 | self.figfile = None | ||
|
r897 | |||
|
r511 | def getSubplots(self): | ||
|
r897 | |||
|
r511 | ncol = 1 | ||
nrow = self.nplots | ||||
|
r897 | |||
|
r511 | return nrow, ncol | ||
|
r897 | |||
|
r511 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | ||
|
r897 | |||
|
r511 | self.__showprofile = showprofile | ||
self.nplots = nplots | ||||
|
r897 | |||
|
r511 | ncolspan = 1 | ||
colspan = 1 | ||||
|
r897 | |||
|
r511 | self.createFigure(id = id, | ||
wintitle = wintitle, | ||||
widthplot = self.WIDTH + self.WIDTHPROF, | ||||
heightplot = self.HEIGHT + self.HEIGHTPROF, | ||||
show=show) | ||||
|
r897 | |||
|
r511 | nrow, ncol = self.getSubplots() | ||
|
r897 | |||
|
r511 | counter = 0 | ||
for y in range(nrow): | ||||
for x in range(ncol): | ||||
|
r897 | |||
|
r511 | if counter >= self.nplots: | ||
break | ||||
|
r897 | |||
|
r511 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | ||
|
r897 | |||
|
r511 | if showprofile: | ||
self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | ||||
|
r897 | |||
|
r511 | counter += 1 | ||
|
r897 | |||
|
r511 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=False, | ||
|
r897 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,timerange=None, | ||
|
r543 | parameterIndex = None, onlyPositive = False, | ||
|
r608 | SNRthresh = -numpy.inf, SNR = True, SNRmin = None, SNRmax = None, onlySNR = False, | ||
|
r588 | DOP = True, | ||
|
r543 | zlabel = "", parameterName = "", parameterObject = "data_param", | ||
|
r568 | save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True, | ||
|
r511 | server=None, folder=None, username=None, password=None, | ||
ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): | ||||
|
r929 | #print inspect.getargspec(self.run).args | ||
|
r511 | """ | ||
|
r897 | |||
|
r511 | Input: | ||
dataOut : | ||||
id : | ||||
wintitle : | ||||
channelList : | ||||
showProfile : | ||||
xmin : None, | ||||
xmax : None, | ||||
ymin : None, | ||||
ymax : None, | ||||
zmin : None, | ||||
zmax : None | ||||
""" | ||||
|
r897 | |||
|
r543 | data_param = getattr(dataOut, parameterObject) | ||
|
r897 | |||
|
r511 | if channelList == None: | ||
|
r543 | channelIndexList = numpy.arange(data_param.shape[0]) | ||
|
r511 | else: | ||
|
r550 | channelIndexList = numpy.array(channelList) | ||
|
r543 | |||
|
r548 | nchan = len(channelIndexList) #Number of channels being plotted | ||
|
r897 | |||
|
r588 | if nchan < 1: | ||
return | ||||
nGraphsByChannel = 0 | ||||
|
r897 | |||
|
r588 | if SNR: | ||
nGraphsByChannel += 1 | ||||
if DOP: | ||||
nGraphsByChannel += 1 | ||||
if nGraphsByChannel < 1: | ||||
return | ||||
|
r897 | |||
|
r588 | nplots = nGraphsByChannel*nchan | ||
|
r897 | |||
|
r612 | if timerange is not None: | ||
|
r511 | self.timerange = timerange | ||
|
r897 | |||
|
r511 | #tmin = None | ||
#tmax = None | ||||
|
r543 | if parameterIndex == None: | ||
parameterIndex = 1 | ||||
|
r897 | |||
|
r804 | x = dataOut.getTimeRange1(dataOut.paramInterval) | ||
|
r543 | y = dataOut.heightList | ||
z = data_param[channelIndexList,parameterIndex,:].copy() | ||||
|
r897 | |||
|
r543 | zRange = dataOut.abscissaList | ||
|
r588 | # nChannels = z.shape[0] #Number of wind dimensions estimated | ||
|
r511 | # thisDatetime = dataOut.datatime | ||
|
r548 | |||
|
r612 | if dataOut.data_SNR is not None: | ||
|
r550 | SNRarray = dataOut.data_SNR[channelIndexList,:] | ||
|
r548 | SNRdB = 10*numpy.log10(SNRarray) | ||
# SNRavgdB = 10*numpy.log10(SNRavg) | ||||
ind = numpy.where(SNRdB < 10**(SNRthresh/10)) | ||||
z[ind] = numpy.nan | ||||
|
r897 | |||
|
r568 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) | ||
|
r512 | title = wintitle + " Parameters Plot" #: %s" %(thisDatetime.strftime("%d-%b-%Y")) | ||
|
r511 | xlabel = "" | ||
|
r512 | ylabel = "Range (Km)" | ||
|
r897 | |||
|
r608 | if (SNR and not onlySNR): nplots = 2*nplots | ||
|
r897 | |||
|
r512 | if onlyPositive: | ||
colormap = "jet" | ||||
|
r897 | zmin = 0 | ||
|
r512 | else: colormap = "RdBu_r" | ||
|
r897 | |||
|
r793 | if not self.isConfig: | ||
|
r897 | |||
|
r511 | self.setup(id=id, | ||
nplots=nplots, | ||||
wintitle=wintitle, | ||||
showprofile=showprofile, | ||||
show=show) | ||||
|
r897 | |||
|
r567 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) | ||
|
r897 | |||
|
r511 | if ymin == None: ymin = numpy.nanmin(y) | ||
if ymax == None: ymax = numpy.nanmax(y) | ||||
if zmin == None: zmin = numpy.nanmin(zRange) | ||||
if zmax == None: zmax = numpy.nanmax(zRange) | ||||
|
r897 | |||
|
r588 | if SNR: | ||
|
r548 | if SNRmin == None: SNRmin = numpy.nanmin(SNRdB) | ||
|
r897 | if SNRmax == None: SNRmax = numpy.nanmax(SNRdB) | ||
|
r511 | self.FTP_WEI = ftp_wei | ||
self.EXP_CODE = exp_code | ||||
self.SUB_EXP_CODE = sub_exp_code | ||||
self.PLOT_POS = plot_pos | ||||
|
r897 | |||
|
r511 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | ||
|
r793 | self.isConfig = True | ||
|
r511 | self.figfile = figfile | ||
|
r897 | |||
|
r511 | self.setWinTitle(title) | ||
|
r897 | |||
|
r511 | if ((self.xmax - x[1]) < (x[1]-x[0])): | ||
x[1] = self.xmax | ||||
|
r897 | |||
|
r548 | for i in range(nchan): | ||
|
r608 | |||
if (SNR and not onlySNR): j = 2*i | ||||
else: j = i | ||||
|
r897 | |||
|
r588 | j = nGraphsByChannel*i | ||
|
r608 | |||
if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): | ||||
title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith) | ||||
|
r897 | |||
|
r608 | if not onlySNR: | ||
axes = self.axesList[j*self.__nsubplots] | ||||
z1 = z[i,:].reshape((1,-1)) | ||||
axes.pcolorbuffer(x, y, z1, | ||||
xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | ||||
xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap=colormap, | ||||
ticksize=9, cblabel=zlabel, cbsize="1%") | ||||
|
r588 | if DOP: | ||
|
r713 | title = "%s Channel %d: %s" %(parameterName, channelIndexList[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | ||
|
r897 | |||
|
r588 | if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): | ||
title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith) | ||||
axes = self.axesList[j] | ||||
z1 = z[i,:].reshape((1,-1)) | ||||
axes.pcolorbuffer(x, y, z1, | ||||
xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | ||||
xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap=colormap, | ||||
ticksize=9, cblabel=zlabel, cbsize="1%") | ||||
|
r897 | |||
|
r548 | if SNR: | ||
|
r713 | title = "Channel %d Signal Noise Ratio (SNR): %s" %(channelIndexList[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | ||
|
r608 | axes = self.axesList[(j)*self.__nsubplots] | ||
if not onlySNR: | ||||
axes = self.axesList[(j + 1)*self.__nsubplots] | ||||
|
r588 | axes = self.axesList[(j + nGraphsByChannel-1)] | ||
|
r608 | |||
|
r548 | z1 = SNRdB[i,:].reshape((1,-1)) | ||
axes.pcolorbuffer(x, y, z1, | ||||
xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax, | ||||
xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap="jet", | ||||
ticksize=9, cblabel=zlabel, cbsize="1%") | ||||
|
r897 | |||
|
r512 | |||
|
r568 | self.draw() | ||
|
r897 | |||
|
r513 | if x[1] >= self.axesList[0].xmax: | ||
self.counter_imagwr = wr_period | ||||
|
r793 | self.isConfig = False | ||
|
r513 | self.figfile = None | ||
|
r897 | |||
|
r573 | self.save(figpath=figpath, | ||
figfile=figfile, | ||||
save=save, | ||||
ftp=ftp, | ||||
wr_period=wr_period, | ||||
thisDatetime=thisDatetime, | ||||
update_figfile=False) | ||||
|
r897 | |||
|
r513 | class SpectralFittingPlot(Figure): | ||
|
r897 | |||
|
r513 | __isConfig = None | ||
__nsubplots = None | ||||
|
r897 | |||
|
r513 | WIDTHPROF = None | ||
HEIGHTPROF = None | ||||
PREFIX = 'prm' | ||||
|
r897 | |||
|
r513 | N = None | ||
ippSeconds = None | ||||
|
r897 | |||
def __init__(self, **kwargs): | ||||
Figure.__init__(self, **kwargs) | ||||
|
r793 | self.isConfig = False | ||
|
r513 | self.__nsubplots = 1 | ||
|
r897 | |||
|
r573 | self.PLOT_CODE = SPECFIT_CODE | ||
|
r897 | |||
|
r513 | self.WIDTH = 450 | ||
self.HEIGHT = 250 | ||||
self.WIDTHPROF = 0 | ||||
self.HEIGHTPROF = 0 | ||||
|
r897 | |||
|
r513 | def getSubplots(self): | ||
|
r897 | |||
|
r513 | ncol = int(numpy.sqrt(self.nplots)+0.9) | ||
nrow = int(self.nplots*1./ncol + 0.9) | ||||
|
r897 | |||
|
r513 | return nrow, ncol | ||
|
r897 | |||
|
r513 | def setup(self, id, nplots, wintitle, showprofile=False, show=True): | ||
|
r897 | |||
showprofile = False | ||||
|
r513 | self.__showprofile = showprofile | ||
self.nplots = nplots | ||||
|
r897 | |||
|
r513 | ncolspan = 5 | ||
colspan = 4 | ||||
if showprofile: | ||||
ncolspan = 5 | ||||
colspan = 4 | ||||
self.__nsubplots = 2 | ||||
|
r897 | |||
|
r513 | self.createFigure(id = id, | ||
wintitle = wintitle, | ||||
widthplot = self.WIDTH + self.WIDTHPROF, | ||||
heightplot = self.HEIGHT + self.HEIGHTPROF, | ||||
show=show) | ||||
|
r897 | |||
|
r513 | nrow, ncol = self.getSubplots() | ||
|
r897 | |||
|
r513 | counter = 0 | ||
for y in range(nrow): | ||||
for x in range(ncol): | ||||
|
r897 | |||
|
r513 | if counter >= self.nplots: | ||
break | ||||
|
r897 | |||
|
r513 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | ||
|
r897 | |||
|
r513 | if showprofile: | ||
self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | ||||
|
r897 | |||
|
r513 | counter += 1 | ||
|
r897 | |||
|
r513 | def run(self, dataOut, id, cutHeight=None, fit=False, wintitle="", channelList=None, showprofile=True, | ||
xmin=None, xmax=None, ymin=None, ymax=None, | ||||
save=False, figpath='./', figfile=None, show=True): | ||||
|
r897 | |||
|
r513 | """ | ||
|
r897 | |||
|
r513 | Input: | ||
dataOut : | ||||
id : | ||||
wintitle : | ||||
channelList : | ||||
showProfile : | ||||
xmin : None, | ||||
xmax : None, | ||||
zmin : None, | ||||
zmax : None | ||||
""" | ||||
|
r897 | |||
|
r513 | if cutHeight==None: | ||
h=270 | ||||
heightindex = numpy.abs(cutHeight - dataOut.heightList).argmin() | ||||
cutHeight = dataOut.heightList[heightindex] | ||||
|
r897 | |||
|
r513 | factor = dataOut.normFactor | ||
|
r543 | x = dataOut.abscissaList[:-1] | ||
|
r513 | #y = dataOut.getHeiRange() | ||
|
r897 | |||
|
r513 | z = dataOut.data_pre[:,:,heightindex]/factor | ||
|
r897 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | ||
|
r513 | avg = numpy.average(z, axis=1) | ||
listChannels = z.shape[0] | ||||
#Reconstruct Function | ||||
if fit==True: | ||||
groupArray = dataOut.groupList | ||||
listChannels = groupArray.reshape((groupArray.size)) | ||||
listChannels.sort() | ||||
spcFitLine = numpy.zeros(z.shape) | ||||
constants = dataOut.constants | ||||
|
r897 | |||
|
r513 | nGroups = groupArray.shape[0] | ||
nChannels = groupArray.shape[1] | ||||
nProfiles = z.shape[1] | ||||
|
r897 | |||
|
r513 | for f in range(nGroups): | ||
groupChann = groupArray[f,:] | ||||
p = dataOut.data_param[f,:,heightindex] | ||||
# p = numpy.array([ 89.343967,0.14036615,0.17086219,18.89835291,1.58388365,1.55099167]) | ||||
fitLineAux = dataOut.library.modelFunction(p, constants)*nProfiles | ||||
fitLineAux = fitLineAux.reshape((nChannels,nProfiles)) | ||||
|
r897 | spcFitLine[groupChann,:] = fitLineAux | ||
|
r513 | # spcFitLine = spcFitLine/factor | ||
|
r897 | |||
|
r513 | z = z[listChannels,:] | ||
spcFitLine = spcFitLine[listChannels,:] | ||||
spcFitLinedB = 10*numpy.log10(spcFitLine) | ||||
|
r897 | |||
|
r513 | zdB = 10*numpy.log10(z) | ||
#thisDatetime = dataOut.datatime | ||||
|
r568 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) | ||
|
r513 | title = wintitle + " Doppler Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | ||
xlabel = "Velocity (m/s)" | ||||
ylabel = "Spectrum" | ||||
|
r897 | |||
|
r793 | if not self.isConfig: | ||
|
r897 | |||
|
r513 | nplots = listChannels.size | ||
|
r897 | |||
|
r513 | self.setup(id=id, | ||
nplots=nplots, | ||||
wintitle=wintitle, | ||||
showprofile=showprofile, | ||||
show=show) | ||||
|
r897 | |||
|
r513 | if xmin == None: xmin = numpy.nanmin(x) | ||
if xmax == None: xmax = numpy.nanmax(x) | ||||
if ymin == None: ymin = numpy.nanmin(zdB) | ||||
if ymax == None: ymax = numpy.nanmax(zdB)+2 | ||||
|
r897 | |||
|
r793 | self.isConfig = True | ||
|
r897 | |||
|
r513 | self.setWinTitle(title) | ||
for i in range(self.nplots): | ||||
# title = "Channel %d: %4.2fdB" %(dataOut.channelList[i]+1, noisedB[i]) | ||||
|
r713 | title = "Height %4.1f km\nChannel %d:" %(cutHeight, listChannels[i]) | ||
|
r513 | axes = self.axesList[i*self.__nsubplots] | ||
if fit == False: | ||||
axes.pline(x, zdB[i,:], | ||||
xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, | ||||
xlabel=xlabel, ylabel=ylabel, title=title | ||||
) | ||||
if fit == True: | ||||
fitline=spcFitLinedB[i,:] | ||||
y=numpy.vstack([zdB[i,:],fitline] ) | ||||
legendlabels=['Data','Fitting'] | ||||
axes.pmultilineyaxis(x, y, | ||||
xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, | ||||
xlabel=xlabel, ylabel=ylabel, title=title, | ||||
|
r897 | legendlabels=legendlabels, marker=None, | ||
|
r513 | linestyle='solid', grid='both') | ||
|
r897 | |||
|
r513 | self.draw() | ||
|
r897 | |||
|
r573 | self.save(figpath=figpath, | ||
figfile=figfile, | ||||
save=save, | ||||
ftp=ftp, | ||||
wr_period=wr_period, | ||||
thisDatetime=thisDatetime) | ||||
|
r897 | |||
|
r513 | class EWDriftsPlot(Figure): | ||
|
r897 | |||
|
r513 | __isConfig = None | ||
__nsubplots = None | ||||
|
r897 | |||
|
r513 | WIDTHPROF = None | ||
HEIGHTPROF = None | ||||
PREFIX = 'drift' | ||||
|
r897 | |||
def __init__(self, **kwargs): | ||||
Figure.__init__(self, **kwargs) | ||||
|
r513 | self.timerange = 2*60*60 | ||
self.isConfig = False | ||||
self.__nsubplots = 1 | ||||
|
r897 | |||
|
r513 | self.WIDTH = 800 | ||
self.HEIGHT = 150 | ||||
self.WIDTHPROF = 120 | ||||
self.HEIGHTPROF = 0 | ||||
self.counter_imagwr = 0 | ||||
|
r897 | |||
|
r573 | self.PLOT_CODE = EWDRIFT_CODE | ||
|
r897 | |||
|
r513 | self.FTP_WEI = None | ||
self.EXP_CODE = None | ||||
self.SUB_EXP_CODE = None | ||||
self.PLOT_POS = None | ||||
|
r897 | self.tmin = None | ||
|
r513 | self.tmax = None | ||
|
r897 | |||
|
r513 | self.xmin = None | ||
self.xmax = None | ||||
|
r897 | |||
|
r513 | self.figfile = None | ||
|
r897 | |||
|
r513 | def getSubplots(self): | ||
|
r897 | |||
|
r513 | ncol = 1 | ||
nrow = self.nplots | ||||
|
r897 | |||
|
r513 | return nrow, ncol | ||
|
r897 | |||
|
r513 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | ||
|
r897 | |||
|
r513 | self.__showprofile = showprofile | ||
self.nplots = nplots | ||||
|
r897 | |||
|
r513 | ncolspan = 1 | ||
colspan = 1 | ||||
|
r897 | |||
|
r513 | self.createFigure(id = id, | ||
wintitle = wintitle, | ||||
widthplot = self.WIDTH + self.WIDTHPROF, | ||||
heightplot = self.HEIGHT + self.HEIGHTPROF, | ||||
show=show) | ||||
|
r897 | |||
|
r513 | nrow, ncol = self.getSubplots() | ||
|
r897 | |||
|
r513 | counter = 0 | ||
for y in range(nrow): | ||||
if counter >= self.nplots: | ||||
break | ||||
|
r897 | |||
self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1) | ||||
|
r513 | counter += 1 | ||
|
r897 | |||
def run(self, dataOut, id, wintitle="", channelList=None, | ||||
|
r513 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | ||
zmaxVertical = None, zminVertical = None, zmaxZonal = None, zminZonal = None, | ||||
timerange=None, SNRthresh = -numpy.inf, SNRmin = None, SNRmax = None, SNR_1 = False, | ||||
|
r568 | save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True, | ||
|
r513 | server=None, folder=None, username=None, password=None, | ||
|
r897 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): | ||
|
r513 | """ | ||
|
r897 | |||
|
r513 | Input: | ||
dataOut : | ||||
id : | ||||
wintitle : | ||||
channelList : | ||||
showProfile : | ||||
xmin : None, | ||||
xmax : None, | ||||
ymin : None, | ||||
ymax : None, | ||||
zmin : None, | ||||
zmax : None | ||||
""" | ||||
|
r897 | |||
|
r612 | if timerange is not None: | ||
|
r513 | self.timerange = timerange | ||
|
r897 | |||
|
r513 | tmin = None | ||
tmax = None | ||||
|
r897 | |||
|
r804 | x = dataOut.getTimeRange1(dataOut.outputInterval) | ||
|
r543 | # y = dataOut.heightList | ||
|
r513 | y = dataOut.heightList | ||
|
r897 | |||
|
r513 | z = dataOut.data_output | ||
nplots = z.shape[0] #Number of wind dimensions estimated | ||||
nplotsw = nplots | ||||
|
r897 | |||
|
r513 | #If there is a SNR function defined | ||
|
r612 | if dataOut.data_SNR is not None: | ||
|
r513 | nplots += 1 | ||
|
r514 | SNR = dataOut.data_SNR | ||
|
r897 | |||
|
r513 | if SNR_1: | ||
SNR += 1 | ||||
|
r897 | |||
|
r513 | SNRavg = numpy.average(SNR, axis=0) | ||
|
r897 | |||
|
r513 | SNRdB = 10*numpy.log10(SNR) | ||
SNRavgdB = 10*numpy.log10(SNRavg) | ||||
|
r897 | |||
|
r513 | ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0] | ||
|
r897 | |||
|
r513 | for i in range(nplotsw): | ||
z[i,ind] = numpy.nan | ||||
|
r897 | |||
showprofile = False | ||||
|
r513 | # thisDatetime = dataOut.datatime | ||
|
r543 | thisDatetime = datetime.datetime.utcfromtimestamp(x[1]) | ||
|
r513 | title = wintitle + " EW Drifts" | ||
xlabel = "" | ||||
ylabel = "Height (Km)" | ||||
|
r897 | |||
|
r793 | if not self.isConfig: | ||
|
r897 | |||
|
r513 | self.setup(id=id, | ||
nplots=nplots, | ||||
wintitle=wintitle, | ||||
showprofile=showprofile, | ||||
show=show) | ||||
|
r897 | |||
|
r567 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) | ||
|
r897 | |||
|
r513 | if ymin == None: ymin = numpy.nanmin(y) | ||
if ymax == None: ymax = numpy.nanmax(y) | ||||
|
r897 | |||
|
r513 | if zmaxZonal == None: zmaxZonal = numpy.nanmax(abs(z[0,:])) | ||
if zminZonal == None: zminZonal = -zmaxZonal | ||||
if zmaxVertical == None: zmaxVertical = numpy.nanmax(abs(z[1,:])) | ||||
if zminVertical == None: zminVertical = -zmaxVertical | ||||
|
r897 | |||
|
r612 | if dataOut.data_SNR is not None: | ||
|
r513 | if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB) | ||
|
r897 | if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB) | ||
|
r513 | self.FTP_WEI = ftp_wei | ||
self.EXP_CODE = exp_code | ||||
self.SUB_EXP_CODE = sub_exp_code | ||||
self.PLOT_POS = plot_pos | ||||
|
r897 | |||
|
r513 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | ||
|
r793 | self.isConfig = True | ||
|
r897 | |||
|
r513 | self.setWinTitle(title) | ||
|
r897 | |||
|
r513 | if ((self.xmax - x[1]) < (x[1]-x[0])): | ||
x[1] = self.xmax | ||||
|
r897 | |||
|
r513 | strWind = ['Zonal','Vertical'] | ||
strCb = 'Velocity (m/s)' | ||||
zmaxVector = [zmaxZonal, zmaxVertical] | ||||
zminVector = [zminZonal, zminVertical] | ||||
|
r897 | |||
|
r513 | for i in range(nplotsw): | ||
|
r897 | |||
|
r513 | title = "%s Drifts: %s" %(strWind[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | ||
axes = self.axesList[i*self.__nsubplots] | ||||
|
r897 | |||
z1 = z[i,:].reshape((1,-1)) | ||||
|
r513 | axes.pcolorbuffer(x, y, z1, | ||
xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zminVector[i], zmax=zmaxVector[i], | ||||
xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | ||||
ticksize=9, cblabel=strCb, cbsize="1%", colormap="RdBu_r") | ||||
|
r897 | |||
|
r612 | if dataOut.data_SNR is not None: | ||
|
r897 | i += 1 | ||
|
r513 | if SNR_1: | ||
title = "Signal Noise Ratio + 1 (SNR+1): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | ||||
else: | ||||
title = "Signal Noise Ratio (SNR): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | ||||
axes = self.axesList[i*self.__nsubplots] | ||||
|
r897 | SNRavgdB = SNRavgdB.reshape((1,-1)) | ||
|
r513 | axes.pcolorbuffer(x, y, SNRavgdB, | ||
xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax, | ||||
xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | ||||
ticksize=9, cblabel='', cbsize="1%", colormap="jet") | ||||
|
r897 | |||
|
r513 | self.draw() | ||
|
r897 | |||
|
r509 | if x[1] >= self.axesList[0].xmax: | ||
self.counter_imagwr = wr_period | ||||
|
r793 | self.isConfig = False | ||
|
r573 | self.figfile = None | ||
|
r897 | |||
|
r608 | class PhasePlot(Figure): | ||
|
r897 | |||
|
r608 | __isConfig = None | ||
__nsubplots = None | ||||
PREFIX = 'mphase' | ||||
|
r897 | |||
def __init__(self, **kwargs): | ||||
Figure.__init__(self, **kwargs) | ||||
|
r608 | self.timerange = 24*60*60 | ||
|
r793 | self.isConfig = False | ||
|
r608 | self.__nsubplots = 1 | ||
self.counter_imagwr = 0 | ||||
self.WIDTH = 600 | ||||
self.HEIGHT = 300 | ||||
self.WIDTHPROF = 120 | ||||
self.HEIGHTPROF = 0 | ||||
self.xdata = None | ||||
self.ydata = None | ||||
|
r897 | |||
|
r608 | self.PLOT_CODE = MPHASE_CODE | ||
|
r897 | |||
|
r608 | self.FTP_WEI = None | ||
self.EXP_CODE = None | ||||
self.SUB_EXP_CODE = None | ||||
self.PLOT_POS = None | ||||
|
r897 | |||
|
r608 | self.filename_phase = None | ||
|
r897 | |||
|
r608 | self.figfile = None | ||
|
r897 | |||
|
r608 | def getSubplots(self): | ||
|
r897 | |||
|
r608 | ncol = 1 | ||
nrow = 1 | ||||
|
r897 | |||
|
r608 | return nrow, ncol | ||
|
r897 | |||
|
r608 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | ||
|
r897 | |||
|
r608 | self.__showprofile = showprofile | ||
self.nplots = nplots | ||||
|
r897 | |||
|
r608 | ncolspan = 7 | ||
colspan = 6 | ||||
self.__nsubplots = 2 | ||||
|
r897 | |||
|
r608 | self.createFigure(id = id, | ||
wintitle = wintitle, | ||||
widthplot = self.WIDTH+self.WIDTHPROF, | ||||
heightplot = self.HEIGHT+self.HEIGHTPROF, | ||||
show=show) | ||||
|
r897 | |||
|
r608 | nrow, ncol = self.getSubplots() | ||
|
r897 | |||
|
r608 | self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1) | ||
def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True', | ||||
xmin=None, xmax=None, ymin=None, ymax=None, | ||||
timerange=None, | ||||
|
r786 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, | ||
|
r608 | server=None, folder=None, username=None, password=None, | ||
ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): | ||||
|
r897 | |||
|
r608 | tmin = None | ||
tmax = None | ||||
|
r804 | x = dataOut.getTimeRange1(dataOut.outputInterval) | ||
|
r608 | y = dataOut.getHeiRange() | ||
|
r897 | |||
|
r608 | #thisDatetime = dataOut.datatime | ||
|
r852 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime) | ||
|
r608 | title = wintitle + " Phase of Beacon Signal" # : %s" %(thisDatetime.strftime("%d-%b-%Y")) | ||
xlabel = "Local Time" | ||||
ylabel = "Phase" | ||||
|
r897 | |||
|
r608 | #phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList))) | ||
phase_beacon = dataOut.data_output | ||||
|
r786 | update_figfile = False | ||
|
r897 | |||
|
r793 | if not self.isConfig: | ||
|
r897 | |||
|
r608 | self.nplots = phase_beacon.size | ||
|
r897 | |||
|
r608 | self.setup(id=id, | ||
nplots=self.nplots, | ||||
wintitle=wintitle, | ||||
showprofile=showprofile, | ||||
show=show) | ||||
|
r897 | |||
|
r612 | if timerange is not None: | ||
|
r897 | self.timerange = timerange | ||
|
r610 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) | ||
|
r897 | |||
|
r608 | if ymin == None: ymin = numpy.nanmin(phase_beacon) - 10.0 | ||
if ymax == None: ymax = numpy.nanmax(phase_beacon) + 10.0 | ||||
|
r897 | |||
|
r608 | self.FTP_WEI = ftp_wei | ||
self.EXP_CODE = exp_code | ||||
self.SUB_EXP_CODE = sub_exp_code | ||||
self.PLOT_POS = plot_pos | ||||
|
r897 | |||
|
r608 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | ||
|
r793 | self.isConfig = True | ||
|
r608 | self.figfile = figfile | ||
self.xdata = numpy.array([]) | ||||
self.ydata = numpy.array([]) | ||||
|
r897 | |||
|
r608 | #open file beacon phase | ||
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) | ||||
|
r786 | update_figfile = True | ||
|
r897 | |||
|
r608 | #store data beacon phase | ||
#self.save_data(self.filename_phase, phase_beacon, thisDatetime) | ||||
|
r897 | |||
|
r608 | self.setWinTitle(title) | ||
|
r897 | |||
|
r608 | title = "Phase Offset %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | ||
|
r897 | |||
|
r608 | legendlabels = ["phase %d"%(chan) for chan in numpy.arange(self.nplots)] | ||
axes = self.axesList[0] | ||||
|
r897 | |||
|
r608 | self.xdata = numpy.hstack((self.xdata, x[0:1])) | ||
|
r897 | |||
|
r608 | if len(self.ydata)==0: | ||
self.ydata = phase_beacon.reshape(-1,1) | ||||
else: | ||||
self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1))) | ||||
|
r897 | |||
|
r608 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, | ||
|
r610 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, | ||
|
r608 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid", | ||
XAxisAsTime=True, grid='both' | ||||
) | ||||
|
r897 | |||
|
r608 | self.draw() | ||
|
r897 | |||
|
r852 | self.save(figpath=figpath, | ||
figfile=figfile, | ||||
save=save, | ||||
ftp=ftp, | ||||
wr_period=wr_period, | ||||
thisDatetime=thisDatetime, | ||||
update_figfile=update_figfile) | ||||
|
r897 | |||
|
r852 | if dataOut.ltctime + dataOut.outputInterval >= self.xmax: | ||
|
r608 | self.counter_imagwr = wr_period | ||
|
r793 | self.isConfig = False | ||
|
r786 | update_figfile = True | ||
|
r852 | |||
|
r897 | |||
|
r841 | class NSMeteorDetection1Plot(Figure): | ||
|
r897 | |||
|
r841 | isConfig = None | ||
__nsubplots = None | ||||
|
r897 | |||
|
r841 | WIDTHPROF = None | ||
HEIGHTPROF = None | ||||
PREFIX = 'nsm' | ||||
|
r897 | |||
|
r841 | zminList = None | ||
zmaxList = None | ||||
cmapList = None | ||||
titleList = None | ||||
nPairs = None | ||||
nChannels = None | ||||
nParam = None | ||||
|
r897 | |||
def __init__(self, **kwargs): | ||||
Figure.__init__(self, **kwargs) | ||||
|
r841 | self.isConfig = False | ||
self.__nsubplots = 1 | ||||
|
r897 | |||
|
r841 | self.WIDTH = 750 | ||
self.HEIGHT = 250 | ||||
self.WIDTHPROF = 120 | ||||
self.HEIGHTPROF = 0 | ||||
self.counter_imagwr = 0 | ||||
|
r897 | |||
|
r841 | self.PLOT_CODE = SPEC_CODE | ||
|
r897 | |||
|
r841 | self.FTP_WEI = None | ||
self.EXP_CODE = None | ||||
self.SUB_EXP_CODE = None | ||||
self.PLOT_POS = None | ||||
|
r897 | |||
|
r841 | self.__xfilter_ena = False | ||
self.__yfilter_ena = False | ||||
|
r897 | |||
|
r841 | def getSubplots(self): | ||
|
r897 | |||
|
r841 | ncol = 3 | ||
nrow = int(numpy.ceil(self.nplots/3.0)) | ||||
|
r897 | |||
|
r841 | return nrow, ncol | ||
|
r897 | |||
|
r841 | def setup(self, id, nplots, wintitle, show=True): | ||
|
r897 | |||
|
r841 | self.nplots = nplots | ||
|
r897 | |||
|
r841 | ncolspan = 1 | ||
colspan = 1 | ||||
|
r897 | |||
|
r841 | self.createFigure(id = id, | ||
wintitle = wintitle, | ||||
widthplot = self.WIDTH + self.WIDTHPROF, | ||||
heightplot = self.HEIGHT + self.HEIGHTPROF, | ||||
show=show) | ||||
|
r897 | |||
|
r841 | nrow, ncol = self.getSubplots() | ||
|
r897 | |||
|
r841 | counter = 0 | ||
for y in range(nrow): | ||||
for x in range(ncol): | ||||
|
r897 | |||
|
r841 | if counter >= self.nplots: | ||
break | ||||
|
r897 | |||
|
r841 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | ||
|
r897 | |||
|
r841 | counter += 1 | ||
|
r897 | |||
|
r841 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True, | ||
|
r897 | xmin=None, xmax=None, ymin=None, ymax=None, SNRmin=None, SNRmax=None, | ||
|
r841 | vmin=None, vmax=None, wmin=None, wmax=None, mode = 'SA', | ||
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, realtime=False, | ||||
xaxis="frequency"): | ||||
|
r897 | |||
|
r841 | """ | ||
|
r897 | |||
|
r841 | Input: | ||
dataOut : | ||||
id : | ||||
wintitle : | ||||
channelList : | ||||
showProfile : | ||||
xmin : None, | ||||
xmax : None, | ||||
ymin : None, | ||||
ymax : None, | ||||
zmin : None, | ||||
zmax : None | ||||
""" | ||||
#SEPARAR EN DOS PLOTS | ||||
nParam = dataOut.data_param.shape[1] - 3 | ||||
|
r897 | |||
utctime = dataOut.data_param[0,0] | ||||
|
r841 | tmet = dataOut.data_param[:,1].astype(int) | ||
hmet = dataOut.data_param[:,2].astype(int) | ||||
|
r897 | |||
|
r841 | x = dataOut.abscissaList | ||
y = dataOut.heightList | ||||
|
r897 | |||
|
r841 | z = numpy.zeros((nParam, y.size, x.size - 1)) | ||
z[:,:] = numpy.nan | ||||
z[:,hmet,tmet] = dataOut.data_param[:,3:].T | ||||
z[0,:,:] = 10*numpy.log10(z[0,:,:]) | ||||
|
r897 | |||
|
r841 | xlabel = "Time (s)" | ||
ylabel = "Range (km)" | ||||
|
r897 | |||
|
r841 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime) | ||
|
r897 | |||
|
r841 | if not self.isConfig: | ||
|
r897 | |||
|
r841 | nplots = nParam | ||
|
r897 | |||
|
r841 | self.setup(id=id, | ||
nplots=nplots, | ||||
wintitle=wintitle, | ||||
show=show) | ||||
|
r897 | |||
|
r841 | if xmin is None: xmin = numpy.nanmin(x) | ||
if xmax is None: xmax = numpy.nanmax(x) | ||||
if ymin is None: ymin = numpy.nanmin(y) | ||||
if ymax is None: ymax = numpy.nanmax(y) | ||||
if SNRmin is None: SNRmin = numpy.nanmin(z[0,:]) | ||||
if SNRmax is None: SNRmax = numpy.nanmax(z[0,:]) | ||||
if vmax is None: vmax = numpy.nanmax(numpy.abs(z[1,:])) | ||||
if vmin is None: vmin = -vmax | ||||
if wmin is None: wmin = 0 | ||||
if wmax is None: wmax = 50 | ||||
|
r897 | |||
|
r841 | pairsList = dataOut.groupList | ||
self.nPairs = len(dataOut.groupList) | ||||
|
r897 | |||
|
r841 | zminList = [SNRmin, vmin, cmin] + [pmin]*self.nPairs | ||
zmaxList = [SNRmax, vmax, cmax] + [pmax]*self.nPairs | ||||
titleList = ["SNR","Radial Velocity","Coherence"] | ||||
cmapList = ["jet","RdBu_r","jet"] | ||||
|
r897 | |||
|
r841 | for i in range(self.nPairs): | ||
strAux1 = "Phase Difference "+ str(pairsList[i][0]) + str(pairsList[i][1]) | ||||
titleList = titleList + [strAux1] | ||||
cmapList = cmapList + ["RdBu_r"] | ||||
|
r897 | |||
|
r841 | self.zminList = zminList | ||
self.zmaxList = zmaxList | ||||
self.cmapList = cmapList | ||||
self.titleList = titleList | ||||
|
r897 | |||
|
r841 | self.FTP_WEI = ftp_wei | ||
self.EXP_CODE = exp_code | ||||
self.SUB_EXP_CODE = sub_exp_code | ||||
self.PLOT_POS = plot_pos | ||||
|
r897 | |||
|
r841 | self.isConfig = True | ||
|
r897 | |||
|
r841 | str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) | ||
for i in range(nParam): | ||||
title = self.titleList[i] + ": " +str_datetime | ||||
axes = self.axesList[i] | ||||
axes.pcolor(x, y, z[i,:].T, | ||||
xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=self.zminList[i], zmax=self.zmaxList[i], | ||||
xlabel=xlabel, ylabel=ylabel, title=title, colormap=self.cmapList[i],ticksize=9, cblabel='') | ||||
self.draw() | ||||
|
r897 | |||
|
r841 | if figfile == None: | ||
str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") | ||||
name = str_datetime | ||||
if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): | ||||
|
r897 | name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith) | ||
|
r841 | figfile = self.getFilename(name) | ||
|
r897 | |||
|
r841 | self.save(figpath=figpath, | ||
figfile=figfile, | ||||
save=save, | ||||
ftp=ftp, | ||||
wr_period=wr_period, | ||||
thisDatetime=thisDatetime) | ||||
|
r897 | |||
|
r841 | |||
class NSMeteorDetection2Plot(Figure): | ||||
|
r897 | |||
|
r841 | isConfig = None | ||
__nsubplots = None | ||||
|
r897 | |||
|
r841 | WIDTHPROF = None | ||
HEIGHTPROF = None | ||||
PREFIX = 'nsm' | ||||
|
r897 | |||
|
r841 | zminList = None | ||
zmaxList = None | ||||
cmapList = None | ||||
titleList = None | ||||
nPairs = None | ||||
nChannels = None | ||||
nParam = None | ||||
|
r897 | |||
def __init__(self, **kwargs): | ||||
Figure.__init__(self, **kwargs) | ||||
|
r841 | self.isConfig = False | ||
self.__nsubplots = 1 | ||||
|
r897 | |||
|
r841 | self.WIDTH = 750 | ||
self.HEIGHT = 250 | ||||
self.WIDTHPROF = 120 | ||||
self.HEIGHTPROF = 0 | ||||
self.counter_imagwr = 0 | ||||
|
r897 | |||
|
r841 | self.PLOT_CODE = SPEC_CODE | ||
|
r897 | |||
|
r841 | self.FTP_WEI = None | ||
self.EXP_CODE = None | ||||
self.SUB_EXP_CODE = None | ||||
self.PLOT_POS = None | ||||
|
r897 | |||
|
r841 | self.__xfilter_ena = False | ||
self.__yfilter_ena = False | ||||
|
r897 | |||
|
r841 | def getSubplots(self): | ||
|
r897 | |||
|
r841 | ncol = 3 | ||
nrow = int(numpy.ceil(self.nplots/3.0)) | ||||
|
r897 | |||
|
r841 | return nrow, ncol | ||
|
r897 | |||
|
r841 | def setup(self, id, nplots, wintitle, show=True): | ||
|
r897 | |||
|
r841 | self.nplots = nplots | ||
|
r897 | |||
|
r841 | ncolspan = 1 | ||
colspan = 1 | ||||
|
r897 | |||
|
r841 | self.createFigure(id = id, | ||
wintitle = wintitle, | ||||
widthplot = self.WIDTH + self.WIDTHPROF, | ||||
heightplot = self.HEIGHT + self.HEIGHTPROF, | ||||
show=show) | ||||
|
r897 | |||
|
r841 | nrow, ncol = self.getSubplots() | ||
|
r897 | |||
|
r841 | counter = 0 | ||
for y in range(nrow): | ||||
for x in range(ncol): | ||||
|
r897 | |||
|
r841 | if counter >= self.nplots: | ||
break | ||||
|
r897 | |||
|
r841 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | ||
|
r897 | |||
|
r841 | counter += 1 | ||
|
r897 | |||
|
r841 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True, | ||
|
r897 | xmin=None, xmax=None, ymin=None, ymax=None, SNRmin=None, SNRmax=None, | ||
|
r841 | vmin=None, vmax=None, wmin=None, wmax=None, mode = 'SA', | ||
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, realtime=False, | ||||
xaxis="frequency"): | ||||
|
r897 | |||
|
r841 | """ | ||
|
r897 | |||
|
r841 | Input: | ||
dataOut : | ||||
id : | ||||
wintitle : | ||||
channelList : | ||||
showProfile : | ||||
xmin : None, | ||||
xmax : None, | ||||
ymin : None, | ||||
ymax : None, | ||||
zmin : None, | ||||
zmax : None | ||||
""" | ||||
|
r897 | #Rebuild matrix | ||
utctime = dataOut.data_param[0,0] | ||||
|
r841 | cmet = dataOut.data_param[:,1].astype(int) | ||
tmet = dataOut.data_param[:,2].astype(int) | ||||
hmet = dataOut.data_param[:,3].astype(int) | ||||
|
r897 | |||
|
r841 | nParam = 3 | ||
nChan = len(dataOut.groupList) | ||||
x = dataOut.abscissaList | ||||
y = dataOut.heightList | ||||
|
r897 | |||
|
r841 | z = numpy.full((nChan, nParam, y.size, x.size - 1),numpy.nan) | ||
z[cmet,:,hmet,tmet] = dataOut.data_param[:,4:] | ||||
z[:,0,:,:] = 10*numpy.log10(z[:,0,:,:]) #logarithmic scale | ||||
z = numpy.reshape(z, (nChan*nParam, y.size, x.size-1)) | ||||
|
r897 | |||
|
r841 | xlabel = "Time (s)" | ||
ylabel = "Range (km)" | ||||
|
r897 | |||
|
r841 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime) | ||
|
r897 | |||
|
r841 | if not self.isConfig: | ||
|
r897 | |||
|
r841 | nplots = nParam*nChan | ||
|
r897 | |||
|
r841 | self.setup(id=id, | ||
nplots=nplots, | ||||
wintitle=wintitle, | ||||
show=show) | ||||
|
r897 | |||
|
r841 | if xmin is None: xmin = numpy.nanmin(x) | ||
if xmax is None: xmax = numpy.nanmax(x) | ||||
if ymin is None: ymin = numpy.nanmin(y) | ||||
if ymax is None: ymax = numpy.nanmax(y) | ||||
if SNRmin is None: SNRmin = numpy.nanmin(z[0,:]) | ||||
if SNRmax is None: SNRmax = numpy.nanmax(z[0,:]) | ||||
if vmax is None: vmax = numpy.nanmax(numpy.abs(z[1,:])) | ||||
if vmin is None: vmin = -vmax | ||||
if wmin is None: wmin = 0 | ||||
if wmax is None: wmax = 50 | ||||
|
r897 | |||
|
r841 | self.nChannels = nChan | ||
|
r897 | |||
zminList = [] | ||||
|
r841 | zmaxList = [] | ||
titleList = [] | ||||
cmapList = [] | ||||
for i in range(self.nChannels): | ||||
strAux1 = "SNR Channel "+ str(i) | ||||
strAux2 = "Radial Velocity Channel "+ str(i) | ||||
strAux3 = "Spectral Width Channel "+ str(i) | ||||
|
r897 | |||
|
r841 | titleList = titleList + [strAux1,strAux2,strAux3] | ||
cmapList = cmapList + ["jet","RdBu_r","jet"] | ||||
zminList = zminList + [SNRmin,vmin,wmin] | ||||
zmaxList = zmaxList + [SNRmax,vmax,wmax] | ||||
|
r897 | |||
|
r841 | self.zminList = zminList | ||
self.zmaxList = zmaxList | ||||
self.cmapList = cmapList | ||||
self.titleList = titleList | ||||
|
r897 | |||
|
r841 | self.FTP_WEI = ftp_wei | ||
self.EXP_CODE = exp_code | ||||
self.SUB_EXP_CODE = sub_exp_code | ||||
self.PLOT_POS = plot_pos | ||||
|
r897 | |||
|
r841 | self.isConfig = True | ||
|
r897 | |||
|
r841 | str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) | ||
for i in range(self.nplots): | ||||
title = self.titleList[i] + ": " +str_datetime | ||||
axes = self.axesList[i] | ||||
axes.pcolor(x, y, z[i,:].T, | ||||
xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=self.zminList[i], zmax=self.zmaxList[i], | ||||
xlabel=xlabel, ylabel=ylabel, title=title, colormap=self.cmapList[i],ticksize=9, cblabel='') | ||||
self.draw() | ||||
|
r897 | |||
|
r841 | if figfile == None: | ||
str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") | ||||
name = str_datetime | ||||
if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): | ||||
|
r897 | name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith) | ||
|
r841 | figfile = self.getFilename(name) | ||
|
r897 | |||
|
r841 | self.save(figpath=figpath, | ||
figfile=figfile, | ||||
save=save, | ||||
ftp=ftp, | ||||
wr_period=wr_period, | ||||
|
r897 | thisDatetime=thisDatetime) | ||