pyckles.spectral_library module¶
- class pyckles.spectral_library.SpectralLibrary(catalog_name=None, **kwargs)[source]¶
Bases:
object
A 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.BinTableHDU
Spectra 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 the
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
get_catalog_list
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>
- Attributes:
- available_spectra
Methods
load
(catalog_name)Loads the catalogue for a valid string
catalog_name
- property available_spectra¶
- pyckles.spectral_library.spectrum_from_hdu(hdu, return_type='fits')[source]¶
Converts a BinTableHDU into 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