source: trunk/examples/test.py @ 91

Last change on this file since 91 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
RevLine 
[76]1#import genera operating system related functions
2import os
[84]3#import asap module
4from asap import *
[20]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
[63]13scans = r.getdata()
[20]14# close the reader
15r = None
[32]16# Test sdwriter.
[84]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')
[32]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.
[84]27w.write(scans, '/tmp/test_SDWriter.sdfits')
[76]28# clean up
29print "removing test_SDWriter.sdfits ..."
[84]30os.remove('/tmp/test_SDWriter.sdfits')
[20]31# print a short summary of the data
32scans.summary()
33# get the scan with the number '1'
[76]34scan = scans.getscan(0)
[20]35# get the scan with the number '1'
[76]36ref = scans.getscan(1)
[20]37# close the data table
38scans = None
39# open the math server
40# average the "on" scan
[76]41scanav = average(scan)
[20]42# get rid of the original scan
43scan = None
44# print a summary of the scan
45scanav.summary()
46# average the "off" scan
[76]47refav = average(ref)
[20]48# get rid of the original scan
49ref = None
50# print a summary of the scan
51refav.summary()
52# form the quotione spectrum
[76]53quot = quotient(scanav,refav)
[20]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]
[76]60# set the cursor to polarisation 1
[20]61quot.setpol(1)
[76]62# get the spectrum for polarisation 1
[20]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')
[76]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.