source: trunk/python/asapreader.py@ 395

Last change on this file since 395 was 360, checked in by kil064, 20 years ago

fix summary function binding

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.7 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
[341]21 def __init__(self, filename, unit=None, theif=None, thebeam=None):
22 self.unit = unit
[103]23 """
24 Parameters:
25 filename: the name of an rpfits/sdfits/ms file on disk
[339]26 unit: brightness unit; must be consistent with K or Jy.
27 The default is that a unit is set depending on
28 the telescope. Setting this over-rides that choice.
[333]29 theif: select a specific IF (default is all)
30 thebeam: select a specific beam (default is all)
[103]31 Example:
[333]32 r = reader('/tmp/2001-09-01_0332_P363.rpf', theif=2)
[103]33 """
[333]34 if theif is None:
35 theif = -1
36 if thebeam is None:
37 thebeam = -1
[341]38 sdreader.__init__(self, filename, theif, thebeam)
[103]39
40 def read(self,integrations=None):
41 """
42 Reads in an returns a specified sequence of integrations.
43 If no list is given all integrations a read in.
44 Parameters:
45 integrations: a 'range' of integration numbers, e.g.
46 range(100) or [0,1,2,3,4,10,11,100]
[113]47 If not given (default) all integrations
48 are read in
[103]49 Example:
50 r.read([0,1,2,3,4]) # reads in the first 5 integatrions
51 # NOT scans
52 r.read(range(100)) # read in the first 100 integrations
53 """
54 from asap import scantable
55 if integrations is None:
56 integrations = [-1]
[127]57 print "Reading integrations from disk..."
[103]58 sdreader.read(self,integrations)
59 tbl = sdreader.getdata(self)
[341]60 if self.unit is not None:
61 tbl.set_fluxunit(self.unit)
[103]62 return scantable(tbl)
63
64 def summary(self):
[113]65 """
66 Print a summary of all scans/integrations. This reads through the
67 whole file once.
68 Parameters:
69 None
70 Example:
71 r.summary()
72 """
[103]73 sdreader.reset(self)
[113]74 sdreader.read(self,[-1])
75 tbl = sdreader.getdata(self)
[103]76 sdreader.reset(self)
[360]77 print tbl._summary()
[113]78 return
Note: See TracBrowser for help on using the repository browser.