milespy.ssp_library.SSPLibrary

class milespy.ssp_library.SSPLibrary(source='MILES_SSP', version='9.1', isochrone='P', imf_type='ch')

Bases: Repository

Single stellar population (SSP) model library.

This class is used to generate SSP spectra from the repository files.

models

Spectra of all the SSP that form the loaded library

Type:

Spectra

avail_alphas

Available alpha/Fe values in the loaded library

Type:

list

avail_imfs

Available initial mass function (IMF) slopes in the loaded library

Type:

list

source

Name of input models being used

Type:

str

version

Version number of the models

Type:

str

Attributes:
models

Methods

closest(age, met[, alpha, imf_slope, mass])

Retrieve the closest SSP avaiable in the library

from_sfh(sfh)

Compute the spectra derived from the input SFH.

in_list(age, met[, alpha, imf_slope, mass])

Extracts a selected set of models available from the library.

in_range(age_lims, met_lims[, alpha_lims, ...])

Extracts all SSP models within selected limits

interpolate(age, met[, alpha, imf_slope, ...])

Interpolates SSP models for certain parameters using Delaunay triangulation

resample(new_wave)

Resample all the models in the library

trim(lower, upper)

Trim all the models in the library

__init__(source='MILES_SSP', version='9.1', isochrone='P', imf_type='ch')

Creates an instance of the class

Parameters:
  • source (str, default: "MILES_SSP") – Name of input models to use. If none of the options below, it will assume that source is the path to an external model repository file. Valid inputs are MILES_SSP/CaT_SSP/EMILES_SSP

  • version (str, default: "9.1") – version number of the models

  • isochrone (str, default: "P") – Type of isochrone to use. Valid inputs are P/T for Padova+00 and BaSTI isochrones respectively

  • imf_type (str, default: "ch") – Type of IMF shape. Valid inputs are ch/ku/kb/un/bi

Notes

We limit the choice of models to a given isochrone and imf_type for effective loading. Otherwise it can take along time to upload the entire dataset

Return type:

SSPLibrary

closest(age, met, alpha=None, imf_slope=None, mass=<Quantity 1. solMass>)

Retrieve the closest SSP avaiable in the library

Parameters:
  • age (Quantity) – Desired age

  • met (Quantity) – Desired metallicity

  • alpha (Optional[Quantity]) – Desired alpha

  • imf_slope (Optional[Quantity]) – Desired IMF slope

  • mass (Quantity) – Mass of the SSP

Returns:

Closest spectra from the repository.

Return type:

Spectra

Raises:
  • RuntimeError – If the values are out of the grid.

  • ValueError – If the provided parameters do not have the same shape.

from_sfh(sfh)

Compute the spectra derived from the input SFH.

Parameters:

sfh (SFH) – Star formation history

Return type:

Spectra

in_list(age, met, alpha=None, imf_slope=None, mass=None)

Extracts a selected set of models available from the library.

Parameters:
  • age (Quantity) – list of ages to extract

  • met (Quantity) – list of metallicities to extract

  • alpha (Optional[Quantity]) – list of alphas to extract

  • imf_slope (Optional[Quantity]) – list of IMF slopes to extract

  • mass (default 1 solar mass) – mass of each SSP

Notes

All lists must have the same length. This function does not perform any interpolation. Values in the inputs have to be valid ages, mets, alpha, and imf_slopes for the input isochrone and imf_type.

Raises:

ValueError – If inputs do not have the same shape or there is no resulting SSP.

Warns:

If the number of output spectra is different that the input values.

Return type:

Spectra

in_range(age_lims, met_lims, alpha_lims=None, imf_slope_lims=None, mass=<Quantity 1. solMass>)

Extracts all SSP models within selected limits

Parameters:
  • age_lims (Quantity) – tuple with age limits

  • met_lims (Quantity) – tuple with metallicity limits

  • alpha_lims (Optional[Quantity]) – tuple with alpha limits

  • imf_slope_lims (Optional[Quantity]) – tuple with IMF slope limits

  • mass (Quantity) – mass of each SSP

Raises:

ValueError – If there is no matching SSP.

Returns:

Spectra in the selected ranges

Return type:

Spectra

interpolate(age, met, alpha=None, imf_slope=None, mass=<Quantity 1. solMass>, closest=False, simplex=False, force_interp=[])

Interpolates SSP models for certain parameters using Delaunay triangulation

Parameters:
  • age (Quantity) – Desired age

  • met (Quantity) – Desired metallicity

  • alpha (Optional[Quantity]) – Desired alpha

  • imf_slope (Optional[Quantity]) – Desired IMF slope

  • mass (Quantity) – Mass of the SSP

  • closest (bool) – Return the closest spectra, rather than performing the interpolation. If only one interpolation is performed, all the spectra in the simplex vertices are returned.

  • simplex (bool) – If only one set of input parameters is given, return all the spectra that form part of the simplex used for the interpolation. These spectra have the weights information in their meta dictionary.

  • force_interp (List) – Force the interpolation over the indicated variables, even if the asked alpha/imf_slope is sampled in the repository. Valid values are “alpha” and “imf_slope”.

Returns:

Interpolated spectrum. If closest == True, return the closest spectra from the repository, rather than doing the interpolation.

Return type:

Spectra

Raises:
  • RuntimeError – If the values are out of the grid.

  • ValueError – If the provided parameters do not have the same shape.

resample(new_wave)

Resample all the models in the library

Parameters:

new_wave (Quantity) – Spectral axis with the desired sampling for the spectra

See also

milespy.spectra.resample()

trim(lower, upper)

Trim all the models in the library

Parameters:
  • lower (Quantity)

  • upper (Quantity)