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")
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.8.tar.gz (70.1 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.8-cp314-cp314-macosx_14_0_x86_64.whl (96.9 kB view details)

Uploaded CPython 3.14macOS 14.0+ x86-64

pyovf-0.2.8-cp314-cp314-macosx_14_0_arm64.whl (101.1 kB view details)

Uploaded CPython 3.14macOS 14.0+ ARM64

pyovf-0.2.8-cp313-cp313-macosx_14_0_x86_64.whl (96.8 kB view details)

Uploaded CPython 3.13macOS 14.0+ x86-64

pyovf-0.2.8-cp313-cp313-macosx_14_0_arm64.whl (100.5 kB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

pyovf-0.2.8-cp312-cp312-macosx_14_0_x86_64.whl (96.8 kB view details)

Uploaded CPython 3.12macOS 14.0+ x86-64

pyovf-0.2.8-cp312-cp312-macosx_14_0_arm64.whl (100.5 kB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

pyovf-0.2.8-cp311-cp311-macosx_14_0_x86_64.whl (97.8 kB view details)

Uploaded CPython 3.11macOS 14.0+ x86-64

pyovf-0.2.8-cp311-cp311-macosx_14_0_arm64.whl (101.7 kB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

pyovf-0.2.8-cp310-cp310-macosx_14_0_x86_64.whl (96.4 kB view details)

Uploaded CPython 3.10macOS 14.0+ x86-64

pyovf-0.2.8-cp310-cp310-macosx_14_0_arm64.whl (97.5 kB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

pyovf-0.2.8-cp39-cp39-macosx_14_0_universal2.whl (96.4 kB view details)

Uploaded CPython 3.9macOS 14.0+ universal2 (ARM64, x86-64)

pyovf-0.2.8-cp39-cp39-macosx_14_0_arm64.whl (97.6 kB view details)

Uploaded CPython 3.9macOS 14.0+ ARM64

File details

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

File metadata

  • Download URL: pyovf-0.2.8.tar.gz
  • Upload date:
  • Size: 70.1 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.8.tar.gz
Algorithm Hash digest
SHA256 93b609030bf842ea822f4ac7f09ddc9990626fc5e2b9d2f8bc9f944284fbc5cc
MD5 493db7bceeb88d0000340381c11e3174
BLAKE2b-256 dab6d78bec40a60466d0afd457dae7f0467157764488ece9e98ffa55e876ff0d

See more details on using hashes here.

File details

Details for the file pyovf-0.2.8-cp314-cp314-macosx_14_0_x86_64.whl.

File metadata

File hashes

Hashes for pyovf-0.2.8-cp314-cp314-macosx_14_0_x86_64.whl
Algorithm Hash digest
SHA256 f21547b702cb9a67bf5a32069a7d94bbe3f658a489ca63a89fcbe97decc24313
MD5 ae034c41f621b29f8b0fc968e053d7d8
BLAKE2b-256 7f6ceb5934bc87d5c536a6923d6d265067f56193da6b607806e7ac1925ab4e4e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyovf-0.2.8-cp314-cp314-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 3ed56e34826af9e9cbe1a4831454670471a0f2fb823f49ac4ae5e2ce79907caa
MD5 faf26a381b306c77e2357bc49095ab85
BLAKE2b-256 e201fd0915326b8773dceff3434cb5e4c7525d0a4332fc1c1a11e82142b2a8a7

See more details on using hashes here.

File details

Details for the file pyovf-0.2.8-cp313-cp313-macosx_14_0_x86_64.whl.

File metadata

File hashes

Hashes for pyovf-0.2.8-cp313-cp313-macosx_14_0_x86_64.whl
Algorithm Hash digest
SHA256 463ff833215676e88f119c37e84f07a7b31e7f990b7ddf151d3c0bdb360d1003
MD5 df7fa93f8846c8de42d8bedb949c99cb
BLAKE2b-256 6b6e9d33bafa62710f822160ee56659f379cd29d2e2ed2c9f4ba7fdf0d04160c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyovf-0.2.8-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 b6b97c1931a34d17951a3106423ed7e78f7e5fe3993bfcdb5d463b39400f8d21
MD5 e9d5e04636e8cc6162ee2b740eef8010
BLAKE2b-256 4e611c0fcc293893f87012f76d504ea7a02b7fe9326720fd977185c7575df300

See more details on using hashes here.

File details

Details for the file pyovf-0.2.8-cp312-cp312-macosx_14_0_x86_64.whl.

File metadata

File hashes

Hashes for pyovf-0.2.8-cp312-cp312-macosx_14_0_x86_64.whl
Algorithm Hash digest
SHA256 939dcd90605c966a764810398fb1671f07fc5030cd8ff8ad97de74980ff3ec38
MD5 dfa0fad1795f230ce6cf8da2ad4dc124
BLAKE2b-256 1113e159b27186e2e3bebcc1303c7f37d776b2df78c904cf4642f0710a0e51ec

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyovf-0.2.8-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 891debf566b783cef56f780fe9796fff9476ae33e4ce57121b34101cb1059e20
MD5 47c236e0452956b33d41c2d6af14be79
BLAKE2b-256 0f644d6e53a7eecfde58d8f2d0d5778768dcd24158adf7432ff0b408fed3da0c

See more details on using hashes here.

File details

Details for the file pyovf-0.2.8-cp311-cp311-macosx_14_0_x86_64.whl.

File metadata

File hashes

Hashes for pyovf-0.2.8-cp311-cp311-macosx_14_0_x86_64.whl
Algorithm Hash digest
SHA256 703fe5916935cd5f2589e2be459e2864885680774251354cfc6308a8be62146f
MD5 679f17334f4d810687f9ed052e1b48f2
BLAKE2b-256 49de8efe443e30d831f5a0e6900ad8c1ac15bc8f1d9a583f0764bfd2b66096e2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyovf-0.2.8-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 6d09fa927ad9c5679baf2ab026fec10ed20859b7ab77b4f3d40ac68d9f84cfc0
MD5 a8931bde02563d3319d593b13d25238c
BLAKE2b-256 3139ef1b005712b0e06629e819f5bc71771fe3b4719f910ce377ed662cd35f75

See more details on using hashes here.

File details

Details for the file pyovf-0.2.8-cp310-cp310-macosx_14_0_x86_64.whl.

File metadata

File hashes

Hashes for pyovf-0.2.8-cp310-cp310-macosx_14_0_x86_64.whl
Algorithm Hash digest
SHA256 df6f6952ce1f3c59cbb456cbe47d9853934ee263fc82e1352b00daece318a09d
MD5 de044860f1a3e32dfdea82eb99b7ff35
BLAKE2b-256 4025ecc6fe6df9ebba0009f074e4a12cf77fbb780506f6430a9f64767ee9d723

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyovf-0.2.8-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 8d4d6c5e251c12318d715dbaa4b29158aef283405367c62d27869c9218f388d2
MD5 251d9378cb7fc92262f733ec065a2972
BLAKE2b-256 0c7093a1b4b5b13ee4e3f9db0808053181cccd711c507ee92ebf00b4a5719db2

See more details on using hashes here.

File details

Details for the file pyovf-0.2.8-cp39-cp39-macosx_14_0_universal2.whl.

File metadata

  • Download URL: pyovf-0.2.8-cp39-cp39-macosx_14_0_universal2.whl
  • Upload date:
  • Size: 96.4 kB
  • Tags: CPython 3.9, macOS 14.0+ universal2 (ARM64, x86-64)
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for pyovf-0.2.8-cp39-cp39-macosx_14_0_universal2.whl
Algorithm Hash digest
SHA256 f7437c25a529b4661dc726c32e07abd8f8bf54c7c51986c13eebbe54463c4a13
MD5 c491a19f10ccdd9368f231745d7ad854
BLAKE2b-256 47af64ca44d7d1145ea276d4ce69e3363cab48896679d0e0ef96f957a2d7c0ab

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyovf-0.2.8-cp39-cp39-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 81acf3c2b383e2bf3d7cd776b0a9abeb744c1dc9d4f0e6a837539c39de701493
MD5 be1da98c257bd7cd1e543c71bebe09f7
BLAKE2b-256 b2acd3e6b916abd901d4af009a031bbfbccf15bbde58207d766cf215a609d380

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