yaw.correlation.PatchedSumWeights#

class yaw.correlation.PatchedSumWeights(binning: Binning, sum_weights1: NDArray, sum_weights2: NDArray, *, auto: bool)[source]#

Bases: BinwisePatchwiseArray

Stores the sum of weights in spatial patches from catalogs in a correlation measurement.

The sum of weights are stored separately for the first and second catalog, each per patch and per redshift bin. The product of these numbers is used to normalised correlation pair counts between patches. This normalisation factor in bins or redshifts, including jackknife samples thereof, can be obtained by calling sample_patch_sum(), which sums over all possible pairs of patches from the first and second catalog.

Implements comparison with the == operator.

Parameters:
  • binning – Redshift bins used when counting pairs between patches.

  • sum_weights1 – Sum of weights in patches of catalog 1, array with shape (num_bins, num_patches).

  • sum_weights2 – Sum of weights in patches of catalog 2, array with shape (num_bins, num_patches).

Keyword Arguments:

auto – Whether the pair counts originate from an autocorrelation measurement.

Methods

__init__(binning, sum_weights1, ...)

from_file(path)

Restore the class instance from a HDF5 file.

from_hdf(source)

Restore the class instance from a specific HDF5-file group.

get_array()

Represent the internal data as numpy array with shape (num_bins, num_patches, num_patches).

is_compatible(other, *[, require])

Checks if two containers have the same redshift binning and number of spatial patches.

sample_patch_sum()

Compute the sum over all patches and leave-one-out jackknife samples.

to_file(path)

Serialise the class instances into a HDF5 file.

to_hdf(dest)

Serialise the class instances into a specific HDF5-file group.

Attributes

binning

Accessor for the redshift Binning attribute.

auto

Whether the pair counts originate from an autocorrelation measurement.

sum_weights1

Sum of weights in patches of catalog 1, array with shape (num_bins, num_patches).

sum_weights2

Sum of weights in patches of catalog 2, array with shape (num_bins, num_patches).

bins

Indexing helper to create a new instance from a subset of patches.

num_bins

The number of redshift bins.

num_patches

The number of spatial patches.

patches

Indexing helper to create a new instance from a subset of patches.

auto: bool#

Whether the pair counts originate from an autocorrelation measurement.

binning: Binning#

Accessor for the redshift Binning attribute.

property bins: Indexer[TypeSliceIndex, TypeBinwiseData]#

Indexing helper to create a new instance from a subset of patches.

The indexer supports indexing, slicing, and iteration over individual patches.

Caution

Indixing a non-contiguous subset of bins will result in expanding the previous bin to encompass all omitted bins, e.g. selecting the first and third bin of (0, 1], (1, 2], (2, 3] will result in a binning with edges (0, 2], (2, 3].

Slicing is unaffected since it always results in a contiguous subset of bins.

classmethod from_file(path: Path | str) TypeHdfSerializable#

Restore the class instance from a HDF5 file.

Parameters:

path – Path (str or pathlib.Path) to HDF5 file to restore from, see also to_file().

Returns:

Restored class instance.

classmethod from_hdf(source: Group) PatchedSumWeights[source]#

Restore the class instance from a specific HDF5-file group.

Parameters:

source – HDF5-file group to restore from, see also to_hdf().

Returns:

Restored class instance.

get_array() NDArray[source]#

Represent the internal data as numpy array with shape (num_bins, num_patches, num_patches).

Construct array of product of sum of weights for patch pairs, i.e. an array that holds the product of the sum from patch \(i\) from catalog 1 and patch \(j\) from catalog 2 in the \(b\)-th redshift bin at index [b, i, j].

Returns:

Internal data represented as numpy array.

is_compatible(other: Any, *, require: bool = False) bool#

Checks if two containers have the same redshift binning and number of spatial patches.

Parameters:

other – Another instance of this class to compare to, returns False if instance types do not match.

Keyword Arguments:

require – Whether to raise exceptions if any of the checks fail.

Returns:

Whether the number of patches is identical if require=False.

Raises:
  • TypeError – If require=True and type of other does match this class.

  • ValueError – If require=True and binning and the number of patches is not identical.

property num_bins: int#

The number of redshift bins.

property num_patches: int#

The number of spatial patches.

property patches: Indexer[TypeSliceIndex, TypePatchwiseData]#

Indexing helper to create a new instance from a subset of patches.

The indexer supports indexing, slicing, and iteration over individual patches.

sample_patch_sum() SampledData#

Compute the sum over all patches and leave-one-out jackknife samples.

I.e. marginalise over the patch axes and return a 1-dim array with length num_bins.

Returns:

Sum over patches and jackknife samples thereof packed in an instance of SampledData.

sum_weights1: NDArray#

Sum of weights in patches of catalog 1, array with shape (num_bins, num_patches).

sum_weights2: NDArray#

Sum of weights in patches of catalog 2, array with shape (num_bins, num_patches).

to_file(path: Path | str) None#

Serialise the class instances into a HDF5 file.

Parameters:

path – Path (str or pathlib.Path) to HDF5 file to serialise into, see also from_file().

to_hdf(dest: Group) None[source]#

Serialise the class instances into a specific HDF5-file group.

Parameters:

dest – HDF5-file group to serialise into, see also from_hdf().