xarpes 0.2.1__py3-none-any.whl → 0.2.3__py3-none-any.whl
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.
- xarpes/.ipynb_checkpoints/__init__-checkpoint.py +2 -7
- xarpes/__init__.py +1 -1
- xarpes/band_map.py +107 -6
- xarpes/distributions.py +144 -69
- xarpes/functions.py +60 -58
- xarpes/plotting.py +2 -0
- {xarpes-0.2.1.dist-info → xarpes-0.2.3.dist-info}/METADATA +5 -4
- xarpes-0.2.3.dist-info/RECORD +10 -0
- xarpes/.ipynb_checkpoints/band_map-checkpoint.py +0 -205
- xarpes/.ipynb_checkpoints/distributions-checkpoint.py +0 -430
- xarpes/.ipynb_checkpoints/functions-checkpoint.py +0 -133
- xarpes/.ipynb_checkpoints/plotting-checkpoint.py +0 -157
- xarpes-0.2.1.dist-info/RECORD +0 -14
- {xarpes-0.2.1.dist-info → xarpes-0.2.3.dist-info}/LICENSE +0 -0
- {xarpes-0.2.1.dist-info → xarpes-0.2.3.dist-info}/WHEEL +0 -0
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
__version__ = '0.
|
|
1
|
+
__version__ = '0.2.2'
|
|
2
2
|
|
|
3
3
|
from . import plotting
|
|
4
4
|
|
|
5
5
|
from .band_map import *
|
|
6
6
|
from .distributions import *
|
|
7
7
|
from .functions import *
|
|
8
|
-
from .plotting import *
|
|
9
|
-
|
|
10
|
-
# from . import plotting
|
|
11
|
-
# from xarpes.plotting import *
|
|
12
|
-
# from xarpes.distributions import *
|
|
13
|
-
# from xarpes.distributions import fermi_dirac
|
|
8
|
+
from .plotting import *
|
xarpes/__init__.py
CHANGED
xarpes/band_map.py
CHANGED
|
@@ -12,9 +12,49 @@
|
|
|
12
12
|
"""The band map class and allowed operations on it."""
|
|
13
13
|
|
|
14
14
|
import numpy as np
|
|
15
|
+
|
|
15
16
|
from .plotting import get_ax_fig_plt, add_fig_kwargs
|
|
17
|
+
from .functions import fit_leastsq
|
|
16
18
|
from .distributions import fermi_dirac
|
|
17
19
|
|
|
20
|
+
|
|
21
|
+
class MDCs():
|
|
22
|
+
r"""
|
|
23
|
+
"""
|
|
24
|
+
def __init__(self, intensities, angles, ekin, angular_resolution):
|
|
25
|
+
self.intensities = intensities
|
|
26
|
+
self.angles = angles
|
|
27
|
+
self.ekin = ekin
|
|
28
|
+
self.angular_resolution = angular_resolution
|
|
29
|
+
|
|
30
|
+
# @add_fig_kwargs
|
|
31
|
+
# def fit(self):
|
|
32
|
+
# r"""
|
|
33
|
+
# """
|
|
34
|
+
# return 0
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
# @add_fig_kwargs
|
|
38
|
+
# def fit_fermi_edge(self, hnuminphi_guess, background_guess=0.0,
|
|
39
|
+
# integrated_weight_guess=1.0, angle_min=-np.infty,
|
|
40
|
+
# angle_max=np.infty, ekin_min=-np.infty,
|
|
41
|
+
# ekin_max=np.infty, ax=None, **kwargs):
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
@add_fig_kwargs
|
|
45
|
+
def plot(self, ax=None, **kwargs):
|
|
46
|
+
r"""
|
|
47
|
+
"""
|
|
48
|
+
ax, fig, plt = get_ax_fig_plt(ax=ax)
|
|
49
|
+
|
|
50
|
+
ax.scatter(self.angles, self.intensities)
|
|
51
|
+
|
|
52
|
+
ax.set_xlabel("Angle ($\degree$)")
|
|
53
|
+
ax.set_ylabel('Counts (-)')
|
|
54
|
+
|
|
55
|
+
return fig
|
|
56
|
+
|
|
57
|
+
|
|
18
58
|
class band_map():
|
|
19
59
|
r"""Class for the band map from the ARPES experiment.
|
|
20
60
|
|
|
@@ -26,7 +66,9 @@ class band_map():
|
|
|
26
66
|
1D array of angular values for the abscissa [degrees]
|
|
27
67
|
ekin : ndarray
|
|
28
68
|
1D array of kinetic energy values for the ordinate [eV]
|
|
29
|
-
|
|
69
|
+
angular_resolution : float, None
|
|
70
|
+
Angular resolution of the detector [degrees]
|
|
71
|
+
energy_resolution : float, None
|
|
30
72
|
Energy resolution of the detector [eV]
|
|
31
73
|
temperature : float, None
|
|
32
74
|
Temperature of the sample [K]
|
|
@@ -36,11 +78,13 @@ class band_map():
|
|
|
36
78
|
Standard deviation of kinetic energy minus work function [eV]
|
|
37
79
|
"""
|
|
38
80
|
def __init__(self, intensities, angles, ekin, energy_resolution=None,
|
|
39
|
-
|
|
81
|
+
angular_resolution=None, temperature=None, hnuminphi=None,
|
|
82
|
+
hnuminphi_std=None):
|
|
40
83
|
self.intensities = intensities
|
|
41
84
|
self.angles = angles
|
|
42
85
|
self.ekin = ekin
|
|
43
86
|
self.energy_resolution = energy_resolution
|
|
87
|
+
self.angular_resolution = angular_resolution
|
|
44
88
|
self.temperature = temperature
|
|
45
89
|
self.hnuminphi = hnuminphi
|
|
46
90
|
self.hnuminphi_std = hnuminphi_std
|
|
@@ -106,13 +150,72 @@ class band_map():
|
|
|
106
150
|
"""
|
|
107
151
|
self.angles = self.angles + shift
|
|
108
152
|
|
|
153
|
+
def slice(self, angle_min, angle_max, energy_value):
|
|
154
|
+
r"""
|
|
155
|
+
Parameters
|
|
156
|
+
----------
|
|
157
|
+
angle_min : float
|
|
158
|
+
Minimum angle of integration interval [degrees]
|
|
159
|
+
angle_max : float
|
|
160
|
+
Maximum angle of integration interval [degrees]
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
Returns
|
|
164
|
+
-------
|
|
165
|
+
angle_range : ndarray
|
|
166
|
+
Array of size n containing the angular values
|
|
167
|
+
energy_range : ndarray
|
|
168
|
+
Array of size m containing the energy values
|
|
169
|
+
mdcs :
|
|
170
|
+
Array of size nxm containing the MDC intensities
|
|
171
|
+
"""
|
|
172
|
+
|
|
173
|
+
energy_index = np.abs(self.ekin-energy_value).argmin()
|
|
174
|
+
angle_min_index = np.abs(self.angles-angle_min).argmin()
|
|
175
|
+
angle_max_index = np.abs(self.angles-angle_max).argmin()
|
|
176
|
+
|
|
177
|
+
angle_range = self.angles[angle_min_index:angle_max_index+1]
|
|
178
|
+
energy_range = self.ekin[energy_index]
|
|
179
|
+
mdcs = self.intensities[energy_index, angle_min_index:angle_max_index+1]
|
|
180
|
+
|
|
181
|
+
return mdcs, angle_range, energy_range, self.angular_resolution
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
@add_fig_kwargs
|
|
185
|
+
def plot_band_map(self, ax=None, **kwargs):
|
|
186
|
+
r"""Plots the band map.
|
|
187
|
+
|
|
188
|
+
Parameters
|
|
189
|
+
----------
|
|
190
|
+
|
|
191
|
+
Other parameters
|
|
192
|
+
----------------
|
|
193
|
+
**kwargs : dict, optional
|
|
194
|
+
Additional arguments passed on to add_fig_kwargs. See the keyword
|
|
195
|
+
table below.
|
|
196
|
+
|
|
197
|
+
Returns
|
|
198
|
+
-------
|
|
199
|
+
fig : Matplotlib-Figure
|
|
200
|
+
Figure containing the Fermi edge fit
|
|
201
|
+
"""
|
|
202
|
+
ax, fig, plt = get_ax_fig_plt(ax=ax)
|
|
203
|
+
|
|
204
|
+
Angl, Ekin = np.meshgrid(self.angles, self.ekin)
|
|
205
|
+
mesh = ax.pcolormesh(Angl, Ekin, self.intensities, shading="auto", cmap=plt.get_cmap("bone").reversed())
|
|
206
|
+
cbar = plt.colorbar(mesh, ax=ax)
|
|
207
|
+
|
|
208
|
+
ax.set_xlabel("Angle ($\degree$)")
|
|
209
|
+
ax.set_ylabel("$E_{\mathrm{kin}}$ (eV)")
|
|
210
|
+
|
|
211
|
+
return fig
|
|
212
|
+
|
|
109
213
|
@add_fig_kwargs
|
|
110
214
|
def fit_fermi_edge(self, hnuminphi_guess, background_guess=0.0,
|
|
111
215
|
integrated_weight_guess=1.0, angle_min=-np.infty,
|
|
112
216
|
angle_max=np.infty, ekin_min=-np.infty,
|
|
113
217
|
ekin_max=np.infty, ax=None, **kwargs):
|
|
114
|
-
r"""
|
|
115
|
-
Fits the Fermi edge of the band map and plots the result.
|
|
218
|
+
r"""Fits the Fermi edge of the band map and plots the result.
|
|
116
219
|
Also sets hnuminphi, the kinetic energy minus the work function in eV.
|
|
117
220
|
The fitting includes an energy convolution with an abscissa range
|
|
118
221
|
expanded by 5 times the energy resolution standard deviation.
|
|
@@ -148,8 +251,6 @@ class band_map():
|
|
|
148
251
|
fig : Matplotlib-Figure
|
|
149
252
|
Figure containing the Fermi edge fit
|
|
150
253
|
"""
|
|
151
|
-
from xarpes.functions import fit_leastsq
|
|
152
|
-
|
|
153
254
|
ax, fig, plt = get_ax_fig_plt(ax=ax)
|
|
154
255
|
|
|
155
256
|
min_angle_index = np.argmin(np.abs(self.angles - angle_min))
|
xarpes/distributions.py
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
"""The distributions used throughout the code."""
|
|
5
5
|
|
|
6
|
+
import numpy as np
|
|
7
|
+
|
|
6
8
|
class distribution:
|
|
7
9
|
r"""Parent class for distributions. The class cannot be used on its own,
|
|
8
10
|
but is used to instantiate unique and non-unique distributions.
|
|
@@ -27,6 +29,7 @@ class distribution:
|
|
|
27
29
|
"""
|
|
28
30
|
return self._name
|
|
29
31
|
|
|
32
|
+
|
|
30
33
|
class unique_distribution(distribution):
|
|
31
34
|
r"""Parent class for unique distributions, to be used one at a time, e.g.,
|
|
32
35
|
during the background of an MDC fit or the Fermi-Dirac distribution.
|
|
@@ -53,6 +56,7 @@ class unique_distribution(distribution):
|
|
|
53
56
|
"""
|
|
54
57
|
return self._label
|
|
55
58
|
|
|
59
|
+
|
|
56
60
|
class constant(unique_distribution):
|
|
57
61
|
r"""Child class for constant distributions, used e.g., during MDC fitting.
|
|
58
62
|
The constant class is unique, only one instance should be used per task.
|
|
@@ -62,8 +66,8 @@ class constant(unique_distribution):
|
|
|
62
66
|
offset : float
|
|
63
67
|
The value of the distribution for the abscissa equal to 0.
|
|
64
68
|
"""
|
|
65
|
-
def __init__(self, offset):
|
|
66
|
-
super().__init__(name
|
|
69
|
+
def __init__(self, offset, name='constant'):
|
|
70
|
+
super().__init__(name)
|
|
67
71
|
self._offset = offset
|
|
68
72
|
|
|
69
73
|
@property
|
|
@@ -88,65 +92,6 @@ class constant(unique_distribution):
|
|
|
88
92
|
"""
|
|
89
93
|
self._offset = x
|
|
90
94
|
|
|
91
|
-
class linear(unique_distribution):
|
|
92
|
-
r"""Child cass for for linear distributions, used e.g., during MDC fitting.
|
|
93
|
-
The constant class is unique, only one instance should be used per task.
|
|
94
|
-
|
|
95
|
-
Parameters
|
|
96
|
-
----------
|
|
97
|
-
offset : float
|
|
98
|
-
The value of the distribution for the abscissa equal to 0.
|
|
99
|
-
slope : float
|
|
100
|
-
The linear slope of the distribution w.r.t. the abscissa.
|
|
101
|
-
"""
|
|
102
|
-
def __init__(self, slope, offset):
|
|
103
|
-
super().__init__(name='linear')
|
|
104
|
-
self._offset = offset
|
|
105
|
-
self._slope = slope
|
|
106
|
-
|
|
107
|
-
@property
|
|
108
|
-
def offset(self):
|
|
109
|
-
r"""Returns the offset of the linear distribution.
|
|
110
|
-
|
|
111
|
-
Returns
|
|
112
|
-
-------
|
|
113
|
-
offset : float
|
|
114
|
-
The value of the distribution for the abscissa equal to 0.
|
|
115
|
-
"""
|
|
116
|
-
return self._offset
|
|
117
|
-
|
|
118
|
-
@offset.setter
|
|
119
|
-
def set_offset(self, x):
|
|
120
|
-
r"""Sets the offset of the linear distribution.
|
|
121
|
-
|
|
122
|
-
Parameters
|
|
123
|
-
----------
|
|
124
|
-
offset : float
|
|
125
|
-
The value of the distribution for the abscissa equal to 0.
|
|
126
|
-
"""
|
|
127
|
-
self._offset = x
|
|
128
|
-
|
|
129
|
-
@property
|
|
130
|
-
def slope(self):
|
|
131
|
-
r"""Returns the slope of the linear distribution.
|
|
132
|
-
|
|
133
|
-
Returns
|
|
134
|
-
-------
|
|
135
|
-
slope : float
|
|
136
|
-
The linear slope of the distribution w.r.t. the abscissa.
|
|
137
|
-
"""
|
|
138
|
-
return self._slope
|
|
139
|
-
|
|
140
|
-
@slope.setter
|
|
141
|
-
def set_slope(self, x):
|
|
142
|
-
r"""Sets the slope of the linear distribution.
|
|
143
|
-
|
|
144
|
-
Parameters
|
|
145
|
-
----------
|
|
146
|
-
slope : float
|
|
147
|
-
The linear slope of the distribution w.r.t. the abscissa.
|
|
148
|
-
"""
|
|
149
|
-
self._slope = x
|
|
150
95
|
|
|
151
96
|
class linear(unique_distribution):
|
|
152
97
|
r"""Child cass for for linear distributions, used e.g., during MDC fitting.
|
|
@@ -159,9 +104,8 @@ class linear(unique_distribution):
|
|
|
159
104
|
slope : float
|
|
160
105
|
The linear slope of the distribution w.r.t. the abscissa.
|
|
161
106
|
"""
|
|
162
|
-
def __init__(self, slope, offset):
|
|
163
|
-
|
|
164
|
-
super().__init__(name='linear')
|
|
107
|
+
def __init__(self, slope, offset, name='linear'):
|
|
108
|
+
super().__init__(name)
|
|
165
109
|
self._offset = offset
|
|
166
110
|
self._slope = slope
|
|
167
111
|
|
|
@@ -209,6 +153,7 @@ class linear(unique_distribution):
|
|
|
209
153
|
"""
|
|
210
154
|
self._slope = x
|
|
211
155
|
|
|
156
|
+
|
|
212
157
|
class fermi_dirac(unique_distribution):
|
|
213
158
|
r"""Child class for Fermi-Dirac (FD) distributions, used e.g., during Fermi
|
|
214
159
|
edge fitting. The FD class is unique, only one instance should be used
|
|
@@ -357,7 +302,7 @@ class fermi_dirac(unique_distribution):
|
|
|
357
302
|
1D array of the energy-convolved FD distribution [counts]
|
|
358
303
|
"""
|
|
359
304
|
from scipy.ndimage import gaussian_filter
|
|
360
|
-
|
|
305
|
+
|
|
361
306
|
sigma_extend = 5 # Extend data range by "5 sigma"
|
|
362
307
|
# Conversion from FWHM to standard deviation [-]
|
|
363
308
|
fwhm_to_std = np.sqrt(8 * np.log(2))
|
|
@@ -387,8 +332,7 @@ class fermi_dirac(unique_distribution):
|
|
|
387
332
|
-------
|
|
388
333
|
evalf : ndarray
|
|
389
334
|
1D array of the evaluated FD distribution [counts]
|
|
390
|
-
"""
|
|
391
|
-
import numpy as np
|
|
335
|
+
"""
|
|
392
336
|
k_B = 8.617e-5 # Boltzmann constant [eV/K]
|
|
393
337
|
k_BT = self.temperature * k_B
|
|
394
338
|
evalf = (self.integrated_weight
|
|
@@ -414,8 +358,8 @@ class fermi_dirac(unique_distribution):
|
|
|
414
358
|
evalf : ndarray
|
|
415
359
|
1D array of the energy-convolved FD distribution [counts]
|
|
416
360
|
"""
|
|
417
|
-
import numpy as np
|
|
418
361
|
from scipy.ndimage import gaussian_filter
|
|
362
|
+
|
|
419
363
|
sigma_extend = 5 # Extend data range by "5 sigma"
|
|
420
364
|
# Conversion from FWHM to standard deviation [-]
|
|
421
365
|
fwhm_to_std = np.sqrt(8 * np.log(2))
|
|
@@ -427,4 +371,135 @@ class fermi_dirac(unique_distribution):
|
|
|
427
371
|
len(energy_range) + 2 * enumb)
|
|
428
372
|
evalf = gaussian_filter(self.evaluate(extend),
|
|
429
373
|
sigma=estep)[enumb:-enumb]
|
|
430
|
-
return evalf
|
|
374
|
+
return evalf
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
class non_unique_distribution(distribution):
|
|
378
|
+
r"""Parent class for unique distributions, to be used one at a time, e.g.,
|
|
379
|
+
during the background of an MDC fit or the Fermi-Dirac distribution.
|
|
380
|
+
|
|
381
|
+
Parameters
|
|
382
|
+
----------
|
|
383
|
+
label : str
|
|
384
|
+
Unique label for instances, identical to the name for unique
|
|
385
|
+
distributions. Not to be modified after instantiation.
|
|
386
|
+
"""
|
|
387
|
+
def __init__(self, name, index):
|
|
388
|
+
super().__init__(name)
|
|
389
|
+
self._label = name + index
|
|
390
|
+
|
|
391
|
+
@property
|
|
392
|
+
def label(self):
|
|
393
|
+
r"""Returns the unique class label.
|
|
394
|
+
|
|
395
|
+
Returns
|
|
396
|
+
-------
|
|
397
|
+
label : str
|
|
398
|
+
Unique label for instances, identical to the name for unique
|
|
399
|
+
distributions. Not to be modified after instantiation.
|
|
400
|
+
"""
|
|
401
|
+
return self._label
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
class dispersion(distribution):
|
|
405
|
+
r"""Dispersions are assumed to be unique, so they need an index.
|
|
406
|
+
"""
|
|
407
|
+
def __init__(self, amplitude, center, broadening, name, index):
|
|
408
|
+
super().__init__(name)
|
|
409
|
+
self._amplitude = amplitude
|
|
410
|
+
self._center = center
|
|
411
|
+
self._broadening = broadening
|
|
412
|
+
self._label = name + index
|
|
413
|
+
|
|
414
|
+
@property
|
|
415
|
+
def label(self):
|
|
416
|
+
r"""
|
|
417
|
+
"""
|
|
418
|
+
return self._label
|
|
419
|
+
|
|
420
|
+
@property
|
|
421
|
+
def amplitude(self):
|
|
422
|
+
r"""
|
|
423
|
+
"""
|
|
424
|
+
return self._amplitude
|
|
425
|
+
|
|
426
|
+
@amplitude.setter
|
|
427
|
+
def set_amplitude(self, x):
|
|
428
|
+
r"""
|
|
429
|
+
"""
|
|
430
|
+
self._amplitude = x
|
|
431
|
+
|
|
432
|
+
@property
|
|
433
|
+
def center(self):
|
|
434
|
+
r"""
|
|
435
|
+
"""
|
|
436
|
+
return self._center
|
|
437
|
+
|
|
438
|
+
@amplitude.setter
|
|
439
|
+
def set_center(self, x):
|
|
440
|
+
r"""
|
|
441
|
+
"""
|
|
442
|
+
self._center = x
|
|
443
|
+
|
|
444
|
+
@property
|
|
445
|
+
def broadening(self):
|
|
446
|
+
r"""
|
|
447
|
+
"""
|
|
448
|
+
return self._broadening
|
|
449
|
+
|
|
450
|
+
@broadening.setter
|
|
451
|
+
def set_broadening(self, x):
|
|
452
|
+
r"""
|
|
453
|
+
"""
|
|
454
|
+
self._broadening = x
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
# class spectral_linear(dispersion):
|
|
458
|
+
# r"""Class for the linear dispersion spectral function"""
|
|
459
|
+
# def __init__(self, amplitude, center, broadening, name, index):
|
|
460
|
+
# super().__init__(amplitude=amplitude, center=center,
|
|
461
|
+
# broadening=broadening, name=name, index=index)
|
|
462
|
+
|
|
463
|
+
# def result(self, x):
|
|
464
|
+
# r"""
|
|
465
|
+
# """
|
|
466
|
+
# dtor = np.pi/180
|
|
467
|
+
# evalf = self.amplitude / np.pi * self.broadening / ((np.sin(x*dtor)
|
|
468
|
+
# - np.sin(self.center*dtor))**2 + self.broadening**2)
|
|
469
|
+
# return evalf
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
# class spectral_linear(dispersion):
|
|
473
|
+
# r"""Class for the linear dispersion spectral function"""
|
|
474
|
+
# def __init__(self, amplitude, center, broadening, bottom, side, name,
|
|
475
|
+
# index):
|
|
476
|
+
# super()__init__(amplitude=amplitude, center=center,
|
|
477
|
+
# broadening=broadening, name=name, index=index)
|
|
478
|
+
# self._bottom = bottom
|
|
479
|
+
# self._side = side
|
|
480
|
+
|
|
481
|
+
# @property
|
|
482
|
+
# def bottom(self):
|
|
483
|
+
# r"""
|
|
484
|
+
# """
|
|
485
|
+
# return self._bottom
|
|
486
|
+
|
|
487
|
+
# @bottom.setter
|
|
488
|
+
# def set_bottom(self, x):
|
|
489
|
+
# r"""
|
|
490
|
+
# """
|
|
491
|
+
# self._bottom = x
|
|
492
|
+
|
|
493
|
+
# @property
|
|
494
|
+
# def side(self):
|
|
495
|
+
# r"""
|
|
496
|
+
# """
|
|
497
|
+
# return self._side
|
|
498
|
+
|
|
499
|
+
# def result(self, x):
|
|
500
|
+
# r"""
|
|
501
|
+
# """
|
|
502
|
+
# dtor = np.pi/180
|
|
503
|
+
# evalf = self.amplitude / np.pi * self.broadening / (((np.sin(x*dtor)
|
|
504
|
+
# - np.sin(self.bottom*dtor))**2 - np.sin(self.center*dtor)**2)**2
|
|
505
|
+
# + self.broadening**2)
|
xarpes/functions.py
CHANGED
|
@@ -3,62 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
"""Separate functions mostly used in conjunction with various classes."""
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
"""Downloads the examples folder from the xARPES code only if it does not
|
|
8
|
-
already exist. Prints executed steps and a final cleanup/failure message.
|
|
9
|
-
|
|
10
|
-
Returns
|
|
11
|
-
-------
|
|
12
|
-
0, 1 : int
|
|
13
|
-
Returns 0 if the execution succeeds, 1 if it fails.
|
|
14
|
-
"""
|
|
15
|
-
import requests
|
|
16
|
-
import zipfile
|
|
17
|
-
import os
|
|
18
|
-
import shutil
|
|
19
|
-
import io
|
|
20
|
-
|
|
21
|
-
repo_url = 'https://github.com/xARPES/xARPES_examples'
|
|
22
|
-
output_dir = '.' # Directory from which the function is called
|
|
23
|
-
|
|
24
|
-
# Check if 'examples' directory already exists
|
|
25
|
-
final_examples_path = os.path.join(output_dir, 'examples')
|
|
26
|
-
if os.path.exists(final_examples_path):
|
|
27
|
-
print("Warning: 'examples' folder already exists. No download will be performed.")
|
|
28
|
-
return 1 # Exit the function if 'examples' directory exists
|
|
29
|
-
|
|
30
|
-
# Proceed with download if 'examples' directory does not exist
|
|
31
|
-
repo_parts = repo_url.replace("https://github.com/", "").rstrip('/')
|
|
32
|
-
zip_url = f"https://github.com/{repo_parts}/archive/refs/heads/main.zip"
|
|
33
|
-
|
|
34
|
-
# Make the HTTP request to download the zip file
|
|
35
|
-
print(f"Downloading {zip_url}")
|
|
36
|
-
response = requests.get(zip_url)
|
|
37
|
-
if response.status_code == 200:
|
|
38
|
-
zip_file_bytes = io.BytesIO(response.content)
|
|
39
|
-
|
|
40
|
-
with zipfile.ZipFile(zip_file_bytes, 'r') as zip_ref:
|
|
41
|
-
zip_ref.extractall(output_dir)
|
|
42
|
-
|
|
43
|
-
# Path to the extracted main folder
|
|
44
|
-
main_folder_path = os.path.join(output_dir, repo_parts.split('/')[-1] + '-main')
|
|
45
|
-
examples_path = os.path.join(main_folder_path, 'examples')
|
|
46
|
-
|
|
47
|
-
# Move the 'examples' directory to the target location if it was extracted
|
|
48
|
-
if os.path.exists(examples_path):
|
|
49
|
-
shutil.move(examples_path, final_examples_path)
|
|
50
|
-
print(f"'examples' subdirectory moved to {final_examples_path}")
|
|
51
|
-
else:
|
|
52
|
-
print("'examples' subdirectory not found in the repository.")
|
|
53
|
-
|
|
54
|
-
# Remove the rest of the extracted content
|
|
55
|
-
shutil.rmtree(main_folder_path)
|
|
56
|
-
print(f"Cleaned up temporary files in {main_folder_path}")
|
|
57
|
-
return 0
|
|
58
|
-
else:
|
|
59
|
-
print(f"Failed to download the repository. Status code: {response.status_code}")
|
|
60
|
-
return 1
|
|
61
|
-
|
|
6
|
+
import numpy as np
|
|
62
7
|
|
|
63
8
|
def error_function(p, xdata, ydata, function, extra_args):
|
|
64
9
|
r"""The error function used inside the fit_leastsq function.
|
|
@@ -108,8 +53,8 @@ def fit_leastsq(p0, xdata, ydata, function, extra_args):
|
|
|
108
53
|
perr_leastsq : ndarray
|
|
109
54
|
Covariance matrix of the optimized parameters
|
|
110
55
|
"""
|
|
111
|
-
import numpy as np
|
|
112
56
|
from scipy.optimize import leastsq
|
|
57
|
+
|
|
113
58
|
pfit, pcov, infodict, errmsg, success = leastsq(
|
|
114
59
|
error_function, p0, args=(xdata, ydata, function, extra_args),
|
|
115
60
|
full_output=1)
|
|
@@ -130,4 +75,61 @@ def fit_leastsq(p0, xdata, ydata, function, extra_args):
|
|
|
130
75
|
pfit_leastsq = pfit
|
|
131
76
|
perr_leastsq = np.array(error)
|
|
132
77
|
|
|
133
|
-
return pfit_leastsq, perr_leastsq
|
|
78
|
+
return pfit_leastsq, perr_leastsq
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def download_examples():
|
|
82
|
+
"""Downloads the examples folder from the xARPES code only if it does not
|
|
83
|
+
already exist. Prints executed steps and a final cleanup/failure message.
|
|
84
|
+
|
|
85
|
+
Returns
|
|
86
|
+
-------
|
|
87
|
+
0, 1 : int
|
|
88
|
+
Returns 0 if the execution succeeds, 1 if it fails.
|
|
89
|
+
"""
|
|
90
|
+
import requests
|
|
91
|
+
import zipfile
|
|
92
|
+
import os
|
|
93
|
+
import shutil
|
|
94
|
+
import io
|
|
95
|
+
|
|
96
|
+
repo_url = 'https://github.com/xARPES/xARPES_examples'
|
|
97
|
+
output_dir = '.' # Directory from which the function is called
|
|
98
|
+
|
|
99
|
+
# Check if 'examples' directory already exists
|
|
100
|
+
final_examples_path = os.path.join(output_dir, 'examples')
|
|
101
|
+
if os.path.exists(final_examples_path):
|
|
102
|
+
print("Warning: 'examples' folder already exists. No download will be performed.")
|
|
103
|
+
return 1 # Exit the function if 'examples' directory exists
|
|
104
|
+
|
|
105
|
+
# Proceed with download if 'examples' directory does not exist
|
|
106
|
+
repo_parts = repo_url.replace("https://github.com/", "").rstrip('/')
|
|
107
|
+
zip_url = f"https://github.com/{repo_parts}/archive/refs/heads/main.zip"
|
|
108
|
+
|
|
109
|
+
# Make the HTTP request to download the zip file
|
|
110
|
+
print(f"Downloading {zip_url}")
|
|
111
|
+
response = requests.get(zip_url)
|
|
112
|
+
if response.status_code == 200:
|
|
113
|
+
zip_file_bytes = io.BytesIO(response.content)
|
|
114
|
+
|
|
115
|
+
with zipfile.ZipFile(zip_file_bytes, 'r') as zip_ref:
|
|
116
|
+
zip_ref.extractall(output_dir)
|
|
117
|
+
|
|
118
|
+
# Path to the extracted main folder
|
|
119
|
+
main_folder_path = os.path.join(output_dir, repo_parts.split('/')[-1] + '-main')
|
|
120
|
+
examples_path = os.path.join(main_folder_path, 'examples')
|
|
121
|
+
|
|
122
|
+
# Move the 'examples' directory to the target location if it was extracted
|
|
123
|
+
if os.path.exists(examples_path):
|
|
124
|
+
shutil.move(examples_path, final_examples_path)
|
|
125
|
+
print(f"'examples' subdirectory moved to {final_examples_path}")
|
|
126
|
+
else:
|
|
127
|
+
print("'examples' subdirectory not found in the repository.")
|
|
128
|
+
|
|
129
|
+
# Remove the rest of the extracted content
|
|
130
|
+
shutil.rmtree(main_folder_path)
|
|
131
|
+
print(f"Cleaned up temporary files in {main_folder_path}")
|
|
132
|
+
return 0
|
|
133
|
+
else:
|
|
134
|
+
print(f"Failed to download the repository. Status code: {response.status_code}")
|
|
135
|
+
return 1
|
xarpes/plotting.py
CHANGED
|
@@ -25,6 +25,8 @@ def plot_settings(name='default'):
|
|
|
25
25
|
mpl.rcParams['xtick.minor.size'] = 2
|
|
26
26
|
mpl.rcParams['xtick.major.width'] = 0.8
|
|
27
27
|
mpl.rcParams.update({'font.size': 16})
|
|
28
|
+
mpl.use('Qt5Agg') # Backend for showing plots in terminal
|
|
29
|
+
|
|
28
30
|
|
|
29
31
|
def get_ax_fig_plt(ax=None, **kwargs):
|
|
30
32
|
r"""Helper function used in plot functions supporting an optional `Axes`
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: xarpes
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.3
|
|
4
4
|
Summary: Extraction from angle resolved photoemission spectra
|
|
5
5
|
Author: xARPES Developers
|
|
6
|
-
Requires-Python: >=3.
|
|
6
|
+
Requires-Python: >=3.7.0
|
|
7
7
|
Description-Content-Type: text/markdown
|
|
8
|
-
Classifier: License :: OSI Approved :: GNU General Public License
|
|
8
|
+
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
|
9
9
|
Classifier: Programming Language :: Python :: 3
|
|
10
10
|
Requires-Dist: igor2
|
|
11
11
|
Requires-Dist: jupyterlab
|
|
@@ -14,6 +14,7 @@ Requires-Dist: matplotlib
|
|
|
14
14
|
Requires-Dist: numpy
|
|
15
15
|
Requires-Dist: scipy
|
|
16
16
|
Requires-Dist: lmfit
|
|
17
|
+
Requires-Dist: xarray
|
|
17
18
|
Project-URL: Documentation, https://xarpes.github.io
|
|
18
19
|
|
|
19
20
|

|
|
@@ -114,7 +115,7 @@ It is recommended to use JupyterLab to analyse data. JupyterLab is launched usin
|
|
|
114
115
|
|
|
115
116
|
Copyright (C) 2024 xARPES Developers
|
|
116
117
|
|
|
117
|
-
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version
|
|
118
|
+
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 3, as published by the Free Software Foundation.
|
|
118
119
|
|
|
119
120
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
120
121
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
xarpes/__init__.py,sha256=P2gd3I7U1a5sg7k46Cyo4YT2NqvqqYJ-X85-Vs6m5uI,149
|
|
2
|
+
xarpes/band_map.py,sha256=WvriXtP-vWny2yhPy9rC5rxS3fiTYaUph3vvg6GyCCQ,10492
|
|
3
|
+
xarpes/distributions.py,sha256=CvHVdtF-P2wXgahmH8j1nVAawsXyomImZUoNlvymIV4,15201
|
|
4
|
+
xarpes/functions.py,sha256=7WZVD8Vi4t2mg3EFJrAINTKg5Bj8EXMZh6c-N9qn6Nc,4606
|
|
5
|
+
xarpes/plotting.py,sha256=sHOI0zRb0zYgXPfWUtVOAc5ezasVsAVRb3u8E8-SHWc,5410
|
|
6
|
+
xarpes/.ipynb_checkpoints/__init__-checkpoint.py,sha256=Xi1H3Jn5vt_8WQhSTRqb9hSBhv12fTXEnQrKVdkFGcw,148
|
|
7
|
+
xarpes-0.2.3.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
8
|
+
xarpes-0.2.3.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
|
|
9
|
+
xarpes-0.2.3.dist-info/METADATA,sha256=yFbGz9lRmWqY2inVUuqhwFWTqZDyNvIShY51cII1KnY,3889
|
|
10
|
+
xarpes-0.2.3.dist-info/RECORD,,
|