yaw.correlation.paircounts.NormalisedCounts#
- class yaw.correlation.paircounts.NormalisedCounts(count: PatchedCount, total: PatchedTotal)[source]#
Bases:
PatchedQuantity,BinnedQuantity,HDFSerializableContainer to store counts and the total number of objects obtained from measuring pair counts for a correlation function.
Both input containers must have the same binning and the same number of spatial patches. The container supports the same arithmetic as
PatchedCount(see the listed examples), i.e. comparison, addition, multiplication by a scalar, as well as indexing. The resulting pair counts are always normalised by the number of objects stored intotal.- Parameters:
count (
PatchedCount) – The pair count container.total (
PatchedTotal) – The container for the total number of objects from the samples.
Methods
__init__(count, total)concatenate_bins(*pcounts)Concatenate pair count data containers with equal patches.
concatenate_patches(*pcounts)Concatenate pair count data containers with equal redshift binning.
from_file(path)Create a class instance by deserialising data from a HDF5 file.
from_hdf(source)Create a class instance by deserialising data from a HDF5 group.
Get the underlying, exact redshift bin intervals.
is_compatible(other[, require])Check whether this instance is compatible with another instance.
sample(config)Sum the pair counts across all spatial patches and generate samples from resampling the patches.
to_file(path)Serialise the class instance to a new HDF5 file.
to_hdf(dest)Serialise the class instance into an existing HDF5 group.
Attributes
Whether the stored data are from an autocorrelation measurement.
An
Indexerattribute that supports iteration over the bins or selecting a subset of the bins.Specifies on which side the redshift bin intervals are closed, can be:
left,right,both,neither.Get the width of the redshift bins as array.
Get the edges of the redshift bins as flat array.
Get the centers of the redshift bins as array.
Get the number of redshift bins.
Get the number of spatial patches.
An
Indexerattribute that supports iteration over the spatial patches or selecting a subset of the patches.The pair count container.
The container for the total number of objects from the samples.
- property auto: bool#
Whether the stored data are from an autocorrelation measurement.
- property bins: Indexer[int | slice | Sequence, NormalisedCounts]#
An
Indexerattribute that supports iteration over the bins or selecting a subset of the bins.The indexer always returns new container instances with the indexed data subset or the current item when iterating.
Warning
Indexing rules for a one-dimensional numpy array apply, however if the resulting binning is not contiguous or contains repeated bins, some operations on the returned container may fail.
- Returns:
yaw.core.containers.Indexer
- property closed: str#
Specifies on which side the redshift bin intervals are closed, can be:
left,right,both,neither.
- concatenate_bins(*pcounts: NormalisedCounts) NormalisedCounts[source]#
Concatenate pair count data containers with equal patches.
The data is merged by appending the data along the redshift binning axis.
Note
Necessary condition for merging is that the patch numbers are identical and that the merged binning is contiguous and non-overlapping. Cannot merge cross- with autocorrelation containers.
- Parameters:
*data – Containers of same type that are appended to the patch dimension of this container.
- Returns:
New instance of this container with combined data.
- concatenate_patches(*pcounts: NormalisedCounts) NormalisedCounts[source]#
Concatenate pair count data containers with equal redshift binning.
The data is merged by extending the dimension of the patch axes. The resulting data array will be a block matrix of the input data arrays, i.e. all elements with correlations between different inputs set to zero.
Note
Necessary condition for merging is that the the redshift binning of all inputs is identical. Cannot merge cross- with autocorrelation containers.
- Parameters:
*data – Containers of same type that are appended to the patch dimension of this container.
- Returns:
New instance of this container with combined data.
- count: PatchedCount#
The pair count container.
- property dz: ndarray[Any, dtype[float64]]#
Get the width of the redshift bins as array.
- property edges: ndarray[Any, dtype[float64]]#
Get the edges of the redshift bins as flat array.
- classmethod from_file(path: TypePathStr) _Thdf#
Create a class instance by deserialising data from a HDF5 file.
- Parameters:
path (
pathlib.Path,str) – Group in an opened HDF5 file that contains the necessary data.- Returns:
HDFSerializable
- classmethod from_hdf(source: Group) NormalisedCounts[source]#
Create a class instance by deserialising data from a HDF5 group.
- Parameters:
source (
h5py.Group) – Group in an opened HDF5 file that contains the serialised data.- Returns:
HDFSerializablep
- get_binning() IntervalIndex[source]#
Get the underlying, exact redshift bin intervals.
- Returns:
pandas.IntervalIndex
- is_compatible(other: _Tbinned, require: bool = False) bool#
Check whether this instance is compatible with another instance.
Ensures that both objects are instances of the same class and that the redshift binning is identical.
- Parameters:
other (
BinnedQuantity) – Object instance to compare to.require (
bool, optional) – Raise a ValueError if any of the checks fail.
- Returns:
bool
- property mids: ndarray[Any, dtype[float64]]#
Get the centers of the redshift bins as array.
- property n_bins: int#
Get the number of redshift bins.
- property n_patches: int#
Get the number of spatial patches.
- property patches: Indexer[int | slice | Sequence, NormalisedCounts]#
An
Indexerattribute that supports iteration over the spatial patches or selecting a subset of the patches.The indexer always returns new container instances with the indexed data subset or the current item when iterating.
Note
Indexing rules for a one-dimensional numpy array apply.
- Returns:
yaw.core.containers.Indexer
- sample(config: ResamplingConfig) SampledData[source]#
Sum the pair counts across all spatial patches and generate samples from resampling the patches.
Calls the
sample_sum()method of thecountsandtotalcontainers. Returns aSampledDatainstance that contains the normalised pair counts and spatially resampled values. Effectively computes \(\frac{XX}{n_1 n_2}\), where :math:XX` are the number of pairs between the two samples with a total number of objects \(n_1\) and \(n_2\) respectively.- Parameters:
config (
ResamplingConfig) – Specifies the resampling method and its customisation parameters.- Returns:
- to_file(path: TypePathStr) None#
Serialise the class instance to a new HDF5 file.
- Parameters:
path (
pathlib.Path,str) – Path at which the HDF5 file is created.
- to_hdf(dest: Group) None[source]#
Serialise the class instance into an existing HDF5 group.
- Parameters:
dest (
h5py.Group) – Group in which the serialised data structures are created.
- total: PatchedTotal#
The container for the total number of objects from the samples.