Stellar population model

This class is dedicated to handling the fitting of the stellar population model with the FIREFLY code, see Wilkinson et al. 2015.

General purpose:

The class StellarPopulationModel is a wrapper dedicated to handling the fit of stellar population models on observed spectra. It gathers all inputs : from the model and from the data.


import numpy as np
import as pyfits
import astropy.units as u
import glob
import pandas as pd
import os
from firefly_instrument import *
from firefly_dust import *
from firefly_fitter import *
from firefly_library import *
class StellarPopulationModel.StellarPopulationModel(specObs, outputFile, cosmo, models='m11', model_libs=['MILES_UVextended'], imfs=['ss', 'kr'], hpf_mode='on', age_limits=[6, 10.1], downgrade_models=True, dust_law='calzetti', max_ebv=1.5, num_dust_vals=200, dust_smoothing_length=200, max_iterations=10, fit_per_iteration_cap=1000, pdf_sampling=300, data_wave_medium='vacuum', Z_limits=[-0.1, 0.1], wave_limits=[0, 99999990], suffix='-fireflyFits.fits', use_downgraded_models=False)[source]

Choose between MILES, MILES revisednearIRslope, MILES UVextended, STELIB, ELODIE, MARCS.

  • MILES, MILES revisednearIRslope, MILES UVextended, STELIB, ELODIE are empirical libraries.
  • MARCS is a theoretical library.

choose the initial mass function:


This is how it proceeds :
  1. reads the parameter file by using parameters_obtain(
  2. It opens the data file, model files, then it matches their resolutions by downgrading the models to instrumental and velocity dispersion resolution
  3. Determines dust attenuation curve to be applied to the models. Two options : through HPF fitting (3.1.) or through filtered values to determing SP properties (3.2.).
  4. It fits the models to the data
  5. Gets mass-weighted SSP contributions using saved M/L ratio.
  6. Convert chis into probabilities and calculates all average properties and errors (assuming the number of degrees of freedom is the number of wavelength points)
  7. Optionally produces a plot
  8. Finally, it writes the output files
Once the data and models are loaded, then execute this function to find the best model. It loops overs the models to be fitted on the data:
  1. gets the models
  2. matches the model and data to the same resolution
  3. normalises the spectra
get_model(model_used, imf_used, deltal, vdisp, wave_instrument, r_instrument, ebv_mw)[source]

Retrieves all relevant model files, in their downgraded format. If they aren’t downgraded to the correct resolution / velocity dispersion, takes the base models in their native form and converts to downgraded files.

  • model_used – list of models to be used, for example [‘m11’, ‘m09’].
  • imf_used – list of imf to be used, for example [‘ss’, ‘cha’].
  • deltal – delta lambda in the models.
  • vdisp – velocity dispersion observed in the galaxy.
  • wave_instrument – wavelength array from the observations
  • r_instrument – resolution array from the observations
  • ebv_mw – E(B-V) from the dust maps for the galaxy.
  1. loads the models m11 or m09: maps parameters to the right files. Then it constructs the model array. Finally converts wavelengths to air or vacuum.
  2. downgrades the model to match data resolution
  3. applies attenuation
  4. stores models in
    self.model_wavelength, self.model_flux, self.age_model, self.metal_model

and returns it as well