@@ -606,6 +606,8 if __name__ == '__main__': | |||
|
606 | 606 | # opObj11.addParameter(name='zmin', value='70', format='int') |
|
607 | 607 | # opObj11.addParameter(name='zmax', value='90', format='int') |
|
608 | 608 | opObj11.addParameter(name='showprofile', value='0', format='int') |
|
609 | opObj11.addParameter(name='save', value='1', format='int') | |
|
610 | opObj11.addParameter(name='filename', value='/Users/dsuarez/Pictures/SpectraPlot.png', format='str') | |
|
609 | 611 | |
|
610 | 612 | opObj11 = procUnitConfObj1.addOperation(name='RTIPlot', optype='other') |
|
611 | 613 | opObj11.addParameter(name='idfigure', value='10', format='int') |
@@ -104,6 +104,9 class Figure: | |||
|
104 | 104 | axesObj = Axes(self.fig, *args) |
|
105 | 105 | self.axesObjList.append(axesObj) |
|
106 | 106 | |
|
107 | def saveFigure(self, *args): | |
|
108 | self.__driver.saveFigure(self.fig, *args) | |
|
109 | ||
|
107 | 110 | def draw(self): |
|
108 | 111 | |
|
109 | 112 | self.__driver.draw(self.fig) |
@@ -149,6 +152,9 class Axes: | |||
|
149 | 152 | |
|
150 | 153 | self.__driver.setAxesText(self.ax, text) |
|
151 | 154 | |
|
155 | def setXAxisAsTime(self): | |
|
156 | pass | |
|
157 | ||
|
152 | 158 | def pline(self, x, y, |
|
153 | 159 | xmin=None, xmax=None, |
|
154 | 160 | ymin=None, ymax=None, |
@@ -1,10 +1,14 | |||
|
1 | 1 | import numpy |
|
2 | import datetime | |
|
2 | 3 | import matplotlib |
|
3 | 4 | matplotlib.use("TKAgg") |
|
4 | 5 | import matplotlib.pyplot |
|
6 | import matplotlib.dates | |
|
5 | 7 | #import scitools.numpyutils |
|
6 | 8 | from mpl_toolkits.axes_grid1 import make_axes_locatable |
|
7 | 9 | |
|
10 | from matplotlib.dates import DayLocator, HourLocator, MinuteLocator, SecondLocator, DateFormatter | |
|
11 | ||
|
8 | 12 | def init(idfigure, wintitle, width, height, facecolor="w"): |
|
9 | 13 | |
|
10 | 14 | matplotlib.pyplot.ioff() |
@@ -109,6 +113,9 def closeFigure(): | |||
|
109 | 113 | |
|
110 | 114 | return |
|
111 | 115 | |
|
116 | def saveFigure(fig, filename): | |
|
117 | fig.savefig(filename) | |
|
118 | ||
|
112 | 119 | def setWinTitle(fig, title): |
|
113 | 120 | |
|
114 | 121 | fig.canvas.manager.set_window_title(title) |
@@ -193,7 +200,7 def pline(iplot, x, y, xlabel='', ylabel='', title=''): | |||
|
193 | 200 | |
|
194 | 201 | iplot.set_data(x, y) |
|
195 | 202 | |
|
196 | def createPcolor(ax, x, y, z, xmin, xmax, ymin, ymax, zmin, zmax, xlabel='', ylabel='', title='', ticksize = 9, cblabel=''): | |
|
203 | def createPcolor(ax, x, y, z, xmin, xmax, ymin, ymax, zmin, zmax, xlabel='', ylabel='', title='', ticksize = 9, cblabel='',XAxisAsTime=False): | |
|
197 | 204 | |
|
198 | 205 | divider = make_axes_locatable(ax) |
|
199 | 206 | ax_cb = divider.new_horizontal(size="4%", pad=0.05) |
@@ -201,6 +208,19 def createPcolor(ax, x, y, z, xmin, xmax, ymin, ymax, zmin, zmax, xlabel='', yla | |||
|
201 | 208 | fig.add_axes(ax_cb) |
|
202 | 209 | |
|
203 | 210 | ax.set_xlim([xmin,xmax]) |
|
211 | ||
|
212 | if XAxisAsTime: | |
|
213 | seconds = numpy.array([xmin, xmax]) | |
|
214 | datesList = map(datetime.datetime.fromtimestamp, seconds) | |
|
215 | ax.set_xlim([datesList[0],datesList[-1]]) | |
|
216 | ax.xaxis.set_major_locator(MinuteLocator(numpy.arange(0,61,10))) | |
|
217 | ax.xaxis.set_minor_locator(SecondLocator(numpy.arange(0,61,60))) | |
|
218 | ax.xaxis.set_major_formatter(DateFormatter("%H:%M:%S")) | |
|
219 | xdateList = map(datetime.datetime.fromtimestamp, x) | |
|
220 | xdate = matplotlib.dates.date2num(xdateList) | |
|
221 | x = xdate | |
|
222 | ||
|
223 | ||
|
204 | 224 | ax.set_ylim([ymin,ymax]) |
|
205 | 225 | |
|
206 | 226 | printLabels(ax, xlabel, ylabel, title) |
@@ -239,8 +259,10 def pcolor(imesh, z, xlabel='', ylabel='', title=''): | |||
|
239 | 259 | imesh.set_array(z.ravel()) |
|
240 | 260 | |
|
241 | 261 | def addpcolor(ax, x, y, z, zmin, zmax): |
|
262 | xdateList = map(datetime.datetime.fromtimestamp, x) | |
|
263 | xdate = matplotlib.dates.date2num(xdateList) | |
|
242 | 264 | |
|
243 | imesh = ax.pcolormesh(x,y,z.T,vmin=zmin,vmax=zmax) | |
|
265 | imesh = ax.pcolormesh(xdate,y,z.T,vmin=zmin,vmax=zmax) | |
|
244 | 266 | |
|
245 | 267 | def draw(fig): |
|
246 | 268 |
@@ -61,7 +61,7 class RTIPlot(Figure): | |||
|
61 | 61 | counter += 1 |
|
62 | 62 | |
|
63 | 63 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', |
|
64 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None): | |
|
64 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, save=False, filename=None): | |
|
65 | 65 | |
|
66 | 66 | """ |
|
67 | 67 | |
@@ -126,7 +126,7 class RTIPlot(Figure): | |||
|
126 | 126 | z = avg[i].reshape((1,-1)) |
|
127 | 127 | axes.pcolor(x, y, z, |
|
128 | 128 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
129 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, | |
|
129 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
|
130 | 130 | ticksize=9, cblabel='') |
|
131 | 131 | |
|
132 | 132 | if self.__showprofile: |
@@ -139,6 +139,9 class RTIPlot(Figure): | |||
|
139 | 139 | |
|
140 | 140 | self.draw() |
|
141 | 141 | |
|
142 | if save: | |
|
143 | self.saveFigure(filename) | |
|
144 | ||
|
142 | 145 | class SpectraPlot(Figure): |
|
143 | 146 | |
|
144 | 147 | __isConfig = None |
@@ -197,7 +200,7 class SpectraPlot(Figure): | |||
|
197 | 200 | counter += 1 |
|
198 | 201 | |
|
199 | 202 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', |
|
200 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None): | |
|
203 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, save=False, filename=None): | |
|
201 | 204 | |
|
202 | 205 | """ |
|
203 | 206 | |
@@ -273,6 +276,9 class SpectraPlot(Figure): | |||
|
273 | 276 | grid='x') |
|
274 | 277 | |
|
275 | 278 | self.draw() |
|
279 | ||
|
280 | if save: | |
|
281 | self.saveFigure(filename) | |
|
276 | 282 | |
|
277 | 283 | class Scope(Figure): |
|
278 | 284 | |
@@ -304,7 +310,7 class Scope(Figure): | |||
|
304 | 310 | self.nplots = nplots |
|
305 | 311 | |
|
306 | 312 | def run(self, dataOut, idfigure, wintitle="", channelList=None, |
|
307 | xmin=None, xmax=None, ymin=None, ymax=None): | |
|
313 | xmin=None, xmax=None, ymin=None, ymax=None, save=False, filename=None): | |
|
308 | 314 | |
|
309 | 315 | """ |
|
310 | 316 | |
@@ -360,5 +366,6 class Scope(Figure): | |||
|
360 | 366 | |
|
361 | 367 | self.draw() |
|
362 | 368 | |
|
363 | ||
|
369 | if save: | |
|
370 | self.saveFigure(filename) | |
|
364 | 371 | No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now