firecrown.likelihood.two_point

Two point statistic support.

Classes

TwoPoint

A two-point statistic.

TwoPointFactory

Factory class for WeakLensing objects.

Functions

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

Calculate the angular multipole moments.

read_reals(theory, sacc_data)

Read and return theta and xi.

read_ell_cells(theory, sacc_data)

Read and return ell and Cell.

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

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

Calculate the angular multipole moments.

Parameters:
Returns:

The angular multipole moments.

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)[source]

Bases: firecrown.likelihood.statistic.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[source]

Backwards compatibility for sacc_data_type.

Return type:

str

property source0: firecrown.likelihood.source.Source[source]

Backwards compatibility for source0.

Return type:

firecrown.likelihood.source.Source

property source1: firecrown.likelihood.source.Source[source]

Backwards compatibility for source1.

Return type:

firecrown.likelihood.source.Source

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

Backwards compatibility for window.

Return type:

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

property sacc_tracers: None | firecrown.metadata_types.TracerNames[source]

Backwards compatibility for sacc_tracers.

Return type:

None | firecrown.metadata_types.TracerNames

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

Backwards compatibility for ells.

Return type:

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

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

Backwards compatibility for thetas.

Return type:

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

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

Backwards compatibility for ells_for_xi.

Return type:

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

property cells[source]

Backwards compatibility for cells.

theory
classmethod from_metadata_index(metadata_indices, tp_factory)[source]

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)[source]

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)[source]

Create a single TwoPoint statistic from a measurement.

Parameters:
Return type:

TwoPoint

classmethod from_measurement(measurements, tp_factory)[source]

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)[source]

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)[source]

Read the data for this statistic from the SACC file.

Parameters:

sacc_data (sacc.Sacc)

read_harmonic_space(sacc_data)[source]

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)[source]

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()[source]

Return this statistic’s data vector.

Return type:

firecrown.data_types.DataVector

set_data_vector(value)[source]

Set this statistic’s data vector.

Parameters:

value (firecrown.data_types.DataVector)

Return type:

None

compute_theory_vector_real_space(tools)[source]

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)[source]

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)[source]

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

numpy.typing.NDArray[numpy.float64]

firecrown.likelihood.two_point.read_reals(theory, sacc_data)[source]

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.read_ell_cells(theory, sacc_data)[source]

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

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

Bases: pydantic.BaseModel

Inheritance diagram of firecrown.likelihood.two_point.TwoPointFactory

Factory class for WeakLensing objects.

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(_, /)[source]

Initialize the WeakLensingFactory object.

Return type:

None

get_factory(measurement, type_source=TypeSource.DEFAULT)[source]

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)[source]

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)[source]

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.use_source_factory(inferred_galaxy_zdist, measurement, tp_factory)[source]

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)[source]

Apply the factory to create a source using metadata only.

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