Open Source Code used in arxiv:2409.11163
After cloning the repository, create a new conda environment with the provided YAML file
cd frb_horndeski_forecast
conda env create -f env.yml
conda activate frb_horndeski_forecast
Then, we need to install the provided
cd external_packages
tar -xf hi_class_public_modified.tar.gz
cd hi_class_public
make clean
make
This repository contains three major parts, which are all computationally expensive: Simulation, Training and MCMC sampling.
Simulation of (non-)linear matter power spectrum
python simulation/pk_sim_main.py
The code saves the initial parameter suggestion as "raw_lhc_params.npy", and the successfull simulations and their parameters are stored on the fly in "hiclass_pk_simulation.h5py" and "hiclass_param_dict.h5py", respectively.
The training and testing data of our paper is saved on on OneDrive and can be downloaded here. To train a model with it, download the tar and extract the contents (folders "training" and "validation") into
simulation/output_files/
The
python training/pk_training_script.py
to train the model on the data contained in "simulation/output_files/training/". Our pretrained models are stored in "training/trained_models"; feel free to use them.
Run
python mcmc/likelihood_MCMC_NN_main.py
with your preferred settings put into the .py file. The script will look for the cosmopower models inside "training/trained_models/" and use them for the sampling. A minimal working example for calling the models is provided in the notebook "trained_cp_call.ipynb".
Feel free to use and adapt this code however you like, but please cite our paper and the corresponding packages you use (cosmopower, hi_class, nautilus, pyccl, hmcode).