API Reference
Pipeline stages
- class clpipe.clp_covariance.CLPCovariance(*args, **kwargs)[source]
Bases:
PipelineStageTJPCov pipeline stage for covariance computation.
This stage: - Reads an input SACC file (data vector) - Reads the fiducial cosmology (shared with TXPipe) - Computes covariance terms using TJPCov - Optionally merges in non-cluster covariance blocks from the input file - Optionally replaces cluster-count covariance using CROW - Writes a single output SACC file with the final covariance
Key configuration groups: - Covariance selection (cov_type) - Mass–observable relation (mor_parameters) - Pipeline behavior (replace_tjpcov_cov)
- run()[source]
Main execution:
Load input SACC file and fiducial cosmology
Compute covariance via TJPCov
Merge with existing non-cluster covariance blocks (if needed)
Optionally replace cluster-count covariance
Save the final result exactly once
- extract_and_save_cluster_counts(input_sacc_file, output_sacc_file)[source]
Reads a SACC file, extracts only the cluster counts data (without covariance), and saves it to a new SACC file.
- Parameters:
input_sacc_file (
str) – Path to the input SACC file containing full data.output_sacc_file (
str) – Path where the new SACC file with only cluster counts will be saved.
- merge_data_covariance(sacc_obj, full_cov, diagonal_only=True)[source]
Copy non-cluster-count covariance blocks from the original input SACC file’s covariance into the newly computed full covariance.
TJPCov only computes cluster-related covariance terms in this pipeline (cov_type is restricted to Cluster* classes), so any other data type (e.g. cluster_delta_sigma) that was already present with a covariance in the input file needs to be preserved here rather than left at TJPCov’s placeholder value.
- Parameters:
sacc_obj (sacc.Sacc) – The original input SACC file, still carrying its original covariance matrix.
full_cov (np.ndarray) – The newly computed full covariance array to merge non-cluster blocks into (modified in place and returned).
diagonal_only (bool) – If True, only copy the diagonal (per-point variance) for each non-cluster-count data type, dropping any off-diagonal correlation between data points of that type.
- Returns:
full_cov with non-cluster-count blocks copied over from sacc_obj, either diagonal-only or full dense blocks depending on diagonal_only.
- Return type:
np.ndarray
- replace_crow_counts(config_dict, sacc_full, cov_terms, full_cov, cosmo)[source]
Replace TJPCov cluster-count covariance using CROW predictions.
This is a temporary workaround.
Steps: - Construct mass–observable relation (mor_parameters) - Compute theoretical counts - Replace covariance elements using SSC scaling
WARNING: - Hardcoded modeling choices (mass function, grids) - Should eventually be implemented inside TJPCov
- Parameters:
config_dict (dict) – Stage configuration.
sacc_full (sacc.Sacc) – SACC object with tracers/data points for the full covariance (used to look up tracer metadata).
cov_terms (dict) – {‘gauss’: array, ‘SSC’: array} raw covariance term arrays from TJPCov.
full_cov (np.ndarray) – Full covariance array to modify in place.
cosmo (pyccl.Cosmology) – fiducial cosmology, the same object used for TJPCov’s own covariance computation in run().
- Returns:
full_cov with cluster-count blocks replaced.
- Return type:
np.ndarray
- class clpipe.clp_firecrown.CLPFirecrown(*args, **kwargs)[source]
Bases:
PipelineStageFirecrown pipeline stage for cluster cosmology analysis.
This stage:
Builds a Firecrown likelihood from a SACC file
Generates the corresponding CosmoSIS configuration
Writes parameter files for sampling, defaulting the cosmological block to the fiducial cosmology (shared with TXPipe/TJPCov); any entry in cosmological_parameters overrides that default, which is how a parameter gets sampled instead of held fixed
Key configuration groups:
Modeling options (hmf, mass range, redshift range)
Observable selection (cluster counts, shear)
Systematics (purity, completeness)
Sampling configuration (emcee, polychord)
Full configuration documentation: See docs/clp_firecrown.txt
- run()[source]
Run the analysis for this stage. Generates Firecrown likelihood and cosmosis ini files.
- generate_python_file(path_name)[source]
Generates a Python file based on the configuration dictionary.
- Parameters:
path_name (str) – Path to save the generated Python file.
- generate_ini_file(output_ini_path, likelihood_source_name, values_file_name)[source]
Generates an .ini file.
- Parameters:
output_ini_path (str) – Path where the generated .ini file will be saved.
likelihood_source_name (str) – Basename of the generated Firecrown likelihood Python file (the likelihood_file output), written alongside output_ini_path.
values_file_name (str) – Basename of the generated CosmoSIS values file (the priors_file output), written alongside output_ini_path.
File types
CLPipe-specific file types, subclassing base types from ceci. SACCFile and FiducialCosmology adapted from LSSTDESC/TXPipe (file_types.py). CosmosisFile and PythonFile are CLPipe additions, not present in core ceci.
- class clpipe.file_types.CosmosisFile(*args, **kwargs)[source]
Bases:
DataFileA CosmoSIS .ini file. Not present in core ceci.
Cluster theory predictions
- clpipe.cluster_theory_pred.build_cluster_recipes_from_config(yml_file, sacc_file, set_params, **kwargs)[source]
Build cluster counts and (optionally) shear recipes from a YAML configuration and return theory/data vectors.
This function:
Loads configuration from yml_file (supports a top-level CLPFirecrown key).
Builds a pyccl halo mass function and pyccl Cosmology (via build_ccl_cosmology_from_config).
Constructs completeness/purity models if requested.
Configures a mass-proxy model and fills its parameters from the firecrown_parameters block or from runtime set_params.
Builds either GridBinnedClusterRecipe or ExactBinnedClusterRecipe for counts and (optionally) for shear.
Reads the SACC file and returns theory predictions and data vectors.
- Parameters:
yml_file (
str) – Path to the YAML configuration.sacc_file (
str) – Path to the SACC file used for data vectors.set_params (
Dict[str,Any]) – Dictionary with runtime-supplied sampled parameters (e.g. from Firecrown/Cosmosis).**kwargs – Currently unused; accepted for forward compatibility.
- Returns:
(cluster_counts_theory, cluster_counts_data, cluster_shear_profile_theory, cluster_shear_data) cluster_shear_profile_theory and cluster_shear_data can be None if shear is not requested.
- Return type:
Tuple[ndarray,ndarray,Optional[ndarray],Optional[ndarray]]
- clpipe.cluster_theory_pred.build_ccl_cosmology_from_config(yml_config, set_params=None)[source]
Build a pyccl.Cosmology using config values + runtime sampled parameters.
The configuration is expected to contain a “cosmological_parameters” block where each parameter is either marked as sampled (sample: true) in which case the value must be present in set_params, or fixed with a numeric “values” entry.
- Parameters:
yml_config (
Dict[str,Any]) – Configuration dictionary (the CLPFirecrown section).set_params (
Optional[Dict[str,Any]]) – Runtime-supplied sampled parameters (may be None).
- Return type:
Cosmology