Quick Start
Once installed, you can get a non-linear power spectrum prediction in just a few lines of Python.
The typical workflow involves:
1. Creating a cosmology dictionary using the built-in helper function.
2. Initializing the AletheiaEmu class.
3. Calling the get_pnl() method with your wavenumbers, cosmology, and redshift.
Note
The first time you run emu = AletheiaEmu(), the package will automatically download the large model files (approx. 270-300 MB) to your computer’s cache. This one-time download may take a few minutes. Subsequent runs will be fast.
import numpy as np
from aletheiacosmo import AletheiaEmu
# 1. Define cosmology using the built-in helper
cosmo_params = AletheiaEmu.create_cosmo_dict(
h=0.67,
omega_b=0.0224,
omega_c=0.120,
n_s=0.96,
A_s=2.1e-9,
model='LCDM'
)
# 2. Initialize the emulator (this will be slow the first time)
emu = AletheiaEmu()
# 3. Get the non-linear P(k) at z=1.0
k = np.logspace(-2, 0.3, 100)
z = 1.0
p_nonlinear = emu.get_pnl(k, cosmo_params, z)
# The result is a NumPy array
print(f"Calculated P(k) for {len(k)} k-points at z={z}.")