firecrown.likelihood.factories
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
Model for the data source in a likelihood configuration. |
|
Model for the two-point experiment in a likelihood configuration. |
Functions
|
Load SACC data from a file, auto-detecting the format. |
|
Ensure the file path is a Path object. |
|
Build a likelihood object for two-point statistics from a SACC file. |
Module Contents
- firecrown.likelihood.factories.load_sacc_data(filepath)[source]
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.
- Parameters:
filepath (str | pathlib.Path) – Path to the SACC data file (str or Path object)
- Returns:
Loaded SACC data object
- Raises:
FileNotFoundError – If the file does not exist
ValueError – If the file cannot be read as either HDF5 or FITS SACC data
- Return type:
sacc.Sacc
- class firecrown.likelihood.factories.DataSourceSacc(/, **data)[source]
Bases:
pydantic.BaseModel
Model for the data source in a likelihood configuration.
- Parameters:
data (Any)
- sacc_data_file: str
- filters: firecrown.data_functions.TwoPointBinFilterCollection | None = None
- set_path(path)[source]
Set the path for the data source.
- Parameters:
path (pathlib.Path)
- Return type:
None
- firecrown.likelihood.factories.ensure_path(file)[source]
Ensure the file path is a Path object.
- Parameters:
file (str | pathlib.Path)
- Return type:
pathlib.Path
- class firecrown.likelihood.factories.TwoPointExperiment(/, **data)[source]
Bases:
pydantic.BaseModel
Model for the two-point experiment in a likelihood configuration.
- Parameters:
data (Any)
- two_point_factory: firecrown.likelihood.two_point.TwoPointFactory
- data_source: DataSourceSacc
- ccl_factory: firecrown.ccl_factory.CCLFactory | None = None
- classmethod load_from_yaml(file)[source]
Load a TwoPointExperiment object from a YAML file.
- Parameters:
file (str | pathlib.Path)
- Return type:
- firecrown.likelihood.factories.build_two_point_likelihood(build_parameters)[source]
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.
- Parameters:
build_parameters (firecrown.likelihood.likelihood.NamedParameters) – 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.
- Return type:
tuple[firecrown.likelihood.likelihood.Likelihood, firecrown.modeling_tools.ModelingTools]