firecrown.likelihood.two_point
Two point statistic support.
Classes
A two-point statistic. |
|
Factory class for WeakLensing objects. |
Functions
|
Calculate the angular multipole moments. |
|
Read and return theta and xi. |
|
Read and return ell and Cell. |
|
Apply the factory to the inferred galaxy redshift distribution. |
|
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:
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.source.Tracer) – The first tracer to use.
tracer1 (firecrown.likelihood.source.Tracer) – The second tracer to use.
int_options (firecrown.utils.ClIntegrationOptions | None)
- 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
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:
sacc_data_type (str)
source0 (firecrown.likelihood.source.Source)
source1 (firecrown.likelihood.source.Source)
interp_ells_gen (firecrown.generators.two_point.LogLinearElls)
ell_or_theta (None | firecrown.generators.two_point.EllOrThetaConfig)
tracers (None | firecrown.metadata_types.TracerNames)
int_options (firecrown.utils.ClIntegrationOptions | None)
apply_interp (firecrown.models.two_point.ApplyInterpolationWhen)
- property source0: firecrown.likelihood.source.Source[source]
Backwards compatibility for source0.
- Return type:
- property source1: firecrown.likelihood.source.Source[source]
Backwards compatibility for source1.
- Return type:
- 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:
- 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]
- 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:
metadata_index – The metadata index objects to initialize the TwoPoint statistics.
tp_factory (TwoPointFactory) – The TwoPointFactory to use.
metadata_indices (collections.abc.Sequence[firecrown.metadata_functions.TwoPointHarmonicIndex | firecrown.metadata_functions.TwoPointRealIndex])
- Returns:
An UpdatableCollection of TwoPoint statistics.
- Return type:
- 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:
metadata_seq (collections.abc.Sequence[firecrown.metadata_types.TwoPointHarmonic | firecrown.metadata_types.TwoPointReal]) – The metadata 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:
- classmethod create_two_point(measurement, tp_factory)[source]
Create a single TwoPoint statistic from a measurement.
- Parameters:
measurement (firecrown.data_types.TwoPointMeasurement) – The measurement object to initialize the TwoPoint statistic.
tp_factory (TwoPointFactory)
- Return type:
- 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:
- 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]
- 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:
- Return type:
- 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:
- Return type:
- 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:
ells (numpy.typing.NDArray[numpy.int64])
scale0 (float)
scale1 (float)
tracers0 (collections.abc.Sequence[firecrown.likelihood.source.Tracer])
tracers1 (collections.abc.Sequence[firecrown.likelihood.source.Tracer])
interpolate (bool)
- Return type:
numpy.typing.NDArray[numpy.float64]
- firecrown.likelihood.two_point.read_reals(theory, sacc_data)[source]
Read and return theta and xi.
- Parameters:
theory (firecrown.models.two_point.TwoPointTheory) – The theory, carrying data type and tracers.
sacc_data (sacc.Sacc) – The SACC data object to be read.
- 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:
theory (firecrown.models.two_point.TwoPointTheory) – The theory, carrying data type and tracers.
sacc_data (sacc.Sacc) – The SACC data object to be read.
- 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
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
- get_factory(measurement, type_source=TypeSource.DEFAULT)[source]
Get the Factory for the given Measurement and TypeSource.
- Parameters:
measurement (firecrown.metadata_types.Measurement)
type_source (firecrown.metadata_types.TypeSource)
- 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:
- 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.likelihood.two_point.use_source_factory(inferred_galaxy_zdist, measurement, tp_factory)[source]
Apply the factory to the inferred galaxy redshift distribution.
- Parameters:
inferred_galaxy_zdist (firecrown.metadata_types.InferredGalaxyZDist)
measurement (firecrown.metadata_types.Measurement)
tp_factory (TwoPointFactory)
- 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