diff --git a/schainpy/controller.py b/schainpy/controller.py index 6a291a9..785e32a 100644 --- a/schainpy/controller.py +++ b/schainpy/controller.py @@ -598,36 +598,59 @@ if __name__ == '__main__': procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', inputId=readUnitConfObj.getId()) opObj10 = procUnitConfObj1.addOperation(name='selectChannels') - opObj10.addParameter(name='channelList', value='0,1', format='intlist') + opObj10.addParameter(name='channelList', value='0,1,2,4,6,7', format='intlist') opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other') opObj11.addParameter(name='idfigure', value='1', format='int') opObj11.addParameter(name='wintitle', value='SpectraPlot', format='str') -# opObj11.addParameter(name='zmin', value='60', format='int') -# opObj11.addParameter(name='zmax', value='100', format='int') +# opObj11.addParameter(name='zmin', value='70', format='int') +# opObj11.addParameter(name='zmax', value='90', format='int') + opObj11.addParameter(name='showprofile', value='1', format='int') + + opObj10 = procUnitConfObj1.addOperation(name='selectChannels') + opObj10.addParameter(name='channelList', value='0,2,4,6', format='intlist') opObj12 = procUnitConfObj1.addOperation(name='IncohInt', optype='other') - opObj12.addParameter(name='n', value='30', format='int') + opObj12.addParameter(name='n', value='2', format='int') opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other') opObj11.addParameter(name='idfigure', value='2', format='int') opObj11.addParameter(name='wintitle', value='SpectraPlot10', format='str') -# opObj11.addParameter(name='zmin', value='60', format='int') -# opObj11.addParameter(name='zmax', value='100', format='int') - + opObj11.addParameter(name='zmin', value='70', format='int') + opObj11.addParameter(name='zmax', value='90', format='int') + + opObj10 = procUnitConfObj1.addOperation(name='selectChannels') + opObj10.addParameter(name='channelList', value='2,6', format='intlist') + + opObj12 = procUnitConfObj1.addOperation(name='IncohInt', optype='other') + opObj12.addParameter(name='n', value='2', format='int') + + opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other') + opObj11.addParameter(name='idfigure', value='3', format='int') + opObj11.addParameter(name='wintitle', value='SpectraPlot10', format='str') + opObj11.addParameter(name='zmin', value='70', format='int') + opObj11.addParameter(name='zmax', value='90', format='int') + + # opObj12 = procUnitConfObj1.addOperation(name='decoder') # opObj12.addParameter(name='ncode', value='2', format='int') # opObj12.addParameter(name='nbauds', value='8', format='int') # opObj12.addParameter(name='code0', value='001110011', format='int') # opObj12.addParameter(name='code1', value='001110011', format='int') -# procUnitConfObj2 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj1.getId()) + + procUnitConfObj2 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj1.getId()) -# opObj21 = procUnitConfObj2.addOperation(name='IncohInt', optype='other') -# opObj21.addParameter(name='nCohInt', value='10', format='int') - + opObj21 = procUnitConfObj2.addOperation(name='IncohInt', optype='other') + opObj21.addParameter(name='n', value='2', format='int') + opObj11 = procUnitConfObj2.addOperation(name='SpectraPlot', optype='other') + opObj11.addParameter(name='idfigure', value='4', format='int') + opObj11.addParameter(name='wintitle', value='SpectraPlot OBJ 2', format='str') + opObj11.addParameter(name='zmin', value='70', format='int') + opObj11.addParameter(name='zmax', value='90', format='int') + print "Escribiendo el archivo XML" controllerObj.writeXml(filename) diff --git a/schainpy/model/graphics/figure.py b/schainpy/model/graphics/figure.py index ced35cd..c0ed9fa 100644 --- a/schainpy/model/graphics/figure.py +++ b/schainpy/model/graphics/figure.py @@ -39,18 +39,24 @@ class Figure: return width, height def init(self, idfigure, nplots, wintitle): + + raise ValueError, "This method has been replaced with createFigure" + + def createFigure(self, idfigure, wintitle): """ - Inicializa la figura de acuerdo al driver seleccionado + Crea la figura de acuerdo al driver y parametros seleccionados seleccionados. + Las dimensiones de la pantalla es calculada a partir de los atributos self.WIDTH + y self.HEIGHT y el numero de subplots (nrow, ncol) + Input: - *args : Los parametros necesarios son - idfigure, wintitle, width, height + idfigure : Los parametros necesarios son + wintitle : + """ self.idfigure = idfigure - self.nplots = nplots - self.wintitle = wintitle self.width, self.height = self.getScreenDim() @@ -113,6 +119,8 @@ class Axes: firsttime = None + __showprofile = False + def __init__(self, *args): """ @@ -155,6 +163,7 @@ class Axes: **kwargs : Los parametros aceptados son ticksize + ytick_visible """ if self.firsttime: diff --git a/schainpy/model/graphics/mpldriver.py b/schainpy/model/graphics/mpldriver.py index 70ae42c..416aea2 100644 --- a/schainpy/model/graphics/mpldriver.py +++ b/schainpy/model/graphics/mpldriver.py @@ -134,20 +134,44 @@ def printLabels(ax, xlabel, ylabel, title): ax.set_ylabel(ylabel, size=11) ax.set_title(title, size=12) -def createPline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='', ticksize = 9): +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): + """ + + Input: + grid : None, 'both', 'x', 'y' + """ + ax.plot(x, y) ax.set_xlim([xmin,xmax]) ax.set_ylim([ymin,ymax]) printLabels(ax, xlabel, ylabel, title) - for tick in ax.yaxis.get_major_ticks(): - tick.label.set_fontsize(ticksize) + ###################################################### + 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) for tick in ax.xaxis.get_major_ticks(): tick.label.set_fontsize(ticksize) - + + ###################################################### + 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) + matplotlib.pyplot.tight_layout() iplot = ax.lines[-1] diff --git a/schainpy/model/jroplot.py b/schainpy/model/jroplot.py index fa77b82..129b17e 100644 --- a/schainpy/model/jroplot.py +++ b/schainpy/model/jroplot.py @@ -5,58 +5,61 @@ from graphics.figure import * class SpectraPlot(Figure): __isConfig = None + __nsubplots = None + + WIDTHPROF = None + HEIGHTPROF = None def __init__(self): self.__isConfig = False + self.__nsubplots = 1 + self.WIDTH = 300 self.HEIGHT = 400 + self.WIDTHPROF = 120 + self.HEIGHTPROF = 0 def getSubplots(self): ncol = int(numpy.sqrt(self.nplots)+0.9) nrow = int(self.nplots*1./ncol + 0.9) - return nrow, ncol - def setAxesWithOutProfiles(self, nrow, ncol): + return nrow, ncol + + def setup(self, idfigure, nplots, wintitle, showprofile=True): + + self.__showprofile = showprofile + self.nplots = nplots + ncolspan = 1 colspan = 1 - rowspan = 1 - counter = 0 + if showprofile: + ncolspan = 3 + colspan = 2 + self.__nsubplots = 2 + self.WIDTH += self.WIDTHPROF + self.HEIGHT += self.HEIGHTPROF + + self.createFigure(idfigure, wintitle) - for y in range(nrow): - for x in range(ncol): - if counter < self.nplots: - self.addAxes(nrow, ncol, y, x, colspan, rowspan) - counter += 1 - - def setAxesWithProfiles(self, nrow, ncol): + nrow, ncol = self.getSubplots() - colspan = 1 - rowspan = 1 - factor = 2 - ncol = ncol*factor counter = 0 - for y in range(nrow): for x in range(ncol): - if counter < self.nplots*factor: -# plt.subplot2grid((nrow, ncol), (y, x), colspan=colspan, rowspan=rowspan) - self.addAxes(nrow, ncol, y, x, colspan, rowspan) + + 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+2, 1, 1) + counter += 1 - def setup(self, idfigure, nplots, wintitle, showprofile=True): - - self.init(idfigure, nplots, wintitle) - - nrow, ncol = self.getSubplots() - - if showprofile: - self.setAxesWithProfiles(nrow, ncol) - else: - self.setAxesWithOutProfiles(nrow, ncol) - - def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile=False, + def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None): """ @@ -115,15 +118,24 @@ class SpectraPlot(Figure): self.setWinTitle(title) + if self.__showprofile: + avg = numpy.average(z, axis=1) + for i in range(self.nplots): title = "Channel %d: %4.2fdB" %(dataOut.channelList[i], noise[i]) - zchannel = z[i,:,:] - - axes = self.axesList[i] - axes.pcolor(x, y, zchannel, + axes = self.axesList[i*self.__nsubplots] + axes.pcolor(x, y, z[i,:,:], xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, xlabel=xlabel, ylabel=ylabel, title=title, - ticksize=9, cblabel='dB') + 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') self.draw() @@ -145,7 +157,7 @@ class Scope(Figure): def setup(self, idfigure, nplots, wintitle): - self.init(idfigure, nplots, wintitle) + self.createFigure(idfigure, wintitle) nrow,ncol = self.getSubplots() colspan = 3 @@ -153,6 +165,8 @@ class Scope(Figure): for i in range(nplots): self.addAxes(nrow, ncol, i, 0, colspan, rowspan) + + self.nplots = nplots def run(self, dataOut, idfigure, wintitle="", channelList=None, xmin=None, xmax=None, ymin=None, ymax=None):