Sample¶
- class cosmic.sample.sampler.independent.Sample[source]¶
Bases:
objectMethods Summary
binary_select(primary_mass[, binfrac_model])Select which primary masses will have a companion using either a binary fraction specified by a float or a primary-mass dependent binary fraction following van Haaften et al.(2009) in appdx or Offner et al.(2023) in fig 1
sample_SFH([SF_start, SF_duration, met, size])Sample an evolution time for each binary based on a user-specified time at the start of star formation and the duration of star formation.
sample_ecc(aRL_over_a[, ecc_model, size])Sample the eccentricity according to a user specified model
sample_porb(mass1, mass2, rad1, rad2, porb_model)Sample the orbital period according to the user-specified model
sample_primary([primary_model, size])Sample the primary mass (always the most massive star) from a user-selected model
sample_secondary(primary_mass[, q_power_law])Sample a secondary mass using draws from a uniform mass ratio distribution motivated by Mazeh et al. (1992) and Goldberg & Mazeh (1994).
set_kstar(mass)Initialize stellar types according to BSE classification kstar=1 if M>=0.7 Msun; kstar=0 if M<0.7 Msun
set_reff(mass, metallicity[, zsun, SSEDict])Better way to set the radii from BSE, by calling it directly
Methods Documentation
- binary_select(primary_mass, binfrac_model=0.5, **kwargs)[source]¶
Select which primary masses will have a companion using either a binary fraction specified by a float or a primary-mass dependent binary fraction following van Haaften et al.(2009) in appdx or Offner et al.(2023) in fig 1
- Parameters:
- primary_massarray
Mass that determines the binary fraction
- binfrac_modelstr or float
vanHaaften - primary mass dependent and ONLY VALID up to 100 Msun
offner23 - primary mass dependent
float - fraction of binaries; 0.5 means 2 in 3 stars are a binary pair while 1 means every star is in a binary pair
- Optional kwargs are defined in `get_independent_sampler`
- Returns:
- stars_in_binaryarray
primary masses that will have a binary companion
- stars_in_singlearray
primary masses that will be single stars
- binary_fractionarray
system-specific probability of being in a binary
- binaryIdxarray
Idx of stars in binary
- sample_SFH(SF_start=13700.0, SF_duration=0.0, met=0.02, size=None)[source]¶
Sample an evolution time for each binary based on a user-specified time at the start of star formation and the duration of star formation. The default is a burst of star formation 13,700 Myr in the past.
- Parameters:
- SF_startfloat
Time in the past when star formation initiates in Myr
- SF_durationfloat
Duration of constant star formation beginning from SF_Start in Myr
- metfloat
metallicity of the population [Z_sun = 0.02] Default: 0.02
- sizeint, optional
number of evolution times to sample NOTE: this is set in cosmic-pop call as Nstep
- Returns:
- tphysarray
array of evolution times of size=size
- metallicityarray
array of metallicities
- sample_ecc(aRL_over_a, ecc_model='sana12', size=None)[source]¶
Sample the eccentricity according to a user specified model
- Parameters:
- ecc_modelstring
‘thermal’ samples from a thermal eccentricity distribution following Heggie (1975) ‘uniform’ samples from a uniform eccentricity distribution ‘sana12’ samples from the eccentricity distribution from Sana+2012 <https://ui.adsabs.harvard.edu/abs/2012Sci…337..444S/abstract>_ ‘circular’ assumes zero eccentricity for all systems DEFAULT = ‘sana12’
- aRL_over_aratio of the minimum seperation (where RL overflow starts)
to the sampled semi-major axis. Use this to truncate the eccentricitiy
- sizeint, optional
number of eccentricities to sample this is set in cosmic-pop call as Nstep
- Returns:
- eccarray
array of sampled eccentricities with size=size
- sample_porb(mass1, mass2, rad1, rad2, porb_model, porb_max=None, size=None, **kwargs)[source]¶
Sample the orbital period according to the user-specified model
- Parameters:
- mass1array
primary masses
- mass2array
secondary masses
- rad1array
radii of the primaries.
- rad2array
radii of the secondaries
- porb_modelstr or dict
selects which model to sample orbital periods, choices include: log_uniform : semi-major axis flat in log space from RRLO < 0.5 up to 1e5 Rsun according to Abt (1983) and consistent with Dominik+2012,2013 and then converted to orbital period in days using Kepler III sana12 : power law orbital period between 0.15 < log(P/day) < 5.5 following Sana+2012 <https://ui.adsabs.harvard.edu/abs/2012Sci…337..444S/abstract>_ renzo19 : power law orbital period for m1 > 15Msun binaries from Sana+2012 <https://ui.adsabs.harvard.edu/abs/2012Sci…337..444S/abstract>_ following the implementation of Renzo+2019 <https://ui.adsabs.harvard.edu/abs/2019A%26A…624A..66R/abstract>_ and flat in log otherwise raghavan10 : log normal orbital periods in days with mean_logP = 4.9 and sigma_logP = 2.3 between 0 < log10(P/day) < 9 following Raghavan+2010 <https://ui.adsabs.harvard.edu/abs/2010ApJS..190….1R/abstract>_ moe19 : log normal orbital periods in days with mean_logP = 4.9 and sigma_logP = 2.3 between 0 < log10(P/day) < 9 following Raghavan+2010 <https://ui.adsabs.harvard.edu/abs/2010ApJS..190….1R/abstract>_ but with different close binary fractions following Moe+2019 <https://ui.adsabs.harvard.edu/abs/2019ApJ…875…61M/abstract>_ martinez26 : piecewise model with a power law orbital period following Sana+2012 <https://ui.adsabs.harvard.edu/abs/2012Sci…337..444S/abstract>_ between 0.15 < log(P/day) < log(3000) for binaries with primaries large enough to undergo an FeCCSN and following Raghavan+2010 <https://ui.adsabs.harvard.edu/abs/2010ApJS..190….1R/abstract>_ with a log normal orbital period in days with mean_logP = 4.9 and sigma_logP = 2.3 between 0 < log10(P/day) < 9 for binaries with low mass primaries. Used in Martinez+2026 <https://ui.adsabs.harvard.edu/abs/2025arXiv251123285M/abstract>_. Assumes zsun = 0.02 for the metallicity dependence to predict outcomes correctly. martinez26_ecsn : same as martinez26 but with the Sana+2012 power law orbital period distribution for primaries massive enough to undergo an ECSN instead of an FeCCSN. Custom power law distribution defined with a dictionary with keys “min”, “max”, and “slope” (e.g. porb_model={“min”: 0.15, “max”: 0.55, “slope”: -0.55}) would reproduce the Sana+2012 distribution.
- metfloat
metallicity of the population
- Returns:
- porbarray
orbital period with array size equalling array size of mass1 and mass2 in units of days
- aRL_over_a: array
ratio of radius where RL overflow starts to the sampled seperation used to truncate the eccentricitiy distribution
- sample_primary(primary_model='kroupa01', size=None, **kwargs)[source]¶
Sample the primary mass (always the most massive star) from a user-selected model
kroupa93 follows Kroupa (1993), normalization comes from Hurley 2002 between 0.08 and 150 Msun salpter55 follows Salpeter (1955) between 0.08 and 150 Msun kroupa01 follows Kroupa (2001) <https://arxiv.org/abs/astro-ph/0009005> between 0.08 and 100 Msun
- Parameters:
- primary_modelstr, optional
- model for mass distribution; choose from:
- kroupa93 follows Kroupa (1993), normalization comes from
- `Hurley 2002 <https://arxiv.org/abs/astro-ph/0201220>`_
- valid for masses between 0.1 and 100 Msun
- salpter55 follows
- `Salpeter (1955) <http://adsabs.harvard.edu/abs/1955ApJ…121..161S>`_
- valid for masses between 0.1 and 100 Msun
- kroupa01 follows Kroupa (2001), normalization comes from
- `Hurley 2002 <https://arxiv.org/abs/astro-ph/0009005>`_
- valid for masses between 0.1 and 100 Msun
- custom is a generic piecewise power law that takes in the power
- law slopes and break points given in the optional input lists (alphas, mcuts)
- default alphas and mcuts yield an IMF identical to kroupa01
- Default kroupa01
- sizeint, optional
- number of initial primary masses to sample
- NOTE: this is set in cosmic-pop call as Nstep
- alphasarray, optional
- absolute values of the power law slopes for primary_model = ‘custom’
- Default [-1.3,-2.3,-2.3] (identical to slopes for primary_model = ‘kroupa01’)
- mcutsarray, optional, units of Msun
- break points separating the power law ‘pieces’ for primary_model = ‘custom’
- Default [0.08,0.5,1.0,150.] (identical to breaks for primary_model = ‘kroupa01’)
- Optional kwargs are defined in `get_independent_sampler`
- Returns:
- a_0array
- Sampled primary masses
- np.sum(a_0)float
- Total amount of mass sampled
- sample_secondary(primary_mass, q_power_law=0, **kwargs)[source]¶
Sample a secondary mass using draws from a uniform mass ratio distribution motivated by Mazeh et al. (1992) and Goldberg & Mazeh (1994)
NOTE: the lower lim is set by either qmin or m2_min which are passed as kwargs
- Parameters:
- primary_massarray
sets the maximum secondary mass (for a maximum mass ratio of 1)
- Optional kwargs are defined in `get_independent_sampler`
- Returns:
- secondary_massarray
sampled secondary masses with array size matching size of primary_mass
- set_kstar(mass)[source]¶
Initialize stellar types according to BSE classification kstar=1 if M>=0.7 Msun; kstar=0 if M<0.7 Msun
- Parameters:
- massarray
array of masses
- Returns:
- kstararray
array of initial stellar types
- set_reff(mass, metallicity, zsun=0.02, SSEDict=None, **kwargs)[source]¶
Better way to set the radii from BSE, by calling it directly
takes masses and metallicities, and returns the radii
Note that the BSE function is hard-coded to go through arrays of length 10^5. If your masses are more than that, you’ll need to divide it into chunks