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