firecrown.likelihood ==================== .. py:module:: firecrown.likelihood .. autoapi-nested-parse:: Likelihood implementations and infrastructure. This module provides the core likelihood framework and specific likelihood implementations for various cosmological observables. Core Components: - :class:`Likelihood`: Abstract base class for all likelihoods - :class:`Statistic`: Base class for observable statistics - :class:`Source`: Infrastructure for data sources and systematics - Likelihood loading utilities Likelihood Types: - :class:`ConstGaussian`: Constant covariance Gaussian likelihood - :class:`GaussFamily`: Gaussian family likelihoods - :class:`StudentT`: Student-t distributed likelihood - :class:`TwoPoint`: Two-point correlation statistics - :class:`BinnedCluster`: Binned cluster statistics base class - :class:`BinnedClusterNumberCounts`: Cluster abundance likelihoods - :class:`BinnedClusterShearProfile`: Cluster weak lensing likelihoods - :class:`Supernova`: Supernova distance modulus likelihoods - :class:`UpdatableClusterObjects`: Connector for creating Firecrown - cluster updatables from external code Subpackages: - :mod:`weak_lensing`: Weak lensing systematics and sources - :mod:`number_counts`: Galaxy number counts systematics and sources - :mod:`supernova`: Supernova-specific implementations - :mod:`factories`: Factory functions for creating likelihood components Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/firecrown/likelihood/factories/index /autoapi/firecrown/likelihood/gaussian/index /autoapi/firecrown/likelihood/number_counts/index /autoapi/firecrown/likelihood/supernova/index /autoapi/firecrown/likelihood/two_point/index /autoapi/firecrown/likelihood/weak_lensing/index Classes ------- .. autoapisummary:: firecrown.likelihood.Likelihood firecrown.likelihood.NamedParameters firecrown.likelihood.Source firecrown.likelihood.SourceGalaxyArgs firecrown.likelihood.SourceGalaxySystematic firecrown.likelihood.SourceSystematic firecrown.likelihood.Statistic firecrown.likelihood.Tracer firecrown.likelihood.TrivialStatistic firecrown.likelihood.ConstGaussian firecrown.likelihood.GaussFamily firecrown.likelihood.State firecrown.likelihood.StudentT firecrown.likelihood.ConstGaussianPM firecrown.likelihood.UpdatableClusterObjects firecrown.likelihood.TwoPoint firecrown.likelihood.TwoPointFactory firecrown.likelihood.BinnedCluster firecrown.likelihood.BinnedClusterNumberCounts firecrown.likelihood.BinnedClusterShearProfile firecrown.likelihood.Supernova Functions --------- .. autoapisummary:: firecrown.likelihood.load_likelihood firecrown.likelihood.load_likelihood_from_module_type Package Contents ---------------- .. py:class:: Likelihood(*, parameter_prefix = None, raise_on_unused_parameter = True) Bases: :py:obj:`firecrown.updatable.Updatable` .. autoapi-inheritance-diagram:: firecrown.likelihood.Likelihood :parts: 1 Likelihood is an abstract class. Concrete subclasses represent specific likelihood forms (e.g. gaussian with constant covariance matrix, or Student's t, etc.). Concrete subclasses must have an implementation of both :meth:`read` and :meth:`compute_loglike`. Note that abstract subclasses of Likelihood might implement these methods, and provide other abstract methods for their subclasses to implement. .. py:attribute:: raise_on_unused_parameter :value: True .. py:method:: read(sacc_data) :abstractmethod: Read the covariance matrix for this likelihood from the SACC file. :param sacc_data: The SACC data object to be read .. py:method:: make_realization_vector() :abstractmethod: Create a new realization of the model. This new realization uses the previously computed theory vector and covariance matrix. :return: the new realization of the theory vector .. py:method:: make_realization(sacc_data, add_noise = True, strict = True) Create a new realization of the model. This realization uses the previously computed theory vector and covariance matrix. :param sacc_data: The SACC data object containing the covariance matrix :param add_noise: If True, add noise to the realization. If False, return only the theory vector. :param strict: If True, check that the indices of the realization cover all the indices of the SACC data object. :return: the new SACC object containing the new realization .. py:method:: compute_loglike_for_sampling(tools) Compute the log-likelihood of generic CCL data, swallowing some CCL errors. If CCL raises an error indicating an integration error, this function returns -np.inf. :param tools: the ModelingTools to be used in calculating the likelihood :return: the log-likelihood .. py:method:: compute_loglike(tools) :abstractmethod: Compute the log-likelihood of generic CCL data. :param tools: the ModelingTools to be used in calculating the likelihood :return: the log-likelihood .. py:class:: NamedParameters(mapping = None) Provides access to a set of parameters of a given set of types. Access to the parameters is provided by a type-safe interface. Each of the access functions assures that the parameter value it returns is of the specified type. .. py:method:: get_bool(name, default_value = None) Return the named parameter as a bool. :param name: the name of the parameter to be returned :param default_value: the default value if the parameter is not found :return: the value of the parameter (or the default value) .. py:method:: get_string(name, default_value = None) Return the named parameter as a string. :param name: the name of the parameter to be returned :param default_value: the default value if the parameter is not found :return: the value of the parameter (or the default value) .. py:method:: get_int(name, default_value = None) Return the named parameter as an int. :param name: the name of the parameter to be returned :param default_value: the default value if the parameter is not found :return: the value of the parameter (or the default value) .. py:method:: get_float(name, default_value = None) Return the named parameter as a float. :param name: the name of the parameter to be returned :param default_value: the default value if the parameter is not found :return: the value of the parameter (or the default value) .. py:method:: get_int_array(name) Return the named parameter as a numpy array of int. :param name: the name of the parameter to be returned :return: the value of the parameter .. py:method:: get_float_array(name) Return the named parameter as a numpy array of float. :param name: the name of the parameter to be returned :return: the value of the parameter .. py:method:: to_set() Return the contained data as a set. :return: the value of the parameter as a set .. py:method:: set_from_basic_dict(basic_dict) Set the contained data from a dictionary of basic types. :param basic_dict: the mapping from strings to values used for initialization .. py:method:: convert_to_basic_dict() Convert a NamedParameters object to a dictionary of built-in types. :return: a dictionary containing the parameters as built-in Python types .. py:method:: __contains__(key) Check if a key is in the NamedParameters object. :param key: the key to check :return: True if the key is in the NamedParameters object, False otherwise .. py:class:: Source(sacc_tracer) Bases: :py:obj:`firecrown.updatable.Updatable` .. autoapi-inheritance-diagram:: firecrown.likelihood.Source :parts: 1 The abstract base class for all sources. .. py:attribute:: cosmo_hash :type: None | int .. py:attribute:: tracers :type: collections.abc.Sequence[Tracer] .. py:attribute:: sacc_tracer .. py:method:: read_systematics(sacc_data) :abstractmethod: Abstract method to read the systematics for this source from the SACC file. :param sacc_data: The SACC data object to be read .. py:method:: read(sacc_data) Read the data for this source from the SACC file. :param sacc_data: The SACC data object to be read .. py:method:: get_scale() :abstractmethod: Abstract method to return the scale for this `Source`. :return: the scale .. py:method:: create_tracers(tools) :abstractmethod: Abstract method to create tracers for this Source. :param tools: The modeling tools used for creating the tracers .. py:method:: get_tracers(tools) Return the tracer for the given cosmology. This method caches its result, so if called a second time with the same cosmology, no calculation needs to be done. :param tools: The modeling tools used for creating the tracers :return: the list of tracers .. py:class:: SourceGalaxyArgs Class for galaxy based sources arguments. .. py:attribute:: z :type: numpy.typing.NDArray[numpy.float64] .. py:attribute:: dndz :type: numpy.typing.NDArray[numpy.float64] .. py:attribute:: scale :type: float :value: 1.0 .. py:attribute:: field :type: str :value: 'delta_matter' .. py:class:: SourceGalaxySystematic(parameter_prefix = None) Bases: :py:obj:`SourceSystematic`, :py:obj:`Generic`\ [\ :py:obj:`_SourceGalaxyArgsT`\ ] .. autoapi-inheritance-diagram:: firecrown.likelihood.SourceGalaxySystematic :parts: 1 Abstract base class for all galaxy-based source systematics. .. py:method:: apply(tools, tracer_arg) :abstractmethod: Apply method to include systematics in the tracer_arg. :param tools: the modeling tools use to update the tracer arg :param tracer_arg: the original source galaxy tracer arg to which we apply the systematic. :return: a new source galaxy tracer arg with the systematic applied .. py:class:: SourceSystematic(parameter_prefix = None) Bases: :py:obj:`firecrown.updatable.Updatable` .. autoapi-inheritance-diagram:: firecrown.likelihood.SourceSystematic :parts: 1 An abstract systematic class (e.g., shear biases, photo-z shifts, etc.). This class currently has no methods at all, because the argument types for the `apply` method of different subclasses are different. .. py:method:: read(sacc_data) Call to allow this object to read from the appropriate sacc data. :param sacc_data: The SACC data object to be read .. py:class:: Statistic(parameter_prefix = None) Bases: :py:obj:`firecrown.updatable.Updatable` .. autoapi-inheritance-diagram:: firecrown.likelihood.Statistic :parts: 1 The abstract base class for all physics-related statistics. Statistics read data from a SACC object as part of a multi-phase initialization. They manage a :class:`DataVector` and, given a :class:`ModelingTools` object, can compute a :class:`TheoryVector`. Statistics represent things like two-point functions and mass functions. .. py:attribute:: sacc_indices :type: None | numpy.typing.NDArray[numpy.int64] .. py:attribute:: ready :value: False .. py:attribute:: computed_theory_vector :value: False .. py:attribute:: theory_vector :type: None | firecrown.data_types.TheoryVector :value: None .. py:method:: read(_) Read the data for this statistic and mark it as ready for use. Derived classes that override this function should make sure to call the base class method using: .. code-block:: python super().read(sacc_data) as the last thing they do. :param _: currently unused, but required by the interface. .. py:method:: get_data_vector() :abstractmethod: Gets the statistic data vector. :return: The data vector. .. py:method:: compute_theory_vector(tools) Compute a statistic from sources, applying any systematics. :param tools: the modeling tools used to compute the theory vector. :return: The computed theory vector. .. py:method:: get_theory_vector() Returns the last computed theory vector. Raises a RuntimeError if the vector has not been computed. :return: The already-computed theory vector. .. py:class:: Tracer(tracer, tracer_name = None, field = None, pt_tracer = None, halo_profile = None, halo_2pt = None) Extending the pyccl.Tracer object with additional information. Bundles together a pyccl.Tracer object with optional information about the underlying 3D field, or a pyccl.nl_pt.PTTracer and halo profiles. .. py:method:: determine_field_name(field, tracer) :staticmethod: Gets a field name for a tracer. This function encapsulates the policy for determining the value to be assigned to the :attr:`field` attribute of a :class:`Tracer`. It is a static method only to keep it grouped with the class for which it is defining the initialization policy. :param field: the (stub) name of the field :param tracer: the name of the tracer :return: the full name of the field .. py:attribute:: ccl_tracer .. py:attribute:: tracer_name :type: str .. py:attribute:: field .. py:attribute:: pt_tracer :value: None .. py:attribute:: halo_profile :value: None .. py:attribute:: halo_2pt :value: None .. py:property:: has_pt :type: bool Answer whether we have a perturbation theory tracer. :return: True if we have a pt_tracer, and False if not. .. py:property:: has_hm :type: bool Answer whether we have a halo model profile. Return True if we have a halo_profile, and False if not. .. py:class:: TrivialStatistic Bases: :py:obj:`Statistic` .. autoapi-inheritance-diagram:: firecrown.likelihood.TrivialStatistic :parts: 1 A minimal statistic only to be used for testing Gaussian likelihoods. It returns a :class:`DataVector` and :class:`TheoryVector` each of which is three elements long. The SACC data provided to :meth:`TrivialStatistic.read` must supply the necessary values. .. py:attribute:: count :value: 3 .. py:attribute:: data_vector :type: None | firecrown.data_types.DataVector :value: None .. py:attribute:: mean .. py:attribute:: computed_theory_vector :value: False .. py:method:: read(sacc_data) Read the necessary items from the sacc data. :param sacc_data: The SACC data object to be read .. py:method:: get_data_vector() Return the data vector; raise exception if there is none. :return: The data vector. .. py:function:: load_likelihood(likelihood_name, build_parameters) Loads a likelihood from the provided likelihood_name. After loading, this method returns a tuple of the likelihood and the modeling tools. :param likelihood_name: script filename or module name :param build_parameters: a NamedParameters object containing the factory function parameters :return: a tuple of the likelihood and the modeling tools .. py:function:: load_likelihood_from_module_type(module, build_parameters, build_likelihood_name = 'build_likelihood') Loads a likelihood from a module type. After loading, this method returns a tuple of the likelihood and the modeling tools. This function is used by both :meth:`load_likelihood_from_script` and :meth:`load_likelihood_from_module`. It is not intended to be called directly. :param module: a loaded module :param build_parameters: a NamedParameters object containing the factory function parameters :return: a tuple of the likelihood and the modeling tools .. py:class:: ConstGaussian(statistics, use_cholesky = True) Bases: :py:obj:`firecrown.likelihood._gaussfamily.GaussFamily` .. autoapi-inheritance-diagram:: firecrown.likelihood.ConstGaussian :parts: 1 Base class for constant covariance Gaussian likelihoods. Provides shared implementations of compute_loglike and make_realization_vector for all constant covariance Gaussian likelihood variants. .. py:method:: compute_loglike(tools) Compute the log-likelihood. :params tools: The modeling tools used to compute the likelihood. :return: The log-likelihood. .. py:method:: make_realization_vector() Create a new (randomized) realization of the model. :return: A new realization of the model .. py:class:: GaussFamily(statistics, use_cholesky = True) Bases: :py:obj:`firecrown.likelihood._base.Likelihood` .. autoapi-inheritance-diagram:: firecrown.likelihood.GaussFamily :parts: 1 GaussFamily is the base class for likelihoods based on a chi-squared calculation. It provides an implementation of Likelihood.compute_chisq. Derived classes must implement the abstract method compute_loglike, which is inherited from Likelihood. GaussFamily (and all classes that inherit from it) must abide by the the following rules regarding the order of calling of methods. 1. after a new object is created, :meth:`read` must be called before any other method in the interface. 2. after :meth:`read` has been called it is legal to call :meth:`get_data_vector`, or to call :meth:`update`. 3. after :meth:`update` is called it is then legal to call :meth:`calculate_loglike` or :meth:`get_data_vector`, or to reset the object (returning to the pre-update state) by calling :meth:`reset`. It is also legal to call :meth:`compute_theory_vector`. 4. after :meth:`compute_theory_vector` is called it is legal to call :meth:`get_theory_vector` to retrieve the already-calculated theory vector. This state machine behavior is enforced through the use of the decorator :meth:`enforce_states`, above. .. py:attribute:: state :type: State .. py:attribute:: statistics :type: firecrown.updatable.UpdatableCollection[firecrown.likelihood._base.GuardedStatistic] .. py:attribute:: cov :type: None | numpy.typing.NDArray[numpy.float64] :value: None .. py:attribute:: cholesky :type: None | numpy.typing.NDArray[numpy.float64] :value: None .. py:attribute:: inv_cov :type: None | numpy.typing.NDArray[numpy.float64] :value: None .. py:attribute:: cov_index_map :type: None | dict[int, int] :value: None .. py:attribute:: theory_vector :type: None | numpy.typing.NDArray[numpy.double] :value: None .. py:attribute:: data_vector :type: None | numpy.typing.NDArray[numpy.double] :value: None .. py:method:: create_ready(statistics, covariance) :classmethod: Create a GaussFamily object in the READY state. :param statistics: A list of statistics to be include in chisquared calculations :param covariance: The covariance matrix of the statistics :return: A ready GaussFamily object .. py:method:: read(sacc_data) Read the covariance matrix for this likelihood from the SACC file. :param sacc_data: The SACC data object to be read .. py:method:: get_cov(statistic = None) Gets the current covariance matrix. :param statistic: The statistic for which the sub-covariance matrix should be returned. If not specified, return the covariance of all statistics. :return: The covariance matrix (or portion thereof) .. py:method:: get_data_vector() Get the data vector from all statistics in the right order. :return: The data vector .. py:method:: compute_theory_vector(tools) Computes the theory vector using the current instance of pyccl.Cosmology. :param tools: Current ModelingTools object :return: The computed theory vector .. py:method:: get_theory_vector() Get the already-computed theory vector from all statistics. :return: The theory vector, with all statistics in the right order .. py:method:: compute(tools) Calculate and return both the data and theory vectors. This method is deprecated and will be removed in a future version of Firecrown. :param tools: the ModelingTools to be used in the calculation of the theory vector :return: a tuple containing the data vector and the theory vector .. py:method:: compute_chisq_impl(residuals) Implementation of chi-squared calculation. This method can be overridden by subclasses that need different chi-squared calculation strategies. By default, it uses either Cholesky decomposition (more stable) or direct inverse covariance multiplication, depending on the _use_cholesky_for_chisq flag. :param residuals: The residuals (data - theory) :return: The chi-squared value .. py:method:: compute_chisq(tools) Calculate and return the chi-squared for the given cosmology. :param tools: the ModelingTools to be used in the calculation of the theory vector :return: the chi-squared .. py:method:: get_sacc_indices(statistic = None) Get the SACC indices of the statistic or list of statistics. If no statistic is given, get the indices of all statistics of the likelihood. :param statistics: The statistic or list of statistics for which the SACC indices are desired :return: The SACC indices .. py:method:: make_realization(sacc_data, add_noise = True, strict = True) Create a new realization of the model. :param sacc_data: The SACC data object containing the covariance matrix to be read :param add_noise: If True, add noise to the realization. :param strict: If True, check that the indices of the realization cover all the indices of the SACC data object. :return: The SACC data object containing the new realization .. py:class:: State Bases: :py:obj:`enum.Enum` .. autoapi-inheritance-diagram:: firecrown.likelihood.State :parts: 1 The states used in GaussFamily. GaussFamily and all subclasses enforce a state machine behavior based on these states to ensure that the necessary initialization and setup is done in the correct order. .. py:attribute:: INITIALIZED :value: 1 .. py:attribute:: READY :value: 2 .. py:attribute:: UPDATED :value: 3 .. py:attribute:: COMPUTED :value: 4 .. py:class:: StudentT(statistics, nu = None) Bases: :py:obj:`firecrown.likelihood._gaussfamily.GaussFamily` .. autoapi-inheritance-diagram:: firecrown.likelihood.StudentT :parts: 1 A T-distribution for the log-likelihood. This distribution is appropriate when the covariance has been obtained from a finite number of simulations. See Sellentin & Heavens (2016; arXiv:1511.05969). As the number of simulations increases, the T-distribution approaches a Gaussian. .. py:attribute:: nu .. py:method:: compute_loglike(tools) Compute the log-likelihood. :param tools: The modeling tools used to compute the likelihood. :return: The log-likelihood. .. py:class:: ConstGaussianPM(statistics) Bases: :py:obj:`firecrown.likelihood._gaussian.ConstGaussian` .. autoapi-inheritance-diagram:: firecrown.likelihood.ConstGaussianPM :parts: 1 A Gaussian log-like with constant covariance, marginalizing over a point mass. .. py:attribute:: inv_cov_correction :type: numpy.ndarray | None :value: None .. py:property:: pm_maps_ready :type: bool Check if point mass maps have been generated. .. py:method:: compute_chisq_impl(residuals) Override chi-squared calculation to use direct inv_cov. We must use direct inv_cov multiplication because the point mass correction makes the Cholesky decomposition incompatible. :param residuals: The residuals (data - theory) :return: The chi-squared value .. py:method:: compute_pointmass(cosmo, sigma_B = DEFAULT_SIGMA_B, point_mass = DEFAULT_POINT_MASS) Update the inverse covariance matrix to marginalize over the point mass. The procedure follows MacCrann et al. (2019). :param cosmo: A pre-initialized CCL Cosmology object to compute distances. :param sigma_B: The PM prior width defined in MacCrann et al. (2019). :param point_mass: The fiducial value of the point mass in units of Mpc/h. :return: The new inverse covariance matrix. .. py:class:: UpdatableClusterObjects(cluster_objects_configs) Bases: :py:obj:`firecrown.updatable.Updatable` .. autoapi-inheritance-diagram:: firecrown.likelihood.UpdatableClusterObjects :parts: 1 Class to store updatable parameters for cluster objects. This class passes updatable parameters to all objects within a cluster recipe. Attributes ---------- cluster_objects_configs: tuple List of dictionaries containing configuration on which parameters of each cluster objects in the recipe that will be updated. Examples -------- cluster_objects_configs = ( { "recipe_attribute_name": "mass_distribution", "parameters": ["mu0", "mu1", "mu2", "sigma0", "sigma1", "sigma2"], }, { "recipe_attribute_name": "cluster_theory", "parameters": ["cluster_concentration"], # if wl profile "has_cosmo": True, }, { "recipe_attribute_name": "completeness", "parameters": ["a_n", "b_n", "a_logm_piv", "b_logm_piv"], }, { "recipe_attribute_name": "purity", "parameters": ["a_n", "b_n", "a_logm_piv", "b_logm_piv"], }, ) .. py:attribute:: cluster_objects_configs .. py:attribute:: my_updatables :type: firecrown.updatable.UpdatableCollection .. py:method:: init_all_parameters(cluster_recipe) Instanciate all updatables parameiters. Parameters ---------- cluster_recipe: recipe object Recipe containing all cluster objects (as attributes) to get the defalt parameters from. .. py:method:: export_all_parameters(cluster_recipe, cosmo) Passes internal parameters to cluster object. Parameters ---------- cluster_object: list Recipe containing all cluster objects (as attributes) to export internal parameters to. .. py:class:: TwoPoint(sacc_data_type, source0, source1, *, interp_ells_gen = gen.LogLinearElls(), ell_or_theta = None, tracers = None, int_options = None, apply_interp = ApplyInterpolationWhen.DEFAULT, normalize_window = True) Bases: :py:obj:`firecrown.likelihood._base.Statistic` .. autoapi-inheritance-diagram:: firecrown.likelihood.TwoPoint :parts: 1 A two-point statistic. A two-point statistic represents the correlation between two measurements. If the same source is used twice, this produces an autocorrelation. This class supports various two-point statistics including shear correlation functions, galaxy-shear correlation functions, and galaxy clustering statistics in both harmonic and real space. The `sacc_data_type` parameter specifies the type of two-point statistic. Valid SACC data types map to CCL correlation function types or power spectra: * `galaxy_density_cl`: CCL angular power spectrum (cl) * `galaxy_density_xi`: CCL angular position correlation (gg) * `galaxy_shearDensity_cl_e`: CCL angular power spectrum (cl) * `galaxy_shearDensity_xi_t`: CCL position-shear cross-correlation (gl) * `galaxy_shear_cl_ee`: CCL angular power spectrum (cl) * `galaxy_shear_xi_minus`: CCL angular shear correlation xi- * `galaxy_shear_xi_plus`: CCL angular shear correlation xi+ * `cmbGalaxy_convergenceDensity_xi`: CCL position correlation (gg) * `cmbGalaxy_convergenceShear_xi_t`: CCL position-shear cross-correlation (gl) The `ell_or_theta` parameter allows generating ell or theta values for computing statistics when the corresponding data is not present in the SACC file. It accepts a dictionary with keys: `minimum` (float), `maximum` (float), `n` (int), and `binning` (str, 'log' or 'lin'). The `ell_for_xi` parameter configures ell values for computing power spectra used in real-space integrations. It accepts a dictionary with keys: `minimum` (int, default 2), `midpoint` (int, default 50), `maximum` (int, default 60000), and `n_log` (int, default 200). :ivar ccl_kind: The CCL correlation function kind or 'cl' for power spectra. :ivar sacc_tracers: The SACC tracer names for this statistic, set after read. .. py:property:: sacc_data_type :type: str Backwards compatibility for sacc_data_type. .. py:property:: source0 :type: firecrown.likelihood._base.Source Backwards compatibility for source0. .. py:property:: source1 :type: firecrown.likelihood._base.Source Backwards compatibility for source1. .. py:property:: window :type: None | numpy.typing.NDArray[numpy.float64] Backwards compatibility for window. .. py:property:: sacc_tracers :type: None | firecrown.metadata_types.TracerNames Backwards compatibility for sacc_tracers. .. py:property:: ells :type: None | numpy.typing.NDArray[numpy.int64] Backwards compatibility for ells. .. py:property:: thetas :type: None | numpy.typing.NDArray[numpy.float64] Backwards compatibility for thetas. .. py:property:: ells_for_xi :type: None | numpy.typing.NDArray[numpy.int64] Backwards compatibility for ells_for_xi. .. py:property:: cells Backwards compatibility for cells. .. py:attribute:: theory .. py:attribute:: normalize_window :value: True .. py:method:: from_metadata_index(metadata_indices, tp_factory) :classmethod: Create an UpdatableCollection of TwoPoint statistics. This constructor creates an UpdatableCollection of TwoPoint statistics from a list of TwoPointCellsIndex or TwoPointXiThetaIndex metadata index objects. The purpose of this constructor is to create a TwoPoint statistic from metadata index, which requires a follow-up call to `read` to read the data and metadata from the SACC object. :param metadata_index: The metadata index objects to initialize the TwoPoint statistics. :param tp_factory: The TwoPointFactory to use. :return: An UpdatableCollection of TwoPoint statistics. .. py:method:: from_metadata(metadata_seq, tp_factory) :classmethod: Create an UpdatableCollection of TwoPoint statistics from metadata. This constructor creates an UpdatableCollection of TwoPoint statistics from a list of TwoPointHarmonic or TwoPointReal metadata objects. The metadata objects are used to initialize the TwoPoint statistics. The sources are initialized using the factories provided. Note that TwoPoint created with this constructor are ready to be used, but contain no data. :param metadata_seq: The metadata objects to initialize the TwoPoint statistics. :param wl_factory: The weak lensing factory to use. :param nc_factory: The number counts factory to use. :return: An UpdatableCollection of TwoPoint statistics. .. py:method:: create_two_point(measurement, tp_factory) :classmethod: Create a single TwoPoint statistic from a measurement. :param measurement: The measurement object to initialize the TwoPoint statistic. .. py:method:: from_measurement(measurements, tp_factory) :classmethod: Create an UpdatableCollection of TwoPoint statistics from measurements. This constructor creates an UpdatableCollection of TwoPoint statistics from a list of TwoPointMeasurement objects. The measurements are used to initialize the TwoPoint statistics. The sources are initialized using the factories provided. Note that TwoPoint created with this constructor are ready to be used and contain data. :param measurements: The measurements objects to initialize the TwoPoint statistics. :param wl_factory: The weak lensing factory to use. :param nc_factory: The number counts factory to use. :return: An UpdatableCollection of TwoPoint statistics. .. py:method:: read(sacc_data) Read the data for this statistic from the SACC file. :param sacc_data: The data in the sacc format. .. py:method:: read_real_space(sacc_data) Read the data for this statistic from the SACC file. .. py:method:: read_harmonic_space(sacc_data) Read the data for this statistic from the SACC file. .. py:method:: read_harmonic_spectrum_data(ells_cells_indices, sacc_data) Read all the data for this statistic from the SACC file. :param ells_cells_indices: The ells, the cells and the indices of the data in the SACC file. :param sacc_data: The data in the sacc format. :return: The ells, the cells and the indices, and window function if there is one. .. py:method:: get_data_vector() Return this statistic's data vector. .. py:method:: set_data_vector(value) Set this statistic's data vector. .. py:method:: compute_theory_vector_real_space(tools) Compute a two-point statistic in real space. This method computes the two-point statistic in real space. It first computes the Cl's in harmonic space and then translates them to real space using CCL. .. py:method:: compute_theory_vector_harmonic_space(tools) Compute a two-point statistic in harmonic space. This method computes the two-point statistic in harmonic space. It computes either the Cl's at the ells provided by the SACC file or the ells required for the window function. .. py:method:: compute_cells(ells, scale0, scale1, tools, tracers0, tracers1, interpolate = False) Compute the power spectrum for the given ells and tracers. This method computes the power spectrum for the given ells and tracers. If interpolate is True, it will interpolate the power spectrum to the ells provided. .. py:class:: TwoPointFactory(/, **data) Bases: :py:obj:`pydantic.BaseModel` .. autoapi-inheritance-diagram:: firecrown.likelihood.TwoPointFactory :parts: 1 Factory class for creating TwoPoint statistics from measurements. This factory manages the creation of TwoPoint statistics by coordinating multiple source factories (WeakLensing, NumberCounts, and CMBConvergence) and applying them to measurements. It specifies the correlation space (harmonic or real) and optional integration options for C_ℓ calculations. Users typically instantiate this class from YAML configuration and use it to build TwoPoint objects from measurements extracted from SACC files. .. py:attribute:: model_config Configuration for the model, should be a dictionary conforming to [`ConfigDict`][pydantic.config.ConfigDict]. .. py:attribute:: correlation_space :type: Annotated[firecrown.metadata_types.TwoPointCorrelationSpace, BeforeValidator(make_correlation_space), Field(description='The two-point correlation space.')] .. py:attribute:: weak_lensing_factories :type: list[firecrown.likelihood._weak_lensing.WeakLensingFactory] :value: None .. py:attribute:: number_counts_factories :type: list[firecrown.likelihood.number_counts.NumberCountsFactory] :value: None .. py:attribute:: cmb_factories :type: list[firecrown.likelihood._cmb.CMBConvergenceFactory] :value: None .. py:attribute:: int_options :type: firecrown.utils.ClIntegrationOptions | None :value: None .. py:method:: model_post_init(_, /) Initialize the WeakLensingFactory object. .. py:method:: get_factory(measurement, type_source = TypeSource.DEFAULT) Get the Factory for the given Measurement and TypeSource. .. py:method:: from_measurement(tpms) Create a TwoPoint object from a list of TwoPointMeasurement. .. py:method:: from_metadata(metadata_seq) Create a TwoPoint object from a list of TwoPointHarmonic or TwoPointReal. .. py:class:: BinnedCluster(cluster_properties, survey_name, cluster_recipe, systematics = None) Bases: :py:obj:`firecrown.likelihood._base.Statistic` .. autoapi-inheritance-diagram:: firecrown.likelihood.BinnedCluster :parts: 1 A statistic representing clusters in a z, mass bin. .. py:attribute:: systematics :value: [] .. py:attribute:: theory_vector :type: None | firecrown.data_types.TheoryVector :value: None .. py:attribute:: cluster_properties .. py:attribute:: survey_name .. py:attribute:: cluster_recipe .. py:attribute:: data_vector .. py:attribute:: sky_area :value: 0.0 .. py:attribute:: bins :type: list[firecrown.models.cluster.SaccBin] :value: [] .. py:method:: get_data_vector() Gets the statistic data vector. :return: The statistic data vector. .. py:method:: check_mor_murata_variance() Check if variance is negative. .. py:class:: BinnedClusterNumberCounts(cluster_properties, survey_name, cluster_recipe, systematics = None) Bases: :py:obj:`firecrown.likelihood._binned_cluster.BinnedCluster` .. autoapi-inheritance-diagram:: firecrown.likelihood.BinnedClusterNumberCounts :parts: 1 A statistic representing the number of clusters in a z, mass bin. .. py:method:: read(sacc_data) Read the data for this statistic and mark it as ready for use. :param sacc_data: The data in the sacc format. .. py:method:: get_binned_cluster_property(cluster_counts, cluster_properties) Computes the mean mass of clusters in each bin. Using the data from the sacc file, this function evaluates the likelihood for a single point of the parameter space, and returns the predicted mean mass of the clusters in each bin. :param cluster_counts: The number of clusters in each bin. :param cluster_properties: The cluster observables to use. .. py:method:: get_binned_cluster_counts() Computes the number of clusters in each bin. Using the data from the sacc file, this function evaluates the likelihood for a single point of the parameter space, and returns the predicted number of clusters in each bin. :param tools: The modeling tools used to compute the statistic. :return: The number of clusters in each bin. .. py:class:: BinnedClusterShearProfile(cluster_properties, survey_name, cluster_recipe, systematics = None) Bases: :py:obj:`firecrown.likelihood._binned_cluster.BinnedCluster` .. autoapi-inheritance-diagram:: firecrown.likelihood.BinnedClusterShearProfile :parts: 1 The Binned Cluster Delta Sigma statistic. This class will make a prediction for the shear of clusters in a z, mass, radial bin and compare that prediction to the data provided in the sacc file. .. py:method:: read(sacc_data) Read the data for this statistic and mark it as ready for use. :param sacc_data: The data in the sacc format. .. py:method:: get_binned_cluster_property(cluster_properties) Computes the mean deltasigma of clusters in each bin. Using the data from the sacc file, this function evaluates the likelihood for a single point of the parameter space, and returns the predicted mean deltasigma of the clusters in each bin. .. py:class:: Supernova(sacc_tracer) Bases: :py:obj:`firecrown.likelihood._base.Statistic` .. autoapi-inheritance-diagram:: firecrown.likelihood.Supernova :parts: 1 A statistic representing the distance modulus for a single supernova. This statistic that applies an additive shift M to a supernova's distance modulus. .. py:attribute:: sacc_tracer .. py:attribute:: data_vector :type: None | firecrown.data_types.DataVector :value: None .. py:attribute:: a :type: None | numpy.typing.NDArray[numpy.float64] :value: None .. py:attribute:: M .. py:method:: read(sacc_data) Read the data for this statistic from the SACC file. :param sacc_data: The data in the sacc format. .. py:method:: get_data_vector() Return the data vector; raise exception if there is none. :return: The data vector.