Ceridwen
CERIDWEN is a Python package for Bayesian modelling of galaxy spectral energy distributions (SEDs). It fits photometry, spectra and emission-line fluxes, separately or together, to infer stellar populations, dust properties, nebular emission and star formation histories.
The forward model is written in JAX and runs on CPUs and GPUs. It is differentiable, allowing gradient-based sampling with Hamiltonian Monte Carlo. CERIDWEN also supports Bayesian evidence calculations.
The name stands for Comprehensive SED Estimation Routine Involving Data-driven WEight calculatioNs.
See the documentation to get started, or try the Ingredient Explorer to see how each model ingredient changes a galaxy spectrum in your browser, and to build your first script in a more intuitive way.
Features
Stellar populations and star formation
- Star formation histories defined on a lookback-time grid, using non-parametric continuity (
logsfr_ratios) or a parametric form supplied as a transform. - Constant metallicity or a metallicity history (
zh_const). - Sampling of stellar [α/Fe] with
CSPBasis_afeand the aMIST + C3K grid.
Dust, gas and IGM
- Dust attenuation with Kriek & Conroy diffuse dust, power-law birth clouds, and 12 registered laws, including Calzetti, SMC, LMC, Gordon+03 SMC bar and Reddy+15.
- Dust emission using Draine & Li (2007) or THEMIS templates.
- Nebular continuum and emission lines from the FSPS CLOUDY grids.
- Madau (1995) IGM attenuation, with an optional damping wing and damped Ly-α absorber (
MadauDampingDLA).
AGN
Enable AGN components with CSPBasis(agn=AGNConfig()):
- Nenkova+08 clumpy torus, Temple+21 accretion disc, an AGN dust screen and narrow emission lines.
- Modes that reproduce FSPS and Prospector, alongside a corrected default with exact
fagn * L_bolnormalisation, AGN emission applied before IGM attenuation, and energy balance with dust emission. - CIGALE-style models with a SKIRTOR torus, polar dust, Feltre+16 narrow lines and a broad-line region, including a mode that reproduces CIGALE.
Data and fitting
- Fit photometry, spectra and emission-line fluxes separately or together.
- Use the 296 bundled filter curves, or your own
.parfiles withPhotometry(filter_directory=...)or$CERIDWEN_FILTER_DIR. - Combine stellar and gas velocity dispersions with the instrumental line-spread function in one broadening kernel, automatically accounting for the stellar library’s resolution.
- Analytically marginalise over emission-line fluxes with
Spectrum(marginalize_elines=True). - Model noise and calibration uncertainties with jitter, calibration polynomials, an outlier mixture and a Gaussian-process likelihood for correlated residuals. Calibration polynomials can be sampled, profiled or marginalised.
- Use nested sampling to calculate the Bayesian evidence, sample with NUTS or VI-preconditioned NUTS, or find a maximum a posteriori (MAP) solution.
Results and diagnostics
- Use
PostProcessto calculate star formation rates, M_UV, ionising photon rates and posterior-predictive data, and produce summary, corner and diagnostic plots.
Installation
Use Python 3.12 or newer for the installation below. Follow the instructions for your operating system, then download the FSPS data files and check your installation.
Apple Silicon Mac
1. Check your Mac and Conda installation
Open Terminal (Cmd + Space, type “Terminal”, press Enter), then run:
sw_vers -productVersion
conda info | grep platform
- macOS: Apple GPU support requires 26 or newer. To update, open System Settings → General → Software Update. Older versions can use the CPU.
- Conda:
osx-arm64means you have the correct build. If you seeosx-64orcommand not found: conda, install Miniforge below.
The Conda platform describes your software, not your Mac’s hardware. To check the hardware, open Apple menu → About This Mac: Chip: Apple M… means Apple Silicon; Processor: Intel… means an Intel Mac. Intel Macs are not supported by the JAX version CERIDWEN requires.
Install Miniforge for Apple Silicon
Run these commands in Terminal:
curl -L -o Miniforge3-MacOSX-arm64.sh https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-arm64.sh
bash Miniforge3-MacOSX-arm64.sh
Follow the prompts: accept the licence and default installation location, and answer yes when asked to initialise Conda. Quit Terminal with Cmd + Q, reopen it, and check:
conda info | grep platform
It should show osx-arm64. If it still shows osx-64, run the following, then quit and reopen Terminal again:
~/miniforge3/bin/conda init zsh
2. Create an environment and install CERIDWEN
These commands create an environment with Python 3.12:
conda create -n ceridwen python=3.12 -y
conda activate ceridwen
pip install ceridwen
On an Apple Silicon Mac with macOS 26 or newer and native arm64 Python 3.12 or newer, this also installs jax-graft to enable Apple GPU support. Older macOS versions use the CPU.
No additional GPU configuration is needed. When you import CERIDWEN, it detects the GPU, switches to float32 precision, and prints a message once. When you run fitSED, you should see:
Device : MTL
Precision : float32
Apple GPUs do not support float64. Evidence values, gradients, and samples are therefore computed in float32 and will not match a float64 fit bit for bit. See the Apple GPU guide (docs/mac_gpu.md) for the guarantees and limitations of this mode.
To run a float64 fit on the CPU instead, set this variable before starting Python or Jupyter:
export JAX_PLATFORMS=cpu
Continue with Download the FSPS data files below.
Linux
1. Create an environment
With Conda installed, open a terminal and run:
conda create -n ceridwen python=3.12 -y
conda activate ceridwen
2. Install CERIDWEN
Choose one installation option.
CPU:
pip install ceridwen
NVIDIA GPU with CUDA 12 — requires NVIDIA driver 525 or newer:
pip install "ceridwen[cuda12]"
NVIDIA GPU with CUDA 13 — requires NVIDIA driver 580 or newer:
pip install "ceridwen[cuda13]"
To check your NVIDIA driver version, run:
nvidia-smi
The CUDA libraries are installed automatically through pip; you still need a compatible NVIDIA GPU and driver. See the JAX installation guide for compatibility details. These NVIDIA installation options also apply to Linux running under WSL2 on Windows.
Download the FSPS data files — all users
CERIDWEN reads its nebular CLOUDY grids and dust-emission templates from the FSPS data files. Download FSPS and set SPS_HOME to its location. Allow approximately 3.4 GB for the download.
export SPS_HOME="$HOME/fsps"
git clone --depth 1 https://github.com/cconroy20/fsps.git "$SPS_HOME"
To save SPS_HOME for future terminal sessions, run one of the following commands.
For zsh, the default shell on macOS:
echo 'export SPS_HOME="$HOME/fsps"' >> ~/.zshrc
For bash, commonly used on Linux:
echo 'export SPS_HOME="$HOME/fsps"' >> ~/.bashrc
You only need to compile the python-fsps wrapper if you want to build your own SSP grid. To fit data, the published grids and the FSPS data files are sufficient. See the full installation guide for details.
Check the installation — all users
With the ceridwen environment active, run:
python -m ceridwen.check
This prints one line per component and explains how to fix anything missing. A warning about python-fsps is expected if you have not compiled the wrapper; you can ignore it when using the published SSP grids.
Try an example
The notebooks in examples/ walk through fitting mock data:
apple_gpu_mock_fit.ipynbcreates a mock galaxy, fits it on the Apple GPU, and shows the recovered parameters.- The
mock_fit_*.ipynbnotebooks cover photometry alone, photometry with line fluxes, a spectrum alone, and a spectrum calibrated against photometry.
Stay up to date
fitSED and ceridwen.check notify you when a newer version is available on PyPI. To disable these checks, set:
export CERIDWEN_NO_UPDATE_CHECK=1
To receive release notifications through GitHub, select Watch → Custom → Releases at the top of this repository. Email delivery depends on your GitHub notification settings.
Verification
The test suite checks units and conventions, the broadening against direct quadrature, the
likelihoods, the samplers, post-processing and the misuse guards. Two layers compare the
forward model with stored arrays: 22 regression categories (plus optional ones that need a grid or the AGN tables) at
rtol=2e-6 (AGN lines 2e-5) with an absolute tolerance of 1e-10 times each array's maximum
(tests/regression/test_regression.py), and 13 golden configurations (SFH and
metallicity, AGN, and a fixed nebular block; tests/csp/test_lookback_flip_invariant.py) with
SSP weights at rtol=1e-12 and spectra, line fluxes and photometry at rtol=1e-6. See
For developers to run them.
Documentation
- Tutorial: photometry, a spectrum and emission lines fitted jointly
- Samplers: nested sampling, NUTS, VI-preconditioned NUTS, the MAP, resuming a run
- Post-processing: derived quantities, predictions, figures
- Noise and calibration: jitter, error floors, calibration polynomials
- GP likelihood: correlated spectral residuals
- Outlier model: a mixture likelihood for bad data points
- Emission-line marginalisation
- α/Fe: the α-enhanced grid and
CSPBasis_afe - AGN: torus, disc, AGN screen and lines; the modes and their parity with FSPS, Prospector and CIGALE (SKIRTOR, polar dust, Feltre+16 NLR, BLR)
- Conventions: units, metallicity, lookback time, broadening, cosmology
- Troubleshooting
- Development and verification: every check, and how the code is built
- API reference
GOTCHAS.md: the misuse guide;AGENTS.md: conventions for AI assistants
For developers
Clone the repository and install CERIDWEN in editable mode so that changes to the code take effect without reinstalling:
git clone --depth 1 https://github.com/Espe13/ceridwen.git
cd ceridwen
pip install -e .
--depth 1 downloads only the latest version, reducing the download from 244 MB to 41 MB. For an NVIDIA GPU, replace the last command with pip install -e ".[cuda12]".
Running the tests
First, download the published BPASS grid and tell the tests where to find it:
export CERIDWEN_TEST_SSP=$(python -c "from ceridwen.ssps import fetch_grid; print(fetch_grid('mist_bpass_v2'))")
Run the same tests as CI:
pytest -m "not fsps and not gpu" -q -ra
As a guide, this took about 33 minutes on an 11-core laptop CPU while other jobs were running.
To also compare the forward model against the stored reference results, run the following with SPS_HOME set:
pytest tests/regression/test_regression.py tests/csp/test_lookback_flip_invariant.py -q
Check the skip summary: tests that need a grid are skipped if the grid is missing. See the development guide for the full list of checks and details of the code.
Run scripts from inside the repository or another working directory. Avoid running them from the directory immediately above the clone, where Python may find the ceridwen folder instead of the installed package.
Citing
If you use CERIDWEN in your research, please cite it:
@misc{stoffers2026ceridwen,
author = {Stoffers, Amanda},
title = {{CERIDWEN}: Fast and Flexible {GPU}-Accelerated Stellar Population Inference},
year = {2026},
note = {Version 1.0.15},
howpublished = {\url{https://github.com/Espe13/ceridwen}}
}
License
MIT; see LICENSE.
Metadata
Release files for ceridwen 1.0.15
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ceridwen-1.0.15.tar.gz | 4.0 MB | Without provenance | Details for ceridwen-1.0.15.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ceridwen-1.0.15-py3-none-any.whl | Python 3 | none | any | Details for ceridwen-1.0.15-py3-none-any.whl |
Total release size: 8.0 MB
Release files / ceridwen-1.0.15.tar.gz
| Download URL | ceridwen-1.0.15.tar.gz |
|---|---|
| Size | 4.0 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9ada0edf12d71baf36a576b51c0ae90c240bf07447c4d351b12de3ff312fc0f6
|
|
BLAKE2b-256 checksum How to use checksums |
0bb48c5e8ed44d4851e70422ce4e65c84df4af5142b822e2f2f75b158be768bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.14
|
Release files / ceridwen-1.0.15-py3-none-any.whl
| Download URL | ceridwen-1.0.15-py3-none-any.whl |
|---|---|
| Size | 4.1 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a31eec2b2e79dc95025de8613786851c99bb306bc9e4138fc193baa65bcc7ff5
|
|
BLAKE2b-256 checksum How to use checksums |
7d8271c26212fb717d66da723cbd1534060daa4a37fe8bc5e2b5e9927da8c91c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.14
|
Security for ceridwen 1.0.15
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.