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