firecrown.likelihood.two_point
Two point statistic support.
Classes
A statistic that represents the correlation between two measurements. |
Functions
|
Calculate the angular mulitpole moments. |
|
Read and return theta and xi. |
|
Read and return ell and Cell. |
Module Contents
- firecrown.likelihood.two_point.calculate_angular_cl(ells, pk_name, scale0, scale1, tools, tracer0, tracer1)[source]
Calculate the angular mulitpole 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.
- Returns:
The angular mulitpole moments.
- class firecrown.likelihood.two_point.TwoPoint(sacc_data_type, source0, source1, *, ell_for_xi=None, ell_or_theta=None, ell_or_theta_min=None, ell_or_theta_max=None, tracers=None)[source]
Bases:
firecrown.likelihood.statistic.Statistic
A statistic that represents the correlation between two measurements.
If the same source is used twice in the same TwoPoint object, this produces an autocorrelation.
For example, shear correlation function, galaxy-shear correlation function, etc.
Parameters
- sacc_data_typestr
The kind of two-point statistic. This must be a valid SACC data type that maps to one of the CCL correlation function kinds or a power spectra. Possible options are
galaxy_density_cl : maps to ‘cl’ (a CCL angular power spectrum)
galaxy_density_xi : maps to ‘gg’ (a CCL angular position corr. function)
galaxy_shearDensity_cl_e : maps to ‘cl’ (a CCL angular power spectrum)
galaxy_shearDensity_xi_t : maps to ‘gl’ (a CCL angular cross-correlation between position and shear)
galaxy_shear_cl_ee : maps to ‘cl’ (a CCL angular power spectrum)
galaxy_shear_xi_minus : maps to ‘l-’ (a CCL angular shear corr. function xi-)
galaxy_shear_xi_plus : maps to ‘l+’ (a CCL angular shear corr. function xi-)
cmbGalaxy_convergenceDensity_xi : maps to ‘gg’ (a CCL angular position corr. function)
cmbGalaxy_convergenceShear_xi_t : maps to ‘gl’ (a CCL angular cross- correlation between position and shear)
- source0Source
The first sources needed to compute this statistic.
- source1Source
The second sources needed to compute this statistic.
- ell_or_thetadict, optional
A dictionary of options for generating the ell or theta values at which to compute the statistics. This option can be used to have firecrown generate data without the corresponding 2pt data in the input SACC file. The options are:
minimun : float - The start of the binning.
maximun : float - The end of the binning.
n : int - The number of bins. Note that the edges of the bins start at min and end at max. The actual bin locations will be at the (possibly geometric) midpoint of the bin.
binning : str, optional - Pass ‘log’ to get logarithmic spaced bins and ‘lin’ to get linearly spaced bins. Default is ‘log’.
- ell_or_theta_minfloat, optional
The minimum ell or theta value to keep. This minimum is applied after the ell or theta values are read and/or generated.
- ell_or_theta_maxfloat, optional
The maximum ell or theta value to keep. This maximum is applied after the ell or theta values are read and/or generated.
- ell_for_xidict, optional
A dictionary of options for making the ell values at which to compute Cls for use in real-space integrations. The possible keys are:
minimum : int, optional - The minimum angular wavenumber to use for real-space integrations. Default is 2.
midpoint : int, optional - The midpoint angular wavenumber to use for real-space integrations. The angular wavenumber samples are linearly spaced at integers between minimum and midpoint. Default is 50.
maximum : int, optional - The maximum angular wavenumber to use for real-space integrations. The angular wavenumber samples are logarithmically spaced between midpoint and maximum. Default is 60,000.
n_log : int, optional - The number of logarithmically spaced angular wavenumber samples between mid and max. Default is 200.
Attributes
- ccl_kindstr
The CCL correlation function kind or ‘cl’ for power spectra corresponding to the SACC data type.
- sacc_tracers2-tuple of str
A tuple of the SACC tracer names for this 2pt statistic. Set after a call to read.
- property sacc_data_type: str
Backwards compatibility for sacc_data_type.
- Return type:
str
- property source0: firecrown.likelihood.source.Source
Backwards compatibility for source0.
- Return type:
- property source1: firecrown.likelihood.source.Source
Backwards compatibility for source1.
- Return type:
- 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:
- 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
- classmethod from_metadata_index(metadata_indices, wl_factory=None, nc_factory=None)[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.
wl_factory (firecrown.likelihood.weak_lensing.WeakLensingFactory | None) – The weak lensing factory to use.
nc_factory (firecrown.likelihood.number_counts.NumberCountsFactory | None) – The number counts factory to use.
metadata_indices (Sequence[firecrown.metadata_functions.TwoPointHarmonicIndex | firecrown.metadata_functions.TwoPointRealIndex])
- Returns:
An UpdatableCollection of TwoPoint statistics.
- Return type:
- classmethod from_metadata(metadata_seq, wl_factory=None, nc_factory=None)[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 (Sequence[firecrown.metadata_types.TwoPointHarmonic | firecrown.metadata_types.TwoPointReal]) – The metadata objects to initialize the TwoPoint statistics.
wl_factory (firecrown.likelihood.weak_lensing.WeakLensingFactory | None) – The weak lensing factory to use.
nc_factory (firecrown.likelihood.number_counts.NumberCountsFactory | None) – The number counts factory to use.
- Returns:
An UpdatableCollection of TwoPoint statistics.
- Return type:
- classmethod create_two_point(measurement, wl_factory, nc_factory)[source]
Create a single TwoPoint statistic from a measurement.
- Parameters:
measurement (firecrown.data_types.TwoPointMeasurement) – The measurement object to initialize the TwoPoint statistic.
wl_factory (None | firecrown.likelihood.weak_lensing.WeakLensingFactory)
nc_factory (None | firecrown.likelihood.number_counts.NumberCountsFactory)
- Return type:
- classmethod from_measurement(measurements, wl_factory=None, nc_factory=None)[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 (Sequence[firecrown.data_types.TwoPointMeasurement]) – The measurements objects to initialize the TwoPoint statistics.
wl_factory (firecrown.likelihood.weak_lensing.WeakLensingFactory | None) – The weak lensing factory to use.
nc_factory (firecrown.likelihood.number_counts.NumberCountsFactory | None) – The number counts factory to use.
- 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)[source]
Compute the power spectrum for the given ells and tracers.
- Parameters:
ells (numpy.typing.NDArray[numpy.int64])
scale0 (float)
scale1 (float)
tracers0 (Sequence[firecrown.likelihood.source.Tracer])
tracers1 (Sequence[firecrown.likelihood.source.Tracer])
- Return type:
numpy.typing.NDArray[numpy.float64]
- compute_cells_interpolated(ells, ells_for_interpolation, scale0, scale1, tools, tracers0, tracers1)[source]
Compute the interpolated power spectrum for the given ells and tracers.
- Parameters:
ells (numpy.typing.NDArray[numpy.int64]) – The angular wavenumbers at which to compute the power spectrum.
ells_for_interpolation (numpy.typing.NDArray[numpy.int64]) – The angular wavenumbers at which the power spectrum is computed for interpolation.
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.
tracers0 (Sequence[firecrown.likelihood.source.Tracer]) – The first tracers to use.
tracers1 (Sequence[firecrown.likelihood.source.Tracer]) – The second tracers to use.
- Return type:
numpy.typing.NDArray[numpy.float64]
Compute the power spectrum for the given ells and tracers and interpolate the result to the ells provided.
- Returns:
The interpolated power spectrum.
- Parameters:
ells (numpy.typing.NDArray[numpy.int64])
ells_for_interpolation (numpy.typing.NDArray[numpy.int64])
scale0 (float)
scale1 (float)
tracers0 (Sequence[firecrown.likelihood.source.Tracer])
tracers1 (Sequence[firecrown.likelihood.source.Tracer])
- Return type:
numpy.typing.NDArray[numpy.float64]
- Parameters:
sacc_data_type (str)
source0 (firecrown.likelihood.source.Source)
source1 (firecrown.likelihood.source.Source)
ell_for_xi (None | dict[str, int])
ell_or_theta (None | firecrown.generators.two_point.EllOrThetaConfig)
ell_or_theta_min (None | float | int)
ell_or_theta_max (None | float | int)
tracers (None | firecrown.metadata_types.TracerNames)
- 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]]