Skip to main content

Python library for reading and writing OVF (OOMMF Vector Field) files

Project description

PyPI PyPI - Python Version PyPI - Wheel PyPI - License Downloads pipeline status

pyOVF

A Python library for reading and writing OVF (OOMMF Vector Field) files used in micromagnetic simulations.

Features

  • Fast I/O: C++ backend for high-performance file operations (via ovf-rw)
  • NumPy Integration: Seamless conversion between OVF files and NumPy arrays
  • Pure Python Fallback: Works even without the C++ extension (slower but functional)
  • OOMMF & mumax3 Compatible: Supports files from both simulation packages
  • Binary Format: Reads and writes OVF 2.0 Binary 4 format
  • Wide Python Support: Python 3.8 - 3.14

Installation

pip install pyovf

From Source

git clone https://gitlab.flavio.be/flavio/pyovf.git
cd pyovf
pip install -e .

Building with ovf-rw

The C++ bindings are built from the ovf-rw library. When building from source, the build system will automatically fetch the required sources.

# Clone both repositories
git clone https://gitlab.flavio.be/flavio/pyovf.git
git clone https://gitlab.flavio.be/flavio/ovf-rw.git

# Build pyovf (it will find ovf-rw in the parent directory)
cd pyovf
pip install -e .

Quick Start

import pyovf
import numpy as np

# Read an OVF file
ovf = pyovf.read("magnetization.ovf")

# Or read with mesh objects (X and Y)
# X, Y, ovf = pyovf.read('magnetization.ovf', return_mesh=True)

print(f"Data shape: {ovf.data.shape}")
print(f"Grid: {ovf.xnodes}x{ovf.ynodes}x{ovf.znodes}")

# Access and modify data
mx = ovf.data[..., 0]  # X component
my = ovf.data[..., 1]  # Y component
mz = ovf.data[..., 2]  # Z component

# Create a new OVF file from scratch
data = np.zeros((1, 100, 100, 3), dtype=np.float32)
data[..., 2] = 1.0  # Uniform mz = 1

ovf_new = pyovf.create(
    data,
    xstepsize=5e-9,  # 5 nm cells
    ystepsize=5e-9,
    zstepsize=10e-9,
    title="m"
)

pyovf.write("uniform_state.ovf", ovf_new)

API Reference

Functions

pyovf.read(filename) -> OVFFile

Read an OVF file and return an OVFFile object.

pyovf.write(filename, ovf)

Write an OVFFile object to disk.

pyovf.create(data, **kwargs) -> OVFFile

Create a new OVFFile from a NumPy array.

OVFFile Properties

Property Type Description
data np.ndarray Field data (z, y, x, [dim])
xnodes, ynodes, znodes int Grid dimensions
xstepsize, ystepsize, zstepsize float Cell sizes
valuedim int Components (1=scalar, 3=vector)
Title str Data description
TotalSimTime float Simulation time

Data Layout

OVF files store data in column-major order:

  • For a vector field: data[z, y, x, component]
  • For a scalar field: data[z, y, x]

Supported Python Versions

Python Version Status
3.8 ✅ Supported
3.9 ✅ Supported
3.10 ✅ Supported
3.11 ✅ Supported
3.12 ✅ Supported
3.13 ✅ Supported
3.14 ✅ Supported (experimental)

Project Structure

pyovf/
├── pyovf/              # Main package
│   ├── __init__.py     # Package initialization
│   ├── _version.py     # Dynamic version (auto-generated)
│   ├── helper_funcs.py # Helper functions
│   ├── ovf_handler.py  # OVF file handler
│   └── binaries/       # Compiled C++ bindings
├── src/                # Source for pybind11 bindings
├── tests/              # Unit tests
├── pyproject.toml      # Build configuration
├── setup.py            # Setup script with CMake integration
└── CMakeLists.txt      # CMake build configuration

Related Projects

  • ovf-rw: The underlying C++ library for OVF file I/O, providing:
    • MATLAB bindings via MEX
    • Python bindings via Cython
    • High-performance binary file operations

Development

Setting up a development environment

git clone https://gitlab.flavio.be/flavio/pyovf.git
cd pyovf
python -m venv venv
source venv/bin/activate
pip install -e ".[dev]"

Running tests

pytest tests/ -v --cov=pyovf

Building wheels

pip install build
python -m build

Versioning

This project uses setuptools-scm for dynamic versioning based on git tags. Version numbers are automatically determined from git history:

  • Tagged commits (e.g., v1.0.0) produce release versions (1.0.0)
  • Commits after a tag produce development versions (1.0.1.dev3+g1234567)

To create a new release:

git tag -a v1.0.0 -m "Release version 1.0.0"
git push origin v1.0.0

License

MIT License - see LICENSE file for details.

Author

Prof. Flavio ABREU ARAUJO
Email: flavio.abreuaraujo@uclouvain.be

Citation

If you use this software in your research, please cite:

@software{pyovf,
  author = {Abreu Araujo, Flavio},
  title = {pyovf: Python library for OVF file I/O},
  year = {2021},
  url = {https://gitlab.flavio.be/flavio/pyovf}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyovf-0.2.10.tar.gz (85.6 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyovf-0.2.10-cp314-cp314-macosx_14_0_arm64.whl (86.5 kB view details)

Uploaded CPython 3.14macOS 14.0+ ARM64

pyovf-0.2.10-cp313-cp313-macosx_14_0_arm64.whl (163.3 kB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

pyovf-0.2.10-cp312-cp312-macosx_14_0_arm64.whl (163.3 kB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

pyovf-0.2.10-cp311-cp311-macosx_14_0_arm64.whl (163.8 kB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

pyovf-0.2.10-cp310-cp310-macosx_14_0_arm64.whl (162.4 kB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

pyovf-0.2.10-cp39-cp39-macosx_14_0_arm64.whl (162.5 kB view details)

Uploaded CPython 3.9macOS 14.0+ ARM64

File details

Details for the file pyovf-0.2.10.tar.gz.

File metadata

  • Download URL: pyovf-0.2.10.tar.gz
  • Upload date:
  • Size: 85.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for pyovf-0.2.10.tar.gz
Algorithm Hash digest
SHA256 70ec56f94b94d37bdefd64a64104b54de6e128bdd9832be87cd1227e5dcc4e5f
MD5 cd3b66d0b23730809de242fec933410d
BLAKE2b-256 b8287feff705501086ed1871ce0451d5d6b63f6e763f529b65fecf8a26867917

See more details on using hashes here.

File details

Details for the file pyovf-0.2.10-cp314-cp314-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pyovf-0.2.10-cp314-cp314-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 23376e54e3c73ef16226fe56ca648769093779f82103f07196c4dd643f6066dd
MD5 b1e3103488575882d3a99c1eaf78b4b4
BLAKE2b-256 1d92276d2115f816ba913d893b4bd596826788b630fb85893ff8159df71a8f2c

See more details on using hashes here.

File details

Details for the file pyovf-0.2.10-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pyovf-0.2.10-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 b8f49e8f90c54a56934c143ac6e11f033a41ecfb62eb33ebbbaf7fb97fe3671b
MD5 20fcdb7a5dff6c6924113064a479e0b3
BLAKE2b-256 2d678529ee3c32180fc14a9da22d29cb5e301cad91a70701d4ca8685d31868ea

See more details on using hashes here.

File details

Details for the file pyovf-0.2.10-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pyovf-0.2.10-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 a11fc19bf71f0122d54fea356950e47d13531e7bfe3c43949a23b9a0f1d33994
MD5 3702a69d23a048f878bd9cdb339fcc5f
BLAKE2b-256 df59e53b9e14a6fdad0abaa7f32cf1497c33122cf3cd70a0ecd9c3b4baa4b933

See more details on using hashes here.

File details

Details for the file pyovf-0.2.10-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pyovf-0.2.10-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 6df01fd0351620990a5898e2d2578c1286458d4bc9996333b5d640321fbdcecc
MD5 449dae5e94c18746d4fb8d4241aa4a98
BLAKE2b-256 6d2c131b3e0339879b4d6e81af611052140a4324d83dafde645ac1209cefb88f

See more details on using hashes here.

File details

Details for the file pyovf-0.2.10-cp310-cp310-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pyovf-0.2.10-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 7914194c86e33f5511044dc2f97f9515e8cbbc16041e28f4678997c616069f81
MD5 d1c5a183d93a15466d1bc09a3563b9b4
BLAKE2b-256 c48f0d54bd72a4b8540a85638682cfe32b4d542babe0d0bfe9a3260eaf78c091

See more details on using hashes here.

File details

Details for the file pyovf-0.2.10-cp39-cp39-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pyovf-0.2.10-cp39-cp39-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 6ca0f7860dcfd390cf44d71299954cb4ee4de2ad5e36ec045661aafb30bb4ebc
MD5 51e73044f2526070213df461d6a7f2f7
BLAKE2b-256 2b80fd878a35a796164a89b2a7f5476ab62221165a2fb4afe19882c453fc4c85

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page