/gsffile

A Python library to read and write Gwyddion Simple Field files

Primary LanguagePythonMIT LicenseMIT

Read and write Gwyddion Simple Field files

pypi conda-forge python license ci pre-commit.ci status codecov ruff

gsffile is a Python library to:

  • read image and metadata from Gwyddion Simple Field (.gsf) files, and
  • store NumPy arrays in Gwyddion Simple Field files.

It features type annotations, minimal logging, and an overgrown test suite.

Setup

Install with pip

python -m pip install gsffile

or with conda

conda install gsffile

Quickstart

from gsffile import read_gsf, write_gsf
import numpy as np

# The Gwyddion Simple Field format supports only 32-bit floating point data.
data = np.eye(100, dtype=np.float32)

# Optional metadata.
metadata = {
    "XReal": 5e-05,
    "YReal": 5e-05,
    "XYUnits": "m",
    "ZUnits": "V",
    "CustomKey": 33,
    }

write_gsf("example.gsf", data, metadata)

data, metadata = read_gsf("example.gsf")

Documentation

gsffile is documented via docstrings:

python -c "import gsffile; help(gsffile)"