Skip to content

Getting started

Install

haloemu lives in the existing cosemu micromamba environment. Always run it through that env:

micromamba run -n cosemu python3 ...

Editable install:

micromamba run -n cosemu pip install -e /cosma8/data/dp203/dc-ruan1/halobias

Runtime dependencies that are not on PyPI (separate editable local packages in the same env):

  • halocat — per-realisation data loaders (BEffLoader, HMFLoader, XiMMLoader, XiHHLoader) and the cosmology design table.
  • freyja — external HMF emulator, used only as an optional hmf cross-check (located via FREYJA_ROOT). b_diff's n̄ comes from the in-suite hmf emulator, so freyja is not needed for any prediction.

halocat / freyja are only needed for training and validation — every registered property predicts without them (the trained artifacts ship in the package). See Portability.

Silence the CUDA probe

Set JAX_PLATFORMS=cpu before importing. On Cosma the GPU probe prints a harmless CUDA error otherwise.

import os; os.environ.setdefault("JAX_PLATFORMS", "cpu")

First prediction

import os; os.environ.setdefault("JAX_PLATFORMS", "cpu")
from haloemu import get_registry

reg = get_registry()

theta = [0.31, 0.677, 0.967, 0.83]                 # [Omega_m, h, n_s, S_8]
n = reg.predict("hmf", "LCDM", 0.25, theta)        # shape (1, 23): n(>M)

Every prediction is reg.predict(property, gravity, redshift, theta). The return shape and units depend on the property — see Predicting.

θ uses S_8, not σ_8

theta = [Omega_m, h, n_s, S_8] for ΛCDM, plus logf_R0 for fRn1. S_8 = sigma_8 * sqrt(Omega_m / 0.3). The GR fiducial has σ₈ = 0.8159 ⇒ S_8 = 0.827914. See Concepts → The registry.

CLI

# List every registered artifact
micromamba run -n cosemu python3 -m haloemu.cli list

# Predict
micromamba run -n cosemu python3 -m haloemu.cli predict xi_mm \
    --gravity fRn1 --redshift 0.25 --theta 0.31,0.677,0.967,0.83,-5

The console entry point haloemu is also installed, so micromamba run -n cosemu haloemu list works too.

Run the tests

micromamba run -n cosemu python3 -m pytest \
    /cosma8/data/dp203/dc-ruan1/halobias -q

Heavy compute

Training, validation sweeps, and any catalogue measurement belong on slurm (account dp004, partition cosma8-serial) — never on the login node. Single predictions are milliseconds and fine interactively. See Training & CLI.