Supporting Libraries
Two Python packages are useful when working with the OpenCosmo Compute Portal: opencosmo-portal for portal access and opencosmo for reading and analyzing returned data.
OpenCosmo Portal CLI
The opencosmo-portal package installs the ocp command. It provides command-line access to OpenCosmoPortal and a local MCP server for AI assistants.
Use ocp to manage portal profiles, authenticate, browse documentation, discover tasks, submit task runs, monitor run status, retrieve results, and start the local MCP server.
Install it with Python 3.11 or later:
python -m pip install opencosmo-portal
Package and project links:
After installing ocp, see submitting tasks for profile setup, authentication, task submission, and MCP examples.
OpenCosmo Python Toolkit
The OpenCosmo Python Toolkit is the opencosmo package. It reads, writes, queries, and manipulates OpenCosmo data files, including HDF5 files returned by portal tasks.
The toolkit provides lazy datasets and collections, cosmology-aware data access, Astropy integration, and post-processing tools for downloaded portal results. It is the recommended library for continuing analysis after a portal query finishes.
If you install both opencosmo-portal and opencosmo in the same environment, use Python 3.12 or later.
Install with pip:
python -m pip install opencosmo
Install with Conda:
conda create -n opencosmo_env python=3.12 conda-forge::opencosmo
conda activate opencosmo_env
If you plan to use OpenCosmo in Jupyter, install an IPython kernel in the active environment:
python -m pip install ipykernel
python -m ipykernel install --user --name=opencosmo
Some optional analysis helpers have additional dependencies. For example, haloviz can be installed with:
opencosmo install haloviz
These optional analysis helpers are not required for reading standard portal output files.
Package, repository, and documentation links:
For examples of opening returned files and applying additional queries, see reading returned data.