Xarray-binfile
Custom Xarray file engine to handle raw binary files
Overview
Xarray-binfile is a Python package that integrates raw binary files with xarray. You provide the metadata that describes each binary file, and the package exposes those files through xarray datasets and data arrays with optional lazy chunking through Dask.
The package was first designed around binary outputs from the Fortran framework 2DECOMP&FFT and the CFD solver Xcompact3d, which is built on top of it. It is not limited to those ecosystems and can be used with any raw binary convention once the corresponding metadata mapping is provided.
It is aimed at workflows where raw binary files are part of an existing convention, such as simulation outputs or NumPy .tofile() dumps. Once opened, the data can be indexed, reduced, plotted, and computed with the usual xarray and Dask APIs. See why not just numpy.fromfile? in the documentation for what that buys you over numpy.fromfile and numpy.memmap.
Installation
pip install xarray-binfile
Python 3.10 or later is required; xarray, Dask, and NumPy are installed as dependencies. See the installation guide for version pinning and for pyproject.toml, requirements.txt, and conda environment examples.
Quick start
Describe the file convention once, then let xarray and Dask do the rest:
import numpy as np
from xarray_binfile.conventions import Layout, StepIndexedFiles
# Describe the convention once: coordinates, dtype, and filename pattern
convention = StepIndexedFiles(
layout=Layout(
{"x": np.linspace(0, 1, 8), "y": np.linspace(0, 1, 4)},
dtype=np.float32,
),
pattern="{name}-{step:04d}.bin", # ux-0000.bin, ux-0001.bin, ...
)
# Open every matching file in a folder as one lazy, Dask-backed dataset
ds = convention.open("path/to/data", chunks={"time": 1})
# From here on it is plain xarray
mean = ds["ux"].mean(dim="time").compute()
# Write a derived result back to the same raw layout
mean.rename("ux_mean").expand_dims(time=[0]).binary_engine.to_file(
convention.writer, "path/to/data"
)
The same files also open through the standard xarray entry points, xr.open_dataset(path, engine="binfile", read_specs_getter=convention.reader) and xr.open_mfdataset(...), so they fit into existing xarray code.
The documentation covers the rest:
- Spec getter protocols: the shipped conventions (step-indexed, time-stamped, static files, folder layouts, stacked variables) and how to describe your own.
- Read lazily with Dask and write derived results.
- Parallel and larger-than-memory workflows, benchmarking on your own data, and practical examples.
- API reference.
Contributing
Bug reports, feature requests, and pull requests are welcome. Start with CONTRIBUTING.md for the development setup with Hatch and the pull request checklist, or read the full contributor guide in the documentation. This project follows the Contributor Covenant.
Copyright and License
© 2025 Felipe N. Schuch. All content is under MIT License.
Metadata
Release files for xarray-binfile 0.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| xarray_binfile-0.3.2.tar.gz | 276.5 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| xarray_binfile-0.3.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 319.7 kB
Release files / xarray_binfile-0.3.2.tar.gz
| Download URL | xarray_binfile-0.3.2.tar.gz |
|---|---|
| Size | 276.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
261c900ba2b135273281616190636e10910e31ae4ba882914b70dbbcd86089df
|
|
BLAKE2b-256 checksum How to use checksums |
68c29467cc078f56869ad2703205f9b0e6f948a7368d938cd4f6071fd33d7adc
|
| 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 Oct 20, 2026.
Transparency logRelease files / xarray_binfile-0.3.2-py3-none-any.whl
| Download URL | xarray_binfile-0.3.2-py3-none-any.whl |
|---|---|
| Size | 43.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dad3c71f9400fb12ca57c8d6fc4292f809a40409df91f44a3ca37f6deb04d231
|
|
BLAKE2b-256 checksum How to use checksums |
dc00398af5ff28c74477f524e67588c3969c635cd04f09c7c86dd5d0e91596fa
|
| 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 Oct 20, 2026.
Transparency logSecurity for xarray-binfile 0.3.2
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for xarray_binfile-0.3.2.tar.gz
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 Oct 20, 2026.
Transparency logA 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.