figaro.load module

figaro.load.available_gw_pars()[source]

Print a list of available GW parameters

figaro.load.load_data(path, seed=False, par=None, n_samples=-1, cosmology='Planck18', volume=False, waveform='combined', snr_threshold=None, far_threshold=None, verbose=True, likelihood=False)[source]

Loads the data from .txt files (for simulations) or .h5/.hdf5/.dat files (posteriors from GWTC-x). Default cosmological parameters from Planck Collaboration (2021) in a flat Universe (https://www.aanda.org/articles/aa/pdf/2020/09/aa33910-18.pdf) Not all GW parameters are implemented: run figaro.load.available_gw_pars() for a list of available parameters.

Parameters:
  • path (str or Path) – folder with data files

  • seed (bool) – fixes the seed to a default value (1) for reproducibility

  • par (list-of-str) – list with parameter(s) to extract from GW posteriors

  • n_samples (int) – number of samples for (random) downsampling. Default -1: all samples

  • cosmology (str) – set of cosmological parameters (Planck18 or Planck15)

  • waveform (str) – waveform family to be used (‘combined’, ‘seob’, ‘imr’)

  • snr_threhsold (double) – SNR threshold for event filtering. For injection analysis only.

  • far_threshold (double) – FAR threshold for event filtering. For injection analysis only.

  • verbose (bool) – show progress bar

  • likelihood (bool) – resample to get likelihood samples

Returns:

samples np.ndarray: names

Return type:

np.ndarray

figaro.load.load_density(path, make_comp=True)[source]

Loads a list of figaro.mixture instances from path. If the requested file extension (pkl or json) is not available, it tries loading the other.

Parameters:
  • path (str or Path) – path with draws (file or folder)

  • make_comp (bool) – make component objects

Returns:

figaro.mixture object instances

Return type:

list

figaro.load.load_selection_function(file, par=None, far_threshold=1)[source]

Loads the selection function, either from a python module containing a method called ‘selection_function’ or via injections. If injections, it assumes that the last column of a txt/csv/dat file contains the sampling pdf.

Parameters:
  • file (str or Path) – selection function file

  • par (list-of-str) – list with parameter(s) to extract from GW posteriors

  • threshold (double) – FAR threshold to filter LVK injections

Returns:

detected samples or callable with approximant np.ndarray or NoneType: injection pdf (for samples) or None (for approximant) int or NoneType: total number of injections double duration: duration of the observation

Return type:

np.ndarray or callable

figaro.load.load_single_event(event, seed=False, par=None, n_samples=-1, cosmology='Planck18', volume=False, waveform='combined', snr_threshold=None, far_threshold=None, likelihood=False)[source]

Loads the data from .txt/.dat files (for simulations) or .h5/.hdf5 files (posteriors from GWTC) for a single event. Default cosmological parameters from Planck Collaboration (2021) in a flat Universe (https://www.aanda.org/articles/aa/pdf/2020/09/aa33910-18.pdf) Not all GW parameters are implemented: run figaro.load.available_gw_pars() for a list of the available parameters.

Parameters:
  • file (str or Path) – file with samples

  • seed (bool) – fixes the seed to a default value (1) for reproducibility

  • par (list-of-str) – list with parameter(s) to extract from GW posteriors (m1, m2, mc, z, chi_effective)

  • n_samples (int) – number of samples for (random) downsampling. Default -1: all samples

  • cosmology (str) – set of cosmological parameters (Planck18 or Planck15)

  • volume (bool) – if True, loads RA, dec and Luminosity distance (for skymaps)

  • waveform (str) – waveform family to be used (‘combined’, ‘seob’, ‘imr’)

  • snr_threhsold (double) – SNR threshold for event filtering. For injection analysis only.

  • far_threshold (double) – FAR threshold for event filtering. For injection analysis only.

  • likelihood (bool) – resample to get likelihood samples

Returns:

samples np.ndarray: name

Return type:

np.ndarray

figaro.load.save_density(draws, folder='.', name='density', ext='json')[source]

Exports a list of figaro.mixture instances to file

Parameters:
  • draws (list) – list of mixtures to be saved

  • folder (str or Path) – folder in which the output file will be saved

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

  • ext (str) – file extension (pkl or json)