Installation

The OpenCosmo library is available for Python 3.11 and later on Linux and MacOS (and Windows via WSL). It can be installed with pip:

pip install opencosmo

There’s a good chance the default version of Python on your system is less than 3.11. Whether or not this is the case, we recommend installing opencosmo into a virtual environment. If you’re using Conda you can create a new environment and install opencosmo into it automatically:

conda create -n opencosmo_env python=3.11 conda-forge::opencosmo

or, if you already have a virtual environment you’d like to use:

conda install conda-forge::opencosmo

If you plan to use opencosmo in a Jupyter notebook, you can install the ipykernel package to make the environment available as a kernel:

conda install ipykernel
python -m ipykernel install --user --name=opencosmo

Be sure you have run the activate command shown above before running the ipykernel command.

If you are interested in the tools in the analysis module, they need to be installed seperately:

opencosmo install haloviz

Note that the analysis tools must be installed with pip

Installing with MPI Support

opencosmo can leverage MPI to distribute analysis on a very large dataset across multiple cores or nodes. You simply need to install the mpi4py package:

pip install mpi4py

opencosmo Can both read and write data in an MPI context with no additional setup. By default, ranks must write to the file one at a time. This may result in poor performance if the data being written is large. This can be improved by installing the h5py package with MPI support. Pre-built wheels with MPI support are not generally available on PyPI, so you will need to build h5py from source against a version of the HDF5 library that was built with MPI support. Many HPC systems have an optimized MPI-enabled version of HDF5 available. For example, on Polaris at the Argonne Leadership Computing Facility (ALCF), run the follwing commands in the Python environment you plan to use with opencosmo:

pip uninstall h5py # If a non-MPI version is already installed in your environment
HDF5_MPI="ON" HDF5_DIR=$HDF5_DIR  CC="cc" pip install --no-cache-dir --force-reinstall --no-binary=h5py h5py

Parallel HDF5 is also available at NERSC and OLCF. See the linked documentation for details of getting your environment set up at one of those facilities.