Skip to main content

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.7, 3.8, 3.9, 3.10} (Ubuntu 20.04)

  • macOS (darwin, intel) | python {3.7, 3.8, 3.9, 3.10} (Catalina)

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.1.tar.gz (1.4 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.1-py3-none-any.whl (1.4 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyovf-0.2.1.tar.gz
  • Upload date:
  • Size: 1.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for pyovf-0.2.1.tar.gz
Algorithm Hash digest
SHA256 07169997ebbfabc5ad74c078346b0b0f626d2debc6dc327e96de3c1b5f184e1a
MD5 5f234033f6e60d63c2a99f5b42edf0c0
BLAKE2b-256 713b510f154a617c760d21fbdb8a98f5928985bdd9096aa99d1285c0c8bbaa2f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyovf-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for pyovf-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 051fcc5742b4ef9ec189a2920029f1b8ede34acbea04cd3dc551a76fc919b1e6
MD5 90dfc904dc7b5ae22bde3c1af3e9305e
BLAKE2b-256 4dcaec818c2392b7ad0df3d840c56dc975d3dd620ae66fe30e0204c00005d8e9

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