##// END OF EJS Templates
Adicion de la clase ProfilePlot, CoherencePLot en el modulo jroplot.py...
Adicion de la clase ProfilePlot, CoherencePLot en el modulo jroplot.py Adicion de los metodos para graficos multilinea en figure.py y en mpldriver.py Se agrega el colormap como parametro para el metodo addpcolor en mpldriver.py Se hacen ajustes en los xticks cuando la diferencia entre xmax y xmin es menor igual a uno.

File last commit:

r169:661bb8af254a
r229:22aec8924dc0
Show More
VoltagePlot.py
199 lines | 6.9 KiB | text/x-python | PythonLexer
Miguel Valdez
r99 '''
Created on Feb 7, 2012
@author $Author$
@version $Id$
'''
import numpy
Daniel Valdez
Esta version actualiza las librerias de ploteo para graficos RTI, Spectra y Scope, tambien se agregan metodos para procesamiento de Spectra y Voltage. En el caso de Voltage, en la Integracion Coherente se realiza indicando el tiempo de integracion en minutos.
r108 import os
import sys
Miguel Valdez
r99
path = os.path.split(os.getcwd())[0]
sys.path.append(path)
from Graphics.BaseGraph import *
from Model.Voltage import Voltage
class Osciloscope:
Daniel Valdez
Esta version actualiza las librerias de ploteo para graficos RTI, Spectra y Scope, tambien se agregan metodos para procesamiento de Spectra y Voltage. En el caso de Voltage, en la Integracion Coherente se realiza indicando el tiempo de integracion en minutos.
r108 linearplotObj = None
Miguel Valdez
r99
Daniel Valdez
Esta version actualiza las librerias de ploteo para graficos RTI, Spectra y Scope, tambien se agregan metodos para procesamiento de Spectra y Voltage. En el caso de Voltage, en la Integracion Coherente se realiza indicando el tiempo de integracion en minutos.
r108 def __init__(self, Voltage, index):
self.__isPlotConfig = False
self.__isPlotIni = False
self.__xrange = None
self.__yrange = None
self.indexPlot = index
self.voltageObj = Voltage
Miguel Valdez
r99
Daniel Valdez
Esta version actualiza las librerias de ploteo para graficos RTI, Spectra y Scope, tambien se agregan metodos para procesamiento de Spectra y Voltage. En el caso de Voltage, en la Integracion Coherente se realiza indicando el tiempo de integracion en minutos.
r108 def setup(self,indexPlot,nsubplot,winTitle=''):
self.linearplotObj = LinearPlot(indexPlot,nsubplot,winTitle)
Miguel Valdez
r99
Daniel Valdez
Esta version actualiza las librerias de ploteo para graficos RTI, Spectra y Scope, tambien se agregan metodos para procesamiento de Spectra y Voltage. En el caso de Voltage, en la Integracion Coherente se realiza indicando el tiempo de integracion en minutos.
r108 def initPlot(self,xmin,xmax,ymin,ymax,titleList,xlabelList,ylabelList):
nsubplot = self.voltageObj.nChannels
Miguel Valdez
r99
Daniel Valdez
Esta version actualiza las librerias de ploteo para graficos RTI, Spectra y Scope, tambien se agregan metodos para procesamiento de Spectra y Voltage. En el caso de Voltage, en la Integracion Coherente se realiza indicando el tiempo de integracion en minutos.
r108 for index in range(nsubplot):
title = titleList[index]
xlabel = xlabelList[index]
ylabel = ylabelList[index]
subplot = index
self.linearplotObj.setup(subplot+1,xmin,xmax,ymin,ymax,title,xlabel,ylabel)
Miguel Valdez
r99
Daniel Valdez
Esta version actualiza las librerias de ploteo para graficos RTI, Spectra y Scope, tambien se agregan metodos para procesamiento de Spectra y Voltage. En el caso de Voltage, en la Integracion Coherente se realiza indicando el tiempo de integracion en minutos.
r108 def plotData(self,
xmin=None,
xmax=None,
ymin=None,
ymax=None,
titleList=None,
xlabelList=None,
ylabelList=None,
winTitle='',
type="power"):
Miguel Valdez
r99
Daniel Valdez
Esta version actualiza las librerias de ploteo para graficos RTI, Spectra y Scope, tambien se agregan metodos para procesamiento de Spectra y Voltage. En el caso de Voltage, en la Integracion Coherente se realiza indicando el tiempo de integracion en minutos.
r108 databuffer = self.voltageObj.data
Miguel Valdez
r99
Daniel Valdez
Esta version actualiza las librerias de ploteo para graficos RTI, Spectra y Scope, tambien se agregan metodos para procesamiento de Spectra y Voltage. En el caso de Voltage, en la Integracion Coherente se realiza indicando el tiempo de integracion en minutos.
r108 height = self.voltageObj.heightList
nsubplot = self.voltageObj.nChannels
indexPlot = self.indexPlot
Miguel Valdez
r99
Daniel Valdez
Esta version actualiza las librerias de ploteo para graficos RTI, Spectra y Scope, tambien se agregan metodos para procesamiento de Spectra y Voltage. En el caso de Voltage, en la Integracion Coherente se realiza indicando el tiempo de integracion en minutos.
r108 if not(self.__isPlotConfig):
self.setup(indexPlot,nsubplot,winTitle)
self.__isPlotConfig = True
Miguel Valdez
r99
Daniel Valdez
Esta version actualiza las librerias de ploteo para graficos RTI, Spectra y Scope, tambien se agregan metodos para procesamiento de Spectra y Voltage. En el caso de Voltage, en la Integracion Coherente se realiza indicando el tiempo de integracion en minutos.
r108 if not(self.__isPlotIni):
if titleList == None:
titleList = []
thisDatetime = datetime.datetime.fromtimestamp(self.voltageObj.m_BasicHeader.utc)
txtdate = "Date: %s" %(thisDatetime.strftime("%d-%b-%Y"))
for i in range(nsubplot):
titleList.append("Channel: %d %s" %(i, txtdate))
if xlabelList == None:
xlabelList = []
for i in range(nsubplot):
xlabelList.append("")
if ylabelList == None:
ylabelList = []
for i in range(nsubplot):
ylabelList.append("")
if xmin == None: xmin = height[0]
if xmax == None: xmax = height[-1]
if ymin == None: ymin = numpy.nanmin(abs(databuffer))
if ymax == None: ymax = numpy.nanmax(abs(databuffer))
self.initPlot(xmin,xmax,ymin,ymax,titleList,xlabelList,ylabelList)
self.__isPlotIni = True
Miguel Valdez
r99
Daniel Valdez
Esta version actualiza las librerias de ploteo para graficos RTI, Spectra y Scope, tambien se agregan metodos para procesamiento de Spectra y Voltage. En el caso de Voltage, en la Integracion Coherente se realiza indicando el tiempo de integracion en minutos.
r108 self.linearplotObj.setFigure(indexPlot)
Miguel Valdez
r99
Daniel Valdez
Esta version actualiza las librerias de ploteo para graficos RTI, Spectra y Scope, tambien se agregan metodos para procesamiento de Spectra y Voltage. En el caso de Voltage, en la Integracion Coherente se realiza indicando el tiempo de integracion en minutos.
r108 for index in range(nsubplot):
data = databuffer[index,:]
self.linearplotObj.plot(subplot=index+1,x=height,y=data,type=type)
Miguel Valdez
r99
Daniel Valdez
Esta version actualiza las librerias de ploteo para graficos RTI, Spectra y Scope, tambien se agregan metodos para procesamiento de Spectra y Voltage. En el caso de Voltage, en la Integracion Coherente se realiza indicando el tiempo de integracion en minutos.
r108 self.linearplotObj.refresh()
Miguel Valdez
r99
Daniel Valdez
Esta version actualiza las librerias de ploteo para graficos RTI, Spectra y Scope, tambien se agregan metodos para procesamiento de Spectra y Voltage. En el caso de Voltage, en la Integracion Coherente se realiza indicando el tiempo de integracion en minutos.
r108 class RTI:
colorplotObj = None
Miguel Valdez
r99
Daniel Valdez
Esta version actualiza las librerias de ploteo para graficos RTI, Spectra y Scope, tambien se agregan metodos para procesamiento de Spectra y Voltage. En el caso de Voltage, en la Integracion Coherente se realiza indicando el tiempo de integracion en minutos.
r108 def __init__(self, Voltage, index):
self.__isPlotConfig = False
self.__isPlotIni = False
self.__xrange = None
self.__yrange = None
self.indexPlot = index
self.voltageObj = Voltage
def setup(self,indexPlot,nsubplot,winTitle='',colormap="br_green",showColorbar=False,showPowerProfile=False,XAxisAsTime=False):
self.colorplotObj = RtiPlot(indexPlot,nsubplot,winTitle,colormap,showColorbar,showPowerProfile,XAxisAsTime)
def initPlot(self,xmin,xmax,ymin,ymax,zmin,zmax,titleList,xlabelList,ylabelList,timezone,npoints):
nsubplot = self.voltageObj.nChannels
timedata = self.voltageObj.m_BasicHeader.utc
for index in range(nsubplot):
title = titleList[index]
xlabel = xlabelList[index]
ylabel = ylabelList[index]
subplot = index
self.colorplotObj.setup(subplot+1,xmin,xmax,ymin,ymax,zmin,zmax,title,xlabel,ylabel,timedata,timezone,npoints)
def plotData(self,
xmin=None,
xmax=None,
ymin=None,
ymax=None,
zmin=None,
zmax=None,
titleList=None,
xlabelList=None,
ylabelList=None,
winTitle='',
timezone='lt',
npoints=1000.0,
colormap="br_green",
showColorbar=True,
showPowerProfile=True,
Daniel Valdez
Agregando funciones para guardar graficos del tipo Voltage
r113 XAxisAsTime=True,
save = False):
Daniel Valdez
Esta version actualiza las librerias de ploteo para graficos RTI, Spectra y Scope, tambien se agregan metodos para procesamiento de Spectra y Voltage. En el caso de Voltage, en la Integracion Coherente se realiza indicando el tiempo de integracion en minutos.
r108
databuffer = self.voltageObj.data
timedata = self.voltageObj.m_BasicHeader.utc
height = self.voltageObj.heightList
nsubplot = self.voltageObj.nChannels
indexPlot = self.indexPlot
Miguel Valdez
r99 if not(self.__isPlotConfig):
Daniel Valdez
Esta version actualiza las librerias de ploteo para graficos RTI, Spectra y Scope, tambien se agregan metodos para procesamiento de Spectra y Voltage. En el caso de Voltage, en la Integracion Coherente se realiza indicando el tiempo de integracion en minutos.
r108 self.setup(indexPlot,nsubplot,winTitle,colormap,showColorbar,showPowerProfile,XAxisAsTime)
self.__isPlotConfig = True
Miguel Valdez
r99 if not(self.__isPlotIni):
Daniel Valdez
Esta version actualiza las librerias de ploteo para graficos RTI, Spectra y Scope, tambien se agregan metodos para procesamiento de Spectra y Voltage. En el caso de Voltage, en la Integracion Coherente se realiza indicando el tiempo de integracion en minutos.
r108 if titleList == None:
titleList = []
thisDatetime = datetime.datetime.fromtimestamp(timedata)
txtdate = "Date: %s" %(thisDatetime.strftime("%d-%b-%Y"))
for i in range(nsubplot):
titleList.append("Channel: %d %s" %(i, txtdate))
if xlabelList == None:
xlabelList = []
for i in range(nsubplot):
xlabelList.append("")
if ylabelList == None:
ylabelList = []
for i in range(nsubplot):
ylabelList.append("")
if xmin == None: xmin = 0
if xmax == None: xmax = 23
if ymin == None: ymin = min(self.voltageObj.heightList)
if ymax == None: ymax = max(self.voltageObj.heightList)
if zmin == None: zmin = 0
if zmax == None: zmax = 50
self.initPlot(xmin,xmax,ymin,ymax,zmin,zmax,titleList,xlabelList,ylabelList,timezone,npoints)
self.__isPlotIni = True
Miguel Valdez
r99
Daniel Valdez
Esta version actualiza las librerias de ploteo para graficos RTI, Spectra y Scope, tambien se agregan metodos para procesamiento de Spectra y Voltage. En el caso de Voltage, en la Integracion Coherente se realiza indicando el tiempo de integracion en minutos.
r108
self.colorplotObj.setFigure(indexPlot)
Miguel Valdez
r99
Daniel Valdez
Esta version actualiza las librerias de ploteo para graficos RTI, Spectra y Scope, tambien se agregan metodos para procesamiento de Spectra y Voltage. En el caso de Voltage, en la Integracion Coherente se realiza indicando el tiempo de integracion en minutos.
r108 if timezone == 'lt':
timedata = timedata - time.timezone
Miguel Valdez
r99
Daniel Valdez
Esta version actualiza las librerias de ploteo para graficos RTI, Spectra y Scope, tambien se agregan metodos para procesamiento de Spectra y Voltage. En el caso de Voltage, en la Integracion Coherente se realiza indicando el tiempo de integracion en minutos.
r108 for index in range(nsubplot):
data = databuffer[index,:]
self.colorplotObj.plot(subplot=index+1,x=timedata,y=height,z=data)
Miguel Valdez
r99
Daniel Valdez
Esta version actualiza las librerias de ploteo para graficos RTI, Spectra y Scope, tambien se agregan metodos para procesamiento de Spectra y Voltage. En el caso de Voltage, en la Integracion Coherente se realiza indicando el tiempo de integracion en minutos.
r108 self.colorplotObj.refresh()
Daniel Valdez
Agregando funciones para guardar graficos del tipo Voltage
r113
if save:
self.colorplotObj.setFigure(indexPlot)
path = "/Users/jro/Pictures"
now = datetime.datetime.now().timetuple()
file = "rti_img%02d_%03d_%02d%02d%02d.png"%(indexPlot,now[7],now[3],now[4],now[5])
filename = os.path.join(path,file)
self.colorplotObj.savePlot(indexPlot, filename)