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

Uploaded Source

Built Distribution

swiftsimio-0.1.1-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: swiftsimio-0.1.1.tar.gz
  • Upload date:
  • Size: 5.9 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.1.tar.gz
Algorithm Hash digest
SHA256 e7a592fca3a374dad6b54c6e28c522591675c81383665d5854665c8df03326fb
MD5 7dfcee863a1fe9e383790633adb93c32
BLAKE2b-256 9f1d972aa43675f0129e907de1b6c6522999c30c01f1827d6b8cd74aa3c133bf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: swiftsimio-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.6 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1acafb356b8ecfc45c7c40c2304ead02a6cb49c73ee416361fd72e262d3e8d51
MD5 a5bc753e014aababbd4eb68dd2c0b9a8
BLAKE2b-256 42b7a38c079073b3598781f7e3a97be070f6127b02bf8cf76b8dbc35f9d0383a

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