Changes between Initial Version and Version 1 of WriteSpectraToTextFile


Ignore:
Timestamp:
05/08/09 11:21:03 (16 years ago)
Author:
Malte Marquarding
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • WriteSpectraToTextFile

    v1 v1  
     1= Write spectra to a text file =
     2
     3Assume that you have a {{{scantable}}} called {{{scan}}} it contains linear polarisations and cross-polarisation terms. ou now wnat to write out circular polarisations.
     4
     5{{{
     6scan = scantable("pol.rpf")
     7# some processing
     8scan.set_unit("km/s") # to get abcissa values in km/s
     9# assumption that at this point there is only one scan left in the scantable
     10assert scan.nrow() == 4
     11
     12# abscissa
     13x, xlabel = scan.get_abcissa(0)
     14sel = selector()
     15sel.set_pols("RR")
     16scan.set_selection(sel)
     17yrr = scan.get_spectrum(0)
     18sel.set_pols("LL")
     19scan.set_selection(sel)
     20yll = scan.get_spectrum(0)
     21
     22
     23columns = map(None, x, yrr, yll)
     24
     25
     26# write a file for an RR/LL pair
     27myfile = open("RR-LL-spectra.txt", "w")
     28header = "#%s\tRR\tLL\n\n" % xlabel
     29myfile.write(header)
     30for row in columns:
     31   outstring = "%f\t%f\t%f\n" % row
     32   myfile.write()
     33
     34myfile.close()
     35
     36}}}
     37