Search code examples
pythonastropy

build new table from rows in astropy


I am trying to cut out several selected objects in a astronomical catalog (FITS file) using the python package astropy. My question is how to cut out these objects and save them in a new catalog?


Solution

  • convert them to a astropy.table.Table object:

    from astropy.table import Table
    orig_catalogue = Table.read('filename.fits')
    

    and then select your targets (using indexing. i.e. to find all the objects that are more interesting than 100) and write them to a new fits file:

    new_catalogue = orig_catalogue[orig_catalogue['interesting'] > 100]
    new_catalogue.write('new_filename.fits')