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=None, morphology=None, sfzh=None, sf_hist=None, metal_dist=None, fesc=None, fesc_ly_alpha=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
- 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.
- get_metal_dist()[source]¶
Get the metallicity distribution of the stellar population.
- Returns:
The metallicity distribution of the stellar population.
- Return type:
unyt_array
- get_sfh()[source]¶
Get the star formation history of the stellar population.
- Returns:
The star formation history of the stellar population.
- Return type:
unyt_array
- get_sfzh(log10ages, metallicities, grid_assignment_method='cic', nthreads=0)[source]¶
Generate the binned SFZH history of this stellar component.
In the parametric case this will resample the existing SFZH onto the desired grid. For a particle based component the binned SFZH is calculated by binning the particles onto the desired grid defined by the input log10ages and metallicities.
For a particle based galaxy the binned SFZH produced by this method is equivalent to the weights used to extract spectra from the grid.
- Parameters:
log10ages (array-like, float) – The log10 ages of the desired SFZH.
metallicities (array-like, float) – The metallicities of the desired SFZH.
grid_assignment_method (string) – The type of method used to assign particles to a SPS grid point. Allowed methods are cic (cloud in cell) or nearest grid point (ngp) or their uppercase equivalents (CIC, NGP). Defaults to cic. (particle only)
nthreads (int) – The number of threads to use in the computation. If set to -1 all available threads will be used. (particle only)
- Returns:
Numpy array of containing the SFZH.
- Return type:
numpy.ndarray
- get_weighted_attr(attr)[source]¶
Get a weighted attribute of the stellar population.
- Parameters:
attr (str) – The attribute to get.
axis (int) – The axis to sum over.
- Returns:
The weighted attribute.
- Return type:
unyt_quantity
- plot_metal_dist(xlimits=(), ylimits=(), show=True)[source]¶
Plot the metallicity distribution of the stellar population.
- Parameters:
xlimits (tuple) – The limits of the x-axis.
ylimits (tuple) – The limits of the y-axis.
show (bool) – Should we invoke plt.show()?
- Returns:
- fig
The Figure object contain the plot axes.
- ax
The Axes object containing the plotted data.
- plot_sfh(xlimits=(), ylimits=(), show=True)[source]¶
Plot the star formation history of the stellar population.
- Parameters:
xlimits (tuple) – The limits of the x-axis.
ylimits (tuple) – The limits of the y-axis.
show (bool) – Should we invoke plt.show()?
- Returns:
- fig
The Figure object contain the plot axes.
- ax
The Axes object containing the plotted data.
- 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.