Closed drphilmarshall closed 8 years ago
@mbaumer git pull and check out the db.get_sky_positions
and db.assign_sky_positions
methods: they currently don't work (run python om10/db.py
to see the problem). We need to be able to append columns to the table, but with the current pyfits tomfoolery it's difficult. Shoudl we switch to using pandas
? The constraints are that we need to be able to read from the One True FITS Table of OM10 data, and also write out FITS tables in the same way. If pandas
just works and can handle FITS format, I'd be happy to switch to that - otherwise I think astropy.table
does now support FITS. I'd say this was our first order of business - we can't append RA and DEC in the (sane) way we want to until we figure this columns problem out...
OK, @richardgmcmahon convinced me we should switch to astropy tables (or at least, stop using pyfits!). The main reason is so we can start reading in more general LRG and QSO data files, and interpret their headers automatically (to enable painting in any color!) Richard, would you mind pasting us some examples of you using astropy tables to read the OM10 FITS table, please? Thanks!
""" here is an example; I like to write out the version number to help with debugging.
"""
import astropy print('astropy: ', astropy.version) from astropy.table import Table from astropy.io import fits
infile_OM10="/home/rgm/soft/OM10/OM10/data/qso_mock.fits"
print 'Read in with Astropy FITS table reader'
table=Table.read(infile_OM10)
table.pprint()
print 'Numer of rows: ', len(table)
print 'columns: ', table.columns
print 'colnames: ', table.colnames
print 'meta: ', table.meta
see http://astropy.readthedocs.org/en/latest/table/modify_table.html
to see how to add a column
e.g.
table.add_column(aa, index=0) # Insert before the first table column
table.write('new.fits')
Need to either
a) understand how to manipulate structure provided by pyfits.getdata
or
b) make astropy tables work.
I prefer b) so will try hard on this first.