1 | #import genera operating system related functions
|
---|
2 | import os
|
---|
3 | #import asap module
|
---|
4 | from asap import *
|
---|
5 | # create a reader
|
---|
6 | r = sdreader()
|
---|
7 | # open an RPFITS file
|
---|
8 | r.open('/u/mmarquar/zorro/singledish/data/2001-09-01_0332_P363.rpf')
|
---|
9 | # create a vector with numbers [0..109]
|
---|
10 | integrations = range(110)
|
---|
11 | r.read(integrations)
|
---|
12 | # get the data out of the reader
|
---|
13 | scans = r.getdata()
|
---|
14 | # close the reader
|
---|
15 | r = None
|
---|
16 | # Test sdwriter.
|
---|
17 | print 'Writing ASAP table to disk as /tmp/test.tbl...'
|
---|
18 | scans.makepersistent('/tmp/test.tbl')
|
---|
19 | print "removing /tmp/test.tbl ..."
|
---|
20 | os.remove('/tmp/test_SDWriter.sdfits')
|
---|
21 | print 'Begin sdwriter tests...'
|
---|
22 | # Create an MS2 writer.
|
---|
23 | w = sdwriter('MS2')
|
---|
24 | # Change to SDFITS output format (the default).
|
---|
25 | w.setformat()
|
---|
26 | # Write out the spectra.
|
---|
27 | w.write(scans, '/tmp/test_SDWriter.sdfits')
|
---|
28 | # clean up
|
---|
29 | print "removing test_SDWriter.sdfits ..."
|
---|
30 | os.remove('/tmp/test_SDWriter.sdfits')
|
---|
31 | # print a short summary of the data
|
---|
32 | scans.summary()
|
---|
33 | # get the scan with the number '1'
|
---|
34 | scan = scans.getscan(0)
|
---|
35 | # get the scan with the number '1'
|
---|
36 | ref = scans.getscan(1)
|
---|
37 | # close the data table
|
---|
38 | scans = None
|
---|
39 | # open the math server
|
---|
40 | # average the "on" scan
|
---|
41 | scanav = average(scan)
|
---|
42 | # get rid of the original scan
|
---|
43 | scan = None
|
---|
44 | # print a summary of the scan
|
---|
45 | scanav.summary()
|
---|
46 | # average the "off" scan
|
---|
47 | refav = average(ref)
|
---|
48 | # get rid of the original scan
|
---|
49 | ref = None
|
---|
50 | # print a summary of the scan
|
---|
51 | refav.summary()
|
---|
52 | # form the quotione spectrum
|
---|
53 | quot = quotient(scanav,refav)
|
---|
54 | # set the cursor to polarisation 0
|
---|
55 | quot.setpol(0)
|
---|
56 | # get the spectrum for polarisation 0
|
---|
57 | v0 = quot.getspectrum()
|
---|
58 | #print the first ten channel
|
---|
59 | print v0[0:10]
|
---|
60 | # set the cursor to polarisation 1
|
---|
61 | quot.setpol(1)
|
---|
62 | # get the spectrum for polarisation 1
|
---|
63 | v1 = quot.getspectrum()
|
---|
64 | #print the first ten channel
|
---|
65 | print v1[0:10]
|
---|
66 | # write it to disk for further use
|
---|
67 | quot.makepersistent('/tmp/myfirstquotient.tbl')
|
---|
68 | # cleanup
|
---|
69 | print "removing /tmp/myfirstquotient.tbl ..."
|
---|
70 | os.system('rm -rf /tmp/myfirstquotient.tbl')
|
---|
71 | print "Test successful."
|
---|