Changeset 115 for trunk/examples
- Timestamp:
- 12/01/04 12:30:51 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/examples/test.py
r84 r115 3 3 #import asap module 4 4 from 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 6 r = reader('/u/mmarquar/zorro/singledish/data/2001-09-01_0332_P363.rpf') 9 7 # create a vector with numbers [0..109] 10 8 integrations = range(110) 11 r.read(integrations)12 9 # get the data out of the reader 13 scans = r. getdata()10 scans = r.read(integrations) 14 11 # close the reader 15 12 r = 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') 13 print 'Begin export test...' 14 # Write out the spectra in SDFITS format 15 scans.save('/tmp/test_SDWriter.sdfits','SDFITS') 28 16 # clean up 29 17 print "removing test_SDWriter.sdfits ..." … … 31 19 # print a short summary of the data 32 20 scans.summary() 33 # get the scan with the number ' 1'34 scan = scans.get scan(0)35 # get the scan with the n umber '1'36 ref = scans.get scan(1)21 # get the scan with the number '0' 22 scan = scans.get_scan(0) 23 # get the scan with the name 'ref_R' 24 ref = scans.get_scan('ref_R') 37 25 # close the data table 38 26 scans = None 39 27 # open the math server 40 28 # average the "on" scan 41 scanav = average (scan)29 scanav = average_time(scan) 42 30 # get rid of the original scan 43 31 scan = None … … 45 33 scanav.summary() 46 34 # average the "off" scan 47 refav = average (ref)35 refav = average_time(ref) 48 36 # get rid of the original scan 49 37 ref = None … … 53 41 quot = quotient(scanav,refav) 54 42 # set the cursor to polarisation 0 55 quot.set pol(0)43 quot.set_selection(thepol=0) 56 44 # get the spectrum for polarisation 0 57 45 v0 = quot.getspectrum() … … 59 47 print v0[0:10] 60 48 # set the cursor to polarisation 1 61 quot.set pol(1)49 quot.set_selection(thepol=1) 62 50 # get the spectrum for polarisation 1 63 51 v1 = quot.getspectrum() … … 65 53 print v1[0:10] 66 54 # write it to disk for further use 67 quot. makepersistent('/tmp/myfirstquotient.tbl')55 quot.save('/tmp/myfirstquotient.asap') 68 56 # cleanup 69 print "removing /tmp/myfirstquotient. tbl..."70 os.system('rm -rf /tmp/myfirstquotient. tbl')57 print "removing /tmp/myfirstquotient.asap ..." 58 os.system('rm -rf /tmp/myfirstquotient.asap') 71 59 print "Test successful."
Note:
See TracChangeset
for help on using the changeset viewer.