Changeset 411


Ignore:
Timestamp:
02/11/05 14:37:03 (19 years ago)
Author:
mar637
Message:

Added handling of environment variables throughout.

Location:
trunk/python
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/asaplot.py

    r376 r411  
    626626           
    627627        d = ['png','.ps','eps']
     628
     629        from os.path import expandvars
     630        fname = expandvars(fname)
     631
    628632        if fname[-3:].lower() in d:
    629633            try:
     
    676680
    677681
    678 def load_colours(file='/usr/local/lib/rgb.txt'):
     682def load_colours(filename='/usr/local/lib/rgb.txt'):
    679683    """
    680684    Load the colour dictionary from the specified file.
    681685    """
    682686    print 'Loading colour dictionary from', file
    683     rgb = open(file, 'r')
     687    from os.path import expandvars
     688    filename = expandvars(filename)
     689    rgb = open(filename, 'r')
    684690
    685691    while True:
  • trunk/python/asapmath.py

    r399 r411  
    160160        return
    161161
    162 def gain_el(scan, poly=None, filename="", method="linear", insitu=None, allaxes=None):
     162def gain_el(scan, poly=None, filename="", method="linear",
     163            insitu=None, allaxes=None):
    163164    """
    164165    Return a scan after applying a gain-elevation correction. The correction
     
    204205       poly = ()
    205206    if insitu is None: insitu = rcParams['insitu']
     207    from os.path import expandvars
     208    filename = expandvars(filename)
    206209    if not insitu:
    207210        from asap._asap import gainel as _gainEl
  • trunk/python/asapreader.py

    r409 r411  
    3636        if thebeam is None:
    3737            thebeam = -1
     38        from os.path import expandvars
     39        filename = expandvars(filename)
    3840        sdreader.__init__(self, filename, theif, thebeam)
    3941
     
    6365        return scantable(tbl)
    6466
    65     def summary(self):
     67    def summary(self, name=None):
    6668        """
    6769        Print a summary of all scans/integrations. This reads through the
     
    7476        sdreader._reset(self)
    7577        sdreader._read(self,[-1])
    76         tbl = sdreader._getdata(self)
     78        from asap import scantable
     79        tbl = scantable(sdreader._getdata(self))
    7780        sdreader._reset(self)
    78         print tbl._summary()
     81        print tbl.summary(name=name)
    7982        return
    8083##     def reset(self):
  • trunk/python/scantable.py

    r407 r411  
    3535                self.set_fluxunit(unit)                       
    3636        else:
    37             try:
    38                 mode = st(filename)[stat.ST_MODE]
    39             except OSError:
    40                 print "File not found"
     37            import os.path
     38            if not os.path.exists(filename):
     39                print "File '%s' not found." % (filename)
    4140                return
    42             if stat.S_ISDIR(mode):
     41            filename = os.path.expandvars(filename)
     42            if os.path.isdir(filename):
    4343                # crude check if asap table
    44                 if stat.S_ISREG(st(filename+'/table.info')[stat.ST_MODE]):
     44                if os.path.exists(filename+'/table.info'):
    4545                    sdtable.__init__(self, filename)
    4646                    if unit is not None:
    4747                        self.set_fluxunit(unit)                       
    4848                else:
    49                     print 'The given file is not a valid asap table'
     49                    print "The given file '%s'is not a valid asap table." % (filename)
    5050                    return
    5151            else:
     
    5757                r = sdreader(filename,ifSel,beamSel)
    5858                print 'Importing data...'
    59                 r.read([-1])
    60                 tbl = r.getdata()
     59                r._read([-1])
     60                tbl = r._getdata()
    6161                if unit is not None:
    6262                    tbl.set_fluxunit(unit)
     
    8686                                       'MS2' (saves as an aips++
    8787                                              MeasurementSet V2)
    88             overwrite:   if the file should be overwritten if it exists.
     88            overwrite:   If the file should be overwritten if it exists.
    8989                         The default False is to return with warning
    90                          without writing the output
     90                         without writing the output. USE WITH CARE.
    9191        Example:
    9292            scan.save('myscan.asap')
    9393            scan.save('myscan.sdfits','SDFITS')
    9494        """
     95        from os import path
    9596        if format is None: format = rcParams['scantable.save']
    9697        suffix = '.'+format.lower()
     
    9899            name = 'scantable'+suffix
    99100            print "No filename given. Using default name %s..." % name
    100         from os import path
     101        name = path.expandvars(name)
    101102        if path.isfile(name) or path.isdir(name):
    102103            if not overwrite:
     
    166167            if filename is "":
    167168                filename = 'scantable_summary.txt'
     169            from os.path import expandvars
     170            filename = expandvars(filename)
    168171            data = open(filename, 'w')
    169172            data.write(info)
Note: See TracChangeset for help on using the changeset viewer.