Force Spectroscopy Processing

Import packages and find all the *.nid files.

In [42]:
from NSFopen.read import read as afmreader

import os
from os import listdir
from os.path import isfile, join

import numpy as np
import math
import collections
from pprint import pprint

import matplotlib
import matplotlib.pyplot as plt

from mpl_toolkits.axes_grid1 import make_axes_locatable
from mpl_toolkits.axes_grid1.colorbar import colorbar
%matplotlib inline

dirpath = os.getcwd()

# list all *.nid files
onlyfiles = [f for f in listdir(dirpath) if isfile(join(dirpath, f)) and f.split(".")[-1] == "nid"]

# list only files where there is "spectroscopy_" in the filename
force_files = [f for f in onlyfiles if "spectroscopy" in f.split("_")]

print(dirpath, "with", len(force_files)," *.nid force files:")
pprint(force_files)
Q:\Marketing\Projects\Jupyter Notebooks\ForceSpetroscopy with 1  *.nid force files:
['spectroscopy_0001.nid']

Read data

In [43]:
filename = 'spectroscopy_0001.nid'
alldata = afmreader(filename, verbose=False).data
params = afmreader(filename, verbose=False).param

Study the data

In [44]:
alldata
Out[44]:
Image  Forward   Z-Axis           [[-2.0353380013257264e-06, -2.0353067460469904...
                 Amplitude        [[0.19510995596647263, 0.19624395295977592, 0....
                 Phase            [[-0.3227592632174492, -0.570032112300396, 1.4...
                 Z-Axis Sensor    [[1.3012584000825895e-06, 1.3011265546083438e-...
                 Deflection                                                     NaN
       Backward  Z-Axis           [[-2.0308267816901207e-06, -2.0314367319457234...
                 Amplitude        [[0.19098110496997833, 0.19194109365344048, 0....
                 Phase            [[-0.9834825620055199, -1.571555882692337, 0.6...
                 Z-Axis Sensor    [[1.301939662545919e-06, 1.301317282021045e-06...
                 Deflection                                                     NaN
Spec   Forward   Z-Axis                                                         NaN
                 Amplitude                                                      NaN
                 Phase                                                          NaN
                 Z-Axis Sensor    [[-2.4028351604938504e-06, -2.4016023427248004...
                 Deflection       [[-5.270044375212667e-10, -5.464680488219607e-...
       Backward  Z-Axis                                                         NaN
                 Amplitude                                                      NaN
                 Phase                                                          NaN
                 Z-Axis Sensor    [[-2.1268137395381934e-06, -2.1259107962250702...
                 Deflection       [[-8.34981137885745e-11, -1.0336219565944979e-...
dtype: object
In [46]:
params
Out[46]:
Tip          Manufacturer                                                                                 BudgetSensors
             Name                                                                                            Tap150Al-G
             Prop0                                                                    {'Value': 2.72436, 'Unit': 'N/m'}
             Prop1                                                                    {'Value': 150000.0, 'Unit': 'Hz'}
             Prop2                                                                     {'Value': 0.000125, 'Unit': 'm'}
                                                                                            ...                        
Header Dump  ProcessorSet-{138707ED-FD93-4E28-B2B0-C5DA628CB815}:0    {'Name': 'Indentation', 'GUID': '{138707ED-FD9...
             ProcessorSet-{AB0B4062-81AF-464B-A7F7-75B11891ACF8}:0    {'Name': 'Slope', 'GUID': '{AB0B4062-81AF-464B...
             ProcessorSet-{AB0B4062-81AF-464B-A7F7-75B11891ACF8}:1    {'Name': 'Slope', 'GUID': '{AB0B4062-81AF-464B...
             ProcessorSet-{1220F4A8-053A-494D-B28C-3635059D1530}:0    {'Name': 'MaxAdhesion', 'GUID': '{1220F4A8-053...
             ProcessorSet-{1220F4A8-053A-494D-B28C-3635059D1530}:1    {'Name': 'MaxAdhesion', 'GUID': '{1220F4A8-053...
Length: 88, dtype: object

Read spectorscopy data

In [47]:
adhesion_data = alldata['Spec']['Backward']['Deflection']
zaxis = alldata['Spec']['Backward']['Z-Axis Sensor']

Plot spectorscopy data

In [49]:
font = {'size': 16}
matplotlib.rc('font', **font)

adhesion_force = []

for i in range(len(adhesion_data)):
    plt.plot(zaxis[i]*1e9+1250, adhesion_data[i]*1e9)
    adhesion_force.append(np.min(adhesion_data[i]*1e9))

plt.xlim([-100, 100])
plt.ylim([-15, 5])
plt.xticks(np.arange(-50, 150, step=50))

plt.xlabel('Z (nm)')
plt.ylabel('Force (nN)')

fig = matplotlib.pyplot.gcf()
fig.set_size_inches(11, 10)
fig.savefig('adhesion.png', dpi=300)

plt.show()

Plot histogram

In [50]:
med = np.median(adhesion_force)
stdev = np.std(adhesion_force)
n, bins, patches = plt.hist(adhesion_force, 100, density=True, facecolor='g', alpha=0.75)
plt.title('\u00B5 = {:.1f} nN, \u03C3 = {:.2f} nN'.format(med, stdev))
plt.xlabel('Force (nN)')
plt.ylabel('Occurence')
fig = matplotlib.pyplot.gcf()
fig.set_size_inches(11, 10)
fig.savefig('adhesion_dist.png', dpi=300)