@@ -1,232 +1,294 | |||
|
1 | 1 | import numpy |
|
2 | 2 | from schainPlotLib import Driver |
|
3 | 3 | |
|
4 | 4 | class Figure: |
|
5 | 5 | __isDriverOpen = False |
|
6 | 6 | __isFigureOpen = False |
|
7 | 7 | __isConfig = False |
|
8 | 8 | drvObj = None |
|
9 | 9 | idfigure = None |
|
10 | 10 | nframes = None |
|
11 | 11 | wintitle = None |
|
12 | 12 | colormap = None |
|
13 | 13 | driver = None |
|
14 | 14 | overplot = None |
|
15 | 15 | xmin = None |
|
16 | 16 | xmax = None |
|
17 | 17 | minvalue = None |
|
18 | 18 | maxvalue = None |
|
19 | 19 | frameObjList = [] |
|
20 | 20 | figtitle = "" |
|
21 | 21 | |
|
22 | 22 | def __init__(self,idfigure, nframes, wintitle, xw=600, yw=800, overplot=0, driver='plplot', colorbar= True, colormap=None, *args): |
|
23 | 23 | self.idfigure = idfigure |
|
24 | 24 | self.nframes = nframes |
|
25 | 25 | self.wintitle = wintitle |
|
26 | 26 | self.xw = xw |
|
27 | 27 | self.yw = yw |
|
28 | 28 | self.overplot = overplot |
|
29 | 29 | self.colorbar = colorbar |
|
30 | 30 | self.colormap = colormap |
|
31 | 31 | #esta seccion deberia ser dinamica de acuerdo a len(args) |
|
32 | 32 | self.showGraph1 = args[0] |
|
33 | 33 | self.showGraph2 = args[1] |
|
34 | 34 | |
|
35 | 35 | self.drvObj = Driver(driver, idfigure, xw, yw, wintitle, overplot, colorbar, colormap) |
|
36 | 36 | |
|
37 | 37 | self.drvObj.driver.setFigure() |
|
38 | 38 | |
|
39 | 39 | |
|
40 | 40 | def __openDriver(self): |
|
41 | 41 | self.drvObj.driver.openDriver() |
|
42 | 42 | |
|
43 | 43 | # def __openFigure(self): |
|
44 | 44 | # nrows, ncolumns = self.getSubplots() |
|
45 | 45 | # self.drvObj.driver.openFigure() |
|
46 | 46 | # self.drvObj.driver.setTitleFig(title) |
|
47 | 47 | # self.drvObj.driver.setSubPlots(nrows, ncolumns) |
|
48 | 48 | |
|
49 | 49 | def __initFigure(self): |
|
50 | 50 | nrows, ncolumns = self.getSubplots() |
|
51 | 51 | self.drvObj.driver.openFigure() |
|
52 | 52 | self.drvObj.driver.setFigTitle(self.figtitle) |
|
53 | 53 | self.drvObj.driver.setSubPlots(nrows, ncolumns) |
|
54 | 54 | |
|
55 | 55 | def __isOutOfXRange(self,x): |
|
56 | 56 | return 1 |
|
57 | 57 | |
|
58 | 58 | def __refresh(self): |
|
59 | 59 | self.drvObj.driver.refresh() |
|
60 | 60 | |
|
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 | |
|
68 | 68 | if channelList == None: |
|
69 | 69 | channelList = range(nx) |
|
70 | 70 | |
|
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() |
|
81 | 81 | self.__isDriverOpen = True |
|
82 | 82 | |
|
83 | 83 | if not(self.__isConfig): |
|
84 | 84 | self.xmin = xmin |
|
85 | 85 | self.xmax = xmax |
|
86 | 86 | self.minvalue = minvalue |
|
87 | 87 | self.maxvalue = maxvalue |
|
88 | 88 | |
|
89 | 89 | if self.xmin == None: self.xmin = numpy.min(x) |
|
90 | 90 | if self.xmax == None: self.xmax = numpy.max(x) |
|
91 | 91 | if self.minvalue == None: self.minvalue = numpy.min(data1D) |
|
92 | 92 | if self.maxvalue == None: self.maxvalue = numpy.max(data1D) |
|
93 | 93 | |
|
94 | 94 | self.createFrames() |
|
95 | 95 | self.__isConfig = True |
|
96 | 96 | |
|
97 | 97 | if not(self.__isOutOfXRange(x)): |
|
98 | 98 | self.__changeXRange(x) |
|
99 | 99 | |
|
100 | 100 | if self.__isFigureOpen: |
|
101 | 101 | self.driverObj.closePage() |
|
102 | 102 | self.__isFigureOpen = False |
|
103 | 103 | |
|
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, |
|
111 | 110 | ymin=self.minvalue, |
|
112 | 111 | ymax=self.maxvalue, |
|
113 | 112 | minvalue=self.minvalue, |
|
114 | 113 | maxvalue=self.maxvalue) |
|
115 | 114 | |
|
116 | 115 | for channel in channelList: |
|
117 | 116 | dataCh = data1D[channel,:] |
|
118 | 117 | frameObj = self.frameObjList[channel] |
|
119 | 118 | # frameObj.clearData() |
|
120 | 119 | frameObj.plot(x, dataCh) |
|
121 | 120 | |
|
122 | 121 | # frameObj.refresh() |
|
123 | 122 | self.__refresh() |
|
124 | 123 | |
|
125 | 124 | |
|
126 | 125 | # |
|
127 | 126 | # if save: |
|
128 | 127 | # self.colorplotObj.setFigure(indexPlot) |
|
129 | 128 | # path = "/home/roj-idl71/tmp/" |
|
130 | 129 | # now = datetime.datetime.now().timetuple() |
|
131 | 130 | # file = "spc_img%02d_%03d_%02d%02d%02d.png"%(indexPlot,now[7],now[3],now[4],now[5]) |
|
132 | 131 | # filename = os.path.join(path,file) |
|
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 |
|
139 | 201 | plotObjList = [] |
|
140 | 202 | title = "" |
|
141 | 203 | def __init__(self,drvObj, idframe): |
|
142 | 204 | self.drvObj = drvObj |
|
143 | 205 | self.idframe = idframe |
|
144 | 206 | self.createPlots() |
|
145 | 207 | |
|
146 | 208 | def createPlots(self): |
|
147 | 209 | raise ValueError, "No implemented" |
|
148 | 210 | |
|
149 | 211 | def getScreenPosMainPlot(self): |
|
150 | 212 | raise ValueError, "No implemented" |
|
151 | 213 | |
|
152 | 214 | def getScreenPos(self, nplot): |
|
153 | 215 | |
|
154 | 216 | if nplot == 0: |
|
155 | 217 | xi, yi, xw, yw = self.getScreenPosMainPlot() |
|
156 | 218 | return xi, yi, xw, yw |
|
157 | 219 | |
|
158 | 220 | |
|
159 | 221 | def init(self, xmin, xmax, ymin, ymax, minvalue, maxvalue): |
|
160 | 222 | |
|
161 | 223 | for plotObj in self.plotObjList: |
|
162 | 224 | plotObj.plotBox(xmin, xmax, ymin, ymax, minvalue, maxvalue) |
|
163 | 225 | # plotObj.setLabels() # ? evaluar si conviene colocarlo dentro del plotbox |
|
164 | 226 | |
|
165 | 227 | def refresh(self): |
|
166 | 228 | for plotObj in self.plotObjList: |
|
167 | 229 | plotObj.refresh() |
|
168 | 230 | |
|
169 | 231 | class Plot: |
|
170 | 232 | title = "" |
|
171 | 233 | xlabel = "" |
|
172 | 234 | ylabel = "" |
|
173 | 235 | xaxisastime = None |
|
174 | 236 | timefmt = None |
|
175 | 237 | xopt = "" |
|
176 | 238 | yopt = "" |
|
177 | 239 | xpos = None |
|
178 | 240 | ypos = None |
|
179 | 241 | szchar = None |
|
180 | 242 | idframe = None |
|
181 | 243 | idplot = None |
|
182 | 244 | |
|
183 | 245 | def __init__(self, drvObj, idframe, idplot, xi, yi, xw, yw): |
|
184 | 246 | self.drvObj = drvObj |
|
185 | 247 | self.idframe = idframe |
|
186 | 248 | self.idplot = idplot |
|
187 | 249 | self.xi = xi |
|
188 | 250 | self.yi = yi |
|
189 | 251 | self.xw = xw |
|
190 | 252 | self.yw = yw |
|
191 | 253 | |
|
192 | 254 | # def setLabels(self): |
|
193 | 255 | # self.drvObj.driver.setPlotLabels(self.xlabel, self.ylabel, self.title) |
|
194 | 256 | |
|
195 | 257 | def plotBox(self, xmin, xmax, ymin, ymax, minvalue, maxvalue): |
|
196 | 258 | self.xmin = xmin |
|
197 | 259 | self.xmax = xmax |
|
198 | 260 | self.ymin = ymin |
|
199 | 261 | self.ymax = ymax |
|
200 | 262 | self.minvalue = minvalue |
|
201 | 263 | self.maxvalue = maxvalue |
|
202 | 264 | |
|
203 | 265 | self.drvObj.driver.plotBox(self.idframe, |
|
204 | 266 | self.xpos, |
|
205 | 267 | self.ypos, |
|
206 | 268 | self.xmin, |
|
207 | 269 | self.xmax, |
|
208 | 270 | self.ymin, |
|
209 | 271 | self.ymax, |
|
210 | 272 | self.minvalue, |
|
211 | 273 | self.maxvalue, |
|
212 | 274 | self.xopt, |
|
213 | 275 | self.yopt, |
|
214 | 276 | self.szchar, |
|
215 | 277 | self.xaxisastime, |
|
216 | 278 | self.timefmt) |
|
217 | 279 | |
|
218 | 280 | self.drvObj.driver.setPlotLabels(self.xlabel, self.ylabel, self.title) |
|
219 | 281 | |
|
220 | 282 | def plotBasicLine(self,x, y, color): |
|
221 | 283 | """ |
|
222 | 284 | Inputs: |
|
223 | 285 | x: |
|
224 | 286 | |
|
225 | 287 | y: |
|
226 | 288 | |
|
227 | 289 | color: |
|
228 | 290 | """ |
|
229 | 291 | self.drvObj.driver.basicLine(x, y, self.xmin, self.xmax, self.ymin, self.ymax, color, self.idframe, self.xpos, self.ypos) |
|
230 | 292 | |
|
231 | 293 | |
|
232 | 294 | No newline at end of file |
@@ -1,153 +1,181 | |||
|
1 | 1 | import plplot |
|
2 | 2 | import numpy |
|
3 | 3 | import sys |
|
4 | 4 | import plplot #condicional |
|
5 | 5 | |
|
6 | 6 | class Driver: |
|
7 |
def __init__(self,driver, idfigure, xw, yw, wintitle, overplot, color |
|
|
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, color |
|
|
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 | |
|
15 | 15 | class PlplotDriver: |
|
16 | 16 | |
|
17 | 17 | __isDriverOpen = False |
|
18 | 18 | pldriver = None |
|
19 | 19 | |
|
20 |
def __init__(self, idfigure, xw, yw, wintitle, overplot, color |
|
|
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' |
|
24 | 24 | |
|
25 | 25 | self.idfigure = idfigure |
|
26 | 26 | self.xw = xw |
|
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 | """ |
|
37 | 35 | previous configuration to open(init) the plplot driver |
|
38 | 36 | """ |
|
39 | 37 | plplot.plsstrm(self.idfigure) |
|
40 | 38 | plplot.plparseopts([self.wintitle],plplot.PL_PARSE_FULL) |
|
41 | 39 | plplot.plsetopt("geometry", "%dx%d"%(self.xw, self.yw)) |
|
42 | 40 | |
|
43 | 41 | |
|
44 | 42 | def openDriver(self, pldriver=None): |
|
45 | 43 | if pldriver == None: |
|
46 | 44 | if sys.platform == "linux": |
|
47 | 45 | pldriver = "xcairo" |
|
48 | 46 | |
|
49 | 47 | if sys.platform == "linux2": |
|
50 | 48 | pldriver = "xcairo" |
|
51 | 49 | |
|
52 | 50 | elif sys.platform == "darwin": |
|
53 | 51 | pldriver = "xwin" |
|
54 | 52 | |
|
55 | 53 | else: |
|
56 | 54 | pldriver = "" |
|
57 | 55 | |
|
58 | 56 | plplot.plsdev("xwin") #para pruebas |
|
59 | 57 | plplot.plscolbg(255,255,255) |
|
60 | 58 | plplot.plscol0(1,0,0,0) |
|
61 | 59 | plplot.plinit() |
|
62 | 60 | plplot.plspause(False) |
|
63 | 61 | |
|
64 | 62 | self.pldriver = pldriver |
|
65 | 63 | |
|
66 | 64 | def closeDriver(self): |
|
67 | 65 | pass |
|
68 | 66 | |
|
69 | 67 | def openPage(self): |
|
70 | 68 | plplot.plbop() |
|
71 | 69 | plplot.pladv(0) |
|
72 | 70 | |
|
73 | 71 | def closePage(self): |
|
74 | 72 | plplot.pleop() |
|
75 | 73 | |
|
76 | 74 | def openFigure(self): |
|
77 | 75 | plplot.plbop() |
|
78 | 76 | plplot.pladv(0) |
|
79 | 77 | |
|
80 | 78 | def closeFigure(self): |
|
81 | 79 | plplot.pleop() |
|
82 | 80 | |
|
83 | 81 | def setSubPlots(self,nrows, ncolumns): |
|
84 | 82 | plplot.plssub(ncolumns,nrows) |
|
85 | 83 | |
|
86 | 84 | def setPlotLabels(self, xlabel, ylabel, title): |
|
87 | 85 | plplot.pllab(xlabel, ylabel, title) |
|
88 | 86 | |
|
89 | 87 | def setFigTitle(self, title,color="black", szchar=0.55): |
|
90 | 88 | self.setSubPlots(1, 0) |
|
91 | 89 | plplot.pladv(0) |
|
92 | 90 | plplot.plvpor(0., 1., 0., 1.) |
|
93 | 91 | |
|
94 | 92 | if color == "black": |
|
95 | 93 | plplot.plcol0(1) |
|
96 | 94 | if color == "white": |
|
97 | 95 | plplot.plcol0(15) |
|
98 | 96 | |
|
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 |
|
105 | 128 | """ |
|
106 | 129 | plplot.pladv(id) |
|
107 | 130 | plplot.plschr(0.0,szchar-0.05) |
|
108 | 131 | plplot.plvpor(xpos[0], xpos[1], ypos[0], ypos[1]) |
|
109 | 132 | plplot.plwind(float(xmin), float(xmax), float(ymin), float(ymax)) |
|
110 | 133 | if xaxisastime: |
|
111 | 134 | plplot.pltimefmt(timefmt) |
|
112 | 135 | timedelta = (xmax - xmin + 1)/8. |
|
113 | 136 | plplot.plbox(xopt, timedelta, 3, yopt, 0.0, 0) |
|
114 | 137 | else: |
|
115 | 138 | plplot.plbox(xopt, 0.0, 0, yopt, 0.0, 0) |
|
116 | 139 | |
|
117 | 140 | def refresh(self): |
|
118 | 141 | plplot.plflush() |
|
119 | 142 | |
|
120 | 143 | def basicLine(self, x, y, xmin, xmax, ymin, ymax, color, id, xpos, ypos): |
|
121 | 144 | |
|
122 | 145 | """ |
|
123 | 146 | Inputs: |
|
124 | 147 | x: datos en el eje x |
|
125 | 148 | |
|
126 | 149 | y: datos en el eje y |
|
127 | 150 | |
|
128 | 151 | xmin, xmax: intervalo de datos en el eje x |
|
129 | 152 | |
|
130 | 153 | ymin, ymax: intervalo de datos en el eje y |
|
131 | 154 | |
|
132 | 155 | color: color de la linea a dibujarse |
|
133 | 156 | |
|
134 | 157 | id: identificador del plot, en este caso indica al frame que pertenece, la posicion de cada |
|
135 | 158 | plot esta definido por xpos, ypos. |
|
136 | 159 | |
|
137 | 160 | xpos,ypos: coordenadas que indican la posicion del plot en el frame |
|
138 | 161 | |
|
139 | 162 | """ |
|
140 | 163 | |
|
141 | 164 | plplot.pladv(id) |
|
142 | 165 | plplot.plvpor(xpos[0], xpos[1], ypos[0], ypos[1]) |
|
143 | 166 | plplot.plwind(float(xmin),float(xmax), float(ymin), float(ymax)) |
|
144 | 167 | |
|
145 | 168 | if color == "blue": |
|
146 | 169 | colline = 9 |
|
147 | 170 | if color == "green": |
|
148 | 171 | colline = 3 |
|
149 | 172 | |
|
150 | 173 | plplot.plcol0(colline) |
|
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,106 +1,298 | |||
|
1 |
import nump |
|
|
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) |
|
33 | 225 | |
|
34 | 226 | def getSubplots(self): |
|
35 | 227 | nrows = self.nframes |
|
36 | 228 | ncolumns = 1 |
|
37 | 229 | return nrows, ncolumns |
|
38 | 230 | |
|
39 | 231 | def createFrames(self): |
|
40 | 232 | for frame in range(self.nframes): |
|
41 | 233 | frameObj = ScopeFrame(self.drvObj,frame + 1) |
|
42 | 234 | self.frameObjList.append(frameObj) |
|
43 | 235 | |
|
44 | 236 | |
|
45 | 237 | class ScopeFrame(Frame): |
|
46 | 238 | # plotObjList = [] |
|
47 | 239 | xlabel = "" |
|
48 | 240 | ylabel = "" |
|
49 | 241 | title = "" |
|
50 | 242 | def __init__(self,drvObj,idframe): |
|
51 | 243 | self.drvObj = drvObj |
|
52 | 244 | self.idframe = idframe |
|
53 | 245 | self.nplots = 1 #nplots/frame |
|
54 | 246 | self.createPlots() |
|
55 | 247 | # Frame.__init__(self, drvObj, idframe) |
|
56 | 248 | |
|
57 | 249 | def getScreenPosMainPlot(self):#cada Frame determina las coordenadas de los plots |
|
58 | 250 | xi = 0.07; xw = 0.9 |
|
59 | 251 | yi = 0.20; yw = 0.75 |
|
60 | 252 | return xi,yi,xw,yw |
|
61 | 253 | |
|
62 | 254 | def createPlots(self): |
|
63 | 255 | plotObjList = [] |
|
64 | 256 | for idplot in range(self.nplots): |
|
65 | 257 | xi, yi, xw, yw = self.getScreenPos(idplot) |
|
66 | 258 | plotObj = Plot1D(self.drvObj, self.idframe, idplot, xi, yi, xw, yw) |
|
67 | 259 | plotObjList.append(plotObj) |
|
68 | 260 | self.plotObjList = plotObjList |
|
69 | 261 | # self.plotObjList.append(plotObj) |
|
70 | 262 | |
|
71 | 263 | def plot(self, x, y, z=None): |
|
72 | 264 | for plotObj in self.plotObjList: |
|
73 | 265 | plotObj.plot(x, y) |
|
74 | 266 | |
|
75 | 267 | |
|
76 | 268 | class Plot1D(Plot): |
|
77 | 269 | |
|
78 | 270 | def __init__(self, drvObj, idframe, idplot, xi, yi, xw, yw): |
|
79 | 271 | self.drvObj = drvObj |
|
80 | 272 | self.idframe = idframe |
|
81 | 273 | self.idplot = idplot |
|
82 | 274 | self.xi = xi |
|
83 | 275 | self.yi = yi |
|
84 | 276 | self.xw = xw |
|
85 | 277 | self.yw = yw |
|
86 | 278 | self.xpos = [self.xi,self.xw] |
|
87 | 279 | self.ypos = [self.yi,self.yw] |
|
88 | 280 | self.xaxisastime = False |
|
89 | 281 | self.timefmt = None |
|
90 | 282 | self.xopt = "bcnst" |
|
91 | 283 | self.yopt = "bcnstv" |
|
92 | 284 | self.szchar = 1.0 |
|
93 | 285 | self.title = "Channel %d"%self.idframe |
|
94 | 286 | self.xlabel = "x-axis" |
|
95 | 287 | self.ylabel = "y-axis" |
|
96 | 288 | |
|
97 | 289 | |
|
98 | 290 | def plot(self,x,y): |
|
99 | 291 | if y.dtype == "complex128": |
|
100 | 292 | color="blue" |
|
101 | 293 | self.plotBasicLine(x, y.real, color) |
|
102 | 294 | color="red" |
|
103 | 295 | self.plotBasicLine(x, y.imag, color) |
|
104 | 296 | else: |
|
105 | 297 | color="blue" |
|
106 | 298 | self.plotBasicLine(x, y, color) |
General Comments 0
You need to be logged in to leave comments.
Login now