Skip to content

Quick start

This page walks one realisation (gravity=LCDM, redshift=0.25, imodel=1, ibox=1) from raw .DAT to all four data products, mostly through the high-level loaders.

1. Process one realisation end to end

from halocat.pipeline import run_single

status = run_single("LCDM", 0.25, imodel=1, ibox=1)
assert status["ok"], status["error"]

run_single reformats CatshortV.*.DAT → halo.hdf5 if needed and writes hmf.hdf5, xi_hh.hdf5, and velocity_moments.hdf5 in the per-realisation output directory. Existing files are not overwritten unless overwrite=True.

2. Where the outputs live

from halocat import config as C
print(C.get_output_dir("LCDM", 0.25, 1, 1))
# /cosma8/data/dp203/dc-ruan1/degrace_pilot/gravity_LCDM/z_0.25/imodel_1/box_1

The directory contains:

File Produced by
halo.hdf5 halocat.io.write_halo_hdf5
hmf.hdf5 halocat.hmf.write_hmf
xi_hh.hdf5 halocat.tpcf.write_xi_hh
velocity_moments.hdf5 halocat.velocity.write_velocity_moments

3. Load the data products back

from halocat import HMFLoader, XiHHLoader
from halocat.io import read_halo_hdf5

# Halo catalogue: dict of NumPy arrays keyed by CATALOGUE_COLUMNS.
data = read_halo_hdf5(f"{C.get_output_dir('LCDM', 0.25, 1, 1)}/halo.hdf5")
print(len(data['Mtot']), "haloes")

# HMF
hmf = HMFLoader().get("LCDM", 0.25, imodel=1, ibox=1)
print(hmf.dndlog10M.shape, hmf.log10M_bin_centre[[0, -1]])

# xi_hh on the static MASS_BINS / R_EDGES grid
xi = XiHHLoader().get("LCDM", 0.25, imodel=1, ibox=1)
print(xi.pairs)

4. xi_hh for an arbitrary mass-bin pair

For finite-width custom bins (no need to be in the static MASS_BINS grid, no I/O):

rec = XiHHLoader().measure_pair(
    "LCDM", 0.25, imodel=1, ibox=1,
    log10M1=(13.0, 13.3),
    log10M2=(13.7, 14.0),
)
rec.is_auto       # -> False
rec.n1, rec.n2    # halo counts in each side
rec.r, rec.xi     # (K,), (K,) arrays

See Halo–halo 2PCF for the full story.

5. Stack across iboxes

grid = HMFLoader().get_grid(
    gravities=["LCDM"], redshifts=[0.25],
    imodels=[1], iboxes=[1, 2, 3, 4, 5],
)
# grid['dndlog10M'].shape == (G, Z, M, B, K) == (1, 1, 1, 5, K)
import numpy as np
mean_hmf = np.nanmean(grid['dndlog10M'], axis=3)  # mean over iboxes

6. Notebook walkthrough

A full Jupyter walkthrough lives at notebooks/example_load.ipynb in the repository — open it locally with Jupyter against the cosemu kernel. It walks halo + HMF + xi_hh + velocity moments + sub-grid stacking on the same realisation.