source: trunk/python/asaplinefind.py@ 307

Last change on this file since 307 was 302, checked in by kil064, 20 years ago

getmask -> _getmask

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.9 KB
Line 
1import _asap
2
3class linefinder:
4 """
5 The class for automated spectral line search in ASAP.
6 """
7
8 def __init__(self):
9 """
10 Create a line finder object.
11 """
12 self.finder = _asap.linefinder()
13 return
14
15 def set_scan(self,scan,mask=None,edge=(0,0)):
16 """
17 Set the 'data' (scantable) to work with.
18 Parameters:
19 scan: a scantable
20 mask: an optional mask retreived from scantable
21 edge: an optional number of channel to drop at
22 the edge of spectrum. If only one value is
23 specified, the same number will be dropped from
24 both sides of the spectrum. Default is to keep
25 all channels
26 """
27 if not scan:
28 raise RuntimeError, 'Please give a correct scan'
29 if len(edge)>2:
30 raise RuntimeError, "The edge parameter should have two \
31 or less elements"
32 if mask is None:
33 from numarray import ones
34 self.finder.setscan(scan,ones(scan.nchan()),edge)
35 else:
36 self.finder.setscan(scan,mask,edge)
37 return
38 def find_lines(self):
39 """
40 Search for spectral lines in the scan assigned in set_scan.
41 A number of lines found will be returned
42 """
43 return self.finder.findlines()
44 def get_mask(self,invert=False):
45 """
46 Get the mask to mask out all lines that have been found (default)
47
48 Parameters:
49 invert if True, only channels belong to lines will be unmasked
50
51 Note: all channels originally masked by the input mask or
52 dropped out by the edge parameter will still be excluded
53 regardless on the invert option
54 """
55 return self.finder._getmask(invert)
56 def get_ranges(self,defunits=True):
57 """
58 Get ranges (start and end channels or velocities) for all spectral
59 lines found.
60
61 Parameters:
62 defunits if True (default), the range will use the same units
63 as set for the scan (e.g. LSR velocity)
64 if False, the range will be expressed in channels
65 """
66 return self.finder.getlineranges(defunits)
Note: See TracBrowser for help on using the repository browser.