Open In Colab

Installation for developers

If you are a developer, you may need to modify the C code and the python wrapper to implement your own functions, or modify existing ones.

CLASS_SZ functionalities are located in the files:

And importantly, in the python and cython files:

To install the C executable, so you can run the C code, you should install from source and compile.

The following instructions should be executed carefully in that order.

git clone https://github.com/CLASS-SZ/class_sz
git clone https://github.com/CLASS-SZ/get_cosmopower_emus.git

cd get_cosmopower_emus
pip install -e .
cd ..

git clone https://github.com/CLASS-SZ/class_sz_data.git
cd class_sz_data
pip install -e .
cd ..

cd class_sz/class-sz/python
git clone https://github.com/CLASS-SZ/classy_szfast
cd ..

chmod +x select_makefile.sh
./select_makefile.sh

chmod +x download_emulators.sh
source download_emulators.sh

export PATH_TO_CLASS_SZ_DATA=$PWD/../class_sz_data_directory

make clean
make -j

cd python/classy_szfast
pip install -e .
cd ../..

export PYTHONPATH=$(pwd)/python/classy_szfast:$PYTHONPATH

Then you should be able to run:

$ python
>>> import classy_sz

And the package should be imported without errors.

Now, for this installation to work next time. You need to save the following environment variables and source the environment file.

First retrieve the environment variables:

echo $PATH_TO_CLASS_SZ_DATA

It should print something like:

/path/to/class_sz/class_sz_data_directory

also the PYTHONPATH:

echo $PYTHONPATH

It should print something like:

/path/to/class_sz/class-sz/python/classy_szfast:

Save the printed path and put the following the environment file (e.g., create a file called .class_sz_env.sh and paste the following in it):

export PATH_TO_CLASS_SZ_DATA=/path/to/class_sz/class_sz_data_directory
export PYTHONPATH=/path/to/class_sz/class-sz/python/classy_szfast:

Of course, you need to replace /path/to/.. with the actual path.

Then, next time you want to work with class_sz, just source the environment file before running python:

source /path/to/.class_sz_env.sh

To run the C code with many power spectra output you can do:

$ ./class_sz class_sz_test.ini

The .ini files are the parameter files.

If you want to run CLASS and not do the class_sz part, you can! For example:

$ ./class_sz explanatory.ini

This will just run the standard CLASS code and its calculations. All depends on what output you request: if you request a class_sz observable or not.