pystellibs - making synthetic spectra

This is a set of tools to compute synthetic spectra in a simple way, ideal to integrate in larger projects.

This package provides a common interface to compute a single or a collection of spectra using spectral libraries or atmospheres.

Package main content

The main package articulates around 2 parts:

The interpolation within libraries is left as a separated component.

This package provides already multiple input libraries:

Future libraries to be included:

  • XSL: Xshooter spectral library

  • PHOENIX

  • MARCS

References (TBU)

API

The API has been reduced to minimum to make it easy to use. Mostly 2 functions:

  • Stellib.generate_stellar_spectrum() that computes one spectrum for one set of stellar parameters

  • Stellib.generate_individual_spectra() that computes a spectrum for each of many sets of paramaters

Contents:

Quick Start

  • This example shows how to use one of 2 libraries to compute a spectrum

import pylab as plt
from pystellibs import BaSeL, Kurucz

# load 2 libraries
basel = BaSeL()
kurucz = Kurucz()
ap = (4., 3.5, 0., 0.02)
sb = basel.generate_stellar_spectrum(*ap)
sk = kurucz.generate_stellar_spectrum(*ap)
plt.figure()
plt.loglog(osl._wavelength, sb, label='BaSel')
plt.loglog(osl._wavelength, sk, label='Kurucz')
plt.legend(frameon=False, loc='lower right')
plt.xlabel("Wavelength [{0}]".format(basel.wavelength_unit))
plt.ylabel("Flux [{0}]".format(basel.flux_units))
plt.xlim(800, 5e4)
plt.ylim(1e25, 5e30)
plt.tight_layout()
_images/single_spec_libs.png
  • Combining multiple libraries (with priority): the following example combines BaSeL with white-dwarf models.

from pystellibs import BaSeL, Rauch

# Combine 2 libraries by priority order
lib = BaSeL() + Rauch()

for osl in lib._olist:
    l = plt.plot(osl.logT, osl.logg, 'o')[0]
    osl.plot_boundary(color=l.get_color(), dlogT=0.1, dlogg=0.3, alpha=0.3,
                      label=osl.name)

plt.xlim(5.6, 2.8)
plt.ylim(8.5, -2)
plt.xlabel('log T$_{eff}$')
plt.ylabel('log g')
plt.tight_layout()

plt.legend(frameon=False, loc='upper left')
_images/combined_libs.png

Indices and tables