pybird.correlator module

class pybird.correlator.Correlator(config_dict=None, load_engines=True)[source]

Bases: object

A class for computing cosmological correlation functions.

The Correlator class provides functionality to compute various cosmological correlation functions, including power spectra and correlation functions for biased tracers and matter. It implements Effective Field Theory (EFT) of Large Scale Structure calculations with various options for bias models, IR resummation, AP effect, and other corrections.

cosmo_catalog

Catalog of cosmological parameters options.

Type:

dict

c_catalog

Catalog of configuration options.

Type:

dict

cosmo

Current cosmological parameters.

Type:

dict

c

Current configuration parameters.

Type:

dict

bias

Current bias parameters.

Type:

dict

bird

Main computational object containing results.

Type:

Bird

co

Common parameters and utilities.

Type:

Common

nonlinear

Engine for nonlinear calculations.

Type:

NonLinear

resum

Engine for IR resummation.

Type:

Resum

projection

Engine for projections and coordinate transformations.

Type:

Projection

matching

Engine for IR/UV matching if needed.

Type:

Matching

emulator

Emulator for faster calculations if enabled.

Type:

Emulator

info()[source]

Display information about available configuration and cosmology parameters.

set()[source]

Set configuration parameters and initialize engines.

compute()[source]

Compute cosmological correlations based on provided parameters.

get()[source]

Get the computed power spectrum or correlation function.

getmarg()[source]

Get marginalized EFT parameters.

load_engines()[source]

Load and initialize computational engines.

Private Methods:

__read_cosmo(): Read and validate cosmological parameters. __is_cosmo_conflict(): Check for conflicts in cosmological parameters. __is_bias_conflict(): Check for conflicts in bias parameters. __set_eft_parameters_list(): Set lists of required EFT parameters. __read_config(): Read and validate configuration parameters. __is_config_conflict(): Check for conflicts in configuration parameters.

info(description=True)[source]

Display information about available configuration and cosmology parameters.

Parameters:

description (bool, optional) – Whether to include parameter descriptions and defaults, by default True

Notes

This method prints two catalogs: - Configuration commands: parameters for .set(config_dict) - Cosmology commands: parameters for .compute(cosmo_dict)

set(config_dict, load_engines=True)[source]

Set configuration parameters and initialize engines.

Parameters:
  • config_dict (dict) – Dictionary containing configuration parameters

  • load_engines (bool, optional) – Whether to load and initialize computational engines, by default True

Notes

This method: 1. Reads and validates the provided configuration 2. Sets default values for optional parameters 3. Checks for configuration conflicts 4. Loads PyBird computational engines if requested

compute(cosmo_dict=None, cosmo_module=None, cosmo_engine=None, do_core=True, do_survey_specific=True)[source]

Compute cosmological correlations based on provided parameters.

Parameters:
  • cosmo_dict (dict, optional) – Dictionary of cosmological parameters for PyBird inputs

  • cosmo_module (str, optional) – Name of Boltzmann solver to call internally (e.g., ‘classy’, ‘camb’)

  • cosmo_engine (object, optional) – External Boltzmann solver engine object

  • do_core (bool, optional) – Whether to perform core EFT calculations, by default True

  • do_survey_specific (bool, optional) – Whether to apply survey-specific effects, by default True

Notes

You must provide either: - cosmo_dict with PyBird parameters, or - cosmo_dict with cosmological parameters + cosmo_module, or - cosmo_module + cosmo_engine for external Boltzmann solver

The method handles cosmological parameter processing, validates inputs, and performs the main EFT calculations for power spectra or correlation functions.

get(bias=None, what='full')[source]

Get the computed power spectrum or correlation function.

Parameters:
  • bias (dict, optional) – Bias parameters dictionary. If None, uses the bias set during compute()

  • what (str, optional) – Which components to return (‘full’, ‘linear’, ‘loop’, etc.), by default “full”

Returns:

Computed power spectrum (if output=’Pk’) or correlation function (if output=’Cf’) Shape depends on configuration (multipoles, redshift bins, etc.)

Return type:

ndarray

getmarg(bias, marg_gauss_eft_parameters_list)[source]

Get marginalized EFT parameters.

Parameters:
  • bias (dict) – Bias parameters dictionary

  • marg_gauss_eft_parameters_list (list) – List of EFT parameter names to marginalize over using Gaussian priors

Notes

This method implements analytical marginalization over nuisance EFT parameters assuming Gaussian priors. Common parameters to marginalize include stochastic terms like ‘ce0’, ‘ce1’, ‘ce2’ and higher-order bias terms.

load_engines(load_engines=True)[source]

Load and initialize computational engines.

Parameters:

load_engines (bool, optional) – Whether to actually load the engines, by default True

Notes

This method initializes all the computational engines needed for PyBird: - Common: shared parameters and utilities - NonLinear: one-loop calculations - Resum: IR resummation - Projection: multipole projections and survey effects - Matching: UV/IR matching (if needed) - Emulator: neural network emulator (if enabled)

class pybird.correlator.BiasCorrelator(config_dict=None, load_engines=False)[source]

Bases: Correlator

A class for loading pre-computed correlations.

BiasCorrelator extends the Correlator class to work with pre-computed correlation functions. It initializes with load_engines=False by default since computational engines are typically not needed for pre-computed results.

Inherits all attributes from Correlator.
Inherits all methods from Correlator.
pybird.correlator.translate_catalog_to_dict(catalog)[source]
pybird.correlator.typename(onetype)[source]
class pybird.correlator.Option(config_name, config_type, config_list=None, description='', default=None, verbose=False)[source]

Bases: object

A class for handling configuration options with validation.

The Option class represents a single configuration parameter with its allowed types, values, description, and default value. It provides methods for validating user-provided values.

name

Name of the configuration option.

Type:

str

type

Allowed type(s) for this option.

Type:

type or tuple

list

List of allowed values if restricted, None otherwise.

Type:

list

description

Description of the option.

Type:

str

default

Default value for the option.

Type:

any

value

Current value of the option.

Type:

any

verbose

Whether to print verbose information.

Type:

bool

check()[source]

Check if a provided value is valid for this option.

error()[source]

Raise an appropriate error for an invalid configuration value.

check(config_key, config_value)[source]
error(config_value)[source]