Skip to main content

SWIFTsimIO

Supported python versions Version released on PyPI Project status: Active - The project has reached a stable, usable state and is being actively developed. Build status Documentation status JOSS publication Ruff

swiftsimio is a toolkit for reading data produced by the SWIFT astrophysics simulation code. It is used to ensure that all data have a symbolic unit attached, and can be used for visualisation. Another key feature is the use of the cell metadata in SWIFT snapshots to enable efficient reading of sub-regions.

The SWIFT astrophysical simulation code is used widely. There exists many ways of reading the data from SWIFT, which outputs HDF5 files. These range from reading directly using h5py to using a complex system such as yt; however these either are unsatisfactory (e.g. a lack of unit information in reading HDF5), or too complex for most use-cases. swiftsimio provides an object-oriented API to dynamically read data from SWIFT outputs, including FOF and SOAP catalogues. An extension module for swiftsimio for using catalogues and snapshots in tandem is available: swiftgalaxy.

Getting set up with swiftsimio is easy; it (by design) has very few requirements. There are a number of optional packages that you can install to make the experience better and these are recommended.

Full documentation is available at ReadTheDocs.

Requirements

Supported python versions is required. Unfortunately it is not possible to support swiftsimio on versions of python lower than this.

Python packages

  • numpy, required for the core numerical routines.

  • h5py, required to read data from the SWIFT HDF5 output files.

  • unyt, required for symbolic unit calculations (depends on sympy``).

  • astropy, required to represent cosmology information.

  • numba, highly recommended should you wish to use the in-built visualisation tools.

Optional packages

  • scipy, required if you wish to generate smoothing lengths for particle types that do not store this variable in the snapshots (e.g. dark matter)

  • tqdm, required for progress bars for some long-running tasks. If not installed no progress bar will be shown.

Installing

swiftsimio can be installed using the pip python packaging manager, or any other packaging manager that you wish to use:

pip install swiftsimio

Usage example

Example usage is shown below, which plots a density-temperature phase diagram, with density and temperature given in CGS units:

import swiftsimio as sw

# This loads all metadata but explicitly does _not_ read any particle data yet
data = sw.load("/path/to/swift/output")

import matplotlib.pyplot as plt

data.gas.densities.convert_to_cgs()
data.gas.temperatures.convert_to_cgs()

plt.loglog()

plt.scatter(
   data.gas.densities,
   data.gas.temperatures,
   s=1
)

plt.xlabel(fr"Gas density $\left[{data.gas.densities.units.latex_repr}\right]$")
plt.ylabel(fr"Gas temperature $\left[{data.gas.temperatures.units.latex_repr}\right]$")

plt.tight_layout()

plt.savefig("test_plot.png", dpi=300)

In the above:

  • All metadata is read in when the swiftsimio.load function is called.

  • Only the densities and temperatures (corresponding to the PartType0/Densities and PartType0/Temperatures) datasets are read in.

  • That data is only read in once the swiftsimio.objects.cosmo_array.convert_to_cgs method is called.

  • swiftsimio.objects.cosmo_array.convert_to_cgs converts data in-place; i.e. it returns None.

  • The data is cached: it is not re-read when plt.scatter is called.

Citing

Please cite swiftsimio using the JOSS paper:

@article{Borrow2020,
  doi = {10.21105/joss.02430},
  url = {https://doi.org/10.21105/joss.02430},
  year = {2020},
  publisher = {The Open Journal},
  volume = {5},
  number = {52},
  pages = {2430},
  author = {Josh Borrow and Alexei Borrisov},
  title = {swiftsimio: A Python library for reading SWIFT data},
  journal = {Journal of Open Source Software}
}

If you use any of the subsampled projection backends, we ask that you cite our relevant SPHERIC paper. Citing the arXiv version here is recommended as the ADS cannot track conference proceedings well.

@article{Borrow2021,
  title={Projecting SPH Particles in Adaptive Environments},
  author={Josh Borrow and Ashley J. Kelly},
  year={2021},
  eprint={2106.05281},
  archivePrefix={arXiv},
  primaryClass={astro-ph.GA}
}

Community

Code contributions are very welcome! A good place to start is the contributing guide and how to set up a development environment.

swiftsimio is licensed under GPL-3.0 and community members are expected to abide by the code of conduct.

Metadata

Release files for swiftsimio 12.4.0

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

Source distribution (sdist)

Source distribution for swiftsimio 12.4.0
File Size Uploaded Provenance
swiftsimio-12.4.0.tar.gz 214.6 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for swiftsimio 12.4.0
File Interpreter ABI Platform
swiftsimio-12.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 408.1 kB

Release files / swiftsimio-12.4.0.tar.gz

Download URL swiftsimio-12.4.0.tar.gz
Size 214.6 kB
Tags Source
SHA-256 checksum
How to use checksums
8f88a77c82daf89191f931ecf87d456b9c3dd2079527d758e7e2523b866bc0dd
BLAKE2b-256 checksum
How to use checksums
7a509313bfe5a532ebd83da99e037b39b6c60abd4d69ba4bfd616615622aff01
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.

Transparency log

Release files / swiftsimio-12.4.0-py3-none-any.whl

Download URL swiftsimio-12.4.0-py3-none-any.whl
Size 193.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c3e30d215b1875d466c69bb206050443fd2a060e822ecfc141fc14a3081c1fcb
BLAKE2b-256 checksum
How to use checksums
604010bd45123a90a6dd64e22b35541d09a8e0693bebc01b1abf5efe6c9a1467
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.

Transparency log

Security for swiftsimio 12.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for swiftsimio-12.4.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

12.4.0 This release

2 release files Full provenance

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