Skip to content

A Python library to read and write Gwyddion Simple Field files

License

Notifications You must be signed in to change notification settings

angelo-peronio/gsffile

Repository files navigation

Read and write Gwyddion Simple Field files

pypi conda-forge python license ci codecov pre-commit.ci status 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 and an overgrown test suite.

Setup

Install with pip

python -m pip install --upgrade 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, 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)"