Skip to main content

Read a Nanonis spectroscopy .dat file into a xarray Dataset

Project description

Xarray plugin to read Nanonis spectroscopy .dat files

pypi conda-forge pypi downloads license python SPEC 0 — Minimum Supported Dependencies ci pre-commit.ci status codecov ruff DOI

nanonis-xarray is a xarray plugin to read spectroscopy measurements saved in text format (.dat) by a Nanonis Mimea SPM control system from SPECS Surface Nano Analysis GmbH.

The data is read into a xarray.Dataset, where each measured channel (tunnelling current, AFM oscillation amplitude, …) is a xarray.DataArray with up to three dimensions:

  • The independent variable of the measurement, such as bias voltage or tip z position;
  • The sweep number, if the measurement has been repeated multiple times;
  • The sweep direction (forward or backward), if the independent variable has been swept in both directions.
>>> import xarray as xr

>>> data = xr.open_dataset("tests/data/z.dat")
>>> data.coords
Coordinates:
  * z_rel      (z_rel) float64 2kB [m] -2.1e-10 -2.065e-10 ... 4.865e-10 4.9e-10
  * sweep      (sweep) int64 24B 1 2 3
  * direction  (direction) object 16B 'bw' 'fw'

pint-xarray is used to associate a physical unit to each channel, unless xr.open_dataset() is called with quantify_vars=False:

>>> data["current"].pint.units
<Unit('ampere')>

The header of the measurement is stored in the attrs nested dictionary:

>>> data.attrs["Z Spectroscopy"]["Number of sweeps"]
3
>>> data.attrs["Z Spectroscopy"]["backward sweep"]
True

Physical quantities are stored as pint.Quantity, timestamps as datetime.datetime, and paths as pathlib.Path:

>>> data.attrs["NanonisMain"]["RT Frequency"]
<Quantity(10000.0, 'hertz')>
>>> data.attrs["Date"]
datetime.datetime(2015, 3, 27, 11, 49, 5)

🚧 Work in progress 🚧

This library is under development: expect breaking changes. Nanonis binary formats (.sxm, .3ds) are currently not supported, and can be read by similar projects:

How to cite

Cite nanonis-xarray in your published work using the metadata in CITATION.cff, or this general BibTeX entry:

@misc{Peronio_nanonis-xarray_2025,
title = {nanonis-xarray},
author = {Peronio, Angelo},
url = {https://github.com/angelo-peronio/nanonis-xarray},
doi = {10.5281/zenodo.17095214},
year = {2025},
month = {5}
}

Specific DOIs for each released version are listed on Zenodo, but are not included in CITATION.cff due to a limitation of Zenodo itself.

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

nanonis_xarray-0.1.6.tar.gz (102.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nanonis_xarray-0.1.6-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file nanonis_xarray-0.1.6.tar.gz.

File metadata

  • Download URL: nanonis_xarray-0.1.6.tar.gz
  • Upload date:
  • Size: 102.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for nanonis_xarray-0.1.6.tar.gz
Algorithm Hash digest
SHA256 330e0dc97e3ff2adb4ec56b93b6343746394bc040eb8f580988b89ea512c2466
MD5 da51d56267459ffe1d84aadeda662b20
BLAKE2b-256 eff6204e5b6c90bedeef217519e09acb0e44b806df76ef8ad071eb99c2e54759

See more details on using hashes here.

Provenance

The following attestation bundles were made for nanonis_xarray-0.1.6.tar.gz:

Publisher: ci.yaml on angelo-peronio/nanonis-xarray

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nanonis_xarray-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: nanonis_xarray-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for nanonis_xarray-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 4abe5422f4d4a547e9032ecd89f50c55e54324ea2cbddd149927c0eaa9e2c865
MD5 cef2cb11321ca6507db9c84984a404c0
BLAKE2b-256 ee6730e6c3ff31276cdbe1620e6ef97d8e7501129d2f1de5373ccff1c822181c

See more details on using hashes here.

Provenance

The following attestation bundles were made for nanonis_xarray-0.1.6-py3-none-any.whl:

Publisher: ci.yaml on angelo-peronio/nanonis-xarray

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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