Skip to main content

xdmf - python interface

Python bindings for the xdmf crate, built with pyo3/maturin: write meshes with time-series data as XDMF files, for ParaView or VisIt to read.

pip install xdmf

One abi3 wheel per platform (Linux x86_64/aarch64, macOS x86_64/arm64, Windows x86_64) covers every Python >= 3.9, and carries its own HDF5 -- xdmf.is_hdf5_enabled() says whether a given build has it.

To build from the repository instead, which links a system HDF5:

pip install ./python

Example

Pass the mesh and the data as numpy arrays. The bindings borrow them rather than copy them, and write each one at the dtype you pass (float64, float32, uint64, uint32, int64, int32), as in Rust:

import numpy as np
import xdmf

writer = xdmf.TimeSeriesWriter("xdmf_writing", xdmf.DataStorage.Hdf5SingleFile)

# define 3 points and 2 cells (a line and a triangle)
coords = np.array([0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0])
connectivity = np.array([0, 1, 0, 2, 1], dtype=np.uint32)  # line (0,1) and triangle (0,2,1)
cell_types = [xdmf.CellType.Edge, xdmf.CellType.Triangle]

# write the mesh, then the data for 10 time steps
with writer.write_mesh(coords, connectivity, cell_types) as data_writer:
    for step in range(10):
        point_values = np.full(9, float(step))
        data_writer.write_time_step(
            str(step),
            point_data=[("point_data", xdmf.DataAttribute.VECTOR, point_values)],
            cell_data=[("cell_data", xdmf.DataAttribute.SCALAR, np.array([0.0, 1.0]))],
        )

Submeshes

write_mesh_with_submeshes splits the mesh into named blocks, which ParaView lists in its Multi-block Inspector (View -> Multi-block Inspector) and shows or hides one at a time. Each (name, cells) pair names the cells belonging to one block, as a range, a numpy integer array or a sequence of int:

writer = xdmf.TimeSeriesWriter("xdmf_blocks", xdmf.DataStorage.Hdf5SingleFile)

with writer.write_mesh_with_submeshes(
    coords, connectivity, cell_types, [("line", range(0, 1)), ("triangle", [1])]
) as data_writer:
    # the data still covers the whole mesh, and each block gets its share
    data_writer.write_time_step(
        "0.0",
        point_data=[("point_data", xdmf.DataAttribute.VECTOR, np.zeros(9))],
        cell_data=[("material", xdmf.DataAttribute.SCALAR, np.array([10.0, 20.0]))],
    )

Give a block of consecutive cells as range(start, stop) to save storage space.

Blocks may overlap, every cell has to belong to at least one, and no two may share a name.

tests/test_writer.py has many more examples, including every failure case.

Good to know

  • Points and vector data may also be shaped (N, 3): a C-contiguous (N, 3) array is the same memory as the flat one, so it needs no reshape. Points are the one array whose shape is checked, so the transposed (3, N) layout raises instead of passing as interleaved coordinates.
  • cell_types also takes a numpy array of cell type codes, in any integer dtype. Those codes are the CellType values, i.e. the XDMF topology types and not the VTK cell codes: a hexahedron is 9 here and 12 in VTK. (The node ordering within a cell does follow VTK.)
  • The file name is a str or any os.PathLike, and writer.file_name hands back the pathlib.Path it writes.
  • A time step is all-or-nothing, as in Rust: one rejected attribute drops the whole step, heavy data and all, and leaves the time free again.
  • The data writer is a context manager, so the with block closes the HDF5 file instead of the garbage collector. close() does the same.
  • Writes release the GIL, so other threads keep running and threads writing their own file write in parallel. The arrays are borrowed, so no thread may modify one mid-write.
  • A rejected write_mesh leaves the writer usable, so fix the dtype or shape and retry. Only a successful call consumes it, as in Rust.
  • DataStorage, DataAttribute and CellType are frozen, comparable and hashable, so they work as dict keys and in sets.
  • Type stubs (xdmf.pyi) ship with the package.

Metadata

Release files for xdmf 1.0.0

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

Source distribution (sdist)

Source distribution for xdmf 1.0.0
File Size Uploaded
xdmf-1.0.0.tar.gz 129.6 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for xdmf 1.0.0
File
xdmf-1.0.0-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details
xdmf-1.0.0-cp39-abi3-manylinux_2_28_x86_64.whl CPython 3.9 abi3 Linux glibc 2.28+ x86-64 Details
xdmf-1.0.0-cp39-abi3-manylinux_2_28_aarch64.whl CPython 3.9 abi3 Linux glibc 2.28+ ARM64 Details
xdmf-1.0.0-cp39-abi3-macosx_11_0_x86_64.whl CPython 3.9 abi3 macOS 11.0+ x86-64 Details
xdmf-1.0.0-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details

Total release size: 13.0 MB

Release files / xdmf-1.0.0.tar.gz

Download URL xdmf-1.0.0.tar.gz
Size 129.6 kB
Tags Source
SHA-256 checksum
How to use checksums
11742c8db90af91ff0c189a531e008e99a579de3449fb82be05c8c20d3ef6ae9
BLAKE2b-256 checksum
How to use checksums
54bab6ea5f69332f74862269a968eb51c2b2819346d203f3b57ff48cf3069308
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.

Transparency log

Release files / xdmf-1.0.0-cp39-abi3-win_amd64.whl

Download URL xdmf-1.0.0-cp39-abi3-win_amd64.whl
Size 3.8 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
c22b68e6c69f6804e9e07c943c1239792efdb8002bad9dcd0d25f363663f19dd
BLAKE2b-256 checksum
How to use checksums
2b7a1131a8062fc82c9c57c66c0ead30be27106dd92f60b55992f6ad52cf3be2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.

Transparency log

Release files / xdmf-1.0.0-cp39-abi3-manylinux_2_28_x86_64.whl

Download URL xdmf-1.0.0-cp39-abi3-manylinux_2_28_x86_64.whl
Size 2.5 MB
Tags CPython 3.9 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
661222b51af9f50ab5d159da39a46c9219ec3659fcf1a5ccd7a8295252a33d6d
BLAKE2b-256 checksum
How to use checksums
10656fe63c8194f3b7efc5d7ee4da4334d47c68e105c09ce3328a645ef15ad87
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.

Transparency log

Release files / xdmf-1.0.0-cp39-abi3-manylinux_2_28_aarch64.whl

Download URL xdmf-1.0.0-cp39-abi3-manylinux_2_28_aarch64.whl
Size 2.5 MB
Tags CPython 3.9 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
9c7eb19208080e0c00ca4cb0934e8cdf45f8d406e8bad502322c63a081a35b99
BLAKE2b-256 checksum
How to use checksums
7730dc8b87e86e17ed4abe9b54a40d2bb1edfd98574e30a463c60340d5d5b1cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.

Transparency log

Release files / xdmf-1.0.0-cp39-abi3-macosx_11_0_x86_64.whl

Download URL xdmf-1.0.0-cp39-abi3-macosx_11_0_x86_64.whl
Size 2.1 MB
Tags CPython 3.9 abi3 macOS 11.0+ x86-64
SHA-256 checksum
How to use checksums
cfb07d2190ee23e0ff8422940fc03770e26a7715916e2f1fe86b6d3d7f71b533
BLAKE2b-256 checksum
How to use checksums
4672808cb24c2bb0baa196feb56c7ee8b0c00e253bf48cf74cc8950bd8b072f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.

Transparency log

Release files / xdmf-1.0.0-cp39-abi3-macosx_11_0_arm64.whl

Download URL xdmf-1.0.0-cp39-abi3-macosx_11_0_arm64.whl
Size 1.9 MB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
91e5607c4d8de0dc78473f989f8d985898dfc78e353eabd73392575454931482
BLAKE2b-256 checksum
How to use checksums
732df253378fc8f7ead2d0de673d07b7cc8c1a0ea9b4bfb3d099a5674d65a929
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.0 This release

6 release files

0.2.4

6 release files

0.2.3

6 release files

0.2.2

6 release files

0.2.1

6 release files

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