##// 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:

r229:22aec8924dc0
r229:22aec8924dc0
Show More
jroplot.py
873 lines | 28.7 KiB | text/x-python | PythonLexer
Daniel Valdez
Se agrega el folder "graphics" que contiene figure.py y mpldriver.py...
r190 import numpy
Miguel Valdez
-Se agrego la funcionalidad de replotear el grafico de RTI, ademas de los parametros timerange, xmin, xmax...
r210 import time, datetime
Daniel Valdez
Se agrega el folder "graphics" que contiene figure.py y mpldriver.py...
r190 from graphics.figure import *
Daniel Valdez
Se agrega clase para ploteo de Espectros Cruzados.
r215 class CrossSpectraPlot(Figure):
__isConfig = None
__nsubplots = None
WIDTHPROF = None
HEIGHTPROF = None
Miguel Valdez
Se restrige el numero de pares a graficar en Cross-Spectra....
r228 PREFIX = 'cspc'
Daniel Valdez
Se agrega clase para ploteo de Espectros Cruzados.
r215
def __init__(self):
self.__isConfig = False
self.__nsubplots = 4
self.WIDTH = 300
self.HEIGHT = 400
self.WIDTHPROF = 0
self.HEIGHTPROF = 0
def getSubplots(self):
ncol = 4
nrow = self.nplots
return nrow, ncol
def setup(self, idfigure, nplots, wintitle, showprofile=True):
self.__showprofile = showprofile
self.nplots = nplots
ncolspan = 1
colspan = 1
self.createFigure(idfigure = idfigure,
wintitle = wintitle,
widthplot = self.WIDTH + self.WIDTHPROF,
heightplot = self.HEIGHT + self.HEIGHTPROF)
nrow, ncol = self.getSubplots()
counter = 0
for y in range(nrow):
for x in range(ncol):
self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
counter += 1
def run(self, dataOut, idfigure, wintitle="", pairsList=None, showprofile='True',
xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
save=False, figpath='./', figfile=None):
"""
Input:
dataOut :
idfigure :
wintitle :
channelList :
showProfile :
xmin : None,
xmax : None,
ymin : None,
ymax : None,
zmin : None,
zmax : None
"""
if pairsList == None:
pairsIndexList = dataOut.pairsIndexList
else:
pairsIndexList = []
for pair in pairsList:
if pair not in dataOut.pairsList:
raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair)
pairsIndexList.append(dataOut.pairsList.index(pair))
Miguel Valdez
Bugs fixed: Eliminacion de numpy.abs() en el calculo de las cross-correlaciones y mejoras en los graficos de CrossSpectra
r227 if pairsIndexList == []:
Miguel Valdez
Busqueda de archivos dentro del directorio indicado (sin busqueda de subdirectorios) activando el flag de lectura 'walk'
r224 return
Miguel Valdez
Se restrige el numero de pares a graficar en Cross-Spectra....
r228 if len(pairsIndexList) > 4:
pairsIndexList = pairsIndexList[0:4]
Miguel Valdez
Bugs fixed: Eliminacion de numpy.abs() en el calculo de las cross-correlaciones y mejoras en los graficos de CrossSpectra
r227 x = dataOut.getFreqRange(1)
Daniel Valdez
Se agrega clase para ploteo de Espectros Cruzados.
r215 y = dataOut.getHeiRange()
z = 10.*numpy.log10(dataOut.data_spc[:,:,:])
avg = numpy.average(numpy.abs(z), axis=1)
noise = dataOut.getNoise()
if not self.__isConfig:
nplots = len(pairsIndexList)
self.setup(idfigure=idfigure,
nplots=nplots,
wintitle=wintitle,
showprofile=showprofile)
if xmin == None: xmin = numpy.nanmin(x)
if xmax == None: xmax = numpy.nanmax(x)
if ymin == None: ymin = numpy.nanmin(y)
if ymax == None: ymax = numpy.nanmax(y)
if zmin == None: zmin = numpy.nanmin(avg)*0.9
if zmax == None: zmax = numpy.nanmax(avg)*0.9
self.__isConfig = True
Miguel Valdez
Busqueda de archivos dentro del directorio indicado (sin busqueda de subdirectorios) activando el flag de lectura 'walk'
r224 thisDatetime = dataOut.datatime
Miguel Valdez
Se restrige el numero de pares a graficar en Cross-Spectra....
r228 title = "Cross-Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
Daniel Valdez
Se agrega clase para ploteo de Espectros Cruzados.
r215 xlabel = "Velocity (m/s)"
ylabel = "Range (Km)"
self.setWinTitle(title)
for i in range(self.nplots):
pair = dataOut.pairsList[pairsIndexList[i]]
title = "Channel %d: %4.2fdB" %(pair[0], noise[pair[0]])
z = 10.*numpy.log10(dataOut.data_spc[pair[0],:,:])
axes0 = self.axesList[i*self.__nsubplots]
axes0.pcolor(x, y, z,
xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
xlabel=xlabel, ylabel=ylabel, title=title,
ticksize=9, cblabel='')
title = "Channel %d: %4.2fdB" %(pair[1], noise[pair[1]])
z = 10.*numpy.log10(dataOut.data_spc[pair[1],:,:])
axes0 = self.axesList[i*self.__nsubplots+1]
axes0.pcolor(x, y, z,
xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
xlabel=xlabel, ylabel=ylabel, title=title,
ticksize=9, cblabel='')
coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:])
coherence = numpy.abs(coherenceComplex)
phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi
title = "Coherence %d%d" %(pair[0], pair[1])
axes0 = self.axesList[i*self.__nsubplots+2]
axes0.pcolor(x, y, coherence,
Miguel Valdez
Bugs fixed: Eliminacion de numpy.abs() en el calculo de las cross-correlaciones y mejoras en los graficos de CrossSpectra
r227 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1,
Daniel Valdez
Se agrega clase para ploteo de Espectros Cruzados.
r215 xlabel=xlabel, ylabel=ylabel, title=title,
ticksize=9, cblabel='')
title = "Phase %d%d" %(pair[0], pair[1])
axes0 = self.axesList[i*self.__nsubplots+3]
axes0.pcolor(x, y, phase,
xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180,
xlabel=xlabel, ylabel=ylabel, title=title,
Miguel Valdez
Bugs fixed: Eliminacion de numpy.abs() en el calculo de las cross-correlaciones y mejoras en los graficos de CrossSpectra
r227 ticksize=9, cblabel='', colormap='RdBu')
Daniel Valdez
Se agrega clase para ploteo de Espectros Cruzados.
r215
self.draw()
if save:
date = thisDatetime.strftime("%Y%m%d")
if figfile == None:
figfile = self.getFilename(name = date)
self.saveFigure(figpath, figfile)
Daniel Valdez
Adicion de la clase RTIPlot
r207 class RTIPlot(Figure):
__isConfig = None
__nsubplots = None
WIDTHPROF = None
HEIGHTPROF = None
Miguel Valdez
Se mejora el metodo para grabar graficos de RTI y Spectra....
r212 PREFIX = 'rti'
Daniel Valdez
Adicion de la clase RTIPlot
r207
def __init__(self):
Miguel Valdez
-Se agrego la funcionalidad de replotear el grafico de RTI, ademas de los parametros timerange, xmin, xmax...
r210 self.__timerange = 24*60*60
Daniel Valdez
Adicion de la clase RTIPlot
r207 self.__isConfig = False
self.__nsubplots = 1
self.WIDTH = 800
Miguel Valdez
Se mejora el metodo para grabar graficos de RTI y Spectra....
r212 self.HEIGHT = 200
Daniel Valdez
Adicion de la clase RTIPlot
r207 self.WIDTHPROF = 120
self.HEIGHTPROF = 0
def getSubplots(self):
ncol = 1
nrow = self.nplots
return nrow, ncol
def setup(self, idfigure, nplots, wintitle, showprofile=True):
self.__showprofile = showprofile
self.nplots = nplots
ncolspan = 1
colspan = 1
if showprofile:
ncolspan = 7
colspan = 6
self.__nsubplots = 2
Miguel Valdez
-Se agrego la funcionalidad de replotear el grafico de RTI, ademas de los parametros timerange, xmin, xmax...
r210 self.createFigure(idfigure = idfigure,
wintitle = wintitle,
widthplot = self.WIDTH + self.WIDTHPROF,
heightplot = self.HEIGHT + self.HEIGHTPROF)
Daniel Valdez
Adicion de la clase RTIPlot
r207
nrow, ncol = self.getSubplots()
counter = 0
for y in range(nrow):
for x in range(ncol):
if counter >= self.nplots:
break
self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
if showprofile:
self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
counter += 1
Miguel Valdez
-Se agrego la funcionalidad de replotear el grafico de RTI, ademas de los parametros timerange, xmin, xmax...
r210 def __getTimeLim(self, x, xmin, xmax):
Miguel Valdez
Se restrige el numero de pares a graficar en Cross-Spectra....
r228 thisdatetime = datetime.datetime.fromtimestamp(numpy.min(x))
Miguel Valdez
-Se agrego la funcionalidad de replotear el grafico de RTI, ademas de los parametros timerange, xmin, xmax...
r210 thisdate = datetime.datetime.combine(thisdatetime.date(), datetime.time(0,0,0))
####################################################
#If the x is out of xrange
if xmax < (thisdatetime - thisdate).seconds/(60*60.):
xmin = None
xmax = None
if xmin == None:
td = thisdatetime - thisdate
xmin = td.seconds/(60*60.)
if xmax == None:
xmax = xmin + self.__timerange/(60*60.)
mindt = thisdate + datetime.timedelta(0,0,0,0,0, xmin)
tmin = time.mktime(mindt.timetuple())
maxdt = thisdate + datetime.timedelta(0,0,0,0,0, xmax)
tmax = time.mktime(maxdt.timetuple())
self.__timerange = tmax - tmin
return tmin, tmax
Daniel Valdez
Adicion de la clase RTIPlot
r207 def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True',
Miguel Valdez
-Se agrego la funcionalidad de replotear el grafico de RTI, ademas de los parametros timerange, xmin, xmax...
r210 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
timerange=None,
Miguel Valdez
Se mejora el metodo para grabar graficos de RTI y Spectra....
r212 save=False, figpath='./', figfile=None):
Daniel Valdez
Adicion de la clase RTIPlot
r207
"""
Input:
dataOut :
idfigure :
wintitle :
channelList :
showProfile :
xmin : None,
xmax : None,
ymin : None,
ymax : None,
zmin : None,
zmax : None
"""
if channelList == None:
channelIndexList = dataOut.channelIndexList
else:
channelIndexList = []
for channel in channelList:
if channel not in dataOut.channelList:
raise ValueError, "Channel %d is not in dataOut.channelList"
Daniel Valdez
Se agrega clase para ploteo de Espectros Cruzados.
r215 channelIndexList.append(dataOut.channelList.index(channel))
Daniel Valdez
Adicion de la clase RTIPlot
r207
Miguel Valdez
-Se agrego la funcionalidad de replotear el grafico de RTI, ademas de los parametros timerange, xmin, xmax...
r210 if timerange != None:
self.__timerange = timerange
tmin = None
tmax = None
Miguel Valdez
Busqueda de archivos dentro del directorio indicado (sin busqueda de subdirectorios) activando el flag de lectura 'walk'
r224 x = dataOut.getTimeRange()
Daniel Valdez
Adicion de la clase RTIPlot
r207 y = dataOut.getHeiRange()
z = 10.*numpy.log10(dataOut.data_spc[channelIndexList,:,:])
avg = numpy.average(z, axis=1)
noise = dataOut.getNoise()
Miguel Valdez
-Se agrego la funcionalidad de replotear el grafico de RTI, ademas de los parametros timerange, xmin, xmax...
r210
Daniel Valdez
Adicion de la clase RTIPlot
r207 if not self.__isConfig:
nplots = len(channelIndexList)
self.setup(idfigure=idfigure,
nplots=nplots,
wintitle=wintitle,
showprofile=showprofile)
Miguel Valdez
-Se agrego la funcionalidad de replotear el grafico de RTI, ademas de los parametros timerange, xmin, xmax...
r210 tmin, tmax = self.__getTimeLim(x, xmin, xmax)
Daniel Valdez
Adicion de la clase RTIPlot
r207 if ymin == None: ymin = numpy.nanmin(y)
if ymax == None: ymax = numpy.nanmax(y)
if zmin == None: zmin = numpy.nanmin(avg)*0.9
if zmax == None: zmax = numpy.nanmax(avg)*0.9
self.__isConfig = True
Miguel Valdez
Busqueda de archivos dentro del directorio indicado (sin busqueda de subdirectorios) activando el flag de lectura 'walk'
r224 thisDatetime = dataOut.datatime
Miguel Valdez
-Se agrego la funcionalidad de replotear el grafico de RTI, ademas de los parametros timerange, xmin, xmax...
r210 title = "RTI: %s" %(thisDatetime.strftime("%d-%b-%Y"))
Daniel Valdez
Adicion de la clase RTIPlot
r207 xlabel = "Velocity (m/s)"
ylabel = "Range (Km)"
self.setWinTitle(title)
for i in range(self.nplots):
Miguel Valdez
-Se agrego la funcionalidad de replotear el grafico de RTI, ademas de los parametros timerange, xmin, xmax...
r210 title = "Channel %d: %s" %(dataOut.channelList[i], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
Daniel Valdez
Adicion de la clase RTIPlot
r207 axes = self.axesList[i*self.__nsubplots]
z = avg[i].reshape((1,-1))
axes.pcolor(x, y, z,
Miguel Valdez
-Se agrego la funcionalidad de replotear el grafico de RTI, ademas de los parametros timerange, xmin, xmax...
r210 xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=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 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
Miguel Valdez
Se adecuo el ancho del colorbar de acuerdo al tipo de grafico
r211 ticksize=9, cblabel='', cbsize="1%")
Daniel Valdez
Adicion de la clase RTIPlot
r207
if self.__showprofile:
axes = self.axesList[i*self.__nsubplots +1]
axes.pline(avg[i], y,
xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
xlabel='dB', ylabel='', title='',
ytick_visible=False,
grid='x')
self.draw()
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 save:
Miguel Valdez
Se mejora el metodo para grabar graficos de RTI y Spectra....
r212 date = thisDatetime.strftime("%Y%m%d")
if figfile == None:
figfile = self.getFilename(name = date)
self.saveFigure(figpath, figfile)
Miguel Valdez
-Se agrego la funcionalidad de replotear el grafico de RTI, ademas de los parametros timerange, xmin, xmax...
r210
if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax:
self.__isConfig = False
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
Daniel Valdez
En graphics:...
r192 class SpectraPlot(Figure):
Miguel Valdez
Primera version del controlador probada y testeada incluyendo graficos
r199
Daniel Valdez
En graphics:...
r192 __isConfig = None
Miguel Valdez
-Se agrego el perfil de potencia al grafico de espectros
r204 __nsubplots = None
WIDTHPROF = None
HEIGHTPROF = None
Miguel Valdez
Se mejora el metodo para grabar graficos de RTI y Spectra....
r212 PREFIX = 'spc'
Daniel Valdez
En graphics:...
r192
def __init__(self):
Miguel Valdez
Primera version del controlador probada y testeada incluyendo graficos
r199
Daniel Valdez
En graphics:...
r192 self.__isConfig = False
Miguel Valdez
-Se agrego el perfil de potencia al grafico de espectros
r204 self.__nsubplots = 1
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201 self.WIDTH = 300
self.HEIGHT = 400
Miguel Valdez
-Se agrego el perfil de potencia al grafico de espectros
r204 self.WIDTHPROF = 120
self.HEIGHTPROF = 0
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201
Daniel Valdez
En graphics:...
r192 def getSubplots(self):
Miguel Valdez
Primera version del controlador probada y testeada incluyendo graficos
r199
Daniel Valdez
En graphics:...
r192 ncol = int(numpy.sqrt(self.nplots)+0.9)
nrow = int(self.nplots*1./ncol + 0.9)
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201
Miguel Valdez
-Se agrego el perfil de potencia al grafico de espectros
r204 return nrow, ncol
def setup(self, idfigure, nplots, wintitle, showprofile=True):
self.__showprofile = showprofile
self.nplots = nplots
Miguel Valdez
Primera version del controlador probada y testeada incluyendo graficos
r199
Miguel Valdez
-Se agrego el perfil de potencia al grafico de espectros
r204 ncolspan = 1
Daniel Valdez
En graphics:...
r192 colspan = 1
Miguel Valdez
-Se agrego el perfil de potencia al grafico de espectros
r204 if showprofile:
ncolspan = 3
colspan = 2
self.__nsubplots = 2
Miguel Valdez
-Se agrego la funcionalidad de replotear el grafico de RTI, ademas de los parametros timerange, xmin, xmax...
r210
self.createFigure(idfigure = idfigure,
wintitle = wintitle,
widthplot = self.WIDTH + self.WIDTHPROF,
heightplot = self.HEIGHT + self.HEIGHTPROF)
Daniel Valdez
En graphics:...
r192
Miguel Valdez
-Se agrego el perfil de potencia al grafico de espectros
r204 nrow, ncol = self.getSubplots()
Miguel Valdez
Primera version del controlador probada y testeada incluyendo graficos
r199
Daniel Valdez
En graphics:...
r192 counter = 0
for y in range(nrow):
for x in range(ncol):
Miguel Valdez
-Se agrego el perfil de potencia al grafico de espectros
r204
if counter >= self.nplots:
break
self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
if showprofile:
Daniel Valdez
Adicion de la clase RTIPlot
r207 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
Miguel Valdez
-Se agrego el perfil de potencia al grafico de espectros
r204
Daniel Valdez
En graphics:...
r192 counter += 1
Miguel Valdez
-Se agrego el perfil de potencia al grafico de espectros
r204 def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True',
Miguel Valdez
Se mejora el metodo para grabar graficos de RTI y Spectra....
r212 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
save=False, figpath='./', figfile=None):
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201
"""
Input:
dataOut :
idfigure :
wintitle :
channelList :
showProfile :
xmin : None,
xmax : None,
ymin : None,
ymax : None,
zmin : None,
zmax : None
"""
Daniel Valdez
En graphics:...
r192
if channelList == None:
Miguel Valdez
Bug fixed: Al graficar los canales selecionados en SpectraPlot
r203 channelIndexList = dataOut.channelIndexList
else:
channelIndexList = []
for channel in channelList:
if channel not in dataOut.channelList:
raise ValueError, "Channel %d is not in dataOut.channelList"
Miguel Valdez
Bux fixed: La seleccion de canales en el gragico SpectraPlot, RTIPlot y Scope fueron testeados
r214 channelIndexList.append(dataOut.channelList.index(channel))
Daniel Valdez
En graphics:...
r192
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201 x = dataOut.getVelRange(1)
Daniel Valdez
Adicion de la clase RTIPlot
r207 y = dataOut.getHeiRange()
Miguel Valdez
Bug fixed: Al graficar los canales selecionados en SpectraPlot
r203 z = 10.*numpy.log10(dataOut.data_spc[channelIndexList,:,:])
Miguel Valdez
Se modifico el calculo automatico del rango de valores del grafico de Espectros.
r205 avg = numpy.average(z, axis=1)
Daniel Valdez
En graphics:...
r192
Miguel Valdez
Primera version del controlador probada y testeada incluyendo graficos
r199 noise = dataOut.getNoise()
Daniel Valdez
En graphics:...
r192 if not self.__isConfig:
Miguel Valdez
Bug fixed: Al graficar los canales selecionados en SpectraPlot
r203 nplots = len(channelIndexList)
Miguel Valdez
Primera version del controlador probada y testeada incluyendo graficos
r199
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201 self.setup(idfigure=idfigure,
nplots=nplots,
wintitle=wintitle,
showprofile=showprofile)
if xmin == None: xmin = numpy.nanmin(x)
if xmax == None: xmax = numpy.nanmax(x)
if ymin == None: ymin = numpy.nanmin(y)
if ymax == None: ymax = numpy.nanmax(y)
Miguel Valdez
Se modifico el calculo automatico del rango de valores del grafico de Espectros.
r205 if zmin == None: zmin = numpy.nanmin(avg)*0.9
if zmax == None: zmax = numpy.nanmax(avg)*0.9
Miguel Valdez
Primera version del controlador probada y testeada incluyendo graficos
r199
Daniel Valdez
En graphics:...
r192 self.__isConfig = True
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201
Miguel Valdez
Busqueda de archivos dentro del directorio indicado (sin busqueda de subdirectorios) activando el flag de lectura 'walk'
r224 thisDatetime = dataOut.datatime
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201 title = "Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
xlabel = "Velocity (m/s)"
ylabel = "Range (Km)"
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
self.setWinTitle(title)
Miguel Valdez
-Se agrego el perfil de potencia al grafico de espectros
r204
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201 for i in range(self.nplots):
Miguel Valdez
Bug fixed: Al graficar los canales selecionados en SpectraPlot
r203 title = "Channel %d: %4.2fdB" %(dataOut.channelList[i], noise[i])
Miguel Valdez
-Se agrego el perfil de potencia al grafico de espectros
r204 axes = self.axesList[i*self.__nsubplots]
axes.pcolor(x, y, z[i,:,:],
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
xlabel=xlabel, ylabel=ylabel, title=title,
Miguel Valdez
-Se agrego el perfil de potencia al grafico de espectros
r204 ticksize=9, cblabel='')
if self.__showprofile:
axes = self.axesList[i*self.__nsubplots +1]
axes.pline(avg[i], y,
xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
xlabel='dB', ylabel='', title='',
ytick_visible=False,
grid='x')
Miguel Valdez
Primera version del controlador probada y testeada incluyendo graficos
r199
Daniel Valdez
En graphics:...
r192 self.draw()
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 save:
Miguel Valdez
Se mejora el metodo para grabar graficos de RTI y Spectra....
r212 date = thisDatetime.strftime("%Y%m%d")
if figfile == None:
figfile = self.getFilename(name = date)
self.saveFigure(figpath, figfile)
Daniel Valdez
En graphics:...
r192
Daniel Valdez
Se agrega el folder "graphics" que contiene figure.py y mpldriver.py...
r190 class Scope(Figure):
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201
Daniel Valdez
Se agrega el folder "graphics" que contiene figure.py y mpldriver.py...
r190 __isConfig = None
def __init__(self):
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201
Daniel Valdez
Se agrega el folder "graphics" que contiene figure.py y mpldriver.py...
r190 self.__isConfig = False
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201 self.WIDTH = 600
self.HEIGHT = 200
Daniel Valdez
Se agrega el folder "graphics" que contiene figure.py y mpldriver.py...
r190
def getSubplots(self):
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201
Daniel Valdez
Se agrega el folder "graphics" que contiene figure.py y mpldriver.py...
r190 nrow = self.nplots
ncol = 3
return nrow, ncol
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201 def setup(self, idfigure, nplots, wintitle):
Miguel Valdez
-Se agrego el perfil de potencia al grafico de espectros
r204 self.createFigure(idfigure, wintitle)
Daniel Valdez
Se agrega el folder "graphics" que contiene figure.py y mpldriver.py...
r190
nrow,ncol = self.getSubplots()
colspan = 3
rowspan = 1
for i in range(nplots):
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201 self.addAxes(nrow, ncol, i, 0, colspan, rowspan)
Miguel Valdez
-Se agrego el perfil de potencia al grafico de espectros
r204
self.nplots = nplots
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 run(self, dataOut, idfigure, wintitle="", channelList=None,
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 xmin=None, xmax=None, ymin=None, ymax=None, save=False, filename=None):
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201
"""
Input:
dataOut :
idfigure :
wintitle :
channelList :
xmin : None,
xmax : None,
ymin : None,
ymax : None,
"""
Daniel Valdez
Se agrega el folder "graphics" que contiene figure.py y mpldriver.py...
r190
if channelList == None:
Miguel Valdez
Bux fixed: La seleccion de canales en el gragico SpectraPlot, RTIPlot y Scope fueron testeados
r214 channelIndexList = dataOut.channelIndexList
else:
channelIndexList = []
for channel in channelList:
if channel not in dataOut.channelList:
raise ValueError, "Channel %d is not in dataOut.channelList"
Daniel Valdez
Se agrega clase para ploteo de Espectros Cruzados.
r215 channelIndexList.append(dataOut.channelList.index(channel))
Daniel Valdez
Se agrega el folder "graphics" que contiene figure.py y mpldriver.py...
r190
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201 x = dataOut.heightList
Daniel Valdez
Se agrega el folder "graphics" que contiene figure.py y mpldriver.py...
r190 y = dataOut.data[channelList,:] * numpy.conjugate(dataOut.data[channelList,:])
y = y.real
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201 noise = dataOut.getNoise()
Daniel Valdez
Se agrega el folder "graphics" que contiene figure.py y mpldriver.py...
r190
if not self.__isConfig:
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201 nplots = len(channelList)
self.setup(idfigure=idfigure,
nplots=nplots,
wintitle=wintitle)
Daniel Valdez
Se agrega el folder "graphics" que contiene figure.py y mpldriver.py...
r190
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201 if xmin == None: xmin = numpy.nanmin(x)
if xmax == None: xmax = numpy.nanmax(x)
if ymin == None: ymin = numpy.nanmin(y)
if ymax == None: ymax = numpy.nanmax(y)
Daniel Valdez
Se agrega el folder "graphics" que contiene figure.py y mpldriver.py...
r190
self.__isConfig = True
Miguel Valdez
Busqueda de archivos dentro del directorio indicado (sin busqueda de subdirectorios) activando el flag de lectura 'walk'
r224 thisDatetime = dataOut.datatime
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201 title = "Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
xlabel = "Range (Km)"
Daniel Valdez
Se agrega el folder "graphics" que contiene figure.py y mpldriver.py...
r190 ylabel = "Intensity"
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201 self.setWinTitle(title)
Daniel Valdez
Se agrega el folder "graphics" que contiene figure.py y mpldriver.py...
r190
for i in range(len(self.axesList)):
Miguel Valdez
Primera version del controlador probada y testeada incluyendo graficos
r199 title = "Channel %d: %4.2fdB" %(i, noise[i])
Daniel Valdez
Se agrega el folder "graphics" que contiene figure.py y mpldriver.py...
r190 axes = self.axesList[i]
Miguel Valdez
Testeado con datos de Imagenes (Espectros)...
r201 ychannel = y[i,:]
axes.pline(x, ychannel,
xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
xlabel=xlabel, ylabel=ylabel, title=title)
Daniel Valdez
Se agrega el folder "graphics" que contiene figure.py y mpldriver.py...
r190
self.draw()
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 save:
self.saveFigure(filename)
Daniel Valdez
Adicion de la clase ProfilePlot, CoherencePLot en el modulo jroplot.py...
r229
class ProfilePlot(Figure):
__isConfig = None
__nsubplots = None
WIDTHPROF = None
HEIGHTPROF = None
PREFIX = 'spcprofile'
def __init__(self):
self.__isConfig = False
self.__nsubplots = 1
self.WIDTH = 300
self.HEIGHT = 500
def getSubplots(self):
ncol = 1
nrow = 1
return nrow, ncol
def setup(self, idfigure, nplots, wintitle):
self.nplots = nplots
ncolspan = 1
colspan = 1
self.createFigure(idfigure = idfigure,
wintitle = wintitle,
widthplot = self.WIDTH,
heightplot = self.HEIGHT)
nrow, ncol = self.getSubplots()
counter = 0
for y in range(nrow):
for x in range(ncol):
self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
def run(self, dataOut, idfigure, wintitle="", channelList=None,
xmin=None, xmax=None, ymin=None, ymax=None,
save=False, figpath='./', figfile=None):
if channelList == None:
channelIndexList = dataOut.channelIndexList
channelList = dataOut.channelList
else:
channelIndexList = []
for channel in channelList:
if channel not in dataOut.channelList:
raise ValueError, "Channel %d is not in dataOut.channelList"
channelIndexList.append(dataOut.channelList.index(channel))
y = dataOut.getHeiRange()
x = 10.*numpy.log10(dataOut.data_spc[channelIndexList,:,:])
avg = numpy.average(x, axis=1)
if not self.__isConfig:
nplots = 1
self.setup(idfigure=idfigure,
nplots=nplots,
wintitle=wintitle)
if ymin == None: ymin = numpy.nanmin(y)
if ymax == None: ymax = numpy.nanmax(y)
if xmin == None: xmin = numpy.nanmin(avg)*0.9
if xmax == None: xmax = numpy.nanmax(avg)*0.9
self.__isConfig = True
thisDatetime = dataOut.datatime
title = "Power Profile"
xlabel = "dB"
ylabel = "Range (Km)"
self.setWinTitle(title)
title = "Power Profile: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
axes = self.axesList[0]
legendlabels = ["channel %d"%x for x in channelList]
axes.pmultiline(avg, y,
xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels,
ytick_visible=True, nxticks=5,
grid='x')
self.draw()
if save:
date = thisDatetime.strftime("%Y%m%d")
if figfile == None:
figfile = self.getFilename(name = date)
self.saveFigure(figpath, figfile)
class CoherencePlot(Figure):
__isConfig = None
__nsubplots = None
WIDTHPROF = None
HEIGHTPROF = None
PREFIX = 'coherencemap'
def __init__(self):
self.__timerange = 24*60*60
self.__isConfig = False
self.__nsubplots = 1
self.WIDTH = 800
self.HEIGHT = 200
self.WIDTHPROF = 120
self.HEIGHTPROF = 0
def getSubplots(self):
ncol = 1
nrow = self.nplots*2
return nrow, ncol
def setup(self, idfigure, nplots, wintitle, showprofile=True):
self.__showprofile = showprofile
self.nplots = nplots
ncolspan = 1
colspan = 1
if showprofile:
ncolspan = 7
colspan = 6
self.__nsubplots = 2
self.createFigure(idfigure = idfigure,
wintitle = wintitle,
widthplot = self.WIDTH + self.WIDTHPROF,
heightplot = self.HEIGHT + self.HEIGHTPROF)
nrow, ncol = self.getSubplots()
for y in range(nrow):
for x in range(ncol):
self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
if showprofile:
self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
def __getTimeLim(self, x, xmin, xmax):
thisdatetime = datetime.datetime.fromtimestamp(numpy.min(x))
thisdate = datetime.datetime.combine(thisdatetime.date(), datetime.time(0,0,0))
####################################################
#If the x is out of xrange
if xmax < (thisdatetime - thisdate).seconds/(60*60.):
xmin = None
xmax = None
if xmin == None:
td = thisdatetime - thisdate
xmin = td.seconds/(60*60.)
if xmax == None:
xmax = xmin + self.__timerange/(60*60.)
mindt = thisdate + datetime.timedelta(0,0,0,0,0, xmin)
tmin = time.mktime(mindt.timetuple())
maxdt = thisdate + datetime.timedelta(0,0,0,0,0, xmax)
tmax = time.mktime(maxdt.timetuple())
self.__timerange = tmax - tmin
return tmin, tmax
def run(self, dataOut, idfigure, wintitle="", pairsList=None, showprofile='True',
xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
timerange=None,
save=False, figpath='./', figfile=None):
if pairsList == None:
pairsIndexList = dataOut.pairsIndexList
else:
pairsIndexList = []
for pair in pairsList:
if pair not in dataOut.pairsList:
raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair)
pairsIndexList.append(dataOut.pairsList.index(pair))
if timerange != None:
self.__timerange = timerange
tmin = None
tmax = None
x = dataOut.getTimeRange()
y = dataOut.getHeiRange()
if not self.__isConfig:
nplots = len(pairsIndexList)
self.setup(idfigure=idfigure,
nplots=nplots,
wintitle=wintitle,
showprofile=showprofile)
tmin, tmax = self.__getTimeLim(x, xmin, xmax)
if ymin == None: ymin = numpy.nanmin(y)
if ymax == None: ymax = numpy.nanmax(y)
self.__isConfig = True
thisDatetime = dataOut.datatime
title = "CoherenceMap: %s" %(thisDatetime.strftime("%d-%b-%Y"))
xlabel = ""
ylabel = "Range (Km)"
self.setWinTitle(title)
for i in range(self.nplots):
pair = dataOut.pairsList[pairsIndexList[i]]
coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:])
coherence = numpy.abs(coherenceComplex)
avg = numpy.average(coherence, axis=0)
z = avg.reshape((1,-1))
counter = 0
title = "Coherence %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
axes = self.axesList[i*self.__nsubplots*2]
axes.pcolor(x, y, z,
xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1,
xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
ticksize=9, cblabel='', cbsize="1%")
if self.__showprofile:
counter += 1
axes = self.axesList[i*self.__nsubplots*2 + counter]
axes.pline(avg, y,
xmin=0, xmax=1, ymin=ymin, ymax=ymax,
xlabel='', ylabel='', title='', ticksize=7,
ytick_visible=False, nxticks=5,
grid='x')
counter += 1
phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi
avg = numpy.average(phase, axis=0)
z = avg.reshape((1,-1))
title = "Phase %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
axes = self.axesList[i*self.__nsubplots*2 + counter]
axes.pcolor(x, y, z,
xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180,
xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
ticksize=9, cblabel='', colormap='RdBu', cbsize="1%")
if self.__showprofile:
counter += 1
axes = self.axesList[i*self.__nsubplots*2 + counter]
axes.pline(avg, y,
xmin=-180, xmax=180, ymin=ymin, ymax=ymax,
xlabel='', ylabel='', title='', ticksize=7,
ytick_visible=False, nxticks=4,
grid='x')
self.draw()
if save:
date = thisDatetime.strftime("%Y%m%d")
if figfile == None:
figfile = self.getFilename(name = date)
self.saveFigure(figpath, figfile)
if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax:
self.__isConfig = False
Daniel Valdez
Se agrega el folder "graphics" que contiene figure.py y mpldriver.py...
r190