firecrown.ccl_factory

This module contains the CCLFactory class and it supporting classes.

The CCLFactory class is a factory class that creates instances of the pyccl.Cosmology class.

Attributes

PowerSpec

Classes

Background

Type representing cosmological background quantities.

CCLCalculatorArgs

Arguments for the CCLCalculator.

PoweSpecAmplitudeParameter

This class defines the two-point correlation space.

CCLCreationMode

This class defines the CCL instance creation mode.

CCLPureModeTransferFunction

This class defines the transfer function to use in PURE_CCL_MODE.

MuSigmaModel

Model for the mu-sigma modified gravity model.

CAMBExtraParams

Extra parameters for CAMB.

CCLSplineParams

Params to control CCL spline interpolation.

CCLFactory

Factory class for creating instances of the pyccl.Cosmology class.

Module Contents

firecrown.ccl_factory.PowerSpec
class firecrown.ccl_factory.Background[source]

Bases: TypedDict

Inheritance diagram of firecrown.ccl_factory.Background

Type representing cosmological background quantities.

Contains arrays for scale factor, comoving distance, and Hubble parameter ratio.

a: numpy.typing.NDArray[numpy.float64]
chi: numpy.typing.NDArray[numpy.float64]
h_over_h0: numpy.typing.NDArray[numpy.float64]
class firecrown.ccl_factory.CCLCalculatorArgs[source]

Bases: TypedDict

Inheritance diagram of firecrown.ccl_factory.CCLCalculatorArgs

Arguments for the CCLCalculator.

Contains background cosmology and optional linear/nonlinear power spectra.

background: Background
pk_linear: NotRequired[PowerSpec]
pk_nonlin: NotRequired[PowerSpec]
class firecrown.ccl_factory.PoweSpecAmplitudeParameter[source]

Bases: firecrown.utils.YAMLSerializable, enum.StrEnum

Inheritance diagram of firecrown.ccl_factory.PoweSpecAmplitudeParameter

This class defines the two-point correlation space.

The two-point correlation space can be either real or harmonic. The real space corresponds measurements in terms of angular separation, while the harmonic space corresponds to measurements in terms of spherical harmonics decomposition.

AS
SIGMA8
classmethod __get_pydantic_core_schema__(_source_type, _handler)[source]

Get the Pydantic core schema for the PoweSpecAmplitudeParameter class.

Parameters:
  • _source_type (Any)

  • _handler (Any)

Return type:

pydantic_core.core_schema.CoreSchema

class firecrown.ccl_factory.CCLCreationMode[source]

Bases: enum.StrEnum

Inheritance diagram of firecrown.ccl_factory.CCLCreationMode

This class defines the CCL instance creation mode.

The DEFAULT mode represents the current CCL behavior. It will use CCL’s calculator mode if prepare is called with a CCLCalculatorArgs object. Otherwise, it will use the default CCL mode.

The MU_SIGMA_ISITGR mode enables the mu-sigma modified gravity model with the ISiTGR transfer function, it is not compatible with the Calculator mode.

The PURE_CCL_MODE mode will create a CCL instance with the default parameters. It is not compatible with the Calculator mode.

DEFAULT
MU_SIGMA_ISITGR
PURE_CCL_MODE
classmethod __get_pydantic_core_schema__(_source_type, _handler)[source]

Get the Pydantic core schema for the CCLCreationMode class.

Parameters:
  • _source_type (Any)

  • _handler (Any)

Return type:

pydantic_core.core_schema.CoreSchema

class firecrown.ccl_factory.CCLPureModeTransferFunction[source]

Bases: enum.StrEnum

Inheritance diagram of firecrown.ccl_factory.CCLPureModeTransferFunction

This class defines the transfer function to use in PURE_CCL_MODE.

The options are those available in CCL for the transfer_function argument. See https://ccl.readthedocs.io/en/latest/api/pyccl.cosmology.html

BBKS
BOLTZMANN_CAMB
BOLTZMANN_CLASS
EISENSTEIN_HU
EISENSTEIN_HU_NOWIGGLES
classmethod __get_pydantic_core_schema__(_source_type, _handler)[source]

Get the Pydantic core schema for the CCLPureModeTransferFunction class.

Parameters:
  • _source_type (Any)

  • _handler (Any)

Return type:

pydantic_core.core_schema.CoreSchema

class firecrown.ccl_factory.MuSigmaModel[source]

Bases: firecrown.updatable.Updatable

Inheritance diagram of firecrown.ccl_factory.MuSigmaModel

Model for the mu-sigma modified gravity model.

mu
sigma
c1
c2
lambda0
create()[source]

Create a pyccl.modified_gravity.MuSigmaMG object.

Return type:

pyccl.modified_gravity.MuSigmaMG

class firecrown.ccl_factory.CAMBExtraParams(/, **data)[source]

Bases: pydantic.BaseModel

Inheritance diagram of firecrown.ccl_factory.CAMBExtraParams

Extra parameters for CAMB.

Parameters:

data (Any)

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

HMCode_A_baryon: Annotated[float | None, Field(frozen=False)] = None
HMCode_eta_baryon: Annotated[float | None, Field(frozen=False)] = None
HMCode_logT_AGN: Annotated[float | None, Field(frozen=False)] = None
halofit_version: Annotated[str | None, Field(frozen=True)] = None
kmax: Annotated[float | None, Field(frozen=True)] = None
lmax: Annotated[int | None, Field(frozen=True)] = None
dark_energy_model: Annotated[str | None, Field(frozen=True)] = None
model_post_init(_, /)[source]

Validate that HMCode parameters are compatible with halofit_version.

get_dict()[source]

Return the extra parameters as a dictionary.

Return type:

dict

update(params)[source]

Update the CAMB sampling parameters.

Parameters:

params (firecrown.parameters.ParamsMap) – The parameters to update.

Returns:

None

Return type:

None

is_mead2020_feedback()[source]

Return True if the halofit_version is mead2020_feedback.

Return type:

bool

is_mead()[source]

Return True if the halofit_version is mead, mead2015, or mead2016.

CAMB treats None as mead.

Returns:

True if the halofit_version is mead, mead2015, or mead2016

Return type:

bool

class firecrown.ccl_factory.CCLSplineParams(/, **data)[source]

Bases: pydantic.BaseModel

Inheritance diagram of firecrown.ccl_factory.CCLSplineParams

Params to control CCL spline interpolation.

Parameters:

data (Any)

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

a_spline_na: Annotated[int | None, Field(frozen=True)] = None
a_spline_min: Annotated[float | None, Field(frozen=True)] = None
a_spline_minlog_pk: Annotated[float | None, Field(frozen=True)] = None
a_spline_min_pk: Annotated[float | None, Field(frozen=True)] = None
a_spline_minlog_sm: Annotated[float | None, Field(frozen=True)] = None
a_spline_min_sm: Annotated[float | None, Field(frozen=True)] = None
a_spline_minlog: Annotated[float | None, Field(frozen=True)] = None
a_spline_nlog: Annotated[int | None, Field(frozen=True)] = None
logm_spline_delta: Annotated[float | None, Field(frozen=True)] = None
logm_spline_nm: Annotated[int | None, Field(frozen=True)] = None
logm_spline_min: Annotated[float | None, Field(frozen=True)] = None
logm_spline_max: Annotated[float | None, Field(frozen=True)] = None
a_spline_na_sm: Annotated[int | None, Field(frozen=True)] = None
a_spline_nlog_sm: Annotated[int | None, Field(frozen=True)] = None
a_spline_na_pk: Annotated[int | None, Field(frozen=True)] = None
a_spline_nlog_pk: Annotated[int | None, Field(frozen=True)] = None
k_max_spline: Annotated[float | None, Field(frozen=True)] = None
k_max: Annotated[float | None, Field(frozen=True)] = None
k_min: Annotated[float | None, Field(frozen=True)] = None
dlogk_integration: Annotated[float | None, Field(frozen=True)] = None
dchi_integration: Annotated[float | None, Field(frozen=True)] = None
n_k: Annotated[int | None, Field(frozen=True)] = None
n_k_3dcor: Annotated[int | None, Field(frozen=True)] = None
ell_min_corr: Annotated[float | None, Field(frozen=True)] = None
ell_max_corr: Annotated[float | None, Field(frozen=True)] = None
n_ell_corr: Annotated[int | None, Field(frozen=True)] = None
check_spline_params()[source]

Check that the spline parameters are valid.

Return type:

CCLSplineParams

__enter__()[source]

Enter the context manager.

This method saves the current CCL global spline parameters, updates them with the values from this CCLSplineParams instance, and returns the instance itself. This allows for temporary modification of CCL spline parameters using a with statement.

Returns:

The current instance with updated spline parameters.

Return type:

CCLSplineParams

__exit__(exc_type, exc_value, traceback)[source]

Exit the context manager.

This method resets the CCL global spline parameters to their original values, as saved when entering the context manager. It ensures that any temporary modifications made to the CCL spline parameters within a with statement are reverted upon exit.

Parameters:
  • exc_type – The exception type, if an exception occurred.

  • exc_value – The exception value, if an exception occurred.

  • traceback – The traceback object, if an exception occurred.

class firecrown.ccl_factory.CCLFactory(**data)[source]

Bases: firecrown.updatable.Updatable, pydantic.BaseModel

Inheritance diagram of firecrown.ccl_factory.CCLFactory

Factory class for creating instances of the pyccl.Cosmology class.

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

require_nonlinear_pk: Annotated[bool, Field(frozen=True)] = False
amplitude_parameter: Annotated[PoweSpecAmplitudeParameter, Field(frozen=True)]
mass_split: Annotated[pyccl.neutrinos.NeutrinoMassSplits, BeforeValidator(_validate_neutrino_mass_splits), Field(frozen=True)]
num_neutrino_masses: Annotated[int | None, Field(frozen=True, ge=1)] = None
creation_mode: Annotated[CCLCreationMode, Field(frozen=True)]
pure_ccl_transfer_function: Annotated[CCLPureModeTransferFunction, Field(frozen=True)]
use_camb_hm_sampling: Annotated[bool, Field(frozen=True)] = False
allow_multiple_camb_instances: Annotated[bool, Field(frozen=True)] = False
camb_extra_params: Annotated[CAMBExtraParams | None, Field(frozen=True)] = None
ccl_spline_params: Annotated[CCLSplineParams | None, Field(frozen=True)] = None
Omega_c
Omega_b
h
n_s
Omega_k
Neff
m_nu: float | None
w0
wa
T_CMB
using_camb()[source]

Return True if the CCLFactory is using CAMB for the matter power spectrum.

Returns:

True if the CCLFactory is using CAMB for the matter power spectrum.

Return type:

bool

serialize_model(nxt, _)[source]

Serialize the CCLFactory object.

Parameters:
  • nxt (pydantic.SerializerFunctionWrapHandler)

  • _ (pydantic.SerializationInfo)

classmethod serialize_mass_split(value)[source]

Serialize the mass split parameter.

Parameters:

value (pyccl.neutrinos.NeutrinoMassSplits)

Return type:

str

model_post_init(_, /)[source]

Initialize the WeakLensingFactory object.

Return type:

None

create(calculator_args=None)[source]

Create a pyccl.Cosmology object.

Parameters:

calculator_args (CCLCalculatorArgs | None)

Return type:

pyccl.Cosmology

get()[source]

Return the pyccl.Cosmology object.

Return type:

pyccl.Cosmology