@@ -1,414 +1,491 | |||||
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 | os.mkdir(fullpath) |
|
160 | os.mkdir(fullpath) | |
161 |
|
161 | |||
162 | self.__driver.saveFigure(self.fig, filename, *args) |
|
162 | self.__driver.saveFigure(self.fig, filename, *args) | |
163 |
|
163 | |||
164 | def sendByFTP(self, figfilename): |
|
164 | def sendByFTP(self, figfilename): | |
165 | ftpObj = Ftp() |
|
165 | ftpObj = Ftp() | |
166 | ftpObj.upload(figfilename) |
|
166 | ftpObj.upload(figfilename) | |
167 | ftpObj.close() |
|
167 | ftpObj.close() | |
168 |
|
168 | |||
169 | def draw(self): |
|
169 | def draw(self): | |
170 |
|
170 | |||
171 | self.__driver.draw(self.fig) |
|
171 | self.__driver.draw(self.fig) | |
172 |
|
172 | |||
173 | def run(self): |
|
173 | def run(self): | |
174 |
|
174 | |||
175 | raise ValueError, "This method is not implemented" |
|
175 | raise ValueError, "This method is not implemented" | |
176 |
|
176 | |||
177 | axesList = property(getAxesObjList) |
|
177 | axesList = property(getAxesObjList) | |
178 |
|
178 | |||
179 |
|
179 | |||
180 | class Axes: |
|
180 | class Axes: | |
181 |
|
181 | |||
182 | __driver = mpldriver |
|
182 | __driver = mpldriver | |
183 | fig = None |
|
183 | fig = None | |
184 | ax = None |
|
184 | ax = None | |
185 | plot = None |
|
185 | plot = None | |
186 |
|
186 | __missing = 1E30 | ||
187 | __firsttime = None |
|
187 | __firsttime = None | |
188 |
|
188 | |||
189 | __showprofile = False |
|
189 | __showprofile = False | |
190 |
|
190 | |||
191 | xmin = None |
|
191 | xmin = None | |
192 | xmax = None |
|
192 | xmax = None | |
193 | ymin = None |
|
193 | ymin = None | |
194 | ymax = None |
|
194 | ymax = None | |
195 | zmin = None |
|
195 | zmin = None | |
196 | zmax = None |
|
196 | zmax = None | |
197 |
|
197 | |||
|
198 | x_buffer = None | |||
|
199 | z_buffer = None | |||
|
200 | ||||
198 | def __init__(self, *args): |
|
201 | def __init__(self, *args): | |
199 |
|
202 | |||
200 | """ |
|
203 | """ | |
201 |
|
204 | |||
202 | Input: |
|
205 | Input: | |
203 | *args : Los parametros necesarios son |
|
206 | *args : Los parametros necesarios son | |
204 | fig, nrow, ncol, xpos, ypos, colspan, rowspan |
|
207 | fig, nrow, ncol, xpos, ypos, colspan, rowspan | |
205 | """ |
|
208 | """ | |
206 |
|
209 | |||
207 | ax = self.__driver.createAxes(*args) |
|
210 | ax = self.__driver.createAxes(*args) | |
208 | self.fig = args[0] |
|
211 | self.fig = args[0] | |
209 | self.ax = ax |
|
212 | self.ax = ax | |
210 | self.plot = None |
|
213 | self.plot = None | |
211 |
|
214 | |||
212 | self.__firsttime = True |
|
215 | self.__firsttime = True | |
213 | self.idlineList = [] |
|
216 | self.idlineList = [] | |
214 |
|
217 | |||
|
218 | self.x_buffer = numpy.array([]) | |||
|
219 | self.z_buffer = numpy.array([]) | |||
|
220 | ||||
215 | def setText(self, text): |
|
221 | def setText(self, text): | |
216 |
|
222 | |||
217 | self.__driver.setAxesText(self.ax, text) |
|
223 | self.__driver.setAxesText(self.ax, text) | |
218 |
|
224 | |||
219 | def setXAxisAsTime(self): |
|
225 | def setXAxisAsTime(self): | |
220 | pass |
|
226 | pass | |
221 |
|
227 | |||
222 | def pline(self, x, y, |
|
228 | def pline(self, x, y, | |
223 | xmin=None, xmax=None, |
|
229 | xmin=None, xmax=None, | |
224 | ymin=None, ymax=None, |
|
230 | ymin=None, ymax=None, | |
225 | xlabel='', ylabel='', |
|
231 | xlabel='', ylabel='', | |
226 | title='', |
|
232 | title='', | |
227 | **kwargs): |
|
233 | **kwargs): | |
228 |
|
234 | |||
229 | """ |
|
235 | """ | |
230 |
|
236 | |||
231 | Input: |
|
237 | Input: | |
232 | x : |
|
238 | x : | |
233 | y : |
|
239 | y : | |
234 | xmin : |
|
240 | xmin : | |
235 | xmax : |
|
241 | xmax : | |
236 | ymin : |
|
242 | ymin : | |
237 | ymax : |
|
243 | ymax : | |
238 | xlabel : |
|
244 | xlabel : | |
239 | ylabel : |
|
245 | ylabel : | |
240 | title : |
|
246 | title : | |
241 | **kwargs : Los parametros aceptados son |
|
247 | **kwargs : Los parametros aceptados son | |
242 |
|
248 | |||
243 | ticksize |
|
249 | ticksize | |
244 | ytick_visible |
|
250 | ytick_visible | |
245 | """ |
|
251 | """ | |
246 |
|
252 | |||
247 | if self.__firsttime: |
|
253 | if self.__firsttime: | |
248 |
|
254 | |||
249 | if xmin == None: xmin = numpy.nanmin(x) |
|
255 | if xmin == None: xmin = numpy.nanmin(x) | |
250 | if xmax == None: xmax = numpy.nanmax(x) |
|
256 | if xmax == None: xmax = numpy.nanmax(x) | |
251 | if ymin == None: ymin = numpy.nanmin(y) |
|
257 | if ymin == None: ymin = numpy.nanmin(y) | |
252 | if ymax == None: ymax = numpy.nanmax(y) |
|
258 | if ymax == None: ymax = numpy.nanmax(y) | |
253 |
|
259 | |||
254 | self.plot = self.__driver.createPline(self.ax, x, y, |
|
260 | self.plot = self.__driver.createPline(self.ax, x, y, | |
255 | xmin, xmax, |
|
261 | xmin, xmax, | |
256 | ymin, ymax, |
|
262 | ymin, ymax, | |
257 | xlabel=xlabel, |
|
263 | xlabel=xlabel, | |
258 | ylabel=ylabel, |
|
264 | ylabel=ylabel, | |
259 | title=title, |
|
265 | title=title, | |
260 | **kwargs) |
|
266 | **kwargs) | |
261 |
|
267 | |||
262 | self.idlineList.append(0) |
|
268 | self.idlineList.append(0) | |
263 | self.__firsttime = False |
|
269 | self.__firsttime = False | |
264 | return |
|
270 | return | |
265 |
|
271 | |||
266 | self.__driver.pline(self.plot, x, y, xlabel=xlabel, |
|
272 | self.__driver.pline(self.plot, x, y, xlabel=xlabel, | |
267 | ylabel=ylabel, |
|
273 | ylabel=ylabel, | |
268 | title=title) |
|
274 | title=title) | |
269 |
|
275 | |||
270 | def addpline(self, x, y, idline, **kwargs): |
|
276 | def addpline(self, x, y, idline, **kwargs): | |
271 | lines = self.ax.lines |
|
277 | lines = self.ax.lines | |
272 |
|
278 | |||
273 | if idline in self.idlineList: |
|
279 | if idline in self.idlineList: | |
274 | self.__driver.set_linedata(self.ax, x, y, idline) |
|
280 | self.__driver.set_linedata(self.ax, x, y, idline) | |
275 |
|
281 | |||
276 | if idline not in(self.idlineList): |
|
282 | if idline not in(self.idlineList): | |
277 | self.__driver.addpline(self.ax, x, y, **kwargs) |
|
283 | self.__driver.addpline(self.ax, x, y, **kwargs) | |
278 | self.idlineList.append(idline) |
|
284 | self.idlineList.append(idline) | |
279 |
|
285 | |||
280 | return |
|
286 | return | |
281 |
|
287 | |||
282 | def pmultiline(self, x, y, |
|
288 | def pmultiline(self, x, y, | |
283 | xmin=None, xmax=None, |
|
289 | xmin=None, xmax=None, | |
284 | ymin=None, ymax=None, |
|
290 | ymin=None, ymax=None, | |
285 | xlabel='', ylabel='', |
|
291 | xlabel='', ylabel='', | |
286 | title='', |
|
292 | title='', | |
287 | **kwargs): |
|
293 | **kwargs): | |
288 |
|
294 | |||
289 | if self.__firsttime: |
|
295 | if self.__firsttime: | |
290 |
|
296 | |||
291 | if xmin == None: xmin = numpy.nanmin(x) |
|
297 | if xmin == None: xmin = numpy.nanmin(x) | |
292 | if xmax == None: xmax = numpy.nanmax(x) |
|
298 | if xmax == None: xmax = numpy.nanmax(x) | |
293 | if ymin == None: ymin = numpy.nanmin(y) |
|
299 | if ymin == None: ymin = numpy.nanmin(y) | |
294 | if ymax == None: ymax = numpy.nanmax(y) |
|
300 | if ymax == None: ymax = numpy.nanmax(y) | |
295 |
|
301 | |||
296 | self.plot = self.__driver.createPmultiline(self.ax, x, y, |
|
302 | self.plot = self.__driver.createPmultiline(self.ax, x, y, | |
297 | xmin, xmax, |
|
303 | xmin, xmax, | |
298 | ymin, ymax, |
|
304 | ymin, ymax, | |
299 | xlabel=xlabel, |
|
305 | xlabel=xlabel, | |
300 | ylabel=ylabel, |
|
306 | ylabel=ylabel, | |
301 | title=title, |
|
307 | title=title, | |
302 | **kwargs) |
|
308 | **kwargs) | |
303 | self.__firsttime = False |
|
309 | self.__firsttime = False | |
304 | return |
|
310 | return | |
305 |
|
311 | |||
306 | self.__driver.pmultiline(self.plot, x, y, xlabel=xlabel, |
|
312 | self.__driver.pmultiline(self.plot, x, y, xlabel=xlabel, | |
307 | ylabel=ylabel, |
|
313 | ylabel=ylabel, | |
308 | title=title) |
|
314 | title=title) | |
309 |
|
315 | |||
310 | def pmultilineyaxis(self, x, y, |
|
316 | def pmultilineyaxis(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.createPmultilineYAxis(self.ax, x, y, |
|
330 | self.plot = self.__driver.createPmultilineYAxis(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 | if self.xmin == None: self.xmin = xmin |
|
337 | if self.xmin == None: self.xmin = xmin | |
332 | if self.xmax == None: self.xmax = xmax |
|
338 | if self.xmax == None: self.xmax = xmax | |
333 | if self.ymin == None: self.ymin = ymin |
|
339 | if self.ymin == None: self.ymin = ymin | |
334 | if self.ymax == None: self.ymax = ymax |
|
340 | if self.ymax == None: self.ymax = ymax | |
335 |
|
341 | |||
336 | self.__firsttime = False |
|
342 | self.__firsttime = False | |
337 | return |
|
343 | return | |
338 |
|
344 | |||
339 | self.__driver.pmultilineyaxis(self.plot, x, y, xlabel=xlabel, |
|
345 | self.__driver.pmultilineyaxis(self.plot, x, y, xlabel=xlabel, | |
340 | ylabel=ylabel, |
|
346 | ylabel=ylabel, | |
341 | title=title) |
|
347 | title=title) | |
342 |
|
348 | |||
343 | def pcolor(self, x, y, z, |
|
349 | def pcolor(self, x, y, z, | |
344 | xmin=None, xmax=None, |
|
350 | xmin=None, xmax=None, | |
345 | ymin=None, ymax=None, |
|
351 | ymin=None, ymax=None, | |
346 | zmin=None, zmax=None, |
|
352 | zmin=None, zmax=None, | |
347 | xlabel='', ylabel='', |
|
353 | xlabel='', ylabel='', | |
348 | title='', rti = False, colormap='jet', |
|
354 | title='', rti = False, colormap='jet', | |
349 | **kwargs): |
|
355 | **kwargs): | |
350 |
|
356 | |||
351 | """ |
|
357 | """ | |
352 | Input: |
|
358 | Input: | |
353 | x : |
|
359 | x : | |
354 | y : |
|
360 | y : | |
355 | x : |
|
361 | x : | |
356 | xmin : |
|
362 | xmin : | |
357 | xmax : |
|
363 | xmax : | |
358 | ymin : |
|
364 | ymin : | |
359 | ymax : |
|
365 | ymax : | |
360 | zmin : |
|
366 | zmin : | |
361 | zmax : |
|
367 | zmax : | |
362 | xlabel : |
|
368 | xlabel : | |
363 | ylabel : |
|
369 | ylabel : | |
364 | title : |
|
370 | title : | |
365 | **kwargs : Los parametros aceptados son |
|
371 | **kwargs : Los parametros aceptados son | |
366 | ticksize=9, |
|
372 | ticksize=9, | |
367 | cblabel='' |
|
373 | cblabel='' | |
368 | rti = True or False |
|
374 | rti = True or False | |
369 | """ |
|
375 | """ | |
370 |
|
376 | |||
371 | if self.__firsttime: |
|
377 | if self.__firsttime: | |
372 |
|
378 | |||
373 | if xmin == None: xmin = numpy.nanmin(x) |
|
379 | if xmin == None: xmin = numpy.nanmin(x) | |
374 | if xmax == None: xmax = numpy.nanmax(x) |
|
380 | if xmax == None: xmax = numpy.nanmax(x) | |
375 | if ymin == None: ymin = numpy.nanmin(y) |
|
381 | if ymin == None: ymin = numpy.nanmin(y) | |
376 | if ymax == None: ymax = numpy.nanmax(y) |
|
382 | if ymax == None: ymax = numpy.nanmax(y) | |
377 | if zmin == None: zmin = numpy.nanmin(z) |
|
383 | if zmin == None: zmin = numpy.nanmin(z) | |
378 | if zmax == None: zmax = numpy.nanmax(z) |
|
384 | if zmax == None: zmax = numpy.nanmax(z) | |
379 |
|
385 | |||
380 |
|
386 | |||
381 | self.plot = self.__driver.createPcolor(self.ax, x, y, z, |
|
387 | self.plot = self.__driver.createPcolor(self.ax, x, y, z, | |
382 | xmin, xmax, |
|
388 | xmin, xmax, | |
383 | ymin, ymax, |
|
389 | ymin, ymax, | |
384 | zmin, zmax, |
|
390 | zmin, zmax, | |
385 | xlabel=xlabel, |
|
391 | xlabel=xlabel, | |
386 | ylabel=ylabel, |
|
392 | ylabel=ylabel, | |
387 | title=title, |
|
393 | title=title, | |
388 | colormap=colormap, |
|
394 | colormap=colormap, | |
389 | **kwargs) |
|
395 | **kwargs) | |
390 |
|
396 | |||
391 | if self.xmin == None: self.xmin = xmin |
|
397 | if self.xmin == None: self.xmin = xmin | |
392 | if self.xmax == None: self.xmax = xmax |
|
398 | if self.xmax == None: self.xmax = xmax | |
393 | if self.ymin == None: self.ymin = ymin |
|
399 | if self.ymin == None: self.ymin = ymin | |
394 | if self.ymax == None: self.ymax = ymax |
|
400 | if self.ymax == None: self.ymax = ymax | |
395 | if self.zmin == None: self.zmin = zmin |
|
401 | if self.zmin == None: self.zmin = zmin | |
396 | if self.zmax == None: self.zmax = zmax |
|
402 | if self.zmax == None: self.zmax = zmax | |
397 |
|
403 | |||
398 | self.__firsttime = False |
|
404 | self.__firsttime = False | |
399 | return |
|
405 | return | |
400 |
|
406 | |||
401 | if rti: |
|
407 | if rti: | |
402 | self.__driver.addpcolor(self.ax, x, y, z, self.zmin, self.zmax, |
|
408 | self.__driver.addpcolor(self.ax, x, y, z, self.zmin, self.zmax, | |
403 | xlabel=xlabel, |
|
409 | xlabel=xlabel, | |
404 | ylabel=ylabel, |
|
410 | ylabel=ylabel, | |
405 | title=title, |
|
411 | title=title, | |
406 | colormap=colormap) |
|
412 | colormap=colormap) | |
407 | return |
|
413 | return | |
408 |
|
414 | |||
409 | self.__driver.pcolor(self.plot, z, |
|
415 | self.__driver.pcolor(self.plot, z, | |
410 | xlabel=xlabel, |
|
416 | xlabel=xlabel, | |
411 | ylabel=ylabel, |
|
417 | ylabel=ylabel, | |
412 | title=title) |
|
418 | title=title) | |
|
419 | ||||
|
420 | def pcolorbuffer(self, x, y, z, | |||
|
421 | xmin=None, xmax=None, | |||
|
422 | ymin=None, ymax=None, | |||
|
423 | zmin=None, zmax=None, | |||
|
424 | xlabel='', ylabel='', | |||
|
425 | title='', rti = False, colormap='jet', | |||
|
426 | **kwargs): | |||
|
427 | ||||
413 |
|
428 | |||
|
429 | if self.__firsttime: | |||
|
430 | self.z_buffer = z | |||
|
431 | self.x_buffer = numpy.hstack((self.x_buffer, x)) | |||
|
432 | ||||
|
433 | if xmin == None: xmin = numpy.nanmin(x) | |||
|
434 | if xmax == None: xmax = numpy.nanmax(x) | |||
|
435 | if ymin == None: ymin = numpy.nanmin(y) | |||
|
436 | if ymax == None: ymax = numpy.nanmax(y) | |||
|
437 | if zmin == None: zmin = numpy.nanmin(z) | |||
|
438 | if zmax == None: zmax = numpy.nanmax(z) | |||
|
439 | ||||
|
440 | ||||
|
441 | self.plot = self.__driver.createPcolor(self.ax, self.x_buffer, y, z, | |||
|
442 | xmin, xmax, | |||
|
443 | ymin, ymax, | |||
|
444 | zmin, zmax, | |||
|
445 | xlabel=xlabel, | |||
|
446 | ylabel=ylabel, | |||
|
447 | title=title, | |||
|
448 | colormap=colormap, | |||
|
449 | **kwargs) | |||
|
450 | ||||
|
451 | if self.xmin == None: self.xmin = xmin | |||
|
452 | if self.xmax == None: self.xmax = xmax | |||
|
453 | if self.ymin == None: self.ymin = ymin | |||
|
454 | if self.ymax == None: self.ymax = ymax | |||
|
455 | if self.zmin == None: self.zmin = zmin | |||
|
456 | if self.zmax == None: self.zmax = zmax | |||
|
457 | ||||
|
458 | self.__firsttime = False | |||
|
459 | return | |||
|
460 | ||||
|
461 | if rti: | |||
|
462 | if x[0]>self.x_buffer[-1]: | |||
|
463 | gap = z.copy() | |||
|
464 | gap[:] = self.__missing | |||
|
465 | 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) | |||
|
467 | self.x_buffer = numpy.hstack((self.x_buffer, x)) | |||
|
468 | ||||
|
469 | else: | |||
|
470 | self.x_buffer = numpy.hstack((self.x_buffer, x[-1])) | |||
|
471 | ||||
|
472 | self.z_buffer = numpy.hstack((self.z_buffer, z)) | |||
|
473 | ||||
|
474 | newydim = len(y) | |||
|
475 | ||||
|
476 | # self.z_buffer = numpy.ma.masked_inside(self.z_buffer,0.99*self.__missing,1.01*self.__missing) | |||
|
477 | ||||
|
478 | z_buffer = self.z_buffer.reshape(-1,newydim) | |||
|
479 | ||||
|
480 | self.__driver.addpcolorbuffer(self.ax, self.x_buffer, y, z_buffer, self.zmin, self.zmax, | |||
|
481 | xlabel=xlabel, | |||
|
482 | ylabel=ylabel, | |||
|
483 | title=title, | |||
|
484 | colormap=colormap) | |||
|
485 | return | |||
|
486 | ||||
|
487 | self.__driver.pcolor(self.plot, z, | |||
|
488 | xlabel=xlabel, | |||
|
489 | ylabel=ylabel, | |||
|
490 | title=title) | |||
414 | No newline at end of file |
|
491 |
@@ -1,373 +1,379 | |||||
1 | import numpy |
|
1 | import numpy | |
2 | import datetime |
|
2 | import datetime | |
3 | import sys |
|
3 | import sys | |
4 | import matplotlib |
|
4 | import matplotlib | |
5 |
|
5 | |||
6 | if 'linux' in sys.platform: |
|
6 | if 'linux' in sys.platform: | |
7 | matplotlib.use("TKAgg") |
|
7 | matplotlib.use("TKAgg") | |
8 |
|
8 | |||
9 | if 'darwin' in sys.platform: |
|
9 | if 'darwin' in sys.platform: | |
10 | matplotlib.use("TKAgg") |
|
10 | matplotlib.use("TKAgg") | |
11 |
|
11 | |||
12 | import matplotlib.pyplot |
|
12 | import matplotlib.pyplot | |
13 |
|
13 | |||
14 | from mpl_toolkits.axes_grid1 import make_axes_locatable |
|
14 | from mpl_toolkits.axes_grid1 import make_axes_locatable | |
15 | from matplotlib.ticker import * |
|
15 | from matplotlib.ticker import * | |
16 |
|
16 | |||
17 | ########################################### |
|
17 | ########################################### | |
18 | #Actualizacion de las funciones del driver |
|
18 | #Actualizacion de las funciones del driver | |
19 | ########################################### |
|
19 | ########################################### | |
20 |
|
20 | |||
21 | def createFigure(idfigure, wintitle, width, height, facecolor="w"): |
|
21 | def createFigure(idfigure, wintitle, width, height, facecolor="w"): | |
22 |
|
22 | |||
23 | matplotlib.pyplot.ioff() |
|
23 | matplotlib.pyplot.ioff() | |
24 | fig = matplotlib.pyplot.figure(num=idfigure, facecolor=facecolor) |
|
24 | fig = matplotlib.pyplot.figure(num=idfigure, facecolor=facecolor) | |
25 | fig.canvas.manager.set_window_title(wintitle) |
|
25 | fig.canvas.manager.set_window_title(wintitle) | |
26 | fig.canvas.manager.resize(width, height) |
|
26 | fig.canvas.manager.resize(width, height) | |
27 | matplotlib.pyplot.ion() |
|
27 | matplotlib.pyplot.ion() | |
28 | matplotlib.pyplot.show() |
|
28 | matplotlib.pyplot.show() | |
29 |
|
29 | |||
30 | return fig |
|
30 | return fig | |
31 |
|
31 | |||
32 | def closeFigure(): |
|
32 | def closeFigure(): | |
33 |
|
33 | |||
34 | matplotlib.pyplot.ioff() |
|
34 | matplotlib.pyplot.ioff() | |
35 | matplotlib.pyplot.show() |
|
35 | matplotlib.pyplot.show() | |
36 |
|
36 | |||
37 | return |
|
37 | return | |
38 |
|
38 | |||
39 | def saveFigure(fig, filename): |
|
39 | def saveFigure(fig, filename): | |
40 |
|
40 | |||
41 | matplotlib.pyplot.ioff() |
|
41 | matplotlib.pyplot.ioff() | |
42 | fig.savefig(filename) |
|
42 | fig.savefig(filename) | |
43 | matplotlib.pyplot.ion() |
|
43 | matplotlib.pyplot.ion() | |
44 |
|
44 | |||
45 | def setWinTitle(fig, title): |
|
45 | def setWinTitle(fig, title): | |
46 |
|
46 | |||
47 | fig.canvas.manager.set_window_title(title) |
|
47 | fig.canvas.manager.set_window_title(title) | |
48 |
|
48 | |||
49 | def setTitle(fig, title): |
|
49 | def setTitle(fig, title): | |
50 |
|
50 | |||
51 | fig.suptitle(title) |
|
51 | fig.suptitle(title) | |
52 |
|
52 | |||
53 | def createAxes(fig, nrow, ncol, xpos, ypos, colspan, rowspan): |
|
53 | def createAxes(fig, nrow, ncol, xpos, ypos, colspan, rowspan): | |
54 |
|
54 | |||
55 | matplotlib.pyplot.ioff() |
|
55 | matplotlib.pyplot.ioff() | |
56 | matplotlib.pyplot.figure(fig.number) |
|
56 | matplotlib.pyplot.figure(fig.number) | |
57 | axes = matplotlib.pyplot.subplot2grid((nrow, ncol), |
|
57 | axes = matplotlib.pyplot.subplot2grid((nrow, ncol), | |
58 | (xpos, ypos), |
|
58 | (xpos, ypos), | |
59 | colspan=colspan, |
|
59 | colspan=colspan, | |
60 | rowspan=rowspan) |
|
60 | rowspan=rowspan) | |
61 |
|
61 | |||
62 | matplotlib.pyplot.ion() |
|
62 | matplotlib.pyplot.ion() | |
63 | return axes |
|
63 | return axes | |
64 |
|
64 | |||
65 | def setAxesText(ax, text): |
|
65 | def setAxesText(ax, text): | |
66 |
|
66 | |||
67 | ax.annotate(text, |
|
67 | ax.annotate(text, | |
68 | xy = (.1, .99), |
|
68 | xy = (.1, .99), | |
69 | xycoords = 'figure fraction', |
|
69 | xycoords = 'figure fraction', | |
70 | horizontalalignment = 'left', |
|
70 | horizontalalignment = 'left', | |
71 | verticalalignment = 'top', |
|
71 | verticalalignment = 'top', | |
72 | fontsize = 10) |
|
72 | fontsize = 10) | |
73 |
|
73 | |||
74 | def printLabels(ax, xlabel, ylabel, title): |
|
74 | def printLabels(ax, xlabel, ylabel, title): | |
75 |
|
75 | |||
76 | ax.set_xlabel(xlabel, size=11) |
|
76 | ax.set_xlabel(xlabel, size=11) | |
77 | ax.set_ylabel(ylabel, size=11) |
|
77 | ax.set_ylabel(ylabel, size=11) | |
78 | ax.set_title(title, size=12) |
|
78 | ax.set_title(title, size=12) | |
79 |
|
79 | |||
80 | def createPline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='', |
|
80 | def createPline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='', | |
81 | ticksize=9, xtick_visible=True, ytick_visible=True, |
|
81 | ticksize=9, xtick_visible=True, ytick_visible=True, | |
82 | nxticks=4, nyticks=10, |
|
82 | nxticks=4, nyticks=10, | |
83 | grid=None): |
|
83 | grid=None): | |
84 |
|
84 | |||
85 | """ |
|
85 | """ | |
86 |
|
86 | |||
87 | Input: |
|
87 | Input: | |
88 | grid : None, 'both', 'x', 'y' |
|
88 | grid : None, 'both', 'x', 'y' | |
89 | """ |
|
89 | """ | |
90 |
|
90 | |||
91 | matplotlib.pyplot.ioff() |
|
91 | matplotlib.pyplot.ioff() | |
92 |
|
92 | |||
93 | ax.set_xlim([xmin,xmax]) |
|
93 | ax.set_xlim([xmin,xmax]) | |
94 | ax.set_ylim([ymin,ymax]) |
|
94 | ax.set_ylim([ymin,ymax]) | |
95 |
|
95 | |||
96 | printLabels(ax, xlabel, ylabel, title) |
|
96 | printLabels(ax, xlabel, ylabel, title) | |
97 |
|
97 | |||
98 | ###################################################### |
|
98 | ###################################################### | |
99 | if (xmax-xmin)<=1: |
|
99 | if (xmax-xmin)<=1: | |
100 | xtickspos = numpy.linspace(xmin,xmax,nxticks) |
|
100 | xtickspos = numpy.linspace(xmin,xmax,nxticks) | |
101 | xtickspos = numpy.array([float("%.1f"%i) for i in xtickspos]) |
|
101 | xtickspos = numpy.array([float("%.1f"%i) for i in xtickspos]) | |
102 | ax.set_xticks(xtickspos) |
|
102 | ax.set_xticks(xtickspos) | |
103 | else: |
|
103 | else: | |
104 | xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/(nxticks)) + int(xmin) |
|
104 | xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/(nxticks)) + int(xmin) | |
105 | ax.set_xticks(xtickspos) |
|
105 | ax.set_xticks(xtickspos) | |
106 |
|
106 | |||
107 | for tick in ax.get_xticklabels(): |
|
107 | for tick in ax.get_xticklabels(): | |
108 | tick.set_visible(xtick_visible) |
|
108 | tick.set_visible(xtick_visible) | |
109 |
|
109 | |||
110 | for tick in ax.xaxis.get_major_ticks(): |
|
110 | for tick in ax.xaxis.get_major_ticks(): | |
111 | tick.label.set_fontsize(ticksize) |
|
111 | tick.label.set_fontsize(ticksize) | |
112 |
|
112 | |||
113 | ###################################################### |
|
113 | ###################################################### | |
114 | for tick in ax.get_yticklabels(): |
|
114 | for tick in ax.get_yticklabels(): | |
115 | tick.set_visible(ytick_visible) |
|
115 | tick.set_visible(ytick_visible) | |
116 |
|
116 | |||
117 | for tick in ax.yaxis.get_major_ticks(): |
|
117 | for tick in ax.yaxis.get_major_ticks(): | |
118 | tick.label.set_fontsize(ticksize) |
|
118 | tick.label.set_fontsize(ticksize) | |
119 |
|
119 | |||
120 | ax.plot(x, y) |
|
120 | ax.plot(x, y) | |
121 | iplot = ax.lines[-1] |
|
121 | iplot = ax.lines[-1] | |
122 |
|
122 | |||
123 | ###################################################### |
|
123 | ###################################################### | |
124 | if '0.' in matplotlib.__version__[0:2]: |
|
124 | if '0.' in matplotlib.__version__[0:2]: | |
125 | print "The matplotlib version has to be updated to 1.1 or newer" |
|
125 | print "The matplotlib version has to be updated to 1.1 or newer" | |
126 | return iplot |
|
126 | return iplot | |
127 |
|
127 | |||
128 | if '1.0.' in matplotlib.__version__[0:4]: |
|
128 | if '1.0.' in matplotlib.__version__[0:4]: | |
129 | print "The matplotlib version has to be updated to 1.1 or newer" |
|
129 | print "The matplotlib version has to be updated to 1.1 or newer" | |
130 | return iplot |
|
130 | return iplot | |
131 |
|
131 | |||
132 | if grid != None: |
|
132 | if grid != None: | |
133 | ax.grid(b=True, which='major', axis=grid) |
|
133 | ax.grid(b=True, which='major', axis=grid) | |
134 |
|
134 | |||
135 | matplotlib.pyplot.tight_layout() |
|
135 | matplotlib.pyplot.tight_layout() | |
136 |
|
136 | |||
137 | matplotlib.pyplot.ion() |
|
137 | matplotlib.pyplot.ion() | |
138 |
|
138 | |||
139 | return iplot |
|
139 | return iplot | |
140 |
|
140 | |||
141 | def set_linedata(ax, x, y, idline): |
|
141 | def set_linedata(ax, x, y, idline): | |
142 |
|
142 | |||
143 | ax.lines[idline].set_data(x,y) |
|
143 | ax.lines[idline].set_data(x,y) | |
144 |
|
144 | |||
145 | def pline(iplot, x, y, xlabel='', ylabel='', title=''): |
|
145 | def pline(iplot, x, y, xlabel='', ylabel='', title=''): | |
146 |
|
146 | |||
147 | ax = iplot.get_axes() |
|
147 | ax = iplot.get_axes() | |
148 |
|
148 | |||
149 | printLabels(ax, xlabel, ylabel, title) |
|
149 | printLabels(ax, xlabel, ylabel, title) | |
150 |
|
150 | |||
151 | set_linedata(ax, x, y, idline=0) |
|
151 | set_linedata(ax, x, y, idline=0) | |
152 |
|
152 | |||
153 | def addpline(ax, x, y, color, linestyle, lw): |
|
153 | def addpline(ax, x, y, color, linestyle, lw): | |
154 |
|
154 | |||
155 | ax.plot(x,y,color=color,linestyle=linestyle,lw=lw) |
|
155 | ax.plot(x,y,color=color,linestyle=linestyle,lw=lw) | |
156 |
|
156 | |||
157 |
|
157 | |||
158 | def createPcolor(ax, x, y, z, xmin, xmax, ymin, ymax, zmin, zmax, |
|
158 | def createPcolor(ax, x, y, z, xmin, xmax, ymin, ymax, zmin, zmax, | |
159 | xlabel='', ylabel='', title='', ticksize = 9, |
|
159 | xlabel='', ylabel='', title='', ticksize = 9, | |
160 | colormap='jet',cblabel='', cbsize="5%", |
|
160 | colormap='jet',cblabel='', cbsize="5%", | |
161 | XAxisAsTime=False): |
|
161 | XAxisAsTime=False): | |
162 |
|
162 | |||
163 | matplotlib.pyplot.ioff() |
|
163 | matplotlib.pyplot.ioff() | |
164 |
|
164 | |||
165 | divider = make_axes_locatable(ax) |
|
165 | divider = make_axes_locatable(ax) | |
166 | ax_cb = divider.new_horizontal(size=cbsize, pad=0.05) |
|
166 | ax_cb = divider.new_horizontal(size=cbsize, pad=0.05) | |
167 | fig = ax.get_figure() |
|
167 | fig = ax.get_figure() | |
168 | fig.add_axes(ax_cb) |
|
168 | fig.add_axes(ax_cb) | |
169 |
|
169 | |||
170 | ax.set_xlim([xmin,xmax]) |
|
170 | ax.set_xlim([xmin,xmax]) | |
171 | ax.set_ylim([ymin,ymax]) |
|
171 | ax.set_ylim([ymin,ymax]) | |
172 |
|
172 | |||
173 | printLabels(ax, xlabel, ylabel, title) |
|
173 | printLabels(ax, xlabel, ylabel, title) | |
174 |
|
174 | |||
175 | imesh = ax.pcolormesh(x,y,z.T, vmin=zmin, vmax=zmax, cmap=matplotlib.pyplot.get_cmap(colormap)) |
|
175 | imesh = ax.pcolormesh(x,y,z.T, vmin=zmin, vmax=zmax, cmap=matplotlib.pyplot.get_cmap(colormap)) | |
176 | cb = matplotlib.pyplot.colorbar(imesh, cax=ax_cb) |
|
176 | cb = matplotlib.pyplot.colorbar(imesh, cax=ax_cb) | |
177 | cb.set_label(cblabel) |
|
177 | cb.set_label(cblabel) | |
178 |
|
178 | |||
179 | # for tl in ax_cb.get_yticklabels(): |
|
179 | # for tl in ax_cb.get_yticklabels(): | |
180 | # tl.set_visible(True) |
|
180 | # tl.set_visible(True) | |
181 |
|
181 | |||
182 | for tick in ax.yaxis.get_major_ticks(): |
|
182 | for tick in ax.yaxis.get_major_ticks(): | |
183 | tick.label.set_fontsize(ticksize) |
|
183 | tick.label.set_fontsize(ticksize) | |
184 |
|
184 | |||
185 | for tick in ax.xaxis.get_major_ticks(): |
|
185 | for tick in ax.xaxis.get_major_ticks(): | |
186 | tick.label.set_fontsize(ticksize) |
|
186 | tick.label.set_fontsize(ticksize) | |
187 |
|
187 | |||
188 | for tick in cb.ax.get_yticklabels(): |
|
188 | for tick in cb.ax.get_yticklabels(): | |
189 | tick.set_fontsize(ticksize) |
|
189 | tick.set_fontsize(ticksize) | |
190 |
|
190 | |||
191 | ax_cb.yaxis.tick_right() |
|
191 | ax_cb.yaxis.tick_right() | |
192 |
|
192 | |||
193 | if '0.' in matplotlib.__version__[0:2]: |
|
193 | if '0.' in matplotlib.__version__[0:2]: | |
194 | print "The matplotlib version has to be updated to 1.1 or newer" |
|
194 | print "The matplotlib version has to be updated to 1.1 or newer" | |
195 | return imesh |
|
195 | return imesh | |
196 |
|
196 | |||
197 | if '1.0.' in matplotlib.__version__[0:4]: |
|
197 | if '1.0.' in matplotlib.__version__[0:4]: | |
198 | print "The matplotlib version has to be updated to 1.1 or newer" |
|
198 | print "The matplotlib version has to be updated to 1.1 or newer" | |
199 | return imesh |
|
199 | return imesh | |
200 |
|
200 | |||
201 | matplotlib.pyplot.tight_layout() |
|
201 | matplotlib.pyplot.tight_layout() | |
202 |
|
202 | |||
203 | if XAxisAsTime: |
|
203 | if XAxisAsTime: | |
204 |
|
204 | |||
205 | func = lambda x, pos: ('%s') %(datetime.datetime.utcfromtimestamp(x).strftime("%H:%M:%S")) |
|
205 | func = lambda x, pos: ('%s') %(datetime.datetime.utcfromtimestamp(x).strftime("%H:%M:%S")) | |
206 | ax.xaxis.set_major_formatter(FuncFormatter(func)) |
|
206 | ax.xaxis.set_major_formatter(FuncFormatter(func)) | |
207 | ax.xaxis.set_major_locator(LinearLocator(7)) |
|
207 | ax.xaxis.set_major_locator(LinearLocator(7)) | |
208 |
|
208 | |||
209 | matplotlib.pyplot.ion() |
|
209 | matplotlib.pyplot.ion() | |
210 | return imesh |
|
210 | return imesh | |
211 |
|
211 | |||
212 | def pcolor(imesh, z, xlabel='', ylabel='', title=''): |
|
212 | def pcolor(imesh, z, xlabel='', ylabel='', title=''): | |
213 |
|
213 | |||
214 | z = z.T |
|
214 | z = z.T | |
215 |
|
215 | |||
216 | ax = imesh.get_axes() |
|
216 | ax = imesh.get_axes() | |
217 |
|
217 | |||
218 | printLabels(ax, xlabel, ylabel, title) |
|
218 | printLabels(ax, xlabel, ylabel, title) | |
219 |
|
219 | |||
220 | imesh.set_array(z.ravel()) |
|
220 | imesh.set_array(z.ravel()) | |
221 |
|
221 | |||
222 | def addpcolor(ax, x, y, z, zmin, zmax, xlabel='', ylabel='', title='', colormap='jet'): |
|
222 | def addpcolor(ax, x, y, z, zmin, zmax, xlabel='', ylabel='', title='', colormap='jet'): | |
223 |
|
223 | |||
224 | printLabels(ax, xlabel, ylabel, title) |
|
224 | printLabels(ax, xlabel, ylabel, title) | |
225 |
|
225 | |||
226 | # ax.collections.remove(ax.collections[0]) |
|
226 | ax.pcolormesh(x,y,z.T,vmin=zmin,vmax=zmax, cmap=matplotlib.pyplot.get_cmap(colormap)) | |
|
227 | ||||
|
228 | def addpcolorbuffer(ax, x, y, z, zmin, zmax, xlabel='', ylabel='', title='', colormap='jet'): | |||
|
229 | ||||
|
230 | printLabels(ax, xlabel, ylabel, title) | |||
|
231 | ||||
|
232 | ax.collections.remove(ax.collections[0]) | |||
227 |
|
233 | |||
228 | ax.pcolormesh(x,y,z.T,vmin=zmin,vmax=zmax, cmap=matplotlib.pyplot.get_cmap(colormap)) |
|
234 | ax.pcolormesh(x,y,z.T,vmin=zmin,vmax=zmax, cmap=matplotlib.pyplot.get_cmap(colormap)) | |
229 |
|
235 | |||
230 | def createPmultiline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='', legendlabels=None, |
|
236 | def createPmultiline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='', legendlabels=None, | |
231 | ticksize=9, xtick_visible=True, ytick_visible=True, |
|
237 | ticksize=9, xtick_visible=True, ytick_visible=True, | |
232 | nxticks=4, nyticks=10, |
|
238 | nxticks=4, nyticks=10, | |
233 | grid=None): |
|
239 | grid=None): | |
234 |
|
240 | |||
235 | """ |
|
241 | """ | |
236 |
|
242 | |||
237 | Input: |
|
243 | Input: | |
238 | grid : None, 'both', 'x', 'y' |
|
244 | grid : None, 'both', 'x', 'y' | |
239 | """ |
|
245 | """ | |
240 |
|
246 | |||
241 | matplotlib.pyplot.ioff() |
|
247 | matplotlib.pyplot.ioff() | |
242 |
|
248 | |||
243 | lines = ax.plot(x.T, y) |
|
249 | lines = ax.plot(x.T, y) | |
244 | leg = ax.legend(lines, legendlabels, loc='upper right') |
|
250 | leg = ax.legend(lines, legendlabels, loc='upper right') | |
245 | leg.get_frame().set_alpha(0.5) |
|
251 | leg.get_frame().set_alpha(0.5) | |
246 | ax.set_xlim([xmin,xmax]) |
|
252 | ax.set_xlim([xmin,xmax]) | |
247 | ax.set_ylim([ymin,ymax]) |
|
253 | ax.set_ylim([ymin,ymax]) | |
248 | printLabels(ax, xlabel, ylabel, title) |
|
254 | printLabels(ax, xlabel, ylabel, title) | |
249 |
|
255 | |||
250 | xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/(nxticks)) + int(xmin) |
|
256 | xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/(nxticks)) + int(xmin) | |
251 | ax.set_xticks(xtickspos) |
|
257 | ax.set_xticks(xtickspos) | |
252 |
|
258 | |||
253 | for tick in ax.get_xticklabels(): |
|
259 | for tick in ax.get_xticklabels(): | |
254 | tick.set_visible(xtick_visible) |
|
260 | tick.set_visible(xtick_visible) | |
255 |
|
261 | |||
256 | for tick in ax.xaxis.get_major_ticks(): |
|
262 | for tick in ax.xaxis.get_major_ticks(): | |
257 | tick.label.set_fontsize(ticksize) |
|
263 | tick.label.set_fontsize(ticksize) | |
258 |
|
264 | |||
259 | for tick in ax.get_yticklabels(): |
|
265 | for tick in ax.get_yticklabels(): | |
260 | tick.set_visible(ytick_visible) |
|
266 | tick.set_visible(ytick_visible) | |
261 |
|
267 | |||
262 | for tick in ax.yaxis.get_major_ticks(): |
|
268 | for tick in ax.yaxis.get_major_ticks(): | |
263 | tick.label.set_fontsize(ticksize) |
|
269 | tick.label.set_fontsize(ticksize) | |
264 |
|
270 | |||
265 | iplot = ax.lines[-1] |
|
271 | iplot = ax.lines[-1] | |
266 |
|
272 | |||
267 | if '0.' in matplotlib.__version__[0:2]: |
|
273 | if '0.' in matplotlib.__version__[0:2]: | |
268 | print "The matplotlib version has to be updated to 1.1 or newer" |
|
274 | print "The matplotlib version has to be updated to 1.1 or newer" | |
269 | return iplot |
|
275 | return iplot | |
270 |
|
276 | |||
271 | if '1.0.' in matplotlib.__version__[0:4]: |
|
277 | if '1.0.' in matplotlib.__version__[0:4]: | |
272 | print "The matplotlib version has to be updated to 1.1 or newer" |
|
278 | print "The matplotlib version has to be updated to 1.1 or newer" | |
273 | return iplot |
|
279 | return iplot | |
274 |
|
280 | |||
275 | if grid != None: |
|
281 | if grid != None: | |
276 | ax.grid(b=True, which='major', axis=grid) |
|
282 | ax.grid(b=True, which='major', axis=grid) | |
277 |
|
283 | |||
278 | matplotlib.pyplot.tight_layout() |
|
284 | matplotlib.pyplot.tight_layout() | |
279 |
|
285 | |||
280 | matplotlib.pyplot.ion() |
|
286 | matplotlib.pyplot.ion() | |
281 |
|
287 | |||
282 | return iplot |
|
288 | return iplot | |
283 |
|
289 | |||
284 |
|
290 | |||
285 | def pmultiline(iplot, x, y, xlabel='', ylabel='', title=''): |
|
291 | def pmultiline(iplot, x, y, xlabel='', ylabel='', title=''): | |
286 |
|
292 | |||
287 | ax = iplot.get_axes() |
|
293 | ax = iplot.get_axes() | |
288 |
|
294 | |||
289 | printLabels(ax, xlabel, ylabel, title) |
|
295 | printLabels(ax, xlabel, ylabel, title) | |
290 |
|
296 | |||
291 | for i in range(len(ax.lines)): |
|
297 | for i in range(len(ax.lines)): | |
292 | line = ax.lines[i] |
|
298 | line = ax.lines[i] | |
293 | line.set_data(x[i,:],y) |
|
299 | line.set_data(x[i,:],y) | |
294 |
|
300 | |||
295 | def createPmultilineYAxis(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='', legendlabels=None, |
|
301 | def createPmultilineYAxis(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='', legendlabels=None, | |
296 | ticksize=9, xtick_visible=True, ytick_visible=True, |
|
302 | ticksize=9, xtick_visible=True, ytick_visible=True, | |
297 | nxticks=4, nyticks=10, marker='^', markersize=8, linestyle="solid", |
|
303 | nxticks=4, nyticks=10, marker='^', markersize=8, linestyle="solid", | |
298 | grid=None, XAxisAsTime=False): |
|
304 | grid=None, XAxisAsTime=False): | |
299 |
|
305 | |||
300 | """ |
|
306 | """ | |
301 |
|
307 | |||
302 | Input: |
|
308 | Input: | |
303 | grid : None, 'both', 'x', 'y' |
|
309 | grid : None, 'both', 'x', 'y' | |
304 | """ |
|
310 | """ | |
305 |
|
311 | |||
306 | matplotlib.pyplot.ioff() |
|
312 | matplotlib.pyplot.ioff() | |
307 |
|
313 | |||
308 | lines = ax.plot(x, y.T, marker=marker,markersize=markersize,linestyle=linestyle) |
|
314 | lines = ax.plot(x, y.T, marker=marker,markersize=markersize,linestyle=linestyle) | |
309 | leg = ax.legend(lines, legendlabels, loc='upper left', bbox_to_anchor=(1.01, 1.00), numpoints=1, handlelength=1.5, \ |
|
315 | leg = ax.legend(lines, legendlabels, loc='upper left', bbox_to_anchor=(1.01, 1.00), numpoints=1, handlelength=1.5, \ | |
310 | handletextpad=0.5, borderpad=0.5, labelspacing=0.5, borderaxespad=0.) |
|
316 | handletextpad=0.5, borderpad=0.5, labelspacing=0.5, borderaxespad=0.) | |
311 |
|
317 | |||
312 | for label in leg.get_texts(): label.set_fontsize(9) |
|
318 | for label in leg.get_texts(): label.set_fontsize(9) | |
313 |
|
319 | |||
314 | ax.set_xlim([xmin,xmax]) |
|
320 | ax.set_xlim([xmin,xmax]) | |
315 | ax.set_ylim([ymin,ymax]) |
|
321 | ax.set_ylim([ymin,ymax]) | |
316 | printLabels(ax, xlabel, ylabel, title) |
|
322 | printLabels(ax, xlabel, ylabel, title) | |
317 |
|
323 | |||
318 | # xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/(nxticks)) + int(xmin) |
|
324 | # xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/(nxticks)) + int(xmin) | |
319 | # ax.set_xticks(xtickspos) |
|
325 | # ax.set_xticks(xtickspos) | |
320 |
|
326 | |||
321 | for tick in ax.get_xticklabels(): |
|
327 | for tick in ax.get_xticklabels(): | |
322 | tick.set_visible(xtick_visible) |
|
328 | tick.set_visible(xtick_visible) | |
323 |
|
329 | |||
324 | for tick in ax.xaxis.get_major_ticks(): |
|
330 | for tick in ax.xaxis.get_major_ticks(): | |
325 | tick.label.set_fontsize(ticksize) |
|
331 | tick.label.set_fontsize(ticksize) | |
326 |
|
332 | |||
327 | for tick in ax.get_yticklabels(): |
|
333 | for tick in ax.get_yticklabels(): | |
328 | tick.set_visible(ytick_visible) |
|
334 | tick.set_visible(ytick_visible) | |
329 |
|
335 | |||
330 | for tick in ax.yaxis.get_major_ticks(): |
|
336 | for tick in ax.yaxis.get_major_ticks(): | |
331 | tick.label.set_fontsize(ticksize) |
|
337 | tick.label.set_fontsize(ticksize) | |
332 |
|
338 | |||
333 | iplot = ax.lines[-1] |
|
339 | iplot = ax.lines[-1] | |
334 |
|
340 | |||
335 | if '0.' in matplotlib.__version__[0:2]: |
|
341 | if '0.' in matplotlib.__version__[0:2]: | |
336 | print "The matplotlib version has to be updated to 1.1 or newer" |
|
342 | print "The matplotlib version has to be updated to 1.1 or newer" | |
337 | return iplot |
|
343 | return iplot | |
338 |
|
344 | |||
339 | if '1.0.' in matplotlib.__version__[0:4]: |
|
345 | if '1.0.' in matplotlib.__version__[0:4]: | |
340 | print "The matplotlib version has to be updated to 1.1 or newer" |
|
346 | print "The matplotlib version has to be updated to 1.1 or newer" | |
341 | return iplot |
|
347 | return iplot | |
342 |
|
348 | |||
343 | if grid != None: |
|
349 | if grid != None: | |
344 | ax.grid(b=True, which='major', axis=grid) |
|
350 | ax.grid(b=True, which='major', axis=grid) | |
345 |
|
351 | |||
346 | matplotlib.pyplot.tight_layout() |
|
352 | matplotlib.pyplot.tight_layout() | |
347 |
|
353 | |||
348 | if XAxisAsTime: |
|
354 | if XAxisAsTime: | |
349 |
|
355 | |||
350 | func = lambda x, pos: ('%s') %(datetime.datetime.utcfromtimestamp(x).strftime("%H:%M:%S")) |
|
356 | func = lambda x, pos: ('%s') %(datetime.datetime.utcfromtimestamp(x).strftime("%H:%M:%S")) | |
351 | ax.xaxis.set_major_formatter(FuncFormatter(func)) |
|
357 | ax.xaxis.set_major_formatter(FuncFormatter(func)) | |
352 | ax.xaxis.set_major_locator(LinearLocator(7)) |
|
358 | ax.xaxis.set_major_locator(LinearLocator(7)) | |
353 |
|
359 | |||
354 | matplotlib.pyplot.ion() |
|
360 | matplotlib.pyplot.ion() | |
355 |
|
361 | |||
356 | return iplot |
|
362 | return iplot | |
357 |
|
363 | |||
358 | def pmultilineyaxis(iplot, x, y, xlabel='', ylabel='', title=''): |
|
364 | def pmultilineyaxis(iplot, x, y, xlabel='', ylabel='', title=''): | |
359 |
|
365 | |||
360 | ax = iplot.get_axes() |
|
366 | ax = iplot.get_axes() | |
361 |
|
367 | |||
362 | printLabels(ax, xlabel, ylabel, title) |
|
368 | printLabels(ax, xlabel, ylabel, title) | |
363 |
|
369 | |||
364 | for i in range(len(ax.lines)): |
|
370 | for i in range(len(ax.lines)): | |
365 | line = ax.lines[i] |
|
371 | line = ax.lines[i] | |
366 | line.set_data(x,y[i,:]) |
|
372 | line.set_data(x,y[i,:]) | |
367 |
|
373 | |||
368 | def draw(fig): |
|
374 | def draw(fig): | |
369 |
|
375 | |||
370 | if type(fig) == 'int': |
|
376 | if type(fig) == 'int': | |
371 | raise ValueError, "This parameter should be of tpye matplotlib figure" |
|
377 | raise ValueError, "This parameter should be of tpye matplotlib figure" | |
372 |
|
378 | |||
373 | fig.canvas.draw() No newline at end of file |
|
379 | fig.canvas.draw() |
@@ -1,1004 +1,1004 | |||||
1 | import numpy |
|
1 | import numpy | |
2 | import time, datetime, os |
|
2 | import time, datetime, os | |
3 | from graphics.figure import * |
|
3 | from graphics.figure import * | |
4 |
|
4 | |||
5 | class CrossSpectraPlot(Figure): |
|
5 | class CrossSpectraPlot(Figure): | |
6 |
|
6 | |||
7 | __isConfig = None |
|
7 | __isConfig = None | |
8 | __nsubplots = None |
|
8 | __nsubplots = None | |
9 |
|
9 | |||
10 | WIDTH = None |
|
10 | WIDTH = None | |
11 | HEIGHT = None |
|
11 | HEIGHT = None | |
12 | WIDTHPROF = None |
|
12 | WIDTHPROF = None | |
13 | HEIGHTPROF = None |
|
13 | HEIGHTPROF = None | |
14 | PREFIX = 'cspc' |
|
14 | PREFIX = 'cspc' | |
15 |
|
15 | |||
16 | def __init__(self): |
|
16 | def __init__(self): | |
17 |
|
17 | |||
18 | self.__isConfig = False |
|
18 | self.__isConfig = False | |
19 | self.__nsubplots = 4 |
|
19 | self.__nsubplots = 4 | |
20 |
|
20 | |||
21 | self.WIDTH = 250 |
|
21 | self.WIDTH = 250 | |
22 | self.HEIGHT = 250 |
|
22 | self.HEIGHT = 250 | |
23 | self.WIDTHPROF = 0 |
|
23 | self.WIDTHPROF = 0 | |
24 | self.HEIGHTPROF = 0 |
|
24 | self.HEIGHTPROF = 0 | |
25 |
|
25 | |||
26 | def getSubplots(self): |
|
26 | def getSubplots(self): | |
27 |
|
27 | |||
28 | ncol = 4 |
|
28 | ncol = 4 | |
29 | nrow = self.nplots |
|
29 | nrow = self.nplots | |
30 |
|
30 | |||
31 | return nrow, ncol |
|
31 | return nrow, ncol | |
32 |
|
32 | |||
33 | def setup(self, idfigure, nplots, wintitle, showprofile=True): |
|
33 | def setup(self, idfigure, nplots, wintitle, showprofile=True): | |
34 |
|
34 | |||
35 | self.__showprofile = showprofile |
|
35 | self.__showprofile = showprofile | |
36 | self.nplots = nplots |
|
36 | self.nplots = nplots | |
37 |
|
37 | |||
38 | ncolspan = 1 |
|
38 | ncolspan = 1 | |
39 | colspan = 1 |
|
39 | colspan = 1 | |
40 |
|
40 | |||
41 | self.createFigure(idfigure = idfigure, |
|
41 | self.createFigure(idfigure = idfigure, | |
42 | wintitle = wintitle, |
|
42 | wintitle = wintitle, | |
43 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
43 | widthplot = self.WIDTH + self.WIDTHPROF, | |
44 | heightplot = self.HEIGHT + self.HEIGHTPROF) |
|
44 | heightplot = self.HEIGHT + self.HEIGHTPROF) | |
45 |
|
45 | |||
46 | nrow, ncol = self.getSubplots() |
|
46 | nrow, ncol = self.getSubplots() | |
47 |
|
47 | |||
48 | counter = 0 |
|
48 | counter = 0 | |
49 | for y in range(nrow): |
|
49 | for y in range(nrow): | |
50 | for x in range(ncol): |
|
50 | for x in range(ncol): | |
51 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
51 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
52 |
|
52 | |||
53 | counter += 1 |
|
53 | counter += 1 | |
54 |
|
54 | |||
55 | def run(self, dataOut, idfigure, wintitle="", pairsList=None, showprofile='True', |
|
55 | def run(self, dataOut, idfigure, wintitle="", pairsList=None, showprofile='True', | |
56 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
56 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
57 | save=False, figpath='./', figfile=None, |
|
57 | save=False, figpath='./', figfile=None, | |
58 | power_cmap='jet', coherence_cmap='jet', phase_cmap='RdBu_r'): |
|
58 | power_cmap='jet', coherence_cmap='jet', phase_cmap='RdBu_r'): | |
59 |
|
59 | |||
60 | """ |
|
60 | """ | |
61 |
|
61 | |||
62 | Input: |
|
62 | Input: | |
63 | dataOut : |
|
63 | dataOut : | |
64 | idfigure : |
|
64 | idfigure : | |
65 | wintitle : |
|
65 | wintitle : | |
66 | channelList : |
|
66 | channelList : | |
67 | showProfile : |
|
67 | showProfile : | |
68 | xmin : None, |
|
68 | xmin : None, | |
69 | xmax : None, |
|
69 | xmax : None, | |
70 | ymin : None, |
|
70 | ymin : None, | |
71 | ymax : None, |
|
71 | ymax : None, | |
72 | zmin : None, |
|
72 | zmin : None, | |
73 | zmax : None |
|
73 | zmax : None | |
74 | """ |
|
74 | """ | |
75 |
|
75 | |||
76 | if pairsList == None: |
|
76 | if pairsList == None: | |
77 | pairsIndexList = dataOut.pairsIndexList |
|
77 | pairsIndexList = dataOut.pairsIndexList | |
78 | else: |
|
78 | else: | |
79 | pairsIndexList = [] |
|
79 | pairsIndexList = [] | |
80 | for pair in pairsList: |
|
80 | for pair in pairsList: | |
81 | if pair not in dataOut.pairsList: |
|
81 | if pair not in dataOut.pairsList: | |
82 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) |
|
82 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) | |
83 | pairsIndexList.append(dataOut.pairsList.index(pair)) |
|
83 | pairsIndexList.append(dataOut.pairsList.index(pair)) | |
84 |
|
84 | |||
85 | if pairsIndexList == []: |
|
85 | if pairsIndexList == []: | |
86 | return |
|
86 | return | |
87 |
|
87 | |||
88 | if len(pairsIndexList) > 4: |
|
88 | if len(pairsIndexList) > 4: | |
89 | pairsIndexList = pairsIndexList[0:4] |
|
89 | pairsIndexList = pairsIndexList[0:4] | |
90 | factor = dataOut.normFactor |
|
90 | factor = dataOut.normFactor | |
91 | x = dataOut.getVelRange(1) |
|
91 | x = dataOut.getVelRange(1) | |
92 | y = dataOut.getHeiRange() |
|
92 | y = dataOut.getHeiRange() | |
93 | z = dataOut.data_spc[:,:,:]/factor |
|
93 | z = dataOut.data_spc[:,:,:]/factor | |
94 | # z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
94 | # z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
95 | avg = numpy.abs(numpy.average(z, axis=1)) |
|
95 | avg = numpy.abs(numpy.average(z, axis=1)) | |
96 | noise = dataOut.getNoise()/factor |
|
96 | noise = dataOut.getNoise()/factor | |
97 |
|
97 | |||
98 | zdB = 10*numpy.log10(z) |
|
98 | zdB = 10*numpy.log10(z) | |
99 | avgdB = 10*numpy.log10(avg) |
|
99 | avgdB = 10*numpy.log10(avg) | |
100 | noisedB = 10*numpy.log10(noise) |
|
100 | noisedB = 10*numpy.log10(noise) | |
101 |
|
101 | |||
102 |
|
102 | |||
103 | thisDatetime = dataOut.datatime |
|
103 | thisDatetime = dataOut.datatime | |
104 | title = "Cross-Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
104 | title = "Cross-Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
105 | xlabel = "Velocity (m/s)" |
|
105 | xlabel = "Velocity (m/s)" | |
106 | ylabel = "Range (Km)" |
|
106 | ylabel = "Range (Km)" | |
107 |
|
107 | |||
108 | if not self.__isConfig: |
|
108 | if not self.__isConfig: | |
109 |
|
109 | |||
110 | nplots = len(pairsIndexList) |
|
110 | nplots = len(pairsIndexList) | |
111 |
|
111 | |||
112 | self.setup(idfigure=idfigure, |
|
112 | self.setup(idfigure=idfigure, | |
113 | nplots=nplots, |
|
113 | nplots=nplots, | |
114 | wintitle=wintitle, |
|
114 | wintitle=wintitle, | |
115 | showprofile=showprofile) |
|
115 | showprofile=showprofile) | |
116 |
|
116 | |||
117 | if xmin == None: xmin = numpy.nanmin(x) |
|
117 | if xmin == None: xmin = numpy.nanmin(x) | |
118 | if xmax == None: xmax = numpy.nanmax(x) |
|
118 | if xmax == None: xmax = numpy.nanmax(x) | |
119 | if ymin == None: ymin = numpy.nanmin(y) |
|
119 | if ymin == None: ymin = numpy.nanmin(y) | |
120 | if ymax == None: ymax = numpy.nanmax(y) |
|
120 | if ymax == None: ymax = numpy.nanmax(y) | |
121 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 |
|
121 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 | |
122 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 |
|
122 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 | |
123 |
|
123 | |||
124 | self.__isConfig = True |
|
124 | self.__isConfig = True | |
125 |
|
125 | |||
126 | self.setWinTitle(title) |
|
126 | self.setWinTitle(title) | |
127 |
|
127 | |||
128 | for i in range(self.nplots): |
|
128 | for i in range(self.nplots): | |
129 | pair = dataOut.pairsList[pairsIndexList[i]] |
|
129 | pair = dataOut.pairsList[pairsIndexList[i]] | |
130 |
|
130 | |||
131 | title = "Channel %d: %4.2fdB" %(pair[0], noisedB[pair[0]]) |
|
131 | title = "Channel %d: %4.2fdB" %(pair[0], noisedB[pair[0]]) | |
132 | zdB = 10.*numpy.log10(dataOut.data_spc[pair[0],:,:]/factor) |
|
132 | zdB = 10.*numpy.log10(dataOut.data_spc[pair[0],:,:]/factor) | |
133 | axes0 = self.axesList[i*self.__nsubplots] |
|
133 | axes0 = self.axesList[i*self.__nsubplots] | |
134 | axes0.pcolor(x, y, zdB, |
|
134 | axes0.pcolor(x, y, zdB, | |
135 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
135 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
136 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
136 | xlabel=xlabel, ylabel=ylabel, title=title, | |
137 | ticksize=9, colormap=power_cmap, cblabel='') |
|
137 | ticksize=9, colormap=power_cmap, cblabel='') | |
138 |
|
138 | |||
139 | title = "Channel %d: %4.2fdB" %(pair[1], noisedB[pair[1]]) |
|
139 | title = "Channel %d: %4.2fdB" %(pair[1], noisedB[pair[1]]) | |
140 | zdB = 10.*numpy.log10(dataOut.data_spc[pair[1],:,:]/factor) |
|
140 | zdB = 10.*numpy.log10(dataOut.data_spc[pair[1],:,:]/factor) | |
141 | axes0 = self.axesList[i*self.__nsubplots+1] |
|
141 | axes0 = self.axesList[i*self.__nsubplots+1] | |
142 | axes0.pcolor(x, y, zdB, |
|
142 | axes0.pcolor(x, y, zdB, | |
143 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
143 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
144 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
144 | xlabel=xlabel, ylabel=ylabel, title=title, | |
145 | ticksize=9, colormap=power_cmap, cblabel='') |
|
145 | ticksize=9, colormap=power_cmap, cblabel='') | |
146 |
|
146 | |||
147 | coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:]) |
|
147 | coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:]) | |
148 | coherence = numpy.abs(coherenceComplex) |
|
148 | coherence = numpy.abs(coherenceComplex) | |
149 | # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi |
|
149 | # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi | |
150 | phase = numpy.arctan2(coherenceComplex.imag, coherenceComplex.real)*180/numpy.pi |
|
150 | phase = numpy.arctan2(coherenceComplex.imag, coherenceComplex.real)*180/numpy.pi | |
151 |
|
151 | |||
152 | title = "Coherence %d%d" %(pair[0], pair[1]) |
|
152 | title = "Coherence %d%d" %(pair[0], pair[1]) | |
153 | axes0 = self.axesList[i*self.__nsubplots+2] |
|
153 | axes0 = self.axesList[i*self.__nsubplots+2] | |
154 | axes0.pcolor(x, y, coherence, |
|
154 | axes0.pcolor(x, y, coherence, | |
155 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1, |
|
155 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1, | |
156 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
156 | xlabel=xlabel, ylabel=ylabel, title=title, | |
157 | ticksize=9, colormap=coherence_cmap, cblabel='') |
|
157 | ticksize=9, colormap=coherence_cmap, cblabel='') | |
158 |
|
158 | |||
159 | title = "Phase %d%d" %(pair[0], pair[1]) |
|
159 | title = "Phase %d%d" %(pair[0], pair[1]) | |
160 | axes0 = self.axesList[i*self.__nsubplots+3] |
|
160 | axes0 = self.axesList[i*self.__nsubplots+3] | |
161 | axes0.pcolor(x, y, phase, |
|
161 | axes0.pcolor(x, y, phase, | |
162 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180, |
|
162 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180, | |
163 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
163 | xlabel=xlabel, ylabel=ylabel, title=title, | |
164 | ticksize=9, colormap=phase_cmap, cblabel='') |
|
164 | ticksize=9, colormap=phase_cmap, cblabel='') | |
165 |
|
165 | |||
166 |
|
166 | |||
167 |
|
167 | |||
168 | self.draw() |
|
168 | self.draw() | |
169 |
|
169 | |||
170 | if save: |
|
170 | if save: | |
171 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
171 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
172 | if figfile == None: |
|
172 | if figfile == None: | |
173 | figfile = self.getFilename(name = date) |
|
173 | figfile = self.getFilename(name = date) | |
174 |
|
174 | |||
175 | self.saveFigure(figpath, figfile) |
|
175 | self.saveFigure(figpath, figfile) | |
176 |
|
176 | |||
177 |
|
177 | |||
178 | class RTIPlot(Figure): |
|
178 | class RTIPlot(Figure): | |
179 |
|
179 | |||
180 | __isConfig = None |
|
180 | __isConfig = None | |
181 | __nsubplots = None |
|
181 | __nsubplots = None | |
182 |
|
182 | |||
183 | WIDTHPROF = None |
|
183 | WIDTHPROF = None | |
184 | HEIGHTPROF = None |
|
184 | HEIGHTPROF = None | |
185 | PREFIX = 'rti' |
|
185 | PREFIX = 'rti' | |
186 |
|
186 | |||
187 | def __init__(self): |
|
187 | def __init__(self): | |
188 |
|
188 | |||
189 | self.timerange = 2*60*60 |
|
189 | self.timerange = 2*60*60 | |
190 | self.__isConfig = False |
|
190 | self.__isConfig = False | |
191 | self.__nsubplots = 1 |
|
191 | self.__nsubplots = 1 | |
192 |
|
192 | |||
193 | self.WIDTH = 800 |
|
193 | self.WIDTH = 800 | |
194 | self.HEIGHT = 150 |
|
194 | self.HEIGHT = 150 | |
195 | self.WIDTHPROF = 120 |
|
195 | self.WIDTHPROF = 120 | |
196 | self.HEIGHTPROF = 0 |
|
196 | self.HEIGHTPROF = 0 | |
197 | self.counterftp = 0 |
|
197 | self.counterftp = 0 | |
198 |
|
198 | |||
199 | def getSubplots(self): |
|
199 | def getSubplots(self): | |
200 |
|
200 | |||
201 | ncol = 1 |
|
201 | ncol = 1 | |
202 | nrow = self.nplots |
|
202 | nrow = self.nplots | |
203 |
|
203 | |||
204 | return nrow, ncol |
|
204 | return nrow, ncol | |
205 |
|
205 | |||
206 | def setup(self, idfigure, nplots, wintitle, showprofile=True): |
|
206 | def setup(self, idfigure, nplots, wintitle, showprofile=True): | |
207 |
|
207 | |||
208 | self.__showprofile = showprofile |
|
208 | self.__showprofile = showprofile | |
209 | self.nplots = nplots |
|
209 | self.nplots = nplots | |
210 |
|
210 | |||
211 | ncolspan = 1 |
|
211 | ncolspan = 1 | |
212 | colspan = 1 |
|
212 | colspan = 1 | |
213 | if showprofile: |
|
213 | if showprofile: | |
214 | ncolspan = 7 |
|
214 | ncolspan = 7 | |
215 | colspan = 6 |
|
215 | colspan = 6 | |
216 | self.__nsubplots = 2 |
|
216 | self.__nsubplots = 2 | |
217 |
|
217 | |||
218 | self.createFigure(idfigure = idfigure, |
|
218 | self.createFigure(idfigure = idfigure, | |
219 | wintitle = wintitle, |
|
219 | wintitle = wintitle, | |
220 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
220 | widthplot = self.WIDTH + self.WIDTHPROF, | |
221 | heightplot = self.HEIGHT + self.HEIGHTPROF) |
|
221 | heightplot = self.HEIGHT + self.HEIGHTPROF) | |
222 |
|
222 | |||
223 | nrow, ncol = self.getSubplots() |
|
223 | nrow, ncol = self.getSubplots() | |
224 |
|
224 | |||
225 | counter = 0 |
|
225 | counter = 0 | |
226 | for y in range(nrow): |
|
226 | for y in range(nrow): | |
227 | for x in range(ncol): |
|
227 | for x in range(ncol): | |
228 |
|
228 | |||
229 | if counter >= self.nplots: |
|
229 | if counter >= self.nplots: | |
230 | break |
|
230 | break | |
231 |
|
231 | |||
232 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
232 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
233 |
|
233 | |||
234 | if showprofile: |
|
234 | if showprofile: | |
235 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
235 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
236 |
|
236 | |||
237 | counter += 1 |
|
237 | counter += 1 | |
238 |
|
238 | |||
239 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', |
|
239 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', | |
240 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
240 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
241 | timerange=None, |
|
241 | timerange=None, | |
242 | save=False, figpath='./', figfile=None, ftp=False, ftpratio=1): |
|
242 | save=False, figpath='./', figfile=None, ftp=False, ftpratio=1): | |
243 |
|
243 | |||
244 | """ |
|
244 | """ | |
245 |
|
245 | |||
246 | Input: |
|
246 | Input: | |
247 | dataOut : |
|
247 | dataOut : | |
248 | idfigure : |
|
248 | idfigure : | |
249 | wintitle : |
|
249 | wintitle : | |
250 | channelList : |
|
250 | channelList : | |
251 | showProfile : |
|
251 | showProfile : | |
252 | xmin : None, |
|
252 | xmin : None, | |
253 | xmax : None, |
|
253 | xmax : None, | |
254 | ymin : None, |
|
254 | ymin : None, | |
255 | ymax : None, |
|
255 | ymax : None, | |
256 | zmin : None, |
|
256 | zmin : None, | |
257 | zmax : None |
|
257 | zmax : None | |
258 | """ |
|
258 | """ | |
259 |
|
259 | |||
260 | if channelList == None: |
|
260 | if channelList == None: | |
261 | channelIndexList = dataOut.channelIndexList |
|
261 | channelIndexList = dataOut.channelIndexList | |
262 | else: |
|
262 | else: | |
263 | channelIndexList = [] |
|
263 | channelIndexList = [] | |
264 | for channel in channelList: |
|
264 | for channel in channelList: | |
265 | if channel not in dataOut.channelList: |
|
265 | if channel not in dataOut.channelList: | |
266 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
266 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
267 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
267 | channelIndexList.append(dataOut.channelList.index(channel)) | |
268 |
|
268 | |||
269 | if timerange != None: |
|
269 | if timerange != None: | |
270 | self.timerange = timerange |
|
270 | self.timerange = timerange | |
271 |
|
271 | |||
272 | tmin = None |
|
272 | tmin = None | |
273 | tmax = None |
|
273 | tmax = None | |
274 | factor = dataOut.normFactor |
|
274 | factor = dataOut.normFactor | |
275 | x = dataOut.getTimeRange() |
|
275 | x = dataOut.getTimeRange() | |
276 | y = dataOut.getHeiRange() |
|
276 | y = dataOut.getHeiRange() | |
277 |
|
277 | |||
278 | z = dataOut.data_spc[channelIndexList,:,:]/factor |
|
278 | z = dataOut.data_spc[channelIndexList,:,:]/factor | |
279 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
279 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
280 | avg = numpy.average(z, axis=1) |
|
280 | avg = numpy.average(z, axis=1) | |
281 |
|
281 | |||
282 | avgdB = 10.*numpy.log10(avg) |
|
282 | avgdB = 10.*numpy.log10(avg) | |
283 |
|
283 | |||
284 |
|
284 | |||
285 | thisDatetime = dataOut.datatime |
|
285 | thisDatetime = dataOut.datatime | |
286 | title = "RTI: %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
286 | title = "RTI: %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
287 | xlabel = "" |
|
287 | xlabel = "" | |
288 | ylabel = "Range (Km)" |
|
288 | ylabel = "Range (Km)" | |
289 |
|
289 | |||
290 | if not self.__isConfig: |
|
290 | if not self.__isConfig: | |
291 |
|
291 | |||
292 | nplots = len(channelIndexList) |
|
292 | nplots = len(channelIndexList) | |
293 |
|
293 | |||
294 | self.setup(idfigure=idfigure, |
|
294 | self.setup(idfigure=idfigure, | |
295 | nplots=nplots, |
|
295 | nplots=nplots, | |
296 | wintitle=wintitle, |
|
296 | wintitle=wintitle, | |
297 | showprofile=showprofile) |
|
297 | showprofile=showprofile) | |
298 |
|
298 | |||
299 | tmin, tmax = self.getTimeLim(x, xmin, xmax) |
|
299 | tmin, tmax = self.getTimeLim(x, xmin, xmax) | |
300 | if ymin == None: ymin = numpy.nanmin(y) |
|
300 | if ymin == None: ymin = numpy.nanmin(y) | |
301 | if ymax == None: ymax = numpy.nanmax(y) |
|
301 | if ymax == None: ymax = numpy.nanmax(y) | |
302 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 |
|
302 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 | |
303 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 |
|
303 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 | |
304 |
|
304 | |||
305 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
305 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
306 | self.__isConfig = True |
|
306 | self.__isConfig = True | |
307 |
|
307 | |||
308 |
|
308 | |||
309 | self.setWinTitle(title) |
|
309 | self.setWinTitle(title) | |
310 |
|
310 | |||
311 | for i in range(self.nplots): |
|
311 | for i in range(self.nplots): | |
312 | title = "Channel %d: %s" %(dataOut.channelList[i], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
312 | title = "Channel %d: %s" %(dataOut.channelList[i], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
313 | axes = self.axesList[i*self.__nsubplots] |
|
313 | axes = self.axesList[i*self.__nsubplots] | |
314 | zdB = avgdB[i].reshape((1,-1)) |
|
314 | zdB = avgdB[i].reshape((1,-1)) | |
315 | axes.pcolor(x, y, zdB, |
|
315 | axes.pcolorbuffer(x, y, zdB, | |
316 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
316 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
317 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
317 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
318 | ticksize=9, cblabel='', cbsize="1%") |
|
318 | ticksize=9, cblabel='', cbsize="1%") | |
319 |
|
319 | |||
320 | if self.__showprofile: |
|
320 | if self.__showprofile: | |
321 | axes = self.axesList[i*self.__nsubplots +1] |
|
321 | axes = self.axesList[i*self.__nsubplots +1] | |
322 | axes.pline(avgdB[i], y, |
|
322 | axes.pline(avgdB[i], y, | |
323 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, |
|
323 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, | |
324 | xlabel='dB', ylabel='', title='', |
|
324 | xlabel='dB', ylabel='', title='', | |
325 | ytick_visible=False, |
|
325 | ytick_visible=False, | |
326 | grid='x') |
|
326 | grid='x') | |
327 |
|
327 | |||
328 | self.draw() |
|
328 | self.draw() | |
329 |
|
329 | |||
330 | if save: |
|
330 | if save: | |
331 |
|
331 | |||
332 | if figfile == None: |
|
332 | if figfile == None: | |
333 | figfile = self.getFilename(name = self.name) |
|
333 | figfile = self.getFilename(name = self.name) | |
334 |
|
334 | |||
335 | self.saveFigure(figpath, figfile) |
|
335 | self.saveFigure(figpath, figfile) | |
336 |
|
336 | |||
337 | self.counterftp += 1 |
|
337 | self.counterftp += 1 | |
338 | if (ftp and (self.counterftp==ftpratio)): |
|
338 | if (ftp and (self.counterftp==ftpratio)): | |
339 | figfilename = os.path.join(figpath,figfile) |
|
339 | figfilename = os.path.join(figpath,figfile) | |
340 | self.sendByFTP(figfilename) |
|
340 | self.sendByFTP(figfilename) | |
341 | self.counterftp = 0 |
|
341 | self.counterftp = 0 | |
342 |
|
342 | |||
343 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: |
|
343 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: | |
344 | self.__isConfig = False |
|
344 | self.__isConfig = False | |
345 |
|
345 | |||
346 | class SpectraPlot(Figure): |
|
346 | class SpectraPlot(Figure): | |
347 |
|
347 | |||
348 | __isConfig = None |
|
348 | __isConfig = None | |
349 | __nsubplots = None |
|
349 | __nsubplots = None | |
350 |
|
350 | |||
351 | WIDTHPROF = None |
|
351 | WIDTHPROF = None | |
352 | HEIGHTPROF = None |
|
352 | HEIGHTPROF = None | |
353 | PREFIX = 'spc' |
|
353 | PREFIX = 'spc' | |
354 |
|
354 | |||
355 | def __init__(self): |
|
355 | def __init__(self): | |
356 |
|
356 | |||
357 | self.__isConfig = False |
|
357 | self.__isConfig = False | |
358 | self.__nsubplots = 1 |
|
358 | self.__nsubplots = 1 | |
359 |
|
359 | |||
360 | self.WIDTH = 230 |
|
360 | self.WIDTH = 230 | |
361 | self.HEIGHT = 250 |
|
361 | self.HEIGHT = 250 | |
362 | self.WIDTHPROF = 120 |
|
362 | self.WIDTHPROF = 120 | |
363 | self.HEIGHTPROF = 0 |
|
363 | self.HEIGHTPROF = 0 | |
364 |
|
364 | |||
365 | def getSubplots(self): |
|
365 | def getSubplots(self): | |
366 |
|
366 | |||
367 | ncol = int(numpy.sqrt(self.nplots)+0.9) |
|
367 | ncol = int(numpy.sqrt(self.nplots)+0.9) | |
368 | nrow = int(self.nplots*1./ncol + 0.9) |
|
368 | nrow = int(self.nplots*1./ncol + 0.9) | |
369 |
|
369 | |||
370 | return nrow, ncol |
|
370 | return nrow, ncol | |
371 |
|
371 | |||
372 | def setup(self, idfigure, nplots, wintitle, showprofile=True): |
|
372 | def setup(self, idfigure, nplots, wintitle, showprofile=True): | |
373 |
|
373 | |||
374 | self.__showprofile = showprofile |
|
374 | self.__showprofile = showprofile | |
375 | self.nplots = nplots |
|
375 | self.nplots = nplots | |
376 |
|
376 | |||
377 | ncolspan = 1 |
|
377 | ncolspan = 1 | |
378 | colspan = 1 |
|
378 | colspan = 1 | |
379 | if showprofile: |
|
379 | if showprofile: | |
380 | ncolspan = 3 |
|
380 | ncolspan = 3 | |
381 | colspan = 2 |
|
381 | colspan = 2 | |
382 | self.__nsubplots = 2 |
|
382 | self.__nsubplots = 2 | |
383 |
|
383 | |||
384 | self.createFigure(idfigure = idfigure, |
|
384 | self.createFigure(idfigure = idfigure, | |
385 | wintitle = wintitle, |
|
385 | wintitle = wintitle, | |
386 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
386 | widthplot = self.WIDTH + self.WIDTHPROF, | |
387 | heightplot = self.HEIGHT + self.HEIGHTPROF) |
|
387 | heightplot = self.HEIGHT + self.HEIGHTPROF) | |
388 |
|
388 | |||
389 | nrow, ncol = self.getSubplots() |
|
389 | nrow, ncol = self.getSubplots() | |
390 |
|
390 | |||
391 | counter = 0 |
|
391 | counter = 0 | |
392 | for y in range(nrow): |
|
392 | for y in range(nrow): | |
393 | for x in range(ncol): |
|
393 | for x in range(ncol): | |
394 |
|
394 | |||
395 | if counter >= self.nplots: |
|
395 | if counter >= self.nplots: | |
396 | break |
|
396 | break | |
397 |
|
397 | |||
398 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
398 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
399 |
|
399 | |||
400 | if showprofile: |
|
400 | if showprofile: | |
401 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
401 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
402 |
|
402 | |||
403 | counter += 1 |
|
403 | counter += 1 | |
404 |
|
404 | |||
405 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', |
|
405 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', | |
406 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
406 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
407 | save=False, figpath='./', figfile=None): |
|
407 | save=False, figpath='./', figfile=None): | |
408 |
|
408 | |||
409 | """ |
|
409 | """ | |
410 |
|
410 | |||
411 | Input: |
|
411 | Input: | |
412 | dataOut : |
|
412 | dataOut : | |
413 | idfigure : |
|
413 | idfigure : | |
414 | wintitle : |
|
414 | wintitle : | |
415 | channelList : |
|
415 | channelList : | |
416 | showProfile : |
|
416 | showProfile : | |
417 | xmin : None, |
|
417 | xmin : None, | |
418 | xmax : None, |
|
418 | xmax : None, | |
419 | ymin : None, |
|
419 | ymin : None, | |
420 | ymax : None, |
|
420 | ymax : None, | |
421 | zmin : None, |
|
421 | zmin : None, | |
422 | zmax : None |
|
422 | zmax : None | |
423 | """ |
|
423 | """ | |
424 |
|
424 | |||
425 | if channelList == None: |
|
425 | if channelList == None: | |
426 | channelIndexList = dataOut.channelIndexList |
|
426 | channelIndexList = dataOut.channelIndexList | |
427 | else: |
|
427 | else: | |
428 | channelIndexList = [] |
|
428 | channelIndexList = [] | |
429 | for channel in channelList: |
|
429 | for channel in channelList: | |
430 | if channel not in dataOut.channelList: |
|
430 | if channel not in dataOut.channelList: | |
431 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
431 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
432 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
432 | channelIndexList.append(dataOut.channelList.index(channel)) | |
433 | factor = dataOut.normFactor |
|
433 | factor = dataOut.normFactor | |
434 | x = dataOut.getVelRange(1) |
|
434 | x = dataOut.getVelRange(1) | |
435 | y = dataOut.getHeiRange() |
|
435 | y = dataOut.getHeiRange() | |
436 |
|
436 | |||
437 | z = dataOut.data_spc[channelIndexList,:,:]/factor |
|
437 | z = dataOut.data_spc[channelIndexList,:,:]/factor | |
438 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
438 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
439 | avg = numpy.average(z, axis=1) |
|
439 | avg = numpy.average(z, axis=1) | |
440 | noise = dataOut.getNoise()/factor |
|
440 | noise = dataOut.getNoise()/factor | |
441 |
|
441 | |||
442 | zdB = 10*numpy.log10(z) |
|
442 | zdB = 10*numpy.log10(z) | |
443 | avgdB = 10*numpy.log10(avg) |
|
443 | avgdB = 10*numpy.log10(avg) | |
444 | noisedB = 10*numpy.log10(noise) |
|
444 | noisedB = 10*numpy.log10(noise) | |
445 |
|
445 | |||
446 | thisDatetime = dataOut.datatime |
|
446 | thisDatetime = dataOut.datatime | |
447 | title = "Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
447 | title = "Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
448 | xlabel = "Velocity (m/s)" |
|
448 | xlabel = "Velocity (m/s)" | |
449 | ylabel = "Range (Km)" |
|
449 | ylabel = "Range (Km)" | |
450 |
|
450 | |||
451 | if not self.__isConfig: |
|
451 | if not self.__isConfig: | |
452 |
|
452 | |||
453 | nplots = len(channelIndexList) |
|
453 | nplots = len(channelIndexList) | |
454 |
|
454 | |||
455 | self.setup(idfigure=idfigure, |
|
455 | self.setup(idfigure=idfigure, | |
456 | nplots=nplots, |
|
456 | nplots=nplots, | |
457 | wintitle=wintitle, |
|
457 | wintitle=wintitle, | |
458 | showprofile=showprofile) |
|
458 | showprofile=showprofile) | |
459 |
|
459 | |||
460 | if xmin == None: xmin = numpy.nanmin(x) |
|
460 | if xmin == None: xmin = numpy.nanmin(x) | |
461 | if xmax == None: xmax = numpy.nanmax(x) |
|
461 | if xmax == None: xmax = numpy.nanmax(x) | |
462 | if ymin == None: ymin = numpy.nanmin(y) |
|
462 | if ymin == None: ymin = numpy.nanmin(y) | |
463 | if ymax == None: ymax = numpy.nanmax(y) |
|
463 | if ymax == None: ymax = numpy.nanmax(y) | |
464 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 |
|
464 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 | |
465 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 |
|
465 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 | |
466 |
|
466 | |||
467 | self.__isConfig = True |
|
467 | self.__isConfig = True | |
468 |
|
468 | |||
469 | self.setWinTitle(title) |
|
469 | self.setWinTitle(title) | |
470 |
|
470 | |||
471 | for i in range(self.nplots): |
|
471 | for i in range(self.nplots): | |
472 | title = "Channel %d: %4.2fdB" %(dataOut.channelList[i], noisedB[i]) |
|
472 | title = "Channel %d: %4.2fdB" %(dataOut.channelList[i], noisedB[i]) | |
473 | axes = self.axesList[i*self.__nsubplots] |
|
473 | axes = self.axesList[i*self.__nsubplots] | |
474 | axes.pcolor(x, y, zdB[i,:,:], |
|
474 | axes.pcolor(x, y, zdB[i,:,:], | |
475 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
475 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
476 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
476 | xlabel=xlabel, ylabel=ylabel, title=title, | |
477 | ticksize=9, cblabel='') |
|
477 | ticksize=9, cblabel='') | |
478 |
|
478 | |||
479 | if self.__showprofile: |
|
479 | if self.__showprofile: | |
480 | axes = self.axesList[i*self.__nsubplots +1] |
|
480 | axes = self.axesList[i*self.__nsubplots +1] | |
481 | axes.pline(avgdB[i], y, |
|
481 | axes.pline(avgdB[i], y, | |
482 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, |
|
482 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, | |
483 | xlabel='dB', ylabel='', title='', |
|
483 | xlabel='dB', ylabel='', title='', | |
484 | ytick_visible=False, |
|
484 | ytick_visible=False, | |
485 | grid='x') |
|
485 | grid='x') | |
486 |
|
486 | |||
487 | noiseline = numpy.repeat(noisedB[i], len(y)) |
|
487 | noiseline = numpy.repeat(noisedB[i], len(y)) | |
488 | axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2) |
|
488 | axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2) | |
489 |
|
489 | |||
490 | self.draw() |
|
490 | self.draw() | |
491 |
|
491 | |||
492 | if save: |
|
492 | if save: | |
493 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
493 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
494 | if figfile == None: |
|
494 | if figfile == None: | |
495 | figfile = self.getFilename(name = date) |
|
495 | figfile = self.getFilename(name = date) | |
496 |
|
496 | |||
497 | self.saveFigure(figpath, figfile) |
|
497 | self.saveFigure(figpath, figfile) | |
498 |
|
498 | |||
499 | class Scope(Figure): |
|
499 | class Scope(Figure): | |
500 |
|
500 | |||
501 | __isConfig = None |
|
501 | __isConfig = None | |
502 |
|
502 | |||
503 | def __init__(self): |
|
503 | def __init__(self): | |
504 |
|
504 | |||
505 | self.__isConfig = False |
|
505 | self.__isConfig = False | |
506 | self.WIDTH = 600 |
|
506 | self.WIDTH = 600 | |
507 | self.HEIGHT = 200 |
|
507 | self.HEIGHT = 200 | |
508 |
|
508 | |||
509 | def getSubplots(self): |
|
509 | def getSubplots(self): | |
510 |
|
510 | |||
511 | nrow = self.nplots |
|
511 | nrow = self.nplots | |
512 | ncol = 3 |
|
512 | ncol = 3 | |
513 | return nrow, ncol |
|
513 | return nrow, ncol | |
514 |
|
514 | |||
515 | def setup(self, idfigure, nplots, wintitle): |
|
515 | def setup(self, idfigure, nplots, wintitle): | |
516 |
|
516 | |||
517 | self.nplots = nplots |
|
517 | self.nplots = nplots | |
518 |
|
518 | |||
519 | self.createFigure(idfigure, wintitle) |
|
519 | self.createFigure(idfigure, wintitle) | |
520 |
|
520 | |||
521 | nrow,ncol = self.getSubplots() |
|
521 | nrow,ncol = self.getSubplots() | |
522 | colspan = 3 |
|
522 | colspan = 3 | |
523 | rowspan = 1 |
|
523 | rowspan = 1 | |
524 |
|
524 | |||
525 | for i in range(nplots): |
|
525 | for i in range(nplots): | |
526 | self.addAxes(nrow, ncol, i, 0, colspan, rowspan) |
|
526 | self.addAxes(nrow, ncol, i, 0, colspan, rowspan) | |
527 |
|
527 | |||
528 |
|
528 | |||
529 |
|
529 | |||
530 | def run(self, dataOut, idfigure, wintitle="", channelList=None, |
|
530 | def run(self, dataOut, idfigure, wintitle="", channelList=None, | |
531 | xmin=None, xmax=None, ymin=None, ymax=None, save=False, |
|
531 | xmin=None, xmax=None, ymin=None, ymax=None, save=False, | |
532 | figpath='./', figfile=None): |
|
532 | figpath='./', figfile=None): | |
533 |
|
533 | |||
534 | """ |
|
534 | """ | |
535 |
|
535 | |||
536 | Input: |
|
536 | Input: | |
537 | dataOut : |
|
537 | dataOut : | |
538 | idfigure : |
|
538 | idfigure : | |
539 | wintitle : |
|
539 | wintitle : | |
540 | channelList : |
|
540 | channelList : | |
541 | xmin : None, |
|
541 | xmin : None, | |
542 | xmax : None, |
|
542 | xmax : None, | |
543 | ymin : None, |
|
543 | ymin : None, | |
544 | ymax : None, |
|
544 | ymax : None, | |
545 | """ |
|
545 | """ | |
546 |
|
546 | |||
547 | if channelList == None: |
|
547 | if channelList == None: | |
548 | channelIndexList = dataOut.channelIndexList |
|
548 | channelIndexList = dataOut.channelIndexList | |
549 | else: |
|
549 | else: | |
550 | channelIndexList = [] |
|
550 | channelIndexList = [] | |
551 | for channel in channelList: |
|
551 | for channel in channelList: | |
552 | if channel not in dataOut.channelList: |
|
552 | if channel not in dataOut.channelList: | |
553 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
553 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
554 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
554 | channelIndexList.append(dataOut.channelList.index(channel)) | |
555 |
|
555 | |||
556 | x = dataOut.heightList |
|
556 | x = dataOut.heightList | |
557 | y = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:]) |
|
557 | y = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:]) | |
558 | y = y.real |
|
558 | y = y.real | |
559 |
|
559 | |||
560 | thisDatetime = dataOut.datatime |
|
560 | thisDatetime = dataOut.datatime | |
561 | title = "Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
561 | title = "Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
562 | xlabel = "Range (Km)" |
|
562 | xlabel = "Range (Km)" | |
563 | ylabel = "Intensity" |
|
563 | ylabel = "Intensity" | |
564 |
|
564 | |||
565 | if not self.__isConfig: |
|
565 | if not self.__isConfig: | |
566 | nplots = len(channelIndexList) |
|
566 | nplots = len(channelIndexList) | |
567 |
|
567 | |||
568 | self.setup(idfigure=idfigure, |
|
568 | self.setup(idfigure=idfigure, | |
569 | nplots=nplots, |
|
569 | nplots=nplots, | |
570 | wintitle=wintitle) |
|
570 | wintitle=wintitle) | |
571 |
|
571 | |||
572 | if xmin == None: xmin = numpy.nanmin(x) |
|
572 | if xmin == None: xmin = numpy.nanmin(x) | |
573 | if xmax == None: xmax = numpy.nanmax(x) |
|
573 | if xmax == None: xmax = numpy.nanmax(x) | |
574 | if ymin == None: ymin = numpy.nanmin(y) |
|
574 | if ymin == None: ymin = numpy.nanmin(y) | |
575 | if ymax == None: ymax = numpy.nanmax(y) |
|
575 | if ymax == None: ymax = numpy.nanmax(y) | |
576 |
|
576 | |||
577 | self.__isConfig = True |
|
577 | self.__isConfig = True | |
578 |
|
578 | |||
579 | self.setWinTitle(title) |
|
579 | self.setWinTitle(title) | |
580 |
|
580 | |||
581 | for i in range(len(self.axesList)): |
|
581 | for i in range(len(self.axesList)): | |
582 | title = "Channel %d" %(i) |
|
582 | title = "Channel %d" %(i) | |
583 | axes = self.axesList[i] |
|
583 | axes = self.axesList[i] | |
584 | ychannel = y[i,:] |
|
584 | ychannel = y[i,:] | |
585 | axes.pline(x, ychannel, |
|
585 | axes.pline(x, ychannel, | |
586 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, |
|
586 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, | |
587 | xlabel=xlabel, ylabel=ylabel, title=title) |
|
587 | xlabel=xlabel, ylabel=ylabel, title=title) | |
588 |
|
588 | |||
589 | self.draw() |
|
589 | self.draw() | |
590 |
|
590 | |||
591 | if save: |
|
591 | if save: | |
592 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
592 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
593 | if figfile == None: |
|
593 | if figfile == None: | |
594 | figfile = self.getFilename(name = date) |
|
594 | figfile = self.getFilename(name = date) | |
595 |
|
595 | |||
596 | self.saveFigure(figpath, figfile) |
|
596 | self.saveFigure(figpath, figfile) | |
597 |
|
597 | |||
598 | class ProfilePlot(Figure): |
|
598 | class ProfilePlot(Figure): | |
599 | __isConfig = None |
|
599 | __isConfig = None | |
600 | __nsubplots = None |
|
600 | __nsubplots = None | |
601 |
|
601 | |||
602 | WIDTHPROF = None |
|
602 | WIDTHPROF = None | |
603 | HEIGHTPROF = None |
|
603 | HEIGHTPROF = None | |
604 | PREFIX = 'spcprofile' |
|
604 | PREFIX = 'spcprofile' | |
605 |
|
605 | |||
606 | def __init__(self): |
|
606 | def __init__(self): | |
607 | self.__isConfig = False |
|
607 | self.__isConfig = False | |
608 | self.__nsubplots = 1 |
|
608 | self.__nsubplots = 1 | |
609 |
|
609 | |||
610 | self.WIDTH = 300 |
|
610 | self.WIDTH = 300 | |
611 | self.HEIGHT = 500 |
|
611 | self.HEIGHT = 500 | |
612 |
|
612 | |||
613 | def getSubplots(self): |
|
613 | def getSubplots(self): | |
614 | ncol = 1 |
|
614 | ncol = 1 | |
615 | nrow = 1 |
|
615 | nrow = 1 | |
616 |
|
616 | |||
617 | return nrow, ncol |
|
617 | return nrow, ncol | |
618 |
|
618 | |||
619 | def setup(self, idfigure, nplots, wintitle): |
|
619 | def setup(self, idfigure, nplots, wintitle): | |
620 |
|
620 | |||
621 | self.nplots = nplots |
|
621 | self.nplots = nplots | |
622 |
|
622 | |||
623 | ncolspan = 1 |
|
623 | ncolspan = 1 | |
624 | colspan = 1 |
|
624 | colspan = 1 | |
625 |
|
625 | |||
626 | self.createFigure(idfigure = idfigure, |
|
626 | self.createFigure(idfigure = idfigure, | |
627 | wintitle = wintitle, |
|
627 | wintitle = wintitle, | |
628 | widthplot = self.WIDTH, |
|
628 | widthplot = self.WIDTH, | |
629 | heightplot = self.HEIGHT) |
|
629 | heightplot = self.HEIGHT) | |
630 |
|
630 | |||
631 | nrow, ncol = self.getSubplots() |
|
631 | nrow, ncol = self.getSubplots() | |
632 |
|
632 | |||
633 | counter = 0 |
|
633 | counter = 0 | |
634 | for y in range(nrow): |
|
634 | for y in range(nrow): | |
635 | for x in range(ncol): |
|
635 | for x in range(ncol): | |
636 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
636 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
637 |
|
637 | |||
638 | def run(self, dataOut, idfigure, wintitle="", channelList=None, |
|
638 | def run(self, dataOut, idfigure, wintitle="", channelList=None, | |
639 | xmin=None, xmax=None, ymin=None, ymax=None, |
|
639 | xmin=None, xmax=None, ymin=None, ymax=None, | |
640 | save=False, figpath='./', figfile=None): |
|
640 | save=False, figpath='./', figfile=None): | |
641 |
|
641 | |||
642 | if channelList == None: |
|
642 | if channelList == None: | |
643 | channelIndexList = dataOut.channelIndexList |
|
643 | channelIndexList = dataOut.channelIndexList | |
644 | channelList = dataOut.channelList |
|
644 | channelList = dataOut.channelList | |
645 | else: |
|
645 | else: | |
646 | channelIndexList = [] |
|
646 | channelIndexList = [] | |
647 | for channel in channelList: |
|
647 | for channel in channelList: | |
648 | if channel not in dataOut.channelList: |
|
648 | if channel not in dataOut.channelList: | |
649 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
649 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
650 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
650 | channelIndexList.append(dataOut.channelList.index(channel)) | |
651 |
|
651 | |||
652 | factor = dataOut.normFactor |
|
652 | factor = dataOut.normFactor | |
653 | y = dataOut.getHeiRange() |
|
653 | y = dataOut.getHeiRange() | |
654 | x = dataOut.data_spc[channelIndexList,:,:]/factor |
|
654 | x = dataOut.data_spc[channelIndexList,:,:]/factor | |
655 | x = numpy.where(numpy.isfinite(x), x, numpy.NAN) |
|
655 | x = numpy.where(numpy.isfinite(x), x, numpy.NAN) | |
656 | avg = numpy.average(x, axis=1) |
|
656 | avg = numpy.average(x, axis=1) | |
657 |
|
657 | |||
658 | avgdB = 10*numpy.log10(avg) |
|
658 | avgdB = 10*numpy.log10(avg) | |
659 |
|
659 | |||
660 | thisDatetime = dataOut.datatime |
|
660 | thisDatetime = dataOut.datatime | |
661 | title = "Power Profile" |
|
661 | title = "Power Profile" | |
662 | xlabel = "dB" |
|
662 | xlabel = "dB" | |
663 | ylabel = "Range (Km)" |
|
663 | ylabel = "Range (Km)" | |
664 |
|
664 | |||
665 | if not self.__isConfig: |
|
665 | if not self.__isConfig: | |
666 |
|
666 | |||
667 | nplots = 1 |
|
667 | nplots = 1 | |
668 |
|
668 | |||
669 | self.setup(idfigure=idfigure, |
|
669 | self.setup(idfigure=idfigure, | |
670 | nplots=nplots, |
|
670 | nplots=nplots, | |
671 | wintitle=wintitle) |
|
671 | wintitle=wintitle) | |
672 |
|
672 | |||
673 | if ymin == None: ymin = numpy.nanmin(y) |
|
673 | if ymin == None: ymin = numpy.nanmin(y) | |
674 | if ymax == None: ymax = numpy.nanmax(y) |
|
674 | if ymax == None: ymax = numpy.nanmax(y) | |
675 | if xmin == None: xmin = numpy.nanmin(avgdB)*0.9 |
|
675 | if xmin == None: xmin = numpy.nanmin(avgdB)*0.9 | |
676 | if xmax == None: xmax = numpy.nanmax(avgdB)*0.9 |
|
676 | if xmax == None: xmax = numpy.nanmax(avgdB)*0.9 | |
677 |
|
677 | |||
678 | self.__isConfig = True |
|
678 | self.__isConfig = True | |
679 |
|
679 | |||
680 | self.setWinTitle(title) |
|
680 | self.setWinTitle(title) | |
681 |
|
681 | |||
682 |
|
682 | |||
683 | title = "Power Profile: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
683 | title = "Power Profile: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
684 | axes = self.axesList[0] |
|
684 | axes = self.axesList[0] | |
685 |
|
685 | |||
686 | legendlabels = ["channel %d"%x for x in channelList] |
|
686 | legendlabels = ["channel %d"%x for x in channelList] | |
687 | axes.pmultiline(avgdB, y, |
|
687 | axes.pmultiline(avgdB, y, | |
688 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, |
|
688 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, | |
689 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, |
|
689 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, | |
690 | ytick_visible=True, nxticks=5, |
|
690 | ytick_visible=True, nxticks=5, | |
691 | grid='x') |
|
691 | grid='x') | |
692 |
|
692 | |||
693 | self.draw() |
|
693 | self.draw() | |
694 |
|
694 | |||
695 | if save: |
|
695 | if save: | |
696 | date = thisDatetime.strftime("%Y%m%d") |
|
696 | date = thisDatetime.strftime("%Y%m%d") | |
697 | if figfile == None: |
|
697 | if figfile == None: | |
698 | figfile = self.getFilename(name = date) |
|
698 | figfile = self.getFilename(name = date) | |
699 |
|
699 | |||
700 | self.saveFigure(figpath, figfile) |
|
700 | self.saveFigure(figpath, figfile) | |
701 |
|
701 | |||
702 | class CoherenceMap(Figure): |
|
702 | class CoherenceMap(Figure): | |
703 | __isConfig = None |
|
703 | __isConfig = None | |
704 | __nsubplots = None |
|
704 | __nsubplots = None | |
705 |
|
705 | |||
706 | WIDTHPROF = None |
|
706 | WIDTHPROF = None | |
707 | HEIGHTPROF = None |
|
707 | HEIGHTPROF = None | |
708 | PREFIX = 'cmap' |
|
708 | PREFIX = 'cmap' | |
709 |
|
709 | |||
710 | def __init__(self): |
|
710 | def __init__(self): | |
711 | self.timerange = 2*60*60 |
|
711 | self.timerange = 2*60*60 | |
712 | self.__isConfig = False |
|
712 | self.__isConfig = False | |
713 | self.__nsubplots = 1 |
|
713 | self.__nsubplots = 1 | |
714 |
|
714 | |||
715 | self.WIDTH = 800 |
|
715 | self.WIDTH = 800 | |
716 | self.HEIGHT = 150 |
|
716 | self.HEIGHT = 150 | |
717 | self.WIDTHPROF = 120 |
|
717 | self.WIDTHPROF = 120 | |
718 | self.HEIGHTPROF = 0 |
|
718 | self.HEIGHTPROF = 0 | |
719 | self.counterftp = 0 |
|
719 | self.counterftp = 0 | |
720 |
|
720 | |||
721 | def getSubplots(self): |
|
721 | def getSubplots(self): | |
722 | ncol = 1 |
|
722 | ncol = 1 | |
723 | nrow = self.nplots*2 |
|
723 | nrow = self.nplots*2 | |
724 |
|
724 | |||
725 | return nrow, ncol |
|
725 | return nrow, ncol | |
726 |
|
726 | |||
727 | def setup(self, idfigure, nplots, wintitle, showprofile=True): |
|
727 | def setup(self, idfigure, nplots, wintitle, showprofile=True): | |
728 | self.__showprofile = showprofile |
|
728 | self.__showprofile = showprofile | |
729 | self.nplots = nplots |
|
729 | self.nplots = nplots | |
730 |
|
730 | |||
731 | ncolspan = 1 |
|
731 | ncolspan = 1 | |
732 | colspan = 1 |
|
732 | colspan = 1 | |
733 | if showprofile: |
|
733 | if showprofile: | |
734 | ncolspan = 7 |
|
734 | ncolspan = 7 | |
735 | colspan = 6 |
|
735 | colspan = 6 | |
736 | self.__nsubplots = 2 |
|
736 | self.__nsubplots = 2 | |
737 |
|
737 | |||
738 | self.createFigure(idfigure = idfigure, |
|
738 | self.createFigure(idfigure = idfigure, | |
739 | wintitle = wintitle, |
|
739 | wintitle = wintitle, | |
740 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
740 | widthplot = self.WIDTH + self.WIDTHPROF, | |
741 | heightplot = self.HEIGHT + self.HEIGHTPROF) |
|
741 | heightplot = self.HEIGHT + self.HEIGHTPROF) | |
742 |
|
742 | |||
743 | nrow, ncol = self.getSubplots() |
|
743 | nrow, ncol = self.getSubplots() | |
744 |
|
744 | |||
745 | for y in range(nrow): |
|
745 | for y in range(nrow): | |
746 | for x in range(ncol): |
|
746 | for x in range(ncol): | |
747 |
|
747 | |||
748 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
748 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
749 |
|
749 | |||
750 | if showprofile: |
|
750 | if showprofile: | |
751 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
751 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
752 |
|
752 | |||
753 | def run(self, dataOut, idfigure, wintitle="", pairsList=None, showprofile='True', |
|
753 | def run(self, dataOut, idfigure, wintitle="", pairsList=None, showprofile='True', | |
754 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
754 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
755 | timerange=None, |
|
755 | timerange=None, | |
756 | save=False, figpath='./', figfile=None, ftp=False, ftpratio=1, |
|
756 | save=False, figpath='./', figfile=None, ftp=False, ftpratio=1, | |
757 | coherence_cmap='jet', phase_cmap='RdBu_r'): |
|
757 | coherence_cmap='jet', phase_cmap='RdBu_r'): | |
758 |
|
758 | |||
759 | if pairsList == None: |
|
759 | if pairsList == None: | |
760 | pairsIndexList = dataOut.pairsIndexList |
|
760 | pairsIndexList = dataOut.pairsIndexList | |
761 | else: |
|
761 | else: | |
762 | pairsIndexList = [] |
|
762 | pairsIndexList = [] | |
763 | for pair in pairsList: |
|
763 | for pair in pairsList: | |
764 | if pair not in dataOut.pairsList: |
|
764 | if pair not in dataOut.pairsList: | |
765 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) |
|
765 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) | |
766 | pairsIndexList.append(dataOut.pairsList.index(pair)) |
|
766 | pairsIndexList.append(dataOut.pairsList.index(pair)) | |
767 |
|
767 | |||
768 | if timerange != None: |
|
768 | if timerange != None: | |
769 | self.timerange = timerange |
|
769 | self.timerange = timerange | |
770 |
|
770 | |||
771 | if pairsIndexList == []: |
|
771 | if pairsIndexList == []: | |
772 | return |
|
772 | return | |
773 |
|
773 | |||
774 | if len(pairsIndexList) > 4: |
|
774 | if len(pairsIndexList) > 4: | |
775 | pairsIndexList = pairsIndexList[0:4] |
|
775 | pairsIndexList = pairsIndexList[0:4] | |
776 |
|
776 | |||
777 | tmin = None |
|
777 | tmin = None | |
778 | tmax = None |
|
778 | tmax = None | |
779 | x = dataOut.getTimeRange() |
|
779 | x = dataOut.getTimeRange() | |
780 | y = dataOut.getHeiRange() |
|
780 | y = dataOut.getHeiRange() | |
781 |
|
781 | |||
782 | thisDatetime = dataOut.datatime |
|
782 | thisDatetime = dataOut.datatime | |
783 | title = "CoherenceMap: %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
783 | title = "CoherenceMap: %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
784 | xlabel = "" |
|
784 | xlabel = "" | |
785 | ylabel = "Range (Km)" |
|
785 | ylabel = "Range (Km)" | |
786 |
|
786 | |||
787 | if not self.__isConfig: |
|
787 | if not self.__isConfig: | |
788 | nplots = len(pairsIndexList) |
|
788 | nplots = len(pairsIndexList) | |
789 | self.setup(idfigure=idfigure, |
|
789 | self.setup(idfigure=idfigure, | |
790 | nplots=nplots, |
|
790 | nplots=nplots, | |
791 | wintitle=wintitle, |
|
791 | wintitle=wintitle, | |
792 | showprofile=showprofile) |
|
792 | showprofile=showprofile) | |
793 |
|
793 | |||
794 | tmin, tmax = self.getTimeLim(x, xmin, xmax) |
|
794 | tmin, tmax = self.getTimeLim(x, xmin, xmax) | |
795 | if ymin == None: ymin = numpy.nanmin(y) |
|
795 | if ymin == None: ymin = numpy.nanmin(y) | |
796 | if ymax == None: ymax = numpy.nanmax(y) |
|
796 | if ymax == None: ymax = numpy.nanmax(y) | |
797 |
|
797 | |||
798 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
798 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
799 |
|
799 | |||
800 | self.__isConfig = True |
|
800 | self.__isConfig = True | |
801 |
|
801 | |||
802 | self.setWinTitle(title) |
|
802 | self.setWinTitle(title) | |
803 |
|
803 | |||
804 | for i in range(self.nplots): |
|
804 | for i in range(self.nplots): | |
805 |
|
805 | |||
806 | pair = dataOut.pairsList[pairsIndexList[i]] |
|
806 | pair = dataOut.pairsList[pairsIndexList[i]] | |
807 | coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:]) |
|
807 | coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:]) | |
808 | avgcoherenceComplex = numpy.average(coherenceComplex, axis=0) |
|
808 | avgcoherenceComplex = numpy.average(coherenceComplex, axis=0) | |
809 | coherence = numpy.abs(avgcoherenceComplex) |
|
809 | coherence = numpy.abs(avgcoherenceComplex) | |
810 | # coherence = numpy.abs(coherenceComplex) |
|
810 | # coherence = numpy.abs(coherenceComplex) | |
811 | # avg = numpy.average(coherence, axis=0) |
|
811 | # avg = numpy.average(coherence, axis=0) | |
812 |
|
812 | |||
813 | z = coherence.reshape((1,-1)) |
|
813 | z = coherence.reshape((1,-1)) | |
814 |
|
814 | |||
815 | counter = 0 |
|
815 | counter = 0 | |
816 |
|
816 | |||
817 | title = "Coherence %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
817 | title = "Coherence %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
818 | axes = self.axesList[i*self.__nsubplots*2] |
|
818 | axes = self.axesList[i*self.__nsubplots*2] | |
819 | axes.pcolor(x, y, z, |
|
819 | axes.pcolorbuffer(x, y, z, | |
820 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1, |
|
820 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1, | |
821 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
821 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
822 | ticksize=9, cblabel='', colormap=coherence_cmap, cbsize="1%") |
|
822 | ticksize=9, cblabel='', colormap=coherence_cmap, cbsize="1%") | |
823 |
|
823 | |||
824 | if self.__showprofile: |
|
824 | if self.__showprofile: | |
825 | counter += 1 |
|
825 | counter += 1 | |
826 | axes = self.axesList[i*self.__nsubplots*2 + counter] |
|
826 | axes = self.axesList[i*self.__nsubplots*2 + counter] | |
827 | axes.pline(coherence, y, |
|
827 | axes.pline(coherence, y, | |
828 | xmin=0, xmax=1, ymin=ymin, ymax=ymax, |
|
828 | xmin=0, xmax=1, ymin=ymin, ymax=ymax, | |
829 | xlabel='', ylabel='', title='', ticksize=7, |
|
829 | xlabel='', ylabel='', title='', ticksize=7, | |
830 | ytick_visible=False, nxticks=5, |
|
830 | ytick_visible=False, nxticks=5, | |
831 | grid='x') |
|
831 | grid='x') | |
832 |
|
832 | |||
833 | counter += 1 |
|
833 | counter += 1 | |
834 | # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi |
|
834 | # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi | |
835 | phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi |
|
835 | phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi | |
836 | # avg = numpy.average(phase, axis=0) |
|
836 | # avg = numpy.average(phase, axis=0) | |
837 | z = phase.reshape((1,-1)) |
|
837 | z = phase.reshape((1,-1)) | |
838 |
|
838 | |||
839 | title = "Phase %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
839 | title = "Phase %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
840 | axes = self.axesList[i*self.__nsubplots*2 + counter] |
|
840 | axes = self.axesList[i*self.__nsubplots*2 + counter] | |
841 | axes.pcolor(x, y, z, |
|
841 | axes.pcolorbuffer(x, y, z, | |
842 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180, |
|
842 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180, | |
843 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
843 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
844 | ticksize=9, cblabel='', colormap=phase_cmap, cbsize="1%") |
|
844 | ticksize=9, cblabel='', colormap=phase_cmap, cbsize="1%") | |
845 |
|
845 | |||
846 | if self.__showprofile: |
|
846 | if self.__showprofile: | |
847 | counter += 1 |
|
847 | counter += 1 | |
848 | axes = self.axesList[i*self.__nsubplots*2 + counter] |
|
848 | axes = self.axesList[i*self.__nsubplots*2 + counter] | |
849 | axes.pline(phase, y, |
|
849 | axes.pline(phase, y, | |
850 | xmin=-180, xmax=180, ymin=ymin, ymax=ymax, |
|
850 | xmin=-180, xmax=180, ymin=ymin, ymax=ymax, | |
851 | xlabel='', ylabel='', title='', ticksize=7, |
|
851 | xlabel='', ylabel='', title='', ticksize=7, | |
852 | ytick_visible=False, nxticks=4, |
|
852 | ytick_visible=False, nxticks=4, | |
853 | grid='x') |
|
853 | grid='x') | |
854 |
|
854 | |||
855 | self.draw() |
|
855 | self.draw() | |
856 |
|
856 | |||
857 | if save: |
|
857 | if save: | |
858 |
|
858 | |||
859 | if figfile == None: |
|
859 | if figfile == None: | |
860 | figfile = self.getFilename(name = self.name) |
|
860 | figfile = self.getFilename(name = self.name) | |
861 |
|
861 | |||
862 | self.saveFigure(figpath, figfile) |
|
862 | self.saveFigure(figpath, figfile) | |
863 |
|
863 | |||
864 | self.counterftp += 1 |
|
864 | self.counterftp += 1 | |
865 | if (ftp and (self.counterftp==ftpratio)): |
|
865 | if (ftp and (self.counterftp==ftpratio)): | |
866 | figfilename = os.path.join(figpath,figfile) |
|
866 | figfilename = os.path.join(figpath,figfile) | |
867 | self.sendByFTP(figfilename) |
|
867 | self.sendByFTP(figfilename) | |
868 | self.counterftp = 0 |
|
868 | self.counterftp = 0 | |
869 |
|
869 | |||
870 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: |
|
870 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: | |
871 | self.__isConfig = False |
|
871 | self.__isConfig = False | |
872 |
|
872 | |||
873 | class RTIfromNoise(Figure): |
|
873 | class RTIfromNoise(Figure): | |
874 |
|
874 | |||
875 | __isConfig = None |
|
875 | __isConfig = None | |
876 | __nsubplots = None |
|
876 | __nsubplots = None | |
877 |
|
877 | |||
878 | PREFIX = 'rtinoise' |
|
878 | PREFIX = 'rtinoise' | |
879 |
|
879 | |||
880 | def __init__(self): |
|
880 | def __init__(self): | |
881 |
|
881 | |||
882 | self.timerange = 24*60*60 |
|
882 | self.timerange = 24*60*60 | |
883 | self.__isConfig = False |
|
883 | self.__isConfig = False | |
884 | self.__nsubplots = 1 |
|
884 | self.__nsubplots = 1 | |
885 |
|
885 | |||
886 | self.WIDTH = 820 |
|
886 | self.WIDTH = 820 | |
887 | self.HEIGHT = 200 |
|
887 | self.HEIGHT = 200 | |
888 | self.WIDTHPROF = 120 |
|
888 | self.WIDTHPROF = 120 | |
889 | self.HEIGHTPROF = 0 |
|
889 | self.HEIGHTPROF = 0 | |
890 | self.xdata = None |
|
890 | self.xdata = None | |
891 | self.ydata = None |
|
891 | self.ydata = None | |
892 |
|
892 | |||
893 | def getSubplots(self): |
|
893 | def getSubplots(self): | |
894 |
|
894 | |||
895 | ncol = 1 |
|
895 | ncol = 1 | |
896 | nrow = 1 |
|
896 | nrow = 1 | |
897 |
|
897 | |||
898 | return nrow, ncol |
|
898 | return nrow, ncol | |
899 |
|
899 | |||
900 | def setup(self, idfigure, nplots, wintitle, showprofile=True): |
|
900 | def setup(self, idfigure, nplots, wintitle, showprofile=True): | |
901 |
|
901 | |||
902 | self.__showprofile = showprofile |
|
902 | self.__showprofile = showprofile | |
903 | self.nplots = nplots |
|
903 | self.nplots = nplots | |
904 |
|
904 | |||
905 | ncolspan = 7 |
|
905 | ncolspan = 7 | |
906 | colspan = 6 |
|
906 | colspan = 6 | |
907 | self.__nsubplots = 2 |
|
907 | self.__nsubplots = 2 | |
908 |
|
908 | |||
909 | self.createFigure(idfigure = idfigure, |
|
909 | self.createFigure(idfigure = idfigure, | |
910 | wintitle = wintitle, |
|
910 | wintitle = wintitle, | |
911 | widthplot = self.WIDTH+self.WIDTHPROF, |
|
911 | widthplot = self.WIDTH+self.WIDTHPROF, | |
912 | heightplot = self.HEIGHT+self.HEIGHTPROF) |
|
912 | heightplot = self.HEIGHT+self.HEIGHTPROF) | |
913 |
|
913 | |||
914 | nrow, ncol = self.getSubplots() |
|
914 | nrow, ncol = self.getSubplots() | |
915 |
|
915 | |||
916 | self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1) |
|
916 | self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1) | |
917 |
|
917 | |||
918 |
|
918 | |||
919 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', |
|
919 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', | |
920 | xmin=None, xmax=None, ymin=None, ymax=None, |
|
920 | xmin=None, xmax=None, ymin=None, ymax=None, | |
921 | timerange=None, |
|
921 | timerange=None, | |
922 | save=False, figpath='./', figfile=None): |
|
922 | save=False, figpath='./', figfile=None): | |
923 |
|
923 | |||
924 | if channelList == None: |
|
924 | if channelList == None: | |
925 | channelIndexList = dataOut.channelIndexList |
|
925 | channelIndexList = dataOut.channelIndexList | |
926 | channelList = dataOut.channelList |
|
926 | channelList = dataOut.channelList | |
927 | else: |
|
927 | else: | |
928 | channelIndexList = [] |
|
928 | channelIndexList = [] | |
929 | for channel in channelList: |
|
929 | for channel in channelList: | |
930 | if channel not in dataOut.channelList: |
|
930 | if channel not in dataOut.channelList: | |
931 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
931 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
932 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
932 | channelIndexList.append(dataOut.channelList.index(channel)) | |
933 |
|
933 | |||
934 | if timerange != None: |
|
934 | if timerange != None: | |
935 | self.timerange = timerange |
|
935 | self.timerange = timerange | |
936 |
|
936 | |||
937 | tmin = None |
|
937 | tmin = None | |
938 | tmax = None |
|
938 | tmax = None | |
939 | x = dataOut.getTimeRange() |
|
939 | x = dataOut.getTimeRange() | |
940 | y = dataOut.getHeiRange() |
|
940 | y = dataOut.getHeiRange() | |
941 | factor = dataOut.normFactor |
|
941 | factor = dataOut.normFactor | |
942 | noise = dataOut.getNoise()/factor |
|
942 | noise = dataOut.getNoise()/factor | |
943 | noisedB = 10*numpy.log10(noise) |
|
943 | noisedB = 10*numpy.log10(noise) | |
944 |
|
944 | |||
945 | thisDatetime = dataOut.datatime |
|
945 | thisDatetime = dataOut.datatime | |
946 | title = "RTI Noise: %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
946 | title = "RTI Noise: %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
947 | xlabel = "" |
|
947 | xlabel = "" | |
948 | ylabel = "Range (Km)" |
|
948 | ylabel = "Range (Km)" | |
949 |
|
949 | |||
950 | if not self.__isConfig: |
|
950 | if not self.__isConfig: | |
951 |
|
951 | |||
952 | nplots = 1 |
|
952 | nplots = 1 | |
953 |
|
953 | |||
954 | self.setup(idfigure=idfigure, |
|
954 | self.setup(idfigure=idfigure, | |
955 | nplots=nplots, |
|
955 | nplots=nplots, | |
956 | wintitle=wintitle, |
|
956 | wintitle=wintitle, | |
957 | showprofile=showprofile) |
|
957 | showprofile=showprofile) | |
958 |
|
958 | |||
959 | tmin, tmax = self.getTimeLim(x, xmin, xmax) |
|
959 | tmin, tmax = self.getTimeLim(x, xmin, xmax) | |
960 | if ymin == None: ymin = numpy.nanmin(noisedB) |
|
960 | if ymin == None: ymin = numpy.nanmin(noisedB) | |
961 | if ymax == None: ymax = numpy.nanmax(noisedB) |
|
961 | if ymax == None: ymax = numpy.nanmax(noisedB) | |
962 |
|
962 | |||
963 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
963 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
964 | self.__isConfig = True |
|
964 | self.__isConfig = True | |
965 |
|
965 | |||
966 | self.xdata = numpy.array([]) |
|
966 | self.xdata = numpy.array([]) | |
967 | self.ydata = numpy.array([]) |
|
967 | self.ydata = numpy.array([]) | |
968 |
|
968 | |||
969 | self.setWinTitle(title) |
|
969 | self.setWinTitle(title) | |
970 |
|
970 | |||
971 |
|
971 | |||
972 | title = "RTI Noise %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
972 | title = "RTI Noise %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
973 |
|
973 | |||
974 | legendlabels = ["channel %d"%idchannel for idchannel in channelList] |
|
974 | legendlabels = ["channel %d"%idchannel for idchannel in channelList] | |
975 | axes = self.axesList[0] |
|
975 | axes = self.axesList[0] | |
976 |
|
976 | |||
977 | self.xdata = numpy.hstack((self.xdata, x[0:1])) |
|
977 | self.xdata = numpy.hstack((self.xdata, x[0:1])) | |
978 |
|
978 | |||
979 | if len(self.ydata)==0: |
|
979 | if len(self.ydata)==0: | |
980 | self.ydata = noisedB[channelIndexList].reshape(-1,1) |
|
980 | self.ydata = noisedB[channelIndexList].reshape(-1,1) | |
981 | else: |
|
981 | else: | |
982 | self.ydata = numpy.hstack((self.ydata, noisedB[channelIndexList].reshape(-1,1))) |
|
982 | self.ydata = numpy.hstack((self.ydata, noisedB[channelIndexList].reshape(-1,1))) | |
983 |
|
983 | |||
984 |
|
984 | |||
985 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, |
|
985 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, | |
986 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, |
|
986 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, | |
987 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid", |
|
987 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid", | |
988 | XAxisAsTime=True |
|
988 | XAxisAsTime=True | |
989 | ) |
|
989 | ) | |
990 |
|
990 | |||
991 | self.draw() |
|
991 | self.draw() | |
992 |
|
992 | |||
993 | if save: |
|
993 | if save: | |
994 |
|
994 | |||
995 | if figfile == None: |
|
995 | if figfile == None: | |
996 | figfile = self.getFilename(name = self.name) |
|
996 | figfile = self.getFilename(name = self.name) | |
997 |
|
997 | |||
998 | self.saveFigure(figpath, figfile) |
|
998 | self.saveFigure(figpath, figfile) | |
999 |
|
999 | |||
1000 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: |
|
1000 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: | |
1001 | self.__isConfig = False |
|
1001 | self.__isConfig = False | |
1002 | del self.xdata |
|
1002 | del self.xdata | |
1003 | del self.ydata |
|
1003 | del self.ydata | |
1004 | No newline at end of file |
|
1004 |
General Comments 0
You need to be logged in to leave comments.
Login now