Simple Rust-backed Python module for tracing field lines.
This package is built with maturin and published to PyPI as rastra.
uv pip install -e .This installs:
rastra(Rust extension module)
If you prefer using maturin directly:
maturin developimport numpy as np
import rastra
paths = rastra.trace_fieldlines(
xmin=0.0,
xmax=1.0,
ymin=0.0,
ymax=1.0,
nx=16,
ny=16,
bx=np.ones(16 * 16),
by=np.zeros(16 * 16),
seeds=[(0.1, 0.1), (0.2, 0.3)],
step=0.01,
max_steps=1024,
)This project now keeps a small, non-public API focused on one task: compute field lines.
- Create an API token on PyPI.
- Export it in your shell:
export MATURIN_PYPI_TOKEN=pypi-...- Build the distribution artifacts locally:
uvx maturin build- Optionally validate the built wheel in a clean environment:
uv venv /tmp/rastra-test
source /tmp/rastra-test/bin/activate
uv pip install dist/*.whl
python -c "import rastra; print(sorted(name for name in dir(rastra) if 'fieldlines' in name))"- Publish to TestPyPI first:
uvx maturin publish --repository testpypi- Publish to PyPI:
uvx maturin publishThe package name is configured as rastra in pyproject.toml.
src/core Rust tracing implementation and Python bindingsCargo.tomlRust package configurationpyproject.tomlmaturin/Python packaging configuration
trace_fieldlines(...)fixed-step tracer (RK4)