Changeset 1560


Ignore:
Timestamp:
03/31/09 12:13:51 (15 years ago)
Author:
Malte Marquarding
Message:

minor doc fixes; fixed list_scans, which seems brokrn in latest ipython; rc parameter xaxisformatting -> axesformatting; fixed font settings for matplotlib rc parameters

Location:
trunk/python
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/__init__.py

    r1558 r1560  
    107107    'plotter.histogram'  : [False, _validate_bool],
    108108    'plotter.papertype'  : ['A4', str],
    109     'plotter.xaxisformatting' : ['asap', str],
     109    'plotter.axesformatting' : ['mpl', str],
    110110
    111111    # scantable
     
    144144plotter.panelling          : scan
    145145
    146 # push panels together, to share axislabels
     146# push panels together, to share axis labels
    147147plotter.ganged             : True
    148148
     
    162162
    163163# The formatting style of the xaxis
    164 plotter.xaxisformatting    : 'asap' or 'mpl'
     164plotter.axesformatting    : 'mpl' (default) or 'asap' (for old versions of matplotlib)
    165165
    166166# scantable
     
    188188# This is has to be a regular expression
    189189scantable.reference         : .*(e|w|_R)$
     190
    190191# Fitter
    191192"""
     
    389390
    390391__date__ = '$Date$'.split()[1]
    391 __version__  = '$Revision:$'
     392__version__  = '$Revision$'
    392393
    393394def is_ipython():
     
    396397    def version(): print  "ASAP %s(%s)"% (__version__, __date__)
    397398   
    398     def list_scans(t = scantable):
    399         import types
    400         globs = sys.modules['__main__'].__dict__.iteritems()
    401         print "The user created scantables are:"
    402         sts = map(lambda x: x[0], filter(lambda x: isinstance(x[1], t), globs))
    403         print filter(lambda x: not x.startswith('_'), sts)
    404         return
     399    def list_scans(t = scantable):       
     400        import inspect
     401        print "The user created scantables are: ",
     402        globs=inspect.currentframe().f_back.f_locals.copy()
     403        out = [ k for k,v in globs.iteritems() \
     404                     if isinstance(v, scantable) and not k.startswith("_") ]
     405        print out
     406        return out
    405407
    406408    def commands():
     
    472474            mx_quotient     - Form a quotient using MX data (off beams)
    473475            scale, *, /     - return a scan scaled by a given factor
    474             add, +, -       - return a scan with given value added
     476            add, +          - return a scan with given value added
     477            sub, -          - return a scan with given value subtracted
    475478            bin             - return a scan with binned channels
    476479            resample        - return a scan with resampled channels
     
    579582            axhline,axvline - draw horizontal/vertical lines
    580583            axhspan,axvspan - draw horizontal/vertical regions
     584            annotate        - draw an arrow with label
     585            create_mask     - create a scnatble mask interactively
    581586
    582587        xyplotter           - matplotlib/pylab plotting functions
     
    592597        commands            - this command
    593598        print               - print details about a variable
    594         list_scans          - list all scantables created bt the user
     599        list_scans          - list all scantables created by the user
    595600        list_files          - list all files readable by asap (default rpf)
    596601        del                 - delete the given variable from memory
  • trunk/python/asaplotbase.py

    r1553 r1560  
    1414from asap import rcParams as asaprcParams
    1515from matplotlib.ticker import OldScalarFormatter
    16 from matplotlib.ticker import NullLocator
    1716
    1817# API change in mpl >= 0.98
     
    2019    from matplotlib.transforms import blended_transform_factory
    2120except ImportError:
    22     from matplotlib.transforms import blend_xy_sep_transform  as blended_transform_factory
     21    from matplotlib.transforms import blend_xy_sep_transform as blended_transform_factory
    2322
    2423if int(matplotlib.__version__.split(".")[1]) < 87:
    2524    print "Warning: matplotlib version < 0.87. This might cause errors. Please upgrade."
    26 
    27 #class MyFormatter(OldScalarFormatter):
    28 #    def __call__(self, x, pos=None):
    29 #        last = len(self.locs)-2
    30 #        if pos==0:
    31 #            return ''
    32 #        else: return OldScalarFormatter.__call__(self, x, pos)
    3325
    3426class asaplotbase:
     
    645637                    self.subplots[i]['axes'] = self.figure.add_subplot(rows,
    646638                                                cols, i+1)
    647                     if asaprcParams['plotter.xaxisformatting'] == 'mpl':
     639                    if asaprcParams['plotter.axesformatting'] != 'mpl':
    648640                        self.subplots[i]['axes'].xaxis.set_major_formatter(OldScalarFormatter())
    649641                else:
     
    651643                        self.subplots[i]['axes'] = self.figure.add_subplot(rows,
    652644                                                cols, i+1)
    653                         if asaprcParams['plotter.xaxisformatting'] != 'mpl':
     645                        if asaprcParams['plotter.axesformatting'] != 'mpl':
    654646                           
    655647                            self.subplots[i]['axes'].xaxis.set_major_formatter(OldScalarFormatter())
     
    733725                        sp['axes'].legend((' '))
    734726
     727
    735728            from matplotlib.artist import setp
    736             fp = FP(size=rcParams['xtick.labelsize'])
    737             xts = fp.get_size_in_points()- (self.cols)/2
    738             fp = FP(size=rcParams['ytick.labelsize'])
    739             yts = fp.get_size_in_points() - (self.rows)/2
     729            fpx = FP(size=rcParams['xtick.labelsize'])
     730            xts = fpx.get_size_in_points()- (self.cols)/2
     731            fpy = FP(size=rcParams['ytick.labelsize'])
     732            yts = fpy.get_size_in_points() - (self.rows)/2
     733            fpa = FP(size=rcParams['axes.labelsize'])
     734            fpat = FP(size=rcParams['axes.titlesize'])
     735            axsize =  fpa.get_size_in_points()
     736            tsize =  fpat.get_size_in_points()
    740737            for sp in self.subplots:
    741738                ax = sp['axes']
    742                 s = ax.title.get_size()
    743                 tsize = s-(self.cols+self.rows)
    744                 ax.title.set_size(tsize)
    745                 fp = FP(size=rcParams['axes.labelsize'])
     739                off = 0
     740                if len(self.subplots) > 1:
     741                    off = self.cols+self.rows
     742                ax.title.set_size(tsize-off)
    746743                setp(ax.get_xticklabels(), fontsize=xts)
    747744                setp(ax.get_yticklabels(), fontsize=yts)
    748                 origx =  fp.get_size_in_points()
    749                 origy = origx
    750745                off = 0
    751                 if self.cols > 1: off = self.cols
    752                 xfsize = origx-off
    753                 ax.xaxis.label.set_size(xfsize)
    754                 off = 0
    755                 if self.rows > 1: off = self.rows
    756                 yfsize = origy-off
    757                 ax.yaxis.label.set_size(yfsize)
     746                if self.cols > 1:
     747                    off = self.cols
     748                ax.xaxis.label.set_size(axsize-off)
     749                if self.rows > 1:
     750                    off = self.rows
     751                ax.yaxis.label.set_size(axsize-off)
    758752
    759753    def subplot(self, i=None, inc=None):
Note: See TracChangeset for help on using the changeset viewer.