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