source: trunk/python/asapreader.py@ 1001

Last change on this file since 1001 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
RevLine 
[895]1from asap._asap import stfiller
[719]2from asap import print_log
[103]3
[895]4class reader(stfiller):
[103]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)
[895]48 stfiller.__init__(self, filename, theif, thebeam)
[719]49 print_log()
[103]50
[895]51 def read(self):
[103]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
[719]57 from asap import asaplog
[103]58 if integrations is None:
59 integrations = [-1]
[719]60 asaplog.push("Reading integrations from disk...")
[895]61 stfiller._read(self)
62 tbl = stfiller._getdata(self)
[341]63 if self.unit is not None:
64 tbl.set_fluxunit(self.unit)
[719]65 print_log()
[103]66 return scantable(tbl)
67
[895]68 def close(self):
69 """
70 Close the reader.
71 """
72 self._close()
73
[411]74 def summary(self, name=None):
[113]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 """
[895]83 stfiller._read(self)
[411]84 from asap import scantable
[895]85 tbl = scantable(stfiller._getdata(self))
[415]86 tbl.summary(name)
[895]87 del tbl
[113]88 return
Note: See TracBrowser for help on using the repository browser.