yaw.catalogs.scipy.SphericalKDTree#
- class yaw.catalogs.scipy.SphericalKDTree(position: Coordinate, weights: NDArray[np.float64] | None = None, leafsize: int = 16)[source]#
Bases:
objectWrapper around
scipy.spatial.cKDTreethat represents angular coordinates as points on the unitsphere.The only implemented operation is counting pairs in a fixed angular annulus. Angular distances are converted to the corresponding Euclidean distance on the unitsphere. Individual weights for points are supported.
Build a new tree from a set of coordinates.
- Parameters:
position (
yaw.coordinates.Coordinate) – A vector of coordinates in either angular or 3D coordiantes, is converted to 3D coordinates if needed.weights (
NDArray, optional) – Individual weights for the points.leafsize (
int, optional) – Size at which branches of the KDTree are considered leaf nodes with no further childs.
Methods
__init__(position[, weights, leafsize])Build a new tree from a set of coordinates.
count(other, scales[, dist_weight_scale, ...])Count pairs on a set of angular scales.
Attributes
Sum of weights or total number of objects if not provided.
- count(other: SphericalKDTree, scales: NDArray[np.float64], dist_weight_scale: float | None = None, weight_res: int = 50) NDArray[source]#
Count pairs on a set of angular scales.
Pairs are counted with in a range of minimum and maximum angle in radian. If multiple scales are provided, the set of scales is converted into a list of radial bins. After counting, the binned counts are summed to obtain the counts for the (potentially overlapping) input scales.
The method also supports weighting the pairs radially by a simple power-law \(r^\alpha\), where \(r\) is the pair separation. To speed up computation, the weight is computed individually, but for all pairs within one angular bin in the logarithmic center of the bin. If radial weights are provided, the resultion of the angular binning is increased beyond the binning obtained by combining the scale limits (see above).
- Parameters:
other (
SphericalKDTree) – Second tree used to count pairs.scales (
NDArray) – Array with angular scales in radian with shape (2, N). The scales are provided as at least one tuple of minimum and maximum angular scale.dist_weight_scale (
float, optional) – The power-law index for the radial weighting.weight_res (
NDArray) – The number of logarithmic angular bins used to compute the angular weights. Ignored if no power-law index is set.
- Returns:
The pair counts for each input scale, with optional inidividual point weights and radial weights applied.
- Return type:
NDArray
Warning
For autocorrelation measurements,
othermust be the same tree as the calling instance itself. This will results in pairs being counted twice, as they normally would be in the cross-tree counting case.
- property total: float#
Sum of weights or total number of objects if not provided.