GCien
GCien

Reputation: 2349

Table join operation with FITS files in Astropy

This one is specifically for the astropy community.

I have two tables in .fit format, where both tables may contain a common coloumn/header (i.e., "SDSS identifier"). Now, I wanted to join the tables such that it produces a new table that contains only the objects found in both the tables. So that, any objects that are only in one table are discarded.

I've read the documentation on the table join astropy operations tutorials, but I was wondering whether .fit files are supported (or if I need HDU fits, or csv, or ascii etc) and if certain non-matching objects were included in the final merged table.

If anyone could advise me on how to achieve this that would be excellent.

Upvotes: 0

Views: 1134

Answers (1)

astrofrog
astrofrog

Reputation: 34091

You can read in tables using:

from astropy.table import Table
t1 = Table.read('table1.fit')
t2 = Table.read('table2.fit')

and you can then join them using the join function, e.g.:

from astropy.table import join
t_new = join(t1, t2, keys='id_column')

See the table operations docs and the join docs for more information about the different types of joining and any additional options.

Upvotes: 2

Related Questions