holodeck.librarian.posterior_populations

Script to generate Holodeck populations, drawing from the 15yr analysis constraints.

See holodeck-pops.ipynb for example usage of this data.

Usage (posterior_populations.py)

See python gen_holodeck_pop.py -h for usage information.

Example:

python gen_holodeck_pops.py -t 20 -f 30 -r 100 -l 10 -m
                               |     |     |      |   |--> use maxmimum-likelihood values
                               |     |     |      |------> 10 loudest binaries in each frequency bin
                               |     |     |-------------> 100 realizations of populations
                               |     |-------------------> 30 frequency bins
                               |-------------------------> 20 years observing baseline = 1/(20yr) lowest frequency

To-Do (posterior_populations.py)

  • Improve handling of data path.

  • Improve handling/specification of parameter space.
    • Allow changes to be passed in through API and or CL

    • Make each particular 15yr dataset specify its own parameter space (these need to match up anyway!)

holodeck.librarian.posterior_populations.get_maxlike_pars_from_chains(chains=None)[source]

Load the maximum-likelihood (ML) parameters from the given chains (i.e. parameter posteriors).

KDEs from kalepy are used to construct the ML parameters.

Parameters:

chains (dict) – The MCMC parameter values for each of the parameters in this holodeck parameter-space. These chains should typically be loaded using the load_chains function.

Returns:

pars – Maximum likelihood parameters drawn from the chains. This will be a single float value for each of the parameters in the holodeck parameter-space, for example:

['hard_time', 'gsmf_phi0', 'gsmf_mchar0_log10',
'mmb_mamp_log10', 'mmb_scatter_dex', 'hard_gamma_inner']

Return type:

dict

holodeck.librarian.posterior_populations.load_chains(path_data)[source]

Load the MCMC chains from the given path.

The path must contain the expected files resulting from fitting with ceffyl.

Parameters:

path_data (str or pathlib.Path) – Path to directory containing the pars.txt and chain_1.0.txt files.

Returns:

data – The values at each step of the MCMC chains for each parameters. For example, the parameters may be:

['hard_time', 'gsmf_phi0', 'gsmf_mchar0_log10',
'mmb_mamp_log10', 'mmb_scatter_dex', 'hard_gamma_inner']

in which case each of these will be an entry in the dictionary, where the values are an array of the steps in each of these parameters.

Return type:

dict

holodeck.librarian.posterior_populations.load_population_for_pars(pars, pta_dur=16.0, nfreqs=60, nreals=103, nloudest=10)[source]

Construct a holodeck population.

Parameters:
  • pars (dict) – Binary population parameters for the appropriate parameter space PSPACE. Typically the pars should be loaded using either the sample_pars_from_chains or the get_maxlike_pars_from_chains function.

  • pta_dur (scalar [seconds]) – Duration of PTA observations, used to determine Fourier frequency bins. Bin centers are at frequencies f_i = (i+1) / pta_dur

  • nfreqs (int) – Number of frequency bins.

  • nreals (int) – Number of realizations to construct.

  • nloudest (int) – Number of loudest binaries to calculate, per frequency bin.

Returns:

data – Binary population and derived properties. Entries:

  • number : ndarray (M, Q, Z, F) Number of binaries in the Universe in each bin. The bins are total mass (M), mass ratio (Q), redshift (Z), and frequency (F).

  • hc_ss : ndarray (F, R, L) GW characteristic strain of the loudest L binaries in each frequency bin (F) and realization (R). The GW frequencies are assumed to be 2x the orbital frequencies (i.e. circular orbits).

  • hc_bg : ndarray (F, R) GW characteristic strain of all binaries besides the L loudest in each frequency bin, for frequency bins F and realizations R. The GW frequencies are assumed to be 2x the orbital frequencies (i.e. circular orbits).

  • sspar : ndarray (P, F, R, L) Binary parameters of the loudest L binaries in each frequency bin F for realizations R. The P=4 parameters included are {total mass [grams], mass ratio, initial redshift, final redshift}, where initial redshift is at the time of galaxy merger, and final redshift is when reaching the frequency bin.

  • mtot_edges : ndarray (M+1,) The edges of the total-mass dimension of the SAM grid, in units of [grams]. Note that there are M+1 bin edges for M bins.

  • mrat_edges : ndarray (Q+1,) The edges of the mass-ratio dimension of the SAM grid. Note that there are Q+1 bin edges for Q bins.

  • redz_edges : ndarray (Z+1,) The edges of the redshfit dimension of the SAM grid. Note that there are Z+1 bin edges for Z bins.

  • fobs_orb_edges : ndarray (F+1,) The edges of the orbital-frequency dimension of the SAM grid. Note that there are F+1 bin edges for F bins.

Return type:

dict

holodeck.librarian.posterior_populations.main(args=None)[source]

Top level function that does all the work.

holodeck.librarian.posterior_populations.sample_pars_from_chains(chains=None)[source]

Sample randomly from the given chains (i.e. parameter posteriors).

Parameters:

chains (dict) – The MCMC parameter values for each of the parameters in this holodeck parameter-space. These chains should typically be loaded using the load_chains function.

Returns:

pars – Randomly selected parameters drawn from the chains. This will be a single float value for each of the parameters in the holodeck parameter-space, for example:

['hard_time', 'gsmf_phi0', 'gsmf_mchar0_log10',
'mmb_mamp_log10', 'mmb_scatter_dex', 'hard_gamma_inner'],

Return type:

dict

holodeck.librarian.posterior_populations.setup_argparse(*args, **kwargs)[source]

Setup parameters/arguments.

Note that this can be used to set parameters NOT from command-line usage, but in this case the args argument must be set to empty. For example:

This will load of all the default arguments (NOTE the empty string argument is typically needed):

args = gen_holodeck_pops.setup_argparse("")

This will set the desired parameters, and otherwise load the defaults:

args = gen_holodeck_pops.setup_argparse("", nloudest=12, nreals=6, maxlike=True)