synthesizer.parametric.sf_hist¶
A submodule for creating and manipulating star formation histories.
- NOTE: This module is imported as SFH in parametric.__init__ enabling the syntax
shown below.
Example usage:
from synthesizer.parametric import SFH
print(SFH.parametrisations)
sfh = SFH.Constant(…) sfh = SFH.Exponential(…) sfh = SFH.LogNormal(…)
sfh.calculate_sfh()
Classes
- class synthesizer.parametric.sf_hist.CombinedSFH(sfhs, weights=None)[source]¶
A combined SFH model that uses multiple SFH models.
This class allows for the combination of different SFH models (e.g., Continuity, Dirichlet) into a single SFH model. It provides methods to calculate the SFR and mass formed in each bin.
- sfhs¶
List of SFH model instances to combine.
- Type:
list
- name¶
Name of the combined SFH model.
- Type:
str
- class synthesizer.parametric.sf_hist.Common(name, **kwargs)[source]¶
The parent class for all SFH parametrisations.
- name¶
The name of this SFH. This is set by the child and encodes the type of the SFH. Possible values are defined in parametrisations above.
- Type:
str
- parameters¶
A dictionary containing the parameters of the model.
- Type:
dict
- calculate_mean_age(t_range=(0, 10000000000), dt=1000000)[source]¶
Calculate the median age of a given star formation history.
- Parameters:
t_range (tuple, float) – The age limits over which to calculate the SFH.
dt (float) – The interval between age bins.
- Returns:
The mean age of the star formation history.
- Return type:
unyt_array
- calculate_median_age(t_range=(0, 10000000000), dt=1000000)[source]¶
Calculate the median age of a given star formation history.
- Parameters:
t_range (tuple, float) – The age limits over which to calculate the SFH.
dt (float) – The interval between age bins.
- Returns:
The median age of the star formation history.
- Return type:
unyt_array
- calculate_sfh(t_range=(0, 10000000000), dt=1000000)[source]¶
Calculate the star formation history over a specified time range.
- Parameters:
t_range (tuple, float) – The age limits over which to calculate the SFH.
dt (float) – The interval between age bins.
- Returns:
The age bins. sfh (np.ndarray of float):
The SFH in units of 1 / yr.
- Return type:
t (np.ndarray of float)
- get_sfr(age)[source]¶
Calculate the star formation in each bin.
- Parameters:
age (float) – The age at which to calculate the SFR.
- Returns:
- sfr (float/np.ndarray of float)
The SFR at the passed age. Either as a single value or an array for each age in age.
- classmethod init_from_prior(**kwargs)[source]¶
Initialise the SFH from its prior distribution.
Expects each parameter either as a single value or a length 2 list/tuple/np.ndarray defining a uniform prior.
- Parameters:
**kwargs (dict) – Additional keyword arguments to pass to the child class initialiser.
- Returns:
An instance of the child class.
Examples using synthesizer.parametric.sf_hist.Common¶
Compare different parametric star formation history models
Demonstrate the dense basis approach for describing the SFZH
An example showing how to scale a galaxy’s mass by luminosity/flux.
- class synthesizer.parametric.sf_hist.Constant(max_age=unyt_quantity(100, 'yr'), min_age=unyt_quantity(0, 'yr'), duration=None)[source]¶
A constant star formation history.
- The SFR is defined such that:
sfr = 1; min_age<t<=max_age sfr = 0; t>max_age, t<min_age
- max_age¶
The age above which the star formation history is truncated.
- Type:
unyt_quantity
- min_age¶
The age below which the star formation history is truncated.
- Type:
unyt_quantity
Examples using synthesizer.parametric.sf_hist.Constant¶
Compare different parametric star formation history models
An example showing how to scale a galaxy’s mass by luminosity/flux.
- class synthesizer.parametric.sf_hist.Continuity(logsfr_ratios=None, agebins=None, min_age=unyt_quantity(0, 'yr'), max_age=unyt_quantity(1.e+11, 'yr'))[source]¶
Non-parametric SFH model of mass in fixed bins with a smoothness prior.
See Leja et al. 2019 for details on the model. This model uses log SFR ratios between adjacent bins with a Student-t prior to ensure smoothness in the star formation history.
Attributes: - logsfr_ratios (np.ndarray):
Array of log_10(SFR_j / SFR_{j+1}) values for adjacent bins.
agebins (unyt_array, optional): Array of shape (N, 2) with age bin edges in time units (e.g., years.) If None, uses default 3-bin setup: [[0,8], [8,9], [9,10]] (log10 yr).
- masses (np.ndarray):
The stellar mass formed in each age bin (computed from parameters).
- min_age (unyt_quantity):
The minimum age for truncation.
- max_age (unyt_quantity):
The maximum age for truncation.
- class synthesizer.parametric.sf_hist.ContinuityFlex(logsfr_ratio_young=0.0, logsfr_ratio_old=0.0, logsfr_ratios=None, fixed_young_bin=None, fixed_old_bin=None, min_age=unyt_quantity(0, 'yr'), max_age=unyt_quantity(1.e+11, 'yr'))[source]¶
Continuity Flex SFH model.
A non-parametric SFH model with fixed young and old bins, and flexible intermediate bins. Uses log SFR ratios between adjacent bins with a Student-t prior to ensure smoothness in the star formation history. See Leja et al. 2019 for details.
- logsfr_ratio_young¶
Log SFR ratio for the youngest bin (default: 0.0).
- Type:
float
- logsfr_ratio_old¶
Log SFR ratio for the oldest bin (default: 0.0).
- Type:
float
- logsfr_ratios¶
Array of log SFR ratios for flexible bins. If None, defaults to [0.0, 0.0].
- Type:
array-like, optional
- fixed_young_bin¶
Fixed age bin for the youngest bin as [start, end] in log10 years. If None, defaults to [0.0, 7.5] (log10 years).
- Type:
list, optional
- fixed_old_bin¶
Fixed age bin for the oldest bin as [start, end] in log10 years. If None, defaults to [9.7, 10.136] (log10 years).
- Type:
list, optional
- min_age¶
The minimum age for truncation (default: 0 yr).
- Type:
unyt_quantity
- max_age¶
The maximum age for truncation (default: 1e11 yr).
- Type:
unyt_quantity
- Raises:
ValueError – If fixed_young_bin or fixed_old_bin
are not lists of length 2. –
TypeError – If logsfr_ratios is not an array-like type
or convertible to an array. –
AssertionError – If fixed_young_bin or fixed_old_bin
are not lists of length 2. –
TypeError – If fixed_young_bin or fixed_old_bin
are not unyt_arrays or convertible to unyt_arrays. –
- classmethod init_from_prior(N_flex_bins, fixed_young_bin, fixed_old_bin, df=2, scale=0.3, min_age=unyt_quantity(0, 'yr'), max_age=unyt_quantity(1.e+11, 'yr'), limits=(-10, 10))[source]¶
Initialize Continuity Flex SFH from a student t prior distribution.
- Parameters:
N_flex_bins (int) – Number of flexible bins between fixed young and old bins.
fixed_young_bin (list) – Fixed age bin for the youngest bin as [start, end] in log10 years.
fixed_old_bin (list) – Fixed age bin for the oldest bin as [start, end] in log10 years.
df (int) – Degrees of freedom for the student t prior.
scale (float) – Scale parameter for the student t prior.
min_age (float) – Minimum age for the SFH in years.
max_age (float) – Maximum age for the SFH in years.
limits (tuple) – Limits for the student t prior (SFR ratio).
- Returns:
An instance of the ContinuityFlex class.
- Return type:
- class synthesizer.parametric.sf_hist.ContinuityPSB(logsfr_ratio_young=0.0, logsfr_ratio_old=None, logsfr_ratios=None, tlast=unyt_quantity(2.e+08, 'yr'), tflex=unyt_quantity(2.e+09, 'yr'), nflex=5, nfixed=3, min_age=unyt_quantity(0, 'yr'), max_age=unyt_quantity(1.38e+10, 'yr'))[source]¶
A non-parametric SFH model for post-starburst galaxies.
This model, based on Suess et al. (2021), uses a combination of fixed-width and flexible-boundary time bins to model the star formation history (SFH). A smoothness prior, based on a Student’s t-distribution, is applied to the logarithmic ratios of SFRs in adjacent time bins.
The time bins are structured from youngest to oldest as follows: 1. A single “youngest” bin of variable width tlast. 2. A set of nflex bins spanning the time from tlast to tflex. 3. A set of nfixed bins spanning the time from tflex to max_age.
- logsfr_ratio_young¶
The log10 ratio of SFR in the youngest bin to the subsequent bin.
- Type:
float
- logsfr_ratio_old¶
An array of log10 SFR ratios for the nfixed oldest bins.
- Type:
np.ndarray
- logsfr_ratios¶
An array of log10 SFR ratios for the nflex-1 intermediate flexible bins.
- Type:
np.ndarray
- tlast¶
The temporal width of the youngest age bin.
- Type:
unyt.unyt_quantity
- tflex¶
The lookback time marking the transition from flexible to fixed bins.
- Type:
unyt.unyt_quantity
- nflex¶
The number of flexible bins.
- Type:
int
- nfixed¶
The number of fixed oldest bins.
- Type:
int
- max_age¶
The age of the Universe at the time of observation, which truncates the SFH.
- Type:
unyt.unyt_quantity
- min_age¶
The age below which the SFH is truncated (typically 0).
- Type:
unyt.unyt_quantity
- classmethod init_from_prior(nflex=5, nfixed=3, tflex=unyt_quantity(2., 'Gyr'), max_age=unyt_quantity(13.8, 'Gyr'), student_t_df=2.0, student_t_scale=1.0, tlast_limits_gyr=(0.01, 1.5), **kwargs)[source]¶
Initialize ContinuityPSB SFH by drawing parameters from priors.
This method creates an example SFH based on the priors defined in the model. The logsfr_ratio* parameters are drawn from a Student’s t-dist, and tlast is drawn from a uniform (top-hat) distribution.
- Parameters:
nflex (int) – Number of flexible bins. Defaults to 5.
nfixed (int) – Number of fixed oldest bins. Defaults to 3.
tflex (unyt.unyt_quantity) – Transition time from flexible to fixed bins. Defaults to 2 Gyr.
max_age (unyt.unyt_quantity) – Maximum age for SFH truncation. Defaults to 13.8 Gyr.
student_t_df (float) – Degrees of freedom for the Student’s t-distribution prior. Defaults to 2.0.
student_t_scale (float) –
- Scale parameter for the Student’s t-distribution prior.
Defaults to 0.3.
tlast_limits_gyr (tuple) – The (min, max) limits for the uniform prior on tlast, in Gyr. Defaults to (0.01, 1.5).
**kwargs – Additional keyword arguments to pass to the constructor (e.g., min_age).
- Returns:
An instance of the class with parameters drawn from priors.
- Return type:
- class synthesizer.parametric.sf_hist.DecliningExponential(tau, max_age, min_age=unyt_quantity(0., 'yr'))[source]¶
A declining exponential star formation history.
- tau¶
The “stretch” parameter of the exponential.
- Type:
unyt_quantity
- max_age¶
The age above which the star formation history is truncated.
- Type:
unyt_quantity
- min_age¶
The age below which the star formation history is truncated.
- Type:
unyt_quantity
- class synthesizer.parametric.sf_hist.DelayedExponential(tau, max_age, min_age=unyt_quantity(0., 'yr'))[source]¶
A delayed exponential star formation history that can be truncated.
The “delayed” element results in a more gradual increase at earlier times.
- tau¶
The “stretch” parameter of the exponential.
- Type:
unyt_quantity
- max_age¶
The age above which the star formation history is truncated.
- Type:
unyt_quantity
- min_age¶
The age below which the star formation history is truncated.
- Type:
unyt_quantity
Examples using synthesizer.parametric.sf_hist.DelayedExponential¶
Compare different parametric star formation history models
- class synthesizer.parametric.sf_hist.DenseBasis(db_tuple, redshift)[source]¶
Dense Basis representation of a SFH.
See here for more details on the Dense Basis method.
https://dense-basis.readthedocs.io/en/latest/
- db_tuple¶
Dense basis parameters describing the SFH 1) total mass formed 2) SFR at the time of observation (see redshift) 3) number of tx parameters 4) times when the galaxy formed fractions of its mass,
units of fraction of the age of the universe [0-1]
- Type:
tuple
- redshift¶
redshift at which to scale the SFH
- Type:
float
- classmethod init_from_prior(N_tx, log_mass, log_sfr, redshift, tx_alpha=1.0)[source]¶
Initialise Dense Basis SFH from prior distributions.
- Parameters:
N_tx (int) – Number of time parameters to use in the Dense Basis SFH.
log_mass (float | 2-component tuple) – log_10 of the total mass formed in the SFH.
log_sfr (float | 2-component tuple) – log_10 of the SFR at the time of observation.
redshift (float | 2-component tuple) – redshift at which to scale the SFH.
tx_alpha (float) – Concentration parameter for the Dirichlet prior on the time parameters. Higher values produce more uniform time
Examples using synthesizer.parametric.sf_hist.DenseBasis¶
Demonstrate the dense basis approach for describing the SFZH
- class synthesizer.parametric.sf_hist.Dirichlet(z_fraction=None, agebins=None, min_age=unyt_quantity(0, 'yr'), max_age=unyt_quantity(1.e+11, 'yr'))[source]¶
A non-parametric SFH with Dirichlet prior on SFR fractions.
See Leja et al. 2017, 2019 for details on the model.
This model uses independent Beta-distributed variables that are transformed
to SFR fractions following a Dirichlet distribution.
- z_fraction¶
Array of latent variables from Beta(1,1) distributions. Length should be (nbins-1). If None, defaults to zeros.
- Type:
array-like, optional
- agebins¶
Array of shape (N, 2) with age bin edges in log(years). If None, uses default 3-bin setup.
- Type:
unyt_array, optional
- min_age¶
The minimum age for SFH truncation.
- Type:
unyt_quantity
- max_age¶
The maximum age for SFH truncation.
- Type:
unyt_quantity
- get_mass_fractions()[source]¶
Get the mass fractions in each bin.
Returns: np.ndarray: The fraction of total mass in each age bin.
- get_sfr_fractions()[source]¶
Get the SFR fractions in each bin.
Returns: np.ndarray: The fraction of total SFR in each age bin.
- classmethod init_from_prior(agebins, loc=1.0, scale=1.0, **kwargs)[source]¶
Initialize Dirichlet SFH from a prior distribution.
- Parameters:
agebins (unyt_array) – Array of shape (N, 2) with age bin edges in log(years).
loc (float) – Location parameter for the Beta distribution (default: 1.0).
scale (float) – Scale parameter for the Beta distribution (default: 1.0).
**kwargs – Additional keyword arguments for the class constructor.
- class synthesizer.parametric.sf_hist.DoublePowerLaw(peak_age, alpha, beta, min_age=unyt_quantity(0, 'yr'), max_age=unyt_quantity(1.e+11, 'yr'))[source]¶
A double power law star formation history.
- peak_age¶
The age at which the star formation history peaks.
- Type:
unyt_quantity
- alpha¶
The first power.
- Type:
float
- beta¶
The second power.
- Type:
float
- max_age¶
The age above which the star formation history is truncated.
- Type:
unyt_quantity
- min_age¶
The age below which the star formation history is truncated.
- Type:
unyt_quantity
Examples using synthesizer.parametric.sf_hist.DoublePowerLaw¶
Compare different parametric star formation history models
- class synthesizer.parametric.sf_hist.Exponential(tau, max_age, min_age=unyt_quantity(0., 'yr'))[source]¶
A exponential star formation history that can be truncated.
- Note: synthesizer uses age (not t) as its parameter such that:
t = max_age - age
- tau¶
The “stretch” parameter of the exponential.
- Type:
unyt_quantity
- max_age¶
The age above which the star formation history is truncated.
- Type:
unyt_quantity
- min_age¶
The age below which the star formation history is truncated.
- Type:
unyt_quantity
Examples using synthesizer.parametric.sf_hist.Exponential¶
Compare different parametric star formation history models
- class synthesizer.parametric.sf_hist.Gaussian(peak_age, sigma, max_age=unyt_quantity(1.e+11, 'yr'), min_age=unyt_quantity(0, 'yr'))[source]¶
A Gaussian star formation history.
- peak_age¶
The age at which the star formation peaks, i.e. the age at which the gaussian is centred.
- Type:
unyt_quantity
- sigma¶
The standard deviation of the gaussian function.
- Type:
unyt_quantity
- max_age¶
The age above which the star formation history is truncated.
- Type:
unyt_quantity
- min_age¶
The age below which the star formation history is truncated.
- Type:
unyt_quantity
Examples using synthesizer.parametric.sf_hist.Gaussian¶
Compare different parametric star formation history models
- class synthesizer.parametric.sf_hist.LogNormal(tau, peak_age, max_age, min_age=unyt_quantity(0, 'yr'))[source]¶
A log-normal star formation history.
- tau¶
The dimensionless “width” of the log normal distribution.
- Type:
float
- peak_age¶
The peak of the log normal distribution.
- Type:
float
- max_age¶
The maximum age of the log normal distribution. In addition to truncating the star formation history this is used to define the peak.
- Type:
unyt_quantity
- min_age¶
The age below which the star formation history is truncated.
- Type:
unyt_quantity
Examples using synthesizer.parametric.sf_hist.LogNormal¶
Compare different parametric star formation history models
- class synthesizer.parametric.sf_hist.TruncatedExponential(tau, max_age, min_age)[source]¶
A truncated exponential star formation history.
- tau¶
The “stretch” parameter of the exponential.
- Type:
unyt_quantity
- max_age¶
The age above which the star formation history is truncated.
- Type:
unyt_quantity
- min_age¶
The age below which the star formation history is truncated.
- Type:
unyt_quantity