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.

Imports:

import matplotlib
matplotlib.use('pdf')
import matplotlib.pyplot as p
import os 
import astropy.cosmology as co
cosmo=co.FlatLambdaCDM(H0=70,Om0=0.3)
import astropy.units as u
import astropy.io.fits as fits
import numpy as n
from scipy.optimize import curve_fit
from scipy.interpolate import interp1d
from scipy.stats import scoreatpercentile
import astropy.io.fits 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.

Parameters:
  • 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)
fit_lines_to_fullSpectrum()[source]

Fits the emission lines on the line spectrum.

fit_lines_to_fullSpectrum_tutorial()[source]

Fits the emission lines on the line spectrum.

fit_lines_to_lineSpectrum()[source]

Fits the emission lines on the line spectrum.

fit_lines_to_lineSpectrum_tutorial()[source]

Fits the emission lines on the line spectrum.

interpolate_model()[source]

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

interpolate_stack()[source]

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

save_spectrum()[source]

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

subtract_continuum_model()[source]

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

ModelSpectraStacks.kl(ll)[source]

Calzetti extinction law