A high-performance Python interface for the analysis of AMUN code simulations
Project description
AmunPy
Copyright (C) 2018-2026 Grzegorz Kowal
AmunPy is the official Python interface for handling snapshot datasets produced by the AMUN code. It provides robust, validated readers for AMUN XML and HDF5 snapshots and converts simulation output into uniform NumPy arrays with associated metadata.
Scope note. AmunPy is intentionally limited to snapshot I/O. It does not parse or manage time-series diagnostics, global integrals, mesh statistics, or other auxiliary outputs produced by AMUN. Such data are written by the code as self-describing plain-text files and are documented separately in the AMUN Code Wiki.
🚀 Installation
The package is available on PyPI (https://pypi.org/project/amunpy) and can be installed via pip:
pip install amunpy
Core API & Usage
AmunPy provides a unified high-level API while supporting multiple underlying data formats.
Loading Snapshots
The package includes specialized classes for native XML+binary and HDF5 formats:
AmunXML: Interface for the native format, supporting zstd, lz4, and lzma decompression and xxHash integrity verification.AmunH5: Interface for HDF5-formatted snapshots.
from amunpy import AmunXML, AmunH5
# Load a native XML snapshot
snapshot = AmunXML("./snapshot_dir")
# Load an HDF5 snapshot
snapshot = AmunH5("./snapshot.h5")
Data Retrieval
Use the dataset() method to retrieve physical fields. By default, variables are regridded to a uniform mesh, but they can also be returned as raw AMR blocks.
# Access variables as NumPy arrays
dn = snapshot.dataset("density")
vx = snapshot.dataset("x-velocity")
bx = snapshot.dataset("x-magnetic field")
ex = snapshot.dataset("x-electric field")
Interpolation and AMR regridding
When assembling uniform-resolution datasets from AMR snapshots,
AmunPy applies deterministic, AMR-aware interpolation rules.
Interpolation is performed internally by the dataset() method
and requires no external dependencies.
Available interpolation methods are:
-
"rebin"(conservative, default) Block-averaged restriction and nearest-neighbor prolongation. This method is strictly conservative and does not require ghost-cell information. -
"tvd"(monotone linear) TVD piecewise-linear prolongation using slope limiters. This method uses ghost cells for stencil support and preserves monotonicity without introducing new extrema. -
"pchip"(monotone cubic) Monotonicity-preserving cubic (PCHIP-style) prolongation based on Hermite interpolation with slope limiting. This method provides smooth, high-quality prolongation while avoiding overshoots on monotone data.
All interpolation methods are implemented using NumPy only and are designed for adaptive mesh refinement (AMR) workflows.
Detailed API Documentation
The full documentation of the public API, including:
dataset()parameters and resolution control- uniform-grid semantics and extent handling
- dimensionality conventions (2D vs 3D)
- variable catalog and availability rules (
eqsys,eos) - notes on performance and correctness
is available in: docs/API.md.
This file defines the stable public interface of AmunPy and is the recommended reference for production use.
Supported Variables
AmunPy detects available data and automatically computes derived diagnostics:
- Fluid Dynamics: Density (linear/log), Pressure, Internal Energy, Temperature, and Lorentz factor.
- Vector Fields: Velocity, Magnetic Field, Electric Field, Current Density, and Vorticity (available as full vectors or individual Cartesian components).
- Diagnostics: Kinetic/Magnetic Energy, Magnetic Pressure, and Divergence.
- Grid Metadata: Refinement levels and coordinate arrays.
Authorship & License
- Author/Maintainer: Grzegorz Kowal grzegorz@amuncode.org
- License: Distributed under the GNU General Public License v3.0.
For more information on the simulation engine, visit amuncode.org.
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
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 amunpy-1.0.1.tar.gz.
File metadata
- Download URL: amunpy-1.0.1.tar.gz
- Upload date:
- Size: 56.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1fdefab6ed37e9e0f12e4df42a230fdc13a3400236e5f94d3e5482041686beeb
|
|
| MD5 |
44da598d89261a58170c6f8424cdd7d6
|
|
| BLAKE2b-256 |
5c429f34cb1fd9f1d18225ceb7535379d291371648afdb1d96b7f98c8a8e852a
|
File details
Details for the file amunpy-1.0.1-py3-none-any.whl.
File metadata
- Download URL: amunpy-1.0.1-py3-none-any.whl
- Upload date:
- Size: 45.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e3860c8fee892197306a55062a4c2264159b0fe348255fcee2dfd657ad7f4e6
|
|
| MD5 |
2cd2fa777904c9bfa4911169ef2f62f5
|
|
| BLAKE2b-256 |
b8042347dcbaa80dc74fcde96cabd718b92bacb4477ad1ddc2a30eb2634f00e1
|