Skip to main content

Pure Python implementation of the Gwyddion file format

Project description

A pure Python interface to reading and writing Gwyddion files.

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

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

gwyfile-0.2.0.tar.gz (22.0 kB view details)

Uploaded Source

Built Distribution

gwyfile-0.2.0-py2.py3-none-any.whl (8.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file gwyfile-0.2.0.tar.gz.

File metadata

  • Download URL: gwyfile-0.2.0.tar.gz
  • Upload date:
  • Size: 22.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for gwyfile-0.2.0.tar.gz
Algorithm Hash digest
SHA256 cf72fedd6af15c952067dbbe87978a4a6262b4e2cd3aa9f2e7bee4ced4071e40
MD5 a30eef80bf3620fbae8cb064e7663665
BLAKE2b-256 694835af6771af84d4ef3241fe1a02c41f0652a38e3ed945bbfd0ac4d7725bfd

See more details on using hashes here.

File details

Details for the file gwyfile-0.2.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for gwyfile-0.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 83cca2b8b5283652322f98791a36fdc1375cb25ea7ba88899056e7a00069760f
MD5 8930d9c0b3a6cc8eb04658fe6378fe07
BLAKE2b-256 28a87e1f5105cbf8200705f130545c9ad54592c52c34717609f87570e5a5e2af

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page