Changeset 1865 for trunk/python/linecatalog.py
- Timestamp:
- 08/05/10 17:43:28 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/linecatalog.py
r1859 r1865 1 """ 1 """\ 2 2 A representation of a spectral line catalog. 3 4 Author: Malte Marquarding5 6 3 """ 7 4 __revision__ = "$Revision$" … … 11 8 12 9 class linecatalog(lcbase): 13 """ 10 """\ 14 11 This class is a warpper for line catalogs. These can be either ASCII tables 15 12 or the tables saved from this class. 13 16 14 ASCII tables have the following restrictions: 17 Comments can be present through lines starting with '#'. 18 The first column contains the name of the Molecule. This can't contain spaces, 19 if it does it has to be wrapped in "" 20 The second column contains the frequency of the transition. 21 The third column contains the error in frequency. 22 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 23 27 """ 24 28 … … 45 49 46 50 def set_name(self, name, mode="pattern"): 47 """ 51 """\ 48 52 Set a name restriction on the table. This can be a standard unix-style 49 53 pattern or a regular expression. 54 50 55 Parameters: 56 51 57 name: the name patterrn/regex 58 52 59 mode: the matching mode, i.e. "pattern" (default) or "regex" 60 53 61 """ 54 62 validmodes = "pattern regex".split() … … 58 66 59 67 def set_frequency_limits(self, fmin=1.0, fmax=120.0, unit="GHz"): 60 """ 68 """\ 61 69 Set frequency limits on the table. 70 62 71 Parameters: 72 63 73 fmin: the lower bound 74 64 75 fmax: the upper bound 76 65 77 unit: the frequency unit (default "GHz") 66 78 67 Note: 68 The underlying table conatins frequency values in MHz 79 .. note:: The underlying table contains frequency values in MHz 69 80 """ 70 81 base = { "GHz": 1000.0, "MHz": 1.0 } … … 75 86 76 87 def set_strength_limits(self, smin, smax): 77 """ 88 """\ 78 89 Set line strength limits on the table (arbitrary units) 90 79 91 Parameters: 92 80 93 smin: the lower bound 94 81 95 smax: the upper bound 96 82 97 """ 83 98 lcbase.set_strength_limits(self, smin, smax) 84 99 85 100 def save(self, name, overwrite=False): 86 """ 101 """\ 87 102 Save the subset of the table to disk. This uses an internal data format 88 103 and can be read in again. … … 96 111 97 112 def reset(self): 98 """ 99 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_``. 100 115 """ 101 116 lcbase.reset(self) 102 117 103 118 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 104 126 """ 105 Get the values in a specified row of the table. 106 Parameters: 107 row: the row to retrieve 108 """ 127 if row < 0 or row > len(self)-1: 128 raise IndexError("Row index out of bounds.") 109 129 freq = lcbase.get_frequency(self, row) 110 130 name = lcbase.get_name(self, row) … … 115 135 116 136 def __getitem__(self, k): 117 if k < 0: k = self.nrow()-k 137 if k < 0: 138 k = self.nrow()-k 118 139 return self.get_row(k)
Note:
See TracChangeset
for help on using the changeset viewer.