source: trunk/python/asapreader.py@ 972

Last change on this file since 972 was 895, checked in by mar637, 19 years ago

added asapreader to asap2

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.7 KB
Line 
1from asap._asap import stfiller
2from asap import print_log
3
4class reader(stfiller):
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 stfiller.__init__(self, filename, theif, thebeam)
49 print_log()
50
51 def read(self):
52 """
53 Reads in an returns a specified sequence of integrations.
54 If no list is given all integrations a read in.
55 """
56 from asap import scantable
57 from asap import asaplog
58 if integrations is None:
59 integrations = [-1]
60 asaplog.push("Reading integrations from disk...")
61 stfiller._read(self)
62 tbl = stfiller._getdata(self)
63 if self.unit is not None:
64 tbl.set_fluxunit(self.unit)
65 print_log()
66 return scantable(tbl)
67
68 def close(self):
69 """
70 Close the reader.
71 """
72 self._close()
73
74 def summary(self, name=None):
75 """
76 Print a summary of all scans/integrations. This reads through the
77 whole file once.
78 Parameters:
79 None
80 Example:
81 r.summary()
82 """
83 stfiller._read(self)
84 from asap import scantable
85 tbl = scantable(stfiller._getdata(self))
86 tbl.summary(name)
87 del tbl
88 return
Note: See TracBrowser for help on using the repository browser.