utils
-
cosmic.utils.
a_from_p
(p, m1, m2)¶ Computes the separation from orbital period with KEPLER III
- Parameters
p : float/array
orbital period [day]
m1 : float/array
primary mass [msun]
m2 : float/array
secondary mass [msun]
- Returns
sep : float/array
separation [rsun]
-
cosmic.utils.
check_initial_conditions
(initial_binary_table)¶ Checks initial conditions and reports warnings
Only warning provided right now is if star begins in Roche lobe overflow
-
cosmic.utils.
conv_select
(bcm_save, bpp_save, final_kstar_1, final_kstar_2, method, conv_lims)¶ Select bcm data for special convergence cases
- Parameters
bcm_save : pandas.DataFrame
bcm dataframe containing all saved bcm data
bpp_save : pandas.DataFrame
bpp dataframe containing all saved bpp data
final_kstar_1 : list
contains list of final primary kstars specified by user
final_kstar_2 : list
contains list of final primary kstars specified by user
method : str
stage in binary evolution to check convergence for only one method may be supplied and they are specified in the inifile
conv_lims : dict
dictionary where keys are convergence params and the values are lists containing a [lo, hi] value to filter the convergence param between any non-specified convergence params will not be filtered
- Returns
conv_save : pandas.DataFrame
filtered dataframe containing binaries that fulfill user-specified convergence criteria
-
cosmic.utils.
convert_kstar_evol_type
(bpp)¶ Provides way to convert integer values to their string counterpart
The underlying fortran code relies on integers to indicate things like the evoltuionary stage of the star as well as key moments in its evolutionary track. If you pass the data frame returned from running
`Evolve.evolve`
you can convert the columns with these integer proxies to their true astrophysical meaning.
-
cosmic.utils.
dat_transform
(dat, dat_list)¶ Transform a data set to have limits between zero and one using param_transform, then transform to log space
- Parameters
dat ” DataFrame
Data to transform to eventually perform KDE
dat_list : list
List of DataFrame columns to include in transformation
- Returns
dat_trans : array
Transformed data for columns in dat_list
-
cosmic.utils.
dat_un_transform
(dat_sample, dat_set, dat_list)¶ Un-transform data that was transformed in dat_transform
- Parameters
dat_sample : array
Data sampled from kde generated with transformed data
dat_set : DataFrame
Un-transformed data (same as dat in dat_transform)
dat_list : list
List of DataFrame columns to include in transformation
- Returns
dat : array
Array of data sampled from kde that is transformed back to bounds of the un-transformed data set the kde is generated from
-
cosmic.utils.
error_check
(BSEDict, filters=None, convergence=None, sampling=None)¶ Checks that values in BSEDict, filters, and convergence are viable
-
cosmic.utils.
filter_bpp_bcm
(bcm, bpp, method, kstar1_range, kstar2_range)¶ Filter the output of bpp and bcm
- Parameters
bcm : pandas.DataFrame
bcm dataframe
bpp : pandas.DataFrame
bpp dataframe
method : dict,
one or more methods by which to filter the bpp or bcm table, e.g.
{'binary_state' : [0,1]}
; This means you do not want to select the final state of the binaries in the bcm arraykstar1_range : list
list containing all kstar1 values to retain
kstar2_range : list
list containing all kstar2 values to retain
- Returns
bcm : pandas.DataFrame
filtered bcm dataframe
-
cosmic.utils.
idl_tabulate
(x, f, p=5)¶ Function that replicates the IDL int_tabulated function which performs a p-point integration on a tabulated set of data
- Parameters
x : array
tabulated x-value data
f : array
tabulated f-value data, same size as x
p : int
number of chunks to divide tabulated data into Default: 5
- Returns
ret : float
Integration result
-
cosmic.utils.
knuth_bw_selector
(dat_list)¶ Selects the kde bandwidth using Knuth’s rule implemented in Astropy If Knuth’s rule raises error, Scott’s rule is used
- Parameters
dat_list : list
List of data arrays that will be used to generate a kde
- Returns
bw_min : float
Minimum of bandwidths for all of the data arrays in dat_list
-
cosmic.utils.
mass_min_max_select
(kstar_1, kstar_2)¶ Select a minimum and maximum mass to filter out binaries in the initial parameter sample to reduce the number of unneccessary binaries evolved in BSE
- Parameters
kstar_1 : int, list
BSE stellar type for the primary or minimum and maximum stellar types for the primary
kstar_2 : int, list
BSE stellar type for the secondary or minimum and maximum stellar types for the secondary
- Returns
min_mass[0] : float
minimum primary mass for initial sample
max_mass[0] : float
maximum primary mass for initial sample
min_mass[1] : float
minimum secondary mass for initial sample
max_mass[1] : float
maximum secondary mass for initial sample
-
cosmic.utils.
p_from_a
(sep, m1, m2)¶ Computes separation from orbital period with kepler III
- Parameters
sep : float/array
separation [rsun]
m1 : float/array
primary mass [msun]
m2 : float/array
secondary mass [msun]
- Returns
p : float/array
orbital period [day]
-
cosmic.utils.
param_transform
(dat)¶ Transforms a data set to limits between zero and one Leaves some wiggle room on the edges of the data set
- Parameters
dat : array
array of data to transform between 0 and 1
- Returns
datTransformed : array
array of data with limits between 0 and 1
-
cosmic.utils.
pop_write
(dat_store, log_file, mass_list, number_list, bcm, bpp, initC, conv, kick_info, bin_state_nums, match, idx)¶ - Writes all the good stuff that you want to save from runFixedPop in a
single function
- Parameters
dat_store : pandas HDFStore
H5 file to write to
log_file : file write
log file to write to
mass_list : list
list containing the mass of the singles, mass of the binaries, and mass of the stars
n_list : list
list containing the number of singles, number of binaries, and number of stars
bcm : pandas.DataFrame
bcm array to write
bpp : pandas.DataFrame
bpp array to write
initCond : pandas.DataFrame
initCond array to write
conv : pandas.DataFrame
conv array to write
kick_info : pandas.DataFrame
kick_info array to write
bin_state_nums : list
contains the count of binstates 0,1,2
match : pandas.DataFrame
contains the match values for each conv_param
idx : int
contains the index of the bcm so we can pick up where we left off if runFixedPop hits a wall time
- Returns
- Nothing!
-
cosmic.utils.
rndm
(a, b, g, size)¶ Power-law generator for pdf(x)propto x^{g} for a<=x<=b
- Parameters
a : float
Minimum of range for power law
b : float
Maximum of range for power law
g : float
Index for power law
size : int
Number of data points to draw
- Returns
power : array
Array of data sampled from power law distribution with params fixed by inputs