dsf.covariance.projection.hankel_utils module

Numerical scripts for projected radial statistics.

This module provides small utilities used when converting Fourier-space power spectra into radial-space projected statistics. The scripts cover Bessel-function roots, smooth spectrum tapering, radial bin centers, radial integration weights, covariance-to-correlation conversion, and bin-averaging of radial matrices or tensors.

The functions assume their inputs have already been validated by the public calling layer.

dsf.covariance.projection.hankel_utils.apply_taper_spectrum(k, pk, large_k_lower=10.0, large_k_upper=100.0, low_k_lower=0.0, low_k_upper=1e-05)[source]

Return a smoothly tapered power spectrum.

The taper suppresses power outside the trusted wavenumber range so that projected radial statistics are less sensitive to sharp spectrum cutoffs.

Parameters:
  • k (ndarray[tuple[Any, ...], dtype[float64]]) – Wavenumber grid.

  • pk (ndarray[tuple[Any, ...], dtype[float64]]) – Power-spectrum values evaluated on k.

  • large_k_lower (float) – Wavenumber where high-k suppression begins.

  • large_k_upper (float) – Wavenumber above which the spectrum is set to zero.

  • low_k_lower (float) – Wavenumber below which the spectrum is set to zero.

  • low_k_upper (float) – Wavenumber where low-k suppression ends.

Returns:

Power spectrum with smooth low-k and high-k suppression applied.

Return type:

ndarray[tuple[Any, …], dtype[float64]]

dsf.covariance.projection.hankel_utils.bessel_zeros(order, n_zeros)[source]

Return positive roots of the Bessel function for a given order.

Parameters:
  • order (float | int) – Bessel-function order.

  • n_zeros (int) – Number of positive roots to return.

Returns:

Positive roots of \(J_\nu(x)\) for the requested order.

Return type:

ndarray[tuple[Any, …], dtype[float64]]

dsf.covariance.projection.hankel_utils.compute_bin_radial_matrix(r, matrix, r_bins)[source]

Average a radial matrix or tensor into radial bins.

Each axis of matrix is interpreted as a radial coordinate sampled on the same grid r. The returned quantity is the annular-bin average of the input matrix or tensor.

Parameters:
  • r (ndarray[tuple[Any, ...], dtype[float64]]) – Radial grid associated with each axis of matrix.

  • matrix (ndarray[tuple[Any, ...], dtype[float64]]) – Radial matrix or tensor to bin.

  • r_bins (ndarray[tuple[Any, ...], dtype[float64]]) – Radial bin edges.

Returns:

Radial bin centers and the binned matrix or tensor.

Return type:

tuple[ndarray[tuple[Any, …], dtype[float64]], ndarray[tuple[Any, …], dtype[float64]]]

dsf.covariance.projection.hankel_utils.compute_correlation_matrix(covariance)[source]

Return the correlation matrix associated with a covariance matrix.

Parameters:

covariance (ndarray[tuple[Any, ...], dtype[float64]]) – Covariance matrix.

Returns:

Dimensionless correlation matrix with entries normalized by the corresponding covariance standard deviations.

Return type:

ndarray[tuple[Any, …], dtype[float64]]

dsf.covariance.projection.hankel_utils.compute_diagonal_error(covariance)[source]

Return one-sigma errors from a covariance matrix.

Parameters:

covariance (ndarray[tuple[Any, ...], dtype[float64]]) – Covariance matrix.

Returns:

Square root of the covariance diagonal.

Return type:

ndarray[tuple[Any, …], dtype[float64]]

dsf.covariance.projection.hankel_utils.radial_bin_centers(r_bins)[source]

Return geometric centers of radial bins.

Parameters:

r_bins (ndarray[tuple[Any, ...], dtype[float64]]) – Radial bin edges.

Returns:

Geometric mean of each pair of neighboring radial bin edges.

Return type:

ndarray[tuple[Any, …], dtype[float64]]

dsf.covariance.projection.hankel_utils.radial_weights(r, r_bins=None)[source]

Return radial averaging weights.

The weights represent the radial measure used when averaging projected radial quantities over annular bins.

Parameters:
  • r (ndarray[tuple[Any, ...], dtype[float64]]) – Radial grid.

  • r_bins (ndarray[tuple[Any, ...], dtype[float64]] | None) – Optional radial bin edges.

Returns:

Radial weights proportional to \(r\,dr\).

Return type:

ndarray[tuple[Any, …], dtype[float64]]