|
|
import numpy
|
|
|
import datetime
|
|
|
from graphics.figure import *
|
|
|
|
|
|
class SpectraPlot(Figure):
|
|
|
__isConfig = None
|
|
|
|
|
|
def __init__(self):
|
|
|
self.__isConfig = False
|
|
|
self.width = 850
|
|
|
self.height = 800
|
|
|
|
|
|
def getSubplots(self):
|
|
|
ncol = int(numpy.sqrt(self.nplots)+0.9)
|
|
|
nrow = int(self.nplots*1./ncol + 0.9)
|
|
|
return nrow, ncol
|
|
|
|
|
|
|
|
|
def setAxesWithOutProfiles(self, nrow, ncol):
|
|
|
colspan = 1
|
|
|
rowspan = 1
|
|
|
counter = 0
|
|
|
|
|
|
for y in range(nrow):
|
|
|
for x in range(ncol):
|
|
|
if counter < self.nplots:
|
|
|
# plt.subplot2grid((nrow, ncol), (y, x), colspan=colspan, rowspan=rowspan)
|
|
|
self.makeAxes(nrow, ncol, y, x, colspan, rowspan)
|
|
|
counter += 1
|
|
|
|
|
|
def setAxesWithProfiles(self, nrow, ncol):
|
|
|
colspan = 1
|
|
|
rowspan = 1
|
|
|
factor = 2
|
|
|
ncol = ncol*factor
|
|
|
counter = 0
|
|
|
|
|
|
for y in range(nrow):
|
|
|
for x in range(ncol):
|
|
|
if counter < self.nplots*factor:
|
|
|
# plt.subplot2grid((nrow, ncol), (y, x), colspan=colspan, rowspan=rowspan)
|
|
|
self.makeAxes(nrow, ncol, y, x, colspan, rowspan)
|
|
|
counter += 1
|
|
|
|
|
|
def setup(self, idfigure, wintitle, width, height, nplots, profile):
|
|
|
self.init(idfigure, wintitle, width, height, nplots)
|
|
|
|
|
|
nrow,ncol = self.getSubplots()
|
|
|
|
|
|
if profile:
|
|
|
self.setAxesWithProfiles(nrow, ncol)
|
|
|
else:
|
|
|
self.setAxesWithOutProfiles(nrow, ncol)
|
|
|
|
|
|
def run(self, dataOut, idfigure, wintitle="", channelList=None, xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, profile=False):
|
|
|
if dataOut.isEmpty():
|
|
|
return None
|
|
|
|
|
|
if channelList == None:
|
|
|
channelList = dataOut.channelList
|
|
|
|
|
|
nplots = len(channelList)
|
|
|
|
|
|
z = 10.*numpy.log10(dataOut.data_spc[channelList,:,:])
|
|
|
|
|
|
y = dataOut.heightList
|
|
|
|
|
|
x = numpy.arange(dataOut.nFFTPoints)
|
|
|
|
|
|
if not self.__isConfig:
|
|
|
self.setup(idfigure=idfigure,
|
|
|
wintitle=wintitle,
|
|
|
width=self.width,
|
|
|
height=self.height,
|
|
|
nplots=nplots,
|
|
|
profile=profile)
|
|
|
|
|
|
if xmin == None: self.xmin = numpy.min(x)
|
|
|
if xmax == None: self.xmax = numpy.max(x)
|
|
|
if ymin == None: self.ymin = numpy.min(y)
|
|
|
if ymax == None: self.ymax = numpy.max(y)
|
|
|
if zmin == None: self.zmin = 0
|
|
|
if zmax == None: self.zmax = 90
|
|
|
|
|
|
self.__isConfig = True
|
|
|
|
|
|
ylabel = "Range[Km]"
|
|
|
|
|
|
xlabel = "m/s"
|
|
|
|
|
|
for i in range(len(self.axesList)):
|
|
|
title = "Channel %d"%i
|
|
|
axes = self.axesList[i]
|
|
|
z2 = z[i,:,:]
|
|
|
axes.pcolor(x, y, z, self.xmin, self.xmax, self.ymin, self.ymax, self.zmin, self.zmax, xlabel, ylabel, title)
|
|
|
|
|
|
|
|
|
self.draw()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Scope(Figure):
|
|
|
__isConfig = None
|
|
|
|
|
|
def __init__(self):
|
|
|
self.__isConfig = False
|
|
|
self.width = 850
|
|
|
self.height = 800
|
|
|
|
|
|
def getSubplots(self):
|
|
|
nrow = self.nplots
|
|
|
ncol = 3
|
|
|
return nrow, ncol
|
|
|
|
|
|
def setup(self, idfigure, wintitle, width, height, nplots):
|
|
|
self.init(idfigure, wintitle, width, height, nplots)
|
|
|
|
|
|
nrow,ncol = self.getSubplots()
|
|
|
colspan = 3
|
|
|
rowspan = 1
|
|
|
|
|
|
for i in range(nplots):
|
|
|
self.makeAxes(nrow, ncol, i, 0, colspan, rowspan)
|
|
|
|
|
|
|
|
|
|
|
|
def run(self, dataOut, idfigure, wintitle="", channelList=None, xmin=None, xmax=None, ymin=None, ymax=None):
|
|
|
|
|
|
if dataOut.isEmpty():
|
|
|
return None
|
|
|
|
|
|
if channelList == None:
|
|
|
channelList = dataOut.channelList
|
|
|
|
|
|
nplots = len(channelList)
|
|
|
|
|
|
y = dataOut.data[channelList,:] * numpy.conjugate(dataOut.data[channelList,:])
|
|
|
y = y.real
|
|
|
|
|
|
x = dataOut.heightList
|
|
|
|
|
|
if not self.__isConfig:
|
|
|
self.setup(idfigure=idfigure,
|
|
|
wintitle=wintitle,
|
|
|
width=self.width,
|
|
|
height=self.height,
|
|
|
nplots=nplots)
|
|
|
|
|
|
if xmin == None: self.xmin = numpy.min(x)
|
|
|
if xmax == None: self.xmax = numpy.max(x)
|
|
|
if ymin == None: self.ymin = numpy.min(y)
|
|
|
if ymax == None: self.ymax = numpy.max(y)
|
|
|
|
|
|
self.__isConfig = True
|
|
|
|
|
|
|
|
|
|
|
|
thisDatetime = datetime.datetime.fromtimestamp(dataOut.utctime)
|
|
|
dateTime = "%s"%(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
|
|
|
date = "%s"%(thisDatetime.strftime("%d-%b-%Y"))
|
|
|
figuretitle = "Scope: " + dateTime
|
|
|
|
|
|
self.setTitle(title=figuretitle)
|
|
|
|
|
|
# self.setTextFromAxes(title=figuretitle)
|
|
|
|
|
|
ylabel = "Intensity"
|
|
|
|
|
|
xlabel = "Range[Km]"
|
|
|
|
|
|
for i in range(len(self.axesList)):
|
|
|
title = "Channel %d"%i
|
|
|
axes = self.axesList[i]
|
|
|
y2 = y[i,:]
|
|
|
axes.pline(x, y2, self.xmin, self.xmax, self.ymin, self.ymax, xlabel, ylabel, title)
|
|
|
|
|
|
self.draw()
|
|
|
|
|
|
|
|
|
|