source: trunk/examples/test.py@ 97

Last change on this file since 97 was 84, checked in by mar637, 20 years ago

changes module name form "atnf_sd" to "asap"

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