| 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,theif=None,thebeam=None):
|
|---|
| 22 | """
|
|---|
| 23 | Parameters:
|
|---|
| 24 | filename: the name of an rpfits/sdfits/ms file on disk
|
|---|
| 25 | theif: select a specific IF (default is all)
|
|---|
| 26 | thebeam: select a specific beam (default is all)
|
|---|
| 27 | Example:
|
|---|
| 28 | r = reader('/tmp/2001-09-01_0332_P363.rpf', theif=2)
|
|---|
| 29 | """
|
|---|
| 30 | if theif is None:
|
|---|
| 31 | theif = -1
|
|---|
| 32 | if thebeam is None:
|
|---|
| 33 | thebeam = -1
|
|---|
| 34 | sdreader.__init__(self, filename, theif, thebeam)
|
|---|
| 35 |
|
|---|
| 36 | def read(self,integrations=None):
|
|---|
| 37 | """
|
|---|
| 38 | Reads in an returns a specified sequence of integrations.
|
|---|
| 39 | If no list is given all integrations a read in.
|
|---|
| 40 | Parameters:
|
|---|
| 41 | integrations: a 'range' of integration numbers, e.g.
|
|---|
| 42 | range(100) or [0,1,2,3,4,10,11,100]
|
|---|
| 43 | If not given (default) all integrations
|
|---|
| 44 | are read in
|
|---|
| 45 | Example:
|
|---|
| 46 | r.read([0,1,2,3,4]) # reads in the first 5 integatrions
|
|---|
| 47 | # NOT scans
|
|---|
| 48 | r.read(range(100)) # read in the first 100 integrations
|
|---|
| 49 | """
|
|---|
| 50 | from asap import scantable
|
|---|
| 51 | if integrations is None:
|
|---|
| 52 | integrations = [-1]
|
|---|
| 53 | print "Reading integrations from disk..."
|
|---|
| 54 | sdreader.read(self,integrations)
|
|---|
| 55 | tbl = sdreader.getdata(self)
|
|---|
| 56 | return scantable(tbl)
|
|---|
| 57 |
|
|---|
| 58 | def summary(self):
|
|---|
| 59 | """
|
|---|
| 60 | Print a summary of all scans/integrations. This reads through the
|
|---|
| 61 | whole file once.
|
|---|
| 62 | Parameters:
|
|---|
| 63 | None
|
|---|
| 64 | Example:
|
|---|
| 65 | r.summary()
|
|---|
| 66 | """
|
|---|
| 67 | sdreader.reset(self)
|
|---|
| 68 | sdreader.read(self,[-1])
|
|---|
| 69 | tbl = sdreader.getdata(self)
|
|---|
| 70 | sdreader.reset(self)
|
|---|
| 71 | print tbl.summary()
|
|---|
| 72 | return
|
|---|