NSFopen 2.1.6__tar.gz → 2.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. NSFopen-2.2.1/NSFopen/_version.py +1 -0
  2. NSFopen-2.2.1/NSFopen/process/process.py +459 -0
  3. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen/read/read.py +11 -0
  4. NSFopen-2.2.1/NSFopen/read/read_beta.py +658 -0
  5. {NSFopen-2.1.6 → NSFopen-2.2.1/NSFopen.egg-info}/PKG-INFO +6 -1
  6. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen.egg-info/SOURCES.txt +2 -1
  7. {NSFopen-2.1.6/NSFopen.egg-info → NSFopen-2.2.1}/PKG-INFO +6 -1
  8. NSFopen-2.1.6/NSFopen/_version.py +0 -1
  9. NSFopen-2.1.6/NSFopen/process/process.py +0 -205
  10. {NSFopen-2.1.6 → NSFopen-2.2.1}/LICENSE +0 -0
  11. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen/__init__.py +0 -0
  12. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen/example/Calculate_Roughness/Calculate_Roughness.html +0 -0
  13. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen/example/Calculate_Roughness/Calculate_Roughness.ipynb +0 -0
  14. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen/example/Calculate_Roughness/Calculate_Roughness.py +0 -0
  15. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen/example/Calculate_Roughness/__pycache__/Calculate_Roughness.cpython-310.pyc +0 -0
  16. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen/example/Calculate_Roughness/sapphire.nid +0 -0
  17. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen/example/Force_Spectroscopy/Force_Spectroscopy.html +0 -0
  18. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen/example/Force_Spectroscopy/Force_Spectroscopy.ipynb +0 -0
  19. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen/example/Force_Spectroscopy/Force_Spectroscopy.py +0 -0
  20. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen/example/Force_Spectroscopy/spectroscopy.nid +0 -0
  21. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen/example/Lateral_Force/Lateral Force Processing.html +0 -0
  22. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen/example/Lateral_Force/Lateral Force Processing.ipynb +0 -0
  23. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen/example/Lateral_Force/Lateral Force Processing.py +0 -0
  24. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen/example/Lateral_Force/SBS-PMMA.nid +0 -0
  25. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen/example/Plane_Removal/Plane_Removal.html +0 -0
  26. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen/example/Plane_Removal/Plane_Removal.ipynb +0 -0
  27. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen/example/Plane_Removal/Plane_Removal.py +0 -0
  28. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen/example/Plane_Removal/circles.nid +0 -0
  29. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen/example/Plane_Removal/circles_holes.nid +0 -0
  30. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen/example/Plane_Removal/grid.nid +0 -0
  31. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen/example/Plane_Removal/squares_holes.nid +0 -0
  32. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen/example/Plotting_Data/MoS2.nid +0 -0
  33. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen/example/Plotting_Data/Plotting Data.html +0 -0
  34. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen/example/Plotting_Data/Plotting Data.ipynb +0 -0
  35. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen/example/Plotting_Data/Plotting Data.py +0 -0
  36. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen/example/Sharpen_Image/Sharpen Image.html +0 -0
  37. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen/example/Sharpen_Image/Sharpen Image.ipynb +0 -0
  38. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen/example/Sharpen_Image/Sharpen Image.py +0 -0
  39. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen/example/Sharpen_Image/grid.nid +0 -0
  40. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen/example/Sharpen_Image/img.jpg +0 -0
  41. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen/example/Spring_Constant/Spring_Constant.html +0 -0
  42. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen/example/Spring_Constant/Spring_Constant.ipynb +0 -0
  43. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen/example/Spring_Constant/Spring_Constant.py +0 -0
  44. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen/example/Spring_Constant/__pycache__/Spring_Constant.cpython-310.pyc +0 -0
  45. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen/example/Spring_Constant/__pycache__/__init__.cpython-310.pyc +0 -0
  46. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen/example/Spring_Constant/sader.py +0 -0
  47. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen/example/Spring_Constant/thermal.nid +0 -0
  48. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen/example/Spring_Constant/thermal.png +0 -0
  49. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen/process/__init__.py +0 -0
  50. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen/read/__init__.py +0 -0
  51. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen.egg-info/dependency_links.txt +0 -0
  52. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen.egg-info/entry_points.txt +0 -0
  53. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen.egg-info/not-zip-safe +0 -0
  54. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen.egg-info/requires.txt +0 -0
  55. {NSFopen-2.1.6 → NSFopen-2.2.1}/NSFopen.egg-info/top_level.txt +0 -0
  56. {NSFopen-2.1.6 → NSFopen-2.2.1}/README.md +0 -0
  57. {NSFopen-2.1.6 → NSFopen-2.2.1}/pyproject.toml +0 -0
  58. {NSFopen-2.1.6 → NSFopen-2.2.1}/setup.cfg +0 -0
  59. {NSFopen-2.1.6 → NSFopen-2.2.1}/setup.py +0 -0
@@ -0,0 +1 @@
1
+ __version__ = "2.2.1"
@@ -0,0 +1,459 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Created on Thu Jun 4 15:13:47 2020
4
+
5
+ @author: Edward
6
+ """
7
+
8
+ from NSFopen.read import read
9
+ import numpy as np
10
+ import matplotlib.pyplot as plt
11
+ from mpl_toolkits.mplot3d import Axes3D
12
+ from matplotlib.ticker import LinearLocator, FormatStrFormatter
13
+ from matplotlib import cm
14
+ from scipy.ndimage import gaussian_filter,median_filter
15
+ from sklearn.impute import KNNImputer
16
+ from scipy import stats
17
+
18
+ import pandas as pd
19
+ import scipy.stats as ss
20
+ import os, sys
21
+
22
+
23
+ class process():
24
+ def __init__(self, filename):
25
+
26
+ afm = read(filename)
27
+ self.data = afm.data
28
+ self.param = afm.param
29
+
30
+ def flatten(self,
31
+ order=1,
32
+ direction='Forward',
33
+ channel='Z-Axis',
34
+ mask=[],
35
+ inplace=True):
36
+ """ Flattens an image using a nth-order polynomial
37
+
38
+ Parameters
39
+ ----------
40
+
41
+ order : int, default 1
42
+ Order of the polynomial
43
+ direction : {'Forward','Backward'}, defulat 'Forward'
44
+ Scan direction to use
45
+ channel : string, default 'Z-Axis'
46
+ Name of channel to use
47
+ mask : boolean array
48
+ Mask where True values are ignored in the input array
49
+ inplace : boolean, default True
50
+
51
+ Return
52
+ ------
53
+ array or None
54
+ Flattened image or None if inplace=True
55
+
56
+ """
57
+ data_out = self.data['Image'][direction][channel]
58
+ data_in = data_out.copy()
59
+ data_in = np.array(data_in, dtype=float)
60
+ x = np.arange(data_in.shape[1])
61
+
62
+ if np.any(mask):
63
+ data_in[mask] = np.nan
64
+ for idx, (out, line) in enumerate(zip(data_out, data_in)):
65
+ ix = np.isfinite(line)
66
+ p = np.polyfit(x[ix], line[ix], order)
67
+ y = np.polyval(p, x)
68
+ data_out[idx] = out - y
69
+ if inplace:
70
+ self.data['Image'].loc[direction,channel] = data_out
71
+ return None
72
+ else:
73
+ return data_out
74
+
75
+ def plane_level(self,
76
+ direction='Forward',
77
+ channel='Z-Axis',
78
+ inplace=True):
79
+ data_out = self.data['Image'][direction][channel]
80
+ data_in = data_out.copy()
81
+ data_in = np.array(data_in, dtype=float)
82
+
83
+ # x_size = self.param.X.range[0] * 1e6
84
+ # y_size = self.param.Y.range[0] * 1e6
85
+
86
+ # xs = np.linspace(0,x_size,data_in.shape[0])
87
+ # ys = np.linspace(0,y_size,data_in.shape[1])
88
+
89
+ xs = np.arange(0,data_in.shape[0])
90
+ ys = np.arange(0,data_in.shape[1])
91
+ xs,ys = np.meshgrid(xs,ys)
92
+ ones = np.ones(xs.shape)
93
+
94
+ reshape = (lambda x: np.reshape(x,(len(x)**2,1)))
95
+
96
+ A = np.matrix(np.hstack([reshape(xs),reshape(ys),reshape(ones)]))
97
+ b = np.matrix(reshape(data_in))
98
+
99
+ fit = (A.T * A).I * A.T * b
100
+ plane = np.reshape(A*fit,data_in.shape)
101
+ data_out-=plane
102
+ if inplace:
103
+ self.data['Image'].loc[direction,channel] = data_out
104
+ return None
105
+ else:
106
+ return data_out
107
+
108
+ def remove_outliers(self,
109
+ direction='Forward',
110
+ channel='Z-Axis',
111
+ q=0.01,
112
+ neighbors=5,
113
+ inplace=True):
114
+ data_out = self.data['Image'][direction][channel]
115
+ data_in = data_out.copy()
116
+ data_in = np.array(data_in, dtype=float)
117
+
118
+ if isinstance(q,list):
119
+ q0,q1=q
120
+ else:
121
+ q0=q1=q
122
+
123
+ value = np.quantile(data_in,q=[q0,1-q1])
124
+ mask = (data_in<value[0]) | (data_in>value[1])
125
+ data_in[mask]=np.nan
126
+
127
+ data_out=KNNImputer(n_neighbors=neighbors).fit_transform(data_in)
128
+ if inplace:
129
+ self.data['Image'].loc[direction,channel] = data_out
130
+ return None
131
+ else:
132
+ return data_out
133
+
134
+
135
+ def denoise(self,
136
+ direction='Forward',
137
+ channel='Z-Axis',
138
+ function='gaussian',
139
+ size=5,
140
+ inplace=True,
141
+ **kwargs):
142
+ """ Applies a 2D filter to an image.
143
+
144
+ Parameters
145
+ ----------
146
+
147
+ direction: {'Forward','Backward'}, default 'Forward'
148
+ Scan direction to use
149
+ channel: string, default 'Z-Axis'
150
+ Name of channel to use
151
+ function: {'gaussian','median'}, default 'gaussian'
152
+ Name of filter to apply
153
+ size: scalar
154
+ Size of the filter
155
+ inplace: boolean, default True
156
+ Whether to modify the input array or create new one
157
+ **kwargs:
158
+ Passed to filters
159
+
160
+ Return
161
+ ------
162
+ array or None
163
+ Filtered image or None if inplace=True
164
+
165
+ """
166
+ data_in = self.data['Image'][direction][channel]
167
+ if function == 'median':
168
+ data_out = median_filter(data_in, size=size, **kwargs)
169
+ else:
170
+ data_out = gaussian_filter(data_in, sigma=size, **kwargs)
171
+ if inplace:
172
+ self.data['Image'].loc[direction,channel] = data_out
173
+ return None
174
+ else:
175
+ return data_out
176
+
177
+
178
+ def image(self,
179
+ direction='Forward',
180
+ channel='Z-Axis',
181
+ scale=1e9,
182
+ cmap=cm.afmhot,
183
+ cbar=None,
184
+ fontsize=10,
185
+ scalebar=None,
186
+ theme='light',
187
+ title='XXX',
188
+ **kwargs):
189
+ """ Plots an AFM image
190
+
191
+ Parameters
192
+ ----------
193
+
194
+ direction: {'Forward','Backward'}, default 'Forward'
195
+ Scan direction to use
196
+ channel: string, default 'Z-Axis'
197
+ Name of channel to use
198
+ scale: scalar, default 1e9
199
+ Scale the data before plotting
200
+ cmap: colormap from matplotlib, default afmhot
201
+ Colormap to use in false color plot
202
+ cbar: string, default None
203
+ Add a colorbar to image with label
204
+ fontsize: scalar, default 10
205
+ Font size to use throughout
206
+ scalebar: dict, {'length':scalar,'color':string}, default None
207
+ Applies scalebar to bottom right of image instead of XY axis scale.
208
+ * 'length' : length of scalebar in um
209
+ * 'color' : color of scalebar and label
210
+ theme: {'light','dark'}, default 'light'
211
+ Use either 'light' or 'dark' theme
212
+ **kwargs:
213
+ Passed to matplotlib imshow
214
+
215
+ Return
216
+ ------
217
+ figure
218
+ matplotlib figure object
219
+
220
+ """
221
+ d = np.array(self.data['Image'][direction][channel]*scale,dtype=float)
222
+ if hasattr(self.param, 'X'):
223
+ x = self.param.X.range[0] * 1e6
224
+ y = self.param.Y.range[0] * 1e6
225
+ else:
226
+ x = self.param.image_size_x * 1e6
227
+ y = self.param.image_size_y * 1e6
228
+
229
+ fig = plt.figure(dpi=300)
230
+
231
+ if theme=='light':
232
+ color = 'k'
233
+ else:
234
+ color= 'w'
235
+ fig.patch.set_facecolor('k')
236
+
237
+ im = plt.imshow(d, extent=(0, x, 0, y), cmap=cmap, origin='lower', **kwargs)
238
+
239
+ for spine in im.axes.spines.values():
240
+ spine.set_edgecolor(color)
241
+
242
+ if scalebar:
243
+ if isinstance(scalebar,dict):
244
+ dx = scalebar['length']
245
+ c = scalebar['color']
246
+ else:
247
+ dx = np.round(x / 5)
248
+ c = 'k'
249
+
250
+ pad = y * 0.05
251
+ plt.plot([x - dx - pad, x - pad], [pad, pad], linewidth=5, color=c)
252
+ txt = plt.text(x - pad - dx / 2, pad + x * 0.03, f'%i $\mu$m' % dx,
253
+ horizontalalignment='center',
254
+ fontsize=fontsize,
255
+ color=c)
256
+ if dx<1:
257
+ txt.set_text(f'%i nm' % (dx*1e3))
258
+ plt.xticks([])
259
+ plt.yticks([])
260
+ else:
261
+ plt.xlabel('X $[\mu{}$m]', fontsize=fontsize, color=color)
262
+ plt.ylabel('Y $[\mu{}$m]', fontsize=fontsize, color=color)
263
+ plt.xticks(fontsize=fontsize, color=color)
264
+ plt.yticks(fontsize=fontsize, color=color)
265
+ im.axes.tick_params(color=color, labelcolor=color)
266
+ if title=='XXX':
267
+ title = f'{channel} - {direction}'
268
+ plt.title(title,fontsize=fontsize, color=color)
269
+ if cbar:
270
+ cb = plt.colorbar(pad=0.02)
271
+ cb.set_label(label=cbar,size=fontsize, color=color)
272
+ cb.ax.tick_params(labelsize=fontsize, color=color)
273
+ cb.ax.yaxis.set_tick_params(color=color)
274
+ cb.outline.set_edgecolor(color)
275
+ plt.setp(plt.getp(cb.ax.axes, 'yticklabels'), color=color)
276
+
277
+ return fig
278
+
279
+ def hist(self,
280
+ direction='Forward',
281
+ channel='Z-Axis',
282
+ bins='sqrt',
283
+ scale=1e9,
284
+ cmap=cm.afmhot,
285
+ xlabel='Z-Axis [nm]',
286
+ fontsize=10,
287
+ density=False,
288
+ theme='light',
289
+ **kwargs):
290
+
291
+ data = np.array(self.data['Image'][direction][channel]*scale,dtype=float).reshape(-1)
292
+ if isinstance(bins,str):
293
+ bins = n_bins(data,method=bins)
294
+
295
+ fig = plt.figure(dpi=300)
296
+
297
+ if theme=='light':
298
+ color = 'k'
299
+ c_bg = 'w'
300
+ else:
301
+ color= 'w'
302
+ c_bg = 'k'
303
+ fig.patch.set_facecolor(c_bg)
304
+
305
+
306
+ n, edge, patches = plt.hist(data, bins=bins, density=density, color='green', **kwargs)
307
+ bin_centers = 0.5 * (edge[:-1] + edge[1:])
308
+
309
+ col = bin_centers - min(bin_centers)
310
+ col /= max(col)
311
+
312
+ for c, p in zip(col, patches):
313
+ plt.setp(p, 'facecolor', cmap(c))
314
+
315
+ im = plt.gca()
316
+ for spine in im.axes.spines.values():
317
+ spine.set_edgecolor(color)
318
+
319
+ plt.xlabel(xlabel,fontsize=fontsize, color=color)
320
+ if density:
321
+ ylabel='$\\rho$'
322
+ else:
323
+ ylabel='Counts'
324
+ plt.ylabel(ylabel,fontsize=fontsize, color=color)
325
+ plt.xticks(fontsize=fontsize, color=color)
326
+ plt.yticks(fontsize=fontsize, color=color)
327
+ im.axes.tick_params(color=color, labelcolor=color)
328
+
329
+ im.get_children()[-1].set_facecolor(c_bg)
330
+
331
+ return fig
332
+
333
+
334
+ # def surf(self,
335
+ # direction='Forward',
336
+ # channel='Z-Axis',
337
+ # scale=1e9,
338
+ # cmap = cm.afmhot,
339
+ # cbar = [],
340
+ # fontsize = 10):
341
+
342
+ # Z = self.data['Image'][direction][channel]*scale
343
+ # xx = self.param.X.range[0] * 1e6
344
+ # yy = self.param.Y.range[0] * 1e6
345
+ # X = np.linspace(0,xx,np.shape(Z)[0])
346
+ # Y = np.linspace(0,yy,np.shape(Z)[1])
347
+ # X, Y = np.meshgrid(X,Y)
348
+
349
+ # fig = plt.figure()
350
+ # ax = fig.gca(projection='3d')
351
+ # ax.set_proj_type('ortho')
352
+ # surf = ax.plot_surface(X, Y, Z,
353
+ # cmap=cmap,
354
+ # linewidth=0,
355
+ # antialiased=False)
356
+
357
+ # ax.set_xlabel('$[\mu{}$m]', fontsize=fontsize)
358
+ # ax.set_ylabel('$[\mu{}$m]', fontsize=fontsize)
359
+ # ax.view_init(elev=45., azim=32)
360
+ # ax.set_frame_on(False)
361
+ # ax.grid(False)
362
+ # ax.xaxis.pane.fill=False
363
+ # ax.yaxis.pane.fill=False
364
+ # ax.zaxis.pane.fill=False
365
+ # if cbar:
366
+ # cb = plt.colorbar(surf,pad=0.02, shrink=0.5, aspect=10)
367
+ # cb.set_label(label=cbar,size=fontsize)
368
+ # cb.ax.tick_params(labelsize=fontsize)
369
+ # ax.set_zticks([])
370
+
371
+ # else:
372
+ # ax.set_zlabel('',fontsize=fontsize)
373
+
374
+ def stats(self):
375
+ # definition of central moment
376
+ def Mu(x, i):
377
+ return np.mean((x-x.mean())**i)
378
+
379
+ # mean deviation
380
+ def Sa_(x):
381
+ return np.mean(np.abs(x-x.mean()))
382
+
383
+ # RMS deviation
384
+ def Sq_(x):
385
+ return np.sqrt(Mu(x, 2))
386
+
387
+ # Skew
388
+ def skew_(x):
389
+ return Mu(x, 3)/Mu(x, 2)**(3./2.)
390
+
391
+ # Kurtosis
392
+ def kurt_(x):
393
+ return Mu(x, 4)/Mu(x, 2)**2 - 3
394
+
395
+
396
+ # stat=[]
397
+ func = [Sa_, Sq_, skew_, kurt_, np.min, np.max]
398
+ fname = ['Sa', 'Sq', 'Ssk', 'Sku', 'Min', 'Max']
399
+ stats = {}
400
+ # cnames = []
401
+ for d0, _ in self.data['Image'].groupby(level=0):
402
+ s = {}
403
+ for d1, df in self.data['Image'].groupby(level=1):
404
+ # cnames.append([d0, d1])
405
+ s[d1] = {s: f(df[d0][d1]) for s, f in zip(fname, func)}
406
+ stats[d0] = s
407
+
408
+ return toPandaDF(stats).unstack(level=0)
409
+
410
+
411
+ def toPandaDF(user_dict):
412
+ df = pd.DataFrame.from_dict({(i, j): user_dict[i][j]
413
+ for i in user_dict.keys()
414
+ for j in user_dict[i].keys()}, orient='index').transpose()
415
+ return df
416
+
417
+
418
+ def n_bins(x,method='sqrt'):
419
+ n = len(x)
420
+ if method=='freedman': # freedman-diaconis rule
421
+ h = 2*stats.iqr(x)/np.cbrt(n)
422
+ k = int(np.ceil((max(x)-min(x))/h))
423
+ elif method=='rice':
424
+ k = int(np.ceil(2 * np.cbrt(n)))
425
+ elif method=='sturges':
426
+ k = int(np.ceil(np.log2(n))+1)
427
+ elif method=='doane':
428
+ g = stats.skew(x)
429
+ sigma = np.sqrt(6*(n-2)/((n+1)*(n+3)))
430
+ k = int(1 + np.log2(n)+np.log2(1+np.abs(g)/sigma))
431
+ elif method=='quantile':
432
+ k = np.quantile(x,np.arange(0,1.01,0.025))
433
+ else:
434
+ k = int(np.ceil(np.sqrt(n)))
435
+ return k
436
+
437
+
438
+ if __name__ == "__main__":
439
+ file='..\\example\\Calculate_Roughness\\sapphire.nid'
440
+
441
+ # fig = plt.figure(dpi=300)
442
+ afm = process(file)
443
+
444
+ chan = 'Z-Axis'
445
+
446
+ afm.flatten(channel=chan)
447
+
448
+ rms_roughness = afm.stats().Forward[chan].Sq
449
+ z = afm.data.Image.Forward[chan]
450
+ mask = z > 2*rms_roughness
451
+ afm.plane_level()
452
+ afm.flatten(channel=chan, mask=mask)
453
+ fig = afm.image(cbar='Z [nm]', title='', channel=chan, scalebar={'color':'w','length':0.25}, scale=1e9, theme='dark')
454
+ plt.show()
455
+
456
+ afm.hist(scale=1e12,xlabel='Height [pm]',theme='dark')
457
+
458
+
459
+ print('Average Roughness: %3.2f pm' % (rms_roughness*1e12))
@@ -443,6 +443,17 @@ class nhf_read():
443
443
  prop_s = {name:s_prop[name] for name in list(s_prop)}
444
444
 
445
445
  DAC_max = (2**31-1)
446
+
447
+
448
+ # DAC_max: dict = {0: [-(2.0**31), 2.0**31, 'dt_int32'],
449
+ # 1: [-(2.0**8), 2.0**8, 'dt_uint8'],
450
+ # 2: [-(2.0**16), 2.0**16, 'dt_uint16'],
451
+ # 3: [-(2.0**32), 2.0**32, 'dt_uint32'],
452
+ # 4: [-(2.0**64), 2.0**64, 'dt_uint64'],
453
+ # 5: [-(2.0**15), 2.0**15, 'dt_int16'],
454
+ # 6: [-(2.0**64), 2.0**64, 'dt_int64'],
455
+ # 7: [0.0, 0.0, 'dt_double']
456
+ # }
446
457
 
447
458
  data_out = {}
448
459
  prop = []