source: trunk/python/asapreader.py @ 337

Last change on this file since 337 was 333, checked in by kil064, 19 years ago

allow IF and beam selection

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.3 KB
RevLine 
[103]1from asap._asap import sdreader
2
3class reader(sdreader):
4    """
5    This class allows the user to import single dish files
6    (rpfits,sdfits,ms).
[113]7    The reader reads in integrations from the file and reamins at
8    the fileposition afterwards.
[103]9    Available functions are:
10
11    read(integrations)
12    summary    CURRENTLY DISABLED
13
14    Example:
15        r = reader('/tmp/P389.rpf')
16        scans r.read() # reads in the complete file into 'scans'
17        print scans    # summarises the contents
18        del r          # destroys the reader
19    """
20
[333]21    def __init__(self, filename,theif=None,thebeam=None):
[103]22        """
23        Parameters:
24            filename:    the name of an rpfits/sdfits/ms file on disk
[333]25            theif:       select a specific IF (default is all)
26            thebeam:     select a specific beam (default is all)
[103]27        Example:
[333]28            r = reader('/tmp/2001-09-01_0332_P363.rpf', theif=2)
[103]29        """
[333]30        if theif is None:
31            theif = -1
32        if thebeam is None:
33            thebeam = -1
34        sdreader.__init__(self, filename, theif, thebeam)
[103]35
36    def read(self,integrations=None):
37        """
38        Reads in an returns a specified sequence of integrations.
39        If no list is given all integrations a read in.
40        Parameters:
41            integrations:    a 'range' of integration numbers, e.g.
42                             range(100) or [0,1,2,3,4,10,11,100]
[113]43                             If not given (default) all integrations
44                             are read in
[103]45        Example:
46            r.read([0,1,2,3,4])    # reads in the first 5 integatrions
47                                   # NOT scans
48            r.read(range(100))     # read in the first 100 integrations
49        """
50        from asap import scantable
51        if integrations is None:
52            integrations = [-1]
[127]53        print "Reading integrations from disk..."
[103]54        sdreader.read(self,integrations)
55        tbl = sdreader.getdata(self)
56        return scantable(tbl)
57
58    def summary(self):
[113]59        """
60        Print a summary of all scans/integrations. This reads through the
61        whole file once.
62        Parameters:
63             None
64        Example:
65             r.summary()
66        """
[103]67        sdreader.reset(self)
[113]68        sdreader.read(self,[-1])
69        tbl = sdreader.getdata(self)
[103]70        sdreader.reset(self)
71        print tbl.summary()
[113]72        return
Note: See TracBrowser for help on using the repository browser.