source: trunk/python/asapreader.py@ 340

Last change on this file since 340 was 339, checked in by kil064, 20 years ago

add unit to constructor

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