Skip to main content
Banner with logo showing a swift in a spiral and the text SWIFTGalaxy.

Python Version from PEP 621 TOML PyPI - Version JOSS doi:10.21105/joss.09278 pyOpenSci Peer-Reviewed ascl:2505.002 Project Status: Active – The project has reached a stable, usable state and is being actively developed. Monthly downloads Zenodo DOI Build Status Documentation Status CodeCov status Ruff

SWIFTGalaxy is an open-source astrophysics module that extends SWIFTSimIO tailored to analyses of particles belonging to individual galaxies simulated with SWIFT. It inherits from and extends the functionality of the SWIFTDataset. It understands the content of halo catalogues (supported: Velociraptor, Caesar, SOAP) and therefore which particles belong to a galaxy or other group of particles, and its integrated properties. The particles occupy a coordinate frame that is enforced to be consistent, such that particles loaded on-the-fly will match e.g. rotations and translations of particles already in memory. Intuitive masking of particle datasets is also enabled. Utilities to make working in cylindrical and spherical coordinate systems more convenient are also provided. Finally, tools to iterate efficiently over multiple galaxies are also provided.

Installation is as simple as pip install swiftgalaxy.

To install optional dependencies to support Velociraptor catalogues use pip install swiftgalaxy[velociraptor]. For Caesar support use:

pip install git+https://github.com/dnarayanan/caesar.git

No additional dependencies are needed for reading SOAP catalogues. If you want to generate example input files for SOAP, you should install:

pip install git+https://github.com/SWIFTSIM/soap.git

Once installed, creating a SWIFTGalaxy object to get started with analysis is simple! For instance, for a SWIFT simulation with a SOAP-format halo catalogue (an example - 300 MB - will be automatically downloaded):

from swiftgalaxy import SWIFTGalaxy, SOAP
from swiftgalaxy.demo_data import web_examples

sg = SWIFTGalaxy(
    web_examples.virtual_snapshot,
    SOAP(web_examples.soap, soap_index=0)
)

# access data for particles belonging to the galaxy:
sg.gas.temperatures

# access integrated properties from the halo catalogue
sg.halo_catalogue.spherical_overdensity_200_crit.soradius

# automatically generated spherical/cylindrical coordinates:
sg.gas.spherical_coordinates.r

# consistent coordinate transformations of all particles, even those not loaded yet:
from scipy.spatial.transform import Rotation
sg.rotate(Rotation.from_euler("x", 90, degrees=True))

# compatible with swiftsimio visualisation:
import numpy as np
import unyt as u
from swiftsimio import cosmo_array
from swiftsimio.visualisation import project_gas
import matplotlib.pyplot as plt
img = project_gas(
    sg,
    periodic=False,
    resolution=256,
    region=cosmo_array(
        [-30, 30, -30, 30],
        u.kpc,
        comoving=True,
        scale_factor=sg.metadata.a,
        scale_exponent=1
    ),
)
plt.imsave("eagle6_galaxy.png", np.log10(img.T), origin="lower", cmap="inferno")
https://github.com/SWIFTSIM/swiftgalaxy/raw/main/eagle6_galaxy.png

Examples

More usage examples can be found in the examples folder on github.

Citing SWIFTGalaxy

If your use of SWIFTGalaxy leads to a publication, please cite the JOSS paper (ADS listing). You may also cite the swiftgalaxy entry in the ASCL (indexed on ADS). Ideally specify the version used (Zenodo DOI, git commit ID and/or version number) and link to the github repository.

@ARTICLE{2025JOSS...10.9278O,
    author = {{Oman}, Kyle A.},
    title = "{SWIFTGalaxy: a Python package to work with particle groups from SWIFT simulations}",
    journal = {The Journal of Open Source Software},
    keywords = {astronomy, simulations},
    year = 2025,
    month = oct,
    volume = {10},
    number = {114},
    eid = {9278},
    pages = {9278},
    doi = {10.21105/joss.09278},
    adsurl = {https://ui.adsabs.harvard.edu/abs/2025JOSS...10.9278O},
    adsnote = {Provided by the SAO/NASA Astrophysics Data System}
}

@MISC{
    2025ascl.soft05002O,
    author = {{Oman}, Kyle A.},
    title = "{swiftgalaxy}",
    keywords = {Software},
    howpublished = {Astrophysics Source Code Library, record ascl:2505.002},
    year = 2025,
    month = may,
    eid = {ascl:2505.002},
    pages = {ascl:2505.002},
    archivePrefix = {ascl},
    eprint = {2505.002},
    adsurl = {https://ui.adsabs.harvard.edu/abs/2025ascl.soft05002O},
    adsnote = {Provided by the SAO/NASA Astrophysics Data System}
}

Please also consider the citations requested for SWIFTSimIO.

Community

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

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

Metadata

Release files for swiftgalaxy 3.1.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 swiftgalaxy 3.1.0
File Size Uploaded Provenance Actions
swiftgalaxy-3.1.0.tar.gz 2.0 MB With provenance Details for swiftgalaxy-3.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 2.1 MB

Release files / swiftgalaxy-3.1.0.tar.gz

Download URL swiftgalaxy-3.1.0.tar.gz
Size 2.0 MB
Tags Source
SHA-256 checksum
How to use checksums
6c7d5ed20f19da153d8cddb150d5abc5d81852aaffbd2be241ac2fcac9dab007
BLAKE2b-256 checksum
How to use checksums
5b0655426df126e162134a65ca967577e17a642d48aa34a4c06c0a91e30043b5
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 / swiftgalaxy-3.1.0-py3-none-any.whl

Download URL swiftgalaxy-3.1.0-py3-none-any.whl
Size 85.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
21ef9826994020f3768a2af0deeaaf3e30ed71f807f278324c5b6c58a614253f
BLAKE2b-256 checksum
How to use checksums
90db6d83573c4d8984830ae0953546b8e6ca9c218bb476c24b99cb64e12efb8b
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 swiftgalaxy 3.1.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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for swiftgalaxy-3.1.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

3.1.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