##// END OF EJS Templates
Adicion del metodo saveFigure() para guardar archivos de imagen de la clase Figure(). Se modifica los xaxis se muestran en formato datetime, falta hacer ajustes en los ticks de acuerdo al intervalo [xmin, xmax]
Adicion del metodo saveFigure() para guardar archivos de imagen de la clase Figure(). Se modifica los xaxis se muestran en formato datetime, falta hacer ajustes en los ticks de acuerdo al intervalo [xmin, xmax]

File last commit:

r209:8c431837892b
r209:8c431837892b
Show More
mpldriver.py
271 lines | 7.7 KiB | text/x-python | PythonLexer
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201 import numpy
Daniel Valdez
Adicion del metodo saveFigure() para guardar archivos de imagen de la clase Figure(). Se modifica los xaxis se muestran en formato datetime, falta hacer ajustes en los ticks de acuerdo al intervalo [xmin, xmax]
r209 import datetime
Daniel Valdez
Se agrega el folder "graphics" que contiene figure.py y mpldriver.py...
r190 import matplotlib
Miguel Valdez
Primera version del controlador probada y testeada incluyendo graficos
r199 matplotlib.use("TKAgg")
Daniel Valdez
Se agrega el folder "graphics" que contiene figure.py y mpldriver.py...
r190 import matplotlib.pyplot
Daniel Valdez
Adicion del metodo saveFigure() para guardar archivos de imagen de la clase Figure(). Se modifica los xaxis se muestran en formato datetime, falta hacer ajustes en los ticks de acuerdo al intervalo [xmin, xmax]
r209 import matplotlib.dates
Miguel Valdez
Controlador de Signal Chain finalizado....
r197 #import scitools.numpyutils
Daniel Valdez
En graphics:...
r192 from mpl_toolkits.axes_grid1 import make_axes_locatable
Daniel Valdez
Se agrega el folder "graphics" que contiene figure.py y mpldriver.py...
r190
Daniel Valdez
Adicion del metodo saveFigure() para guardar archivos de imagen de la clase Figure(). Se modifica los xaxis se muestran en formato datetime, falta hacer ajustes en los ticks de acuerdo al intervalo [xmin, xmax]
r209 from matplotlib.dates import DayLocator, HourLocator, MinuteLocator, SecondLocator, DateFormatter
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201 def init(idfigure, wintitle, width, height, facecolor="w"):
Daniel Valdez
Se agrega el folder "graphics" que contiene figure.py y mpldriver.py...
r190 matplotlib.pyplot.ioff()
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201 fig = matplotlib.pyplot.matplotlib.pyplot.figure(num=idfigure, facecolor=facecolor)
Daniel Valdez
Se agrega el folder "graphics" que contiene figure.py y mpldriver.py...
r190 fig.canvas.manager.set_window_title(wintitle)
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201 fig.canvas.manager.resize(width, height)
Daniel Valdez
Se agrega el folder "graphics" que contiene figure.py y mpldriver.py...
r190 matplotlib.pyplot.ion()
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201
Daniel Valdez
En esta version se ha implementado la clase para ploteo de espectros, a este grafico aun le falta agregar el perfil de potencia para cada canal.
r196 return fig
def setWinTitle(fig, title):
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201
Daniel Valdez
En esta version se ha implementado la clase para ploteo de espectros, a este grafico aun le falta agregar el perfil de potencia para cada canal.
r196 fig.canvas.manager.set_window_title(title)
Daniel Valdez
Se agrega el folder "graphics" que contiene figure.py y mpldriver.py...
r190 def setTitle(idfigure, title):
fig = matplotlib.pyplot.figure(idfigure)
fig.suptitle(title)
def makeAxes(idfigure, nrow, ncol, xpos, ypos, colspan, rowspan):
fig = matplotlib.pyplot.figure(idfigure)
ax = matplotlib.pyplot.subplot2grid((nrow, ncol), (xpos, ypos), colspan=colspan, rowspan=rowspan)
return ax
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201 def setTextFromAxes(idfigure, ax, title):
fig = matplotlib.pyplot.figure(idfigure)
ax.annotate(title, xy=(.1, .99),
xycoords='figure fraction',
horizontalalignment='left', verticalalignment='top',
fontsize=10)
Daniel Valdez
Se agrega el folder "graphics" que contiene figure.py y mpldriver.py...
r190 def pline(ax, x, y, xmin, xmax, ymin, ymax, xlabel, ylabel, title, firsttime):
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201
Daniel Valdez
Se agrega el folder "graphics" que contiene figure.py y mpldriver.py...
r190 if firsttime:
ax.plot(x, y)
ax.set_xlim([xmin,xmax])
ax.set_ylim([ymin,ymax])
ax.set_xlabel(xlabel, size=8)
ax.set_ylabel(ylabel, size=8)
ax.set_title(title, size=10)
matplotlib.pyplot.tight_layout()
else:
ax.lines[0].set_data(x,y)
def draw(idfigure):
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201
Daniel Valdez
Se agrega el folder "graphics" que contiene figure.py y mpldriver.py...
r190 fig = matplotlib.pyplot.figure(idfigure)
fig.canvas.draw()
Daniel Valdez
En graphics:...
r192 def pcolor(ax, x, y, z, xmin, xmax, ymin, ymax, zmin, zmax, xlabel, ylabel, title, firsttime, mesh):
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201
Daniel Valdez
En graphics:...
r192 if firsttime:
divider = make_axes_locatable(ax)
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201 ax_cb = divider.new_horizontal(size="4%", pad=0.05)
Daniel Valdez
En graphics:...
r192 fig1 = ax.get_figure()
fig1.add_axes(ax_cb)
ax.set_xlim([xmin,xmax])
ax.set_ylim([ymin,ymax])
ax.set_xlabel(xlabel)
ax.set_ylabel(ylabel)
ax.set_title(title)
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201 print x
Daniel Valdez
En esta version se ha implementado la clase para ploteo de espectros, a este grafico aun le falta agregar el perfil de potencia para cada canal.
r196 imesh=ax.pcolormesh(x,y,z.T,vmin=zmin,vmax=zmax)
Daniel Valdez
En graphics:...
r192 matplotlib.pyplot.colorbar(imesh, cax=ax_cb)
ax_cb.yaxis.tick_right()
for tl in ax_cb.get_yticklabels():
tl.set_visible(True)
ax_cb.yaxis.tick_right()
matplotlib.pyplot.tight_layout()
return imesh
else:
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201 # ax.set_xlim([xmin,xmax])
# ax.set_ylim([ymin,ymax])
Miguel Valdez
Primera version del controlador probada y testeada incluyendo graficos
r199 ax.set_xlabel(xlabel)
ax.set_ylabel(ylabel)
ax.set_title(title)
Daniel Valdez
En esta version se ha implementado la clase para ploteo de espectros, a este grafico aun le falta agregar el perfil de potencia para cada canal.
r196 z = z.T
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201 # z = z[0:-1,0:-1]
Daniel Valdez
En esta version se ha implementado la clase para ploteo de espectros, a este grafico aun le falta agregar el perfil de potencia para cada canal.
r196 mesh.set_array(z.ravel())
Daniel Valdez
En graphics:...
r192
return mesh
Daniel Valdez
Se agrega el folder "graphics" que contiene figure.py y mpldriver.py...
r190
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201 ###########################################
#Actualizacion de las funciones del driver
###########################################
def createFigure(idfigure, wintitle, width, height, facecolor="w"):
matplotlib.pyplot.ioff()
fig = matplotlib.pyplot.matplotlib.pyplot.figure(num=idfigure, facecolor=facecolor)
fig.canvas.manager.set_window_title(wintitle)
fig.canvas.manager.resize(width, height)
matplotlib.pyplot.ion()
return fig
Miguel Valdez
Metodo destructor agregado a la clase Figure para desactivar el modo interactivo y mantener el gráfico.
r206 def closeFigure():
matplotlib.pyplot.ioff()
matplotlib.pyplot.show()
Daniel Valdez
Adicion de la clase RTIPlot
r207 return
Miguel Valdez
Metodo destructor agregado a la clase Figure para desactivar el modo interactivo y mantener el gráfico.
r206
Daniel Valdez
Adicion del metodo saveFigure() para guardar archivos de imagen de la clase Figure(). Se modifica los xaxis se muestran en formato datetime, falta hacer ajustes en los ticks de acuerdo al intervalo [xmin, xmax]
r209 def saveFigure(fig, filename):
fig.savefig(filename)
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201 def setWinTitle(fig, title):
fig.canvas.manager.set_window_title(title)
def setTitle(fig, title):
fig.suptitle(title)
def createAxes(fig, nrow, ncol, xpos, ypos, colspan, rowspan):
matplotlib.pyplot.figure(fig.number)
axes = matplotlib.pyplot.subplot2grid((nrow, ncol),
(xpos, ypos),
colspan=colspan,
rowspan=rowspan)
return axes
def setAxesText(ax, text):
ax.annotate(text,
xy = (.1, .99),
xycoords = 'figure fraction',
horizontalalignment = 'left',
verticalalignment = 'top',
fontsize = 10)
def printLabels(ax, xlabel, ylabel, title):
ax.set_xlabel(xlabel, size=11)
ax.set_ylabel(ylabel, size=11)
ax.set_title(title, size=12)
Miguel Valdez
-Se agrego el perfil de potencia al grafico de espectros
r204 def createPline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='',
ticksize=9, xtick_visible=True, ytick_visible=True,
nxticks=4, nyticks=10,
grid=None):
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201
Miguel Valdez
-Se agrego el perfil de potencia al grafico de espectros
r204 """
Input:
grid : None, 'both', 'x', 'y'
"""
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201 ax.plot(x, y)
ax.set_xlim([xmin,xmax])
ax.set_ylim([ymin,ymax])
printLabels(ax, xlabel, ylabel, title)
Miguel Valdez
-Se agrego el perfil de potencia al grafico de espectros
r204 ######################################################
xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/nxticks) + int(xmin)
ax.set_xticks(xtickspos)
for tick in ax.get_xticklabels():
tick.set_visible(xtick_visible)
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201
for tick in ax.xaxis.get_major_ticks():
tick.label.set_fontsize(ticksize)
Miguel Valdez
-Se agrego el perfil de potencia al grafico de espectros
r204
######################################################
for tick in ax.get_yticklabels():
tick.set_visible(ytick_visible)
for tick in ax.yaxis.get_major_ticks():
tick.label.set_fontsize(ticksize)
######################################################
if grid != None:
ax.grid(b=True, which='major', axis=grid)
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201 matplotlib.pyplot.tight_layout()
iplot = ax.lines[-1]
return iplot
def pline(iplot, x, y, xlabel='', ylabel='', title=''):
ax = iplot.get_axes()
printLabels(ax, xlabel, ylabel, title)
iplot.set_data(x, y)
Daniel Valdez
Adicion del metodo saveFigure() para guardar archivos de imagen de la clase Figure(). Se modifica los xaxis se muestran en formato datetime, falta hacer ajustes en los ticks de acuerdo al intervalo [xmin, xmax]
r209 def createPcolor(ax, x, y, z, xmin, xmax, ymin, ymax, zmin, zmax, xlabel='', ylabel='', title='', ticksize = 9, cblabel='',XAxisAsTime=False):
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201
divider = make_axes_locatable(ax)
ax_cb = divider.new_horizontal(size="4%", pad=0.05)
fig = ax.get_figure()
fig.add_axes(ax_cb)
ax.set_xlim([xmin,xmax])
Daniel Valdez
Adicion del metodo saveFigure() para guardar archivos de imagen de la clase Figure(). Se modifica los xaxis se muestran en formato datetime, falta hacer ajustes en los ticks de acuerdo al intervalo [xmin, xmax]
r209
if XAxisAsTime:
seconds = numpy.array([xmin, xmax])
datesList = map(datetime.datetime.fromtimestamp, seconds)
ax.set_xlim([datesList[0],datesList[-1]])
ax.xaxis.set_major_locator(MinuteLocator(numpy.arange(0,61,10)))
ax.xaxis.set_minor_locator(SecondLocator(numpy.arange(0,61,60)))
ax.xaxis.set_major_formatter(DateFormatter("%H:%M:%S"))
xdateList = map(datetime.datetime.fromtimestamp, x)
xdate = matplotlib.dates.date2num(xdateList)
x = xdate
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201 ax.set_ylim([ymin,ymax])
printLabels(ax, xlabel, ylabel, title)
imesh = ax.pcolormesh(x,y,z.T,vmin=zmin,vmax=zmax)
cb = matplotlib.pyplot.colorbar(imesh, cax=ax_cb)
cb.set_label(cblabel)
ax_cb.yaxis.tick_right()
for tl in ax_cb.get_yticklabels():
tl.set_visible(True)
for tick in ax.yaxis.get_major_ticks():
tick.label.set_fontsize(ticksize)
for tick in ax.xaxis.get_major_ticks():
tick.label.set_fontsize(ticksize)
for tick in cb.ax.get_yticklabels():
tick.set_fontsize(ticksize)
ax_cb.yaxis.tick_right()
matplotlib.pyplot.tight_layout()
return imesh
Daniel Valdez
Se agrega el folder "graphics" que contiene figure.py y mpldriver.py...
r190
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201 def pcolor(imesh, z, xlabel='', ylabel='', title=''):
z = z.T
ax = imesh.get_axes()
printLabels(ax, xlabel, ylabel, title)
imesh.set_array(z.ravel())
Daniel Valdez
Se agrega el folder "graphics" que contiene figure.py y mpldriver.py...
r190
Daniel Valdez
Adicion de la clase RTIPlot
r207 def addpcolor(ax, x, y, z, zmin, zmax):
Daniel Valdez
Adicion del metodo saveFigure() para guardar archivos de imagen de la clase Figure(). Se modifica los xaxis se muestran en formato datetime, falta hacer ajustes en los ticks de acuerdo al intervalo [xmin, xmax]
r209 xdateList = map(datetime.datetime.fromtimestamp, x)
xdate = matplotlib.dates.date2num(xdateList)
Daniel Valdez
Adicion de la clase RTIPlot
r207
Daniel Valdez
Adicion del metodo saveFigure() para guardar archivos de imagen de la clase Figure(). Se modifica los xaxis se muestran en formato datetime, falta hacer ajustes en los ticks de acuerdo al intervalo [xmin, xmax]
r209 imesh = ax.pcolormesh(xdate,y,z.T,vmin=zmin,vmax=zmax)
Daniel Valdez
Adicion de la clase RTIPlot
r207
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201 def draw(fig):
if type(fig) == 'int':
raise ValueError, "This parameter should be of tpye matplotlib figure"
fig.canvas.draw()