Gridex - Your Grid Spectroscopy Solution

This notebook provides an example how to use the module gridex to read ASCII or binary Nanonis data. Fits of IZ and KPFM curves on a grid are demonstrated and the results are plotted in interactive graphs.

Installation

Get the file "gridex.py" and put it into your working directory or the python import path.

Uses: numpy, scipy, matplotlib, seaborn, IPython, ipywidgets

Tested with Python 3.4 and 3.5, numpy 1.10.1, scipy 0.16.0, matplotlib 1.5.0, seaborn 0.7.dev (0.6 gives some warnings, but works as well), IPython 4.0.1, ipywidgets 4.1.0

Alex Riss, 2017


In [1]:
# Import modules and initial setup.
# The "imp.realod" just reloads the module and is convenient for testing (the line can be left out).

%matplotlib notebook
import gridex
import ipywidgets
import IPython

datasets={}
plots={}

In [2]:
# load binary data

fname = 'data/name.3ds'
datasets[fname] = gridex.GridData()
datasets[fname].load_spectroscopy(fname)

# fit IZ
datasets[fname].fit_IZ()

In [3]:
# plot the results
# check out the keyboard shortcuts for the plot:
#     "m", "M" for markers, arrow keys to move the selected point, "i" to toggle legend, "g" to toggle grid

fname = 'data/name.3ds'  # repeat for testing

channels = ['phi_(ev)','fit_r2','fit_sse','z_(m)','amplitude_mean_(m)','amplitude_stddev_(m)']
plots[fname] = gridex.PlotData(datasets[fname])

fig = plots[fname].plot_channels(channels, cmap="Blues_r")
IPython.display.display(plots[fname].plot_options())


Image center: 310.5701, -325.1812 nm. Rotation: 0.00 degrees.

In [4]:
# load ASCII data

fname = 'data/KPFM_dimer_constz_grid2_*.dat'
datasets[fname] = gridex.GridData()
datasets[fname].load_spectroscopy(fname, long_output=False)
datasets[fname].fit_KPFM(x_limit=[-0.8,0.2])  # we can set a x_limit for the fit


400 files read.

In [5]:
# fit KPFM and plot the results

channels = ['v*_(v)','df*_(hz)','fit_r2','fit_sse','amplitude_mean_(m)','amplitude_stddev_(m)']
plots[fname] = gridex.PlotData(datasets[fname])
fig = plots[fname].plot_channels(channels, num_rows=3, cmap='Blues_r')   # cmap='Blues'
IPython.display.display(plots[fname].plot_options())


Warning: Do not know the dimensions of the image. Assuming a 20 x 20 grid of 2.40 x 2.40 nm.
Image center: 322.2180, -311.0400 nm. Rotation: 0.00 degrees.