Changeset 1698
- Timestamp:
- 02/12/10 23:31:55 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/alma/python/asapplotter.py
r1632 r1698 71 71 self._plotter.hold() 72 72 self._plotter.clear() 73 from asap import scantable74 73 if not self._data and not scan: 75 74 msg = "Input is not a scantable" … … 80 79 return 81 80 raise TypeError(msg) 82 if isinstance(scan, scantable): 83 if self._data is not None: 84 if scan != self._data: 85 self._data = scan 86 # reset 87 self._reset() 88 else: 89 self._data = scan 90 self._reset() 91 # ranges become invalid when unit changes 92 if self._abcunit and self._abcunit != self._data.get_unit(): 93 self._minmaxx = None 94 self._minmaxy = None 95 self._abcunit = self._data.get_unit() 96 self._datamask = None 81 if scan: self.set_data(scan,refresh=False) 97 82 self._plot(self._data) 98 83 if self._minmaxy is not None: … … 152 137 # end matplotlib.axes fowarding functions 153 138 154 def set_mode(self, stacking=None, panelling=None): 139 def set_data(self, scan, refresh=True): 140 """ 141 Set a scantable to plot. 142 Parameters: 143 scan: a scantable 144 refresh: True (default) or False. If True, the plot is 145 replotted based on the new parameter setting(s). 146 Otherwise,the parameter(s) are set without replotting. 147 """ 148 from asap import scantable 149 if isinstance(scan, scantable): 150 if self._data is not None: 151 if scan != self._data: 152 self._data = scan 153 # reset 154 self._reset() 155 else: 156 self._data = scan 157 self._reset() 158 else: 159 msg = "Input is not a scantable" 160 if rcParams['verbose']: 161 #print msg 162 asaplog.push( msg ) 163 print_log( 'ERROR' ) 164 return 165 raise TypeError(msg) 166 167 # ranges become invalid when unit changes 168 if self._abcunit and self._abcunit != self._data.get_unit(): 169 self._minmaxx = None 170 self._minmaxy = None 171 self._abcunit = self._data.get_unit() 172 self._datamask = None 173 if refresh: self.plot() 174 175 176 def set_mode(self, stacking=None, panelling=None, refresh=True): 155 177 """ 156 178 Set the plots look and feel, i.e. what you want to see on the plot. … … 160 182 panelling: tell the plotter which variable to plot 161 183 across multiple panels (default 'scan' 184 refresh: True (default) or False. If True, the plot is 185 replotted based on the new parameter setting(s). 186 Otherwise,the parameter(s) are set without replotting. 162 187 Note: 163 188 Valid modes are: … … 178 203 else: 179 204 raise TypeError(msg) 180 if self._data: self.plot(self._data)205 if refresh and self._data: self.plot(self._data) 181 206 return 182 207 … … 192 217 return False 193 218 194 def set_layout(self,rows=None,cols=None ):219 def set_layout(self,rows=None,cols=None,refresh=True): 195 220 """ 196 221 Set the multi-panel layout, i.e. how many rows and columns plots … … 199 224 rows: The number of rows of plots 200 225 cols: The number of columns of plots 226 refresh: True (default) or False. If True, the plot is 227 replotted based on the new parameter setting(s). 228 Otherwise,the parameter(s) are set without replotting. 201 229 Note: 202 230 If no argument is given, the potter reverts to its auto-plot … … 205 233 self._rows = rows 206 234 self._cols = cols 207 if self._data: self.plot(self._data)235 if refresh and self._data: self.plot(self._data) 208 236 return 209 237 … … 219 247 return False 220 248 221 def set_range(self,xstart=None,xend=None,ystart=None,yend=None ):249 def set_range(self,xstart=None,xend=None,ystart=None,yend=None,refresh=True): 222 250 """ 223 251 Set the range of interest on the abcissa of the plot 224 252 Parameters: 225 253 [x,y]start,[x,y]end: The start and end points of the 'zoom' window 254 refresh: True (default) or False. If True, the plot is 255 replotted based on the new parameter setting(s). 256 Otherwise,the parameter(s) are set without replotting. 226 257 Note: 227 258 These become non-sensical when the unit changes. … … 237 268 else: 238 269 self._minmaxy = [ystart,yend] 239 if self._data: self.plot(self._data)270 if refresh and self._data: self.plot(self._data) 240 271 return 241 272 242 def set_legend(self, mp=None, fontsize = None, mode = 0 ):273 def set_legend(self, mp=None, fontsize = None, mode = 0, refresh=True): 243 274 """ 244 275 Specify a mapping for the legend instead of using the default … … 264 295 9: upper center 265 296 10: center 297 refresh: True (default) or False. If True, the plot is 298 replotted based on the new parameter setting(s). 299 Otherwise,the parameter(s) are set without replotting. 266 300 267 301 Example: … … 278 312 from matplotlib import rc as rcp 279 313 rcp('legend', fontsize=fontsize) 280 if self._data: 281 self.plot(self._data) 314 if refresh and self._data: self.plot(self._data) 282 315 return 283 316 284 def set_title(self, title=None, fontsize=None ):317 def set_title(self, title=None, fontsize=None, refresh=True): 285 318 """ 286 319 Set the title of the plot. If multiple panels are plotted, 287 320 multiple titles have to be specified. 321 Parameters: 322 refresh: True (default) or False. If True, the plot is 323 replotted based on the new parameter setting(s). 324 Otherwise,the parameter(s) are set without replotting. 288 325 Example: 289 326 # two panels are visible on the plotter … … 294 331 from matplotlib import rc as rcp 295 332 rcp('axes', titlesize=fontsize) 296 if self._data: self.plot(self._data)333 if refresh and self._data: self.plot(self._data) 297 334 return 298 335 299 def set_ordinate(self, ordinate=None, fontsize=None ):336 def set_ordinate(self, ordinate=None, fontsize=None, refresh=True): 300 337 """ 301 338 Set the y-axis label of the plot. If multiple panels are plotted, … … 304 341 ordinate: a list of ordinate labels. None (default) let 305 342 data determine the labels 343 refresh: True (default) or False. If True, the plot is 344 replotted based on the new parameter setting(s). 345 Otherwise,the parameter(s) are set without replotting. 306 346 Example: 307 347 # two panels are visible on the plotter … … 313 353 rcp('axes', labelsize=fontsize) 314 354 rcp('ytick', labelsize=fontsize) 315 if self._data: self.plot(self._data)355 if refresh and self._data: self.plot(self._data) 316 356 return 317 357 318 def set_abcissa(self, abcissa=None, fontsize=None ):358 def set_abcissa(self, abcissa=None, fontsize=None, refresh=True): 319 359 """ 320 360 Set the x-axis label of the plot. If multiple panels are plotted, … … 323 363 abcissa: a list of abcissa labels. None (default) let 324 364 data determine the labels 365 refresh: True (default) or False. If True, the plot is 366 replotted based on the new parameter setting(s). 367 Otherwise,the parameter(s) are set without replotting. 325 368 Example: 326 369 # two panels are visible on the plotter … … 332 375 rcp('axes', labelsize=fontsize) 333 376 rcp('xtick', labelsize=fontsize) 334 if self._data: self.plot(self._data)377 if refresh and self._data: self.plot(self._data) 335 378 return 336 379 337 def set_colors(self, colmap ):380 def set_colors(self, colmap, refresh=True): 338 381 """ 339 382 Set the colours to be used. The plotter will cycle through … … 341 384 Parameters: 342 385 colmap: a list of colour names 386 refresh: True (default) or False. If True, the plot is 387 replotted based on the new parameter setting(s). 388 Otherwise,the parameter(s) are set without replotting. 343 389 Example: 344 390 plotter.set_colors("red green blue") … … 350 396 colmap = colmap.split() 351 397 self._plotter.palette(0, colormap=colmap) 352 if self._data: self.plot(self._data)398 if refresh and self._data: self.plot(self._data) 353 399 354 400 # alias for english speakers 355 401 set_colours = set_colors 356 402 357 def set_histogram(self, hist=True, linewidth=None ):403 def set_histogram(self, hist=True, linewidth=None, refresh=True): 358 404 """ 359 405 Enable/Disable histogram-like plotting. … … 362 408 is taken from the .asaprc setting 363 409 plotter.histogram 410 refresh: True (default) or False. If True, the plot is 411 replotted based on the new parameter setting(s). 412 Otherwise,the parameter(s) are set without replotting. 364 413 """ 365 414 self._hist = hist … … 367 416 from matplotlib import rc as rcp 368 417 rcp('lines', linewidth=linewidth) 369 if self._data: self.plot(self._data)370 371 def set_linestyles(self, linestyles=None, linewidth=None ):418 if refresh and self._data: self.plot(self._data) 419 420 def set_linestyles(self, linestyles=None, linewidth=None, refresh=True): 372 421 """ 373 422 Set the linestyles to be used. The plotter will cycle through … … 379 428 'dashdotdot' and 'dashdashdot' are 380 429 possible 381 430 refresh: True (default) or False. If True, the plot is 431 replotted based on the new parameter setting(s). 432 Otherwise,the parameter(s) are set without replotting. 382 433 Example: 383 434 plotter.set_colors("black") … … 393 444 from matplotlib import rc as rcp 394 445 rcp('lines', linewidth=linewidth) 395 if self._data: self.plot(self._data)396 397 def set_font(self, family=None, style=None, weight=None, size=None ):446 if refresh and self._data: self.plot(self._data) 447 448 def set_font(self, family=None, style=None, weight=None, size=None, refresh=True): 398 449 """ 399 450 Set font properties. … … 404 455 size: the 'general' font size, individual elements can be adjusted 405 456 seperately 457 refresh: True (default) or False. If True, the plot is 458 replotted based on the new parameter setting(s). 459 Otherwise,the parameter(s) are set without replotting. 406 460 """ 407 461 from matplotlib import rc as rcp … … 414 468 if isinstance(size, float) or isinstance(size, int): 415 469 rcp('font', size=size) 416 if self._data: self.plot(self._data)470 if refresh and self._data: self.plot(self._data) 417 471 418 472 def plot_lines(self, linecat=None, doppler=0.0, deltachan=10, rotate=90.0, … … 512 566 513 567 514 def set_mask(self, mask=None, selection=None ):568 def set_mask(self, mask=None, selection=None, refresh=True): 515 569 """ 516 570 Set a plotting mask for a specific polarization. … … 519 573 mask: a mask from scantable.create_mask 520 574 selection: the spectra to apply the mask to. 575 refresh: True (default) or False. If True, the plot is 576 replotted based on the new parameter setting(s). 577 Otherwise,the parameter(s) are set without replotting. 521 578 Example: 522 579 select = selector() … … 549 606 else: 550 607 self._maskselection = None 551 self.plot(self._data)608 if refresh: self.plot(self._data) 552 609 553 610 def _slice_indeces(self, data): … … 733 790 734 791 def set_selection(self, selection=None, refresh=True): 792 """ 793 Parameters: 794 selection: a selector object (default unset the selection) 795 refresh: True (default) or False. If True, the plot is 796 replotted based on the new parameter setting(s). 797 Otherwise,the parameter(s) are set without replotting. 798 """ 735 799 self._selection = isinstance(selection,selector) and selection or selector() 736 800 d0 = {'s': 'SCANNO', 'b': 'BEAMNO', 'i':'IFNO', … … 738 802 order = [d0[self._panelling],d0[self._stacking]] 739 803 self._selection.set_order(order) 740 if self._data and refresh: self.plot(self._data)804 if refresh and self._data: self.plot(self._data) 741 805 742 806 def _get_selected_n(self, scan):
Note:
See TracChangeset
for help on using the changeset viewer.