yaw.CorrFunc#

class yaw.CorrFunc(dd: NormalisedCounts, dr: NormalisedCounts | None = None, rd: NormalisedCounts | None = None, rr: NormalisedCounts | None = None)[source]#

Bases: BinwiseData, PatchwiseData, Serialisable, HdfSerializable, Broadcastable

Container for correlation function amplitude pair counts.

The container is typically created by crosscorrelate() or autocorrelate() and stores pair counts in bins of redshift and per spatial patch of the input Catalog s. The data-data, data-random, etc. pair counts are stored in separate attributes.

Note

While the pair counts dr, rd, or rr are all optional, at least one of these pair counts must pre provided.

Additionally implements comparison with the == operator, addition with + and scaling of the pair counts by a scalar with *.

Parameters:

dd – The data-data pair counts as NormalisedCounts.

Keyword Arguments:
Raises:
  • ValueError – If any of the pair counts are not compatible (by binning or number of patches).

  • EstimatorError – If none of the optional pair counts are provided.

Methods

__init__(dd[, dr, rd, rr])

from_dict(the_dict)

Restore the class instance from a python dictionary.

from_file(path)

Restore the class instance from a HDF5 file.

from_hdf(source)

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

is_compatible(other, *[, require])

Checks if two containers have compatible binning.

sample()

Compute an estimate of the correlation function in bins of redshift.

to_dict()

Serialise the class instances into a dictionary.

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

dd

The data-data pair counts.

dr

The optional data-random pair counts.

rd

The optional random-data pair counts.

rr

The optional random-random pair counts.

auto

Whether the pair counts describe an autocorrelation function.

binning

Accessor for the redshift Binning attribute.

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.

property auto: bool#

Whether the pair counts describe an autocorrelation function.

property 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.

dd: NormalisedCounts#

The data-data pair counts.

dr: NormalisedCounts | None#

The optional data-random pair counts.

classmethod from_dict(the_dict: dict[str, Any]) TypeSerialisable#

Restore the class instance from a python dictionary.

Parameters:

the_dict – Dictionary containing all required data attributes to restore the instance, see also to_dict().

Returns:

Restored class instance.

classmethod from_file(path: Path | str) CorrFunc[source]#

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) CorrFunc[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.

is_compatible(other: CorrFunc, *, require: bool = False) bool[source]#

Checks if two containers have compatible binning.

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 binnings have identical edges if require=False.

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

  • ValueError – If require=True the binning 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.

rd: NormalisedCounts | None#

The optional random-data pair counts.

rr: NormalisedCounts | None#

The optional random-random pair counts.

sample() CorrData[source]#

Compute an estimate of the correlation function in bins of redshift.

Sums the pair counts over all spatial patches and uses the Landy-Szalay estimator if random-random pair counts exist, otherwise the Davis- Peebles estimator to compute the correlation function. Computes the uncertainty of the correlation function by computing jackknife samples from the spatial patches.

Returns:

The correlation function estimate with jackknife samples wrapped in a CorrData instance.

to_dict() dict[str, Any][source]#

Serialise the class instances into a dictionary.

Returns:

A dictionary containnig the minimal set of data attributes to restore the instance with from_dict().

to_file(path: Path | str) None[source]#

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().