Skip to main content

Reading and writing binary OVF files for mumax3 or OOMMF.

Project description

PyPI PyPI - Python Version PyPI - Wheel PyPI - License Downloads

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, 3.14} (Ubuntu 22.04)
  • macOS (darwin, apple silicon) | python {3.10, 3.11, 3.12, 3.13, 3.14} (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

MIT

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.6.tar.gz (2.5 MB view details)

Uploaded Source

Built Distribution

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

pyovf-0.2.6-py3-none-any.whl (2.5 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyovf-0.2.6.tar.gz
  • Upload date:
  • Size: 2.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for pyovf-0.2.6.tar.gz
Algorithm Hash digest
SHA256 279ab018766e359ed23e5ac71f5fa2606fa481f1de07e4645a3e903c39dcbc56
MD5 0c049f7d7867c7a5126cdbadea3e439e
BLAKE2b-256 6c583b7f6aef11880876e1c29909ee7e7b648a477efa995c36deb6246ea25965

See more details on using hashes here.

File details

Details for the file pyovf-0.2.6-py3-none-any.whl.

File metadata

  • Download URL: pyovf-0.2.6-py3-none-any.whl
  • Upload date:
  • Size: 2.5 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for pyovf-0.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 6bc9c2012d9a9ec293b377bcdc8c76490259303f8fa5b35b315f894ff3b0ec3b
MD5 b401ea9938a4647cb301631432548061
BLAKE2b-256 7057b9af6cb14b6223269b9b31c9b9ffa19d3f1e1bc1849038d48c0dbda3e003

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