schainPlotTypes.py
106 lines
| 3.0 KiB
| text/x-python
|
PythonLexer
|
r133 | import numpy | ||
from schainPlot import * | ||||
|
r135 | #from schainPlotLib import Driver | ||
|
r133 | |||
class ScopeFigure(Figure): | ||||
overplot = 0 | ||||
xw = 700 | ||||
|
r135 | yw = 650 | ||
colorbar = None | ||||
# frameObjList = [] | ||||
|
r133 | |||
|
r134 | def __init__(self,idfigure,nframes,wintitle,driver): | ||
colormap = None | ||||
|
r135 | colorbar = False | ||
addGraph = 0 | ||||
args=(addGraph, addGraph) | ||||
|
r133 | |||
|
r135 | self.idfigure = idfigure | ||
|
r133 | self.nframes = nframes | ||
|
r135 | self.wintitle = wintitle | ||
# self.xw = | ||||
# self.yw = | ||||
# self.overplot = | ||||
self.driver = driver | ||||
self.colorbar = colorbar | ||||
self.colormap = colormap | ||||
|
r133 | |||
|
r135 | self.drvObj = Driver(self.driver, self.idfigure, self.xw, self.yw, self.wintitle, self.overplot, self.colorbar, self.colormap) | ||
self.drvObj.driver.setFigure() | ||||
|
r133 | |||
|
r135 | # Figure.__init__(self,idfigure,nframes,wintitle,self.xw,self.yw,self.overplot,driver,colorbar,colormap,*args) | ||
|
r133 | |||
def getSubplots(self): | ||||
nrows = self.nframes | ||||
ncolumns = 1 | ||||
return nrows, ncolumns | ||||
|
r135 | |||
def createFrames(self): | ||||
|
r133 | for frame in range(self.nframes): | ||
|
r135 | frameObj = ScopeFrame(self.drvObj,frame + 1) | ||
|
r133 | self.frameObjList.append(frameObj) | ||
|
r135 | |||
|
r133 | |||
|
r135 | class ScopeFrame(Frame): | ||
# plotObjList = [] | ||||
xlabel = "" | ||||
ylabel = "" | ||||
title = "" | ||||
def __init__(self,drvObj,idframe): | ||||
self.drvObj = drvObj | ||||
self.idframe = idframe | ||||
self.nplots = 1 #nplots/frame | ||||
self.createPlots() | ||||
# Frame.__init__(self, drvObj, idframe) | ||||
|
r133 | |||
|
r135 | def getScreenPosMainPlot(self):#cada Frame determina las coordenadas de los plots | ||
xi = 0.07; xw = 0.9 | ||||
yi = 0.20; yw = 0.75 | ||||
return xi,yi,xw,yw | ||||
|
r133 | |||
|
r135 | def createPlots(self): | ||
plotObjList = [] | ||||
for idplot in range(self.nplots): | ||||
xi, yi, xw, yw = self.getScreenPos(idplot) | ||||
plotObj = Plot1D(self.drvObj, self.idframe, idplot, xi, yi, xw, yw) | ||||
plotObjList.append(plotObj) | ||||
self.plotObjList = plotObjList | ||||
# self.plotObjList.append(plotObj) | ||||
|
r133 | |||
|
r135 | def plot(self, x, y, z=None): | ||
for plotObj in self.plotObjList: | ||||
plotObj.plot(x, y) | ||||
|
r133 | |||
|
r135 | class Plot1D(Plot): | ||
def __init__(self, drvObj, idframe, idplot, xi, yi, xw, yw): | ||||
self.drvObj = drvObj | ||||
self.idframe = idframe | ||||
self.idplot = idplot | ||||
self.xi = xi | ||||
self.yi = yi | ||||
self.xw = xw | ||||
self.yw = yw | ||||
self.xpos = [self.xi,self.xw] | ||||
self.ypos = [self.yi,self.yw] | ||||
self.xaxisastime = False | ||||
self.timefmt = None | ||||
self.xopt = "bcnst" | ||||
self.yopt = "bcnstv" | ||||
self.szchar = 1.0 | ||||
self.title = "Channel %d"%self.idframe | ||||
self.xlabel = "x-axis" | ||||
self.ylabel = "y-axis" | ||||
|
r133 | |||
|
r134 | |||
|
r135 | def plot(self,x,y): | ||
if y.dtype == "complex128": | ||||
color="blue" | ||||
self.plotBasicLine(x, y.real, color) | ||||
color="red" | ||||
self.plotBasicLine(x, y.imag, color) | ||||
else: | ||||
color="blue" | ||||
self.plotBasicLine(x, y, color) | ||||