Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
gduscher committed Feb 6, 2025
1 parent b51f369 commit b262dd9
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 44 deletions.
7 changes: 3 additions & 4 deletions notebooks/Spectroscopy/Analyse_EELSs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,13 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "d511383382c64143831832038a6c540e",
"model_id": "19a19d099fcd4206ba1d147412f71e4b",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -236,8 +236,7 @@
"source": [
"if 'google.colab' in sys.modules:\n",
" drive.mount(\"/content/drive\")\n",
"import pyTEMlib.info_widget \n",
"# filename = '../../example_data/AL-DFoffset0.00.dm3'\n",
"import pyTEMlib.info_widget filename = '../../example_data/AL-DFoffset0.00.dm3'\n",
"infoWidget= pyTEMlib.info_widget3.EELSWidget()\n"
]
},
Expand Down
68 changes: 36 additions & 32 deletions pyTEMlib/eels_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1180,38 +1180,39 @@ def find_associated_edges(dataset: sidpy.Dataset) -> None:
# peak['distance_to_onset'] = np.min(distances)
print(dataset.metadata['core_loss'])

def find_white_lines(dataset: sidpy.Dataset) -> None:
if 'edges' in dataset.metadata:
white_lines = {}
for index, peak in dataset.metadata['peak_fit']['peaks'].items():
if index.isdigit():
if 'associated_edge' in peak:
if peak['associated_edge'][-2:] in ['L3', 'L2', 'M5', 'M4']:
if peak['distance_to_onset'] < 10:
area = np.sqrt(2 * np.pi) * peak['amplitude'] * np.abs(peak['width']/np.sqrt(2 * np.log(2)))
if peak['associated_edge'] not in white_lines:
white_lines[peak['associated_edge']] = 0.
if area > 0:
white_lines[peak['associated_edge']] += area # TODO: only positive ones?
white_line_ratios = {}
white_line_sum = {}
for sym, area in white_lines.items():
if sym[-2:] in ['L2', 'M4', 'M2']:
if area > 0 and f"{sym[:-1]}{int(sym[-1]) + 1}" in white_lines:
if white_lines[f"{sym[:-1]}{int(sym[-1]) + 1}"] > 0:
white_line_ratios[f"{sym}/{sym[-2]}{int(sym[-1]) + 1}"] = area / white_lines[
f"{sym[:-1]}{int(sym[-1]) + 1}"]
white_line_sum[f"{sym}+{sym[-2]}{int(sym[-1]) + 1}"] = (
area + white_lines[f"{sym[:-1]}{int(sym[-1]) + 1}"])

areal_density = 1.
if 'edges' in dataset.metadata:
for key, edge in dataset.metadata['edges'].items():
if key.isdigit():
if edge['element'] == sym.split('-')[0]:
areal_density = edge['areal_density']
break
white_line_sum[f"{sym}+{sym[-2]}{int(sym[-1]) + 1}"] /= areal_density

def find_white_lines(peaks: dict) -> None:

white_lines = {}
for index, peak in peaks['peaks'].items():
if index.isdigit():
if 'associated_edge' in peak:
if peak['associated_edge'][-2:] in ['L3', 'L2', 'M5', 'M4']:
if peak['distance_to_onset'] < 10:
area = np.sqrt(2 * np.pi) * peak['amplitude'] * np.abs(peak['width']/np.sqrt(2 * np.log(2)))
if peak['associated_edge'] not in white_lines:
white_lines[peak['associated_edge']] = 0.
if area > 0:
white_lines[peak['associated_edge']] += area # TODO: only positive ones?
white_line_ratios = {}
white_line_sum = {}
for sym, area in white_lines.items():
if sym[-2:] in ['L2', 'M4', 'M2']:
if area > 0 and f"{sym[:-1]}{int(sym[-1]) + 1}" in white_lines:
if white_lines[f"{sym[:-1]}{int(sym[-1]) + 1}"] > 0:
white_line_ratios[f"{sym}/{sym[-2]}{int(sym[-1]) + 1}"] = area / white_lines[
f"{sym[:-1]}{int(sym[-1]) + 1}"]
white_line_sum[f"{sym}+{sym[-2]}{int(sym[-1]) + 1}"] = (
area + white_lines[f"{sym[:-1]}{int(sym[-1]) + 1}"])

areal_density = 1.
if 'edges' in dataset.metadata:
for key, edge in dataset.metadata['edges'].items():
if key.isdigit():
if edge['element'] == sym.split('-')[0]:
areal_density = edge['areal_density']
break
white_line_sum[f"{sym}+{sym[-2]}{int(sym[-1]) + 1}"] /= areal_density

dataset.metadata['peak_fit']['white_lines'] = white_lines
dataset.metadata['peak_fit']['white_line_ratios'] = white_line_ratios
Expand Down Expand Up @@ -1544,6 +1545,9 @@ def make_cross_sections(edges:dict, energy_scale:np.ndarray, e_0:float, coll_ang
"""
for key in edges:
if str(key).isdigit():
print(edges[key]['z'])
if edges[key]['z'] <1:
break
edges[key]['data'] = xsec_xrpa(energy_scale, e_0 / 1000., edges[key]['z'], coll_angle,
edges[key]['chemical_shift']) / 1e10 # from barnes to 1/nm^2
if low_loss is not None:
Expand Down
13 changes: 5 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
with open(os.path.join(here, 'README.rst')) as f:
long_description = f.read()

with open(os.path.join(here, 'pyTEMlib/version.py')) as f:
with open(os.path.join(here, './version.py')) as f:
__version__ = f.read().split("'")[1]


setuptools.setup(
name="pyTEMlib",
name="pycrosGUI",
version=__version__,
description="pyTEM: TEM Data Quantification library through a model-based approach",
long_description=long_description,
Expand All @@ -32,7 +32,6 @@
'Operating System :: OS Independent',
'Programming Language :: Cython',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
Expand All @@ -43,22 +42,20 @@
'storage', 'hdf5', 'diffraction'],
packages=setuptools.find_packages(exclude=["*.tests", "*.tests.*",
"tests.*", "tests"]),
url="https://pycroscopy.github.io/pyTEMlib/about.html",
url="https://pycroscopy.github.io/pycrosGUI/about.html",
license='MIT',
author="Gerd Duscher",
author_email="[email protected]",

install_requires=['scipy', 'numpy', 'pillow', 'ase', 'tqdm', 'plotly', 'pandas', 'requests', 'lxml', 'ipympl',
'spglib', 'scikit-image', 'scikit-learn', 'pyNSID>=0.0.7', 'sidpy>=0.12.1', 'SciFiReaders>=0.0.8'], # 'PyQt5> 1.0'],#
install_requires=['pyTEMlib', 'pyqt5', 'pyqtgraph'], # 'PyQt5> 1.0'],#
setup_requires=['pytest-runner'],
tests_require=['pytest'],
platforms=['Linux', 'Mac OSX', 'Windows 11/10'],
package_data={"pyTEMlib": ["data/*"]},
test_suite='pytest',
include_package_data=True,
entry_points={
'console_scripts': [
'pyTEMlib=pyTEMlib:main',
'pycrosGUI=pycrosGUI:main',
],
},
)

0 comments on commit b262dd9

Please sign in to comment.