[76] | 1 | #import genera operating system related functions |
---|
| 2 | import os |
---|
[84] | 3 | #import asap module |
---|
| 4 | from asap import * |
---|
[20] | 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 |
---|
[63] | 13 | scans = r.getdata() |
---|
[20] | 14 | # close the reader |
---|
| 15 | r = None |
---|
[32] | 16 | # Test sdwriter. |
---|
[84] | 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') |
---|
[32] | 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. |
---|
[84] | 27 | w.write(scans, '/tmp/test_SDWriter.sdfits') |
---|
[76] | 28 | # clean up |
---|
| 29 | print "removing test_SDWriter.sdfits ..." |
---|
[84] | 30 | os.remove('/tmp/test_SDWriter.sdfits') |
---|
[20] | 31 | # print a short summary of the data |
---|
| 32 | scans.summary() |
---|
| 33 | # get the scan with the number '1' |
---|
[76] | 34 | scan = scans.getscan(0) |
---|
[20] | 35 | # get the scan with the number '1' |
---|
[76] | 36 | ref = scans.getscan(1) |
---|
[20] | 37 | # close the data table |
---|
| 38 | scans = None |
---|
| 39 | # open the math server |
---|
| 40 | # average the "on" scan |
---|
[76] | 41 | scanav = average(scan) |
---|
[20] | 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 |
---|
[76] | 47 | refav = average(ref) |
---|
[20] | 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 |
---|
[76] | 53 | quot = quotient(scanav,refav) |
---|
[20] | 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] |
---|
[76] | 60 | # set the cursor to polarisation 1 |
---|
[20] | 61 | quot.setpol(1) |
---|
[76] | 62 | # get the spectrum for polarisation 1 |
---|
[20] | 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') |
---|
[76] | 68 | # cleanup |
---|
| 69 | print "removing /tmp/myfirstquotient.tbl ..." |
---|
| 70 | os.system('rm -rf /tmp/myfirstquotient.tbl') |
---|
| 71 | print "Test successful." |
---|