yaw.CorrFunc#
- class yaw.CorrFunc(dd: NormalisedCounts, dr: NormalisedCounts | None = None, rd: NormalisedCounts | None = None, rr: NormalisedCounts | None = None)[source]#
Bases:
BaseCorrFunc[NormalisedCounts]Container for correlation function amplitude pair counts.
The container is typically created by
crosscorrelate()orautocorrelate()and stores pair counts in bins of redshift and per spatial patch of the inputCatalogs. The data-data, data-random, etc. pair counts are stored in separate attributes.Note
While the pair counts
dr,rd, orrrare 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:
dr – The optional data-random pair counts as
NormalisedCounts.rd – The optional random-random pair counts as
NormalisedCounts.rr – The optional random-random pair counts as
NormalisedCounts.
- 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.
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
Whether the pair counts describe an autocorrelation function.
Accessor for the redshift
Binningattribute.Indexing helper to create a new instance from a subset of patches.
The data-data pair counts.
The data-random pair counts.
The number of redshift bins.
The number of spatial patches.
Indexing helper to create a new instance from a subset of patches.
The random-data pair counts.
The random-random pair counts.
- property auto: bool#
Whether the pair counts describe an autocorrelation function.
- 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 (
strorpathlib.Path) to HDF5 file to restore from, see alsoto_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
Falseif 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=Trueand type ofotherdoes match this class.ValueError – If
require=Truethe 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
CorrDatainstance.
- 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 (
strorpathlib.Path) to HDF5 file to serialise into, see alsofrom_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().