firecrown.likelihood.factories ============================== .. py:module:: firecrown.likelihood.factories .. autoapi-nested-parse:: Factory functions for creating likelihoods from SACC files. This module provides factory functions to create likelihood objects by combining a SACC file and a set of statistic factories. Users can define their own custom statistic factories for advanced use cases or rely on the generic factory functions provided here for simpler scenarios. For straightforward contexts where all data in the SACC file is utilized, the generic factories simplify the process. The user only needs to supply the SACC file and specify which statistic factories to use, and the likelihood factory will handle the creation of the likelihood object, assembling the necessary components automatically. These functions are particularly useful when the full set of statistics present in a SACC file is being used without the need for complex customization. Classes ------- .. autoapisummary:: firecrown.likelihood.factories.DataSourceSacc firecrown.likelihood.factories.TwoPointExperiment Functions --------- .. autoapisummary:: firecrown.likelihood.factories.load_sacc_data firecrown.likelihood.factories.ensure_path firecrown.likelihood.factories.build_two_point_likelihood Module Contents --------------- .. py:function:: load_sacc_data(filepath) Load SACC data from a file, auto-detecting the format. Attempts to load the file first as HDF5, then as FITS if HDF5 fails. This allows the function to work with both modern HDF5-based SACC files and legacy FITS-based SACC files. :param filepath: Path to the SACC data file (str or Path object) :return: Loaded SACC data object :raises FileNotFoundError: If the file does not exist :raises ValueError: If the file cannot be read as either HDF5 or FITS SACC data .. py:class:: DataSourceSacc(/, **data) Bases: :py:obj:`pydantic.BaseModel` .. autoapi-inheritance-diagram:: firecrown.likelihood.factories.DataSourceSacc :parts: 1 Model for the data source in a likelihood configuration. .. py:attribute:: sacc_data_file :type: str .. py:attribute:: filters :type: firecrown.data_functions.TwoPointBinFilterCollection | None :value: None .. py:method:: set_path(path) Set the path for the data source. .. py:method:: get_filepath() Return the filename of the data source. Raises a FileNotFoundError if the file does not exist. :return: The filename .. py:method:: get_sacc_data() Load the SACC data file. Uses automatic format detection to load both HDF5 and FITS files. .. py:function:: ensure_path(file) Ensure the file path is a Path object. .. py:class:: TwoPointExperiment(/, **data) Bases: :py:obj:`pydantic.BaseModel` .. autoapi-inheritance-diagram:: firecrown.likelihood.factories.TwoPointExperiment :parts: 1 Model for the two-point experiment in a likelihood configuration. .. py:attribute:: two_point_factory :type: firecrown.likelihood.two_point.TwoPointFactory .. py:attribute:: data_source :type: DataSourceSacc .. py:attribute:: ccl_factory :type: firecrown.ccl_factory.CCLFactory | None :value: None .. py:method:: model_post_init(_, /) Initialize the TwoPointExperiment object. .. py:method:: load_from_yaml(file) :classmethod: Load a TwoPointExperiment object from a YAML file. .. py:method:: make_likelihood() Create a likelihood object for two-point statistics from a SACC file. .. py:function:: build_two_point_likelihood(build_parameters) Build a likelihood object for two-point statistics from a SACC file. This function creates a likelihood object for two-point statistics using a SACC file and a set of statistic factories. The user must provide the SACC file and specify which statistic factories to use. The likelihood object is created by combining the SACC file with the specified statistic factories. :param build_parameters: A NamedParameters object containing the following parameters: - sacc_file: The SACC file containing the data. - statistic_factories: A YAML file containing the statistic factories to use.