yaw.ScalarCorrFunc#

class yaw.ScalarCorrFunc(dd: NormalisedScalarCounts, dr: NormalisedScalarCounts | None = None)[source]#

Bases: CorrFunc

Container for scalar field correlation function amplitude pair counts.

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

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

  • dr – The data-random pair counts as NormalisedScalarCounts.

Raises:

ValueError – If any of the pair counts are not compatible (by binning or number of patches).

Methods

__init__(dd[, dr])

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.

get_estimator()

Get the most appropriate correlation estimator for evaluating the pair counts.

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

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.

dd

The data-data pair counts.

dr

The data-random 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.

rd

The random-data pair counts.

rr

The random-random pair counts.

property auto: bool#

Whether the pair counts describe an autocorrelation function.

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 dd: T#

The data-data pair counts.

property dr: NormalisedCounts | None#

The data-random pair counts.

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

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

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_estimator() Callable[..., NDArray][source]#

Get the most appropriate correlation estimator for evaluating the pair counts.

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

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

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

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

property rd: NormalisedCounts | None#

The random-data pair counts.

property rr: NormalisedCounts | None#

The random-random pair counts.

sample() CorrData#

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

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#

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