Skip to main content
https://img.shields.io/pypi/v/gwyfile.svg https://img.shields.io/pypi/l/gwyfile.svg https://img.shields.io/pypi/wheel/gwyfile.svg https://img.shields.io/pypi/pyversions/gwyfile.svg

A pure Python interface to reading and writing Gwyddion files.

Installation

$ pip install gwyfile

Usage

At the heart of this module is the GwyObject class, derived from collections.OrderedDict. Gwyddion files are just serialized copies of GwyObjects and its subclasses (GwyContainer, GwyDataField, …).

Here is a simple example that shows how to load a file and display a data channel:

import gwyfile

# Load a Gwyddion file into memory
obj = gwyfile.load('test.gwy')
# Return a dictionary with the datafield titles as keys and the
# datafield objects as values.
channels = gwyfile.util.get_datafields(obj)
channel = channels['Test']
# Datafield objects have a `data` property to access their
# two-dimensional data as numpy arrays.
data = channel.data

# Plot the data using matplotlib.
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.imshow(data, interpolation='none', origin='upper',
        extent=(0, channel.xreal, 0, channel.yreal))
plt.show()

It is also possible to manipulate and save objects:

import numpy as np
from gwyfile.objects import GwyContainer, GwyDataField
obj = GwyContainer()
obj['/0/data/title'] = 'Noise'
data = np.random.normal(size=(256, 256))
obj['/0/data'] = GwyDataField(data)
obj.tofile('noise.gwy')

The Gwyddion manual has a nice description of the file format. See there for further information on object properties.

Status

GwyObject serialization and deserialization should be complete. There are specialized subclasses for GwyDataField and GwySIUnit, but other convenience wrappers e.g. for GwyBrick are missing.

License

This project is licensed under the MIT license. See LICENSE.rst for details.

© 2014-17 Tino Wagner

Release files for gwyfile 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gwyfile 0.3.0
File Size Uploaded
gwyfile-0.3.0.tar.gz 133.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gwyfile 0.3.0
File Interpreter ABI Platform
gwyfile-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size:141.2 kB

Release files / gwyfile-0.3.0.tar.gz

Download URL gwyfile-0.3.0.tar.gz
Size 133.7 kB
Tags Source
SHA-256 checksum
How to use checksums
c12b1bab832698af554afad1e6e4f9c06b1d309b589e235a8ef365bdeef66549
BLAKE2b-256 checksum
How to use checksums
e4f94652b4d44cfeb9ddfb3ea8e0da0e98eb23e51dc181adb039f92af3fe2171
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / gwyfile-0.3.0-py3-none-any.whl

Download URL gwyfile-0.3.0-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6a68c5c748f0390cce1e0d6b8d622fa7f267ef94d47aa5fd7eb95abfeb4256c1
BLAKE2b-256 checksum
How to use checksums
c60326d3d8eab0d4df620830a6a3296878d08e3a9240c206d38f5b2e8aeb6a9f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page