Velocity moments¶
Pairwise velocity moments are computed by
measure_velocity_moments,
which delegates to the pairvel Python wrapper around
PairVel.jl. For every auto and cross
mass-bin pair (same convention as xi_hh) the function returns the
mean radial pairwise velocity plus a small set of central moments, all
binned in separation r.
Output¶
Each velocity_moments.hdf5 file contains one HDF5 group per pair
M{i}_M{j} (i <= j) with the following datasets:
| Key | Description |
|---|---|
npairs |
pair count per r bin |
m10 |
mean radial pairwise velocity ⟨v_r⟩ (km/s) |
c20 |
second central moment of v_r |
c02 |
second central moment of v_t (transverse) |
c12 |
mixed third moment |
c30 |
third central moment of v_r |
c40, c04, c22 |
fourth-order central moments |
Each group additionally carries r (centres), the log10M1 / log10M2
bin edges as HDF5 attributes, and the halo counts n1 / n2.
Loading from HDF5¶
There is no dedicated Loader class — read it directly with h5py:
import h5py
from halocat import config as C
vel_path = f"{C.get_output_dir('LCDM', 0.25, 1, 1)}/velocity_moments.hdf5"
with h5py.File(vel_path, "r") as f:
r_edges = f["r_edges"][...]
mass_bins = f["mass_bins"][...] # (P, 2)
moment_keys = [s.decode() if isinstance(s, bytes) else s
for s in f.attrs["moment_keys"]]
groups = sorted(k for k in f.keys()
if k.startswith("M") and "_M" in k)
autos = [g for g in groups
if g.split("_")[0] == g.split("_")[1]]
# Pull one auto for inspection
g = f[autos[0]]
r = g["r"][...]
m10 = g["m10"][...]
log10M = g.attrs["log10M1"]
n_halo = int(g.attrs["n1"])
Default binning¶
The defaults live in halocat.config:
VEL_R_EDGES— linearredges in Mpc/hVEL_MASS_BINS— same asMASS_BINSby default
Measuring directly¶
measure_velocity_moments
takes a halo dict, the box size, mass bins, and r_edges, and returns
the same dict-of-groups structure that
write_velocity_moments
serialises:
from halocat.io import read_halo_hdf5
from halocat.velocity import measure_velocity_moments
from halocat import config as C
data = read_halo_hdf5(f"{C.get_output_dir('LCDM', 0.25, 1, 1)}/halo.hdf5")
vel = measure_velocity_moments(
data, C.BOX_SIZE, C.VEL_MASS_BINS, C.VEL_R_EDGES,
)
# vel['M0_M0']['m10'] -> (K,) ndarray
Driver¶
The pipeline produces velocity_moments.hdf5 automatically when you
run halocat/run_single/run_all. There is no standalone script for
just velocity moments — the measurement is always part of the bundled
pipeline.