@@ -1,491 +1,496 | |||||
1 | import os |
|
1 | import os | |
2 | import numpy |
|
2 | import numpy | |
3 | import time, datetime |
|
3 | import time, datetime | |
4 | import mpldriver |
|
4 | import mpldriver | |
5 | from customftp import * |
|
5 | from customftp import * | |
6 |
|
6 | |||
7 | class Figure: |
|
7 | class Figure: | |
8 |
|
8 | |||
9 | __driver = mpldriver |
|
9 | __driver = mpldriver | |
10 | fig = None |
|
10 | fig = None | |
11 |
|
11 | |||
12 | idfigure = None |
|
12 | idfigure = None | |
13 | wintitle = None |
|
13 | wintitle = None | |
14 | width = None |
|
14 | width = None | |
15 | height = None |
|
15 | height = None | |
16 | nplots = None |
|
16 | nplots = None | |
17 | timerange = None |
|
17 | timerange = None | |
18 |
|
18 | |||
19 | axesObjList = [] |
|
19 | axesObjList = [] | |
20 |
|
20 | |||
21 | WIDTH = None |
|
21 | WIDTH = None | |
22 | HEIGHT = None |
|
22 | HEIGHT = None | |
23 | PREFIX = 'fig' |
|
23 | PREFIX = 'fig' | |
24 |
|
24 | |||
25 | def __init__(self): |
|
25 | def __init__(self): | |
26 |
|
26 | |||
27 | raise ValueError, "This method is not implemented" |
|
27 | raise ValueError, "This method is not implemented" | |
28 |
|
28 | |||
29 | def __del__(self): |
|
29 | def __del__(self): | |
30 |
|
30 | |||
31 | self.__driver.closeFigure() |
|
31 | self.__driver.closeFigure() | |
32 |
|
32 | |||
33 | def getFilename(self, name, ext='.png'): |
|
33 | def getFilename(self, name, ext='.png'): | |
34 |
|
34 | |||
35 | path = '%s%03d' %(self.PREFIX, self.idfigure) |
|
35 | path = '%s%03d' %(self.PREFIX, self.idfigure) | |
36 | filename = '%s_%s%s' %(self.PREFIX, name, ext) |
|
36 | filename = '%s_%s%s' %(self.PREFIX, name, ext) | |
37 |
|
37 | |||
38 | return os.path.join(path, filename) |
|
38 | return os.path.join(path, filename) | |
39 |
|
39 | |||
40 | def getAxesObjList(self): |
|
40 | def getAxesObjList(self): | |
41 |
|
41 | |||
42 | return self.axesObjList |
|
42 | return self.axesObjList | |
43 |
|
43 | |||
44 | def getSubplots(self): |
|
44 | def getSubplots(self): | |
45 |
|
45 | |||
46 | raise ValueError, "Abstract method: This method should be defined" |
|
46 | raise ValueError, "Abstract method: This method should be defined" | |
47 |
|
47 | |||
48 | def getScreenDim(self, widthplot, heightplot): |
|
48 | def getScreenDim(self, widthplot, heightplot): | |
49 |
|
49 | |||
50 | nrow, ncol = self.getSubplots() |
|
50 | nrow, ncol = self.getSubplots() | |
51 |
|
51 | |||
52 | widthscreen = widthplot*ncol |
|
52 | widthscreen = widthplot*ncol | |
53 | heightscreen = heightplot*nrow |
|
53 | heightscreen = heightplot*nrow | |
54 |
|
54 | |||
55 | return widthscreen, heightscreen |
|
55 | return widthscreen, heightscreen | |
56 |
|
56 | |||
57 | def getTimeLim(self, x, xmin, xmax): |
|
57 | def getTimeLim(self, x, xmin, xmax): | |
58 |
|
58 | |||
59 | thisdatetime = datetime.datetime.utcfromtimestamp(numpy.min(x)) |
|
59 | thisdatetime = datetime.datetime.utcfromtimestamp(numpy.min(x)) | |
60 | thisdate = datetime.datetime.combine(thisdatetime.date(), datetime.time(0,0,0)) |
|
60 | thisdate = datetime.datetime.combine(thisdatetime.date(), datetime.time(0,0,0)) | |
61 |
|
61 | |||
62 | #################################################### |
|
62 | #################################################### | |
63 | #If the x is out of xrange |
|
63 | #If the x is out of xrange | |
64 | if xmax < (thisdatetime - thisdate).seconds/(60*60.): |
|
64 | if xmax < (thisdatetime - thisdate).seconds/(60*60.): | |
65 | xmin = None |
|
65 | xmin = None | |
66 | xmax = None |
|
66 | xmax = None | |
67 |
|
67 | |||
68 | if xmin == None: |
|
68 | if xmin == None: | |
69 | td = thisdatetime - thisdate |
|
69 | td = thisdatetime - thisdate | |
70 | xmin = td.seconds/(60*60.) |
|
70 | xmin = td.seconds/(60*60.) | |
71 |
|
71 | |||
72 | if xmax == None: |
|
72 | if xmax == None: | |
73 | xmax = xmin + self.timerange/(60*60.) |
|
73 | xmax = xmin + self.timerange/(60*60.) | |
74 |
|
74 | |||
75 | mindt = thisdate + datetime.timedelta(hours=xmin) - datetime.timedelta(seconds=time.timezone) |
|
75 | mindt = thisdate + datetime.timedelta(hours=xmin) - datetime.timedelta(seconds=time.timezone) | |
76 | tmin = time.mktime(mindt.timetuple()) |
|
76 | tmin = time.mktime(mindt.timetuple()) | |
77 |
|
77 | |||
78 | maxdt = thisdate + datetime.timedelta(hours=xmax) - datetime.timedelta(seconds=time.timezone) |
|
78 | maxdt = thisdate + datetime.timedelta(hours=xmax) - datetime.timedelta(seconds=time.timezone) | |
79 | tmax = time.mktime(maxdt.timetuple()) |
|
79 | tmax = time.mktime(maxdt.timetuple()) | |
80 |
|
80 | |||
81 | self.timerange = tmax - tmin |
|
81 | self.timerange = tmax - tmin | |
82 |
|
82 | |||
83 | return tmin, tmax |
|
83 | return tmin, tmax | |
84 |
|
84 | |||
85 | def init(self, idfigure, nplots, wintitle): |
|
85 | def init(self, idfigure, nplots, wintitle): | |
86 |
|
86 | |||
87 | raise ValueError, "This method has been replaced with createFigure" |
|
87 | raise ValueError, "This method has been replaced with createFigure" | |
88 |
|
88 | |||
89 | def createFigure(self, idfigure, wintitle, widthplot=None, heightplot=None): |
|
89 | def createFigure(self, idfigure, wintitle, widthplot=None, heightplot=None): | |
90 |
|
90 | |||
91 | """ |
|
91 | """ | |
92 | Crea la figura de acuerdo al driver y parametros seleccionados seleccionados. |
|
92 | Crea la figura de acuerdo al driver y parametros seleccionados seleccionados. | |
93 | Las dimensiones de la pantalla es calculada a partir de los atributos self.WIDTH |
|
93 | Las dimensiones de la pantalla es calculada a partir de los atributos self.WIDTH | |
94 | y self.HEIGHT y el numero de subplots (nrow, ncol) |
|
94 | y self.HEIGHT y el numero de subplots (nrow, ncol) | |
95 |
|
95 | |||
96 | Input: |
|
96 | Input: | |
97 | idfigure : Los parametros necesarios son |
|
97 | idfigure : Los parametros necesarios son | |
98 | wintitle : |
|
98 | wintitle : | |
99 |
|
99 | |||
100 | """ |
|
100 | """ | |
101 |
|
101 | |||
102 | if widthplot == None: |
|
102 | if widthplot == None: | |
103 | widthplot = self.WIDTH |
|
103 | widthplot = self.WIDTH | |
104 |
|
104 | |||
105 | if heightplot == None: |
|
105 | if heightplot == None: | |
106 | heightplot = self.HEIGHT |
|
106 | heightplot = self.HEIGHT | |
107 |
|
107 | |||
108 | self.idfigure = idfigure |
|
108 | self.idfigure = idfigure | |
109 |
|
109 | |||
110 | self.wintitle = wintitle |
|
110 | self.wintitle = wintitle | |
111 |
|
111 | |||
112 | self.widthscreen, self.heightscreen = self.getScreenDim(widthplot, heightplot) |
|
112 | self.widthscreen, self.heightscreen = self.getScreenDim(widthplot, heightplot) | |
113 |
|
113 | |||
114 | self.fig = self.__driver.createFigure(self.idfigure, |
|
114 | self.fig = self.__driver.createFigure(self.idfigure, | |
115 | self.wintitle, |
|
115 | self.wintitle, | |
116 | self.widthscreen, |
|
116 | self.widthscreen, | |
117 | self.heightscreen) |
|
117 | self.heightscreen) | |
118 |
|
118 | |||
119 | self.axesObjList = [] |
|
119 | self.axesObjList = [] | |
120 |
|
120 | |||
121 |
|
121 | |||
122 | def setDriver(self, driver=mpldriver): |
|
122 | def setDriver(self, driver=mpldriver): | |
123 |
|
123 | |||
124 | self.__driver = driver |
|
124 | self.__driver = driver | |
125 |
|
125 | |||
126 | def setTitle(self, title): |
|
126 | def setTitle(self, title): | |
127 |
|
127 | |||
128 | self.__driver.setTitle(self.fig, title) |
|
128 | self.__driver.setTitle(self.fig, title) | |
129 |
|
129 | |||
130 | def setWinTitle(self, title): |
|
130 | def setWinTitle(self, title): | |
131 |
|
131 | |||
132 | self.__driver.setWinTitle(self.fig, title=title) |
|
132 | self.__driver.setWinTitle(self.fig, title=title) | |
133 |
|
133 | |||
134 | def setTextFromAxes(self, text): |
|
134 | def setTextFromAxes(self, text): | |
135 |
|
135 | |||
136 | raise ValueError, "Este metodo ha sido reemplazaado con el metodo setText de la clase Axes" |
|
136 | raise ValueError, "Este metodo ha sido reemplazaado con el metodo setText de la clase Axes" | |
137 |
|
137 | |||
138 | def makeAxes(self, nrow, ncol, xpos, ypos, colspan, rowspan): |
|
138 | def makeAxes(self, nrow, ncol, xpos, ypos, colspan, rowspan): | |
139 |
|
139 | |||
140 | raise ValueError, "Este metodo ha sido reemplazaado con el metodo addAxes" |
|
140 | raise ValueError, "Este metodo ha sido reemplazaado con el metodo addAxes" | |
141 |
|
141 | |||
142 | def addAxes(self, *args): |
|
142 | def addAxes(self, *args): | |
143 | """ |
|
143 | """ | |
144 |
|
144 | |||
145 | Input: |
|
145 | Input: | |
146 | *args : Los parametros necesarios son |
|
146 | *args : Los parametros necesarios son | |
147 | nrow, ncol, xpos, ypos, colspan, rowspan |
|
147 | nrow, ncol, xpos, ypos, colspan, rowspan | |
148 | """ |
|
148 | """ | |
149 |
|
149 | |||
150 | axesObj = Axes(self.fig, *args) |
|
150 | axesObj = Axes(self.fig, *args) | |
151 | self.axesObjList.append(axesObj) |
|
151 | self.axesObjList.append(axesObj) | |
152 |
|
152 | |||
153 | def saveFigure(self, figpath, figfile, *args): |
|
153 | def saveFigure(self, figpath, figfile, *args): | |
154 |
|
154 | |||
155 | filename = os.path.join(figpath, figfile) |
|
155 | filename = os.path.join(figpath, figfile) | |
156 |
|
156 | |||
157 | fullpath = os.path.split(filename)[0] |
|
157 | fullpath = os.path.split(filename)[0] | |
158 |
|
158 | |||
159 | if not os.path.exists(fullpath): |
|
159 | if not os.path.exists(fullpath): | |
|
160 | subpath = os.path.split(fullpath)[0] | |||
|
161 | ||||
|
162 | if not os.path.exists(subpath): | |||
|
163 | os.mkdir(subpath) | |||
|
164 | ||||
160 | os.mkdir(fullpath) |
|
165 | os.mkdir(fullpath) | |
161 |
|
166 | |||
162 | self.__driver.saveFigure(self.fig, filename, *args) |
|
167 | self.__driver.saveFigure(self.fig, filename, *args) | |
163 |
|
168 | |||
164 | def sendByFTP(self, figfilename): |
|
169 | def sendByFTP(self, figfilename): | |
165 | ftpObj = Ftp() |
|
170 | ftpObj = Ftp() | |
166 | ftpObj.upload(figfilename) |
|
171 | ftpObj.upload(figfilename) | |
167 | ftpObj.close() |
|
172 | ftpObj.close() | |
168 |
|
173 | |||
169 | def draw(self): |
|
174 | def draw(self): | |
170 |
|
175 | |||
171 | self.__driver.draw(self.fig) |
|
176 | self.__driver.draw(self.fig) | |
172 |
|
177 | |||
173 | def run(self): |
|
178 | def run(self): | |
174 |
|
179 | |||
175 | raise ValueError, "This method is not implemented" |
|
180 | raise ValueError, "This method is not implemented" | |
176 |
|
181 | |||
177 | axesList = property(getAxesObjList) |
|
182 | axesList = property(getAxesObjList) | |
178 |
|
183 | |||
179 |
|
184 | |||
180 | class Axes: |
|
185 | class Axes: | |
181 |
|
186 | |||
182 | __driver = mpldriver |
|
187 | __driver = mpldriver | |
183 | fig = None |
|
188 | fig = None | |
184 | ax = None |
|
189 | ax = None | |
185 | plot = None |
|
190 | plot = None | |
186 | __missing = 1E30 |
|
191 | __missing = 1E30 | |
187 | __firsttime = None |
|
192 | __firsttime = None | |
188 |
|
193 | |||
189 | __showprofile = False |
|
194 | __showprofile = False | |
190 |
|
195 | |||
191 | xmin = None |
|
196 | xmin = None | |
192 | xmax = None |
|
197 | xmax = None | |
193 | ymin = None |
|
198 | ymin = None | |
194 | ymax = None |
|
199 | ymax = None | |
195 | zmin = None |
|
200 | zmin = None | |
196 | zmax = None |
|
201 | zmax = None | |
197 |
|
202 | |||
198 | x_buffer = None |
|
203 | x_buffer = None | |
199 | z_buffer = None |
|
204 | z_buffer = None | |
200 |
|
205 | |||
201 | def __init__(self, *args): |
|
206 | def __init__(self, *args): | |
202 |
|
207 | |||
203 | """ |
|
208 | """ | |
204 |
|
209 | |||
205 | Input: |
|
210 | Input: | |
206 | *args : Los parametros necesarios son |
|
211 | *args : Los parametros necesarios son | |
207 | fig, nrow, ncol, xpos, ypos, colspan, rowspan |
|
212 | fig, nrow, ncol, xpos, ypos, colspan, rowspan | |
208 | """ |
|
213 | """ | |
209 |
|
214 | |||
210 | ax = self.__driver.createAxes(*args) |
|
215 | ax = self.__driver.createAxes(*args) | |
211 | self.fig = args[0] |
|
216 | self.fig = args[0] | |
212 | self.ax = ax |
|
217 | self.ax = ax | |
213 | self.plot = None |
|
218 | self.plot = None | |
214 |
|
219 | |||
215 | self.__firsttime = True |
|
220 | self.__firsttime = True | |
216 | self.idlineList = [] |
|
221 | self.idlineList = [] | |
217 |
|
222 | |||
218 | self.x_buffer = numpy.array([]) |
|
223 | self.x_buffer = numpy.array([]) | |
219 | self.z_buffer = numpy.array([]) |
|
224 | self.z_buffer = numpy.array([]) | |
220 |
|
225 | |||
221 | def setText(self, text): |
|
226 | def setText(self, text): | |
222 |
|
227 | |||
223 | self.__driver.setAxesText(self.ax, text) |
|
228 | self.__driver.setAxesText(self.ax, text) | |
224 |
|
229 | |||
225 | def setXAxisAsTime(self): |
|
230 | def setXAxisAsTime(self): | |
226 | pass |
|
231 | pass | |
227 |
|
232 | |||
228 | def pline(self, x, y, |
|
233 | def pline(self, x, y, | |
229 | xmin=None, xmax=None, |
|
234 | xmin=None, xmax=None, | |
230 | ymin=None, ymax=None, |
|
235 | ymin=None, ymax=None, | |
231 | xlabel='', ylabel='', |
|
236 | xlabel='', ylabel='', | |
232 | title='', |
|
237 | title='', | |
233 | **kwargs): |
|
238 | **kwargs): | |
234 |
|
239 | |||
235 | """ |
|
240 | """ | |
236 |
|
241 | |||
237 | Input: |
|
242 | Input: | |
238 | x : |
|
243 | x : | |
239 | y : |
|
244 | y : | |
240 | xmin : |
|
245 | xmin : | |
241 | xmax : |
|
246 | xmax : | |
242 | ymin : |
|
247 | ymin : | |
243 | ymax : |
|
248 | ymax : | |
244 | xlabel : |
|
249 | xlabel : | |
245 | ylabel : |
|
250 | ylabel : | |
246 | title : |
|
251 | title : | |
247 | **kwargs : Los parametros aceptados son |
|
252 | **kwargs : Los parametros aceptados son | |
248 |
|
253 | |||
249 | ticksize |
|
254 | ticksize | |
250 | ytick_visible |
|
255 | ytick_visible | |
251 | """ |
|
256 | """ | |
252 |
|
257 | |||
253 | if self.__firsttime: |
|
258 | if self.__firsttime: | |
254 |
|
259 | |||
255 | if xmin == None: xmin = numpy.nanmin(x) |
|
260 | if xmin == None: xmin = numpy.nanmin(x) | |
256 | if xmax == None: xmax = numpy.nanmax(x) |
|
261 | if xmax == None: xmax = numpy.nanmax(x) | |
257 | if ymin == None: ymin = numpy.nanmin(y) |
|
262 | if ymin == None: ymin = numpy.nanmin(y) | |
258 | if ymax == None: ymax = numpy.nanmax(y) |
|
263 | if ymax == None: ymax = numpy.nanmax(y) | |
259 |
|
264 | |||
260 | self.plot = self.__driver.createPline(self.ax, x, y, |
|
265 | self.plot = self.__driver.createPline(self.ax, x, y, | |
261 | xmin, xmax, |
|
266 | xmin, xmax, | |
262 | ymin, ymax, |
|
267 | ymin, ymax, | |
263 | xlabel=xlabel, |
|
268 | xlabel=xlabel, | |
264 | ylabel=ylabel, |
|
269 | ylabel=ylabel, | |
265 | title=title, |
|
270 | title=title, | |
266 | **kwargs) |
|
271 | **kwargs) | |
267 |
|
272 | |||
268 | self.idlineList.append(0) |
|
273 | self.idlineList.append(0) | |
269 | self.__firsttime = False |
|
274 | self.__firsttime = False | |
270 | return |
|
275 | return | |
271 |
|
276 | |||
272 | self.__driver.pline(self.plot, x, y, xlabel=xlabel, |
|
277 | self.__driver.pline(self.plot, x, y, xlabel=xlabel, | |
273 | ylabel=ylabel, |
|
278 | ylabel=ylabel, | |
274 | title=title) |
|
279 | title=title) | |
275 |
|
280 | |||
276 | def addpline(self, x, y, idline, **kwargs): |
|
281 | def addpline(self, x, y, idline, **kwargs): | |
277 | lines = self.ax.lines |
|
282 | lines = self.ax.lines | |
278 |
|
283 | |||
279 | if idline in self.idlineList: |
|
284 | if idline in self.idlineList: | |
280 | self.__driver.set_linedata(self.ax, x, y, idline) |
|
285 | self.__driver.set_linedata(self.ax, x, y, idline) | |
281 |
|
286 | |||
282 | if idline not in(self.idlineList): |
|
287 | if idline not in(self.idlineList): | |
283 | self.__driver.addpline(self.ax, x, y, **kwargs) |
|
288 | self.__driver.addpline(self.ax, x, y, **kwargs) | |
284 | self.idlineList.append(idline) |
|
289 | self.idlineList.append(idline) | |
285 |
|
290 | |||
286 | return |
|
291 | return | |
287 |
|
292 | |||
288 | def pmultiline(self, x, y, |
|
293 | def pmultiline(self, x, y, | |
289 | xmin=None, xmax=None, |
|
294 | xmin=None, xmax=None, | |
290 | ymin=None, ymax=None, |
|
295 | ymin=None, ymax=None, | |
291 | xlabel='', ylabel='', |
|
296 | xlabel='', ylabel='', | |
292 | title='', |
|
297 | title='', | |
293 | **kwargs): |
|
298 | **kwargs): | |
294 |
|
299 | |||
295 | if self.__firsttime: |
|
300 | if self.__firsttime: | |
296 |
|
301 | |||
297 | if xmin == None: xmin = numpy.nanmin(x) |
|
302 | if xmin == None: xmin = numpy.nanmin(x) | |
298 | if xmax == None: xmax = numpy.nanmax(x) |
|
303 | if xmax == None: xmax = numpy.nanmax(x) | |
299 | if ymin == None: ymin = numpy.nanmin(y) |
|
304 | if ymin == None: ymin = numpy.nanmin(y) | |
300 | if ymax == None: ymax = numpy.nanmax(y) |
|
305 | if ymax == None: ymax = numpy.nanmax(y) | |
301 |
|
306 | |||
302 | self.plot = self.__driver.createPmultiline(self.ax, x, y, |
|
307 | self.plot = self.__driver.createPmultiline(self.ax, x, y, | |
303 | xmin, xmax, |
|
308 | xmin, xmax, | |
304 | ymin, ymax, |
|
309 | ymin, ymax, | |
305 | xlabel=xlabel, |
|
310 | xlabel=xlabel, | |
306 | ylabel=ylabel, |
|
311 | ylabel=ylabel, | |
307 | title=title, |
|
312 | title=title, | |
308 | **kwargs) |
|
313 | **kwargs) | |
309 | self.__firsttime = False |
|
314 | self.__firsttime = False | |
310 | return |
|
315 | return | |
311 |
|
316 | |||
312 | self.__driver.pmultiline(self.plot, x, y, xlabel=xlabel, |
|
317 | self.__driver.pmultiline(self.plot, x, y, xlabel=xlabel, | |
313 | ylabel=ylabel, |
|
318 | ylabel=ylabel, | |
314 | title=title) |
|
319 | title=title) | |
315 |
|
320 | |||
316 | def pmultilineyaxis(self, x, y, |
|
321 | def pmultilineyaxis(self, x, y, | |
317 | xmin=None, xmax=None, |
|
322 | xmin=None, xmax=None, | |
318 | ymin=None, ymax=None, |
|
323 | ymin=None, ymax=None, | |
319 | xlabel='', ylabel='', |
|
324 | xlabel='', ylabel='', | |
320 | title='', |
|
325 | title='', | |
321 | **kwargs): |
|
326 | **kwargs): | |
322 |
|
327 | |||
323 | if self.__firsttime: |
|
328 | if self.__firsttime: | |
324 |
|
329 | |||
325 | if xmin == None: xmin = numpy.nanmin(x) |
|
330 | if xmin == None: xmin = numpy.nanmin(x) | |
326 | if xmax == None: xmax = numpy.nanmax(x) |
|
331 | if xmax == None: xmax = numpy.nanmax(x) | |
327 | if ymin == None: ymin = numpy.nanmin(y) |
|
332 | if ymin == None: ymin = numpy.nanmin(y) | |
328 | if ymax == None: ymax = numpy.nanmax(y) |
|
333 | if ymax == None: ymax = numpy.nanmax(y) | |
329 |
|
334 | |||
330 | self.plot = self.__driver.createPmultilineYAxis(self.ax, x, y, |
|
335 | self.plot = self.__driver.createPmultilineYAxis(self.ax, x, y, | |
331 | xmin, xmax, |
|
336 | xmin, xmax, | |
332 | ymin, ymax, |
|
337 | ymin, ymax, | |
333 | xlabel=xlabel, |
|
338 | xlabel=xlabel, | |
334 | ylabel=ylabel, |
|
339 | ylabel=ylabel, | |
335 | title=title, |
|
340 | title=title, | |
336 | **kwargs) |
|
341 | **kwargs) | |
337 | if self.xmin == None: self.xmin = xmin |
|
342 | if self.xmin == None: self.xmin = xmin | |
338 | if self.xmax == None: self.xmax = xmax |
|
343 | if self.xmax == None: self.xmax = xmax | |
339 | if self.ymin == None: self.ymin = ymin |
|
344 | if self.ymin == None: self.ymin = ymin | |
340 | if self.ymax == None: self.ymax = ymax |
|
345 | if self.ymax == None: self.ymax = ymax | |
341 |
|
346 | |||
342 | self.__firsttime = False |
|
347 | self.__firsttime = False | |
343 | return |
|
348 | return | |
344 |
|
349 | |||
345 | self.__driver.pmultilineyaxis(self.plot, x, y, xlabel=xlabel, |
|
350 | self.__driver.pmultilineyaxis(self.plot, x, y, xlabel=xlabel, | |
346 | ylabel=ylabel, |
|
351 | ylabel=ylabel, | |
347 | title=title) |
|
352 | title=title) | |
348 |
|
353 | |||
349 | def pcolor(self, x, y, z, |
|
354 | def pcolor(self, x, y, z, | |
350 | xmin=None, xmax=None, |
|
355 | xmin=None, xmax=None, | |
351 | ymin=None, ymax=None, |
|
356 | ymin=None, ymax=None, | |
352 | zmin=None, zmax=None, |
|
357 | zmin=None, zmax=None, | |
353 | xlabel='', ylabel='', |
|
358 | xlabel='', ylabel='', | |
354 | title='', rti = False, colormap='jet', |
|
359 | title='', rti = False, colormap='jet', | |
355 | **kwargs): |
|
360 | **kwargs): | |
356 |
|
361 | |||
357 | """ |
|
362 | """ | |
358 | Input: |
|
363 | Input: | |
359 | x : |
|
364 | x : | |
360 | y : |
|
365 | y : | |
361 | x : |
|
366 | x : | |
362 | xmin : |
|
367 | xmin : | |
363 | xmax : |
|
368 | xmax : | |
364 | ymin : |
|
369 | ymin : | |
365 | ymax : |
|
370 | ymax : | |
366 | zmin : |
|
371 | zmin : | |
367 | zmax : |
|
372 | zmax : | |
368 | xlabel : |
|
373 | xlabel : | |
369 | ylabel : |
|
374 | ylabel : | |
370 | title : |
|
375 | title : | |
371 | **kwargs : Los parametros aceptados son |
|
376 | **kwargs : Los parametros aceptados son | |
372 | ticksize=9, |
|
377 | ticksize=9, | |
373 | cblabel='' |
|
378 | cblabel='' | |
374 | rti = True or False |
|
379 | rti = True or False | |
375 | """ |
|
380 | """ | |
376 |
|
381 | |||
377 | if self.__firsttime: |
|
382 | if self.__firsttime: | |
378 |
|
383 | |||
379 | if xmin == None: xmin = numpy.nanmin(x) |
|
384 | if xmin == None: xmin = numpy.nanmin(x) | |
380 | if xmax == None: xmax = numpy.nanmax(x) |
|
385 | if xmax == None: xmax = numpy.nanmax(x) | |
381 | if ymin == None: ymin = numpy.nanmin(y) |
|
386 | if ymin == None: ymin = numpy.nanmin(y) | |
382 | if ymax == None: ymax = numpy.nanmax(y) |
|
387 | if ymax == None: ymax = numpy.nanmax(y) | |
383 | if zmin == None: zmin = numpy.nanmin(z) |
|
388 | if zmin == None: zmin = numpy.nanmin(z) | |
384 | if zmax == None: zmax = numpy.nanmax(z) |
|
389 | if zmax == None: zmax = numpy.nanmax(z) | |
385 |
|
390 | |||
386 |
|
391 | |||
387 | self.plot = self.__driver.createPcolor(self.ax, x, y, z, |
|
392 | self.plot = self.__driver.createPcolor(self.ax, x, y, z, | |
388 | xmin, xmax, |
|
393 | xmin, xmax, | |
389 | ymin, ymax, |
|
394 | ymin, ymax, | |
390 | zmin, zmax, |
|
395 | zmin, zmax, | |
391 | xlabel=xlabel, |
|
396 | xlabel=xlabel, | |
392 | ylabel=ylabel, |
|
397 | ylabel=ylabel, | |
393 | title=title, |
|
398 | title=title, | |
394 | colormap=colormap, |
|
399 | colormap=colormap, | |
395 | **kwargs) |
|
400 | **kwargs) | |
396 |
|
401 | |||
397 | if self.xmin == None: self.xmin = xmin |
|
402 | if self.xmin == None: self.xmin = xmin | |
398 | if self.xmax == None: self.xmax = xmax |
|
403 | if self.xmax == None: self.xmax = xmax | |
399 | if self.ymin == None: self.ymin = ymin |
|
404 | if self.ymin == None: self.ymin = ymin | |
400 | if self.ymax == None: self.ymax = ymax |
|
405 | if self.ymax == None: self.ymax = ymax | |
401 | if self.zmin == None: self.zmin = zmin |
|
406 | if self.zmin == None: self.zmin = zmin | |
402 | if self.zmax == None: self.zmax = zmax |
|
407 | if self.zmax == None: self.zmax = zmax | |
403 |
|
408 | |||
404 | self.__firsttime = False |
|
409 | self.__firsttime = False | |
405 | return |
|
410 | return | |
406 |
|
411 | |||
407 | if rti: |
|
412 | if rti: | |
408 | self.__driver.addpcolor(self.ax, x, y, z, self.zmin, self.zmax, |
|
413 | self.__driver.addpcolor(self.ax, x, y, z, self.zmin, self.zmax, | |
409 | xlabel=xlabel, |
|
414 | xlabel=xlabel, | |
410 | ylabel=ylabel, |
|
415 | ylabel=ylabel, | |
411 | title=title, |
|
416 | title=title, | |
412 | colormap=colormap) |
|
417 | colormap=colormap) | |
413 | return |
|
418 | return | |
414 |
|
419 | |||
415 | self.__driver.pcolor(self.plot, z, |
|
420 | self.__driver.pcolor(self.plot, z, | |
416 | xlabel=xlabel, |
|
421 | xlabel=xlabel, | |
417 | ylabel=ylabel, |
|
422 | ylabel=ylabel, | |
418 | title=title) |
|
423 | title=title) | |
419 |
|
424 | |||
420 | def pcolorbuffer(self, x, y, z, |
|
425 | def pcolorbuffer(self, x, y, z, | |
421 | xmin=None, xmax=None, |
|
426 | xmin=None, xmax=None, | |
422 | ymin=None, ymax=None, |
|
427 | ymin=None, ymax=None, | |
423 | zmin=None, zmax=None, |
|
428 | zmin=None, zmax=None, | |
424 | xlabel='', ylabel='', |
|
429 | xlabel='', ylabel='', | |
425 | title='', rti = False, colormap='jet', |
|
430 | title='', rti = False, colormap='jet', | |
426 | **kwargs): |
|
431 | **kwargs): | |
427 |
|
432 | |||
428 |
|
433 | |||
429 | if self.__firsttime: |
|
434 | if self.__firsttime: | |
430 | self.z_buffer = z |
|
435 | self.z_buffer = z | |
431 | self.x_buffer = numpy.hstack((self.x_buffer, x)) |
|
436 | self.x_buffer = numpy.hstack((self.x_buffer, x)) | |
432 |
|
437 | |||
433 | if xmin == None: xmin = numpy.nanmin(x) |
|
438 | if xmin == None: xmin = numpy.nanmin(x) | |
434 | if xmax == None: xmax = numpy.nanmax(x) |
|
439 | if xmax == None: xmax = numpy.nanmax(x) | |
435 | if ymin == None: ymin = numpy.nanmin(y) |
|
440 | if ymin == None: ymin = numpy.nanmin(y) | |
436 | if ymax == None: ymax = numpy.nanmax(y) |
|
441 | if ymax == None: ymax = numpy.nanmax(y) | |
437 | if zmin == None: zmin = numpy.nanmin(z) |
|
442 | if zmin == None: zmin = numpy.nanmin(z) | |
438 | if zmax == None: zmax = numpy.nanmax(z) |
|
443 | if zmax == None: zmax = numpy.nanmax(z) | |
439 |
|
444 | |||
440 |
|
445 | |||
441 | self.plot = self.__driver.createPcolor(self.ax, self.x_buffer, y, z, |
|
446 | self.plot = self.__driver.createPcolor(self.ax, self.x_buffer, y, z, | |
442 | xmin, xmax, |
|
447 | xmin, xmax, | |
443 | ymin, ymax, |
|
448 | ymin, ymax, | |
444 | zmin, zmax, |
|
449 | zmin, zmax, | |
445 | xlabel=xlabel, |
|
450 | xlabel=xlabel, | |
446 | ylabel=ylabel, |
|
451 | ylabel=ylabel, | |
447 | title=title, |
|
452 | title=title, | |
448 | colormap=colormap, |
|
453 | colormap=colormap, | |
449 | **kwargs) |
|
454 | **kwargs) | |
450 |
|
455 | |||
451 | if self.xmin == None: self.xmin = xmin |
|
456 | if self.xmin == None: self.xmin = xmin | |
452 | if self.xmax == None: self.xmax = xmax |
|
457 | if self.xmax == None: self.xmax = xmax | |
453 | if self.ymin == None: self.ymin = ymin |
|
458 | if self.ymin == None: self.ymin = ymin | |
454 | if self.ymax == None: self.ymax = ymax |
|
459 | if self.ymax == None: self.ymax = ymax | |
455 | if self.zmin == None: self.zmin = zmin |
|
460 | if self.zmin == None: self.zmin = zmin | |
456 | if self.zmax == None: self.zmax = zmax |
|
461 | if self.zmax == None: self.zmax = zmax | |
457 |
|
462 | |||
458 | self.__firsttime = False |
|
463 | self.__firsttime = False | |
459 | return |
|
464 | return | |
460 |
|
465 | |||
461 | if rti: |
|
466 | if rti: | |
462 | if x[0]>self.x_buffer[-1]: |
|
467 | if x[0]>self.x_buffer[-1]: | |
463 | gap = z.copy() |
|
468 | gap = z.copy() | |
464 | gap[:] = self.__missing |
|
469 | gap[:] = self.__missing | |
465 | self.z_buffer = numpy.hstack((self.z_buffer, gap)) |
|
470 | self.z_buffer = numpy.hstack((self.z_buffer, gap)) | |
466 | self.z_buffer = numpy.ma.masked_inside(self.z_buffer,0.99*self.__missing,1.01*self.__missing) |
|
471 | self.z_buffer = numpy.ma.masked_inside(self.z_buffer,0.99*self.__missing,1.01*self.__missing) | |
467 | self.x_buffer = numpy.hstack((self.x_buffer, x)) |
|
472 | self.x_buffer = numpy.hstack((self.x_buffer, x)) | |
468 |
|
473 | |||
469 | else: |
|
474 | else: | |
470 | self.x_buffer = numpy.hstack((self.x_buffer, x[-1])) |
|
475 | self.x_buffer = numpy.hstack((self.x_buffer, x[-1])) | |
471 |
|
476 | |||
472 | self.z_buffer = numpy.hstack((self.z_buffer, z)) |
|
477 | self.z_buffer = numpy.hstack((self.z_buffer, z)) | |
473 |
|
478 | |||
474 | newydim = len(y) |
|
479 | newydim = len(y) | |
475 |
|
480 | |||
476 | # self.z_buffer = numpy.ma.masked_inside(self.z_buffer,0.99*self.__missing,1.01*self.__missing) |
|
481 | # self.z_buffer = numpy.ma.masked_inside(self.z_buffer,0.99*self.__missing,1.01*self.__missing) | |
477 |
|
482 | |||
478 | z_buffer = self.z_buffer.reshape(-1,newydim) |
|
483 | z_buffer = self.z_buffer.reshape(-1,newydim) | |
479 |
|
484 | |||
480 | self.__driver.addpcolorbuffer(self.ax, self.x_buffer, y, z_buffer, self.zmin, self.zmax, |
|
485 | self.__driver.addpcolorbuffer(self.ax, self.x_buffer, y, z_buffer, self.zmin, self.zmax, | |
481 | xlabel=xlabel, |
|
486 | xlabel=xlabel, | |
482 | ylabel=ylabel, |
|
487 | ylabel=ylabel, | |
483 | title=title, |
|
488 | title=title, | |
484 | colormap=colormap) |
|
489 | colormap=colormap) | |
485 | return |
|
490 | return | |
486 |
|
491 | |||
487 | self.__driver.pcolor(self.plot, z, |
|
492 | self.__driver.pcolor(self.plot, z, | |
488 | xlabel=xlabel, |
|
493 | xlabel=xlabel, | |
489 | ylabel=ylabel, |
|
494 | ylabel=ylabel, | |
490 | title=title) |
|
495 | title=title) | |
491 | No newline at end of file |
|
496 |
General Comments 0
You need to be logged in to leave comments.
Login now