{ "cells": [ { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "view-in-github" }, "source": [ "\"Open\n" ] }, { "cell_type": "markdown", "metadata": { "id": "sQTPD6PrqLMN" }, "source": [ "# Installation for developers" ] }, { "cell_type": "markdown", "metadata": { "id": "npBlA6RtqHjs" }, "source": [ "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. \n", "\n", "CLASS_SZ functionalities are located in the files:\n", "\n", "- [**source/class_sz.c**](https://github.com/CLASS-SZ/class_sz/blob/master/class-sz/source/class_sz.c) for the main CLASS_SZ functions,\n", "- [**tools/class_sz_tools.c**](https://github.com/CLASS-SZ/class_sz/blob/master/class-sz/tools/class_sz_tools.c) for other useful routines,\n", "- [**source/class_sz_clustercounts.c**](https://github.com/CLASS-SZ/class_sz/blob/master/class-sz/source/class_sz_clustercounts.c) for tSZ cluster counts. Since March 2024, CLASS_SZ cluster counts calculations are superseded by [cosmocnc](https://github.com/inigozubeldia/cosmocnc) ([Zubeldia & Bolliet 2024](https://arxiv.org/abs/2403.09589)).\n", "\n", "And importantly, in the python and cython files:\n", "\n", "- [**python/classy.pyx**](https://github.com/CLASS-SZ/class_sz/blob/master/class-sz/python/classy.pyx) for the Python wrapper,\n", "- [**classy_szfast/classy_szfast.py**](https://github.com/CLASS-SZ/classy_szfast/blob/master/classy_szfast/classy_szfast.py) for the Python wrapper for the emulators,\n", "- [**classy_szfast/classy_sz.py**](https://github.com/CLASS-SZ/classy_szfast/blob/master/classy_szfast/classy_sz.py) for the Python wrapper for cobaya,\n", "- [**classy_szfast/cosmosis_classy_szfast_interface.py**](https://github.com/CLASS-SZ/classy_szfast/blob/master/python/classy_szfast/cosmosis_classy_szfast_interface.py) for the Python wrapper for cosmosis. \n", "\n", "To install the C executable, so you can run the C code, you should install from source and compile.\n", "\n", "The following instructions should be executed carefully in that order. \n", "\n", "```bash\n", "\n", "git clone https://github.com/CLASS-SZ/class_sz\n", "git clone https://github.com/CLASS-SZ/get_cosmopower_emus.git\n", "\n", "cd get_cosmopower_emus\n", "pip install -e .\n", "cd ..\n", "\n", "git clone https://github.com/CLASS-SZ/class_sz_data.git\n", "cd class_sz_data\n", "pip install -e .\n", "cd ..\n", "\n", "cd class_sz/class-sz/python\n", "git clone https://github.com/CLASS-SZ/classy_szfast\n", "cd ..\n", "\n", "chmod +x select_makefile.sh\n", "./select_makefile.sh\n", "\n", "chmod +x download_emulators.sh\n", "source download_emulators.sh\n", "\n", "export PATH_TO_CLASS_SZ_DATA=$PWD/../class_sz_data_directory\n", "\n", "make clean \n", "make -j \n", "\n", "cd python/classy_szfast\n", "pip install -e .\n", "cd ../..\n", "\n", "export PYTHONPATH=$(pwd)/python/classy_szfast:$PYTHONPATH\n", "```\n", "\n", "Then you should be able to run: \n", "\n", "```bash\n", "$ python\n", ">>> import classy_sz\n", "```\n", "\n", "And the package should be imported without errors.\n", "\n", "\n", "\n", "Now, for this installation to work next time. You need to save the following environment variables and source the environment file. \n", "\n", "First retrieve the environment variables: \n", "\n", "```bash\n", "echo $PATH_TO_CLASS_SZ_DATA\n", "```\n", "It should print something like:\n", "\n", "```bash\n", "/path/to/class_sz/class_sz_data_directory\n", "```\n", "\n", "also the PYTHONPATH:\n", "\n", "```bash\n", "echo $PYTHONPATH\n", "```\n", "\n", "It should print something like:\n", "\n", "```bash\n", "/path/to/class_sz/class-sz/python/classy_szfast:\n", "```\n", "\n", "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):\n", "\n", "```bash\n", "export PATH_TO_CLASS_SZ_DATA=/path/to/class_sz/class_sz_data_directory\n", "export PYTHONPATH=/path/to/class_sz/class-sz/python/classy_szfast:\n", "```\n", "\n", "Of course, you need to replace `/path/to/..` with the actual path. \n", "\n", "Then, next time you want to work with class_sz, just source the environment file before running python:\n", "\n", "```bash\n", "source /path/to/.class_sz_env.sh\n", "```\n", "\n", "\n", "\n", "\n", "To run the C code with many power spectra output you can do:\n", "\n", "```bash\n", "$ ./class_sz class_sz_test.ini\n", "```\n", "\n", "The `.ini` files are the parameter files.\n", "\n", "If you want to run CLASS and not do the class_sz part, you can! For example:\n", "\n", "```bash\n", "$ ./class_sz explanatory.ini\n", "```\n", "\n", "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.\n", "\n" ] } ], "metadata": { "colab": { "authorship_tag": "ABX9TyNomB/jTOR9zSFAOAQBc+X9", "include_colab_link": true, "provenance": [] }, "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.9" } }, "nbformat": 4, "nbformat_minor": 4 }