##// END OF EJS Templates
Daniel Valdez -
r138:e16175a3f22c
parent child
Show More
@@ -61,7 +61,7 class Figure:
61 61 def createFrames(self):
62 62 raise ValueError, "No implemented"
63 63
64 def plot1DArray(self, data1D, x=None, channelList=None, xmin=None, xmax=None, minvalue=None, maxvalue=None, figtitle=None, save=False, gpath='./'):
64 def plot1DArray(self, data1D, x=None, channelList=None, xmin=None, xmax=None, minvalue=None, maxvalue=None, figuretitle=None, save=False, gpath='./'):
65 65
66 66 nx, ny = data1D.shape
67 67
@@ -71,10 +71,10 class Figure:
71 71 if x == None:
72 72 x = numpy.arange(data1D.size)
73 73
74 if figtitle == None:
75 self.figtitle = ""
74 if figuretitle == None:
75 self.figuretitle = ""
76 76 else:
77 self.figtitle = figtitle
77 self.figuretitle = figuretitle
78 78
79 79 if not(self.__isDriverOpen):
80 80 self.__openDriver()
@@ -104,7 +104,6 class Figure:
104 104 self.__initFigure()
105 105
106 106 for channel in channelList:
107 # frametitle = self.plotTitleDict[channel]
108 107 frameObj = self.frameObjList[channel]
109 108 frameObj.init(xmin=self.xmin,
110 109 xmax=self.xmax,
@@ -133,6 +132,69 class Figure:
133 132 # self.colorplotObj.savePlot(indexPlot, filename)
134 133 #
135 134 # self.colorplotObj.closePage()
135
136
137 def plotPcolor(self,data,
138 x=None,
139 y=None,
140 channelList=None,
141 xmin=None,
142 xmax=None,
143 ymin=None,
144 ymax=None,
145 minvalue=None,
146 maxvalue=None,
147 figuretitle=None,
148 deltax=None,
149 save=False,
150 gpath='./'):
151 # data,
152 # currenttime,
153 # range,
154 # starttime,
155 # endtime,
156 # minrange,
157 # maxrange,
158 # minvalue,
159 # maxvalue,
160 # figuretitle,
161 # interval,
162 # save,
163 # gpath):
164
165 if figuretitle == None:
166 self.figuretitle = ""
167 else:
168 self.figuretitle = figuretitle
169
170
171
172 if not(self.__isDriverOpen):
173 self.__openDriver()
174 self.__isDriverOpen = True
175
176 if not(self.__isConfig):
177
178 self.setParms(data,x,y,xmin,xmax,ymin,ymax,minvalue,maxvalue,deltax)
179
180
181
182 # if self.xmin == None: self.xmin = numpy.min(x)
183 # if self.xmax == None: self.xmax = numpy.max(x)
184
185
186 self.createFrames()
187 self.__isConfig = True
188
189 if not(self.__isOutOfXRange(x)):
190 self.__changeXRange(x)
191
192 if self.__isFigureOpen:
193 self.driverObj.closePage()
194 self.__isFigureOpen = False
195
196 self.__initFigure()
197
136 198
137 199 class Frame:
138 200 nplots = None
@@ -4,11 +4,11 import sys
4 4 import plplot #condicional
5 5
6 6 class Driver:
7 def __init__(self,driver, idfigure, xw, yw, wintitle, overplot, colorbar, colormap):
7 def __init__(self,driver, idfigure, xw, yw, wintitle, overplot, colormap, colorbar):
8 8 if driver == "plplot":
9 self.driver = PlplotDriver(idfigure, xw, yw, wintitle, overplot, colorbar, colormap)
9 self.driver = PlplotDriver(idfigure, xw, yw, wintitle, overplot, colormap, colorbar)
10 10 elif driver == "mpl":
11 self.driver = MplDriver(idfigure, xw, yw, wintitle, overplot, colormap)
11 self.driver = MplDriver(idfigure, xw, yw, wintitle, overplot, colormap, colorbar)
12 12 else:
13 13 raise ValueError, "The driver: %s is not defined"%driver
14 14
@@ -17,7 +17,7 class PlplotDriver:
17 17 __isDriverOpen = False
18 18 pldriver = None
19 19
20 def __init__(self, idfigure, xw, yw, wintitle, overplot, colorbar, colormap):
20 def __init__(self, idfigure, xw, yw, wintitle, overplot, colormap, colorbar):
21 21
22 22 if idfigure == None:
23 23 raise ValueError, 'idfigure input must be defined'
@@ -27,10 +27,8 class PlplotDriver:
27 27 self.yw = yw
28 28 self.wintitle = wintitle
29 29 self.overplot = overplot
30 self.colorbar = colorbar
31 30 self.colormap = colormap
32
33
31 self.colorbar = colorbar
34 32
35 33 def setFigure(self):
36 34 """
@@ -99,6 +97,31 class PlplotDriver:
99 97 plplot.plschr(0.0,szchar)
100 98 plplot.plmtex("t",-1., 0.5, 0.5, title)
101 99
100 def colorbar(self, minvalue, maxvalue, xpos, ypos):
101 # plplot.pladv(id)
102 # plplot.plschr(0.0,szchar-0.05)
103 xmin = 0; xmax = 1
104 ymin = minvalue; ymax = maxvalue
105 plplot.plvpor(xpos[0], xpos[1], ypos[0], ypos[1])
106 plplot.plwind(float(xmin), float(xmax), float(ymin), float(ymax))
107 plplot.plbox("bc", 0.0, 0, "bcmtsv", 0.0, 0)
108
109 data = numpy.arange(256)
110 data = numpy.reshape(data, (1,-1))
111
112 plplot.plimage(data,
113 float(xmin),
114 float(xmax),
115 float(ymin),
116 float(ymax),
117 0.,
118 255.,
119 float(xmin),
120 float(xmax),
121 float(ymin),
122 float(ymax))
123
124
102 125 def plotBox(self, id, xpos, ypos, xmin, xmax, ymin, ymax, minvalue, maxvalue, xopt, yopt, szchar=0.6, xaxisastime = False, timefmt="%H:%M"):
103 126 """
104 127 xopt, yopt: entradas que no se aplican en MPL
@@ -151,3 +174,8 class PlplotDriver:
151 174 plplot.plline(x, y)
152 175 plplot.plcol0(1)
153 176 plplot.plbox("bcst", 0.0, 0, "bcst", 0.0, 0)
177
178
179 class MplDriver:
180 def __init__(self):
181 pass No newline at end of file
@@ -1,32 +1,224
1 import numpy
1 import nump
2 import datetime
3 import time
2 4 from schainPlot import *
3 5 #from schainPlotLib import Driver
4 6
7
8 class RTIFigure:
9 overplot = 1
10 xw = 700
11 yw = 650
12 showprofile = False
13 starttime = None
14 endtime = None
15 minrange = None
16 maxrange = None
17 minvalue = None
18 maxvalue = None
19
20
21 def __init__(self, idfigure, nframes, wintitle, driver, colormap="br_green", colorbar= True, showprofile=False):
22 self.idfigure = idfigure
23 self.nframes = nframes
24 self.wintitle = wintitle
25 self.colormap = colormap
26 self.colorbar = colorbar
27 self.showprofile = showprofile
28 self.driver = driver
29 self.drvObj = Driver(self.driver, self.idfigure, self.xw, self.yw, self.wintitle, self.overplot, self.colormap, self.colorbar)
30 self.drvObj.driver.setFigure()
31
32 def getSubplots(self):
33 nrows = self.nframes
34 ncolumns = 1
35 return nrows, ncolumns
36
37 def setParms(self, data, x, y, xmin, xmax, ymin, ymax, minvalue, maxvalue, deltax):
38
39 if minvalue == None: minvalue = numpy.min(data)
40 if maxvalue == None: maxvalue = numpy.max(data)
41
42 utcdatetime = datetime.datetime.utcfromtimestamp(x)
43 startdatetime = datetime.datetime(thisDateTime.year,thisDateTime.month,thisDateTime.day,xmin.hour,xmin.minute, xmin.second)
44 enddatetime = datetime.datetime(thisDateTime.year,thisDateTime.month,thisDateTime.day,xmax.hour,xmax.minute, xmax.second)
45 deltatime = 0
46 if timezone == "lt": deltatime = time.timezone
47 startTimeInSecs = time.mktime(startdatetime.timetuple()) - deltatime
48 endTimeInSecs = time.mktime(enddatetime.timetuple()) - deltatime
49 self.starttime = xmin
50 self.endtime = xmax
51 self.xmin = startTimeInSecs
52 self.xmax = self.xmin + interval
53
54
55
56 if ymin == None: ymin = numpy.min(y)
57 if ymin == None: ymax = numpy.max(y)
58
59 starttime = None
60 endtime = None
61 minrange = None
62 maxrange = None
63 minvalue = None
64 maxvalue = None
65
66
67 self.xmin = s
68 self.xmax = self.starttime + timeinterval
69 self.ymin = minrange
70 self.ymax = maxrange
71 self.minvalue = minvalue
72 self.maxvalue = maxvalue
73
74
75 def createFrames(self):
76 for frame in range(self.nframes):
77 frameObj = ScopeFrame(self.drvObj,frame + 1)
78 self.frameObjList.append(frameObj)
79
80 class RTIFrame(Frame):
81 def __init__(self,drvObj,idframe,colorbar,showProfile):
82 self.drvObj = drvObj
83 self.idframe = idframe
84 self.nplots = 1
85
86 if showProfile:
87 self.nplots += 1
88
89 self.colorbar = colorbar
90 self.showprofile = showprofile
91 self.createPlots()
92
93 def createPlots(self):
94 plotObjList = []
95
96 idplot = 0
97 xi, yi, xw, yw = self.getScreenPos(idplot)
98 plotObj = RTIPlot(self.drvObj, self.idframe, idplot, xi, yi, xw, yw)
99 plotObjList.append(plotObj)
100
101 if self.showprofile:
102 idplot = 1
103 xi, yi, xw, yw = self.getScreenPos(idplot)
104 plotObj = Plot1D(self.drvObj, self.idframe, idplot, xi, yi, xw, yw)
105 plotObjList.append(plotObj)
106
107 self.plotObjList = plotObjList
108
109 def getScreenPosMainPlot(self):#cada Frame determina las coordenadas de los plots
110 xi = 0.07
111
112 if self.showprofile:
113 xw = 0.65
114
115 else:
116 xw = 0.9
117
118 if self.colorbar:
119 xw = xw - 0.06
120
121 yi = 0.20; yw = 0.75
122
123 return xi, yi, xw, yw
124
125 def getScreenPosGraph1(self):
126 if self.colorbar:
127 xi = 0.65 + 0.05
128 else:
129 xi = 0.9 + 0.05
130
131 xw = xi + 0.2
132
133 yi = 0.2; yw = 0.75
134
135 return xi, yi, xw, yw
136
137
138 class RTIPlot:
139 def __init__(self,drvObj, idframe, idplot, xi, yi, xw, yw):
140 self.drvObj = drvObj
141 self.idframe = idframe
142 self.idplot = idplot
143 self.xi = xi
144 self.yi = yi
145 self.xw = xw
146 self.yw = yw
147
148 if self.colorbar:
149 cbxi = xw + 0.03
150 cbxw = cbxi + 0.03
151 cbyi = yi
152 cbyw = yw
153 self.cbxpos = [cbxi,cbxw]
154 self.cbypos = [cbyi,cbyw]
155
156 self.xpos = [self.xi,self.xw]
157 self.ypos = [self.yi,self.yw]
158 self.xaxisastime = True
159 self.timefmt = "%H:%M"
160 self.xopt = "bcnstd"
161 self.yopt = "bcnstv"
162
163 self.szchar = 1.0
164 self.title = "Channel %d"%self.idframe
165 self.xlabel = "x-axis"
166 self.ylabel = "y-axis"
167
168 def plotBox(self, xmin, xmax, ymin, ymax, minvalue, maxvalue):
169 self.xmin = xmin
170 self.xmax = xmax
171 self.ymin = ymin
172 self.ymax = ymax
173 self.minvalue = minvalue
174 self.maxvalue = maxvalue
175
176 self.drvObj.driver.plotBox(self.idframe,
177 self.xpos,
178 self.ypos,
179 self.xmin,
180 self.xmax,
181 self.ymin,
182 self.ymax,
183 self.minvalue,
184 self.maxvalue,
185 self.xopt,
186 self.yopt,
187 self.szchar,
188 self.xaxisastime,
189 self.timefmt)
190
191 self.drvObj.driver.setPlotLabels(self.xlabel, self.ylabel, self.title)
192
193 if self.colorbar:
194 self.drvObj.driver.colorbar(minvalue, maxvalue, self.cbxpos,self.cbypos)
195
196
197 def plot(self):
198 pass
199
200
201
202
203
5 204 class ScopeFigure(Figure):
6 205 overplot = 0
7 206 xw = 700
8 207 yw = 650
9 208 colorbar = None
10 # frameObjList = []
11 209
12 210 def __init__(self,idfigure,nframes,wintitle,driver):
13 211 colormap = None
14 212 colorbar = False
15 addGraph = 0
16 args=(addGraph, addGraph)
17
18 213
19 214 self.idfigure = idfigure
20 215 self.nframes = nframes
21 216 self.wintitle = wintitle
22 # self.xw =
23 # self.yw =
24 # self.overplot =
25 self.driver = driver
26 self.colorbar = colorbar
217
27 218 self.colormap = colormap
28
29 self.drvObj = Driver(self.driver, self.idfigure, self.xw, self.yw, self.wintitle, self.overplot, self.colorbar, self.colormap)
219 self.colorbar = colorbar
220 self.driver = driver
221 self.drvObj = Driver(self.driver, self.idfigure, self.xw, self.yw, self.wintitle, self.overplot, self.colormap, self.colorbar)
30 222 self.drvObj.driver.setFigure()
31 223
32 224 # Figure.__init__(self,idfigure,nframes,wintitle,self.xw,self.yw,self.overplot,driver,colorbar,colormap,*args)
General Comments 0
You need to be logged in to leave comments. Login now