Changeset 115


Ignore:
Timestamp:
12/01/04 12:30:51 (20 years ago)
Author:
mar637
Message:

Aligned with asap v0.1a

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/examples/test.py

    r84 r115  
    33#import asap module
    44from asap 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')
     5# create a readersa and open an RPFITS file
     6r = reader('/u/mmarquar/zorro/singledish/data/2001-09-01_0332_P363.rpf')
    97# create a vector with numbers [0..109]
    108integrations = range(110)
    11 r.read(integrations)
    129# get the data out of  the reader
    13 scans = r.getdata()
     10scans = r.read(integrations)
    1411# close the reader
    1512r = None
    16 # Test sdwriter.
    17 print 'Writing ASAP table to disk as /tmp/test.tbl...'
    18 scans.makepersistent('/tmp/test.tbl')
    19 print "removing /tmp/test.tbl ..."
    20 os.remove('/tmp/test_SDWriter.sdfits')
    21 print 'Begin sdwriter tests...'
    22 # Create an MS2 writer.
    23 w = sdwriter('MS2')
    24 # Change to SDFITS output format (the default).
    25 w.setformat()
    26 # Write out the spectra.
    27 w.write(scans, '/tmp/test_SDWriter.sdfits')
     13print 'Begin export test...'
     14# Write out the spectra in SDFITS format
     15scans.save('/tmp/test_SDWriter.sdfits','SDFITS')
    2816# clean up
    2917print "removing test_SDWriter.sdfits ..."
     
    3119# print a short summary of the data
    3220scans.summary()
    33 # get the scan with the number '1'
    34 scan = scans.getscan(0)
    35 # get the scan with the number '1'
    36 ref = scans.getscan(1)
     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')
    3725# close the data table
    3826scans = None
    3927# open the math server
    4028# average the "on" scan
    41 scanav = average(scan)
     29scanav = average_time(scan)
    4230# get rid of the original scan
    4331scan = None
     
    4533scanav.summary()
    4634# average the "off" scan
    47 refav = average(ref)
     35refav = average_time(ref)
    4836# get rid of the original scan
    4937ref = None
     
    5341quot = quotient(scanav,refav)
    5442# set the cursor to polarisation 0
    55 quot.setpol(0)
     43quot.set_selection(thepol=0)
    5644# get the spectrum for polarisation 0
    5745v0 = quot.getspectrum()
     
    5947print v0[0:10]
    6048# set the cursor to polarisation 1
    61 quot.setpol(1)
     49quot.set_selection(thepol=1)
    6250# get the spectrum for polarisation 1
    6351v1 = quot.getspectrum()
     
    6553print v1[0:10]
    6654# write it to disk for further use
    67 quot.makepersistent('/tmp/myfirstquotient.tbl')
     55quot.save('/tmp/myfirstquotient.asap')
    6856# cleanup
    69 print "removing /tmp/myfirstquotient.tbl ..."
    70 os.system('rm -rf /tmp/myfirstquotient.tbl')
     57print "removing /tmp/myfirstquotient.asap ..."
     58os.system('rm -rf /tmp/myfirstquotient.asap')
    7159print "Test successful."
Note: See TracChangeset for help on using the changeset viewer.