Curlz: Difference between revisions
Jump to navigation
Jump to search
New page: """In preparation""". Usage (written for python 3.5 and newer): # copy following text to blank file named ""culrz.py"" # /usr/bin/env python3 # coding: utf-8 import ... |
No edit summary |
||
| (4 intermediate revisions by the same user not shown) | |||
| Line 16: | Line 16: | ||
min=float(sys.argv[2]) | min=float(sys.argv[2]) | ||
max=float(sys.argv[3]) | max=float(sys.argv[3]) | ||
sig=0.2 #float(sys.argv[4]) | |||
df=pd.read_csv(file, delim_whitespace=True) | df=pd.read_csv(file, delim_whitespace=True) | ||
no_of_shifts=len(df) | no_of_shifts=len(df) | ||
###gauss func### | ###gauss func### | ||
graphdots=(max-min)/0.01 | graphdots=(max-min)/0.01 | ||
graphdots=int(graphdots) | graphdots=int(graphdots) | ||
def gaussian(x, mu, sig): | def gaussian(x, mu, sig): | ||
return np.exp(-np.power(x - mu, 2.) / (2 * np.power(sig, 2.))) | return np.exp(-np.power(x - mu, 2.) / (2 * np.power(sig, 2.))) | ||
###loop over rows in list ($1 input) and convert to gaus bell### | ###loop over rows in list ($1 input) and convert to gaus bell### | ||
| Line 49: | Line 47: | ||
del atomgaus | del atomgaus | ||
del ef | del ef | ||
with pd.option_context('display.max_rows', None, 'display.max_columns', None): | with pd.option_context('display.max_rows', None, 'display.max_columns', None): | ||
print(tot) | print(tot) | ||
| Line 55: | Line 53: | ||
fig = tot.plot(x='E / eV',y='intensity', kind='line', linewidth=1.2, color='#000000', layout=None, figsize=(3, 3.2), title=(shift), grid=True, legend=False, xlim=(min, max), fontsize=(10)) | fig = tot.plot(x='E / eV',y='intensity', kind='line', linewidth=1.2, color='#000000', layout=None, figsize=(3, 3.2), title=(shift), grid=True, legend=False, xlim=(min, max), fontsize=(10)) | ||
plt.savefig(str(file) + str(shift) + ".png", dpi=120) | plt.savefig(str(file) + str(shift) + ".png", dpi=120) | ||
# make ""culrz.py"" executable: | # make ""culrz.py"" executable: | ||
chmod +x | chmod +x curlz.py | ||
# to run script type: | # to run script type: | ||
Latest revision as of 13:17, 14 November 2018
"""In preparation""". Usage (written for python 3.5 and newer):
- copy following text to blank file named ""culrz.py""
# /usr/bin/env python3
# coding: utf-8
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import sys
###input###
file=sys.argv[1]
min=float(sys.argv[2])
max=float(sys.argv[3])
sig=0.2 #float(sys.argv[4])
df=pd.read_csv(file, delim_whitespace=True)
no_of_shifts=len(df)
###gauss func###
graphdots=(max-min)/0.01
graphdots=int(graphdots)
def gaussian(x, mu, sig):
return np.exp(-np.power(x - mu, 2.) / (2 * np.power(sig, 2.)))
###loop over rows in list ($1 input) and convert to gaus bell###
tot=pd.DataFrame(np.zeros((graphdots, 2)), columns = ['E / eV', 'intensity'])
for shift in np.arange(0, no_of_shifts, 1):
atomgaus = []
trid=df.iloc[shift]['level']
#print(shift)
for e in np.arange(min, max, 0.01):
spect=gaussian(e, trid, sig)
pair = [e, spect]
atomgaus.append(pair)
ef = pd.DataFrame(atomgaus, columns = ['E / eV', 'intensity'])
tot.iloc[:,1]=tot.iloc[:,1] + ef.iloc[:,1]
tot.iloc[:,0]=ef.iloc[:,0]
del spect
del pair
del atomgaus
del ef
with pd.option_context('display.max_rows', None, 'display.max_columns', None):
print(tot)
fig = tot.plot(x='E / eV',y='intensity', kind='line', linewidth=1.2, color='#000000', layout=None, figsize=(3, 3.2), title=(shift), grid=True, legend=False, xlim=(min, max), fontsize=(10))
plt.savefig(str(file) + str(shift) + ".png", dpi=120)
- make ""culrz.py"" executable:
chmod +x curlz.py
- to run script type:
python3.6 <list_of_xps_shifts.dat> <min_of_ploted> <max_of_ploted>
- to write script output to file:
python3.6 <list_of_xps_shifts.dat> <min_of_ploted> <max_of_ploted> > <output.dat>