firecrown.likelihood.two_point ============================== .. py:module:: firecrown.likelihood.two_point .. autoapi-nested-parse:: Two point statistic support. Classes ------- .. autoapisummary:: firecrown.likelihood.two_point.TwoPoint firecrown.likelihood.two_point.TwoPointFactory Functions --------- .. autoapisummary:: firecrown.likelihood.two_point.calculate_angular_cl firecrown.likelihood.two_point.read_reals firecrown.likelihood.two_point.read_ell_cells firecrown.likelihood.two_point.use_source_factory firecrown.likelihood.two_point.use_source_factory_metadata_index Module Contents --------------- .. py:function:: calculate_angular_cl(ells, pk_name, scale0, scale1, tools, tracer0, tracer1, int_options = None) Calculate the angular multipole moments. :param ells: The angular wavenumbers at which to compute the power spectrum. :param pk_name: The name of the power spectrum to return. :param scale0: The scale factor for the first tracer. :param scale1: The scale factor for the second tracer. :param tools: The modeling tools to use. :param tracer0: The first tracer to use. :param tracer1: The second tracer to use. :return: The angular multipole moments. .. py:class:: TwoPoint(sacc_data_type, source0, source1, *, interp_ells_gen = gen.LogLinearElls(), ell_or_theta = None, tracers = None, int_options = None, apply_interp = ApplyInterpolationWhen.DEFAULT) Bases: :py:obj:`firecrown.likelihood.statistic.Statistic` .. autoapi-inheritance-diagram:: firecrown.likelihood.two_point.TwoPoint :parts: 1 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). :ivar ccl_kind: The CCL correlation function kind or 'cl' for power spectra. :ivar sacc_tracers: The SACC tracer names for this statistic, set after read. .. py:property:: sacc_data_type :type: str Backwards compatibility for sacc_data_type. .. py:property:: source0 :type: firecrown.likelihood.source.Source Backwards compatibility for source0. .. py:property:: source1 :type: firecrown.likelihood.source.Source Backwards compatibility for source1. .. py:property:: window :type: None | numpy.typing.NDArray[numpy.float64] Backwards compatibility for window. .. py:property:: sacc_tracers :type: None | firecrown.metadata_types.TracerNames Backwards compatibility for sacc_tracers. .. py:property:: ells :type: None | numpy.typing.NDArray[numpy.int64] Backwards compatibility for ells. .. py:property:: thetas :type: None | numpy.typing.NDArray[numpy.float64] Backwards compatibility for thetas. .. py:property:: ells_for_xi :type: None | numpy.typing.NDArray[numpy.int64] Backwards compatibility for ells_for_xi. .. py:property:: cells Backwards compatibility for cells. .. py:attribute:: theory .. py:method:: from_metadata_index(metadata_indices, tp_factory) :classmethod: 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. :param metadata_index: The metadata index objects to initialize the TwoPoint statistics. :param tp_factory: The TwoPointFactory to use. :return: An UpdatableCollection of TwoPoint statistics. .. py:method:: from_metadata(metadata_seq, tp_factory) :classmethod: 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. :param metadata_seq: The metadata objects to initialize the TwoPoint statistics. :param wl_factory: The weak lensing factory to use. :param nc_factory: The number counts factory to use. :return: An UpdatableCollection of TwoPoint statistics. .. py:method:: create_two_point(measurement, tp_factory) :classmethod: Create a single TwoPoint statistic from a measurement. :param measurement: The measurement object to initialize the TwoPoint statistic. .. py:method:: from_measurement(measurements, tp_factory) :classmethod: 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. :param measurements: The measurements objects to initialize the TwoPoint statistics. :param wl_factory: The weak lensing factory to use. :param nc_factory: The number counts factory to use. :return: An UpdatableCollection of TwoPoint statistics. .. py:method:: read(sacc_data) Read the data for this statistic from the SACC file. :param sacc_data: The data in the sacc format. .. py:method:: read_real_space(sacc_data) Read the data for this statistic from the SACC file. .. py:method:: read_harmonic_space(sacc_data) Read the data for this statistic from the SACC file. .. py:method:: read_harmonic_spectrum_data(ells_cells_indices, sacc_data) Read all the data for this statistic from the SACC file. :param ells_cells_indices: The ells, the cells and the indices of the data in the SACC file. :param sacc_data: The data in the sacc format. :return: The ells, the cells and the indices, and window function if there is one. .. py:method:: get_data_vector() Return this statistic's data vector. .. py:method:: set_data_vector(value) Set this statistic's data vector. .. py:method:: 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. .. py:method:: 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. .. py:method:: 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. .. py:function:: read_reals(theory, sacc_data) Read and return theta and xi. :param theory: The theory, carrying data type and tracers. :param sacc_data: The SACC data object to be read. :return: The theta and xi values. .. py:function:: read_ell_cells(theory, sacc_data) Read and return ell and Cell. :param theory: The theory, carrying data type and tracers. :param sacc_data: The SACC data object to be read. :return: The ell and Cell values. .. py:class:: TwoPointFactory(/, **data) Bases: :py:obj:`pydantic.BaseModel` .. autoapi-inheritance-diagram:: firecrown.likelihood.two_point.TwoPointFactory :parts: 1 Factory class for WeakLensing objects. .. py:attribute:: model_config Configuration for the model, should be a dictionary conforming to [`ConfigDict`][pydantic.config.ConfigDict]. .. py:attribute:: correlation_space :type: Annotated[firecrown.metadata_types.TwoPointCorrelationSpace, BeforeValidator(make_correlation_space), Field(description='The two-point correlation space.')] .. py:attribute:: weak_lensing_factories :type: list[firecrown.likelihood.weak_lensing.WeakLensingFactory] :value: None .. py:attribute:: number_counts_factories :type: list[firecrown.likelihood.number_counts.NumberCountsFactory] :value: None .. py:attribute:: cmb_factories :type: list[firecrown.likelihood.cmb.CMBConvergenceFactory] :value: None .. py:attribute:: int_options :type: firecrown.utils.ClIntegrationOptions | None :value: None .. py:method:: model_post_init(_, /) Initialize the WeakLensingFactory object. .. py:method:: get_factory(measurement, type_source = TypeSource.DEFAULT) Get the Factory for the given Measurement and TypeSource. .. py:method:: from_measurement(tpms) Create a TwoPoint object from a list of TwoPointMeasurement. .. py:method:: from_metadata(metadata_seq) Create a TwoPoint object from a list of TwoPointHarmonic or TwoPointReal. .. py:function:: use_source_factory(inferred_galaxy_zdist, measurement, tp_factory) Apply the factory to the inferred galaxy redshift distribution. .. py:function:: use_source_factory_metadata_index(sacc_tracer, measurement, tp_factory) Apply the factory to create a source using metadata only.