yaw.catalogs.treecorr.TreecorrCatalog#
- class yaw.catalogs.treecorr.TreecorrCatalog(data: DataFrame, ra_name: str, dec_name: str, *, patch_name: str | None = None, patch_centers: BaseCatalog | Coordinate | None = None, n_patches: int | None = None, redshift_name: str | None = None, weight_name: str | None = None, cache_directory: str | None = None, progress: bool = False)[source]#
Bases:
BaseCatalogAn implementation of the
BaseCatalogusingTreeCorrfor the pair counting.Note
The current implementation is not very efficient, because the internal fields of the underlying
treecorr.Catalogmust be rebuilt every time the catalog is iterated in redshift bins for the pair counting.Warning
Currently this backend does not support restoration from cache and raises an
NotImplementedError`when calling thefrom_cache()method.Build a catalogue from in-memory data.
Catalogs should be instantiated through the factory class, see
yaw.catalogs.NewCatalog.from_dataframe().Methods
__init__(data, ra_name, dec_name, *[, ...])Build a catalogue from in-memory data.
correlate(config, binned[, other, linkage, ...])Count pairs between objects at a given separation and in bins of redshift.
from_cache(cache_directory[, progress])from_file(filepath, patches, ra, dec, *[, ...])Build a catalogue from data file.
from_treecorr(cat)Create a new instace from a
treecorr.Catalog.Get the maximum redshift or
Noneif not available.Get the minimum redshift or
Noneif not available.Get an array of the sum of weights or number of objects in each patch.
Indicates whether the
redshifts()attribute holds data.Indicates whether the
weights()attribute holds data.Indicates whether the catalog data is loaded.
iter_bins(z_bins[, allow_no_redshift])Iterate the catalogue in bins of redshift.
load()Permanently load data from cache into memory.
Get the internal
treecorr.Cataloginstance.true_redshifts(config[, sampling_config, ...])Compute a histogram of the object redshifts from the binning defined in the provided configuration.
unload()Unload data from memory if a disk cache is provided.
Attributes
Get a vector of sky coordinates of the patch centers in radians.
Get an array of the declination values in radians.
Return a list of unique patch indices in the catalog.
The number of spatial patches of this catalogue.
Get the patch indices of each object as array.
Get a vector of the object sky positions in radians.
Get an array of the right ascension values in radians.
Get a vector of angular separations in radians that describe the patch sizes.
Get the redshifts as array or
Noneif not available.Get the sum of weights or the number of objects if weights are not available.
Get the object weights as array or
Noneif not available.- property centers: CoordSky#
Get a vector of sky coordinates of the patch centers in radians.
- Returns:
- correlate(config: Configuration, binned: bool, other: TreecorrCatalog = None, linkage: PatchLinkage | None = None, progress: bool = False) NormalisedCounts | dict[str, NormalisedCounts][source]#
Count pairs between objects at a given separation and in bins of redshift.
If another catalog instance is passed to
other, then pairs are formed between these catalogues (cross), otherwise pairs are formed with the catalog (auto). Pairs are counted in bins of redshift, as defined in the configuration object (config). Pairs are only considered within fixed angular scales that are computed from the physical scales in the configuration and the mid of the current redshift bin.- Parameters:
config (
yaw.Configuration) – Configuration object that defines measurement scales, redshift binning, cosmological model, and various backend specific parameters.binned (
bool) – Whether to apply the redshift binning to the second catalogue (seeother).other (Catalog instance, optional) – Second catalog instance used for cross-catalogue pair counting. Catalogue must use the same backend.
linkage (
PatchLinkage, optional) – Linkage object that defines with patches must be correlated for a given scales and which patch combinations can be skipped. Can be used for thescipybackend to count pairs consistently between multiple catalogue instances.progress (
bool) – Show a progress indication, depends on backend.
There are three different modes of operation that are determined by the combination of the
binnedandotherparameters:If no second catalogue is provided, pairs are counted within the catalogue while applying the redshift binning.
If a second catalogue is provided and
binned=True, pairs are counted between the catalogues and the binning is applied to both cataluges.If a second catalogue is provided and
binned=False, the redshift binning is not applied to the second catalogue, otherwise above.
The catalogue from the calling instance of
correlate()has always redshift binning applied.
- property dec: ndarray[Any, dtype[float64]]#
Get an array of the declination values in radians.
- classmethod from_cache(cache_directory: str, progress: bool = False) NoReturn[source]#
- Raises:
NotImplementedError –
Warning
Currently this backend does not support restoration from cache.
- classmethod from_file(filepath: str, patches: str | int | BaseCatalog | Coordinate, ra: str, dec: str, *, redshift: str | None = None, weight: str | None = None, sparse: int | None = None, cache_directory: str | None = None, file_ext: str | None = None, progress: bool = False, **kwargs) BaseCatalog#
Build a catalogue from data file.
Catalogs should be instantiated through the factory class, see
yaw.catalogs.NewCatalog.from_file().
- classmethod from_treecorr(cat: Catalog) TreecorrCatalog[source]#
Create a new instace from a
treecorr.Catalog.
- get_totals() ndarray[Any, dtype[float64]][source]#
Get an array of the sum of weights or number of objects in each patch.
- has_redshifts() bool[source]#
Indicates whether the
redshifts()attribute holds data.
- property ids: list[int]#
Return a list of unique patch indices in the catalog.
- is_loaded() bool[source]#
Indicates whether the catalog data is loaded.
Always
Trueif no cache is used. If the catalog is unloaded, data will be read from cache every time data is accessed.
- iter_bins(z_bins: NDArray[np.float64], allow_no_redshift: bool = False) Iterator[tuple[Interval, TreecorrCatalog | EmptyCatalog]][source]#
Iterate the catalogue in bins of redshift.
- Parameters:
z_bins (
NDArray) – Edges of the redshift bins.allow_no_redshift (
bool) – If true and the data has no redshifts, the iterator yields the whole catalogue at each iteration step.
- Yields:
(tuple) –
- tuple containing:
intv (
pandas.Interval): the selection for this bin.cat (
TreecorrCatalog): instance containing the data for this bin.
- load() None[source]#
Permanently load data from cache into memory.
Raises a
CachingErrorif no cache is configured.
- property n_patches: int#
The number of spatial patches of this catalogue.
- property patch: ndarray[Any, dtype[int64]]#
Get the patch indices of each object as array.
- property ra: ndarray[Any, dtype[float64]]#
Get an array of the right ascension values in radians.
- property radii: DistSky#
Get a vector of angular separations in radians that describe the patch sizes.
The radius of the patch is defined as the maximum angular distance of any object from the patch center.
- Returns:
- property redshifts: ndarray[Any, dtype[float64]] | None#
Get the redshifts as array or
Noneif not available.
- property total: float#
Get the sum of weights or the number of objects if weights are not available.
- true_redshifts(config: Configuration, sampling_config: ResamplingConfig | None = None, progress: bool = False) HistData[source]#
Compute a histogram of the object redshifts from the binning defined in the provided configuration.
- Parameters:
config (
Configuration) – Defines the bin edges used for the histogram.sampling_config (
ResamplingConfig, optional) – Specifies the spatial resampling for error estimates.progress (
bool) – Show a progress bar.
- Returns:
Object holding the redshift histogram
- Return type:
- property weights: ndarray[Any, dtype[float64]]#
Get the object weights as array or
Noneif not available.