GWForge.population.user_defined =============================== .. py:module:: GWForge.population.user_defined .. autoapi-nested-parse:: User-defined population distributions from tabulated (xx, yy) priors. This lets people feed a population produced by an external population-synthesis code straight into GWForge, without shoehorning it into a parameterised model. The distribution of any parameter is supplied as a support array ``xx`` and a (possibly unnormalised) probability-density array ``yy`` in a JSON file with the structure:: { "mass_1_source": {"xx": [...], "yy": [...]}, "mass_ratio": {"xx": [...], "yy": [...]}, "a_1": {"xx": [...], "yy": [...]} } Each ``(xx, yy)`` pair is turned into a :class:`bilby.core.prior.Interped` prior, which normalises ``yy`` and samples via inverse-CDF. Functions --------- .. autoapisummary:: GWForge.population.user_defined.get_xx_yy_from_population_priors GWForge.population.user_defined.interped_prior_from_file Module Contents --------------- .. py:function:: get_xx_yy_from_population_priors(file, parameter) Extract the ``xx`` (support) and ``yy`` (density) arrays for a parameter. :param file: Path to the JSON file of population priors, structured as ``{parameter: {"xx": [...], "yy": [...]}}``. :type file: str :param parameter: The parameter name to extract (e.g. ``'mass_1_source'``, ``'mass_ratio'``, ``'a_1'``). :type parameter: str :returns: * **xx** (*numpy.ndarray*) -- The support (x-values) of the prior distribution. * **yy** (*numpy.ndarray*) -- The probability density (y-values) of the prior distribution. .. py:function:: interped_prior_from_file(file, parameter, name=None) Build a :class:`bilby.core.prior.Interped` prior from a tabulated prior. :param file: Path to the JSON population-priors file. :type file: str :param parameter: Key to read from the file. :type parameter: str :param name: Name to give the resulting prior. Defaults to ``parameter``. :type name: str, optional :rtype: bilby.core.prior.Interped