Ignore:
Timestamp:
02/11/10 11:46:14 (14 years ago)
Author:
Malte Marquarding
Message:

Some minor tidy up and documentation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/scantable.py

    r1691 r1697  
     1import os
    12try:
    23    from functools import wraps as wraps_dec
     
    2223        return val
    2324    return wrap
     25
     26
     27def is_scantable(filename):
     28    return (os.path.isdir(filename)
     29            and not os.path.exists(filename+'/table.f1')
     30            and os.path.exists(filename+'/table.info'))
    2431
    2532
     
    5966            Scantable.__init__(self, filename)
    6067        else:
    61             if isinstance(filename, str):# or \
    62 #                (isinstance(filename, list) or isinstance(filename, tuple)) \
    63 #                  and isinstance(filename[-1], str):
    64                 import os.path
     68            if isinstance(filename, str):
    6569                filename = os.path.expandvars(filename)
    6670                filename = os.path.expanduser(filename)
     
    6973                    if rcParams['verbose']:
    7074                        asaplog.push(s)
    71                         #print asaplog.pop().strip()
    7275                        return
    7376                    raise IOError(s)
    74                 if os.path.isdir(filename) \
    75                     and not os.path.exists(filename+'/table.f1'):
    76                     # crude check if asap table
    77                     if os.path.exists(filename+'/table.info'):
    78                         ondisk = rcParams['scantable.storage'] == 'disk'
    79                         Scantable.__init__(self, filename, ondisk)
    80                         if unit is not None:
    81                             self.set_fluxunit(unit)
    82                         self.set_freqframe(rcParams['scantable.freqframe'])
    83                     else:
    84                         msg = "The given file '%s'is not a valid " \
    85                               "asap table." % (filename)
    86                         if rcParams['verbose']:
    87                             print msg
    88                             return
    89                         else:
    90                             raise IOError(msg)
     77                if is_scantable(filename):
     78                    ondisk = rcParams['scantable.storage'] == 'disk'
     79                    Scantable.__init__(self, filename, ondisk)
     80                    if unit is not None:
     81                        self.set_fluxunit(unit)
     82                    self.set_freqframe(rcParams['scantable.freqframe'])
    9183                else:
    9284                    self._fill([filename], unit, average)
     
    260252            filename:    the name of a file to write the putput to
    261253                         Default - no file output
    262             verbose:     print extra info such as the frequency table
    263                          The default (False) is taken from .asaprc
    264254        """
    265255        info = Scantable._summary(self, True)
     
    347337        are only applied to thi selection.
    348338        Parameters:
    349             selection:    a selector object (default unset the selection)
     339            selection:    a selector object (default unset the selection),
     340
     341            or
     342
     343            any combination of
     344            "pols", "ifs", "beams", "scans", "cycles", "name", "query"
     345
    350346        Examples:
    351347            sel = selector()         # create a selection object
    352348            self.set_scans([0, 3])    # select SCANNO 0 and 3
    353349            scan.set_selection(sel)  # set the selection
     350            scan.summary()           # will only print summary of scanno 0 an 3
     351            scan.set_selection()     # unset the selection
     352            # or the equivalent
     353            scan.set_selection(scans=[0,3])
    354354            scan.summary()           # will only print summary of scanno 0 an 3
    355355            scan.set_selection()     # unset the selection
Note: See TracChangeset for help on using the changeset viewer.