Path to the equiprobable binary parameters h5 file, generated from the uncorrelated distributions.
The File is structured in 200 Groups, corresponding to 200
equiprobable m1 values drawn from a Salpeter IMF [1]_.
Each Group is structure in 100 Tables, each corresponding to one of
100 equiprobable logp values drawn for that m1 from the
CompanionFrequencyDistribution class. Each Table holds 1000 lines,
each of which contains one of 1000 equiprobable q,e pairs, from 10
possible q and 10 possible e, drawn from the MassRatioDistribution
and EccentricityDistribution classes. The orbital parameter
distributions are due to Moe & Di Stefano (2017) [2]_.
Compute the embedded cluster initial mass function.
Compute the embedded cluster initial mass function (eIMF) specific
to a given galaxy with a set star formation rate (SFR) and star
formation duration (time). The eIMF is a simple power law between
M_TRUNC_MIN and M_max. The index beta is given as a function of the
SFR, while the normalization constant, k, and m_max result from the
numerical solution of two adequate constraints.
Attributes
beta
sfr : float
Galactic SFR.
timefloat
Duration of ECL formation.
_m_maxfloat
Maximum mass of an ECL.
kfloat
Normalization constant of the eIMF.
Methods
get_mmax_k()
Solves the system of equations made up of methods f1 and f2 to
determine m_max and k.
Notes
The eIMF is as given by Jerabkova et al. (2018) [3]_. M_TRUNC_MIN is
set to the default 5 Msun, and the maximum mass m_max is at most
1e9 Msun. k and m_max are determined from two constraints.
A constant star formation history (SFH) is assumed. Given the
duration of the period of formation of new ECLs within a galaxy,
time, the total galactic stellar ECL mass is m_tot=time*SFR. The
first constraint is obtained by imposing that the total stellar mass
of all ECLs be equal to m_tot, i.e., by equaling to m_tot the
integral of the eIMF between M_TRUNC_MIN and m_max.
The second constraint is obtained by imposing that only one ECL be
found with stellar mass equal to or greater than m_max, i.e., by
equaling to unity the integral of the eIMF between m_max and 1e9.
All masses in this class are given in units of solar mass. The SFR
is given in units of solar masses per year. The ECL formation time
is given in years.
The galactic IMF (gIMF) is computed according to the
integrated galaxy-wide IMF (IGIMF) framework by integrating
the product between the embedded cluster (ECL) and stellar IMFs
(eIMF and sIMF, respectively) over all embedded clusters in the
galaxy. This corresponds to integrating over the product of the imf
methods of the Star and EmbeddedCluster classes with respect to ECL
mass, with all other parameters (including stellar mass) fixed.
Attributes
sfrfloat
SFR of the galaxy.
fehfloat
[Fe/H] metallicity of the galaxy.
timefloat
Duration of the period of ECL formation in the galaxy.
m_trunc_minfloat
Minimum possible stellar mass.
m_trunc_maxfloat
Maximum possible stellar mass.
m_ecl_minfloat
Minimum possible embedded cluster mass.
m_ecl_maxfloat
Maximum mass of embedded clusters in the galaxy.
clustersEmbeddedCluster object
Calculates the eIMF of the galaxy.
m_ecl_arraynumpy array
Array of ECL masses over which to compute the sIMF for
interpolation.
stellar_imf_ip: scipy.interpolate interp1d
Interpolation of the sIMF over ECL masses, for a fixed star
mass.
Methods
get_clusters()
Instantiate an EmbeddedCluster object and compute the maximum
embedded cluster mass.
imf(m)
Integrate the product of the sIMF and eIMF with respect to the
ECL mass, for a given stellar mass.
Warns:
UserWarning – If method imf(m) is run before get_clusters().
Notes
The IGIMF framework is applied as described in Jerabkova et al.
(2018) [3]_, Yan et al. (2017) [4]_ and references therein.
Explicitly, the gIMF at a given stellar mass m is
where M is the ECL stellar mass; Z the galaxy metallicity, assumed
homogeneous. The integration interval is broken into log-uniform
intervals. Integration is performed with Scipy’s quad function.
This constitutes a spatial integration over the whole galaxy for all
the stars formed within the ECLs during a time interval
time, without taking into account the spatial distribution
of star-forming regions or their differing chemical properties.
Thus, the entire galaxy is specified by SFR and feh.
The SFR is given in solar masses per year. The metallicity is
expressed as [Fe/H]. Time is given in years. All masses are given in
solar masses.
This class contains the attributes that are expected by the module
from any choice of broken power-law IMF with an arbitrary number of
breaks, as well as methods for returning dN/dM and integrating the
IMF within an arbitrary interval.
m_totfloat
Total mass of the population described by the IMF.
m_trunc_minfloat
Lower truncation mass, taken as the IMF lower limit.
m_trunc_maxfloat
Upper truncation the same, can be >= m_max.
m_maxfloat
IMF upper limit.
breakslist
Power-law breaks.
exponentslist
Power law exponents with padding. Carries the sign.
normslist
Normalization constants for each range, with padding.
imf(m)
Return dN/dM at mass m.
integrate(m0, m1, mass=False, normalized=True)
Return the integral of imf(m) or m*imf(m) between m0
and m1, for the IMF normalized to m_tot.
In keeping with the convention suggested by Hopkins (2018) [1]_, the
power law index is defined to have the same signal as the power law
slope, i.e.,
\[dN/dM = k M^a.\]
This class is written so that breaks, exponents and norms
may be set by subclasses. These properties’ setters add appropriate
padding that is expected by the imf and integrate methods and
by the norms setter. The m_tot, m_trunc_min and
m_trunc_max properties are defined so that this class will not
overwrite those of a subclass instance for which they are already
set.
All masses are given and expected in solar masses.
Star : subclass for a variable stellar IMF.
EmbeddedCluster : subclass for a variable cluster IMF.
IGIMF : a galaxy IMF from Star and EmbeddedCluster.
Padded broken power-law exponents. The first and last exponents
are repeated in the padding. The padding is expected when
computing the norms and locating the appropriate region for
masses are passed to imf(m) and integrate(m0,m1).
Compute dN/dM at mass m. As some subclasses migh require a
set_mmax_k() method to be run to compute m_max and
the normalization constants, warn the user if m_mas is None.
Parameters:
m (float) – Mass at which to compute dN/dM.
Returns:
dN/dM at m.
Return type:
float
Warns:
UserWarning – If m_max is None (set_mmax_k not run).
Padded broken power-law normalization constants. Zeros are added
in the padding. The padding is expected when computing the norms
and when locating the appropriate region for masses passed to
imf(m) and integrate(m0,m1).
Compute the stellar initial mass function (sIMF) specific to a given
star-forming region (embedded cluster, or ECL), with a set [Fe/H],
and a total ECL stellar mass, m_tot. According to the
invariant attribute, the sIMF might either follow an invariant
Kroupa (2001) [2]_ IMF or a metallicity- and star formation rate-
dependent Jerabkova et al. (2018) [3]_ IMF.
Attributes
x
g1
g2
feh : float
Embedded cluster metallicity in [Fe/H].
m_ecl_minfloat
Absolute minimum embedded cluster mass.
_m_maxfloat
Maximum stellar mass. Embedded cluster-specific.
k1float
m<0.5 IMF normalization constant.
k2float
0.5<=m<1 IMF normalization constant.
k3float
1<= IMF normalization constant.
a1float
First interval power-law index.
a2float
Second interval power-law index.
a3: float
Third interval power-law index.
Methods
get_mmax_k()
Solves the system of equations made up of methods f1 and f2 to
determine m_max and k1.
Notes
If invariant is set to False, the sIMF is as given by Jerabkova et al.
(2018) [3]_. M_TRUNC_MIN is set at the hydrogen burning
threshold of 0.08 Msun. Normalization constants k1 and k2
are found from k3 by continuity. k3 and m_max are
determined from two constraints.
M_TRUNC_MAX sets the mass of the most massive formable star,
m_max, but is not equal to it. Thus, the first constraint is
obtained by imposing that the number of stars found with mass equal
to or higher than m_max be one, i.e., by equating the integral
of the IMF between m_max and M_TRUNC_MAX to unity. This
constraint is expressed in method f1.
m_tot does set the total formed stellar mass. Thus, the second
constraint is obtained by integrating m*imf(m) between
M_TRUNC_MIN and m_max. This constraint is expressed in
methods f1 and f2.
Solving f1 and f2 simultaneously determines m_max and
k3, which also determines k1 and k2. This is done by the
method get_mmax_k.
All masses are given and expected in solar masses.
Use Scipy’s fsolve to solve the two constraints with adequate
initial guesses for k3 and _m_max.
After solving for k3 and _m_max, k1 and k2 are immediately
determined. Automatically sets the IMF to zero for all
masses if the star-forming region mass is below a minimum of 5
solar masses.
Generate a grid of galaxy properties over redshift.
This class uses the galaxy stellar mass function (GSMF), star
formation-mass relation (SFMR) and mass-metallicity relation (MZR)
models from the sfh module to sample the space of galaxy
parameters (stellar mass, redshift, star formation rate and
metallicity).
A set of n_redshift redshifts is sampled first, and only
then are the other three parameters sampled,
logm_per_redshift sets per redshift. Unless
scatter_model is set to normal, the redshift plus any one
parameter fully determines the others.
Mass is given in solar masses, star formation rate in solar masses
per year, and the metallicity is [Fe/H].
Parameters:
n_redshift (int) – Number of redshift to sample.
redshift_min (float, default : 0.) – Minimum redshift to sample.
redshift_max (float, default : 10.) – Maximum redshift to sample.
force_boundary_redshift (bool, default : True,) – Whether to manually add redshift_min and
redshift_max to the sample.
logm_per_redshift (int, default : 3) – Number of masses to sample per redshift.
logm_min (float, default : 7) – Minimum log10(mass) to sample.
logm_max (float, default : 12) – Maximum log10(mass) to sample.
gsmf_slope_fixed (bool, default: True) – Whether to use the fixed (True) or the varying (False)
GSMF low-mass slope model.
sampling_mode ({'mass', 'number', 'uniform'}, default : 'mass') – Method for sampling masse from the GSMF.
scatter_model (str, default : 'none') – Scatter model to use in the SFMR and MZR.
apply_igimf_corrections (bool, default : True,) – Whether to correct the SFR for imf.IGIMF.
random_state (int) – Random number generator seed.
Attributes
n_redshiftint
Number of redshift values in the grid.
redshift_minfloat
Minimum redshift to sample.
redshift_maxfloat
Maximum redshift to sample.
force_boundary_redshiftbool
Whether to forcefully add redshifts redshift_min and
redshift_min to the sample, thus making its size
(n_redshift+2)*logm_per_redshift.
logm_per_redshiftint
Number of galactic stellar masses to sample per redshift.
logm_minfloat
Minimum log10(mass) to sample.
logm_maxfloat
Maximum log10(mass) to sample.
sample_redshift_arrayNDArray
Redshift sample defining the grid.
sample_redshift_binsNDArray
Limits of the bins represented by sample_redshift_array.
sample_logm_arrayNDArray
Galaxy stellar mass samples for each redshift in
sample_redshift_array.
sample_logm_binsNDArray
Limits of the bins represented by sample_logm_array,
per redshift.
gsmf_slope_fixedbool
Whether the GSMF low-mass slope should be fixed or not.
random_stateint
Random number generator seed.
apply_igimf_correctionsbool
Whether to correct the SFR for imf.IGIMF.
zoh_bin_arrayNDArray
Edges of Z_OH bins represented by zoh_array.
zoh_arrayNDArray
Z_OH values sampled at each redshift.
ndensity_arrayNDArray
Number density of galaxies represented by each grid point.
density_arrayNDArray
Stellar mass density of galaxies represented by each grid point.
mass_listlist
List of n_redshift arrays, containing the galaxy stellar
masses sampled at each redshift.
log_gsmf_listlist
List of n_redshift arrays, containing the log10(gsmf)
values (galaxy number density) sampled at each redshift.
zoh_listlist
List of n_redshift arrays, containing the Z_OH values
sampled at each redshift.
feh_listlist
List of n_redshift, containing the [Fe/H] values
sampled at each redshift.
sfr_listlist
List of n_redshift arrays, containing the SFR values
sampled at each redshift.
grid_arraynumpy_array
Shape (n_redshift,logm_per_redshift,6) array containing
the full grid of galaxy properties.
Notes
This class first samples the redshift, and then for each redshift
a fixed number of “galaxies”, i.e., (mass, metallicity, SFR) sets.
The final grid of galaxies is stored as grid_array, and can
also be written to disk as a .pkl file with Pandas by calling
save_grid(). The _array attributes are used to build
grid_array. The _list attributes are not used
internally, but were instead necessary for older versions of data
analysis/processing and test notebooks.
sample_redshift_array is initialized as a sample of
evenly-space redshifts between the set minimum and maximum.
sample_redshift() must be run to get a sample from the GSMF.
It is recommended not to rely on the _list attributes, as they
should be removed in the future.
Sample redshifts from the GSMF integrated over mass.
Integrating the GSMF over mass yields a star forming mass-over-
redshift distribution. A redshift sample is building by dividing
the redshift range redshift_min-redshift_max
into n_redshift quantiles and assigning each one its
mass-weighted average redshift. If
force_boundary_redshift is True, the redshift
upper and lower limits are also added to the sample.
This class performs a number- or mass-weighted sampling of galaxy
stellar mass from the galaxy stellar mass function (GSMF) in
sfh.GSMF.
Parameters:
gsmf (sfh.GSMF) – GSMF to sample.
logm_min (float) – Log of sampling interval lower limit.
logm_max (float) – Log of sampling interval upper limit.
size (int) – Sample size.
sampling ({'number', 'mass', 'uniform'}, default : 'number') – Whether to sample by galaxy number, stellar mass, or with
uniform mass bins.
Attributes
gsmfsfh.GSMF
GSMF to sample.
logm_minfloat
Log of sampling interval lower limit.
logm_maxfloat
Log of sampling interval upper limit.
sample_sizeint
Sample size.
bin_limitsNDArray
Limits of sampled mass bins.
grid_ndensity_arrayNDArray
Number density within each mass bin.
grid_density_arrayNDArray
Mass density within each mass bin.
grid_logmassesNDArray
Sampled log galaxy stellar masses.
See Also
GalaxyGrid :
Implements this class to generate a grid of galaxy metallicities
and star-formation rates over redshift.
Notes
The sampling method implemented in this class is equivalent to
computing sample_size quantiles of the GSMF and assigning
each one its average stellar mass. Option sampling='number'
implements this for the GSMF(m) directly, while option
sampling='number' does it for m*GSMF(m). In the future this
class might be streamlined with Numpy’s quantile function.
Option sampling='uniform' sets sample_size uniform-width
log mass bins.
Sampling is performed for a fixed redshift (defined within
gsmf). Besides the log stellar masses
(grid_logmasses), this class also stores the total mass and
number densities contained by each mass bin
(grid_density_array and grid_ndensity_array
respectively).
Generates the galaxy stellar mass samples according to
sampling and stores it in grid_logmasses. Number
and mass densities of galaxies in each bin are also computed
and stored in grid_density_array and
grid_ndensity_array, respectively.
This class is meant to speed up the sampling of an IMF defined as a
numerical integral, as with imf.IGIMF, by setting up an
interpolator to compute probabilities.
Parameters:
imf (IMFLike) – Instance of an IMF class with an imf(m) method.
discretization_points (int) – Number of masses on which to compute the IMF.
Generate a sample of zero-age main sequence binaries.
For a given redshift, star formation rate (SFR) and [Fe/H], generate a sample of multiple systems with component
masses between m_min and m_max, and up to max_comp_number companions. Each system is represented by the parameters
of its innermost binaries and its total corresponding mass, including all companions. Masses are drawn from the
integrated galaxy-wide initial mass function (IGIMF) and orbital parameters from correlated distributions.
Attributes
save_path
redshift : float
Redshift at which to generate the sample.
sfrfloat
SFR for which to generate the samples, in Msun yr-1.
fehfloat
[Fe/H] metallicity for which to generate the sample.
z_absfloat
Metallicity feh in Z.
m_minfloat
Minimum sampled mass.
m_maxfloat
Maximum sampled mass.
max_comp_numberint
Maximum number of companions.
poolsizeint
Size of the pool from which masses are drawn, without repetition.
col_nint
Number of columns (parameters) defining a binary.
samplenumpy array
(n, col_n) array of n binaries, each defined by a set of col_n parameters.
sample_massfloat
Total sample mass, including all system components.
qe_max_triesint
Maximum number of attempts to draw a valid system for a given primary mass, orbital period pair.
galaxy_descriptorstr
String describing the sampled population, to be appended to the sample filename.
m1_minfloat
Minimum primary mass allowed.
lowmass_powerlaw_indexfloat
Index of the power law from which < 0.8 Msun mass options are drawn.
lowmass_powerlaw_normfloat
Norm of the power law from which < 0.8 Msun mass options are drawn.
igimf_arrnumpy array
Array of >= 0.8 Msun mass options drawn from the IGIMF.
sampling_poolnumpy array
Complete pool of mass options for sampling.
prioritize_high_massesbool
Whether to bias the sampler towards drawing higher masses first or not.
print_progressbool
Whether to print progress updates (percentage, elapsed time, remaining time) to stdout or not.
Methods
set_sampling_pool()
Compute the array of mass options for sampling.
get_sample()
Generate full sample, save parameters to sample and the total mass to sample_mass.
save_sample()
Save sample to a parquet file at _save_path.
Warns:
UserWarning – If get_sample() is run before set_sampling_pool().
UserWarning – If sample is empty when save_sample() is called.
Warning
For a pool of poolsize possible masses, a sample of <~ 0.7*poolsize/2 binaries is generated. This is because two
mass arrays are generated, one above and one below 0.8 Msun, containing poolsize/2 elements each; and because as the
sampling pool is exhausted, remaining possible multiples tend to be invalid (fail the tolerance test in class
ZAMSSystemGenerator), and the sampling stops after a certain number of consecutive failed iterations.
See Also
zams.ZAMSSystemGenerator
Sampling of an individual multiple system.
zams.MultipleFraction
Sampling of the number of companions.
Notes
This sampler generates a population that simultaneously follows to correlated orbital parameter distributions by
Moe & Di Stefano (2017) [3]_ and the IGIMF by Jerabkova et al. (2018) [2]_. The sample is only representative of the IGIMF
between 0.8 and 150 Msun, because the sampling of the primary mass m1 is restricted to this range in order as per
the minimum mass sampled by the orbital parameter distributions. Components with masses between 0.08 and 0.8 Msun
appear as companions, but they will not reproduce the IGIMF below 0.8 Msun as all < 0.8 Msun primaries and their
companions will be missing. On the other hand, because for the mass ratio 0.1 <= q <= 1.0, the range between 0.8
and 150 Msun should be complete to good approximation, as discussed in OUR WORK.
Set the mass pool from which to draw the final sample as a random sampling of poolsize/2 from the IGIMF, above
m1_min; and of a power law with the same area between m_min and m1_min as the IGIMF between m1_min and m_max,
below m1_min.
Notes
Because the primary mass sampling is limited to m1 >= m1_min, in any case the IMF cannot be reproduced in the
m < m1_min region; at the same time, an IMF at < m1_min is still necessary for the sampling of light companions.
Thus the IMF for m < m1_min is defined to be a power law continuous with the IGIMF at m >= m1_min, with a slope
such that its area below m1_min is the same as that of the IGIMF above. This choice is made in order to conform
with the drawing of the same amount poolsize/2 of masses from both sides of m1_min.
Redshift-dependent SFMR with no flattening at high masses.
Computes the redshift-dependent star formation-mass relation (SFMR)
with no flattening at high masses, for a given redshift. Allows
calculating either the star-formation rate (SFR) from the galaxy
stellar mass, or the galaxy stellar mass from the SFR. Meant to be
implemented trough sfr.SFMR().
Parameters:
redshift (float) – Redshift at which to compute the relation.
Attributes
redshiftfloat
Redshift at which to compute the relation.
Notes
The model is by Boogaard et al. (2018) [1]_ , with the SFR as a
log-linear function of the mass, a the slope and b the
intercept.
Loads the precomputed star formation rate density (SFRD) grid over
redshift (z) and metallicity (Z_OH) and finds the SFRD corresponding
to the (z,Z) pair closest to the (z,Z) provided by the user. Allows
for choosing between the extreme low- and high-metallicity models,
or a moderate-metallicity model.
Parameters:
model ({'midmet', 'lowmet', 'highmet'}, default: 'midmet') – Option of SFRD grid model.
canon (bool, default : False) – Whether to assume an invariant IMF or not.
per_redshift_met_bin (bool, default : False) –
Alters the SFRD computation. For testing purposes only.
Deprecated since version 1.0: Keep to default value.
Attributes
modelstr
Choice of SFRD grid model.
canonstr
Whether to assume an invariant IMF or not.
sfrd_redshift_arrayNDArray
Array of redshifts corresponding to the SFRD grid.
sfrd_dtime_arraynumpy array
Array of time steps defining the SFRD grid redshifts.
logsfrd_arraynumpy array
SFRD log array over the redshift-metallicity grid.
The per_redshift_met_bin parameter is for testing purposes only
and will result in a wrong computation of the star formation rate.
It should be kept to the default value (False).
Notes
The precomputed SFRD grids are by Chruslinska et al. (2020) [9] and
were calculated with the same GSMF, SFMR and MZR relations employed
in this module. These grids already take into account the
corrections for the environment-dependent IMF from
sfh.Corrections.
At the moment only three permutations are included. These correspond
to the high, moderate and low metallicity , defined by Chruslinska &
Nelemans (2019) [4_]. They are,
Low metallicity: combines sfh.MZR(model='PP04'),
sfh.SFMR(flattening='sharp') and
sfh.GSMF(fixed_slope=True).
Moderate metallicity: combines sfh.MZR(model='M09'),
sfh.SFMR(flattening='moderate') and
sfh.GSMF(fixed_slope=True).
High metallicity: combines sfh.MZR(model='KK04'),
sfh.SFMR(flattening='none') and
sfh.GSMF(fixed_slope=True).
Searches for the closest (feh,redshift) in the SFRD grid
and returns the corresponding SFRD log value.
Parameters:
feh (float) – The desired [Fe/H].
redshift (float) – The desired redshift.
Returns:
logsfrd – SFRD log corresponding to the closest point in the grid.
Return type:
float
Warns:
UserWarning – If load_grid() has not been called yet.
Warning
The user should bear in mind the grids range from -4 to 1.7 in
[Fe/H] and 0 to 10 in redshift. Passing values outside
these ranges will always return the edges of the grid.
Corrections to a Kroupa IMF-based star formation rate.
Calculates corrections to a star formation rate (SFR) measured
by assuming a Kroupa initial mass function (IMF), from
imf.Star(invariant=True), for the environment-dependent IMF
from imf.IGIMF. The corrections are a multiplicative factor
dependent on the SFR and associated [Fe/H].
Parameters:
metallicity (NDArray) – Array of metallicities at which to compute the corrections.
sfr (NDArray) – Array of kSFR values for which to compute corrections.
Attributes
metallicityNDArray
Array of metallicities at which to compute the corrections.
sfr_kroupaNDArray
Array of kSFR values correspondent to each metallicity for
which to compute corrections.
correctionsNDArray
Array of calculated corrections for the given SFR-metallicity
pairs.
metallicity_dataNDArray
Metallicity column from the precalculated grid.
sfr_kroupa_dataNDArray
kSFR column from the precalculated grid.
sfr_correction_dataNDArray
Correction columns from the precalculated grid.
Notes
The corrections are obtained for arbitrary values of SFR and
metallicity by interpolation of the SFR density grid from
Chruslinska et al. (2020) [9], kindly made available by Martyna
Chruslinska.
Compute the redshift-dependent galaxy stellar mass function.
Compute the redshift-dependent galaxy stellar mass function (GSMF)
as a Schechter function at high masses, and as power-law with either
fixed of redshift-dependent slope at low masses. The GSMF returns a
galaxy number density *per stellar mass *.
Attributes
redshiftfloat
Redshift at which to compute the GSMF.
fixed_slopebool
Whether to use the fixed (True) or the varying (False) low-mass
slope model.
Notes
This class implements the GSMF model from Chruslisnka & Nelemans
(2019) [4]_. For galaxy stellar masses (log) greater than
logm_break, it is a Schechter function,
Its three parameters (phi, M_co and a) are redshift-dependent.
The values of log(phi), log(M_co) and a at 13 redshifts between
0.05 and 9 (corresponding to Table 1 of Chruslinska & Nelemans,
2019) [4]_ are kept in CHR19_GSMF.
For z<=0.05, the parameters are assumed to be the same as
at 0.05. For 0.05<z<=9, they are interpolated from
CHR19_GSMF. Beyond, log(M_co) and a retain their z=9
values, while log(phi) is assumed to increase linearly with its
mean variation rate between z=8-9.
Below the break, the GSMF is modeled as a power-law, with a slope
low_mass_slope. Depending on fixed_slope, it can
either be fixed to -1.45, or increase as
General redshift-dependent metallicity-mass relation class.
Compute the redshift-dependent mass-(gas) metallicity relation (MZR)
for one of four parameter sets: : “KK04”, “T04”, “M09” or “PP04”.
The MZR takes the form of a power-law at low masses with slope
gamma, which flattens around a turnover mass m_to to
an asymptotic metallicity z_a. Metallicity given and
expected as
where the parameters are the asymptotic metallicity z_a, the
turn-off mass (log) logm_to and the low-mass end slope
:attr:`gamma.
Four sets of parameters are collected by Chruslinska &
Nelemans (2019) [4]_: Tremontini et al. (2004) [5] (T04),
Kobulnicky & Kewley [6] (2004) (KK04), Pettini & Pagel [7] (2004)
(PP04) and Mannucci et al. [8] (2009) (M09).
The relation is fitted for four redshift bins z ~ 0.07, 0.7, 2.2,
3.5, such that each model provides four sets of corresponding MZR
parameters. In order to get the MZR at arbitrary redshift, a (mass,
metallicity) array is generated at each of the four original z and,
for each mass, the metallicity is interpolated to the desired z.
Fitting of the MZR to the interpolated points sets the parameters at
that z.
For z > 3.5, parameters are kept as for z=3.5, but it is assumed
that the normalization varies linearly with redshift with the same
rate as the average rate (dz) between z=2.2 and z=3.5.
Contains parameters for all fit redshifts simultaneously, for
use in interpolation to arbitrary redshift. Lines are
z = 0.07, 0.7, 2.2, 3.5; columns are z_a,
logm_to, gamma, dz.
Return a value for metallicity scatter around the MZR.
Depending on scatter_model, will be a normal distribution
with mean 0 and standard deviation equal to
DISPERSION (if flattening is “norm”); or fixed
to either 0 (if flattening is “none”),
DISPERSION (if flattening is “min”) or
-DISPERSION (if flattening is “max”).
General redshift-dependent star-formation mass relation class.
General SFMR class, with options for no, moderate or sharp
flattening at high masses. Provides a unified way to access the
three SFMR classes: BoogaardSFMR (no flattening),
SpeagleSFMR (moderate flattening) and
TomczakSFMR (sharp flattening).
Parameters:
redshift (float) – Redshift at which to compute the relation.
Depending on flattening, will be a normal distribution
with mean 0 and standard deviation equal to
DISPERSION (if flattening is “norm”); or fixed
to either 0 (if flattening is “none”),
DISPERSION (if flattening is “min”) or
-DISPERSION (if flattening is “max”).
Redshift-dependent SFMR with moderate flattening at high masses.
Computes the redshift-dependent star formation-mass relation (SFMR)
with moderate flattening at high masses, while keeping a
BoogaardSFMR at low masses, for a given redshift.
Allows calculating the star-formation rate (SFR) from the galaxy
stellar mass. Meant to be implemented trough sfr.SFMR().
Parameters:
redshift (float) – Redshift at which to compute the relation.
The SFR is modeled as a log-linear function of the mass, with
a as the slope and b the intercept. Below a break
mass :const:LOGM_BREAK, the SFMR is given by a
BoogaardSFMR (Boogaard et al., 2018) [1]_. Above the
break, the log-linear form is kept, but the slope becomes
redshift-dependent, following the model by Speagle et al. (2014)
[2]_. The intercept is defined by continuity with the Boogaard SFMR.
Redshift-dependent SFMR with sharp flattening at high masses.
Computes the redshift-dependent star formation-mass relation (SFMR)
with sharp flattening at high masses, while keeping a
BoogaardSFMR at low masses, for a given redshift.
Allows calculating the star-formation rate (SFR) from the galaxy
stellar mass. Meant to be implemented trough sfr.SFMR().
Parameters:
redshift (float) – Redshift at which to compute the relation.
Tomczak et al. (2016) [3]_ model the SFMR as a power-law with slope
GAMMA at low masses, which saturates to s0 above a
turn-off mass m_to. Following Chruslinska & Nelemans (2019)
[4]_, here the SFMR is given as a sfr.BoogaardSFMR below
the turn-off, and by the Tomczak SFMR above it.
Orbital period distribution for a 0.1<=q<=1 ZAMS star pair.
For a primary of mass m1, compute the log orbital period
(logp) probability density function (PDF) for a companion with
some mass m_cp such that 0.3<=q<=1.0 (q=m_cp/m1).
Allows for either a strongly m1- and logp-dependent piecewise
function of power-law, linear and exponential components; or a
uniform on logp distribution.
All orbital periods are given in days and masses in solar masses.
uncorrelated (bool) – Whether to assume a correlated distribution or not.
extrapolate_uncorrelated_distribution (bool) – If an uncorrelated distribution is assumed, whether to
extrapolate it to the range of the correlated distribution.
The distribution is by Moe & Di Stefano (2017) [1]_ and covers the
0.2<=logp<=8` range. Most of the observational techniques considered
therein are not able to probe pairs below q=0.3, and thus the
period distribution is only empirically fitted to the q>0.3
region, yielding the distribution in
CompanionFrequencyDistributionHighQ.
However, from the particular observations that do probe
0.1 <= q < 0.3, they are able to empirically fit the mass ratio
distribution in that region, in the form of
MassRatioDistribution.gamma_smallq. Thus, from the
integration of the mass ratio distribution it is possible to compute
the ratio n_q01/n_q03 between pairs above and below
q=0.3.
This class calculates that ratio, and uses it as a correction
factor to obtain, from the companion frequency in
0.3<=q<=1.0 (\(f_{\log P; q>0.3}\)), the companion
frequency in 0.1<=q<=1.0 (\(f_{\log P; q>0.1}\)).
The uncorrelated distribution is a uniform on logp probability
distribution between 0.4 and 3, or Öpik’s law [3]_. The
extrapolate_uncorrelated_distribution parameter allows
extrapolating it to the same range as that of the correlated
distribution.
Orbital period distribution for a 0.3<=q<=1 ZAMS star pair.
For a primary of mass m1, compute the log orbital period
(logp) probability density function (PDF) for a companion with
some mass m_cp such that 0.3<=q<=1.0 (q=m_cp/m1).
The PDF is a strongly m1- and logp-dependent piecewise
function of power-law, linear and exponential components.
All orbital periods are given in days and masses in solar masses.
Parameters:
m1 (float) – Primary mass.
Attributes
m1float
Primary mass.
See Also
CompanionFrequencyDistribution :
Inherits from this class and extrapolates the distribution down
to q=0.1. Includes an uncorrelated distribution option.
MultipleFraction :
Accounts for higher-order multiples in the companion frequency.
Notes
The distribution is by Moe & Di Stefano (2017) [1]_, with small
adjustments as described by de Sá et al. (submitted) [2]_. Although
it is referred to as a PDF, the distribution is defined as a
companion frequency,
i.e., the number of companions, per primary with mass \(M_1\),
per orbital period decade, around a period \(P\).
The companion frequency is empirically fitted for
0.2<=logp<1, logp=2.7, logp=5.5 and
5.5<logp<=8.0. For the intermediate intervals, it is set to
increase linearly with logp.
Eccentricity probability distribution for a ZAMS star pair.
For a given primary of mass m1 and a companion orbit of
log10(period) logp, compute the eccentricity probability density
function (PDF) for that orbit. All orbits with logp<=0.5
(default) are assumed to be circularized. Orbits with logp>8.0
are not allowed (p=0). Primaries with m1<0.8 or
m1>150.0 are not allowed (p=0).
Allows for either a mass- and orbital-period dependent power-law
distribution, or to set all orbits to be circular.
All orbital periods are in days and masses in solar masses.
Parameters:
canonical (bool, default : False) – Whether to assume a correlated distribution or not.
Attributes
etafloat
Index of the eccentricity PDF power law.
kfloat
Normalization constant of the eccentricity PDF power law.
e_maxfloat
Maximum eccentricity set by the <70% Roche lobe filling factor
at periastron.
m1float
Mass of the primary.
logpfloat
Log10(period) of the given orbit.
logp_circfloat
Log10(period) below which all orbits are assumed to be
circularized. Should always be greater than attr:logp_min.
The correlated distribution is by Moe & Di Stefano (2017) [1]_
with small adjustments as described by de Sá et al. (submitted)
[2]_. It takes the shape of a simple power law, with the index eta
being dependent on logp; the functional form of this dependency
itself depends on m1. A maximum eccentricity is set as a function of
logp from the condition that the Roche lobe filling fraction be
<70% at periastron.
The minimum, maximum and circularization periods are set as in the
original work, with log values 0.2, 8.0 and 0.5, respectively.
The minimum m1 is set to 0.8 Msun also in accordance with the
original work, but the mass range is extended up to 150.0 Msun.
The uncorrelated option always returns zero eccentricity.
Compute the eccentricity PDF value at the given e.
Parameters:
e (float) – Eccentricity at which to compute the PDF.
Returns:
prob – PDF value at e.
Return type:
float
Warns:
UserWarning – If power law parameters are not set up
(set_parameters() has not been called yet).
Notes
If logp<=logp_circ (default 0.5), the method forces
e=0 by approximating a delta at e=0 with a finite step. This
is done to avoid dividing by zero while still allowing the PDF
to integrate to 1. An artificial plateau is also inserted at
e<=0.0001 to avoid the probability exploding for circular
systems, at the cost of slightly shifting the PDF’s norm from 1.
Sets eta, k and e_max at m1 and
:attr:logp. If the distribution is set to uncorrelated, or
if m1 and/or logp are out of bounds, all parameters are
set to zero.
Mass ratio probability distribution for a ZAMS star pair.
For a given primary of mass m1 and a companion orbit of
log10(period) logp, compute the mass ratio probability density
function (PDF) for that orbit. The companion mass being m_cp,
the mass ratio is defined as q=m_cp/m1, and is limited to the
interval 0.1<=q<=1.0.
Allows for either a mass- and orbital-dependent broken power-law
with a “twin” (q>0.95) excess; or an uncorrelated uniform
distribution.
All orbital periods are in days and masses in solar masses.
Parameters:
canonical (bool, default : False) – Whether to assume a correlated distribution or not.
Attributes
solar_llimfloat
Lower mass limit of “solar-type” primaries.
solar_ulimfloat
Upper mass limit of “solar-type” primaries.
a_pointfloat
Mass midpoint for A-/late B-type primaries.
ob_llimfloat
Lower mass limit of mid B-, early B- and O-type primaries.
gamma_largeqfloat
Power law PDF index for 0.3<=q<=1.0.
gamma_smallqfloat
Power law PDF index for 0.1<=q<0.3.
f_twinfloat
Excess fraction of q>0.95 pairs relative to a power-law.
The correlated distribution is by Moe & Di Stefano (2017) [1]_ with
small adjustments as described by de Sá et al. (submitted) [2]_. It
takes the shape of a two-part power law, with index
gamma_smallq for 0.1<=q<0.3 and gamma_largeq
for 0.3<=q<=1.0. It also includes an excess of systems with
q>0.95 (twin pairs) expressed as the twin fraction
f_twin, so that at q > 0.95 the PDF is
(1+f_twin) * power_law. As this excess is only observed for
shorter-period systems, there is a maximum logp for which the
excess twin population is present.
Solar-type primaries are defined as having masses
0.8<m1<1.2. The midpoint of A-/late B-type primaries is
defined to be at m1=3.5. Mid B-, early B- and O-type primaries
are defined as having mass m1>6.0. The PDF is defined piecewise
for each the two ranges and the midpoint. Interpolation gives the
PDF in the two intermediary ranges: solar-A (1.2<=m1<3.5)
and A-OB (3.5<m1<=6).
The minimum and maximum periods are set as in the original work,
with log10 values 0.2 and 8.0, respectively. The minimum m1
is set to 0.8 also in accordance with the original work, but the
mass range is extended up to 150.0. The minimum q is set to
0.1 as in the original work.
Set distribution power-law parameters at m1, logp.
Sets gamma_largeq, gamma_smallq, k and
f_twin. If the distribution is set to uncorrelated, or
if m1 and/or logp are out of bounds, all parameters are
set to zero.
Multiplicity fractions as a function of primary mass.
For a given primary mass m1, compute the probability of having
n companions in `` 0.1 <= q <= 1.0`` pairs. The probability
distribution over n is discrete, and takes the form of a
truncated Poisson distribution.
Can return individual multiplicity fractions for up to nmax
companions, or compute a binary fraction by assuming all
non-isolated stars are in binaries.
All masses are in solar masses.
Parameters:
mmin (float) – Minimum primary mass.
mmax (float) – Maximum primary mass.
nmax (float) – Maximum companion number.
nmean_max (float) – Maximum mean companion number, for interpolation.
only_binaries (bool) – Whether to assume all non-isolated stars are in binaries.
Its correlated model is the source of the multiplicity fractions
as a function of mass.
sampling.SimpleBinaryPopulation :
Implements this class to generate a full ZAMS binary population.
Notes
This class computes multiplicity fractions as suggested by Moe & Di
Stefano (2017) [1]_, but for a general case, as described in de Sá
et al. (submitted). Computation starts from the companion frequency
distributed as in CompanionFrequencyDistribution.
The number of companions per primary (multiplicity frequency) is
given by integrating the companion frequency over orbital period,
The multiplicity fraction, \(F_n\), is defined as the fraction
of all primaries with a number \(n\) of companions. These relate
to the multiplicity frequency as:
for a primary mass \(M_1\). The \(F_n\) are not, in general,
empirically constrained. This class follows Moe & Di Stefano (2017)
[1]_ in extending the observed behavior for solar-type primaries to
all primaries. In this case, the number of companions is observed
to be distributed over \(M_1\) in the form of a Poissonian
distribution, with a \(M_1\)-dependent mean
\(n_\mathrm{mean}\) fully determined by imposing the empirical
\(f_\mathrm{mult}(M_1)\) as a constraint.
By assuming a Poissonian truncated at nmax, the companion
number n is distributed as
From this relation an array of
\((f_\mathrm{mult}, n_\mathrm{mean})\) pairs is calculated,
and from it a \(f_\mathrm{mult}\) to \(n_\mathrm{mean}\)
interpolator is built. \(f_\mathrm{mult}\) is then determined
by integrating the companion frequency for a given mass, as per its
definition. This is done for masses m1_array, and the
resulting \((m_1, f_\mathrm{mult})\) array yields a
\((m_1, n_\mathrm{mean})\) array through the above
interpolator. A second, \(m_1\) to \(n_\mathrm{mean}\),
interpolator is then built.
Sets up a series of interpolators necessary for computing the
companion number as a function of mean companion number and
primary mass. Defines m1_array and the corresponding
nmean_array and binary_fraction, and is
necessary for ncomp_mean() and
get_multiple_fraction().
Receives an array of pre-sampled initial masses imf_array
from which all masses (primary and of companions) are drawn without
repetition. Builds zero-age main sequence (ZAMS) multiples by
randomly pulling a primary mass from the pool, drawing a companion
number; then for each companion drawing its mass from a mass ratio
distribution, and looking for the closest match in
imf_array, which is accepted if the relative difference
between masses is at most dmcomp_tol. Orbital period and
eccentricity are drawn from their respective distributions. Allows
the user to pull one system at a time until the mass pool is
exhausted or becomes unable to produce valid mass pairings. The mass
pool allows the sample to follow an arbitrary initial mass function
(IMF).
All orbital periods are in days and masses in solar masses.
Parameters:
imf_array (numpy array) – Array from which to sample primary and companion masses.
pairs_table_path (path_like, default : constants.BINARIES_UNCORRELATED_TABLE_PATH) – Path to a HDF5 file containing equiprobable (m1,logp,q,e) sets
according to the desired orbital parameter distributions.
qe_max_tries (int, default : 1) – Maximum number of attempts at drawing a valid q,e pair for
a given m1,logp, before m1 is redrawn.
dmcomp_tol (float, default : 0.05) – Maximum accepted difference between a companion mass drawn from
a q-distribution and the closest value in imf_array,
relative to the latter.
parent_logger (logging Logger, default : None) – Logger of the class or module from which this class was
instantiated.
Attributes
pairs_table_pathpath_like
Path to a HDF5 file containing equiprobable (m1,logp,q,e) sets
according to the desired orbital parameter distributions.
imf_arrayNDArray
Array from which to sample primary and companion masses.
m1_minfloat
Minimum primary mass.
qe_max_triesint
Maximum number of attempts at drawing a valid q,e pair for
a given m1,logp, before m1 is redrawn.
dmcomp_tolfloat
Maximum accepted difference between a companion mass drawn from
a q-distribution and the closest value in imf_array,
relative to the latter.
pairs_tabletables.File
Table loaded from pairs_table_path
lowmass_imf_arrayNDArray
Subarray of imf_array below m1_min.
highmass_imf_arraynumpy array
Subarray of imf_array above m1_min.
m1array_nint
Live length of highmass_imf_array.
m1array_iint
Index of the last m1 drawn from highmass_imf_array.
m1_arrayfloat32
Last m1 drawn from highmass_imf_array.
m1_tablefloat32
Closest match to m1_array in pairs_table.
dm1float
Difference between m1_table and m1_array
relative to the latter.
m1grouptables.Group
Table of equiprobable companions for m1_table,
identified by a set (logp,q,e).
loggerlogging.Logger
Instance logger.
See Also
sampling.SimpleBinaryPopulation :
Implements this class to generate a binary population.
Notes
This class allow for sampling multiples of arbitrary order, but it
assumes that table pairs_table was built based on
distributions appropriate for the desired degree of multiplicity.
All companion masses are always removed from imf_array upon
a successful draw.
Within triples or higher-order multiples, all orbital periods are
drawn simultaneously, i.e., the orbital periods of individual
companions are not treated as independent quantities. Orbital
parameters are ordered in order of closest farthest companion in
the output of sample_system(), to allow evolving only the
inner binary. Note that this shifts the binary orbital period
distribution to lower periods, as discussed in de Sá et al. [2]_.
Ultimately, orbital periods, mass ratios and eccentricities will be
limited to the values in pairs_table, while both
m1_table and m1_array are returned by
sample_system(). It is expected that the table is composed of
root-level groups, each of which corresponds to a primary mass; and
that each m1group is composed of tables, each of which
corresponding to a logp and containing mass ratio-eccentricity
pairs. It is expected that all combinations of the four parameters
found in the table are equiprobable. By default, this class loads
tables from constants.BINARIES_UNCORRELATED_TABLE_PATH.
Check its documentation for description on its construction.
This class can be employed on its own to generate individual systems.
Its implementation for the generation of an entire sample of
binaries is handled by the sampling.SimpleBinaryPopulation
class.
Generates a multiple system with ncomp companions for
a primary set with open_m1group(), assuming up to
ncomp_max companions are allowed. Returns ordered inner
binary and further pair parameters, as well as companion number
and total system mass.
ncomp_max is used for proper output formatting only.
Parameters:
ncomp (int, default : 1) – Number of companions to the primary. Can be 0 (isolated).
ncomp_max (int, default : 1) – Maximum number of companions in the underlying population.
Returns:
sample_pairs – (12+4*ncomp_max,)-shaped array of 12 inner binary
parameters and 4 parameters per further companion.
Return type:
NDArray
Warns:
UserWarning – If the system fails to be generated.
Notes
For primary masses set with open_m1group(), the orbital
period logs logp_table are drawn for all `ncomp` binaries
from m1group. Then, starting from the innermost
companion and moving toward the outermost one, the corresponding
logp_table table is opened in m1group and a
q_table,e_table pair is drawn from it. The companion mass is
set to mcomp_table=q_table*m1_table, and its closest match in
imf_array, mcomp_array, is found. The drawn pair is
tested against dmcomp_tol, and if
the pair is accepted. If not, q,e can be drawn for up to
qe_max_tries times. If no match can be found, the draw
failed, and an empty parameter array is returned.
If at any point a valid pair fails to be found, the whole system
is discarded and an empty array is returned. Otherwise, the
parameters for the sampled pairs are returned, and the component
masses are removed from the imf_array and its
sub-arrays.
The 12 first output columns are [Table primary mass,
Array primary mass, Relative m1 difference,
Table secondary mass, Array secondary mass,
Relative m2 difference, Mass ratio from table masses,
Mass ratio from array masses, log10(orbital period),
Eccentricity, Companion number, Total system mass].
Each further companion appends 4 more columns to the output.
They are [Table companion mass, Array companion mass,
log10(orbital period), Eccentricity].
Loads data from table_path. Sets two mass sub-arrays,
lowmass_imf_array and highmass_imf_array, to
speed up sampling by assuming that m1 is always in
highmass_imf_array and that
\(m_\mathrm{comp}<m_1\). Sets the initial value of
m1array_n.