- Timestamp:
- 03/31/12 01:22:43 (13 years ago)
- Location:
- trunk/python
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/asapplotter.py
r2452 r2453 121 121 return False 122 122 123 def _assert_plotter(self, mode="status",errmsg=None):124 """ 125 Check asaplotstatus. Returns True if plot window is alive.123 def _assert_plotter(self,action="status",errmsg=None): 124 """ 125 Check plot window status. Returns True if plot window is alive. 126 126 Parameters 127 mode: Mode of operation. ['status'|'reload'|'halt'] 128 The mode 'status' simply returns if asaplot is 129 alive (True/False). When asaplot is not alive, 130 asaplot is reloaded when mode='reload', while 131 an error raised when mode='halt' 127 action: An action to take if the plotter window is not alive. 128 ['status'|'reload'|'halt'] 129 The action 'status' simply returns False if asaplot 130 is not alive. When action='reload', plot window is 131 reloaded and the method returns True. Finally, an 132 error is raised when action='halt'. 132 133 errmsg: An error (warning) message to send to the logger, 133 when asaplot is dead.134 when plot window is not alive. 134 135 """ 135 136 if self._plotter and not self._plotter.is_dead: … … 140 141 haltmsg = errmsg 141 142 142 if mode.upper().startswith("R"):143 if action.upper().startswith("R"): 143 144 # reload plotter 144 145 self._reload_plotter() 145 146 return True 146 elif mode.upper().startswith("H"):147 elif action.upper().startswith("H"): 147 148 # halt 148 149 asaplog.push(haltmsg) … … 176 177 self._panelrows = [] 177 178 178 self._assert_plotter( mode="reload")179 self._assert_plotter(action="reload") 179 180 if self.casabar_exists(): 180 181 self._plotter.figmgr.casabar.set_pagecounter(1) … … 199 200 def gca(self): 200 201 errmsg = "No axis to retun. Need to plot first." 201 if not self._assert_plotter( mode="status",errmsg=errmsg):202 if not self._assert_plotter(action="status",errmsg=errmsg): 202 203 return None 203 204 return self._plotter.figure.gca() … … 206 207 """Do a soft refresh""" 207 208 errmsg = "No figure to re-plot. Need to plot first." 208 self._assert_plotter( mode="halt",errmsg=errmsg)209 self._assert_plotter(action="halt",errmsg=errmsg) 209 210 210 211 self._plotter.figure.show() … … 221 222 """ 222 223 ## this method relies on already plotted figure 223 if not self._assert_plotter( mode="status") or (self._data is None):224 if not self._assert_plotter(action="status") or (self._data is None): 224 225 msg = "Cannot create mask interactively on plot. Can only create mask after plotting." 225 226 asaplog.push( msg ) … … 271 272 # forwards to matplotlib axes 272 273 def text(self, *args, **kwargs): 273 self._assert_plotter( mode="reload")274 self._assert_plotter(action="reload") 274 275 if kwargs.has_key("interactive"): 275 276 if kwargs.pop("interactive"): … … 281 282 282 283 def arrow(self, *args, **kwargs): 283 self._assert_plotter( mode="reload")284 self._assert_plotter(action="reload") 284 285 if kwargs.has_key("interactive"): 285 286 if kwargs.pop("interactive"): … … 294 295 295 296 def annotate(self, text, xy=None, xytext=None, **kwargs): 296 self._assert_plotter( mode="reload")297 self._assert_plotter(action="reload") 297 298 if kwargs.has_key("interactive"): 298 299 if kwargs.pop("interactive"): … … 306 307 307 308 def axvline(self, *args, **kwargs): 308 self._assert_plotter( mode="reload")309 self._assert_plotter(action="reload") 309 310 if kwargs.has_key("interactive"): 310 311 if kwargs.pop("interactive"): … … 316 317 317 318 def axhline(self, *args, **kwargs): 318 self._assert_plotter( mode="reload")319 self._assert_plotter(action="reload") 319 320 if kwargs.has_key("interactive"): 320 321 if kwargs.pop("interactive"): … … 326 327 327 328 def axvspan(self, *args, **kwargs): 328 self._assert_plotter( mode="reload")329 self._assert_plotter(action="reload") 329 330 if kwargs.has_key("interactive"): 330 331 if kwargs.pop("interactive"): … … 341 342 342 343 def axhspan(self, *args, **kwargs): 343 self._assert_plotter( mode="reload")344 self._assert_plotter(action="reload") 344 345 if kwargs.has_key("interactive"): 345 346 if kwargs.pop("interactive"): … … 356 357 357 358 def _axes_callback(self, axesfunc, *args, **kwargs): 358 self._assert_plotter( mode="reload")359 self._assert_plotter(action="reload") 359 360 panel = 0 360 361 if kwargs.has_key("panel"): … … 786 787 """ 787 788 errmsg = "Cannot plot spectral lines. Need to plot scantable first." 788 self._assert_plotter( mode="halt",errmsg=errmsg)789 self._assert_plotter(action="halt",errmsg=errmsg) 789 790 if not self._data: 790 791 raise RuntimeError("No scantable has been plotted yet.") … … 865 866 """ 866 867 errmsg = "Cannot save figure. Need to plot first." 867 self._assert_plotter( mode="halt",errmsg=errmsg)868 self._assert_plotter(action="halt",errmsg=errmsg) 868 869 869 870 self._plotter.save(filename,orientation,dpi) … … 1388 1389 @asaplog_post_dec 1389 1390 def plottp(self, scan=None, outfile=None): 1390 self._assert_plotter( mode="reload")1391 self._assert_plotter(action="reload") 1391 1392 self._plotter.hold() 1392 1393 self._plotter.clear() … … 1478 1479 See the method help for detailed information. 1479 1480 """ 1480 self._assert_plotter( mode="reload")1481 self._assert_plotter(action="reload") 1481 1482 self._plotter.text(*args, **kwargs) 1482 1483 # end matplotlib.Figure.text forwarding function … … 1518 1519 if plot: 1519 1520 errmsg = "Can plot header only after the first call to plot()." 1520 self._assert_plotter( mode="halt",errmsg=errmsg)1521 self._assert_plotter(action="halt",errmsg=errmsg) 1521 1522 self._plotter.hold() 1522 1523 self._header_plot(headstr,fontsize=fontsize) … … 1551 1552 asaplog.push("No header has been plotted. Exit without any operation") 1552 1553 asaplog.post("WARN") 1553 elif self._assert_plotter( mode="status"):1554 elif self._assert_plotter(action="status"): 1554 1555 self._plotter.hold() 1555 1556 for textobj in self._headtext['textobj']: -
trunk/python/flagplotter.py
r2451 r2453 27 27 self._scan = None 28 28 asapplotter.__init__(self,visible=visible, **kwargs) 29 self._assert_plotter( mode='reload')29 self._assert_plotter(action='reload') 30 30 self._plotter._set_window_title('Flag Plotter') 31 31 self._panelling = 'r' -
trunk/python/interactivemask.py
r2451 r2453 163 163 self.p = asapplotter() 164 164 self.newplot = True 165 self.p._assert_plotter( mode='reload')165 self.p._assert_plotter(action='reload') 166 166 167 167 # Plot selected spectra if needed
Note:
See TracChangeset
for help on using the changeset viewer.