Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/linecatalog.py

    r1826 r1865  
    1 """
     1"""\
    22A representation of a spectral line catalog.
    3 
    4 Author: Malte Marquarding
    5 
    63"""
    74__revision__ = "$Revision$"
    85from asap._asap import linecatalog as lcbase
    9 from asap.parameters import rcParams
    106from asap.logging import asaplog
    117import os
    128
    139class linecatalog(lcbase):
    14     """
     10    """\
    1511    This class is a warpper for line catalogs. These can be either ASCII tables
    1612    or the tables saved from this class.
     13
    1714    ASCII tables have the following restrictions:
    18     Comments can be present through lines starting with '#'.
    19     The first column contains the name of the Molecule. This can't contain spaces,
    20     if it does it has to be wrapped in ""
    21     The second column contains the frequency of the transition.
    22     The third column contains the error in frequency.
    23     The fourth column contains a value describing the intensity
     15
     16        * Comments can be present through lines starting with '#'.
     17
     18        * The first column contains the name of the Molecule. This can't contain
     19          spaces, if it does it has to be wrapped in double-quotes.
     20
     21        * The second column contains the frequency of the transition.
     22
     23        * The third column contains the error in frequency.
     24
     25        * The fourth column contains a value describing the intensity.
     26
    2427    """
    2528
     
    3033        else:
    3134            msg = "File '%s' not found" % fpath
    32             if rcParams['verbose']:
    33                 #print msg
    34                 asaplog.push( msg )
    35                 print_log( 'ERROR' )
    36                 return
    37             else:
    38                 raise IOError(msg)
     35            raise IOError(msg)
    3936
    4037    def __repr__(self):
     
    5249
    5350    def set_name(self, name, mode="pattern"):
    54         """
     51        """\
    5552        Set a name restriction on the table. This can be a standard unix-style
    5653        pattern or a regular expression.
     54
    5755        Parameters:
     56
    5857            name:       the name patterrn/regex
     58
    5959            mode:       the matching mode, i.e. "pattern" (default) or "regex"
     60
    6061        """
    6162        validmodes = "pattern regex".split()
     
    6566
    6667    def set_frequency_limits(self, fmin=1.0, fmax=120.0, unit="GHz"):
    67         """
     68        """\
    6869        Set frequency limits on the table.
     70
    6971        Parameters:
     72
    7073            fmin:       the lower bound
     74
    7175            fmax:       the upper bound
     76
    7277            unit:       the frequency unit (default "GHz")
    7378
    74         Note:
    75             The underlying table conatins frequency values in MHz
     79        .. note:: The underlying table contains frequency values in MHz
    7680        """
    7781        base = { "GHz": 1000.0, "MHz": 1.0 }
     
    8286
    8387    def set_strength_limits(self, smin, smax):
    84         """
     88        """\
    8589        Set line strength limits on the table (arbitrary units)
     90
    8691        Parameters:
     92
    8793            smin:       the lower bound
     94
    8895            smax:       the upper bound
     96
    8997        """
    9098        lcbase.set_strength_limits(self, smin, smax)
    9199
    92100    def save(self, name, overwrite=False):
    93         """
     101        """\
    94102        Save the subset of the table to disk. This uses an internal data format
    95103        and can be read in again.
     
    99107            if not overwrite:
    100108                msg = "File %s exists." % name
    101                 if rcParams['verbose']:
    102                     #print msg
    103                     asaplog.push( msg )
    104                     print_log( 'ERROR' )
    105                     return
    106                 else:
    107                     raise IOError(msg)
     109                raise IOError(msg)
    108110        lcbase.save(self, name)
    109111
    110112    def reset(self):
    111         """
    112         Reset the table to its initial state, i.e. undo all calls to set_
     113        """\
     114        Reset the table to its initial state, i.e. undo all calls to ``set_``.
    113115        """
    114116        lcbase.reset(self)
    115117
    116118    def get_row(self, row=0):
     119        """\
     120        Get the values in a specified row of the table.
     121
     122        Parameters:
     123
     124              row:        the row to retrieve
     125
    117126        """
    118         Get the values in a specified row of the table.
    119         Parameters:
    120               row:        the row to retrieve
    121         """
     127        if row < 0 or row > len(self)-1:
     128            raise IndexError("Row index out of bounds.")
    122129        freq = lcbase.get_frequency(self, row)
    123130        name = lcbase.get_name(self, row)
     
    128135
    129136    def __getitem__(self, k):
    130         if k < 0: k = self.nrow()-k
     137        if k < 0:
     138            k = self.nrow()-k
    131139        return self.get_row(k)
Note: See TracChangeset for help on using the changeset viewer.