source: trunk/examples/test.py @ 76

Last change on this file since 76 was 76, checked in by mmarquar, 20 years ago

Fixed up getscan, which is now 0-based.
Added removal of output files.

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