Library of functions to model stacks of spectra

This class is model the stacks spectra produced by SpectraStacking

General purpose:

The class ModelSpectraStacks is dedicated to modelling and extracting information from stacks of spectra.


import matplotlib
import matplotlib.pyplot as p
import os 
import astropy.cosmology as co
import astropy.units as u
import as fits
import numpy as n
from scipy.optimize import curve_fit
from scipy.interpolate import interp1d
from scipy.stats import scoreatpercentile
import as fits
from lineListAir import *
import LineFittingLibrary as lineFit
class ModelSpectraStacks.ModelSpectraStacks(stack_file, mode='MILES', cosmo=FlatLambdaCDM(name="Planck13", H0=67.8 km / (Mpc s), Om0=0.307, Tcmb0=2.725 K, Neff=3.05, m_nu=[ 0. 0. 0.06] eV, Ob0=0.0483), firefly_min_wavelength=1000.0, firefly_max_wavelength=7500.0, dV=-9999.99, N_spectra_limitFraction=0.8, tutorial=False, eboss_stack=False)[source]

This class fits the emission lines on the continuum-subtracted stack.

  • stack_file – fits file generated with a LF in a luminosity bin.
  • cosmo – cosmology class from astropy
  • firefly_min_wavelength – minimum wavelength considered by firefly (default : 1000)
  • firefly_max_wavelength – minimum wavelength considered by firefly (default : 7500)
  • dV – default value that hold the place (default : -9999.99)
  • N_spectra_limitFraction – If the stack was made with N spectra. N_spectra_limitFraction selects the points that have were computed using more thant N_spectra_limitFraction * N spectra. (default : 0.8)

Fits the emission lines on the line spectrum.


Fits the emission lines on the line spectrum.


Fits the emission lines on the line spectrum.


Fits the emission lines on the line spectrum.


Interpolates the model to an array with the same coverage as the stack.


Divides the measured stack in overlapping and non-overlapping parts with the model.


Saves the stack spectrum, the model and derived quantities in a single fits file with different hdus.


Creates the continuum substracted spectrum: the ‘line’ spectrum.


Calzetti extinction law