wiki:WriteSpectraToTextFile

Version 1 (modified by Malte Marquarding, 16 years ago) ( diff )

--

Write spectra to a text file

Assume that you have a scantable called scan it contains linear polarisations and cross-polarisation terms. ou now wnat to write out circular polarisations.

scan = scantable("pol.rpf")
# some processing
scan.set_unit("km/s") # to get abcissa values in km/s
# assumption that at this point there is only one scan left in the scantable
assert scan.nrow() == 4

# abscissa
x, xlabel = scan.get_abcissa(0)
sel = selector()
sel.set_pols("RR")
scan.set_selection(sel)
yrr = scan.get_spectrum(0)
sel.set_pols("LL")
scan.set_selection(sel)
yll = scan.get_spectrum(0)


columns = map(None, x, yrr, yll)


# write a file for an RR/LL pair
myfile = open("RR-LL-spectra.txt", "w")
header = "#%s\tRR\tLL\n\n" % xlabel
myfile.write(header)
for row in columns:
   outstring = "%f\t%f\t%f\n" % row
   myfile.write()

myfile.close()

Note: See TracWiki for help on using the wiki.