Database

Database#

speXtra come with a in-built database of spectral libraries, astronomical filters and extinction curves. The database is constinously growing and we are happy to include additional data that can be useful for your research

The database organized through yaml files which describe the contents of the different data files.

The inner workings of the database are transparent to the user and generally the user does not need to deal with the database when working with speXtra.

There are however few things that might be useful to the user, specially when working in interactive mode (e.g. Jupyter Notebooks)

The database is organized within a directory tree. Depending on what you are requesting, a spectra template, a extinction curve or a filter, it will look for it at that particular place. The syntax is standard:

  • "library_name/template_name" for a spectral template

  • "extinction_curve_family/extinction_curve_name" for extinction curves

  • "filter_system/filter_name" for astronomical filters

Below you can find the contents of the database

Browsing the Database#

from spextra import spextra_database as db

print(db) 
Spextra Database:
  Remote URL: https://scopesim.univie.ac.at/spextra/database/
  Local path: /home/docs/.spextra_cache
Database contents:
├─libraries:
│ ├─ref: Library of reference stars
│ ├─kc96: Kinney-Calzetti Atlas
│ ├─pickles: Pickles Stellar Library
│ ├─dobos: SDSS galaxy composite spectra
│ ├─irtf: IRTF spectral library
│ ├─agn: AGN templates
│ ├─nebulae: Emission line nebulae
│ ├─brown: Galaxy SEDs from the UV to the Mid-IR
│ ├─kurucz: Subset of Kurucz 1993 Models
│ ├─sne: Supernova Legacy Survey
│ ├─moehler: flux/telluric standards with X-Shooter
│ ├─madden: High-Resolution Spectra of Habitable Zone Planets
│ ├─bosz/hr: BOSZ stellar atmosphere Grid - High Resolution
│ ├─bosz/mr: BOSZ stellar atmosphere Grid - Medium Resolution
│ ├─bosz/lr: BOSZ stellar atmosphere Grid - Low Resolution
│ ├─sky: Paranal sky background spectra
│ ├─shapley: Rest-Frame Ultraviolet Spectra of z ∼ 3 Lyman Break Galaxies
│ ├─etc/kurucz: ESO ETC subset of the Kurucz 1993 models
│ ├─etc/marcs/p: ESO ETC subset of the MARCS Stellar Models with Plane Parallel Geometry
│ ├─etc/marcs/s: ESO ETC subset of the MARCS Stellar Models with Spherical Geometry
│ └─etc/misc: Other templates, nubulae and qso
├─extinction_curves:
│ ├─gordon: LMC and SMC extinction laws
│ ├─cardelli: MW extinction laws
│ └─calzetti: extragalactic attenuation curves
└─filter_systems:
  ├─elt/micado: MICADO filters
  ├─elt/metis: METIS filters
  └─etc: ESO ETC standard filters
/home/docs/checkouts/readthedocs.org/user_builds/spextrahb/envs/stable/lib/python3.11/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm

The last will print basic information regarding local and distant storage.

To list all available libraries we can also use:

db["libraries"]
{'ref': 'Library of reference stars',
 'kc96': 'Kinney-Calzetti Atlas',
 'pickles': 'Pickles Stellar Library',
 'dobos': 'SDSS galaxy composite spectra',
 'irtf': 'IRTF spectral library',
 'agn': 'AGN templates',
 'nebulae': 'Emission line nebulae',
 'brown': 'Galaxy SEDs from the UV to the Mid-IR',
 'kurucz': 'Subset of Kurucz 1993 Models',
 'sne': 'Supernova Legacy Survey',
 'moehler': 'flux/telluric standards with X-Shooter',
 'madden': 'High-Resolution Spectra of Habitable Zone Planets',
 'bosz/hr': 'BOSZ stellar atmosphere Grid - High Resolution',
 'bosz/mr': 'BOSZ stellar atmosphere Grid - Medium Resolution',
 'bosz/lr': 'BOSZ stellar atmosphere Grid - Low Resolution',
 'sky': 'Paranal sky background spectra',
 'shapley': 'Rest-Frame Ultraviolet Spectra of z ∼ 3 Lyman Break Galaxies',
 'etc/kurucz': 'ESO ETC subset of the Kurucz 1993 models',
 'etc/marcs/p': 'ESO ETC subset of the MARCS Stellar Models with Plane Parallel Geometry',
 'etc/marcs/s': 'ESO ETC subset of the MARCS Stellar Models with Spherical Geometry',
 'etc/misc': 'Other templates, nubulae and qso'}

which also works for db["filter_systems"] and db["extinction_curves"] which will print the extinction curves and filter systems available


The class SpecLibrary and its equivalents FilterSystem and ExtinctionCurve hold the information regarding a particular library

from spextra import SpecLibrary, FilterSystem, ExtCurvesLibrary

lib = SpecLibrary("ref")

print(lib)
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Cell In[3], line 5
      1 from spextra import SpecLibrary, FilterSystem, ExtCurvesLibrary
      3 lib = SpecLibrary("ref")
----> 5 print(lib)

File ~/checkouts/readthedocs.org/user_builds/spextrahb/checkouts/stable/spextra/libraries.py:189, in SpecLibrary.__str__(self)
    184 def __str__(self) -> str:
    185     """Return str(self)."""
    186     outstr = (
    187         f"Spectral Library '{self.name}': {self.title}\n"
    188         f"  spectral coverage: {', '.join(self.spectral_coverage)}\n"
--> 189         f"  wave_unit: {self.read_kwargs['wave_unit']}\n"
    190         f"  flux_unit: {self.read_kwargs['flux_unit']}\n"
    191         f"  Templates: {', '.join(self.keys())}"
    192     )
    193     return outstr

KeyError: 'wave_unit'

and basic information about the library will be printed

If you are only interested in the template names, just use

list(lib)

Finally to obtain one of these templates just call Spextrum

from spextra import Spextrum
sp = Spextrum("ref/sun")
sp.plot()