https://github.com/angelo-peronio/nanonis-xarray
Xarray plugin to read Nanonis spectroscopy .dat files
https://github.com/angelo-peronio/nanonis-xarray
afm dat mimea nanonis physics python specs sps stm stm-iets sts surface-science xarray
Last synced: 4 months ago
JSON representation
Xarray plugin to read Nanonis spectroscopy .dat files
- Host: GitHub
- URL: https://github.com/angelo-peronio/nanonis-xarray
- Owner: angelo-peronio
- License: mit
- Created: 2025-08-04T21:11:09.000Z (10 months ago)
- Default Branch: master
- Last Pushed: 2025-12-18T20:51:49.000Z (6 months ago)
- Last Synced: 2025-12-21T20:38:55.969Z (5 months ago)
- Topics: afm, dat, mimea, nanonis, physics, python, specs, sps, stm, stm-iets, sts, surface-science, xarray
- Language: Python
- Homepage:
- Size: 407 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Citation: CITATION.cff
Awesome Lists containing this project
README
# Xarray plugin to read Nanonis spectroscopy .dat files
[](https://pypi.org/project/nanonis-xarray/)
[](https://anaconda.org/conda-forge/nanonis-xarray)
[](https://pypistats.org/packages/nanonis-xarray)
[](https://github.com/angelo-peronio/nanonis-xarray/blob/master/LICENSE)
[](https://pypi.org/project/nanonis-xarray/)
[](https://github.com/angelo-peronio/nanonis-xarray/actions/workflows/ci.yaml)
[](https://results.pre-commit.ci/latest/github/angelo-peronio/nanonis-xarray/master)
[](https://codecov.io/github/angelo-peronio/nanonis-xarray)
[](https://scientific-python.org/specs/spec-0000/)
[](https://github.com/astral-sh/ruff)
[](https://doi.org/10.5281/zenodo.17095214)
`nanonis-xarray` is a [`xarray`](https://xarray.dev/) plugin to read spectroscopy measurements saved in text
format (`.dat`) by a [Nanonis Mimea](https://www.specs-group.com/nanonis/products/mimea/)
SPM control system from [SPECS Surface Nano Analysis GmbH](https://www.specs-group.com/).
The data is read into a [`xarray.Dataset`](https://docs.xarray.dev/en/stable/getting-started-guide/why-xarray.html#core-data-structures), where each measured channel (tunnelling current, AFM oscillation amplitude, …) is a [`xarray.DataArray`](https://docs.xarray.dev/en/stable/user-guide/data-structures.html#dataarray) with up to three dimensions:
* The independent variable of the measurement, such as sample 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.
```python
>>> 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) uint32 12B 1 2 3
* direction (direction) category 18B fw bw
```
[`pint-xarray`](https://xarray.dev/blog/introducing-pint-xarray) is used to associate a physical unit to each channel, unless `xr.open_dataset()` is called with `quantify_vars=False`:
```python
>>> data["current"].pint.units
```
The header of the measurement is stored in the `attrs` nested dictionary:
```python
>>> data.attrs["Z Spectroscopy"]["Number of sweeps"]
3
>>> data.attrs["Z Spectroscopy"]["backward sweep"]
True
```
Physical quantities are stored as [`pint.Quantity`](https://pint.readthedocs.io/en/stable/getting/tutorial.html#defining-a-quantity), timestamps as [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime-objects), and paths as [`pathlib.Path`](https://docs.python.org/3/library/pathlib.html#basic-use):
```python
>>> data.attrs["NanonisMain"]["RT Frequency"]
>>> 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:
* [`nanonispy2`](https://github.com/ceds92/nanonispy2)
* [`xarray-nanonis`](https://github.com/John3859/xarray-nanonis)
* ... and [many more](https://pypi.org/search/?q=nanonis).
## How to cite
Cite `nanonis-xarray` in your published work using the metadata in [`CITATION.cff`](CITATION.cff).
Specific DOIs and BibTeX entries for each released version can be found on [Zenodo](https://doi.org/10.5281/zenodo.17095214).