Skip to main content

dhybridrpy

PyPI version Documentation Status

dhybridrpy is an efficient Python package that allows you to easily load and plot data from dHybridR simulations. It provides programmatic access to simulation input and output data and the ability to quickly visualize that data.

Features

  • Efficiently access simulation input data and output data like timesteps, fields (e.g., magnetic field), phases (e.g., distribution functions), raw particle data, and particle tracks.
  • Quickly plot 1D, 2D, and 3D output data, including an interactive slice viewer for 3D volumes.
  • Read a quantity across many timesteps in one call, with files read by parallel worker processes.
  • Compute FFT power spectra and 1D spatial averages.
  • Follow individual particle trajectories across a simulation.
  • Lazily load large datasets using dask.
  • Perform arithmetic operations on data objects directly.
  • Batch-render fields and phases from the command line with the dplot tool.

Installation

The latest package version can be installed via pip:

pip install dhybridrpy

Dependencies

The following packages are installed automatically with dhybridrpy:

Package Purpose
h5py Reading HDF5 simulation output files
numpy Numerical array operations
matplotlib Plotting and visualization
dask Lazy loading for large datasets
f90nml Parsing Fortran namelist input files
typer Command-line interface for the dplot tool
joblib Parallel rendering in the dplot tool
ruff Code linting (development tool)
pre-commit Git hook management (development tool)

Optional: scipy, when installed, is used to run FFTs across multiple threads. ffmpeg is needed on your system for dplot video output.

Usage

Basic usage of the package:

from dhybridrpy import DHybridrpy

# Enter your input file and output folder paths here
input_file = "examples/data/inputs/input"
output_folder = "examples/data/Output"

dpy = DHybridrpy(input_file=input_file, output_folder=output_folder)

# Print simulation timesteps
print(dpy.timesteps())

# Access an input variable
print(f"Timestep = {dpy.inputs['time']['dt']}")

# Access data at a specific timestep
ts = 1
Bx = dpy.timestep(ts).fields.Bx()
print(Bx.data)

# Plot data
import matplotlib.pyplot as plt
Bx.plot()
plt.show()

Further examples can be found in the examples folder and in the online documentation.

CLI Tool: dplot

dplot is a command-line tool for visualizing dHybridR simulation fields and phases across all timesteps, saving PNG images and optionally creating MP4 videos. It is included when you install dhybridrpy.

Discover available data

dplot -i path/to/input

Plot specific fields

dplot -i path/to/input --fields Bx --fields By

Plot phase-space distributions

dplot -i path/to/input --phases p1x1 --species 3

Plot all fields with video output

dplot -i path/to/input --all-fields --video

Key options: --video, --fps, --colormap, --dpi, --vmin/--vmax, --type, --plots-dir, -j (parallel processes), -v (verbose). Large datasets are automatically downsampled to 1080p. See the dplot documentation for full details.

Documentation

Full documentation is available at dhybridrpy.readthedocs.io.

License

Project licensed under the GNU Affero General Public License v3.0. See the LICENSE file for details.

Authors

  • Bricker Ostler
  • Miha Cernetic

Metadata

Release files for dhybridrpy 1.15

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dhybridrpy 1.15
File Size Uploaded Provenance Actions
dhybridrpy-1.15.tar.gz 64.5 kB Without provenance Details for dhybridrpy-1.15.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dhybridrpy 1.15
File Interpreter ABI Platform Actions
dhybridrpy-1.15-py3-none-any.whl Python 3 none any Details for dhybridrpy-1.15-py3-none-any.whl

Total release size: 118.8 kB

Release files / dhybridrpy-1.15.tar.gz

Download URL dhybridrpy-1.15.tar.gz
Size 64.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9743e88c1618aa95ba79d11153395fcad256918849b84edf0894df2cd813c8a5
BLAKE2b-256 checksum
How to use checksums
dd26aa1637f3bd0f27e1a37b755ecae7e0a92de33167dacd316c9a73527e77b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / dhybridrpy-1.15-py3-none-any.whl

Download URL dhybridrpy-1.15-py3-none-any.whl
Size 54.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a3836434626fc9e9c1fda53a01fd95b7c67bb6e367cd73cb08ce261c456002f6
BLAKE2b-256 checksum
How to use checksums
d7cf389abd50626a56a2ebaaf1897fd52b48cc0c898ccab732e3964d770db246
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for dhybridrpy 1.15

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page