# Read Nanonis spectroscopy .dat files into xarray Datasets
[](https://pypi.org/project/nanonis-xarray/)
[](https://github.com/angelo-peronio/nanonis-xarray/blob/master/LICENSE)
[](https://pypi.org/project/nanonis-xarray/)
[](https://scientific-python.org/specs/spec-0000/)
[](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://github.com/astral-sh/ruff)
`nanonis_xarray` is a Python module 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 quantity, such as tunnelling current or 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 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.
It becomes then easy to e.g. plot the average of one measured channel in the forward direction:
```python
from matplotlib import pyplot as plt
from nanonis_xarray import read_dat
data = read_dat("tests/data/z.dat")
fig, ax = plt.subplots()
data["current"].mean(dim=["sweep"]).sel(direction="fw").plot()
```
## Work in progress
This library is under development: expect breaking changes. I do not plan to support the Nanonis binary formats (`.sxm`, `.3ds`), which 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).
Raw data
{
"_id": null,
"home_page": null,
"name": "nanonis-xarray",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": null,
"keywords": "AFM, Atomic Force Microscopy, Inelastic Electron Tunnelling Spectroscopy, Mimea, Nanonis, SPECS, SPS, STM, STM-IETS, STS, Scanning Probe Spectroscopy, Scanning Tunnelling Microscopy, Scanning Tunnelling Spectroscopy, xarray",
"author": "Angelo Peronio",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/ca/99/1988f1838114e6c79514924dfbfcd0037a41308a55b8b538bbf9fd0ef0b3/nanonis_xarray-0.1.2.tar.gz",
"platform": null,
"description": "# Read Nanonis spectroscopy .dat files into xarray Datasets\n\n[](https://pypi.org/project/nanonis-xarray/)\n[](https://github.com/angelo-peronio/nanonis-xarray/blob/master/LICENSE)\n[](https://pypi.org/project/nanonis-xarray/)\n[](https://scientific-python.org/specs/spec-0000/)\n[](https://github.com/angelo-peronio/nanonis-xarray/actions/workflows/ci.yaml)\n[](https://results.pre-commit.ci/latest/github/angelo-peronio/nanonis-xarray/master)\n[](https://codecov.io/github/angelo-peronio/nanonis-xarray)\n[](https://github.com/astral-sh/ruff)\n\n`nanonis_xarray` is a Python module to read spectroscopy measurements saved in text\nformat (`.dat`) by a [Nanonis Mimea](https://www.specs-group.com/nanonis/products/mimea/)\nSPM control system from [SPECS Surface Nano Analysis GmbH](https://www.specs-group.com/).\n\nThe 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 quantity, such as tunnelling current or AFM oscillation amplitude, is a [`xarray.DataArray`](https://docs.xarray.dev/en/stable/user-guide/data-structures.html#dataarray) with up to three dimensions:\n\n* The independent variable of the measurement, such as bias voltage or tip z position;\n* The sweep number, if the measurement has been repeated multiple times;\n* The sweep direction (forward or backward), if the independent variable has been swept in both directions.\n\nIt becomes then easy to e.g. plot the average of one measured channel in the forward direction:\n\n```python\nfrom matplotlib import pyplot as plt\n\nfrom nanonis_xarray import read_dat\n\ndata = read_dat(\"tests/data/z.dat\")\nfig, ax = plt.subplots()\ndata[\"current\"].mean(dim=[\"sweep\"]).sel(direction=\"fw\").plot()\n```\n\n## Work in progress\n\nThis library is under development: expect breaking changes. I do not plan to support the Nanonis binary formats (`.sxm`, `.3ds`), which can be read by similar projects:\n\n* [`nanonispy2`](https://github.com/ceds92/nanonispy2)\n* [`xarray-nanonis`](https://github.com/John3859/xarray-nanonis)\n* ... and [many more](https://pypi.org/search/?q=nanonis).\n",
"bugtrack_url": null,
"license": null,
"summary": "Read a Nanonis spectroscopy .dat file into a xarray Dataset",
"version": "0.1.2",
"project_urls": null,
"split_keywords": [
"afm",
" atomic force microscopy",
" inelastic electron tunnelling spectroscopy",
" mimea",
" nanonis",
" specs",
" sps",
" stm",
" stm-iets",
" sts",
" scanning probe spectroscopy",
" scanning tunnelling microscopy",
" scanning tunnelling spectroscopy",
" xarray"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "24327a00f21bd21e7f2de3d9765f98786deeafafe0a423d6d294265a72d9407b",
"md5": "14ff06fecfd6f5b4ebd4d3e874daeddb",
"sha256": "c8e4953a458f5a7a2a9d329777635cacc3b52f5999c43c7dc5af00ebd8662b88"
},
"downloads": -1,
"filename": "nanonis_xarray-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "14ff06fecfd6f5b4ebd4d3e874daeddb",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 7801,
"upload_time": "2025-08-05T19:28:05",
"upload_time_iso_8601": "2025-08-05T19:28:05.909625Z",
"url": "https://files.pythonhosted.org/packages/24/32/7a00f21bd21e7f2de3d9765f98786deeafafe0a423d6d294265a72d9407b/nanonis_xarray-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "ca991988f1838114e6c79514924dfbfcd0037a41308a55b8b538bbf9fd0ef0b3",
"md5": "a1809abd629dac2a471a58939ddd8380",
"sha256": "7e2b7614fb308e99be0e0cddfe8e635ab7d3de4d7c1c0f25f0bf0b97323c62e3"
},
"downloads": -1,
"filename": "nanonis_xarray-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "a1809abd629dac2a471a58939ddd8380",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 8815,
"upload_time": "2025-08-05T19:28:07",
"upload_time_iso_8601": "2025-08-05T19:28:07.141022Z",
"url": "https://files.pythonhosted.org/packages/ca/99/1988f1838114e6c79514924dfbfcd0037a41308a55b8b538bbf9fd0ef0b3/nanonis_xarray-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-05 19:28:07",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "nanonis-xarray"
}