Getting Started¶
The core of speXtra
is the Spextrum
which is a wrapper of the synphot.SourceSpectrum
with added functionalities.
For example to load a S0
galaxy templates from the The Kinney-Calzetti Spectral Atlas of Galaxies (kc96
) just type
from spextra import Spextrum
sp = Spextrum("kc96/s0")
sp.plot()

The last statement will create a plot of the spectrum for a quick visualization
All operations available in synphot.SourceSpectrum
are possible:
sp1 = Spextrum("kc96/s0")
sp2 = Spextrum("agn/qso")
sp = sp1 + 0.3*sp2
sp.plot()
updating/loading 'libraries/agn/index.yml'
Downloading https://homepage.univie.ac.at/miguel.verdugo/database/libraries/agn/index.yml
[Done]
updating/loading 'libraries/agn/qso.fits'
Downloading https://homepage.univie.ac.at/miguel.verdugo/database/libraries/agn/qso.fits
[Done]

Adding emission lines¶
It is possible to add emission lines, either individually or as a list. Parameters are center, flux and fwhm
astropy.Units
are allowed. If units are not specified it defaults to Angstroms for wavelengths (center and fwhm)
and ergs/s/AA/cm^2 (FLAM) for flux.
import astropy.units as u
sp3 = sp1.add_emi_lines(center=4000,flux=4e-13, fwhm=5*u.AA)
sp3.plot()

Scaling to a magnitude¶
sp1 = Spextrum("kc96/s0")
sp2 = sp1.scale_to_magnitude(amplitude=13 * u.ABmag, filter_curve="g")
sp2.plot()

Obtaining magnitudes from spectra¶
sp1.get_magnitude(filter_curve="g")
Redshifting the spectra¶
It is possible to specify a redshift z
ir a velocity vel
(negative velocities are allowed)
sp3 = sp2.redshift(z=1)
import astropy.units as u
vel = -1000 * u.km / u.s
sp2 = sp1.redshift(vel=vel)
Smooth the spectral¶
Spectra can be smoothed with a kernel with a size in velocities (default km/s)
sp1 = Spextrum("nebulae/pn")
sigma = 500*(u.km / u.s)
sp2 = sp1.smooth(sigma=sigma)
updating/loading 'libraries/nebulae/index.yml'
Downloading https://homepage.univie.ac.at/miguel.verdugo/database/libraries/nebulae/index.yml
[Done]
updating/loading 'libraries/nebulae/pn.fits'
Downloading https://homepage.univie.ac.at/miguel.verdugo/database/libraries/nebulae/pn.fits
[Done]
1000.0 11000.0 0.5