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

Added handling of environment variables throughout.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.