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. |
|
Factory class for creating TwoPoint statistics from measurements. |
Functions
|
Load SACC data from a file, auto-detecting the format. |
|
Build a likelihood object for two-point statistics from a SACC file. |
Package Contents
- firecrown.likelihood.factories.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.
- 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)
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
- normalize_window: bool = True
- set_path(path)
Set the path for the data source.
- Parameters:
path (pathlib.Path)
- Return type:
None
- get_filepath()
Return the filename of the data source.
Raises a FileNotFoundError if the file does not exist. :return: The filename
- Return type:
pathlib.Path
- get_sacc_data()
Load the SACC data file.
Uses automatic format detection to load both HDF5 and FITS files.
- Return type:
sacc.Sacc
- class firecrown.likelihood.factories.TwoPointExperiment(/, **data)
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.modeling_tools.CCLFactory | None = None
- model_post_init(_, /)
Initialize the TwoPointExperiment object.
- Return type:
None
- classmethod load_from_yaml(file)
Load a TwoPointExperiment object from a YAML file.
- Parameters:
file (str | pathlib.Path)
- Return type:
- make_likelihood()
Create a likelihood object for two-point statistics from a SACC file.
- Return type:
firecrown.likelihood._base.Likelihood
- firecrown.likelihood.factories.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.
- Parameters:
build_parameters (firecrown.likelihood._base.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._base.Likelihood, firecrown.modeling_tools.ModelingTools]
- class firecrown.likelihood.factories.TwoPointFactory(/, **data)
Bases:
pydantic.BaseModel
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.
- Parameters:
data (Any)
- model_config
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- correlation_space: Annotated[firecrown.metadata_types.TwoPointCorrelationSpace, BeforeValidator(make_correlation_space), Field(description='The two-point correlation space.')]
- weak_lensing_factories: list[firecrown.likelihood._weak_lensing.WeakLensingFactory] = None
- number_counts_factories: list[firecrown.likelihood.number_counts.NumberCountsFactory] = None
- cmb_factories: list[firecrown.likelihood._cmb.CMBConvergenceFactory] = None
- int_options: firecrown.utils.ClIntegrationOptions | None = None
- model_post_init(_, /)
Initialize the WeakLensingFactory object.
- Return type:
None
- get_factory(measurement, type_source=TypeSource.DEFAULT)
Get the Factory for the given Measurement and TypeSource.
- Parameters:
measurement (firecrown.metadata_types.Measurement)
type_source (firecrown.metadata_types.TypeSource)
- Return type:
firecrown.likelihood._weak_lensing.WeakLensingFactory | firecrown.likelihood.number_counts.NumberCountsFactory | firecrown.likelihood._cmb.CMBConvergenceFactory
- from_measurement(tpms)
Create a TwoPoint object from a list of TwoPointMeasurement.
- Parameters:
tpms (list[firecrown.data_types.TwoPointMeasurement])
- Return type:
- from_metadata(metadata_seq)
Create a TwoPoint object from a list of TwoPointHarmonic or TwoPointReal.
- Parameters:
metadata_seq (list[firecrown.metadata_types.TwoPointHarmonic | firecrown.metadata_types.TwoPointReal])
- Return type: