Skip to content

Python guide for IDL astrolib switchers

Thomas Robitaille edited this page May 15, 2015 · 6 revisions

Currently hosted on AstroBetter

Example entry here:

ASCII/IO

  • READCOL:

There are several ways to read in ASCII data in Python. For very simple tables, you can use Numpy's loadtxt:

import numpy as np
wav, flux = np.loadtxt('spectrum.txt', unpack=True)

For standard ASCII table formats (CSV, CDS tables, DAOPhot tables, IPAC tables, etc.) you can make use of Astropy's astropy.io.ascii module:

from astropy.io.ascii import read
tab = read('spectrum.csv')
Clone this wiki locally