pyckles.spectral_library module#
Main module.
- class pyckles.spectral_library.SpectralLibrary(catalog_name=None, **kwargs)[source]#
Bases:
objectA container for a library of spectra.
Holds and returns spectra from various catalogues in various “python-friendly” formats, such as:
synphot.SourceSpectrum,astropy.Quantity,numpy.ndarray, andfits.BinTableHDUSpectra can be accessed by using the attribute syntax:
>>> spec_lib = pyckles.SpectralLibrary("pickles") >>> spec_lib.A0V
or using the item syntax:
>>> spec_lib["A0V"]
The returned spectrum is formatted according to
meta["return_style"]parameter:>>> spec_lib.meta["return_style"] = 'fits' >>> type(spec_lib.A0V) astropy.io.fits.hdu.table.BinTableHDU
- Parameters:
- catalog_namestr
The name of the spectral catalogue. See
pyckles.catalogs
- Attributes:
available_spectraReturn table column containing all spectra name in the library.
Methods
load(catalog_name)Load the catalogue for a valid string
catalog_name.Examples
List the available spectra:
>>> import pyckles >>> spec_lib = pyckles.SpectralLibrary("pickles", return_style="quantity") >>> spec_lib.available_spectra <Column name='name' dtype='str5' length=131> A0I A0III A0IV ... K2III K3III K4III
Get an A0V spectrum:
>>> vega = spec_lib.A0V >>> vega [<Quantity [ 1150., 1155., 1160., ..., 24990., 24995., 25000.] Angstrom>, <Quantity [0.181751, 0.203323, 0.142062, ..., 0.00699 , 0.006986, 0.006983] erg / (Angstrom cm2 s)>]
Return synphot.SourceSpectrum objects instead of a list of Quantity arrays:
>>> spec_lib.meta["return_style"] = "synphot" >>> spec_lib.A0V <synphot.spectrum.SourceSpectrum at 0x251800272e8>
- property available_spectra#
Return table column containing all spectra name in the library.
- pyckles.spectral_library.spectrum_from_hdu(hdu, return_type='fits')[source]#
Convert a
BinTableHDUinto the required return_type format.- Parameters:
- hduBinTableHDU
A BinTableHDU spectrum with column names:
wavelength,flux- return_typestr
The format of the returned spectra - See SpectralLibrary docs
- Returns:
- specvarious
See above
See also