forked from Probe-Particle/ppafm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplotZcurves.py
More file actions
executable file
·65 lines (52 loc) · 1.96 KB
/
plotZcurves.py
File metadata and controls
executable file
·65 lines (52 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/python
# This is a sead of simple plotting script which should get AFM frequency delta 'df.xsf' and generate 2D plots for different 'z'
import os
import sys
import numpy as np
import matplotlib.pyplot as plt
import pyProbeParticle.GridUtils as GU
from optparse import OptionParser
parser = OptionParser()
parser.add_option( "-p", action="store", type="string", help="pixels (ix,iy) to take curve", default='curve_points.ini' )
parser.add_option( "-i", action="store", type="string", help="input file", default='OutFz' )
parser.add_option( "--iz", action="store", type="int", help="z-slice index to plot legend", default=15 )
parser.add_option( "--npy" , action="store_true" , help="load and save fields in npy instead of xsf" , default=False)
(options, args) = parser.parse_args()
try:
points = np.genfromtxt( options.p ,dtype='int')
print "plotting in points", points
except:
print options.p+" not found => exiting ..."
sys.exit()
if options.npy:
data_format ="npy"
else:
data_format ="xsf"
fzs,lvec,nDim=GU.load_scal_field(options.i,data_format=data_format)
#xs = lvec[3,2]/*np.array( range(nDim[0]) )
xs = np.linspace( 0, lvec[3,2], nDim[0] )
#print nDim
print xs
plt.imshow( fzs[options.iz], origin='imgage', cmap='gray' )
for point in points:
plt.plot(point[0],point[1],'o')
plt.xlim(0,nDim[2])
plt.ylim(0,nDim[1])
plt.savefig( options.i+'_zcurves_legend.png', bbox_inches='tight')
plt.figure()
curves = np.zeros((len(points)+1,len(xs)))
curves[0] = xs
vmin = 0
for i,point in enumerate(points):
ys = fzs[:,point[1],point[0]]
vmin=min(ys.min(),vmin)
print point, vmin
#print ys
curves[i+1] = ys
plt.plot( xs, ys )
plt.grid()
plt.savefig( options.i+'_zcurves.png', bbox_inches='tight')
plt.ylim( 1.1*vmin, -2*vmin )
np.savetxt( options.i+'_zcurves.dat', curves )
#dfs = PPU.Fz2df( fzs, dz = dz, k0 = PPU.params['kCantilever'], f0=PPU.params['f0Cantilever'], n=Amp/dz )
plt.show()