# Import tools to help read IPAC ascii table. # and whatever else we need. import numpy as np from astropy.io import ascii from astropy.table import * def readIPACtbl(file): return ascii.read(file, guess=ascii.ipac) fileName = "wise_allsky.wise_allsky_4band_p3as_psd13598.tbl" wdat = readIPACtbl(fileName) # What type of data did we get from the read? type(wdat) wdat.more() wdat.show_in_browser() # What is the length? len(wdat) # What are the names of the columns? wdat.colnames # How do we access individual columns print wdat["ra", "dec"] print np.max(wdat["w1mpro"]) type(wdat["ra"]) # An example of using variables for column names cols = ["ra", "dec", "w1mpro", "w2mpro"] for iCol in cols: print "Range of values for %-s: %.6f to %.6f" % (iCol, np.min(wdat[iCol]), np.max(wdat[iCol])) # An example of creating a color column w1m2 = wdat["w1mpro"] - wdat["w2mpro"] wdat.add_column(Column(name='w1m2', data=w1m2.data)) wdat.colnames