##// END OF EJS Templates
Se agrega el folder "graphics" que contiene figure.py y mpldriver.py...
Daniel Valdez -
r190:cfcc2c9608cc
parent child
Show More
1 NO CONTENT: new file 100644
NO CONTENT: new file 100644
@@ -0,0 +1,61
1 import mpldriver
2
3 class Figure:
4 axesList = None
5 def __init__(self):
6 pass
7
8 def init(self, idfigure, wintitle, width, height, nplots):
9 self.idfigure = idfigure
10 self.wintitle = wintitle
11 self.width = width
12 self.height = height
13 self.nplots = nplots
14 mpldriver.init(idfigure, wintitle, width, height)
15
16 self.axesList = []
17
18 def setTitle(self, title):
19 mpldriver.setTitle(self.idfigure, title)
20
21 def setTextFromAxes(self, title):
22 mpldriver.setTextFromAxes(self.idfigure, self.axesList[0].ax, title)
23
24 def makeAxes(self, nrow, ncol, xpos, ypos, colspan, rowspan):
25 ax = mpldriver.makeAxes(self.idfigure, nrow, ncol, xpos, ypos, colspan, rowspan)
26 axesObj = Axes(ax)
27 self.axesList.append(axesObj)
28
29 def draw(self):
30 mpldriver.draw(self.idfigure)
31
32 def run(self):
33 pass
34
35
36 class Axes:
37 firsttime = None
38 ax = None
39
40 def __init__(self, ax):
41 self.firsttime = True
42 self.ax = ax
43
44 def pline(self, x, y, xmin, xmax, ymin, ymax, xlabel, ylabel, title):
45
46 mpldriver.pline(ax=self.ax,
47 x=x,
48 y=y,
49 xmin=xmin,
50 xmax=xmax,
51 ymin=ymin,
52 ymax=ymax,
53 xlabel=xlabel,
54 ylabel=ylabel,
55 title=title,
56 firsttime=self.firsttime)
57
58 self.firsttime = False
59
60 def pcolor(self):
61 pass
@@ -0,0 +1,50
1 import matplotlib
2 matplotlib.use("TKAgg")
3 import matplotlib.pyplot
4 import scitools.numpyutils
5
6 def init(idfigure, wintitle, width, height):
7 matplotlib.pyplot.ioff()
8 fig = matplotlib.pyplot.matplotlib.pyplot.figure(num=idfigure, facecolor="w")
9 fig.canvas.manager.set_window_title(wintitle)
10 fig.canvas.manager.resize(width,height)
11 matplotlib.pyplot.ion()
12
13 def setTextFromAxes(idfigure, ax, title):
14 fig = matplotlib.pyplot.figure(idfigure)
15 ax.annotate(title, xy=(.1, .99),
16 xycoords='figure fraction',
17 horizontalalignment='left', verticalalignment='top',
18 fontsize=10)
19
20 def setTitle(idfigure, title):
21 fig = matplotlib.pyplot.figure(idfigure)
22 fig.suptitle(title)
23
24 def makeAxes(idfigure, nrow, ncol, xpos, ypos, colspan, rowspan):
25 fig = matplotlib.pyplot.figure(idfigure)
26 ax = matplotlib.pyplot.subplot2grid((nrow, ncol), (xpos, ypos), colspan=colspan, rowspan=rowspan)
27 return ax
28
29 def pline(ax, x, y, xmin, xmax, ymin, ymax, xlabel, ylabel, title, firsttime):
30 if firsttime:
31 ax.plot(x, y)
32 ax.set_xlim([xmin,xmax])
33 ax.set_ylim([ymin,ymax])
34 ax.set_xlabel(xlabel, size=8)
35 ax.set_ylabel(ylabel, size=8)
36 ax.set_title(title, size=10)
37 matplotlib.pyplot.tight_layout()
38 else:
39 ax.lines[0].set_data(x,y)
40
41 def draw(idfigure):
42 fig = matplotlib.pyplot.figure(idfigure)
43 fig.canvas.draw()
44
45 def pcolor():
46 pass
47
48
49
50 No newline at end of file
@@ -0,0 +1,85
1 import numpy
2 import datetime
3 from graphics.figure import *
4
5 class Scope(Figure):
6 __isConfig = None
7 width = None
8 height = None
9
10 def __init__(self):
11 self.__isConfig = False
12 self.width = 850
13 self.height = 800
14
15 def getSubplots(self):
16 nrow = self.nplots
17 ncol = 3
18 return nrow, ncol
19
20 def setup(self, idfigure, wintitle, width, height, nplots):
21 self.init(idfigure, wintitle, width, height, nplots)
22
23 nrow,ncol = self.getSubplots()
24 colspan = 3
25 rowspan = 1
26
27 for i in range(nplots):
28 self.makeAxes(nrow, ncol, i, 0, colspan, rowspan)
29
30
31
32 def run(self, dataOut, idfigure, wintitle="", channelList=None, xmin=None, xmax=None, ymin=None, ymax=None):
33
34 if dataOut.isEmpty():
35 return None
36
37 if channelList == None:
38 channelList = dataOut.channelList
39
40 nplots = len(channelList)
41
42 y = dataOut.data[channelList,:] * numpy.conjugate(dataOut.data[channelList,:])
43 y = y.real
44
45 x = dataOut.heightList
46
47 if not self.__isConfig:
48 self.setup(idfigure=idfigure,
49 wintitle="Figura 1",
50 width=self.width,
51 height=self.height,
52 nplots=nplots)
53
54 if xmin == None: self.xmin = numpy.min(x)
55 if xmax == None: self.xmax = numpy.max(x)
56 if ymin == None: self.ymin = numpy.min(y)
57 if ymax == None: self.ymax = numpy.max(y)
58
59 self.__isConfig = True
60
61
62
63 thisDatetime = datetime.datetime.fromtimestamp(dataOut.utctime)
64 dateTime = "%s"%(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
65 date = "%s"%(thisDatetime.strftime("%d-%b-%Y"))
66 figuretitle = "Scope: " + dateTime
67
68 self.setTitle(title=figuretitle)
69
70 # self.setTextFromAxes(title=figuretitle)
71
72 ylabel = "Intensity"
73
74 xlabel = "Range[Km]"
75
76 for i in range(len(self.axesList)):
77 title = "Channel %d"%i
78 axes = self.axesList[i]
79 y2 = y[i,:]
80 axes.pline(x, y2, self.xmin, self.xmax, self.ymin, self.ymax, xlabel, ylabel, title)
81
82 self.draw()
83
84
85 No newline at end of file
@@ -15,20 +15,18 class Test():
15
15
16 def createObjects(self):
16 def createObjects(self):
17
17
18
19
20 self.upConfig = controller.UPConf(id=1, name="voltageproc", type="voltage")
18 self.upConfig = controller.UPConf(id=1, name="voltageproc", type="voltage")
21
19
22 opConf = self.upConfig.addOperation(name="init", priority=0)
20 opConf = self.upConfig.addOperation(name="init", priority=0)
23
21
24 opConf1 = self.upConfig.addOperation(name="CohInt", priority=1, type="other")
22 opConf1 = self.upConfig.addOperation(name="CohInt", priority=1, type="other")
23 opConf1.addParameter(name="nCohInt", value=100)
25
24
26 opConf1.addParameter(name="nCohInt", value=10)
25 opConf2 = self.upConfig.addOperation(name="Scope", priority=2, type="other")
27
26 opConf2.addParameter(name="idfigure", value=1)
28
29 opConf = self.upConfig.addOperation(name="selectChannels", priority=2)
30
27
31 opConf.addParameter(name="channelList", value=[0,1])
28 # opConf = self.upConfig.addOperation(name="selectChannels", priority=3)
29 # opConf.addParameter(name="channelList", value=[0,1])
32
30
33
31
34 #########################################
32 #########################################
@@ -36,9 +34,13 class Test():
36 self.objP = jroprocessing.VoltageProc()
34 self.objP = jroprocessing.VoltageProc()
37
35
38 self.objInt = jroprocessing.CohInt()
36 self.objInt = jroprocessing.CohInt()
39
37
40 self.objP.addOperation(self.objInt, opConf1.id)
38 self.objP.addOperation(self.objInt, opConf1.id)
41
39
40 self.objScope = jroplot.Scope()
41
42 self.objP.addOperation(self.objScope, opConf2.id)
43
42 self.connect(self.objR, self.objP)
44 self.connect(self.objR, self.objP)
43
45
44 def connect(self, obj1, obj2):
46 def connect(self, obj1, obj2):
General Comments 0
You need to be logged in to leave comments. Login now