Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/linecatalog.py

    r1865 r1826  
    1 """\
     1"""
    22A representation of a spectral line catalog.
     3
     4Author: Malte Marquarding
     5
    36"""
    47__revision__ = "$Revision$"
    58from asap._asap import linecatalog as lcbase
     9from asap.parameters import rcParams
    610from asap.logging import asaplog
    711import os
    812
    913class linecatalog(lcbase):
    10     """\
     14    """
    1115    This class is a warpper for line catalogs. These can be either ASCII tables
    1216    or the tables saved from this class.
    13 
    1417    ASCII tables have the following restrictions:
    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 
     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
    2724    """
    2825
     
    3330        else:
    3431            msg = "File '%s' not found" % fpath
    35             raise IOError(msg)
     32            if rcParams['verbose']:
     33                #print msg
     34                asaplog.push( msg )
     35                print_log( 'ERROR' )
     36                return
     37            else:
     38                raise IOError(msg)
    3639
    3740    def __repr__(self):
     
    4952
    5053    def set_name(self, name, mode="pattern"):
    51         """\
     54        """
    5255        Set a name restriction on the table. This can be a standard unix-style
    5356        pattern or a regular expression.
    54 
    5557        Parameters:
    56 
    5758            name:       the name patterrn/regex
    58 
    5959            mode:       the matching mode, i.e. "pattern" (default) or "regex"
    60 
    6160        """
    6261        validmodes = "pattern regex".split()
     
    6665
    6766    def set_frequency_limits(self, fmin=1.0, fmax=120.0, unit="GHz"):
    68         """\
     67        """
    6968        Set frequency limits on the table.
    70 
    7169        Parameters:
    72 
    7370            fmin:       the lower bound
    74 
    7571            fmax:       the upper bound
    76 
    7772            unit:       the frequency unit (default "GHz")
    7873
    79         .. note:: The underlying table contains frequency values in MHz
     74        Note:
     75            The underlying table conatins frequency values in MHz
    8076        """
    8177        base = { "GHz": 1000.0, "MHz": 1.0 }
     
    8682
    8783    def set_strength_limits(self, smin, smax):
    88         """\
     84        """
    8985        Set line strength limits on the table (arbitrary units)
    90 
    9186        Parameters:
    92 
    9387            smin:       the lower bound
    94 
    9588            smax:       the upper bound
    96 
    9789        """
    9890        lcbase.set_strength_limits(self, smin, smax)
    9991
    10092    def save(self, name, overwrite=False):
    101         """\
     93        """
    10294        Save the subset of the table to disk. This uses an internal data format
    10395        and can be read in again.
     
    10799            if not overwrite:
    108100                msg = "File %s exists." % name
    109                 raise IOError(msg)
     101                if rcParams['verbose']:
     102                    #print msg
     103                    asaplog.push( msg )
     104                    print_log( 'ERROR' )
     105                    return
     106                else:
     107                    raise IOError(msg)
    110108        lcbase.save(self, name)
    111109
    112110    def reset(self):
    113         """\
    114         Reset the table to its initial state, i.e. undo all calls to ``set_``.
     111        """
     112        Reset the table to its initial state, i.e. undo all calls to set_
    115113        """
    116114        lcbase.reset(self)
    117115
    118116    def get_row(self, row=0):
    119         """\
     117        """
    120118        Get the values in a specified row of the table.
    121 
    122119        Parameters:
    123 
    124120              row:        the row to retrieve
    125 
    126121        """
    127         if row < 0 or row > len(self)-1:
    128             raise IndexError("Row index out of bounds.")
    129122        freq = lcbase.get_frequency(self, row)
    130123        name = lcbase.get_name(self, row)
     
    135128
    136129    def __getitem__(self, k):
    137         if k < 0:
    138             k = self.nrow()-k
     130        if k < 0: k = self.nrow()-k
    139131        return self.get_row(k)
Note: See TracChangeset for help on using the changeset viewer.