Skip to main content

A light-weight Python package for GIZMO snapshot IO

Project description

gizio

A light-weight Python package for GIZMO snapshot IO

Build Status Documentation Status

About

There are two snapshot reading scripts readsnap.py and load_from_snapshot.py accompanying the GIZMO source code. gizio aims to replace load_from_snapshot.py with several improvements:

  • A more flexible interface to access field
  • A unit system powered by unyt
  • Easier format spec customization without source code modification
  • Easier to install and maintain as a Python package

We acknowledge yt and pynbody for interface design inspirations.

Demo

The sample data could be downloaded here.

Load a snapshot:

>>> import gizio
>>> snap = gizio.load('data/FIRE_M12i_ref11/snapshot_600.hdf5')

View its header:

>>> snap.header
{'time': unyt_quantity(13.79874688, 'Gyr'),
 'n_file': 1,
 'mass_tab': unyt_array([0., 0., 0., 0., 0., 0.], 'code_mass'),
 'f_sfr': 1,
 'f_cool': 1,
 'f_fb': 1,
 'f_age': 1,
 'f_met': 11,
 'n_part': array([ 753678, 1104128, 2567905,       0,  361239,       0], dtype=uint32),
 'n_part_pf': [array([ 753678, 1104128, 2567905,       0,  361239,       0], dtype=int32)],
 'box_size': unyt_quantity(60000., 'code_length'),
 'Om0': 0.272,
 'OmL': 0.728,
 'h': 0.702,
 'z': 0.0,
 'cosmological': True}

Load a field:

>>> snap['PartType0', 'Masses']
unyt_array([3.175186e-05, 3.175186e-05, 3.175186e-05, ..., 3.175186e-05,
            3.175186e-05, 3.175186e-05], dtype=float32, units='code_mass')

Load a field using shorthands:

>>> snap.pt['gas']['m']
unyt_array([3.175186e-05, 3.175186e-05, 3.175186e-05, ..., 3.175186e-05,
            3.175186e-05, 3.175186e-05], dtype=float32, units='code_mass')

Select particles by masking:

>>> gas = snap.pt['gas']
>>> hot_gas = gas[gas['t'].to_value('K') > 1e5]
>>> hot_gas['t'].min()
unyt_quantity(100000.79, dtype=float32, units='K')

Select particles by composing:

>>> star = snap.pt['star']
>>> baryon = gas | star
>>> len(gas)
753678
>>> len(star)
361239
>>> len(baryon)
1114917
>>> baryon['m']
unyt_array([3.1751861e-05, 3.1751861e-05, 3.1751861e-05, ...,
            2.2581291e-05, 2.3056862e-05, 2.7417644e-05], dtype=float32, units='code_mass')

Installation

Install latest stable version from PyPI:

pip install gizio

Install development version from source:

git clone https://github.com/galaxy-lab/gizio.git
cd gizio
pip install -e .

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

gizio-0.1.0.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

gizio-0.1.0-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file gizio-0.1.0.tar.gz.

File metadata

  • Download URL: gizio-0.1.0.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for gizio-0.1.0.tar.gz
Algorithm Hash digest
SHA256 998c399338393a7e53df57b8a9af4f03df85e9e19d376a1e7057ce1e1433a0b9
MD5 0e347092434e5696d3bd95aec8ce7226
BLAKE2b-256 190c86de5efce6c9be7ba446f6c0ad4a51072bfb9c45bd2a4330c9db559c2ee0

See more details on using hashes here.

File details

Details for the file gizio-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: gizio-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for gizio-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 843608d48092f8ce0c2d68766558765b3fcabd394139786572eb9454ee96ca1f
MD5 fab0520252c7adfc5277255e54729b72
BLAKE2b-256 4dfe04944ea079a61692b88b23b5dd8ed0e8e8929914c29661753e0e27b1e5f1

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