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.4

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.4
File Size Uploaded
xdmf-0.2.4.tar.gz 139.8 kB Details

Built distributions (wheels)

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

Download URL xdmf-0.2.4.tar.gz
Size 139.8 kB
Tags Source
SHA-256 checksum
How to use checksums
1ffbe6ff571b8bb93831738dbb6b14f2fcf9e7c714943823a57bf0a5aa833bf3
BLAKE2b-256 checksum
How to use checksums
962949d0b34bc9386e9ecf2957efbde37762e1d1bd194ca7e8e05bd1db3355d5
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 5, 2026.

Transparency log

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

Download URL xdmf-0.2.4-cp39-abi3-win_amd64.whl
Size 3.8 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
0aec851fef1b1a8c4abd08c18cd97c6c678157b0cc5606ccb574873487d9faf2
BLAKE2b-256 checksum
How to use checksums
047285b3aef556887e12dfa9555c74bb23301d77376a0b6a00369f3868de763a
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 5, 2026.

Transparency log

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

Download URL xdmf-0.2.4-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
2125d456f5a4138fd36fcc7b0ea2c17e737acf047086f2a4e65a5ffa3df81d18
BLAKE2b-256 checksum
How to use checksums
fb97fab80edbb628fa54329062a6da891235b47990b26de17e1f52c60fa2d2ca
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 5, 2026.

Transparency log

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

Download URL xdmf-0.2.4-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
66847132c5b94d72702d5ffdbcd1f2d0888206527b12196ffa15b6651de8ac65
BLAKE2b-256 checksum
How to use checksums
cf85d0ac1aaff1fb4968eb2e737ff81524a84b7d9216ba7d5159ac5291d1b740
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 5, 2026.

Transparency log

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

Download URL xdmf-0.2.4-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
1d91fbbaf41b6152dde812030f6a14bba74dc8318c84d11ba80d479296397ae4
BLAKE2b-256 checksum
How to use checksums
736dd78fa073f2e9d814df319c45d52642eef4af979898d22916e774af281aad
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 5, 2026.

Transparency log

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

Download URL xdmf-0.2.4-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
0326e522f3522d9e04ca3d3f4352a3f7ff6091371ad739bd4828783d78ecbfc5
BLAKE2b-256 checksum
How to use checksums
f8260d5624973f6247ff3f0bc780054bb40ead778d6c63d742ab96360352711a
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 5, 2026.

Transparency log

Release history Release notifications | RSS feed

1.0.0

6 release files

This release

0.2.4 This release

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