firecrown.likelihood.two_point

DEPRECATED: Use firecrown.likelihood instead.

This module provides backwards compatibility for code that imports from firecrown.likelihood.two_point. All functionality has been moved to firecrown.likelihood._two_point and is re-exported from firecrown.likelihood.

This module will be removed in a future version of Firecrown.

Classes

TwoPoint

A two-point statistic.

TwoPointFactory

Factory class for creating TwoPoint statistics from measurements.

Functions

calculate_angular_cl(ells, pk_name, scale0, scale1, ...)

Calculate the angular multipole moments.

read_ell_cells(theory, sacc_data)

Read and return ell and Cell.

read_reals(theory, sacc_data)

Read and return theta and xi.

use_source_factory(inferred_galaxy_zdist, measurement, ...)

Apply the factory to the inferred galaxy redshift distribution.

use_source_factory_metadata_index(sacc_tracer, ...)

Apply the factory to create a source using metadata only.

Module Contents

class firecrown.likelihood.two_point.TwoPoint(sacc_data_type, source0, source1, *, interp_ells_gen=gen.LogLinearElls(), ell_or_theta=None, tracers=None, int_options=None, apply_interp=ApplyInterpolationWhen.DEFAULT, normalize_window=True)

Bases: firecrown.likelihood._base.Statistic

Inheritance diagram of firecrown.likelihood.two_point.TwoPoint

A two-point statistic.

A two-point statistic represents the correlation between two measurements. If the same source is used twice, this produces an autocorrelation.

This class supports various two-point statistics including shear correlation functions, galaxy-shear correlation functions, and galaxy clustering statistics in both harmonic and real space.

The sacc_data_type parameter specifies the type of two-point statistic. Valid SACC data types map to CCL correlation function types or power spectra:

  • galaxy_density_cl: CCL angular power spectrum (cl)

  • galaxy_density_xi: CCL angular position correlation (gg)

  • galaxy_shearDensity_cl_e: CCL angular power spectrum (cl)

  • galaxy_shearDensity_xi_t: CCL position-shear cross-correlation (gl)

  • galaxy_shear_cl_ee: CCL angular power spectrum (cl)

  • galaxy_shear_xi_minus: CCL angular shear correlation xi-

  • galaxy_shear_xi_plus: CCL angular shear correlation xi+

  • cmbGalaxy_convergenceDensity_xi: CCL position correlation (gg)

  • cmbGalaxy_convergenceShear_xi_t: CCL position-shear cross-correlation (gl)

The ell_or_theta parameter allows generating ell or theta values for computing statistics when the corresponding data is not present in the SACC file. It accepts a dictionary with keys: minimum (float), maximum (float), n (int), and binning (str, ‘log’ or ‘lin’).

The ell_for_xi parameter configures ell values for computing power spectra used in real-space integrations. It accepts a dictionary with keys: minimum (int, default 2), midpoint (int, default 50), maximum (int, default 60000), and n_log (int, default 200).

Variables:
  • ccl_kind – The CCL correlation function kind or ‘cl’ for power spectra.

  • sacc_tracers – The SACC tracer names for this statistic, set after read.

Parameters:
property sacc_data_type: str

Backwards compatibility for sacc_data_type.

Return type:

str

property source0: firecrown.likelihood._base.Source

Backwards compatibility for source0.

Return type:

firecrown.likelihood._base.Source

property source1: firecrown.likelihood._base.Source

Backwards compatibility for source1.

Return type:

firecrown.likelihood._base.Source

property window: None | numpy.typing.NDArray[numpy.float64]

Backwards compatibility for window.

Return type:

None | numpy.typing.NDArray[numpy.float64]

property sacc_tracers: None | firecrown.metadata_types.TracerNames

Backwards compatibility for sacc_tracers.

Return type:

None | firecrown.metadata_types.TracerNames

property ells: None | numpy.typing.NDArray[numpy.int64]

Backwards compatibility for ells.

Return type:

None | numpy.typing.NDArray[numpy.int64]

property thetas: None | numpy.typing.NDArray[numpy.float64]

Backwards compatibility for thetas.

Return type:

None | numpy.typing.NDArray[numpy.float64]

property ells_for_xi: None | numpy.typing.NDArray[numpy.int64]

Backwards compatibility for ells_for_xi.

Return type:

None | numpy.typing.NDArray[numpy.int64]

property cells

Backwards compatibility for cells.

theory
normalize_window = True
classmethod from_metadata_index(metadata_indices, tp_factory)

Create an UpdatableCollection of TwoPoint statistics.

This constructor creates an UpdatableCollection of TwoPoint statistics from a list of TwoPointCellsIndex or TwoPointXiThetaIndex metadata index objects. The purpose of this constructor is to create a TwoPoint statistic from metadata index, which requires a follow-up call to read to read the data and metadata from the SACC object.

Parameters:
Returns:

An UpdatableCollection of TwoPoint statistics.

Return type:

firecrown.updatable.UpdatableCollection[TwoPoint]

classmethod from_metadata(metadata_seq, tp_factory)

Create an UpdatableCollection of TwoPoint statistics from metadata.

This constructor creates an UpdatableCollection of TwoPoint statistics from a list of TwoPointHarmonic or TwoPointReal metadata objects. The metadata objects are used to initialize the TwoPoint statistics. The sources are initialized using the factories provided.

Note that TwoPoint created with this constructor are ready to be used, but contain no data.

Parameters:
Returns:

An UpdatableCollection of TwoPoint statistics.

Return type:

firecrown.updatable.UpdatableCollection[TwoPoint]

classmethod create_two_point(measurement, tp_factory)

Create a single TwoPoint statistic from a measurement.

Parameters:
Return type:

TwoPoint

classmethod from_measurement(measurements, tp_factory)

Create an UpdatableCollection of TwoPoint statistics from measurements.

This constructor creates an UpdatableCollection of TwoPoint statistics from a list of TwoPointMeasurement objects. The measurements are used to initialize the TwoPoint statistics. The sources are initialized using the factories provided.

Note that TwoPoint created with this constructor are ready to be used and contain data.

Parameters:
  • measurements (collections.abc.Sequence[firecrown.data_types.TwoPointMeasurement]) – The measurements objects to initialize the TwoPoint statistics.

  • wl_factory – The weak lensing factory to use.

  • nc_factory – The number counts factory to use.

  • tp_factory (TwoPointFactory)

Returns:

An UpdatableCollection of TwoPoint statistics.

Return type:

firecrown.updatable.UpdatableCollection[TwoPoint]

read(sacc_data)

Read the data for this statistic from the SACC file.

Parameters:

sacc_data (sacc.Sacc) – The data in the sacc format.

Return type:

None

read_real_space(sacc_data)

Read the data for this statistic from the SACC file.

Parameters:

sacc_data (sacc.Sacc)

read_harmonic_space(sacc_data)

Read the data for this statistic from the SACC file.

Parameters:

sacc_data (sacc.Sacc)

Return type:

None

read_harmonic_spectrum_data(ells_cells_indices, sacc_data)

Read all the data for this statistic from the SACC file.

Parameters:
  • ells_cells_indices (None | tuple[numpy.typing.NDArray[numpy.int64], numpy.typing.NDArray[numpy.float64], numpy.typing.NDArray[numpy.int64]]) – The ells, the cells and the indices of the data in the SACC file.

  • sacc_data (sacc.Sacc) – The data in the sacc format.

Returns:

The ells, the cells and the indices, and window function if there is one.

Return type:

tuple[numpy.typing.NDArray[numpy.float64], numpy.typing.NDArray[numpy.int64], numpy.typing.NDArray[numpy.int64] | None, numpy.typing.NDArray[numpy.float64] | None]

get_data_vector()

Return this statistic’s data vector.

Return type:

firecrown.data_types.DataVector

set_data_vector(value)

Set this statistic’s data vector.

Parameters:

value (firecrown.data_types.DataVector)

Return type:

None

compute_theory_vector_real_space(tools)

Compute a two-point statistic in real space.

This method computes the two-point statistic in real space. It first computes the Cl’s in harmonic space and then translates them to real space using CCL.

Parameters:

tools (firecrown.modeling_tools.ModelingTools)

Return type:

firecrown.data_types.TheoryVector

compute_theory_vector_harmonic_space(tools)

Compute a two-point statistic in harmonic space.

This method computes the two-point statistic in harmonic space. It computes either the Cl’s at the ells provided by the SACC file or the ells required for the window function.

Parameters:

tools (firecrown.modeling_tools.ModelingTools)

Return type:

firecrown.data_types.TheoryVector

compute_cells(ells, scale0, scale1, tools, tracers0, tracers1, interpolate=False)

Compute the power spectrum for the given ells and tracers.

This method computes the power spectrum for the given ells and tracers. If interpolate is True, it will interpolate the power spectrum to the ells provided.

Parameters:
  • ells (numpy.typing.NDArray[numpy.int64])

  • scale0 (float)

  • scale1 (float)

  • tools (firecrown.modeling_tools.ModelingTools)

  • tracers0 (collections.abc.Sequence[firecrown.likelihood._base.Tracer])

  • tracers1 (collections.abc.Sequence[firecrown.likelihood._base.Tracer])

  • interpolate (bool)

Return type:

numpy.typing.NDArray[numpy.float64]

class firecrown.likelihood.two_point.TwoPointFactory(/, **data)

Bases: pydantic.BaseModel

Inheritance diagram of firecrown.likelihood.two_point.TwoPointFactory

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:
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:

firecrown.updatable.UpdatableCollection[TwoPoint]

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:

firecrown.updatable.UpdatableCollection[TwoPoint]

firecrown.likelihood.two_point.calculate_angular_cl(ells, pk_name, scale0, scale1, tools, tracer0, tracer1, int_options=None)

Calculate the angular multipole moments.

Parameters:
  • ells (numpy.typing.NDArray[numpy.int64]) – The angular wavenumbers at which to compute the power spectrum.

  • pk_name (str) – The name of the power spectrum to return.

  • scale0 (float) – The scale factor for the first tracer.

  • scale1 (float) – The scale factor for the second tracer.

  • tools (firecrown.modeling_tools.ModelingTools) – The modeling tools to use.

  • tracer0 (firecrown.likelihood._base.Tracer) – The first tracer to use.

  • tracer1 (firecrown.likelihood._base.Tracer) – The second tracer to use.

  • int_options (firecrown.utils.ClIntegrationOptions | None)

Returns:

The angular multipole moments.

firecrown.likelihood.two_point.read_ell_cells(theory, sacc_data)

Read and return ell and Cell.

Parameters:
Returns:

The ell and Cell values.

Return type:

None | tuple[numpy.typing.NDArray[numpy.int64], numpy.typing.NDArray[numpy.float64], numpy.typing.NDArray[numpy.int64]]

firecrown.likelihood.two_point.read_reals(theory, sacc_data)

Read and return theta and xi.

Parameters:
Returns:

The theta and xi values.

Return type:

None | tuple[numpy.typing.NDArray[numpy.float64], numpy.typing.NDArray[numpy.float64], numpy.typing.NDArray[numpy.int64]]

firecrown.likelihood.two_point.use_source_factory(inferred_galaxy_zdist, measurement, tp_factory)

Apply the factory to the inferred galaxy redshift distribution.

Parameters:
Return type:

firecrown.likelihood._weak_lensing.WeakLensing | firecrown.likelihood.number_counts.NumberCounts | firecrown.likelihood._cmb.CMBConvergence

firecrown.likelihood.two_point.use_source_factory_metadata_index(sacc_tracer, measurement, tp_factory)

Apply the factory to create a source using metadata only.

This method is used when the galaxy redshift distribution is not available. It defaults to using the factory associated with the default TypeSource, since SACC does not encode TypeSource information.

Parameters:
  • sacc_tracer (str)

  • measurement (firecrown.metadata_types.Measurement)

  • tp_factory (TwoPointFactory)

Return type:

firecrown.likelihood._weak_lensing.WeakLensing | firecrown.likelihood.number_counts.NumberCounts | firecrown.likelihood._cmb.CMBConvergence