Skip to main content

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:

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


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.2.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

swiftsimio-0.1.2-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file swiftsimio-0.1.2.tar.gz.

File metadata

  • Download URL: swiftsimio-0.1.2.tar.gz
  • Upload date:
  • Size: 9.1 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

Hashes for swiftsimio-0.1.2.tar.gz
Algorithm Hash digest
SHA256 b1fac6a9547c3f458f30f1b9fae22b52b8fdb73c911b1ef9c6826000c305d4cc
MD5 2426805f72f11b427e9155cf76c60d8c
BLAKE2b-256 58aa31d672ebaedf5663758b1695692c92276f0545571c580b6f50df11849779

See more details on using hashes here.

File details

Details for the file swiftsimio-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: swiftsimio-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 14.5 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

Hashes for swiftsimio-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e094f27e1c0d16d05502d5722ba09d1dd4a9dab00259185634b9e1dcbaadaf4f
MD5 7754bf79db022796b9b84a2c52edba29
BLAKE2b-256 966ac19654ef43ab6a1fefeedfaa6796e327963ff76b3a23534e74cca45d6dc8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page