Reading and writing binary OVF files for mumax3 or OOMMF.
Project description
pyOVF
PyOVF is a Python3 package for reading and writing binary OVF files (mumax3 or OOMMF) using the python connector provided by the OVF RW project (which is not open-source yet).
Installation
Use the package manager pip to install pyovf.
pip install pyovf
This package is also available in this private GitLab instance and can be installed using the --extra-index-url parameter.
pip install pyovf --extra-index-url https://gitlab.flavio.be/api/v4/projects/16/packages/pypi/simple
This library relies on the compiled C++ code from OVF RW project. The compiled versions are the following:
- Linux (x86_64) | python {3.10, 3.11, 3.12, 3.13} (Ubuntu 22.04)
- macOS (darwin, apple silicon) | python {3.10, 3.11, 3.12, 3.13} (Sonoma)
As far as the main operating systems are concerned, the following are not available yet:
- Windows (any)
- Linux (armv7l, ARM arch64)
Usage
import pyovf as OVF
import numpy as np
print(f'pyOVF version: {OVF.__version__}')
#* Create a (2, 2, 2, 3) ndarray representing a fictive vector field
data_in = np.array([[[[1.1, 1.2, 1.3], # vector @ z-comp 0, y-comp 0, x-comp 0
[1.4, 1.5, 1.6]], # vector @ z-comp 0, y-comp 0, x-comp 1
[[2.1, 2.2, 2.3], # vector @ z-comp 0, y-comp 1, x-comp 0
[2.4, 2.5, 2.6]]], # vector @ z-comp 0, y-comp 1, x-comp 1
[[[3.1, 3.2, 3.3], # vector @ z-comp 1, y-comp 0, x-comp 0
[3.4, 3.5, 3.6]], # vector @ z-comp 1, y-comp 0, x-comp 1
[[4.1, 4.2, 4.3], # vector @ z-comp 1, y-comp 1, x-comp 0
[4.4, 4.5, 4.6]]], # vector @ z-comp 1, y-comp 1, x-comp 1
], dtype=np.float32)
#* Writes data_in into file
OVF.write('test.ovf', data_in, title="J", Xlim=[0,10e-9],
Ylim=[0,10e-9], Zlim=[0,10e-9])
#* Reads data and meshgrid (X, Y) from file
X, Y, data_out = OVF.read('test.ovf')
#?INFO output format => data_out[z-comp, y-comp, x-comp, vect-comp]
#?INFO vect-comp = 0 for scalar field data (geam, etc.)
#?INFO vect-comp = {0, 1, 2} for scalar field data (m, B_ext, etc.)
print(data_out.shape)
#? Checks if the data elements correspond
if (data_in == data_out.squeeze()).all():
print('Test passed!')
#* Reads data (only) from file
data_out2 = OVF.read_data_only('test.ovf')
#?INFO read_data_only applies squeeze(), so z-comp may desappear
#?INFO if data is scalar field, the vect-comp also desappears
print(data_out2.shape)
#? Checks if the data elements correspond
if (data_in == data_out2).all():
print('Test passed!')
Contributing
Pull requests are welcome.
License
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyovf-0.2.3.tar.gz.
File metadata
- Download URL: pyovf-0.2.3.tar.gz
- Upload date:
- Size: 1.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d67183ab7dc341cdbf600350b937c92cc120fa3d8ec6831a265d06001f59e34d
|
|
| MD5 |
244ad783f0da0197610d7c1091ef0a7a
|
|
| BLAKE2b-256 |
cae4431f36579108ef12542bb0c7918b57662071d6ce89f0a77e92a2cd69a5c1
|
File details
Details for the file pyovf-0.2.3-py3-none-any.whl.
File metadata
- Download URL: pyovf-0.2.3-py3-none-any.whl
- Upload date:
- Size: 1.4 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
652ff1cf25baf009424f9d5e15502ca412c5d904e95ad0f641e8904f7a6f4584
|
|
| MD5 |
544ebb7a3e97561930ac34e4055d7fca
|
|
| BLAKE2b-256 |
f9b7952080de7c141ee2ca6c2c3e2755c15db3695b55d6eddb42a831dc07c9e1
|