figaro.load module

figaro.rate.normalise_alpha_factor(draws, dvdz=None, z_index=-1, z_max=None, n_draws=10000.0)[source]

Normalise the alpha factor for each DPGMM realisation. This is required if during the reconstruction the selection function included the dV/dz*(1+z)^-1 term.

Parameters:
  • draws (iterable) – container for mixture instances

  • dvdz (callable) – function to compute the comoving volume element (in Gpc^3)

  • z_index (int) – redshift parameter index (default: last dimension)

  • z_max (double) – max redshift value

  • n_draws (int) – number of MC draws

figaro.rate.plot_differential_rate(draws, rate, injected=None, bounds=None, out_folder='.', name='density', n_pts=1000, label=None, unit=None, volume_unit='\\mathrm{Gpc}^{-3}\\mathrm{yr}^{-1}', hierarchical=False, show=False, save=True, true_value=None, true_value_label='\\mathrm{True\\ value}', injected_label='\\mathrm{Simulated}', median_label=None, fig=None, colors=['steelblue', 'darkturquoise', 'mediumturquoise'])[source]

Plot the recovered 1D distribution along with the injected distribution and samples from the true distribution (both if available).

Parameters:
  • draws (iterable) – container for mixture instances

  • rate (np.ndarray) – rate samples or value

  • injected (callable or np.ndarray) – injected distribution (if available)

  • bounds (iterable) – bounds for the recovered distribution. If None, bounds from mixture instances are used.

  • out_folder (str or Path) – output folder

  • name (str) – name to be given to outputs

  • n_pts (int) – number of points for linspace

  • label (str) – LaTeX-style quantity label, for plotting purposes

  • unit (str) – LaTeX-style quantity unit, for plotting purposes

  • volume_unit (str) – LaTeX-style volume unit, for plotting purposes

  • hierarchical (bool) – hierarchical inference, for plotting purposes

  • save (bool) – whether to save the plots or not

  • show (bool) – whether to show the plots during the run or not

  • true_value (float) – true value to infer

  • true_value_label (str) – label to assign to the true value marker

  • injected_label (str) – label to assign to the injected distribution

  • median_label (str) – label to assign to the reconstruction

  • fig (matplotlib.figure.Figure) – figure to use for plotting. Must have (dim,dim) axes.

  • colors (list-of-str) – list of colors for median, 68% and 90% credible regions

Returns:

figure with the plot

Return type:

matplotlib.figure.Figure

figaro.rate.plot_integrated_rate(samples, out_folder='.', name='density', volume_unit='\\mathrm{Gpc}^{-3}\\mathrm{yr}^{-1}', show=False, save=True, true_value=None, true_label=None)[source]

Plot the integrated rate distribution.

Parameters:
  • samples (np.ndarray) – rate samples

  • out_folder (str or Path) – output folder

  • name (str) – name to be given to output

  • volume_unit (str) – LaTeX-style volume unit, for plotting purposes

  • save (bool) – whether to save the plot or not

  • show (bool) – whether to show the plot during the run or not

  • true_value (iterable) – true value to plot

  • levels (iterable) – credible levels to plot

  • true_label (str) – label to assign to the reconstruction

Returns:

figure with the plot

Return type:

matplotlib.figure.Figure

figaro.rate.sample_VT(draws, selfunc, T, size=None, n_draws=10000.0, each=False, dvdz=None, z_index=-1)[source]

Draw samples from the VT distribution given the astrophysical distribution of quantities, the selection function and the observing time. See Eqs. (21) of Kapadia et al (2020) (https://arxiv.org/pdf/1903.06881.pdf). The calibration uncertainty is estimated as in Sec. 5 - Eq. (17) - of Abbott et al (2016) (https://arxiv.org/pdf/1606.03939.pdf)

Parameters:
  • draws (iterable) – container for mixture instances

  • selfunc (callable) – selection function approximant

  • T (double) – duration of the observations

  • size (int) – number of samples

  • n_draws (int) – number of MC draws

  • each (bool) – sample one point from each draw

  • element (callable dvdz function to compute the comoving volume)

  • (default (int z_index redshift parameter index) – last dimension)

Returns:

VT samples

Return type:

np.ndarray

figaro.rate.sample_rate(draws, n_obs, selfunc, T, volume=None, size=None, each=False, n_draws=10000.0, dvdz=None, z_index=-1, normalise_alpha=False)[source]

Compute the integrated rate given a set of draws. If volume keyword is not used, returns the expected number of events before filtering.

Parameters:
  • draws (iterable) – container for mixture instances

  • n_obs (int) – number of observed events

  • selfunc (callable) – selection function approximant

  • T (double) – duration of the observations

  • volume (double) – surveyed volume. If None, it is estimated.

  • size (int) – number of samples

  • each (bool) – sample one point from each draw

  • n_draws (int) – number of MC draws

  • element (callable dvdz function to compute the comoving volume)

  • (default (int z_index redshift parameter index) – last dimension)

  • normalise_alpha (bool) – re-normalise alpha (required if the selection function includes dV/dz*(1+z)^-1)

Returns:

integrated rate samples

Return type:

np.ndarray