Skip to main content

OpenCosmo


CI PyPI - Version Conda Version GitHub License

The OpenCosmo Python Toolkit provides utilities for reading, writing and manipulating data from cosmological simulations produced by the Cosmolgical Physics and Advanced Computing (CPAC) group at Argonne National Laboratory. It can be used to work with smaller quantities data retrieved with the CosmoExplorer, as well as the much larget datasets these queries draw from. The OpenCosmo toolkit integrates with standard tools such as AstroPy, and allows you to manipulate data in a fully-consistent cosmological context.

Installation

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

pip install opencosmo

There's a good chance the default version of Python on your system is less than 3.12. 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 conda-forge::opencosmo
conda activate opencosmo_env

or if you already have a virtual environment 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:

pip install ipykernel # can also be installed with conda
python -m ipykernel install --user --name=opencosmo

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

Getting Started

To get started, download the "haloproperites.hdf5" from the OpenCosmo Google Drive. This file contains properties of dark-matter halos from a small hydrodynamical simulation run with HACC. You can easily open the data with the open command:

import opencosmo as oc

dataset = oc.open("haloproperties.hdf5")
print(dataset)
OpenCosmo Dataset (length=237441)
Cosmology: FlatLambdaCDM(name=None, H0=<Quantity 67.66 km / (Mpc s)>, Om0=0.3096446816186967, Tcmb0=<Quantity 0. K>, Neff=3.04, m_nu=None, Ob0=0.04897468161869667)
First 10 rows:
block fof_halo_1D_vel_disp fof_halo_center_x ... sod_halo_sfr unique_tag
             km / s               Mpc        ... solMass / yr
int32       float32             float32      ...   float32      int64
----- -------------------- ----------------- ... ------------ ----------
    0            32.088795         1.4680439 ...       -101.0      21674
    0             41.14525        0.19616994 ...       -101.0      44144
    0             73.82962         1.5071135 ...    3.1447952      48226
    0             31.17231         0.7526525 ...       -101.0      58472
    0            23.038841         5.3246417 ...       -101.0      60550
    0            37.071426         0.5153746 ...       -101.0     537760
    0            26.203058         2.1734374 ...       -101.0     542858
    0              78.7636         2.1477687 ...          0.0     548994
    0             37.12636         6.9660196 ...       -101.0     571540
    0             58.09235          6.072006 ...    1.5439711     576648

The open function returns a Dataset object, which can retrieve the relevant data from disk with a simple method call. It also holds metadata about the simulation, such as the comsology. You can easily access the data and cosmology as Astropy objects:

dataset.get_data()
dataset.cosmology

The first will return an astropy table of the data, with all associated units already applied. The second will return the astropy cosmology object that represents the cosmology the simulation was run with.

Basic Querying

Although you can access data directly, opencosmo provides tools for querying and transforming the data in a fully cosmology-aware context. For example, suppose we wanted to plot the concentration-mass relationship for the halos in our simulation above a certain mass. One way to perform this would be as follows:

dataset = dataset
    .filter(oc.col("fof_halo_mass") > 1e13)
    .take(1000, at="random")
    .select(("fof_halo_mass", "sod_halo_cdelta"))

print(dataset)
OpenCosmo Dataset (length=1000)
Cosmology: FlatLambdaCDM(name=None, H0=<Quantity 67.66 km / (Mpc s)>, Om0=0.3096446816186967, Tcmb0=<Quantity 0. K>, Neff=3.04, m_nu=None, Ob0=0.04897468161869667)
First 10 rows:
 fof_halo_mass   sod_halo_cdelta
    solMass
    float32          float32
---------------- ---------------
11220446000000.0       4.5797048
17266723000000.0       7.4097505
51242150000000.0       1.8738283
70097712000000.0       4.2764015
51028305000000.0        2.678151
11960567000000.0       3.9594727
15276915000000.0        5.793542
16002001000000.0       2.4318497
47030307000000.0       3.7146702
15839942000000.0        3.245569

We could then plot the data, or perform further transformations. This is cool on its own, but the real power of opencosmo comes from its ability to work with different data types. Go ahead and download the "haloparticles" file from the OpenCosmo Google Drive and try the following:

import opencosmo as oc

data = oc.open("haloproperties.hdf5", "haloparticles.hdf5")

This will return a data collection that will allow you to query and transform the data as before, but will associate the halos with their particles.

data = data
    .filter(oc.col("fof_halo_mass") > 1e13)
    .take(1000, at="random")

for halo in data.halos():
    halo_properties = halo["halo_properties"]
    dm_particles = halo["dm_particles"]
    star_particles = halo["star_particles"]

In each iteration, "halo properties" will be a dictionary containing the properties of the halo (such as its total mass), while "dm_particles" and "star_particles" will be OpenCosmo datasets containing the dark matter and stars associated with the halo, respectively. Because these are just like the dataset object we saw eariler, we can further query and transform the particles as needed for our analysis. For more details on how to use the library, check out the full documentation.

Testing

To run tests, first download the test data from Google Drive. Extract it into test_data/ at the repository root, or set OPENCOSMO_DATA_PATH to an extracted data directory elsewhere. See test/TEST_DATA.md for the expected layout. Then run the tests with pytest:

export OPENCOSMO_DATA_PATH=/path/to/data
# From the repository root
pytest --ignore test/parallel 

Although opencosmo does support multi-core processing via MPI, the default installation does not include the necessary dependencies to work in an MPI environment. If you need these capabilities, check out the guide in our documentation.

Contributing

We welcome bug reports and feature requests from the community. If you would like to contribute to the project, please check out the contributing guide for more information.

Citation

If you use OpenCosmo in your work, please cite the release paper in any publications:

@article{wells2026_opencosmo,
      title={OpenCosmo: Community Portal and Analysis Framework for Flagship Cosmological Simulations}, 
      author={Patrick R. Wells and Michael Buelhmann and Patricia Larsen and William M. Hicks and Manpreet Dhillon and Idunnuoluwa A. Adeniji and Katrin Heitmann and Salman Habib and Benoit Côté and Thomas Uram and Gideon McFarland and Andrew Hearin and Ezar Shinabro and Michael E. Papka},
      year={2026},
      eprint={2607.16059},
      archivePrefix={arXiv},
      primaryClass={astro-ph.IM},
      url={https://arxiv.org/abs/2607.16059}, 
}

Release files for opencosmo 1.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for opencosmo 1.4.1
File
opencosmo-1.4.1-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.17+ x86-64 Details
opencosmo-1.4.1-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.14 CPython 3.14 Linux glibc 2.17+ ARM64 Details
opencosmo-1.4.1-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details
opencosmo-1.4.1-cp314-cp314-macosx_10_12_x86_64.whl CPython 3.14 CPython 3.14 macOS 10.12+ x86-64 Details
opencosmo-1.4.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ x86-64 Details
opencosmo-1.4.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ ARM64 Details
opencosmo-1.4.1-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
opencosmo-1.4.1-cp313-cp313-macosx_10_12_x86_64.whl CPython 3.13 CPython 3.13 macOS 10.12+ x86-64 Details
opencosmo-1.4.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64 Details
opencosmo-1.4.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ ARM64 Details
opencosmo-1.4.1-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
opencosmo-1.4.1-cp312-cp312-macosx_10_12_x86_64.whl CPython 3.12 CPython 3.12 macOS 10.12+ x86-64 Details

Total release size: 7.2 MB

Release files / opencosmo-1.4.1-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL opencosmo-1.4.1-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 621.6 kB
Tags CPython 3.14 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
f6fb227d844018d2ba535e74c38d876662e41949c0c814c4900c38f440b3cc0a
BLAKE2b-256 checksum
How to use checksums
859547a7871b859cbead0ee3e910d46fa4c92431f09ceb117683ecf8f67f5fd5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.2

Release files / opencosmo-1.4.1-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL opencosmo-1.4.1-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 613.6 kB
Tags CPython 3.14 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
7185465f3d9fc2baab95197fb66324d03b3c020831b770d7382801066c6807cd
BLAKE2b-256 checksum
How to use checksums
a6ecd9ed949f57b6f1cf07b7dfd745052643fd92dcbba9cd27b79d42b05a9953
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.2

Release files / opencosmo-1.4.1-cp314-cp314-macosx_11_0_arm64.whl

Download URL opencosmo-1.4.1-cp314-cp314-macosx_11_0_arm64.whl
Size 577.0 kB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
68fafcad17c83e5b813972b14769c763245c1b86aa4a32c23dc717a65570c418
BLAKE2b-256 checksum
How to use checksums
5c559ac1e5f416fe2a51f268d479ff2282f0b7cb0920bac22b60ce61de4b0b19
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.2

Release files / opencosmo-1.4.1-cp314-cp314-macosx_10_12_x86_64.whl

Download URL opencosmo-1.4.1-cp314-cp314-macosx_10_12_x86_64.whl
Size 582.4 kB
Tags CPython 3.14 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
1be94b58dfb08c3bec4c9f0e0e49f43aa230b3aba1ab670293a9c6054012371c
BLAKE2b-256 checksum
How to use checksums
27fe2b84f02994c82c87cb501f2bea444558793d9f33aec815fa8f93911c49fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.2

Release files / opencosmo-1.4.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL opencosmo-1.4.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 621.5 kB
Tags CPython 3.13 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
90fbe844580ee1abf789b88046d5b2b25de35b60410388a7e7ada91baf622981
BLAKE2b-256 checksum
How to use checksums
e0ed350ef61bae7e4a153453214c458332bf30a3f19d82d75bb1f1b752b2bb0a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.2

Release files / opencosmo-1.4.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL opencosmo-1.4.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 613.3 kB
Tags CPython 3.13 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
2cb37f26f633410d1d9154e5ebf3c8f66ba89cedf097e4c4068f07074c658ee8
BLAKE2b-256 checksum
How to use checksums
21f5da2ba3ca6d3f4f7da73d7fec680eece3f23eae7b1413d5d58d89abd3c11e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.2

Release files / opencosmo-1.4.1-cp313-cp313-macosx_11_0_arm64.whl

Download URL opencosmo-1.4.1-cp313-cp313-macosx_11_0_arm64.whl
Size 576.2 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
50c5967749dcdd018e50e0da286492f1f82e8dd89527d59818ca6972bdd96fb7
BLAKE2b-256 checksum
How to use checksums
6017cdda570bf9f95b4149294d5a6b62301d77262f9c8bc8bcd9f083bcfe8b88
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.2

Release files / opencosmo-1.4.1-cp313-cp313-macosx_10_12_x86_64.whl

Download URL opencosmo-1.4.1-cp313-cp313-macosx_10_12_x86_64.whl
Size 582.1 kB
Tags CPython 3.13 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
532b25ebd283f8475555d6e1c315b9c30ad91f6f16f13424755875f2526feea8
BLAKE2b-256 checksum
How to use checksums
6fd392b290ab757a68fc72901e3dae9fefbd0fe2b8fd7a018fbab6c6fff4474e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.2

Release files / opencosmo-1.4.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL opencosmo-1.4.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 621.0 kB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
d4a0d24af96bfb1c265f7213c721f59998d6216d5c91dc698f095a1dbc58220d
BLAKE2b-256 checksum
How to use checksums
56ad4986b2933e4049717eacf506a7347cd1b1760d48d44bbf756c24c2daa72d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.2

Release files / opencosmo-1.4.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL opencosmo-1.4.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 613.0 kB
Tags CPython 3.12 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
9f5609b6dde489fd036b2cfa64286f38135ebc85c48cc4a9c0e25e16117669f3
BLAKE2b-256 checksum
How to use checksums
51c2ee961bb55af5c62a3431df0758e918198f61597c6332f91238beec90cf6a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.2

Release files / opencosmo-1.4.1-cp312-cp312-macosx_11_0_arm64.whl

Download URL opencosmo-1.4.1-cp312-cp312-macosx_11_0_arm64.whl
Size 576.5 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
8dbe08e5094d0b1c471ceb56f938ff708bb0362dcdb4c3e5ed39f1d024180fee
BLAKE2b-256 checksum
How to use checksums
b5d58cdc5682b3d3244f8fbf7b326eda441da995145061f3eb20d708ecb4bed0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.2

Release files / opencosmo-1.4.1-cp312-cp312-macosx_10_12_x86_64.whl

Download URL opencosmo-1.4.1-cp312-cp312-macosx_10_12_x86_64.whl
Size 582.2 kB
Tags CPython 3.12 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
d803b9fabce90393aa1296cc9ee1c41ad1991e5a13df11bbea632263262a643b
BLAKE2b-256 checksum
How to use checksums
5bab5f4834a15bcf801a289e9f1f06ca004211910b84cb734367b1638b2cbe29
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.2

Release history Release notifications | RSS feed

This release

1.4.1 This release

12 release files

1.4.0

12 release files

1.3.9

12 release files

1.3.8

12 release files

1.3.7

12 release files

1.3.5

12 release files

1.3.1

12 release files

1.2.7

2 release files

1.2.6

2 release files

1.2.5

2 release files

1.2.4

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.9.6

2 release files

0.9.5

2 release files

0.9.4

2 release files

0.9.3

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page