##// END OF EJS Templates
La opcion nombre de graficos ha sido añadida a los modulos de VoltagePlot y SpectraPlot
La opcion nombre de graficos ha sido añadida a los modulos de VoltagePlot y SpectraPlot

File last commit:

r56:b3cb75f14758
r56:b3cb75f14758
Show More
VoltagePlot.py
181 lines | 4.5 KiB | text/x-python | PythonLexer
Miguel Valdez
r11 '''
Created on Feb 7, 2012
Daniel Valdez
Fijando variables svn:keywords Author Id
r16 @author $Author$
@version $Id$
Miguel Valdez
r11 '''
Miguel Valdez
Los campos de Author y Id fueron agregados a todos los modulos
r18 import os, sys
import numpy
import plplot
Miguel Valdez
r11
Miguel Valdez
Los campos de Author y Id fueron agregados a todos los modulos
r18 path = os.path.split(os.getcwd())[0]
sys.path.append(path)
Miguel Valdez
Dentro del paquete IO se agrego un sufijo "IO" a todos los modulos
r20 from Graphics.BaseGraph import *
Miguel Valdez
Los campos de Author y Id fueron agregados a todos los modulos
r18 from Model.Voltage import Voltage
class Osciloscope():
Miguel Valdez
Actualización de la libreria de graficos para manejar varios plots
r43 def __init__(self, Voltage, index=0):
Miguel Valdez
Los campos de Author y Id fueron agregados a todos los modulos
r18
Miguel Valdez
Dentro del paquete IO se agrego un sufijo "IO" a todos los modulos
r20 """
Miguel Valdez
Los campos de Author y Id fueron agregados a todos los modulos
r18
Miguel Valdez
Dentro del paquete IO se agrego un sufijo "IO" a todos los modulos
r20 Inputs:
type: "power" ->> Potencia
"iq" ->> Real + Imaginario
"""
self.__isPlotConfig = False
self.__isPlotIni = False
self.__xrange = None
self.__yrange = None
self.m_Voltage = None
self.nGraphs = 0
Miguel Valdez
Actualización de la libreria de graficos para manejar varios plots
r43 self.indexPlot = index
Miguel Valdez
Dentro del paquete IO se agrego un sufijo "IO" a todos los modulos
r20 self.graphObjList = []
Miguel Valdez
Actualización de la libreria de graficos para manejar varios plots
r43
Miguel Valdez
Dentro del paquete IO se agrego un sufijo "IO" a todos los modulos
r20 self.m_Voltage = Voltage
Miguel Valdez
Los campos de Author y Id fueron agregados a todos los modulos
r18
Miguel Valdez
Dentro del paquete IO se agrego un sufijo "IO" a todos los modulos
r20 def __addGraph(self, subpage, title="", xlabel="", ylabel="", XAxisAsTime=False):
graphObj = LinearPlot()
graphObj.setup(subpage, title="", xlabel="", ylabel="", XAxisAsTime=False)
#graphObj.setScreenPos()
self.graphObjList.append(graphObj)
del graphObj
Miguel Valdez
Los campos de Author y Id fueron agregados a todos los modulos
r18
Miguel Valdez
Dentro del paquete IO se agrego un sufijo "IO" a todos los modulos
r20 # def setXRange(self, xmin, xmax):
# self.__xrange = (xmin, xmax)
#
# def setYRange(self, ymin, ymax):
# self.__yrange = (ymin, ymax)
Miguel Valdez
Los campos de Author y Id fueron agregados a todos los modulos
r18
Miguel Valdez
Dentro del paquete IO se agrego un sufijo "IO" a todos los modulos
r20
def setup(self, titleList=None, xlabelList=None, ylabelList=None, XAxisAsTime=False):
nChan = int(self.m_Voltage.m_SystemHeader.numChannels)
myTitle = ""
myXlabel = ""
myYlabel = ""
for i in range(nChan):
if titleList != None:
myTitle = titleList[i]
myXlabel = xlabelList[i]
myYlabel = ylabelList[i]
self.__addGraph(i+1, title=myTitle, xlabel=myXlabel, ylabel=myYlabel, XAxisAsTime=XAxisAsTime)
self.nGraphs = nChan
self.__isPlotConfig = True
Miguel Valdez
Los campos de Author y Id fueron agregados a todos los modulos
r18
Miguel Valdez
La opcion nombre de graficos ha sido añadida a los modulos de VoltagePlot y SpectraPlot
r56 def iniPlot(self, winTitle=""):
Miguel Valdez
Actualización de la libreria de graficos para manejar varios plots
r43
plplot.plsstrm(self.indexPlot)
Miguel Valdez
La opcion nombre de graficos ha sido añadida a los modulos de VoltagePlot y SpectraPlot
r56 plplot.plparseopts([winTitle], plplot.PL_PARSE_FULL)
Miguel Valdez
Dentro del paquete IO se agrego un sufijo "IO" a todos los modulos
r20 plplot.plsetopt("geometry", "%dx%d" %(700, 115*self.nGraphs))
Miguel Valdez
Se cambio el driver por defecto de las rutinas graficas a "xwin"
r44 plplot.plsdev("xwin")
Miguel Valdez
Dentro del paquete IO se agrego un sufijo "IO" a todos los modulos
r20 plplot.plscolbg(255,255,255)
plplot.plscol0(1,0,0,0)
plplot.plinit()
plplot.plspause(False)
plplot.plssub(1, self.nGraphs)
self.__isPlotIni = True
Miguel Valdez
Los campos de Author y Id fueron agregados a todos los modulos
r18
Miguel Valdez
La opcion nombre de graficos ha sido añadida a los modulos de VoltagePlot y SpectraPlot
r56 def plotData(self, xmin=None, xmax=None, ymin=None, ymax=None, idProfile=None, titleList=None, xlabelList=None, ylabelList=None, XAxisAsTime=False, type='iq', winTitle="Voltage"):
Miguel Valdez
Dentro del paquete IO se agrego un sufijo "IO" a todos los modulos
r20
if idProfile != None and idProfile != self.m_Voltage.idProfile:
return
if not(self.__isPlotConfig):
self.setup(titleList, xlabelList, ylabelList, XAxisAsTime)
if not(self.__isPlotIni):
self.iniPlot()
Miguel Valdez
r45 plplot.plsstrm(self.indexPlot)
Miguel Valdez
Dentro del paquete IO se agrego un sufijo "IO" a todos los modulos
r20 data = self.m_Voltage.data
x = self.m_Voltage.heights
if xmin == None: xmin = x[0]
if xmax == None: xmax = x[-1]
if ymin == None: ymin = numpy.nanmin(abs(data))
if ymax == None: ymax = numpy.nanmax(abs(data))
plplot.plbop()
for i in range(self.nGraphs):
y = data[:,i]
self.graphObjList[i].iniSubpage()
self.graphObjList[i].plotComplexData(x, y, xmin, xmax, ymin, ymax, 8, type)
plplot.plflush()
plplot.pleop()
def end(self):
plplot.plend()
Miguel Valdez
r11 class VoltagePlot(object):
'''
classdocs
'''
Miguel Valdez
Los campos de Author y Id fueron agregados a todos los modulos
r18 __m_Voltage = None
def __init__(self, m_Voltage):
Miguel Valdez
r11 '''
Constructor
'''
Miguel Valdez
Los campos de Author y Id fueron agregados a todos los modulos
r18 self.__m_Voltage = m_Voltage
def setup(self):
pass
def addGraph(self, type, xrange=None, yrange=None, zrange=None):
pass
def plotData(self):
pass
if __name__ == '__main__':
import numpy
plplot.plsetopt("geometry", "%dx%d" %(450*2, 200*2))
plplot.plsdev("xcairo")
plplot.plscolbg(255,255,255)
plplot.plscol0(1,0,0,0)
plplot.plinit()
plplot.plssub(1, 2)
nx = 64
ny = 100
data = numpy.random.uniform(-50,50,(nx,ny))
baseObj = RTI()
baseObj.setup(1, "Spectrum", "Frequency", "Range", "br_green", False, False)
baseObj.plotData(data)
data = numpy.random.uniform(-50,50,(nx,ny))
base2Obj = RTI()
base2Obj.setup(2, "Spectrum", "Frequency", "Range", "br_green", True, True)
base2Obj.plotData(data)
plplot.plend()
exit(0)