- Added support for linear regime of
$P(k)$ ($-4<\log_{10}(k)<0$ ). - Added support for Fast Emulation without boosts and computations of fiducial cosmology, so the emulator can be used for more complicated computations, e.g.
$C_\ell$ ,$\xi_{\pm}$ . - Strenthened the performance of the emulator with more smoothed boosts (less noise) where the fiducial non-linear power spectra contain massive neutrinos.
- Halo Mass Functions (HMFs)! (TBD)
Instantiate:
- emu = emulator()
Important instance attributes created at init:
- emu.ks : numpy array of the emulator's internal k-grid (logspace from 1e-4 to 1e0, length 1024)
- emu.scaler, emu.scaler_boost : scalers loaded from cache files
- emu.model and emu.boost_model{0,05,1,2,3} : PyTorch models (weights loaded from cache)
Methods:
- set_cosmo(Om=0.3, Ob=0.05, h=0.7, ns=1.0, mnu=0.05, fR0=-3e-5, As=2e-9, redshifts=[3.0,2.0,1.0,0.5,0.0], use_emu=False)
- Purpose: Set cosmological parameters for subsequent get_boost / get_power_spectrum calls.
- Parameters:
- Om : Omega_matter
- Ob : Omega_baryon
- h : reduced Hubble parameter (H0 = 100 * h km/s/Mpc)
- ns : scalar spectral index
- mnu : sum of neutrino masses (eV)
- fR0 : modified gravity parameter (example defaults in code)
- As : scalar amplitude of primordial power spectrum
- redshifts : list used to set CAMB matter power evaluation when use_emu=False
- use_emu : if True, the emulation model predicts P(k) directly (no CAMB); if False (default) the code uses CAMB to compute a fiducial P(k) and multiplies by the boost predicted by the ANN.
- Side effects:
- If use_emu is False, set_cosmo constructs CAMB parameters and stores a matter power interpolator in emu.mpi (results.get_matter_power_interpolator).
- get_k_values()
- Returns emu.ks, the internal k-grid used by the ANN (np.logspace(-4, 0, 1024)).
- get_boost(k=None, z=None, return_k_values=False)
- Purpose: Return the multiplicative boost factor B(k,z) for modified gravity relative to the fiducial matter power spectrum.
- Parameters:
- k : array-like of wavenumbers. If None, uses emulator internal k-grid (emu.ks).
- z : redshift (float). If None, default z=0.0 (the function warns).
- return_k_values : if True, the code attempts to include k values together with the boost (see I/O/format notes).
- Behavior:
- The method scales the cosmology parameters with the boost scaler, feeds them to the five trained boost ANNs (trained at z = 0.0, 0.5, 1.0, 2.0, 3.0), interpolates the ANN outputs across redshift with a cubic spline, then interpolates the result in k using a cubic spline on the internal k-grid.
- Valid z range:
- z must be in [0.0, 3.0]. The code checks redshift ranges and raises ValueError if outside.
- get_power_spectrum(k=None, z=None, return_k_values=False)
- Purpose: Return the nonlinear matter power spectrum P(k,z) in the modified gravity model (as predicted by the emulator + CAMB or by the ANN directly).
- Parameters:
- k : array-like of wavenumbers. If None, uses emulator internal k-grid.
- z : redshift (float). If None, default z=0.0 (the function warns).
- return_k_values : if True, the code attempts to include k values together with P(k) (see I/O/format notes).
- Behavior:
- If emu.use_emu == True: the ANN (model) predicts log10(P) (in the code Pk is reconstructed from principal components and mean), the method exponentiates the interpolated output (10**(...)) and returns P(k).
- If emu.use_emu == False: compute fiducial pk_fid = emu.mpi.P(z,k) via CAMB, compute boost via get_boost, and return pk_fid * boost.