[76] | 1 | #import genera operating system related functions
|
---|
| 2 | import os
|
---|
[20] | 3 | #import atnf_sd module
|
---|
| 4 | from atnf_sd 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
|
---|
[63] | 13 | scans = r.getdata()
|
---|
[20] | 14 | # close the reader
|
---|
| 15 | r = None
|
---|
[32] | 16 | # Test sdwriter.
|
---|
| 17 | print 'Begin sdwriter tests...'
|
---|
| 18 | # Create an MS2 writer.
|
---|
| 19 | w = sdwriter('MS2')
|
---|
| 20 | # Change to SDFITS output format (the default).
|
---|
| 21 | w.setformat()
|
---|
| 22 | # Write out the spectra.
|
---|
| 23 | w.write(scans, 'test_SDWriter.sdfits')
|
---|
[76] | 24 | # clean up
|
---|
| 25 | print "removing test_SDWriter.sdfits ..."
|
---|
| 26 | os.remove('test_SDWriter.sdfits')
|
---|
[20] | 27 | # print a short summary of the data
|
---|
| 28 | scans.summary()
|
---|
| 29 | # get the scan with the number '1'
|
---|
[76] | 30 | scan = scans.getscan(0)
|
---|
[20] | 31 | # get the scan with the number '1'
|
---|
[76] | 32 | ref = scans.getscan(1)
|
---|
[20] | 33 | # close the data table
|
---|
| 34 | scans = None
|
---|
| 35 | # open the math server
|
---|
| 36 | # average the "on" scan
|
---|
[76] | 37 | scanav = average(scan)
|
---|
[20] | 38 | # get rid of the original scan
|
---|
| 39 | scan = None
|
---|
| 40 | # print a summary of the scan
|
---|
| 41 | scanav.summary()
|
---|
| 42 | # average the "off" scan
|
---|
[76] | 43 | refav = average(ref)
|
---|
[20] | 44 | # get rid of the original scan
|
---|
| 45 | ref = None
|
---|
| 46 | # print a summary of the scan
|
---|
| 47 | refav.summary()
|
---|
| 48 | # form the quotione spectrum
|
---|
[76] | 49 | quot = quotient(scanav,refav)
|
---|
[20] | 50 | # set the cursor to polarisation 0
|
---|
| 51 | quot.setpol(0)
|
---|
| 52 | # get the spectrum for polarisation 0
|
---|
| 53 | v0 = quot.getspectrum()
|
---|
| 54 | #print the first ten channel
|
---|
| 55 | print v0[0:10]
|
---|
[76] | 56 | # set the cursor to polarisation 1
|
---|
[20] | 57 | quot.setpol(1)
|
---|
[76] | 58 | # get the spectrum for polarisation 1
|
---|
[20] | 59 | v1 = quot.getspectrum()
|
---|
| 60 | #print the first ten channel
|
---|
| 61 | print v1[0:10]
|
---|
| 62 | # write it to disk for further use
|
---|
| 63 | quot.makepersistent('/tmp/myfirstquotient.tbl')
|
---|
[76] | 64 | # cleanup
|
---|
| 65 | print "removing /tmp/myfirstquotient.tbl ..."
|
---|
| 66 | os.system('rm -rf /tmp/myfirstquotient.tbl')
|
---|
| 67 | print "Test successful."
|
---|