Skip to content

Installation

Requires Python 3.11

Nested sampling depends on the official blackjax (its merged NSS), which requires Python 3.11. Create the environment with exactly that version.

A fresh conda environment is the easy route:

conda create -n ceridwen python=3.11 -y
conda activate ceridwen

git clone https://github.com/Espe13/ceridwen.git
cd ceridwen
pip install .

This pulls everything needed to import CERIDWEN, build the forward model, and run NUTS / VI / nested sampling including posterior plotting: jax, jaxlib, numpy, scipy, matplotlib, h5py, astropy, sedpy-jax, tensorflow-probability, blackjax, tqdm, optax, and anesthetic. The only thing not installed automatically is FSPS (see below).

There are no extras to choose. pip install . includes VI, nested-sampling plotting, and the test runner. FSPS is installed separately (see below), because it compiles Fortran and cannot be a normal Python dependency. Building this documentation site needs pip install ".[docs]" (maintainers only).

blackjax

Nested sampling uses blackjax.nss, which is merged into the official blackjax but not yet in a tagged PyPI release, so CERIDWEN pins a fixed blackjax commit (f73e12956), so everyone installs the same validated state. This is why CERIDWEN installs from source/GitHub rather than PyPI for now; once a blackjax release ships NSS it becomes a normal version pin.

Getting the SSP grid

Fitting needs a pre-computed SSP grid (an HDF5 file). The quickstart resolves it in the order $SSP_FILE, then examples/ssp_data.h5.

  1. Build your own with FSPS (recommended). Install FSPS (below) and let the quickstart build the grid on first run, or call SSPData.from_fsps(save_to="examples/ssp_data.h5", imf_type=1) directly. You control the isochrones, spectral library, and IMF. FSPS is needed anyway for nebular and dust emission, which read the CLOUDY and Draine & Li data from $SPS_HOME.
  2. Download from Zenodo (no FSPS needed): doi:10.5281/zenodo.21221634. Two grids are provided: ssp_data.h5 (MIST isochrones, MILES spectra, Chabrier IMF) and ssp_data_bpass.h5 (BPASS v2 binary SSPs). For the quickstart:

    curl -L -o examples/ssp_data.h5 \
        "https://zenodo.org/records/21221634/files/ssp_data.h5?download=1"
    

Installing FSPS and setting $SPS_HOME

CERIDWEN uses FSPS (via the python-fsps wrapper) to build the SSP cache. The FSPS data files also supply the CLOUDY nebular grids and Draine & Li dust-emission templates: when add_neb=True or add_dust_emission=True, CERIDWEN reads those files directly from $SPS_HOME (FSPS itself is not run at fit time; it just provides the data).

FSPS is not a pure-Python wheel: it needs a Fortran compiler and a clone of the FSPS data files.

# 1. A Fortran compiler (pick one for your system):
brew install gcc                       # macOS (Homebrew)
sudo apt-get install gfortran          # Debian/Ubuntu
conda install -c conda-forge gfortran  # any OS, inside your conda env

# 2. Pick where the FSPS data should live (ANY path: $HOME, a data disk, cluster
#    scratch, ...). git clone writes to the absolute $SPS_HOME path, so it does
#    not matter which directory you run it from.
export SPS_HOME="$HOME/fsps"           # <- edit to your chosen location
git clone https://github.com/cconroy20/fsps.git "$SPS_HOME"

# 3. Install the Python wrapper (it compiles against $SPS_HOME):
python -m pip install "fsps>=0.4.4"

Make $SPS_HOME permanent

python-fsps needs $SPS_HOME in every shell session and fails to import without it. Add it to your shell startup file (use the same path as above):

echo 'export SPS_HOME="$HOME/fsps"' >> ~/.zshrc   # zsh (macOS default)
echo 'export SPS_HOME="$HOME/fsps"' >> ~/.bashrc  # bash (most Linux)

Open a new terminal and check echo $SPS_HOME prints the path.

Verify your setup

With FSPS installed and $SPS_HOME set, run the environment doctor before your first fit:

python -m ceridwen.check

It prints an ok / warn / FAIL line per component (dependencies, FSPS, $SPS_HOME, nested-sampling support) with the fix for anything missing. Run it only after FSPS is set up. Before that it will correctly report python-fsps as missing.