pysvo is a toolset that allows you to handle data coming from the Theoretical Model Services maintained by the Spanish Virtual Observatory. It was originally developed for use with StarHorse (Queiroz et al. 2019, Anders et al. 2019 ).
Currently, it can do the following things:
- Download and handle transmission curves supplied by the Filter Profile Service of the Spanish Virtual Observatory (SVO)
- Download and handle the stellar model spectra available from the Theoretical Spectra Webserver of the SVO
- Handle some of the most widely used extinction curves
- Calculate extinction coefficients for arbitrary photometric bands on the fly
You need to have the following python packages installed in order to use pysvo:
- numpy, scipy, astropy, matplotlib, collections
Optional:
- extinction
The svomodels module downloads model spectra from the Theoretical Spectra Webserver for you, so they no longer have to be fetched by hand. Files are cached under ./pysvo/spectrallib/MODELNAME/, so nothing is downloaded twice.
from pysvo import svomodels
# Read one spectrum - downloading it first if it is not cached yet.
# Columns: "wavelength" [Angstrom] and "flux" [erg/cm2/s/A].
spec = svomodels.read_spectrum("Kurucz", teff=5750, logg=4.5, mh=0.0)
spec["wavelength"], spec["flux"], spec.meta
# Off-grid parameters snap to the nearest grid point (with a warning).
# Pass exact=True to get an error instead.
spec = svomodels.read_spectrum("BT-Settl", teff=3010, logg=5.0, mh=0.0)
# Which models are available?
svomodels.available_models() # known collections
svomodels.grid_values("Kurucz", "teff") # all Teff values of a grid
svomodels.get_grid("Kurucz") # the full grid as a Table
# Download a whole block of the grid in one go
svomodels.download_grid("Kurucz", teff=(5000, 6000), logg=(4.0, 4.5), mh=0.0)For a spectrum you want to plot or interpolate, use the SynSpectrum class, which downloads the spectrum the same way:
sun = svomodels.SynSpectrum(lib="Kurucz", mh=0.0, teff=5750., logg=4.5)
sun.wavelength, sun.flux # plain numpy arrays
sun.PlotSpectrum()
sun.GetFlux([5000., 5500., 6000.], kind="cubicspline") # or "linear" / "cubic"Besides "Kurucz" and "BT-Settl", any model collection id listed on the Theoretical Spectra Webserver works, e.g. "koester2" or "coelho_sed". Collections with extra axes accept them as keyword arguments (e.g. alpha=0.0 for BT-Settl).
Note that interpolation between grid points is not implemented yet - read_spectrum and SynSpectrum always return an actual model from the grid.
The older pysvo.synthspectra module is deprecated: SynSpectrum now lives in pysvo.svomodels, and synthspectra is kept only as a compatibility wrapper around it.
Check out the tutorial in this directory.
The code would be useless without the huge effort by the SVO group at CAB to create and maintain the Spanish VO services. Thus, if you make use of pysvo as part of your work, please link to this repository and include the following acknowledgement in your publication:
This research has made use of the SVO Filter Profile Service (http://svo2.cab.inta-csic.es/theory/fps/) supported from the Spanish MINECO through grant AYA2017-84089.
If you use the Filter Profile Service, then the SVO team also appreciates if you could include the following references in your publication:
The SVO Filter Profile Service. Rodrigo, C., Solano, E., Bayo, A. http://ivoa.net/documents/Notes/SVOFPS/index.html
The Filter Profile Service Access Protocol. Rodrigo, C., Solano, E. http://ivoa.net/documents/Notes/SVOFPSDAL/index.html
Please send questions/doubts/bug reports to fanders@icc.ub.edu or sagar@fqa.ub.edu.