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 0.2.1

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 0.2.1
File Size Uploaded
xdmf-0.2.1.tar.gz 139.0 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for xdmf 0.2.1
File
xdmf-0.2.1-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details
xdmf-0.2.1-cp39-abi3-manylinux_2_28_x86_64.whl CPython 3.9 abi3 Linux glibc 2.28+ x86-64 Details
xdmf-0.2.1-cp39-abi3-manylinux_2_28_aarch64.whl CPython 3.9 abi3 Linux glibc 2.28+ ARM64 Details
xdmf-0.2.1-cp39-abi3-macosx_11_0_x86_64.whl CPython 3.9 abi3 macOS 11.0+ x86-64 Details
xdmf-0.2.1-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-0.2.1.tar.gz

Download URL xdmf-0.2.1.tar.gz
Size 139.0 kB
Tags Source
SHA-256 checksum
How to use checksums
d84cc1c67553acd49c5177e3befcb58c8abccf71ddb16c1f743cf02c50de8869
BLAKE2b-256 checksum
How to use checksums
f47bff4ac12ac48c2cb4eae2c1de3b44c534e96e18ec7be69b8c4234595cc580
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 Aug 28, 2026.

Transparency log

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

Download URL xdmf-0.2.1-cp39-abi3-win_amd64.whl
Size 3.8 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
821d257a3407a4e29340292e8b7e0eea5ae179c09c32e1ad3591efc67c9febbe
BLAKE2b-256 checksum
How to use checksums
167e64f1a6cf48a90b824a47b87ccf208dc9e99f990524a441dbbd4cb5075b7c
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 Aug 28, 2026.

Transparency log

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

Download URL xdmf-0.2.1-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
1306cec7e3c16a99f7e78abc1b008f8baf726b449988a36587d8a97631b989f5
BLAKE2b-256 checksum
How to use checksums
4c74eb538d8695962b92b116925173746cf25166b36b6c02ee57e2e0bf9a7679
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 Aug 28, 2026.

Transparency log

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

Download URL xdmf-0.2.1-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
3821d18ffda2fd7fa903efac3c2d15efa83293e9d51736108071e1e8472c556b
BLAKE2b-256 checksum
How to use checksums
6b2d4202c2f5b046b3f2d1a065f7121d1989d3130a7784be59e4e10d23ea182c
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 Aug 28, 2026.

Transparency log

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

Download URL xdmf-0.2.1-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
e518ffc0320323b09f6384e14efc3a08252cb11d9b85331a9498543d9745f7e0
BLAKE2b-256 checksum
How to use checksums
ace3c4fe3246f27a154aa277924f19ee5a37cf3a7d5c2179b34b31e5f5c52f2e
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 Aug 28, 2026.

Transparency log

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

Download URL xdmf-0.2.1-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
1ecc02df86a1ea03068c5c908f2e6d2a0a194340fc23758845714d3193845de4
BLAKE2b-256 checksum
How to use checksums
823190d452dac8118f7453b429950e3e5d16bee1e85001a110f54c975d7a248f
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 Aug 28, 2026.

Transparency log

Release history Release notifications | RSS feed

1.0.0

6 release files

0.2.4

6 release files

0.2.3

6 release files

0.2.2

6 release files

This release

0.2.1 This release

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