Getting Started#
Installation#
The preferred method to install spextra
is using pip
:
pip install spextra
To install the development version, it is possible to clone the repository and run a local install:
git clone https://github.com/AstarVienna/speXtra.git
cd speXtra
pip install -e .
Keep in mind that the current dev version installed from GitHub may not be stable! We recommend this only for advanced users, if you know why you need to install the dev version.
Dependencies#
The following dependencies are necessary to run speXtra
Additionally, you may need the following libraries for specific purposes.
matplotlib for plotting
specutils optional for loading external spectra in other formats (not required for basic function)
Basic functionality#
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 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
The new spectrum will be the sum of the two components
Scaling to a magnitude#
from astropy import units as u
sp1 = Spextrum("kc96/s0")
sp2 = sp1.scale_to_magnitude(amplitude=13 * u.ABmag, filter_curve="g")
Obtaining magnitudes from spectra#
mag = sp1.get_magnitude(filter_curve="g")
print(mag)
13.034556369593835 mag(AB)
Redshifting the spectra#
It is possible to specify a redshift z
ir a velocity vel
(negative velocities are allowed)
sp3 = sp2.redshift(z=1)
vel = -1000 * u.km / u.s
sp2 = sp1.redshift(vel=vel)