source: trunk/python/asapreader.py@ 410

Last change on this file since 410 was 409, checked in by mar637, 20 years ago

Removed (public) reset until I fix the cursor. read() now auto-resets after each call.

  • 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
2
3class reader(sdreader):
4 """
5 This class allows the user to import single dish files
6 (rpfits,sdfits,ms).
7 The reader reads in integrations from the file and reamins at
8 the fileposition afterwards.
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
21 def __init__(self, filename, unit=None, theif=None, thebeam=None):
22 self.unit = unit
23 """
24 Parameters:
25 filename: the name of an rpfits/sdfits/ms file on disk
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.
29 theif: select a specific IF (default is all)
30 thebeam: select a specific beam (default is all)
31 Example:
32 r = reader('/tmp/2001-09-01_0332_P363.rpf', theif=2)
33 """
34 if theif is None:
35 theif = -1
36 if thebeam is None:
37 thebeam = -1
38 sdreader.__init__(self, filename, theif, thebeam)
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]
47 If not given (default) all integrations
48 are read in
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]
57 print "Reading integrations from disk..."
58 sdreader._read(self,integrations)
59 tbl = sdreader._getdata(self)
60 sdreader._reset(self) # reset to the beginning of the file
61 if self.unit is not None:
62 tbl.set_fluxunit(self.unit)
63 return scantable(tbl)
64
65 def summary(self):
66 """
67 Print a summary of all scans/integrations. This reads through the
68 whole file once.
69 Parameters:
70 None
71 Example:
72 r.summary()
73 """
74 sdreader._reset(self)
75 sdreader._read(self,[-1])
76 tbl = sdreader._getdata(self)
77 sdreader._reset(self)
78 print tbl._summary()
79 return
80## def reset(self):
81## """
82## [Advanced use]
83## Reset to the beginning of the file.
84## Parameters:
85## none
86## Examples:
87## r = reader('xyz.sdfits')
88## scans0 = r.read(range(10))
89## r.reset()
90## scans1 = r.read(range(5,15))
91## # produces 2 scatables one containing integrations(rows) 0-9
92## # and a second one with rows 5-14
93## """
94## sdreader._reset(self)
95
Note: See TracBrowser for help on using the repository browser.