简体   繁体   中英

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 (ie, "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.

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, eg:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM