CatalogΒΆ
Collections of SED
objects can be stored and analyzed in a Catalog
object. One can be initialized and populated with an SED
object using the add_SED()
method.
from sedkit import Catalog, VegaSED
vega = VegaSED()
cat1 = Catalog(name='My New Catalog')
cat1.add_SED(vega)
Catalogs can be merged with the addition operator.
from sedkit import SED
sirius = SED('Sirius', spectral_type='A1V', method_list=['find_2MASS', 'find_WISE'])
cat2 = Catalog('My Second Catalog')
cat2.add_SED(sirius)
cat = cat1 + cat2
To check the table of data and calculated parameters, just call the results`
property. The wavelength and flux density units of all the SEDs can be checked and set with the wave_units`
and flux_units`
properties.
cat.results
import astropy.units as q
cat.wave_units = q.AA
cat.flux_units = q.W / q.m**3
Additional columns of data can be added to the results table with the add_column()
method.
rv = np.array([-13.9, -5.5]) * q.km / q.s
rv_unc = np.array([0.9, 0.1]) * q.km / q.s
cat.add_column('radial_velocity', rv, rv_unc)
Data for individual columns (and associated uncertainties when applicable) can be retrieved by passing the desired column names to the get_data()
method.
spt_data, plx_data = cat.get_data('spectral_type', 'parallax')
The SED
object for a source can be retrieved with the get_SED()
method.
vega = cat.get_SED('Vega')
An interactive scatter plot of any two numeric columns can be made by passing the desired x and y parameter names from the results table to the plot()
method. Photometric colors can be calculated by passing two photometric band names with a -
sign. The order
argument accepts an integer and plots a polynomial of the given order. For busy plots, individual sources can be identified by passing the SED name to the identify
argument. Similarly, setting the argument label_points=True
prints the name of each source next to its data point.
cat.plot('Lbol', 'spectral_type', order=1) # Lbol v. SpT plot with first order polynomial fit
cat.plot('spectral_type', '2MASS.J-2MASS.H') # SpT v. J-H color plot
cat.plot('age', 'distance', identify=['Vega']) # Age v. Dist with Vega circled in red
cat.plot('parallax', 'mbol', label_points=True) # Plx v. mbol with labeled points
The SEDs can be plotted for visual comparison with the plot_SEDs()
method. The can be normalized to 1 by setting the argument normalize=True
.
cat.plot_SEDs('*', normalize=True) # Plot of all SEDs
cat.plot_SEDs(['Vega', 'Sirius']) # Normalized plot of Vega and Sirius
The results table, photometry, and plots of each SED can be exported to a zip file or directory with the export()
method.
cat.export('/path/to/target/dir', zip=True)
The whole Catalog
object can be serialized and loaded with the save()
and load()
methods, respectively.
cat_file = '/path/to/cat.p'
cat.save(cat_file)
new_cat = Catalog('A-type stars')
new_cat.load(cat_file)
A catalog can also be made from an ASCII file with column names name
, ra
, and dec
by passing the filepath to the from_file()
method. For each source in the list, an SED is created, the methods in the run_methods
argument are run, and the SED is added to the catalog.
source_list = '/path/to/sources.csv'
new_cat = Catalog()
new_cat.from_file(source_list, run_methods=['find_2MASS', 'find_WISE', 'find_Gaia'])