diff --git a/Examples/KTaO3.png b/Examples/KTaO3.png new file mode 100644 index 0000000000000000000000000000000000000000..743b6b5ef49d3800a592bad8f463a2ed791e3b30 Binary files /dev/null and b/Examples/KTaO3.png differ diff --git a/Examples/KTaO3.py b/Examples/KTaO3.py index 7d22ada599e4b8c09ce041c4f112cf5013e09be7..1928b2855f647b0a6b01090a279735780981a7be 100644 --- a/Examples/KTaO3.py +++ b/Examples/KTaO3.py @@ -2,6 +2,7 @@ import matplotlib.pyplot as plt import numpy as np from libhreels.calcHREELS import lambin, importMaterials +import os ###### Define Strontium titanate film on Silver #### ## (Thickness is given in Angstroem as second parm)# @@ -20,4 +21,9 @@ plt.xlabel('Energy Loss (cm$^{-1}$)') plt.title(thinFilm[0][0]['name']) plt.ylim(bottom=0.) plt.legend() + +plt.text(0.99, 0.01,os.path.basename(__file__), fontsize=10, ha='right', va='bottom', transform=plt.gcf().transFigure) +output_filename = os.path.splitext(__file__)[0] + '.png' +plt.savefig(output_filename) + plt.show() \ No newline at end of file diff --git a/Examples/calcHREELS1.png b/Examples/calcHREELS1.png new file mode 100644 index 0000000000000000000000000000000000000000..f564843722d10c1a8498cbfd8d716208aab91fe4 Binary files /dev/null and b/Examples/calcHREELS1.png differ diff --git a/Examples/calcHREELS1.py b/Examples/calcHREELS1.py index 8d3af8aa7a07729d622be2a1821ab27436d6dcde..246afad550fd4438ecc6568efdcfdf55da6aadbd 100644 --- a/Examples/calcHREELS1.py +++ b/Examples/calcHREELS1.py @@ -2,6 +2,7 @@ import matplotlib.pyplot as plt import numpy as np from libhreels import calcHREELS +import os ###### Define Strontium titanate film on Silver #### ## (Thickness is given in Angstroem as second parm)# @@ -20,4 +21,9 @@ plt.xlabel('Energy Loss (cm$^{-1}$)') plt.title(r'SrTiO$_3$') plt.ylim(bottom=0.) plt.legend() + +plt.text(0.99, 0.01,os.path.basename(__file__), fontsize=10, ha='right', va='bottom', transform=plt.gcf().transFigure) +output_filename = os.path.splitext(__file__)[0] + '.png' +plt.savefig(output_filename) + plt.show() \ No newline at end of file diff --git a/Examples/calcHREELS3.png b/Examples/calcHREELS3.png new file mode 100644 index 0000000000000000000000000000000000000000..432238c38578ff6c80451899e7f646c20df504b4 Binary files /dev/null and b/Examples/calcHREELS3.png differ diff --git a/Examples/calcHREELS3.py b/Examples/calcHREELS3.py index 890c81764234a4c7790885108aa05c1b6bbd07ab..eb6310c150e3f347e6e11044b7c0dafd2a5eb773 100644 --- a/Examples/calcHREELS3.py +++ b/Examples/calcHREELS3.py @@ -2,12 +2,13 @@ import matplotlib.pyplot as plt import numpy as np from libhreels.calcHREELS import lambin, importMaterials +import os # Experimental setup as dictionary: setup = { "e0": 4.0, # Primary electron energy "theta": 60., # Scattering angle wrt surface normal - "phia": 2.0, + "phia": 0.33, "phib": 2.0, "temperature": 80.,# Sample temperature "debug": False @@ -32,7 +33,7 @@ thinFilm = [[{'eps': 5.1295, 20000.]] d = lambin(thinFilm, setup=setup, instrument=instrument) -x = np.linspace(-100,1000,1100) +x = np.linspace(-100,1000,2000) x,y = d.calcHREELS(x) ###### Plotting ########################### @@ -42,4 +43,9 @@ plt.ylabel('Relative HREELS signal') plt.xlabel('Energy Loss (cm$^{-1}$)') plt.ylim(bottom=0.) plt.legend() + +plt.text(0.99, 0.01,os.path.basename(__file__), fontsize=10, ha='right', va='bottom', transform=plt.gcf().transFigure) +output_filename = os.path.splitext(__file__)[0] + '.png' +plt.savefig(output_filename) + plt.show() \ No newline at end of file diff --git a/Examples/showHREELS1.png b/Examples/showHREELS1.png new file mode 100644 index 0000000000000000000000000000000000000000..4b8ed81c25365479e7b7baa9eafcf1d2110270cf Binary files /dev/null and b/Examples/showHREELS1.png differ diff --git a/Examples/showHREELS1.py b/Examples/showHREELS1.py index 5679b7dc4cfbd9342cfa67333be2984b46f3c4f1..3292303575d31aee14490951cd0c4639f850acc8 100644 --- a/Examples/showHREELS1.py +++ b/Examples/showHREELS1.py @@ -1,9 +1,9 @@ from libhreels import HREELS as hh -import sys +import os import matplotlib.pyplot as plt import numpy as np -# datapath = ".\\data" +# datapath = "./Examples/data" datapath = "./data" d2 = hh.HREELS('c1a02', datapath=datapath) @@ -19,4 +19,9 @@ d2.plot(normalized=True, color='gray', factor = 1, label=None) d1.ax.set_ylim(bottom=0) d1.ax.set_xlim(left=-200,right=1300) plt.axvline(x=69,ymax=0.4, linestyle='dashed') + +plt.text(0.99, 0.01,os.path.basename(__file__), fontsize=10, ha='right', va='bottom', transform=plt.gcf().transFigure) +output_filename = os.path.splitext(__file__)[0] + '.png' +plt.savefig(output_filename) + plt.show() \ No newline at end of file diff --git a/Examples/showHREELS2.png b/Examples/showHREELS2.png new file mode 100644 index 0000000000000000000000000000000000000000..62bd86d21e5c5487f57aaca03c5ee3dad14328f8 Binary files /dev/null and b/Examples/showHREELS2.png differ diff --git a/Examples/showHREELS2.py b/Examples/showHREELS2.py index 01d8604d6f19e0fcc7ecda671c873b0b3dd47cb8..6bedd70595bf3b41ae2223c6f9e7684ad23e5ef8 100644 --- a/Examples/showHREELS2.py +++ b/Examples/showHREELS2.py @@ -1,4 +1,6 @@ from libhreels import HREELS +import matplotlib.pyplot as plt +import os d = './data' # d = './Examples/data' @@ -10,4 +12,9 @@ xmin = 35 d1 = HREELS.HREELS(file,d) d1.plotInfoAmp(factor=factor, xmin=xmin) d1.pickPeak() + +d1.fig.text(0.99, 0.01,os.path.basename(__file__), fontsize=10, ha='right', va='bottom', transform=plt.gcf().transFigure) +output_filename = os.path.splitext(__file__)[0] + '.png' +d1.fig.savefig(output_filename) + d1.show() diff --git a/libhreels/HREELS.py b/libhreels/HREELS.py index 1dd36e1d7859422433f3f1cd8a4eedb30c1ce647..cba1bc70d0627f400590060d38d831bf4eaf7af5 100644 --- a/libhreels/HREELS.py +++ b/libhreels/HREELS.py @@ -402,9 +402,11 @@ class HREELS: ''' Set vertical marker with text label. Note that self.figure() needs to be called before use.''' trans = offset(self.ax, 0, 30) - plt.plot([x,x],[ymin,y], lw=1, c='black', ls='dashed') + # plt.plot([x,x],[ymin,y], lw=1, c='black', ls='dashed') + self.ax.plot([x,x],[ymin,y], lw=1, c='black', ls='dashed') x = round(x) - plt.text(x,y,'%4i' % x, rotation=90, + # plt.text(x,y,'%4i' % x, rotation=90, + self.ax.text(x,y,'%4i' % x, rotation=90, verticalalignment='bottom', horizontalalignment='center', transform=trans) return diff --git a/libhreels/calcHREELS.py b/libhreels/calcHREELS.py index c82403cb0a30236eec16348ca2aea0bdb30ca6b1..7e17da57b8d86e730fdefbbc305960e215598810 100644 --- a/libhreels/calcHREELS.py +++ b/libhreels/calcHREELS.py @@ -11,21 +11,21 @@ libDir = os.path.dirname(os.path.realpath(__file__)) setup = { "e0": 4.0, "theta": 60., - "phia": 2.0, + "phia": 0.33, "phib": 2.0, "temperature": 298., "debug": False } # Instrumental function describing elastic peak shape: instrument = { - "width": 19., + "width": 18., "intensity": 100000., - "asym": 0.1, - "gauss": 0.8 + "asym": 0.01, + "gauss": 0.88 } -def importMaterials(string, path=libDir): +def importMaterials(string='', path=libDir): file = os.path.join(myPath(path),'materials.json') with open(file) as json_file: materials = json.load(json_file) @@ -33,6 +33,7 @@ def importMaterials(string, path=libDir): mat = materials[string] except: print('No data for material >>{}<< found in {} materials.json!!'.format(string, path)) + print('Available materials:\n{}\n'.format(materials.keys())) mat = 'None' return mat