yaw.correlation.NormalisedCounts#

class yaw.correlation.NormalisedCounts(counts: PatchedCounts, sum_weights: PatchedSumWeights)[source]#

Bases: BaseNormalisedCounts

Stores normalised pair counts from a correlation measurement.

This class stores the raw pair counts (counts) and the product of the sum of weights (sum_weights) per redshift bin and combination of patch pairs between the two catalogs use for the pair counting. The total of the normalised counts per redshift bin, including jackknife samples thereof, can be obtained by calling sample_patch_sum(). The method computes the sum of pair counts over all possible pairs of patches and normalises them by dividing them by the product of the sum of weights from catalog 1 and 2.

Implements comparison with the == operator.

Parameters:
  • counts – Container of correlation pair counts.

  • sum_weights – Container of sum of weights in patches of catalogs 1 and 2.

Methods

__init__(counts, sum_weights)

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 normalised pair counts 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

auto

Whether the pair counts originate from an autocorrelation measurement.

binning

Accessor for the redshift Binning attribute.

bins

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

counts

Container of correlation pair counts.

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.

sum_weights

Container of sum of weights in patches of catalogs 1 and 2.

property auto: bool#

Whether the pair counts originate from an autocorrelation measurement.

property binning: Binning#

Accessor for the redshift Binning attribute.

property bins: Indexer[TypeSliceIndex, Self]#

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.

property counts: PatchedCounts#

Container of correlation pair counts.

classmethod from_file(path: Path | str) Self#

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) Self[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#

Represent normalised pair counts as numpy array with shape (num_bins, num_patches, num_patches).

I.e. the first array element contains the data associated with the first redshift bin and pairing the first patch with itself.

Note

The normalisation is computed from all patches and not per patch.

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, Self]#

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.

property sum_weights: PatchedSumWeights#

Container of sum of weights in patches of catalogs 1 and 2.

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#

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

Parameters:

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