Measurements

Measurement logic is implemented in halocat/measurements.py and exposed through cat.measure.

Measurement namespace

cat.measure.hmf(...)
cat.measure.xi(...)
cat.measure.pairwise_velocity_moments(...)
cat.measure.binned_statistic(...)
cat.measure.bias(...)

Convenience wrappers on HaloCat mirror the main methods:

  • cat.measure_hmf(...)
  • cat.measure_chmf(...)
  • cat.measure_dhmf(...)
  • cat.measure_dndlog10M(...)
  • cat.measure_2PCF(...)
  • cat.measure_velocity_moments(...)
  • cat.measure_binned_statistic(...)
  • cat.measure_bias(...)

All pair-counting measurements require catalogue.boxsize. For the current implementation, separation bins must satisfy:

r_edges[-1] <= 0.5 * min(boxsize)

Cross-catalogue measurements are available through the other= argument on xi(...), pairwise_velocity_moments(...), and bias(...). The two catalogues must have matching boxsize and periodic settings.

Halo mass function

Use either physical mass-bin edges or log-mass edges:

hmf = cat.measure.hmf(log10mass_edges=np.arange(12.0, 15.1, 0.1))

Returned fields include:

  • mass_edges
  • mass_centres
  • log10mass_edges
  • log10mass_centres
  • counts
  • number_density
  • cumulative_number_density
  • volume
  • mass_field

number_density is dn/dlog10M. cumulative_number_density is n(>M) evaluated at the lower edge of each bin.

Two-point correlation function

Real-space measurement:

xi = cat.measure.xi(np.geomspace(0.5, 50.0, 20))

Redshift-space measurement:

xi_s = cat.measure.xi(
    np.geomspace(0.5, 50.0, 20),
    space="redshift",
    los="z",
    los_velocity_factor=0.01,
    mu_edges=np.linspace(0.0, 1.0, 33),
    ells=(0, 2, 4),
)

Current implementation notes:

  • The measurement uses periodic-box minimal-image distances.
  • estimator="natural" is the only implemented estimator.
  • boxsize must be set.
  • Cross-correlations can be measured with other=other_catalogue.
  • Redshift-space mode requires velocity fields and los_velocity_factor in Mpc/h per km/s.
  • The returned TwoPointCorrelationResult includes xi, pair_counts, and random_pair_counts in all modes.
  • Redshift-space results additionally include mu_edges, mu_centres, xi_s_mu, pair_counts_s_mu, random_pair_counts_s_mu, ells, and multipoles.

Example cross-correlation:

xi_cross = cat_a.measure.xi(
    np.geomspace(0.5, 50.0, 20),
    other=cat_b,
)

Pairwise velocity moments

vel = cat.measure.pairwise_velocity_moments(np.geomspace(0.5, 20.0, 12))

The result contains:

  • pair_counts
  • mean_radial_velocity
  • mean_squared_radial_velocity
  • radial_velocity_dispersion
  • cross

cross is True when the measurement was made with other=....

Generic binned statistics

spin_vs_mass = cat.measure.binned_statistic(
    "spin",
    bins=np.logspace(12.0, 15.0, 8),
    x_field="mass",
    statistic="mean",
)

The returned BinnedStatisticResult stores:

  • bin_edges
  • bin_centres
  • counts
  • statistic
  • statistic_name
  • x_field
  • y_field

This method is a light wrapper around scipy.stats.binned_statistic.

Halo bias

bias(...) accepts either:

  • a TwoPointCorrelationResult
  • an array-like reference xi plus matching r_edges
matter_xi = ...
bias = cat.measure.bias(matter_xi, r_edges=np.geomspace(0.5, 50.0, 20))

Currently implemented mode:

  • sqrt_ratio: b(r) = sqrt(xi_halo / xi_reference)

If you pass a TwoPointCorrelationResult, its r_edges are reused automatically.