Changeset 2451
- Timestamp:
- 03/30/12 19:58:59 (13 years ago)
- Location:
- trunk/python
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/asapfitter.py
r2409 r2451 544 544 return 545 545 if not self._p or self._p.is_dead: 546 #if rcParams['plotter.gui']:547 # from asap.asaplotgui import asaplotgui as asaplot548 #else:549 # from asap.asaplot import asaplot550 #self._p = asaplot()551 546 from asap.asapplotter import new_asaplot 547 del self._p 552 548 self._p = new_asaplot(rcParams['plotter.gui']) 553 549 self._p.hold() -
trunk/python/asaplot.py
r2146 r2451 7 7 from matplotlib.backends.backend_agg import FigureCanvasAgg 8 8 from matplotlib.backend_bases import FigureManagerBase 9 from matplotlib import _pylab_helpers 9 10 10 11 class asaplot(asaplotbase): … … 22 23 del v['self'] 23 24 asaplotbase.__init__(self,**v) 25 _pylab_helpers.Gcf.destroy(0) 26 self.window = None 24 27 self.canvas = FigureCanvasAgg(self.figure) 25 28 self.figmgr = FigureManagerBase(self.canvas,1) 29 _pylab_helpers.Gcf.figs[self.figmgr.num] = self.figmgr 26 30 27 31 def map(self): -
trunk/python/asaplotbase.py
r2169 r2451 82 82 83 83 self.buffering = buffering 84 85 self.events = {'button_press':None, 86 'button_release':None, 87 'motion_notify':None} 84 88 85 89 def clear(self): … … 554 558 555 559 The set_* methods of class Line2D define the attribute names and 556 values. For non-US usage, "colour"is recognized as synonymous with557 "color".560 values. For non-US usage, 'colour' is recognized as synonymous with 561 'color'. 558 562 559 563 Set the value to None to delete an attribute. -
trunk/python/asaplotgui.py
r2416 r2451 11 11 matplotlib.rcParams['toolbar'] = 'toolbar2' 12 12 from matplotlib import _pylab_helpers 13 from asap.logging import asaplog, asaplog_post_dec 13 14 14 15 class asaplotgui(asaplotbase): … … 28 29 29 30 asaplotbase.__init__(self, **v) 31 #matplotlib.rcParams["interactive"] = True 32 33 _pylab_helpers.Gcf.destroy(0) 30 34 self.window = Tk.Tk() 31 #def dest_callback():32 # print "dest_callback"33 # self.is_dead = True34 # self.window.destroy()35 36 35 self.window.protocol("WM_DELETE_WINDOW", self.quit) 37 36 self.canvas = FigureCanvasTkAgg(self.figure, master=self.window) … … 43 42 _pylab_helpers.Gcf.figs[self.figmgr.num] = self.figmgr 44 43 self._set_window_title('ASAP Plotter - Tk') 44 self.canvas.show() 45 45 46 self.events = {'button_press':None,47 'button_release':None,48 'motion_notify':None}49 50 matplotlib.rcParams["interactive"] = True51 #self.buffering = buffering52 53 self.canvas.show()54 46 55 47 def map(self): … … 58 50 window stack. 59 51 """ 52 if self.is_dead: 53 raise RuntimeError( "No plotter to show. Not yet plotted or plotter is closed." ) 60 54 self.window.wm_deiconify() 61 55 self.window.lift() … … 66 60 """ 67 61 self.is_dead = True 62 if not self.figmgr: 63 return 68 64 #self.window.destroy() 69 65 _pylab_helpers.Gcf.destroy(self.figmgr.num) 70 del self.window, self.canvas 66 del self.window, self.canvas, self.figmgr 71 67 self.window = None 72 68 self.canvas = None 73 69 self.figmgr = None 74 70 75 71 def show(self, hardrefresh=True): … … 77 73 Show graphics dependent on the current buffering state. 78 74 """ 75 if self.is_dead: 76 raise RuntimeError( "No plotter to show (not yet plotted or closed)." ) 79 77 if not self.buffering: 80 78 if hardrefresh: … … 87 85 Clear the figure. 88 86 """ 87 if not self.window: 88 asaplog.push( "No plotter window to terminate." ) 89 asaplog.post( "WARN" ) 90 return 89 91 self.window.destroy() 90 92 … … 93 95 Hide the ASAPlot graphics window. 94 96 """ 97 if not self.window: 98 asaplog.push( "No plotter window to unmap." ) 99 asaplog.post( "WARN" ) 100 return 95 101 self.window.wm_withdraw() 96 102 -
trunk/python/asaplotgui_gtk.py
r1819 r2451 12 12 matplotlib.rcParams['toolbar'] = 'toolbar2' 13 13 from matplotlib.backends.backend_gtk import NavigationToolbar2GTK as NavigationToolbar 14 from matplotlib import _pylab_helpers 14 15 15 16 class asaplotgui(asaplotbase): … … 29 30 30 31 asaplotbase.__init__(self, **v) 32 matplotlib.rcParams['interactive'] = True 31 33 matplotlib.interactive = True 34 35 _pylab_helpers.Gcf.destroy(0) 32 36 self.canvas = FigureCanvas(self.figure) 33 37 # Simply instantiating this is enough to get a working toolbar. … … 39 43 self.window.connect("destroy", dest_callback ) 40 44 self.window.set_title('ASAP Plotter - GTK') 41 self.events = {'button_press':None,42 'button_release':None,43 'motion_notify':None}44 45 self.buffering = buffering46 matplotlib.rcParams['interactive'] = True47 45 #self.canvas.set_size_request(800,600) 46 _pylab_helpers.Gcf.figs[self.figmgr.num] = self.figmgr 48 47 49 48 #self.canvas.show() … … 54 53 window stack. 55 54 """ 55 if self.is_dead: 56 raise RuntimeError( "No plotter to show. Not yet plotted or plotter is closed." ) 56 57 self.window.deiconify() 57 58 #self.window.lift() 58 59 # def position(self):60 # """61 # Use the mouse to get a position from a graph.62 # """63 64 # def position_disable(event):65 # self.register('button_press', None)66 # print '%.4f, %.4f' % (event.xdata, event.ydata)67 68 # print 'Press any mouse button...'69 # self.register('button_press', position_disable)70 71 59 72 60 def quit(self): … … 74 62 Destroy the ASAPlot graphics window. 75 63 """ 76 self.window.destroy() 77 78 79 # def region(self): 80 # """ 81 # Use the mouse to get a rectangular region from a plot. 82 83 # The return value is [x0, y0, x1, y1] in world coordinates. 84 # """ 85 86 # def region_start(event): 87 # height = self.canvas.figure.bbox.height() 88 # self.rect = {'fig': None, 'height': height, 89 # 'x': event.x, 'y': height - event.y, 90 # 'world': [event.xdata, event.ydata, 91 # event.xdata, event.ydata]} 92 # self.register('button_press', None) 93 # self.register('motion_notify', region_draw) 94 # self.register('button_release', region_disable) 95 96 # def region_draw(event): 97 # self.canvas._tkcanvas.delete(self.rect['fig']) 98 # self.rect['fig'] = self.canvas._tkcanvas.create_rectangle( 99 # self.rect['x'], self.rect['y'], 100 # event.x, self.rect['height'] - event.y) 101 102 # def region_disable(event): 103 # self.register('motion_notify', None) 104 # self.register('button_release', None) 105 106 # self.canvas._tkcanvas.delete(self.rect['fig']) 107 108 # self.rect['world'][2:4] = [event.xdata, event.ydata] 109 # print '(%.2f, %.2f) (%.2f, %.2f)' % (self.rect['world'][0], 110 # self.rect['world'][1], self.rect['world'][2], 111 # self.rect['world'][3]) 112 113 # self.register('button_press', region_start) 114 115 # # This has to be modified to block and return the result (currently 116 # # printed by region_disable) when that becomes possible in matplotlib. 117 118 # return [0.0, 0.0, 0.0, 0.0] 119 120 121 # def register(self, type=None, func=None): 122 # """ 123 # Register, reregister, or deregister events of type 'button_press', 124 # 'button_release', or 'motion_notify'. 125 126 # The specified callback function should have the following signature: 127 128 # def func(event) 129 130 # where event is an MplEvent instance containing the following data: 131 132 # name # Event name. 133 # canvas # FigureCanvas instance generating the event. 134 # x = None # x position - pixels from left of canvas. 135 # y = None # y position - pixels from bottom of canvas. 136 # button = None # Button pressed: None, 1, 2, 3. 137 # key = None # Key pressed: None, chr(range(255)), shift, 138 # win, or control 139 # inaxes = None # Axes instance if cursor within axes. 140 # xdata = None # x world coordinate. 141 # ydata = None # y world coordinate. 142 143 # For example: 144 145 # def mouse_move(event): 146 # print event.xdata, event.ydata 147 148 # a = asaplot() 149 # a.register('motion_notify', mouse_move) 150 151 # If func is None, the event is deregistered. 152 153 # Note that in TkAgg keyboard button presses don't generate an event. 154 # """ 155 156 # if not self.events.has_key(type): return 157 158 # if func is None: 159 # if self.events[type] is not None: 160 # # It's not clear that this does anything. 161 # self.canvas.mpl_disconnect(self.events[type]) 162 # self.events[type] = None 163 164 # # It seems to be necessary to return events to the toolbar. 165 # if type == 'motion_notify': 166 # self.canvas.mpl_connect(type + '_event', 167 # self.figmgr.toolbar.mouse_move) 168 # elif type == 'button_press': 169 # self.canvas.mpl_connect(type + '_event', 170 # self.figmgr.toolbar.press) 171 # elif type == 'button_release': 172 # self.canvas.mpl_connect(type + '_event', 173 # self.figmgr.toolbar.release) 174 175 # else: 176 # self.events[type] = self.canvas.mpl_connect(type + '_event', func) 177 64 self.is_dead = True 65 if not self.figmgr: 66 return 67 #self.window.destroy() 68 _pylab_helpers.Gcf.destroy(self.figmgr.num) 69 del self.window, self.canvas, self.figmgr 70 self.window = None 71 self.canvas = None 72 self.figmgr = None 178 73 179 74 def show(self, hardrefresh=True): … … 181 76 Show graphics dependent on the current buffering state. 182 77 """ 78 if self.is_dead: 79 raise RuntimeError( "No plotter to show (not yet plotted or closed)." ) 183 80 if not self.buffering: 184 81 if hardrefresh: … … 192 89 Clear the figure. 193 90 """ 91 if not self.window: 92 asaplog.push( "No plotter window to terminate." ) 93 asaplog.post( "WARN" ) 94 return 194 95 self.window.destroy() 195 96 … … 198 99 Hide the ASAPlot graphics window. 199 100 """ 101 if not self.window: 102 asaplog.push( "No plotter window to unmap." ) 103 asaplog.post( "WARN" ) 104 return 200 105 self.window.wm_withdraw() -
trunk/python/asaplotgui_qt4.py
r2416 r2451 29 29 30 30 asaplotbase.__init__(self, **v) 31 matplotlib.rcParams["interactive"] = True 31 32 33 _pylab_helpers.Gcf.destroy(0) 32 34 self.canvas = FigureCanvasQTAgg(self.figure) 33 35 # Simply instantiating this is enough to get a working toolbar. … … 50 52 qt.QtCore.QObject.connect(self.window, qt.QtCore.SIGNAL('destroyed()'),dest_callback) 51 53 52 self.events = {'button_press':None,53 'button_release':None,54 'motion_notify':None}55 56 matplotlib.rcParams["interactive"] = True57 self.buffering = buffering58 59 54 self.unmap() 60 55 #self.canvas.show() … … 65 60 window stack. 66 61 """ 62 if self.is_dead: 63 raise RuntimeError( "No plotter to show. Not yet plotted or plotter is closed." ) 67 64 self.window.activateWindow() 68 65 #To raise this window to the top of the stacking order … … 75 72 """ 76 73 self.is_dead = True 77 try: self.window.close() 74 if not self.figmgr: 75 return 76 try: 77 #self.window.close() 78 # TODO destroy casabar 79 _pylab_helpers.Gcf.destroy(self.figmgr.num) 80 del self.window, self.canvas, self.figmgr 81 self.window = None 82 self.canvas = None 83 self.figmgr = None 78 84 except RuntimeError: pass # the window may already be closed by user 79 85 … … 82 88 Show graphics dependent on the current buffering state. 83 89 """ 90 if self.is_dead: 91 raise RuntimeError( "No plotter to show (not yet plotted or closed)." ) 84 92 if not self.buffering: 85 93 if hardrefresh: … … 94 102 Clear the figure. 95 103 """ 104 if not self.window: 105 asaplog.push( "No plotter window to terminate." ) 106 asaplog.post( "WARN" ) 107 return 96 108 self.window.close() 97 109 … … 100 112 Hide the ASAPlot graphics window. 101 113 """ 114 if not self.window: 115 asaplog.push( "No plotter window to unmap." ) 116 asaplog.post( "WARN" ) 117 return 102 118 self.window.hide() 103 119 -
trunk/python/asapmath.py
r2366 r2451 312 312 asaplog.push('Plot only first spectrum for each [if,pol] pairs to verify calibration.') 313 313 asaplog.post('WARN') 314 #p=asaplotgui.asaplotgui()315 314 p=new_asaplot() 316 315 #nr=min(6,len(ifnos)*len(polnos)) … … 532 531 asaplog.push('Plot only first spectrum for each [if,pol] pairs to verify calibration.') 533 532 asaplog.post('WARN') 534 #p=asaplotgui.asaplotgui()535 533 p=new_asaplot() 536 534 #nr=min(6,len(ifnos)*len(polnos)) … … 745 743 asaplog.push('Plot only first spectrum for each [if,pol] pairs to verify calibration.') 746 744 asaplog.post('WARN') 747 #p=asaplotgui.asaplotgui()748 745 p=new_asaplot() 749 746 #nr=min(6,len(ifnos)*len(polnos)) -
trunk/python/asapplotter.py
r2416 r2451 45 45 if visible is not None: 46 46 self._visible = visible 47 self._plotter = self._newplotter(**kwargs) 48 # additional tool bar 49 self._plotter.figmgr.casabar=self._new_custombar() 47 self._plotter = None 48 self._inikwg = kwargs 50 49 51 50 self._panelling = None … … 55 54 self._rows = None 56 55 self._cols = None 57 self._autoplot = False58 56 self._minmaxx = None 59 57 self._minmaxy = None … … 76 74 self._panelrows = [] 77 75 self._headtext={'string': None, 'textobj': None} 76 self._colormap = None 77 self._linestyles = None 78 self._legendloc = None 78 79 79 80 def _translate(self, instr): … … 85 86 return None 86 87 87 def _newplotter(self, **kwargs): 88 return new_asaplot(self._visible,**kwargs) 88 def _reload_plotter(self): 89 if self._plotter is not None: 90 self._plotter.clear() 91 if self.casabar_exists(): 92 del self._plotter.figmgr.casabar 93 self._plotter.quit() 94 del self._plotter 95 self._plotter = new_asaplot(self._visible,**self._inikwg) 96 self._plotter.figmgr.casabar=self._new_custombar() 97 # just to make sure they're set 98 self._plotter.palette(color=0,colormap=self._colormap, 99 linestyle=0,linestyles=self._linestyles) 100 self._plotter.legend(self._legendloc) 89 101 90 102 def _new_custombar(self): … … 107 119 return False 108 120 121 def _assert_plotter(self,mode="status",errmsg=None): 122 """ 123 Check asaplot status. Returns True if plot window is alive. 124 Parameters 125 mode: Mode of operation. ['status'|'reload'|'halt'] 126 The mode 'status' simply returns if asaplot is 127 alive (True/False). When asaplot is not alive, 128 asaplot is reloaded when mode='reload', while 129 an error raised when mode='halt' 130 errmsg: An error (warning) message to send to the logger, 131 when asaplot is dead. 132 """ 133 if self._plotter and not self._plotter.is_dead: 134 return True 135 # Plotter is not alive. 136 haltmsg = "Plotter window has not yet been loaded or is closed." 137 if type(errmsg)==str and len(errmsg) > 0: 138 haltmsg = errmsg 139 140 if mode.upper().startswith("R"): 141 # reload plotter 142 self._reload_plotter() 143 return True 144 elif mode.upper().startswith("H"): 145 # halt 146 asaplog.push(haltmsg) 147 asaplog.post("ERROR") 148 raise RuntimeError(haltmsg) 149 else: 150 if errmsg: 151 asaplog.push(errmsg) 152 asaplog.post("WARN") 153 return False 154 155 109 156 @asaplog_post_dec 110 157 def plot(self, scan=None): … … 119 166 are consistent e.g. all 'channel' or all 'velocity' etc. 120 167 """ 168 if not self._data and not scan: 169 msg = "Input is not a scantable" 170 raise TypeError(msg) 121 171 self._startrow = 0 122 172 self._ipanel = -1 123 173 self._reset_header() 124 if self._plotter.is_dead: 125 if self.casabar_exists(): 126 del self._plotter.figmgr.casabar 127 self._plotter = self._newplotter() 128 self._plotter.figmgr.casabar=self._new_custombar() 174 self._panelrows = [] 175 176 self._assert_plotter(mode="reload") 129 177 if self.casabar_exists(): 130 178 self._plotter.figmgr.casabar.set_pagecounter(1) 131 self._panelrows = [] 179 132 180 self._plotter.hold() 133 181 #self._plotter.clear() 134 if not self._data and not scan:135 msg = "Input is not a scantable"136 raise TypeError(msg)137 182 if scan: 138 183 self.set_data(scan, refresh=False) 184 self._plotter.palette(color=0,colormap=self._colormap, 185 linestyle=0,linestyles=self._linestyles) 186 self._plotter.legend(self._legendloc) 187 139 188 self._plot(self._data) 140 189 if self._minmaxy is not None: … … 147 196 148 197 def gca(self): 198 errmsg = "No axis to retun. Need to plot first." 199 if not self._assert_plotter(mode="status",errmsg=errmsg): 200 return None 149 201 return self._plotter.figure.gca() 150 202 151 203 def refresh(self): 152 204 """Do a soft refresh""" 205 errmsg = "No figure to re-plot. Need to plot first." 206 self._assert_plotter(mode="halt",errmsg=errmsg) 207 153 208 self._plotter.figure.show() 154 209 … … 163 218 if different IFs are spread over panels (default 0) 164 219 """ 165 if self._data is None: 220 ## this method relies on already plotted figure 221 if not self._assert_plotter(mode="status") or (self._data is None): 222 msg = "Cannot create mask interactively on plot. Can only create mask after plotting." 223 asaplog.push( msg ) 224 asaplog.post( "ERROR" ) 166 225 return [] 167 226 outmask = [] … … 210 269 # forwards to matplotlib axes 211 270 def text(self, *args, **kwargs): 271 self._assert_plotter(mode="reload") 212 272 if kwargs.has_key("interactive"): 213 273 if kwargs.pop("interactive"): … … 219 279 220 280 def arrow(self, *args, **kwargs): 281 self._assert_plotter(mode="reload") 221 282 if kwargs.has_key("interactive"): 222 283 if kwargs.pop("interactive"): … … 231 292 232 293 def annotate(self, text, xy=None, xytext=None, **kwargs): 294 self._assert_plotter(mode="reload") 233 295 if kwargs.has_key("interactive"): 234 296 if kwargs.pop("interactive"): … … 242 304 243 305 def axvline(self, *args, **kwargs): 306 self._assert_plotter(mode="reload") 244 307 if kwargs.has_key("interactive"): 245 308 if kwargs.pop("interactive"): … … 251 314 252 315 def axhline(self, *args, **kwargs): 316 self._assert_plotter(mode="reload") 253 317 if kwargs.has_key("interactive"): 254 318 if kwargs.pop("interactive"): … … 260 324 261 325 def axvspan(self, *args, **kwargs): 326 self._assert_plotter(mode="reload") 262 327 if kwargs.has_key("interactive"): 263 328 if kwargs.pop("interactive"): … … 274 339 275 340 def axhspan(self, *args, **kwargs): 341 self._assert_plotter(mode="reload") 276 342 if kwargs.has_key("interactive"): 277 343 if kwargs.pop("interactive"): … … 288 354 289 355 def _axes_callback(self, axesfunc, *args, **kwargs): 356 self._assert_plotter(mode="reload") 290 357 panel = 0 291 358 if kwargs.has_key("panel"): … … 504 571 """ 505 572 self._lmap = mp 506 self._plotter.legend(mode) 573 #self._plotter.legend(mode) 574 self._legendloc = mode 507 575 if isinstance(fontsize, int): 508 576 from matplotlib import rc as rcp … … 513 581 def set_title(self, title=None, fontsize=None, refresh=True): 514 582 """ 515 Set the title of the plot. If multiple panels are plotted,583 Set the title of sub-plots. If multiple sub-plots are plotted, 516 584 multiple titles have to be specified. 517 585 Parameters: 586 title: a list of titles of sub-plots. 587 fontsize: a font size of titles (integer) 518 588 refresh: True (default) or False. If True, the plot is 519 589 replotted based on the new parameter setting(s). … … 521 591 Example: 522 592 # two panels are visible on the plotter 523 plotter.set_title([ "First Panel","Second Panel"])593 plotter.set_title(['First Panel','Second Panel']) 524 594 """ 525 595 self._title = title … … 537 607 ordinate: a list of ordinate labels. None (default) let 538 608 data determine the labels 609 fontsize: a font size of vertical axis labels (integer) 539 610 refresh: True (default) or False. If True, the plot is 540 611 replotted based on the new parameter setting(s). … … 542 613 Example: 543 614 # two panels are visible on the plotter 544 plotter.set_ordinate([ "First Y-Axis","Second Y-Axis"])615 plotter.set_ordinate(['First Y-Axis','Second Y-Axis']) 545 616 """ 546 617 self._ordinate = ordinate … … 559 630 abcissa: a list of abcissa labels. None (default) let 560 631 data determine the labels 632 fontsize: a font size of horizontal axis labels (integer) 561 633 refresh: True (default) or False. If True, the plot is 562 634 replotted based on the new parameter setting(s). … … 564 636 Example: 565 637 # two panels are visible on the plotter 566 plotter.set_ordinate([ "First X-Axis","Second X-Axis"])638 plotter.set_ordinate(['First X-Axis','Second X-Axis']) 567 639 """ 568 640 self._abcissa = abcissa … … 584 656 Otherwise,the parameter(s) are set without replotting. 585 657 Example: 586 plotter.set_colors( "red green blue")658 plotter.set_colors('red green blue') 587 659 # If for example four lines are overlaid e.g I Q U V 588 660 # 'I' will be 'red', 'Q' will be 'green', U will be 'blue' 589 661 # and 'V' will be 'red' again. 590 662 """ 591 if isinstance(colmap,str): 592 colmap = colmap.split() 593 self._plotter.palette(0, colormap=colmap) 663 #if isinstance(colmap,str): 664 # colmap = colmap.split() 665 #self._plotter.palette(0, colormap=colmap) 666 self._colormap = colmap 594 667 if refresh and self._data: self.plot(self._data) 595 668 … … 604 677 is taken from the .asaprc setting 605 678 plotter.histogram 679 linewidth: a line width 606 680 refresh: True (default) or False. If True, the plot is 607 681 replotted based on the new parameter setting(s). … … 620 694 only one color has been set. 621 695 Parameters: 622 linestyles:a list of linestyles to use.696 linestyles: a list of linestyles to use. 623 697 'line', 'dashed', 'dotted', 'dashdot', 624 698 'dashdotdot' and 'dashdashdot' are 625 699 possible 700 linewidth: a line width 626 701 refresh: True (default) or False. If True, the plot is 627 702 replotted based on the new parameter setting(s). 628 703 Otherwise,the parameter(s) are set without replotting. 629 704 Example: 630 plotter.set_colors( "black")631 plotter.set_linestyles( "line dashed dotted dashdot")705 plotter.set_colors('black') 706 plotter.set_linestyles('line dashed dotted dashdot') 632 707 # If for example four lines are overlaid e.g I Q U V 633 708 # 'I' will be 'solid', 'Q' will be 'dashed', 634 709 # U will be 'dotted' and 'V' will be 'dashdot'. 635 710 """ 636 if isinstance(linestyles,str): 637 linestyles = linestyles.split() 638 self._plotter.palette(color=0,linestyle=0,linestyles=linestyles) 711 #if isinstance(linestyles,str): 712 # linestyles = linestyles.split() 713 #self._plotter.palette(color=0,linestyle=0,linestyles=linestyles) 714 self._linestyles = linestyles 639 715 if isinstance(linewidth, float) or isinstance(linewidth, int): 640 716 from matplotlib import rc as rcp … … 707 783 If the spectrum is flagged no line will be drawn in that location. 708 784 """ 785 errmsg = "Cannot plot spectral lines. Need to plot scantable first." 786 self._assert_plotter(mode="halt",errmsg=errmsg) 709 787 if not self._data: 710 788 raise RuntimeError("No scantable has been plotted yet.") … … 784 862 dpi: The dpi of the output non-ps plot 785 863 """ 864 errmsg = "Cannot save figure. Need to plot first." 865 self._assert_plotter(mode="halt",errmsg=errmsg) 866 786 867 self._plotter.save(filename,orientation,dpi) 787 868 return … … 791 872 """ 792 873 Set a plotting mask for a specific polarization. 793 This is useful for masking out "noise"Pangle outside a source.874 This is useful for masking out 'noise' Pangle outside a source. 794 875 Parameters: 795 876 mask: a mask from scantable.create_mask … … 800 881 Example: 801 882 select = selector() 802 select.setpolstrings( "Pangle")883 select.setpolstrings('Pangle') 803 884 plotter.set_mask(mymask, select) 804 885 """ … … 1305 1386 @asaplog_post_dec 1306 1387 def plottp(self, scan=None, outfile=None): 1307 if self._plotter.is_dead: 1308 if self.casabar_exists(): 1309 del self._plotter.figmgr.casabar 1310 self._plotter = self._newplotter() 1311 self._plotter.figmgr.casabar=self._new_custombar() 1388 self._assert_plotter(mode="reload") 1312 1389 self._plotter.hold() 1313 1390 self._plotter.clear() … … 1399 1476 See the method help for detailed information. 1400 1477 """ 1478 self._assert_plotter(mode="reload") 1401 1479 self._plotter.text(*args, **kwargs) 1402 1480 # end matplotlib.Figure.text forwarding function … … 1437 1515 1438 1516 if plot: 1517 errmsg = "Can plot header only after the first call to plot()." 1518 self._assert_plotter(mode="halt",errmsg=errmsg) 1439 1519 self._plotter.hold() 1440 1520 self._header_plot(headstr,fontsize=fontsize) … … 1469 1549 asaplog.push("No header has been plotted. Exit without any operation") 1470 1550 asaplog.post("WARN") 1471 el se:1551 elif self._assert_plotter(mode="status"): 1472 1552 self._plotter.hold() 1473 1553 for textobj in self._headtext['textobj']: -
trunk/python/flagplotter.py
r2175 r2451 27 27 self._scan = None 28 28 asapplotter.__init__(self,visible=visible, **kwargs) 29 self._assert_plotter(mode='reload') 29 30 self._plotter._set_window_title('Flag Plotter') 30 31 self._panelling = 'r' … … 100 101 without writing the output. USE WITH CARE. 101 102 """ 103 if not self._data: 104 raise RuntimeError("No scantable has been set yet.") 102 105 # simply calls scantable.save 103 106 self._data.save(name,format,overwrite) -
trunk/python/interactivemask.py
r2427 r2451 157 157 158 158 #if not self.p._plotter or self.p._plotter.is_dead: 159 if not self.p or self.p._plotter.is_dead:159 if not self.p: 160 160 asaplog.push('A new ASAP plotter will be loaded') 161 161 asaplog.post() … … 163 163 self.p = asapplotter() 164 164 self.newplot = True 165 165 self.p._assert_plotter(mode='reload') 166 166 167 # Plot selected spectra if needed 167 168 if self.scan != self.p._data: … … 171 172 asaplog.post("WARN") 172 173 # Need replot 173 self.p._ plotter.legend(1)174 self.p._legendloc = 1 174 175 self.p.plot(self.scan) 175 176 # disable casa toolbar
Note:
See TracChangeset
for help on using the changeset viewer.