yaw.catalogs.BaseCatalog#
- class yaw.catalogs.BaseCatalog(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:
objectThe data catalog base class.
Every new backend must implement a catalog class based on this abstract base class. On import this subclass is automatically registered and can be instantiated using the factory class
yaw.NewCatalog.Note
Base classes must follow the
[Backendname]Catalognaming convention. The new backend is then registered with namebackendname(lower case).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])Restore the catalogue from its cache directory.
from_file(filepath, patches, ra, dec, *[, ...])Build a catalogue from data file.
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.
load()Permanently load data from cache into memory.
The number of spatial patches of this catalogue.
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.
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.- abstract property centers: CoordSky#
Get a vector of sky coordinates of the patch centers in radians.
- Returns:
- abstract correlate(config: Configuration, binned: bool, other: _Tcat = 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.
- abstract property dec: ndarray[Any, dtype[float64]]#
Get an array of the declination values in radians.
- abstract classmethod from_cache(cache_directory: str, progress: bool = False) BaseCatalog[source]#
Restore the catalogue from its cache directory.
Catalogs should be instantiated through the factory class, see
yaw.catalogs.NewCatalog.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[source]#
Build a catalogue from data file.
Catalogs should be instantiated through the factory class, see
yaw.catalogs.NewCatalog.from_file().
- abstract get_totals() ndarray[Any, dtype[float64]][source]#
Get an array of the sum of weights or number of objects in each patch.
- abstract has_redshifts() bool[source]#
Indicates whether the
redshifts()attribute holds data.
- abstract property ids: list[int]#
Return a list of unique patch indices in the catalog.
- abstract 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.
- abstract load() None[source]#
Permanently load data from cache into memory.
Raises a
CachingErrorif no cache is configured.
- abstract property patch: ndarray[Any, dtype[int64]]#
Get the patch indices of each object as array.
- abstract property ra: ndarray[Any, dtype[float64]]#
Get an array of the right ascension values in radians.
- abstract 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:
- abstract property redshifts: ndarray[Any, dtype[float64]] | None#
Get the redshifts as array or
Noneif not available.
- abstract property total: float#
Get the sum of weights or the number of objects if weights are not available.
- abstract 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:
- abstract property weights: ndarray[Any, dtype[float64]]#
Get the object weights as array or
Noneif not available.