firecrown.connector.mapping =========================== .. py:module:: firecrown.connector.mapping .. autoapi-nested-parse:: Facilities for mapping cosmological parameters between frameworks. The module :mod:`mapping` provides facilities for mapping the cosmological constants and functions used by one body of code to another. Each supported body of code has its own dedicated class. Attributes ---------- .. autoapisummary:: firecrown.connector.mapping.mapping_classes Classes ------- .. autoapisummary:: firecrown.connector.mapping.Mapping firecrown.connector.mapping.MappingCosmoSIS firecrown.connector.mapping.MappingCAMB Functions --------- .. autoapisummary:: firecrown.connector.mapping.build_ccl_background_dict firecrown.connector.mapping.mapping_builder Module Contents --------------- .. py:function:: build_ccl_background_dict(*, a, chi, h_over_h0) Builds the CCL dictionary of background quantities. :param a: The scale factor array :param chi: The comoving distance array :param h_over_h0: The Hubble parameter divided by H0 :return: the dictionary of background quantities .. py:class:: Mapping Base class defining the interface for each supported code. The interface describes a mapping of cosmological constants from some concrete Boltzmann calculator to the form those constants take in CCL. Each supported Boltzmann calculator must have its own concrete subclass. The class attributes are all :mod:`firecrown.connector.descriptors`. This is to control the allowed types for the instance attributes. A descriptor of name 'x' will provide an apparent attribute with name `x` in each object, as well as an entry `_x` in the object's `__dict__`. .. py:attribute:: Omega_c .. py:attribute:: Omega_b .. py:attribute:: h .. py:attribute:: A_s .. py:attribute:: sigma8 .. py:attribute:: n_s .. py:attribute:: Omega_k .. py:attribute:: Neff .. py:attribute:: m_nu_type .. py:attribute:: w0 .. py:attribute:: wa .. py:attribute:: T_CMB .. py:attribute:: m_nu :type: float | list[float] | None :value: None .. py:method:: get_params_names(amplitude = PoweSpecAmplitudeParameter.AS) Return the names of the expected cosmological parameters for this mapping. .. py:method:: transform_k_h_to_k(k_h) Transform the given k_h (k over h) to k. :param k_h: the array of wavenumber/h to be transformed :return: the transformed array .. py:method:: transform_p_k_h3_to_p_k(p_k_h3) Transform the given :math:`p_k h^3 \to p_k`. :param p_k_h3: the array of :math:`p_k h^3` to be transformed .. py:method:: transform_h_to_h_over_h0(h) Transform distances h to :math:`h/h_0`. :param h: the array of distances to be transformed :return: the transformed array .. py:method:: set_params(*, Omega_c, Omega_b, h, A_s = None, sigma8 = None, n_s, Omega_k, Neff, m_nu, w0, wa, T_CMB) Sets the cosmological constants suitable a pyccl.core.CosmologyCalculator. See the documentation of that class for an explanation of the choices and meanings of default values of None. :param Omega_c: fraction of cold dark matter :param Omega_b: fraction of baryons :param h: dimensionless Hubble parameter; h = H0/(100 km/s/Mpc) :param A_s: amplitude of the primordial power spectrum :param sigma8: s.d. of the matter contrast on a scale of (8 Mpc)/h :param n_s: scalar spectral index of primordial power spectrum :param Omega_k: curvature of the universe :param Neff: effective number of relativistic neutrino species :param m_nu: effective mass of neutrinos; None for massless neutrinos :param w0: constant of the CPL parameterization of the dark energy equation of state :param wa: linear coefficient of the CPL parameterization of the dark energy equation of state :param T_CMB: cosmic microwave background temperature today .. py:method:: redshift_to_scale_factor(z) :staticmethod: Converts redshift to scale factor. Given arrays of redshift returns an array of scale factor with the inverse order. :param z: array of redshifts :return: array of scale factors .. py:method:: redshift_to_scale_factor_p_k(p_k) :staticmethod: Converts power spectrum from redshift to scale factor. Given an 2d arrays power spectrum ordered by (redshift, mode) return a 2d array with the rows flipped to match the reordering from redshift to scale factor. :param p_k: a power spectrum, ordered by (redshift, mode) :return: array of power spectrum, ordered by (scale factor, mode) .. py:method:: asdict() Return a dictionary containing the cosmological constants. :return: the dictionary, containing keys: - ``Omega_c``: fraction of cold dark matter - ``Omega_b``: fraction of baryons - ``h``: dimensionless Hubble parameter; h = H0/(100 km/s/Mpc) - ``A_s``: amplitude of the primordial power spectrum - ``sigma8``: s.d. of the matter contrast on a scale of (8 Mpc)/h - ``n_s``: scalar spectral index of primordial power spectrum - ``Omega_k``: curvature of the universe - ``Neff``: effective number of relativistic neutrino species - ``m_nu``: effective mass of neutrinos, or first neutrino - ``m_nu_``: effective mass of the nth neutrino, n >= 2 Note: the values of n are guaranteed to be consecutive. - ``w0``: constant of the CPL parameterization of the dark energy equation of state - ``wa``: linear coefficient of the CPL parameterization of the dark energy equation of state - ``T_CMB``: cosmic microwave background temperature today .. py:method:: get_H0() Return the value of H0. :return: H0 in km/s/Mpc .. py:class:: MappingCosmoSIS Bases: :py:obj:`Mapping` .. autoapi-inheritance-diagram:: firecrown.connector.mapping.MappingCosmoSIS :parts: 1 Mapping support for CosmoSIS. .. py:method:: get_params_names(amplitude = PoweSpecAmplitudeParameter.AS) Return the names of the expected cosmological parameters for this mapping. :return: a list of the cosmological parameter names .. py:method:: transform_k_h_to_k(k_h) Transform the given k_h (k over h) to k. :param k_h: the array of wavenumber/h to be transformeed :return: the transformed array .. py:method:: transform_p_k_h3_to_p_k(p_k_h3) Transform the given :math:`p_k h^3 \to p_k`. :param p_k_h3: the array of :math:`p_k h^3` to be transformed :return: the transformed array .. py:method:: transform_h_to_h_over_h0(h) Transform distances h to :math:`h/h_0`. :param h: the array of distances to be transformed :return: the transformed distances .. py:method:: set_params_from_cosmosis(cosmosis_params) Set the parameters in this mapping from the given CosmoSIS parameters. :param cosmosis_params: the cosmological parameters read from CosmoSIS .. py:method:: calculate_ccl_args(sample) Calculate the arguments necessary for CCL for this sample. :param sample: the datablock for the current sample :return: the arguments required by CCL .. py:class:: MappingCAMB Bases: :py:obj:`Mapping` .. autoapi-inheritance-diagram:: firecrown.connector.mapping.MappingCAMB :parts: 1 Mapping support for PyCAMB, the Python version of CAMB. Note that the Python version of CAMB uses some different conventions from the Fortran version of CAMB. The two are not interchangeable. .. py:method:: get_params_names(amplitude = PoweSpecAmplitudeParameter.AS) Return the names of the expected cosmological parameters for this mapping. :return: a list of the cosmological parameter names .. py:method:: set_params_from_camb(params_values) Set the parameters in this mapping from the given CAMB-style parameters. .. py:data:: mapping_classes :type: Mapping[str, type[Mapping]] .. py:function:: mapping_builder(*, input_style, **kwargs) Return the Mapping class for the given input_style. If input_style is not recognized raise an exception. :param input_style: the name of the mapping :param kwargs: the parameters of the mapping :return: the mapping object