A Python package for reading STM experimental data files obtained from Nanonis, based on nanonispy
Project description
nanonis-reader 
A Python package for reading and processing Nanonis STM data files (.sxm, .dat, .3ds, .nsp).
Installation
pip install nanonis-reader
Dependencies
numpy,scipy,matplotlib,python-pptxscikit-learn(optional, for RANSAC fitting)
Quick Start
import nanonis_reader as nr
d = nr.load("path/to/file.sxm") # supports .sxm / .dat / .3ds / .nsp
All data is accessed through d.topo, d.sts, d.iz, d.fer, etc.
The available classes depend on the file type.
.sxm — Topography & Maps
d = nr.load("file.sxm")
# Topography
z = d.topo.raw() # forward scan (default)
z = d.topo.raw(scan_direction='bwd') # backward scan
z = d.topo.subtract_linear_fit() # line-by-line linear fit subtraction
z = d.topo.subtract_linear_fit_xy() # both x and y directions
z = d.topo.subtract_parabolic_fit() # parabolic fit subtraction
z = d.topo.subtract_plane_fit() # plane fit subtraction
z = d.topo.subtract_average() # row average subtraction
z = d.topo.differentiate() # dz/dx
# RANSAC (robust against steps/outliers)
z = d.topo.subtract_linear_fit(method='RANSAC')
z = d.topo.subtract_plane_fit(method='RANSAC', residual_threshold=1e-10)
# dI/dV map
didv = d.didv.raw() # raw lock-in signal
didv = d.didv.subtract_linear_fit() # with linear fit subtraction
didv = d.didv.subtract_linear_fit_xy() # x and y
# Current map
I = d.current.raw()
# FFT (accepts any 2D image: topo, didv, etc.)
fft_img = d.fft.sqrt(z) # sqrt(|FFT|)
fft_img = d.fft.log(z) # log(|FFT|)
fft_img = d.fft.linear(z) # |FFT|
fft_img = d.fft.sqrt(didv) # works on dI/dV maps too
.dat — Point Spectroscopy
.dat files contain various types of point spectroscopy.
Use d.sts, d.fer, or d.iz depending on the measurement type.
Note: Using
d.feron STS data (or vice versa) will show a warning.
STS (dI/dV vs Bias)
d = nr.load("sts_file.dat")
V, didv = d.sts.raw() # raw lock-in signal
V, didv = d.sts.scaled() # scaled by numerical derivative
V, didv = d.sts.numerical() # numerical dI/dV from current
V, didv = d.sts.normalized(factor=0.2) # normalized dI/dV
V, I = d.sts.iv() # I-V curve
# Sweep direction / index
V, didv = d.sts.scaled(sweep_direction='bwd') # backward sweep
V, didv = d.sts.scaled(sweep_index=0) # individual sweep
V, didv = d.sts.scaled(sweep_index='all') # all sweeps (2D array)
FER (Field Emission Resonance)
d = nr.load("fer_file.dat")
V, didv = d.fer.scaled() # dI/dV (inherited from STS)
V, dzdv = d.fer.dzdv_numerical() # dZ/dV (FER-only)
I-z Spectroscopy
d = nr.load("iz_file.dat")
z, I = d.iz.raw() # I-z curve
phi, err, slope = d.iz.barrier_height() # apparent barrier height (eV)
phi, err, slope = d.iz.barrier_height(fitting_current_range=(1e-12, 10e-12))
phi, err, slope = d.iz.barrier_height(method='RANSAC') # RANSAC fitting
Noise / History / Long-term
freq, psd = d.noise.get_noise() # noise spectrum
time, data = d.history.get_history('Z (m)') # history data
time, z = d.longterm.get_z_longterm_chart() # long-term Z chart
.3ds — Grid Spectroscopy
Grid data returns 3D arrays with shape (lines, pixels, sweep_points).
Use numpy slicing to extract points, maps, or lines.
STS Grid
d = nr.load("sts_grid.3ds")
# Topography
topo = d.topo.subtract_linear_fit()
# 3D dI/dV
V, didv = d.sts.scaled() # scaled dI/dV
V, didv = d.sts.normalized(factor=0.2) # normalized dI/dV
V, didv = d.sts.numerical() # numerical dI/dV
V, I = d.sts.iv() # I-V curves
V, didv = d.sts.raw() # raw lock-in signal
# Numpy slicing
spectrum = didv[line, pixel] # single point spectrum
didv_map = didv[:, :, bias_idx] # 2D map at specific bias
line_data = didv[line] # all spectra along a line
I-z Grid
d = nr.load("iz_grid.3ds")
Z, current = d.iz.raw() # 3D I-z curves
barrier_map = d.iz.barrier_height() # 2D apparent barrier height map (eV)
barrier_map = d.iz.barrier_height(method='RANSAC') # RANSAC fitting
FER Grid
d = nr.load("fer_grid.3ds")
V, didv = d.fer.scaled() # 3D dI/dV
V, dzdv = d.fer.dzdv_numerical() # 3D dZ/dV (FER-only)
.nsp — Noise Spectrum
from nanonis_reader.nsp import per_sqrt_hz
d = nr.load("file.nsp")
data = d.ltspec.get() # (freq_points, n_spectra)
unit = per_sqrt_hz(d.header['SIGNAL']) # e.g. '(A/sqrt(Hz))'
Standalone Utilities
These functions work on any numpy array without nr.load().
Image Processing
from nanonis_reader import image_processing as ip
# Apply to any 2D array
processed = ip.subtract_linear_fit(array_2d)
processed = ip.subtract_linear_fit_xy(array_2d)
processed = ip.subtract_average(array_2d)
processed = ip.subtract_parabolic_fit(array_2d)
processed = ip.subtract_plane_fit(array_2d)
processed = ip.differentiate(array_2d, dx=1.0)
# RANSAC fitting (robust against outliers/steps)
processed = ip.subtract_linear_fit(array_2d, method='RANSAC')
processed = ip.subtract_plane_fit(array_2d, method='RANSAC',
residual_threshold=1e-10, max_trials=500)
Spectral Analysis
from nanonis_reader.spectral_analysis import filter_sigma, normalize_didv
# Sigma filtering (remove outlier spectra from multi-sweep data)
filtered, mask = filter_sigma(spectra_2d, n_sigma=3)
# Standalone dI/dV normalization
V_n, norm = normalize_didv(V, dIdV, factor=0.2)
Custom Colormap
from nanonis_reader.cmap_custom import bwr, nanox
plt.imshow(topo, cmap=nanox()) # recommended for topography
plt.imshow(didv, cmap=bwr()) # recommended for dI/dV map
PPT Auto-generation
ppt = nr.util.DataToPPT(
base_path='your_folder_path',
keyword='your_file_keyword',
output_filename='output.pptx'
)
ppt.generate_ppt()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nanonis_reader-0.3.0.tar.gz.
File metadata
- Download URL: nanonis_reader-0.3.0.tar.gz
- Upload date:
- Size: 49.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee9193deda3293a7412dead1d545f615adae3efe4c12c7856a77e895018c6383
|
|
| MD5 |
1b73b0b2971b44f01c2550453dde1485
|
|
| BLAKE2b-256 |
688d7863c6acb788f9457bbbf28ca397a8332624b5fb1a1a7f373b91085cd4cf
|
File details
Details for the file nanonis_reader-0.3.0-py3-none-any.whl.
File metadata
- Download URL: nanonis_reader-0.3.0-py3-none-any.whl
- Upload date:
- Size: 54.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1181de1058879ab827b19ac3016b91e7f77c8a3113074bf8cb67e2b74b0b9430
|
|
| MD5 |
dbc6c5a482ed3dd12977ee17c20c14b1
|
|
| BLAKE2b-256 |
09da2e758f5c3298d8ea34bbea66b8b3e3f1986abe5434ba17954e227b49b9a1
|