##// END OF EJS Templates
-Se agrego el perfil de potencia al grafico de espectros
Miguel Valdez -
r204:af44731cc0d0
parent child
Show More
@@ -598,36 +598,59 if __name__ == '__main__':
598 598 procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', inputId=readUnitConfObj.getId())
599 599
600 600 opObj10 = procUnitConfObj1.addOperation(name='selectChannels')
601 opObj10.addParameter(name='channelList', value='0,1', format='intlist')
601 opObj10.addParameter(name='channelList', value='0,1,2,4,6,7', format='intlist')
602 602
603 603 opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other')
604 604 opObj11.addParameter(name='idfigure', value='1', format='int')
605 605 opObj11.addParameter(name='wintitle', value='SpectraPlot', format='str')
606 # opObj11.addParameter(name='zmin', value='60', format='int')
607 # opObj11.addParameter(name='zmax', value='100', format='int')
606 # opObj11.addParameter(name='zmin', value='70', format='int')
607 # opObj11.addParameter(name='zmax', value='90', format='int')
608 opObj11.addParameter(name='showprofile', value='1', format='int')
609
610 opObj10 = procUnitConfObj1.addOperation(name='selectChannels')
611 opObj10.addParameter(name='channelList', value='0,2,4,6', format='intlist')
608 612
609 613 opObj12 = procUnitConfObj1.addOperation(name='IncohInt', optype='other')
610 opObj12.addParameter(name='n', value='30', format='int')
614 opObj12.addParameter(name='n', value='2', format='int')
611 615
612 616 opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other')
613 617 opObj11.addParameter(name='idfigure', value='2', format='int')
614 618 opObj11.addParameter(name='wintitle', value='SpectraPlot10', format='str')
615 # opObj11.addParameter(name='zmin', value='60', format='int')
616 # opObj11.addParameter(name='zmax', value='100', format='int')
617
619 opObj11.addParameter(name='zmin', value='70', format='int')
620 opObj11.addParameter(name='zmax', value='90', format='int')
621
622 opObj10 = procUnitConfObj1.addOperation(name='selectChannels')
623 opObj10.addParameter(name='channelList', value='2,6', format='intlist')
624
625 opObj12 = procUnitConfObj1.addOperation(name='IncohInt', optype='other')
626 opObj12.addParameter(name='n', value='2', format='int')
627
628 opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other')
629 opObj11.addParameter(name='idfigure', value='3', format='int')
630 opObj11.addParameter(name='wintitle', value='SpectraPlot10', format='str')
631 opObj11.addParameter(name='zmin', value='70', format='int')
632 opObj11.addParameter(name='zmax', value='90', format='int')
633
634
618 635 # opObj12 = procUnitConfObj1.addOperation(name='decoder')
619 636 # opObj12.addParameter(name='ncode', value='2', format='int')
620 637 # opObj12.addParameter(name='nbauds', value='8', format='int')
621 638 # opObj12.addParameter(name='code0', value='001110011', format='int')
622 639 # opObj12.addParameter(name='code1', value='001110011', format='int')
623 640
624 # procUnitConfObj2 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj1.getId())
625 641
642
643 procUnitConfObj2 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj1.getId())
626 644
627 # opObj21 = procUnitConfObj2.addOperation(name='IncohInt', optype='other')
628 # opObj21.addParameter(name='nCohInt', value='10', format='int')
629
645 opObj21 = procUnitConfObj2.addOperation(name='IncohInt', optype='other')
646 opObj21.addParameter(name='n', value='2', format='int')
630 647
648 opObj11 = procUnitConfObj2.addOperation(name='SpectraPlot', optype='other')
649 opObj11.addParameter(name='idfigure', value='4', format='int')
650 opObj11.addParameter(name='wintitle', value='SpectraPlot OBJ 2', format='str')
651 opObj11.addParameter(name='zmin', value='70', format='int')
652 opObj11.addParameter(name='zmax', value='90', format='int')
653
631 654 print "Escribiendo el archivo XML"
632 655
633 656 controllerObj.writeXml(filename)
@@ -39,18 +39,24 class Figure:
39 39 return width, height
40 40
41 41 def init(self, idfigure, nplots, wintitle):
42
43 raise ValueError, "This method has been replaced with createFigure"
44
45 def createFigure(self, idfigure, wintitle):
42 46
43 47 """
44 Inicializa la figura de acuerdo al driver seleccionado
48 Crea la figura de acuerdo al driver y parametros seleccionados seleccionados.
49 Las dimensiones de la pantalla es calculada a partir de los atributos self.WIDTH
50 y self.HEIGHT y el numero de subplots (nrow, ncol)
51
45 52 Input:
46 *args : Los parametros necesarios son
47 idfigure, wintitle, width, height
53 idfigure : Los parametros necesarios son
54 wintitle :
55
48 56 """
49 57
50 58 self.idfigure = idfigure
51 59
52 self.nplots = nplots
53
54 60 self.wintitle = wintitle
55 61
56 62 self.width, self.height = self.getScreenDim()
@@ -113,6 +119,8 class Axes:
113 119
114 120 firsttime = None
115 121
122 __showprofile = False
123
116 124 def __init__(self, *args):
117 125
118 126 """
@@ -155,6 +163,7 class Axes:
155 163 **kwargs : Los parametros aceptados son
156 164
157 165 ticksize
166 ytick_visible
158 167 """
159 168
160 169 if self.firsttime:
@@ -134,20 +134,44 def printLabels(ax, xlabel, ylabel, title):
134 134 ax.set_ylabel(ylabel, size=11)
135 135 ax.set_title(title, size=12)
136 136
137 def createPline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='', ticksize = 9):
137 def createPline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='',
138 ticksize=9, xtick_visible=True, ytick_visible=True,
139 nxticks=4, nyticks=10,
140 grid=None):
138 141
142 """
143
144 Input:
145 grid : None, 'both', 'x', 'y'
146 """
147
139 148 ax.plot(x, y)
140 149 ax.set_xlim([xmin,xmax])
141 150 ax.set_ylim([ymin,ymax])
142 151
143 152 printLabels(ax, xlabel, ylabel, title)
144 153
145 for tick in ax.yaxis.get_major_ticks():
146 tick.label.set_fontsize(ticksize)
154 ######################################################
155 xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/nxticks) + int(xmin)
156 ax.set_xticks(xtickspos)
157
158 for tick in ax.get_xticklabels():
159 tick.set_visible(xtick_visible)
147 160
148 161 for tick in ax.xaxis.get_major_ticks():
149 162 tick.label.set_fontsize(ticksize)
150
163
164 ######################################################
165 for tick in ax.get_yticklabels():
166 tick.set_visible(ytick_visible)
167
168 for tick in ax.yaxis.get_major_ticks():
169 tick.label.set_fontsize(ticksize)
170
171 ######################################################
172 if grid != None:
173 ax.grid(b=True, which='major', axis=grid)
174
151 175 matplotlib.pyplot.tight_layout()
152 176
153 177 iplot = ax.lines[-1]
@@ -5,58 +5,61 from graphics.figure import *
5 5 class SpectraPlot(Figure):
6 6
7 7 __isConfig = None
8 __nsubplots = None
9
10 WIDTHPROF = None
11 HEIGHTPROF = None
8 12
9 13 def __init__(self):
10 14
11 15 self.__isConfig = False
16 self.__nsubplots = 1
17
12 18 self.WIDTH = 300
13 19 self.HEIGHT = 400
20 self.WIDTHPROF = 120
21 self.HEIGHTPROF = 0
14 22
15 23 def getSubplots(self):
16 24
17 25 ncol = int(numpy.sqrt(self.nplots)+0.9)
18 26 nrow = int(self.nplots*1./ncol + 0.9)
19 return nrow, ncol
20 27
21 def setAxesWithOutProfiles(self, nrow, ncol):
28 return nrow, ncol
29
30 def setup(self, idfigure, nplots, wintitle, showprofile=True):
31
32 self.__showprofile = showprofile
33 self.nplots = nplots
22 34
35 ncolspan = 1
23 36 colspan = 1
24 rowspan = 1
25 counter = 0
37 if showprofile:
38 ncolspan = 3
39 colspan = 2
40 self.__nsubplots = 2
41 self.WIDTH += self.WIDTHPROF
42 self.HEIGHT += self.HEIGHTPROF
43
44 self.createFigure(idfigure, wintitle)
26 45
27 for y in range(nrow):
28 for x in range(ncol):
29 if counter < self.nplots:
30 self.addAxes(nrow, ncol, y, x, colspan, rowspan)
31 counter += 1
32
33 def setAxesWithProfiles(self, nrow, ncol):
46 nrow, ncol = self.getSubplots()
34 47
35 colspan = 1
36 rowspan = 1
37 factor = 2
38 ncol = ncol*factor
39 48 counter = 0
40
41 49 for y in range(nrow):
42 50 for x in range(ncol):
43 if counter < self.nplots*factor:
44 # plt.subplot2grid((nrow, ncol), (y, x), colspan=colspan, rowspan=rowspan)
45 self.addAxes(nrow, ncol, y, x, colspan, rowspan)
51
52 if counter >= self.nplots:
53 break
54
55 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
56
57 if showprofile:
58 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+2, 1, 1)
59
46 60 counter += 1
47 61
48 def setup(self, idfigure, nplots, wintitle, showprofile=True):
49
50 self.init(idfigure, nplots, wintitle)
51
52 nrow, ncol = self.getSubplots()
53
54 if showprofile:
55 self.setAxesWithProfiles(nrow, ncol)
56 else:
57 self.setAxesWithOutProfiles(nrow, ncol)
58
59 def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile=False,
62 def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True',
60 63 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None):
61 64
62 65 """
@@ -115,15 +118,24 class SpectraPlot(Figure):
115 118
116 119 self.setWinTitle(title)
117 120
121 if self.__showprofile:
122 avg = numpy.average(z, axis=1)
123
118 124 for i in range(self.nplots):
119 125 title = "Channel %d: %4.2fdB" %(dataOut.channelList[i], noise[i])
120 zchannel = z[i,:,:]
121
122 axes = self.axesList[i]
123 axes.pcolor(x, y, zchannel,
126 axes = self.axesList[i*self.__nsubplots]
127 axes.pcolor(x, y, z[i,:,:],
124 128 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
125 129 xlabel=xlabel, ylabel=ylabel, title=title,
126 ticksize=9, cblabel='dB')
130 ticksize=9, cblabel='')
131
132 if self.__showprofile:
133 axes = self.axesList[i*self.__nsubplots +1]
134 axes.pline(avg[i], y,
135 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
136 xlabel='dB', ylabel='', title='',
137 ytick_visible=False,
138 grid='x')
127 139
128 140 self.draw()
129 141
@@ -145,7 +157,7 class Scope(Figure):
145 157
146 158 def setup(self, idfigure, nplots, wintitle):
147 159
148 self.init(idfigure, nplots, wintitle)
160 self.createFigure(idfigure, wintitle)
149 161
150 162 nrow,ncol = self.getSubplots()
151 163 colspan = 3
@@ -153,6 +165,8 class Scope(Figure):
153 165
154 166 for i in range(nplots):
155 167 self.addAxes(nrow, ncol, i, 0, colspan, rowspan)
168
169 self.nplots = nplots
156 170
157 171 def run(self, dataOut, idfigure, wintitle="", channelList=None,
158 172 xmin=None, xmax=None, ymin=None, ymax=None):
General Comments 0
You need to be logged in to leave comments. Login now