| 1 | = Write spectra to a text file = |
| 2 | |
| 3 | Assume 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 | {{{ |
| 6 | scan = scantable("pol.rpf") |
| 7 | # some processing |
| 8 | scan.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 |
| 10 | assert scan.nrow() == 4 |
| 11 | |
| 12 | # abscissa |
| 13 | x, xlabel = scan.get_abcissa(0) |
| 14 | sel = selector() |
| 15 | sel.set_pols("RR") |
| 16 | scan.set_selection(sel) |
| 17 | yrr = scan.get_spectrum(0) |
| 18 | sel.set_pols("LL") |
| 19 | scan.set_selection(sel) |
| 20 | yll = scan.get_spectrum(0) |
| 21 | |
| 22 | |
| 23 | columns = map(None, x, yrr, yll) |
| 24 | |
| 25 | |
| 26 | # write a file for an RR/LL pair |
| 27 | myfile = open("RR-LL-spectra.txt", "w") |
| 28 | header = "#%s\tRR\tLL\n\n" % xlabel |
| 29 | myfile.write(header) |
| 30 | for row in columns: |
| 31 | outstring = "%f\t%f\t%f\n" % row |
| 32 | myfile.write() |
| 33 | |
| 34 | myfile.close() |
| 35 | |
| 36 | }}} |
| 37 | |