SWIFTsim (swiftsim.com) i/o routines for python.
Project description
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
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.
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 swiftsimio-11.0.0.tar.gz.
File metadata
- Download URL: swiftsimio-11.0.0.tar.gz
- Upload date:
- Size: 165.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89467548433707dc5deb9ca5fe51322fab32866f8289785ad6184b633564798d
|
|
| MD5 |
c249edd746f08c0b840af55cc901b782
|
|
| BLAKE2b-256 |
4e30fd3ad7676d96fba8739e5d52449ac1ffa8ecf9786cac189d51ec6fcb56ee
|
Provenance
The following attestation bundles were made for swiftsimio-11.0.0.tar.gz:
Publisher:
python-publish.yml on SWIFTSIM/swiftsimio
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
swiftsimio-11.0.0.tar.gz -
Subject digest:
89467548433707dc5deb9ca5fe51322fab32866f8289785ad6184b633564798d - Sigstore transparency entry: 870138519
- Sigstore integration time:
-
Permalink:
SWIFTSIM/swiftsimio@33c6b304b50ff1ff295501a7148ac5e5569da365 -
Branch / Tag:
refs/tags/v11.0.0 - Owner: https://github.com/SWIFTSIM
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@33c6b304b50ff1ff295501a7148ac5e5569da365 -
Trigger Event:
release
-
Statement type:
File details
Details for the file swiftsimio-11.0.0-py3-none-any.whl.
File metadata
- Download URL: swiftsimio-11.0.0-py3-none-any.whl
- Upload date:
- Size: 161.5 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 |
162379e1f2f808c3175daa86b680959af81ab90a7329101839dc43a0349116dc
|
|
| MD5 |
687818cb7e88be4c45e514349a4e3ba6
|
|
| BLAKE2b-256 |
ae053c5f355c3e326f4f1231003fec87472cc3a85620f75fd4248f84066bdb66
|
Provenance
The following attestation bundles were made for swiftsimio-11.0.0-py3-none-any.whl:
Publisher:
python-publish.yml on SWIFTSIM/swiftsimio
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
swiftsimio-11.0.0-py3-none-any.whl -
Subject digest:
162379e1f2f808c3175daa86b680959af81ab90a7329101839dc43a0349116dc - Sigstore transparency entry: 870138520
- Sigstore integration time:
-
Permalink:
SWIFTSIM/swiftsimio@33c6b304b50ff1ff295501a7148ac5e5569da365 -
Branch / Tag:
refs/tags/v11.0.0 - Owner: https://github.com/SWIFTSIM
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@33c6b304b50ff1ff295501a7148ac5e5569da365 -
Trigger Event:
release
-
Statement type: