source: branches/Release12/python/asapreader.py@ 1743

Last change on this file since 1743 was 719, checked in by mar637, 19 years ago

added asaplog

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.3 KB
Line 
1from asap._asap import sdreader
2from asap import print_log
3
4class reader(sdreader):
5 """
6 This class allows the user to import single dish files
7 (rpfits,sdfits,ms).
8 The reader reads in integrations from the file and reamins at
9 the fileposition afterwards.
10 Available functions are:
11
12 read(integrations)
13 summary CURRENTLY DISABLED
14
15 Example:
16 r = reader('/tmp/P389.rpf')
17 scans r.read() # reads in the complete file into 'scans'
18 print scans # summarises the contents
19 del r # destroys the reader
20
21 IMPORTANT: Due to limitations in the rpfits library, only one reader
22 can be created at a time.
23 r = reader('XYZ.rpf')
24 r2 = reader('ABC.rpf')
25 is NOT possible. This is a limitation affecting
26 rpfits ONLY.
27 """
28
29 def __init__(self, filename, unit=None, theif=None, thebeam=None):
30 self.unit = unit
31 """
32 Parameters:
33 filename: the name of an rpfits/sdfits/ms file on disk
34 unit: brightness unit; must be consistent with K or Jy.
35 The default is that a unit is set depending on
36 the telescope. Setting this over-rides that choice.
37 theif: select a specific IF (default is all)
38 thebeam: select a specific beam (default is all)
39 Example:
40 r = reader('/tmp/2001-09-01_0332_P363.rpf', theif=2)
41 """
42 if theif is None:
43 theif = -1
44 if thebeam is None:
45 thebeam = -1
46 from os.path import expandvars
47 filename = expandvars(filename)
48 sdreader.__init__(self, filename, theif, thebeam)
49 print_log()
50
51 def read(self,integrations=None):
52 """
53 Reads in an returns a specified sequence of integrations.
54 If no list is given all integrations a read in.
55 Parameters:
56 integrations: a 'range' of integration numbers, e.g.
57 range(100) or [0,1,2,3,4,10,11,100]
58 If not given (default) all integrations
59 are read in
60 Example:
61 r.read([0,1,2,3,4]) # reads in the first 5 integatrions
62 # NOT scans
63 r.read(range(100)) # read in the first 100 integrations
64 """
65 from asap import scantable
66 from asap import asaplog
67 if integrations is None:
68 integrations = [-1]
69 asaplog.push("Reading integrations from disk...")
70 sdreader._read(self,integrations)
71 tbl = sdreader._getdata(self)
72 sdreader._reset(self) # reset to the beginning of the file
73 if self.unit is not None:
74 tbl.set_fluxunit(self.unit)
75 print_log()
76 return scantable(tbl)
77
78 def summary(self, name=None):
79 """
80 Print a summary of all scans/integrations. This reads through the
81 whole file once.
82 Parameters:
83 None
84 Example:
85 r.summary()
86 """
87 sdreader._reset(self)
88 sdreader._read(self,[-1])
89 from asap import scantable
90 tbl = scantable(sdreader._getdata(self))
91 sdreader._reset(self)
92 tbl.summary(name)
93 return
Note: See TracBrowser for help on using the repository browser.