SWIFTsim (swift.dur.ac.uk) i/o routines for python.
Project description
SWIFTsimIO
==========
The SWIFT astrophysical simulation code (http://swift.dur.ac.uk) 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. This (thin) wrapper provides an object-oriented API to read
(dynamically) data from SWIFT.
Requirements
------------
This requires `python3.6.0` or higher. No effort will be made to support python versions
below this. Please update your systems.
### Python packages
+ `h5py`
+ `unyt`
Usage
-----
Example usage is shown below, which plots a density-temperature phase
diagram, with density and temperature given in CGS units:
```python
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.density.convert_to_cgs()
data.gas.temperature.convert_to_cgs()
plt.loglog()
plt.scatter(
data.gas.density,
data.gas.temperature,
s=1
)
plt.xlabel(fr"Gas density $\left[{data.gas.density.units.latex_repr}\right]$")
plt.ylabel(fr"Gas temperature $\left[{data.gas.temperature.units.latex_repr}\right]$")
plt.tight_layout()
plt.savefig("test_plot.png", dpi=300)
```
In the above it's important to note the following:
+ All metadata is read in when the `load` function is called.
+ Only the density and temperature (corresponding to the `PartType0/Density` and
`PartType0/Temperature`) datasets are read in.
+ That data is only read in once the `convert_to_cgs` method is called.
+ `convert_to_cgs` converts data in-place; i.e. it returns `None`.
+ The data is cached and not re-read in when `plt.scatter` is called.
==========
The SWIFT astrophysical simulation code (http://swift.dur.ac.uk) 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. This (thin) wrapper provides an object-oriented API to read
(dynamically) data from SWIFT.
Requirements
------------
This requires `python3.6.0` or higher. No effort will be made to support python versions
below this. Please update your systems.
### Python packages
+ `h5py`
+ `unyt`
Usage
-----
Example usage is shown below, which plots a density-temperature phase
diagram, with density and temperature given in CGS units:
```python
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.density.convert_to_cgs()
data.gas.temperature.convert_to_cgs()
plt.loglog()
plt.scatter(
data.gas.density,
data.gas.temperature,
s=1
)
plt.xlabel(fr"Gas density $\left[{data.gas.density.units.latex_repr}\right]$")
plt.ylabel(fr"Gas temperature $\left[{data.gas.temperature.units.latex_repr}\right]$")
plt.tight_layout()
plt.savefig("test_plot.png", dpi=300)
```
In the above it's important to note the following:
+ All metadata is read in when the `load` function is called.
+ Only the density and temperature (corresponding to the `PartType0/Density` and
`PartType0/Temperature`) datasets are read in.
+ That data is only read in once the `convert_to_cgs` method is called.
+ `convert_to_cgs` converts data in-place; i.e. it returns `None`.
+ The data is cached and not re-read in when `plt.scatter` is called.
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
swiftsimio-0.1.0.tar.gz
(5.2 kB
view details)
Built Distribution
File details
Details for the file swiftsimio-0.1.0.tar.gz
.
File metadata
- Download URL: swiftsimio-0.1.0.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0653860d3f22cce365ee08d56b602929a8583ae615eaebca5b80e4369a840d43 |
|
MD5 | d4cb5ffab8c344afa667dd65cb2d6edd |
|
BLAKE2b-256 | 8654dad6dab57c177d321eaef53555518d1a0b733cf44b46a7b4696b05e7e960 |
File details
Details for the file swiftsimio-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: swiftsimio-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c1889b63b54fc012a80b497cfef655d9bd576302ffaccb128360dea90433da2e |
|
MD5 | 8bbd390b168a9f3fe86197b9893a2484 |
|
BLAKE2b-256 | a08aef10c58e8c59043347f968bb1cf216ec639bbd4ed4368c661422b6aa39be |