1 | from asap._asap import sdreader
|
---|
2 |
|
---|
3 | class 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 | """
|
---|
23 | Parameters:
|
---|
24 | filename: the name of an rpfits/sdfits/ms file on disk
|
---|
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.
|
---|
28 | theif: select a specific IF (default is all)
|
---|
29 | thebeam: select a specific beam (default is all)
|
---|
30 | Example:
|
---|
31 | r = reader('/tmp/2001-09-01_0332_P363.rpf', theif=2)
|
---|
32 | """
|
---|
33 | if unit is None:
|
---|
34 | unit = ""
|
---|
35 | if theif is None:
|
---|
36 | theif = -1
|
---|
37 | if thebeam is None:
|
---|
38 | thebeam = -1
|
---|
39 | sdreader.__init__(self, filename, unit, theif, thebeam)
|
---|
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]
|
---|
48 | If not given (default) all integrations
|
---|
49 | are read in
|
---|
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]
|
---|
58 | print "Reading integrations from disk..."
|
---|
59 | sdreader.read(self,integrations)
|
---|
60 | tbl = sdreader.getdata(self)
|
---|
61 | return scantable(tbl)
|
---|
62 |
|
---|
63 | def summary(self):
|
---|
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 | """
|
---|
72 | sdreader.reset(self)
|
---|
73 | sdreader.read(self,[-1])
|
---|
74 | tbl = sdreader.getdata(self)
|
---|
75 | sdreader.reset(self)
|
---|
76 | print tbl.summary()
|
---|
77 | return
|
---|