Code abstraction of objects (galaxies) in simulations.
Project description
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")
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file swiftgalaxy-2.3.2.tar.gz.
File metadata
- Download URL: swiftgalaxy-2.3.2.tar.gz
- Upload date:
- Size: 2.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
351e165bf847857707e390002a8b3f14e23aebe160ad8ea9dec26f03f48bf10e
|
|
| MD5 |
f12246fc7194f28d63457f00b89d3db5
|
|
| BLAKE2b-256 |
d684c383f82f32a7aa7422e07251bdc56038be5b5156ab00bdcf242f79e8f4df
|
Provenance
The following attestation bundles were made for swiftgalaxy-2.3.2.tar.gz:
Publisher:
python-publish.yml on SWIFTSIM/swiftgalaxy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
swiftgalaxy-2.3.2.tar.gz -
Subject digest:
351e165bf847857707e390002a8b3f14e23aebe160ad8ea9dec26f03f48bf10e - Sigstore transparency entry: 872300256
- Sigstore integration time:
-
Permalink:
SWIFTSIM/swiftgalaxy@7b41519f3700423190309c36c7e12b4265b39aae -
Branch / Tag:
refs/tags/v2.3.2 - Owner: https://github.com/SWIFTSIM
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@7b41519f3700423190309c36c7e12b4265b39aae -
Trigger Event:
release
-
Statement type:
File details
Details for the file swiftgalaxy-2.3.2-py3-none-any.whl.
File metadata
- Download URL: swiftgalaxy-2.3.2-py3-none-any.whl
- Upload date:
- Size: 81.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c962b7a8ac6feb76c1039fcfe74ac78cae2dda26c8e1aee2027420a02aad24f
|
|
| MD5 |
e88efa92903fe7ebd8bc60982e5851b9
|
|
| BLAKE2b-256 |
24ebfd1dec30bf64b27bb5bb71e8cdaf47687ba832defdd3d917c6be78aac1a0
|
Provenance
The following attestation bundles were made for swiftgalaxy-2.3.2-py3-none-any.whl:
Publisher:
python-publish.yml on SWIFTSIM/swiftgalaxy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
swiftgalaxy-2.3.2-py3-none-any.whl -
Subject digest:
9c962b7a8ac6feb76c1039fcfe74ac78cae2dda26c8e1aee2027420a02aad24f - Sigstore transparency entry: 872300306
- Sigstore integration time:
-
Permalink:
SWIFTSIM/swiftgalaxy@7b41519f3700423190309c36c7e12b4265b39aae -
Branch / Tag:
refs/tags/v2.3.2 - Owner: https://github.com/SWIFTSIM
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@7b41519f3700423190309c36c7e12b4265b39aae -
Trigger Event:
release
-
Statement type: