source: trunk/examples/test.py@ 144

Last change on this file since 144 was 115, checked in by mar637, 20 years ago

Aligned with asap v0.1a

  • 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 asap module
4from asap import *
5# create a readersa and open an RPFITS file
6r = reader('/u/mmarquar/zorro/singledish/data/2001-09-01_0332_P363.rpf')
7# create a vector with numbers [0..109]
8integrations = range(110)
9# get the data out of the reader
10scans = r.read(integrations)
11# close the reader
12r = None
13print 'Begin export test...'
14# Write out the spectra in SDFITS format
15scans.save('/tmp/test_SDWriter.sdfits','SDFITS')
16# clean up
17print "removing test_SDWriter.sdfits ..."
18os.remove('/tmp/test_SDWriter.sdfits')
19# print a short summary of the data
20scans.summary()
21# get the scan with the number '0'
22scan = scans.get_scan(0)
23# get the scan with the name 'ref_R'
24ref = scans.get_scan('ref_R')
25# close the data table
26scans = None
27# open the math server
28# average the "on" scan
29scanav = average_time(scan)
30# get rid of the original scan
31scan = None
32# print a summary of the scan
33scanav.summary()
34# average the "off" scan
35refav = average_time(ref)
36# get rid of the original scan
37ref = None
38# print a summary of the scan
39refav.summary()
40# form the quotione spectrum
41quot = quotient(scanav,refav)
42# set the cursor to polarisation 0
43quot.set_selection(thepol=0)
44# get the spectrum for polarisation 0
45v0 = quot.getspectrum()
46#print the first ten channel
47print v0[0:10]
48# set the cursor to polarisation 1
49quot.set_selection(thepol=1)
50# get the spectrum for polarisation 1
51v1 = quot.getspectrum()
52#print the first ten channel
53print v1[0:10]
54# write it to disk for further use
55quot.save('/tmp/myfirstquotient.asap')
56# cleanup
57print "removing /tmp/myfirstquotient.asap ..."
58os.system('rm -rf /tmp/myfirstquotient.asap')
59print "Test successful."
Note: See TracBrowser for help on using the repository browser.