synthesizer.parametric.stars

A module for creating and manipulating parametric stellar populations.

This is the parametric analog of particle.Stars. It not only computes and holds the SFZH grid but everything describing a parametric Galaxy’s stellar component.

Example usage:

stars = Stars(log10ages, metallicities, sfzh=sfzh)
stars.get_spectra(emission_model)
stars.plot_spectra()

Classes

class synthesizer.parametric.stars.Stars(log10ages, metallicities, initial_mass=1.0, morphology=None, sfzh=None, sf_hist=None, metal_dist=None, **kwargs)[source]

The parametric stellar population object.

This class holds a binned star formation and metal enrichment history describing the age and metallicity of the stellar population, an optional morphology model describing the distribution of those stars, and various other important attributes for defining a parametric stellar population.

ages

The array of ages defining the age axis of the SFZH.

Type:

array-like, float

metallicities

The array of metallicitities defining the metallicity axies of the SFZH.

Type:

array-like, float

initial_mass

The total initial stellar mass.

Type:

unyt_quantity/float

morphology

An instance of one of the morphology classes describing the stellar population’s morphology. This can be any of the family of morphology classes from synthesizer.morphology.

Type:

morphology.* e.g. Sersic2D

sfzh

An array describing the binned SFZH. If provided all following arguments are ignored.

Type:

array-like, float

sf_hist

An array describing the star formation history.

Type:

array-like, float

metal_dist

An array describing the metallity distribution.

Type:

array-like, float

sf_hist_func

An instance of one of the child classes of SFH. This will be used to calculate sf_hist and takes precendence over a passed sf_hist if both are present.

Type:

SFH.*

metal_dist_func

An instance of one of the child classes of ZH. This will be used to calculate metal_dist and takes precendence over a passed metal_dist if both are present.

Type:

ZH.*

instant_sf

An age at which to compute an instantaneous SFH, i.e. all stellar mass populating a single SFH bin.

Type:

float

instant_metallicity

A metallicity at which to compute an instantaneous ZH, i.e. all stellar populating a single ZH bin.

Type:

float

log10ages_lims

The log10(age) limits of the SFZH grid.

Type:

array_like_float

metallicities_lims

The metallicity limits of the SFZH grid.

Type:

array-like, float

log10metallicities_lims

The log10(metallicity) limits of the SFZH grid.

Type:

array-like, float

metallicity_grid_type
The type of gridding for the metallicity axis. Either:
  • Regular linear (“Z”)

  • Regular logspace (“log10Z”)

  • Irregular (None)

Type:

string

calculate_mean_age()[source]

Calculate the mean age of the stellar population.

calculate_mean_metallicity()[source]

Calculate the mean metallicity of the stellar population.

calculate_median_age()[source]

Calculate the median age of the stellar population.

generate_line(grid, line_id, line_type, fesc, **kwargs)[source]

Calculate rest frame line luminosity and continuum from an SPS Grid.

This is a flexible base method which extracts the rest frame line luminosity of this stellar population from the SPS grid based on the passed arguments.

Parameters:
  • grid (Grid) – A Grid object.

  • line_id (str) – A str denoting a line. Doublets can be specified using a comma (e.g. ‘OIII4363,OIII4959’).

  • line_type (str) – The type of line to extract. This must match a key in the Grid.

  • fesc (float) – The Lyman continuum escaped fraction, the fraction of ionising photons that entirely escaped.

Returns:

Line

An instance of Line contain this lines wavelenth, luminosity, and continuum.

generate_lnu(grid, spectra_name, old=None, young=None, mask=None, lam_mask=None, fesc=0.0, **kwargs)[source]

Calculate rest frame spectra from an SPS Grid.

This is a flexible base method which extracts the rest frame spectra of this stellar popualtion from the SPS grid based on the passed arguments. More sophisticated types of spectra are produced by the get_spectra_* methods on StarsComponent, which call this method.

Parameters:
  • grid (object, Grid) – The SPS Grid object from which to extract spectra.

  • spectra_name (str) – A string denoting the desired type of spectra. Must match a key on the Grid.

  • old (bool/float) – Are we extracting only old stars? If so only SFZH bins with log10(Ages) > old will be included in the spectra. Defaults to False.

  • young (bool/float) – Are we extracting only young stars? If so only SFZH bins with log10(Ages) <= young will be included in the spectra. Defaults to False.

  • mask (array) – An array to mask the SFZH grid. This can be used to mask specific SFZH bins.

  • lam_mask (array, bool) – A mask to apply to the wavelength array of the grid. This allows for the extraction of specific wavelength ranges.

  • fesc (float) – The Lyman continuum escape fraction, the fraction of ionising photons that entirely escape.

Returns:

The Stars’s integrated rest frame spectra in erg / s / Hz.

get_mask(attr, thresh, op, mask=None)[source]

Create a mask using a threshold and attribute on which to mask.

Parameters:
  • attr (str) – The attribute to derive the mask from.

  • thresh (float) – The threshold value.

  • op (str) – The operation to apply. Can be ‘<’, ‘>’, ‘<=’, ‘>=’, “==”, or “!=”.

  • mask (array) – Optionally, a mask to combine with the new mask.

Returns:

mask (array)

The mask array.

plot_sfzh(show=True)[source]

Plot the binned SZFH.

Parameters:

show (bool) – Should we invoke plt.show()?

Returns:

fig

The Figure object contain the plot axes.

ax

The Axes object containing the plotted data.

scale_mass_by_flux(flux, scale_filter, spectra_type)[source]

Scale the mass of the stellar population to match a flux in a specific filter.

NOTE: This will overwrite the initial mass attribute.

Parameters:
  • flux (unyt_quantity) – The desried flux in scale_filter.

  • scale_filter (Filter) – The filter in which flux is measured.

  • spectra_type (str) – The spectra key with which to do this scaling, e.g. “incident” or “emergent”.

Raises
MissingSpectraType

If the requested spectra doesn’t exist an error is thrown.

scale_mass_by_luminosity(lum, scale_filter, spectra_type)[source]

Scale the mass of the stellar population to match a luminosity in a specific filter.

NOTE: This will overwrite the initial mass attribute.

Parameters:
  • lum (unyt_quantity) – The desried luminosity in scale_filter.

  • scale_filter (Filter) – The filter in which lum is measured.

  • spectra_type (str) – The spectra key with which to do this scaling, e.g. “incident” or “emergent”.

Raises
MissingSpectraType

If the requested spectra doesn’t exist an error is thrown.