source: trunk/python/asapreader.py@ 855

Last change on this file since 855 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
RevLine 
[103]1from asap._asap import sdreader
[719]2from asap import print_log
[103]3
4class reader(sdreader):
5 """
6 This class allows the user to import single dish files
7 (rpfits,sdfits,ms).
[113]8 The reader reads in integrations from the file and reamins at
9 the fileposition afterwards.
[103]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
[415]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.
[103]27 """
28
[341]29 def __init__(self, filename, unit=None, theif=None, thebeam=None):
30 self.unit = unit
[103]31 """
32 Parameters:
33 filename: the name of an rpfits/sdfits/ms file on disk
[339]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.
[333]37 theif: select a specific IF (default is all)
38 thebeam: select a specific beam (default is all)
[103]39 Example:
[333]40 r = reader('/tmp/2001-09-01_0332_P363.rpf', theif=2)
[103]41 """
[333]42 if theif is None:
43 theif = -1
44 if thebeam is None:
45 thebeam = -1
[411]46 from os.path import expandvars
47 filename = expandvars(filename)
[341]48 sdreader.__init__(self, filename, theif, thebeam)
[719]49 print_log()
[103]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]
[113]58 If not given (default) all integrations
59 are read in
[103]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
[719]66 from asap import asaplog
[103]67 if integrations is None:
68 integrations = [-1]
[719]69 asaplog.push("Reading integrations from disk...")
[406]70 sdreader._read(self,integrations)
71 tbl = sdreader._getdata(self)
[409]72 sdreader._reset(self) # reset to the beginning of the file
[341]73 if self.unit is not None:
74 tbl.set_fluxunit(self.unit)
[719]75 print_log()
[103]76 return scantable(tbl)
77
[411]78 def summary(self, name=None):
[113]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 """
[406]87 sdreader._reset(self)
88 sdreader._read(self,[-1])
[411]89 from asap import scantable
90 tbl = scantable(sdreader._getdata(self))
[406]91 sdreader._reset(self)
[415]92 tbl.summary(name)
[113]93 return
Note: See TracBrowser for help on using the repository browser.