diff --git a/notebooks/Spectroscopy/Analyse_EELSs.ipynb b/notebooks/Spectroscopy/Analyse_EELSs.ipynb index af6513d0..ec5c66d9 100644 --- a/notebooks/Spectroscopy/Analyse_EELSs.ipynb +++ b/notebooks/Spectroscopy/Analyse_EELSs.ipynb @@ -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 }, @@ -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" ] }, diff --git a/pyTEMlib/eels_tools.py b/pyTEMlib/eels_tools.py index 0a6ef46a..82b85fb9 100644 --- a/pyTEMlib/eels_tools.py +++ b/pyTEMlib/eels_tools.py @@ -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 @@ -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: diff --git a/setup.py b/setup.py index ad085dc9..9527553a 100644 --- a/setup.py +++ b/setup.py @@ -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, @@ -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', @@ -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="gduscher@utk.edu", - 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', ], }, )