Curlz: Difference between revisions

From Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 24: Line 24:
     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.)))
Line 47: 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 55:


# make ""culrz.py"" executable:
# make ""culrz.py"" executable:
     chmod +x curls.py
     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):

  1. 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)
  1. make ""culrz.py"" executable:
   chmod +x curlz.py
  1. to run script type:
   python3.6 <list_of_xps_shifts.dat> <min_of_ploted> <max_of_ploted>
  1. to write script output to file:
   python3.6 <list_of_xps_shifts.dat> <min_of_ploted> <max_of_ploted> > <output.dat>