Skip to content

Installation

Prerequisites

  • Rust toolchain (stable, 1.70+)
  • HDF5 library (for OpSim/HDF5 survey loading)

For Python bindings:

Rust library

cargo build --release
cargo test -p survey-sim --lib

Python bindings

pip install maturin numpy
cd python
maturin develop --release

This builds and installs the survey_sim package into the active virtualenv.

Virtual environment

Maturin requires a virtualenv or conda environment. Create one with:

python -m venv .venv
source .venv/bin/activate

HPC / module systems

On HPC clusters you may need to load compiler, HDF5, and Python modules first:

module load gcc/13.2.0 openmpi/4.1.6 hdf5/1.14.3 python/3.11.5
source /path/to/your/venv/bin/activate
cd python && maturin develop --release

Dependencies

survey-sim depends on the following local crates:

Crate Path Purpose
lightcurve-fitting ../lightcurve-fitting Parametric lightcurve templates (Metzger, Bazin, Villar)
blastwave /home/mcoughli/blastwave Relativistic blast wave hydrodynamics + afterglow radiation

Ensure these are available at the expected paths, or update Cargo.toml accordingly.

Run tests

# Unit tests (no external data required)
cargo test -p survey-sim --lib

# Integration tests (requires OpSim database)
cargo test -p survey-sim --test test_survey -- --ignored

failing integration test

If the integration test is failing, you may have neglected to create the config.yaml file. Run the following and then edit the generated config.yaml with the relevant credentials:

cp config.defaults.yaml scripts/config.yaml

Controlling parallelism

survey-sim uses Rayon for multi-core parallelism. By default it uses all available cores:

export RAYON_NUM_THREADS=4  # limit to 4 threads