Skip to content

angelo-peronio/nanonis-xarray

Repository files navigation

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

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:

About

Xarray plugin to read Nanonis spectroscopy .dat files

Topics

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •