Changeset 706 for trunk/python


Ignore:
Timestamp:
11/02/05 13:17:39 (19 years ago)
Author:
mar637
Message:

various changes to enable non-gui plotting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/__init__.py

    r702 r706  
    2828     * environ var ASAPRC
    2929     * HOME/.asaprc
    30      
     30
    3131    """
    3232
     
    4747            return fname
    4848    return None
    49        
     49
    5050
    5151defaultParams = {
     
    5454    'useplotter'          : [True, _validate_bool],
    5555    'insitu'              : [True, _validate_bool],
    56    
     56
    5757    # plotting
     58    'plotter.gui'         : [True, _validate_bool],
    5859    'plotter.stacking'    : ['p', str],
    5960    'plotter.panelling'   : ['s', str],
    6061    'plotter.colours'     : ['', str],
    6162    'plotter.linestyles'  : ['', str],
    62 
     63   
    6364    # scantable
    6465    'scantable.save'      : ['ASAP', str],
     
    7374
    7475def list_rcparameters():
    75    
     76
    7677    print """
    7778    # general
     
    8485    # apply operations on the input scantable or return new one
    8586    insitu                     : True
     87
     88    # plotting
    8689   
    87     # plotting
     90    # do we want a GUI or plot to a file
     91    plotter.gui                : True
     92   
    8893    # default mode for colour stacking
    8994    plotter.stacking           : Pol
     
    9499    # default colours/linestyles
    95100    plotter.colours            :
    96     plotter.linestyles         : 
     101    plotter.linestyles         :
    97102
    98103    # scantable
     
    107112
    108113    # apply action to all axes not just the cursor location
    109     scantable.allaxes          : True 
     114    scantable.allaxes          : True
    110115
    111116    # use internal plotter
     
    114119    # Control the level of information printed by summary
    115120    scantable.verbosesummary   : False
    116    
    117     # Fitter   
    118     """
    119    
     121
     122    # Fitter
     123    """
     124
    120125def rc_params():
    121126    'Return the default params updated from the values in the rc file'
    122    
     127
    123128    fname = _asap_fname()
    124    
     129
    125130    if fname is None or not os.path.exists(fname):
    126131        message = 'could not find rc file; returning defaults'
     
    128133        #print message
    129134        return ret
    130        
     135
    131136    cnt = 0
    132137    for line in file(fname):
     
    139144            print ('Illegal line #%d\n\t%s\n\tin file "%s"' % (cnt, line, fname))
    140145            continue
    141        
     146
    142147        key, val = tup
    143148        key = key.strip()
     
    145150            print ('Bad key "%s" on line %d in %s' % (key, cnt, fname))
    146151            continue
    147        
     152
    148153        default, converter =  defaultParams[key]
    149154
     
    167172
    168173# this is the instance used by the asap classes
    169 rcParams = rc_params() 
     174rcParams = rc_params()
    170175
    171176rcParamsDefault = dict(rcParams.items()) # a copy
     
    181186
    182187    sets the current rc params and is equivalent to
    183    
     188
    184189      rcParams['scantable.save'] = 'SDFITS'
    185190
     
    188193
    189194    aliases = {}
    190    
     195
    191196    for k,v in kwargs.items():
    192197        name = aliases.get(k) or k
     
    194199        if not rcParams.has_key(key):
    195200            raise KeyError('Unrecognized key "%s" for group "%s" and name "%s"' % (key, group, name))
    196        
     201
    197202        rcParams[key] = v
    198203
     
    228233
    229234if rcParams['useplotter']:
    230     if os.environ.has_key('DISPLAY'):
    231         print "Initialising asapplotter with the name 'plotter' ..."
    232         import asapplotter
    233         plotter = asapplotter.asapplotter()
    234     else:
    235         print "No $DISPLAY set. Disabling plotter.\n"
    236 
     235    from  asapplotter import *
     236    if rcParams['verbose']:
     237        print "Initialising GUI asapplotter with the name 'plotter' ..."
     238    gui = os.environ.has_key('DISPLAY') and rcParams['plotter.gui']
     239    plotter = asapplotter(gui)
    237240
    238241__date__ = '$Date$'.split()[1]
    239 __version__  = '1.1'
    240 
    241 def list_scans(t = scantable):
    242     import sys, types
    243     globs = sys.modules['__main__'].__dict__.iteritems()
    244     print "The user created scantables are:"
    245     sts = map(lambda x: x[0], filter(lambda x: isinstance(x[1], t), globs))
    246     print filter(lambda x: not x.startswith('_'), sts)
     242__version__  = '1.2'
     243
     244if rcParams['verbose']:
     245    def list_scans(t = scantable):
     246        import sys, types
     247        globs = sys.modules['__main__'].__dict__.iteritems()
     248        print "The user created scantables are:"
     249        sts = map(lambda x: x[0], filter(lambda x: isinstance(x[1], t), globs))
     250        print filter(lambda x: not x.startswith('_'), sts)
     251        return
     252else:
     253    pass
    247254
    248255def commands():
    249     x = """   
     256    x = """
    250257    [The scan container]
    251258        scantable           - a container for integrations/scans
     
    286293            history         - print the history of the scantable
    287294            get_fit         - get a fit which has been stored witnh the data
    288             average_time    - return the (weighted) time average of a scan 
     295            average_time    - return the (weighted) time average of a scan
    289296                              or a list of scans
    290297            average_pol     - average the polarisations together.
     
    296303            quotient        - return the on/off quotient
    297304            scale           - return a scan scaled by a given factor
    298             add             - return a scan with given value added 
     305            add             - return a scan with given value added
    299306            bin             - return a scan with binned channels
    300307            resample        - return a scan with resampled channels
    301308            smooth          - return the spectrally smoothed scan
    302309            poly_baseline   - fit a polynomial baseline to all Beams/IFs/Pols
    303             auto_poly_baseline - automatically fit a polynomial baseline 
     310            auto_poly_baseline - automatically fit a polynomial baseline
    304311            gain_el         - apply gain-elevation correction
    305312            opacity         - apply opacity correction
     
    312319     [Math] Mainly functions which operate on more than one scantable
    313320
    314             average_time    - return the (weighted) time average 
     321            average_time    - return the (weighted) time average
    315322                              of a list of scans
    316323            quotient        - return the on/off quotient
     
    350357            set_abcissa     - specify a user label for the abcissa
    351358            set_layout      - specify the multi-panel layout (rows,cols)
    352            
     359
    353360    [Reading files]
    354361        reader              - access rpfits/sdfits files
     
    370377        mask_not            - boolean operations on masks created with
    371378                              scantable.create_mask
    372        
     379
    373380    Note:
    374381        How to use this with help:
     
    376383        [xxx] is just a category
    377384        Every 'sub-level' in this list should be replaces by a '.' Period when
    378         using help 
     385        using help
    379386        Example:
    380387            ASAP> help scantable # to get info on ths scantable
     
    386393    return
    387394
    388 print """Welcome to ASAP v%s (%s) - the ATNF Spectral Analysis Package
     395def welcome():
     396    return """Welcome to ASAP v%s (%s) - the ATNF Spectral Analysis Package
    389397
    390398Please report any bugs to:
     
    392400
    393401[IMPORTANT: ASAP is 0-based]
    394 Type commands() to get a list of all available ASAP commands.
    395 """ % (__version__, __date__)
     402Type commands() to get a list of all available ASAP commands.""" % (__version__, __date__)
Note: See TracChangeset for help on using the changeset viewer.