Changeset 1259 for trunk/python
- Timestamp:
- 09/11/06 15:10:05 (18 years ago)
- Location:
- trunk/python
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/__init__.py
r1193 r1259 149 149 # scantable 150 150 151 # default storage of scantable ( memory/disk)151 # default storage of scantable ('memory'/'disk') 152 152 scantable.storage : memory 153 153 # default ouput format when saving … … 355 355 356 356 __date__ = '$Date$'.split()[1] 357 __version__ = '2.1 b'357 __version__ = '2.1' 358 358 359 359 def is_ipython(): 360 return '__IP' in dir(sys.modules["__main__"]) 360 return '__IP' in dir(sys.modules["__main__"]) 361 361 if is_ipython(): 362 362 def version(): print "ASAP %s(%s)"% (__version__, __date__) … … 397 397 get_abcissa - get the abcissa values and name for a given 398 398 row (time) 399 get_column_names - get the names of the columns in the scantable 400 for use with selector.set_query 399 401 set_freqframe - set the frame info for the Spectral Axis 400 402 (e.g. 'LSRK') … … 462 464 set_names - set a selection by name (wildcards allowed) 463 465 set_tsys - set a selection by tsys thresholds 466 set_query - set a selection by SQL-like query, e.g. BEAMNO==1 464 467 reset - unset all selections 465 468 + - merge to selections -
trunk/python/asaplotbase.py
r1153 r1259 13 13 from matplotlib import rc, rcParams 14 14 from asap import rcParams as asaprcParams 15 from matplotlib.ticker import ScalarFormatter15 from matplotlib.ticker import OldScalarFormatter 16 16 from matplotlib.ticker import NullLocator 17 17 from matplotlib.transforms import blend_xy_sep_transform … … 20 20 print "Warning: matplotlib version < 0.87. This might cause errors. Please upgrade." 21 21 22 class MyFormatter(ScalarFormatter):23 def __call__(self, x, pos=None):24 #last = len(self.locs)-225 if pos==0:26 return ''27 else: returnScalarFormatter.__call__(self, x, pos)22 #class MyFormatter(OldScalarFormatter): 23 # def __call__(self, x, pos=None): 24 # last = len(self.locs)-2 25 # if pos==0: 26 # return '' 27 # else: return OldScalarFormatter.__call__(self, x, pos) 28 28 29 29 class asaplotbase: … … 615 615 self.subplots[i]['axes'] = self.figure.add_subplot(rows, 616 616 cols, i+1) 617 self.subplots[i]['axes'].xaxis.set_major_formatter(OldScalarFormatter()) 617 618 else: 618 619 if i == 0: 619 620 self.subplots[i]['axes'] = self.figure.add_subplot(rows, 620 621 cols, i+1) 622 self.subplots[i]['axes'].xaxis.set_major_formatter(OldScalarFormatter()) 621 623 else: 622 624 self.subplots[i]['axes'] = self.figure.add_subplot(rows, … … 624 626 sharex=self.subplots[0]['axes'], 625 627 sharey=self.subplots[0]['axes']) 628 626 629 # Suppress tick labelling for interior subplots. 627 630 if i <= (rows-1)*cols - 1: -
trunk/python/asapplotter.py
r1232 r1259 412 412 if self._data: self.plot(self._data) 413 413 414 def plot_lines(self, linecat=None, doppler=0.0, deltachan=10, rotate= 0.0,414 def plot_lines(self, linecat=None, doppler=0.0, deltachan=10, rotate=90.0, 415 415 location=None): 416 416 """ … … 421 421 deltachan: the number of channels to include each side of the 422 422 line to determine a local maximum/minimum 423 rotate: the rotation for the text label423 rotate: the rotation (in degrees) )for the text label (default 90.0) 424 424 location: the location of the line annotation from the 'top', 425 425 'bottom' or alternate (None - the default) … … 427 427 If the spectrum is flagged no line will be drawn in that location. 428 428 """ 429 if not self._data: return 429 if not self._data: 430 raise RuntimeError("No scantable has been plotted yet.") 430 431 from asap._asap import linecatalog 431 if not isinstance(linecat, linecatalog): return 432 if not self._data.get_unit().endswith("GHz"): return 433 #self._plotter.hold() 432 if not isinstance(linecat, linecatalog): 433 raise ValueError("'linecat' isn't of type linecatalog.") 434 if not self._data.get_unit().endswith("Hz"): 435 raise RuntimeError("Can only overlay linecatalogs when data is in frequency.") 434 436 from matplotlib.numerix import ma 435 437 for j in range(len(self._plotter.subplots)): … … 437 439 lims = self._plotter.axes.get_xlim() 438 440 for row in range(linecat.nrow()): 439 restf = linecat.get_frequency(row)/1000.0 441 # get_frequency returns MHz 442 base = { "GHz": 1000.0, "MHz": 1.0, "Hz": 1.0e-6 } 443 restf = linecat.get_frequency(row)/base[self._data.get_unit()] 440 444 c = 299792.458 441 445 freq = restf*(1.0-doppler/c) … … 482 486 linecat.get_name(row), 483 487 location=loc, rotate=rotate) 484 # self._plotter.release()485 488 self._plotter.show(hardrefresh=False) 486 489 -
trunk/python/linecatalog.py
r1156 r1259 25 25 def __init__(self, name): 26 26 fpath = os.path.abspath(os.path.expandvars(os.path.expanduser(name))) 27 lcbase.__init__(self, fpath) 27 if os.path.exists(fpath): 28 lcbase.__init__(self, fpath) 29 else: 30 msg = "File '%s' not found" % fpath 31 if rcParams['verbose']: 32 print msg 33 return 34 else: 35 raise IOError(msg) 28 36 29 37 def summary(self): … … 96 104 Reset the table to its initial state, i.e. undo all calls to set_ 97 105 """ 98 lcbase.reset( )106 lcbase.reset(self) 99 107 100 108 def get_row(self, row=0): -
trunk/python/scantable.py
r1217 r1259 33 33 if average is None: 34 34 average = rcParams['scantable.autoaverage'] 35 #varlist = vars()35 varlist = vars() 36 36 from asap._asap import stmath 37 37 self._math = stmath() … … 72 72 and isinstance(filename[-1], str): 73 73 self._fill(filename, unit, average) 74 self._add_history("scantable", varlist) 74 75 print_log() 75 76 … … 344 345 print "--------------------------------------------------" 345 346 print out 346 retval = { 'axesnames': ['scanno', 'beamno', 'ifno', 'polno', 'cycleno'], 347 'axes' : axes, 348 'data': statvals} 349 return retval 347 return 348 else: 349 retval = { 'axesnames': ['scanno', 'beamno', 'ifno', 'polno', 'cycleno'], 350 'axes' : axes, 351 'data': statvals} 352 return retval 350 353 351 354 def stddev(self, mask=None): … … 366 369 367 370 368 def column_names(self):371 def get_column_names(self): 369 372 """ 370 373 Return a list of column names, which can be used for selection. 371 374 """ 372 return list(Scantable. column_names(self))375 return list(Scantable.get_column_names(self)) 373 376 374 377 def get_tsys(self): … … 809 812 for i in xrange(len(freqs)): 810 813 sel.set_ifs([i]) 814 self._setselection(sel) 811 815 self._setrestfreqs(freqs[i]["value"], 812 816 freqs[i]["name"], "MHz") 813 self._setselection(sel)814 817 self._setselection(savesel) 815 818 # freqs are to be taken from a linecatalog … … 831 834 832 835 833 def history(self): 836 def history(self, filename=None): 837 """ 838 Print the history. Optionally to a file. 839 """ 834 840 hist = list(self._gethistory()) 835 841 out = "-"*80 … … 848 854 out += "\n %s = %s" % (s[0], s[1]) 849 855 out += "\n"+"-"*80 850 try: 851 from IPython.genutils import page as pager 852 except ImportError: 853 from pydoc import pager 854 pager(out) 856 if filename is not None: 857 if filename is "": 858 filename = 'scantable_history.txt' 859 import os 860 filename = os.path.expandvars(os.path.expanduser(filename)) 861 if not os.path.isdir(filename): 862 data = open(filename, 'w') 863 data.write(out) 864 data.close() 865 else: 866 msg = "Illegal file name '%s'." % (filename) 867 if rcParams['verbose']: 868 print msg 869 else: 870 raise IOError(msg) 871 if rcParams['verbose']: 872 try: 873 from IPython.genutils import page as pager 874 except ImportError: 875 from pydoc import pager 876 pager(out) 877 else: 878 return out 855 879 return 856 857 880 # 858 881 # Maths business … … 1676 1699 self.set_fluxunit(unit) 1677 1700 self.set_freqframe(rcParams['scantable.freqframe']) 1678 #self._add_history("scantable", varlist) 1679 1701
Note:
See TracChangeset
for help on using the changeset viewer.