Skip to content

Commit

Permalink
cleaned up kinematic_scattering
Browse files Browse the repository at this point in the history
  • Loading branch information
gduscher committed Jan 10, 2024
1 parent 921afdb commit 20083c5
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 538 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,4 @@ notebooks/Imaging/data/lineweight.txt
notebooks/EELS/relax.csv
Untitled.ipynb
example_data/GOLD-NP-DIFF-2-3.hf5
example_data/GOLD-NP-DIFF-2-4.hf5
96 changes: 75 additions & 21 deletions notebooks/EELS/Analyse_Low_Loss.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,71 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"installing pyTEMlib\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING: Skipping C:\\Users\\gduscher\\AppData\\Local\\anaconda3\\envs\\pyTEMlib\\Lib\\site-packages\\matplotlib-3.7.2.dist-info due to invalid metadata entry 'name'\n",
"WARNING: Skipping C:\\Users\\gduscher\\AppData\\Local\\anaconda3\\envs\\pyTEMlib\\Lib\\site-packages\\numpy-1.24.4.dist-info due to invalid metadata entry 'name'\n",
"WARNING: Skipping C:\\Users\\gduscher\\AppData\\Local\\anaconda3\\envs\\pyTEMlib\\Lib\\site-packages\\pywinpty-2.0.10.dist-info due to invalid metadata entry 'name'\n",
"WARNING: Skipping C:\\Users\\gduscher\\AppData\\Local\\anaconda3\\envs\\pyTEMlib\\Lib\\site-packages\\pyzmq-25.1.0.dist-info due to invalid metadata entry 'name'\n",
"WARNING: Skipping C:\\Users\\gduscher\\AppData\\Local\\anaconda3\\envs\\pyTEMlib\\Lib\\site-packages\\matplotlib-3.7.2.dist-info due to invalid metadata entry 'name'\n",
"WARNING: Skipping C:\\Users\\gduscher\\AppData\\Local\\anaconda3\\envs\\pyTEMlib\\Lib\\site-packages\\numpy-1.24.4.dist-info due to invalid metadata entry 'name'\n",
"WARNING: Skipping C:\\Users\\gduscher\\AppData\\Local\\anaconda3\\envs\\pyTEMlib\\Lib\\site-packages\\pywinpty-2.0.10.dist-info due to invalid metadata entry 'name'\n",
"WARNING: Skipping C:\\Users\\gduscher\\AppData\\Local\\anaconda3\\envs\\pyTEMlib\\Lib\\site-packages\\pyzmq-25.1.0.dist-info due to invalid metadata entry 'name'\n",
"WARNING: Skipping C:\\Users\\gduscher\\AppData\\Local\\anaconda3\\envs\\pyTEMlib\\Lib\\site-packages\\matplotlib-3.7.2.dist-info due to invalid metadata entry 'name'\n",
"WARNING: Skipping C:\\Users\\gduscher\\AppData\\Local\\anaconda3\\envs\\pyTEMlib\\Lib\\site-packages\\numpy-1.24.4.dist-info due to invalid metadata entry 'name'\n",
"WARNING: Skipping C:\\Users\\gduscher\\AppData\\Local\\anaconda3\\envs\\pyTEMlib\\Lib\\site-packages\\pywinpty-2.0.10.dist-info due to invalid metadata entry 'name'\n",
"WARNING: Skipping C:\\Users\\gduscher\\AppData\\Local\\anaconda3\\envs\\pyTEMlib\\Lib\\site-packages\\pyzmq-25.1.0.dist-info due to invalid metadata entry 'name'\n",
" WARNING: Skipping C:\\Users\\gduscher\\AppData\\Local\\anaconda3\\envs\\pyTEMlib\\Lib\\site-packages\\matplotlib-3.7.2.dist-info due to invalid metadata entry 'name'\n",
" WARNING: Skipping C:\\Users\\gduscher\\AppData\\Local\\anaconda3\\envs\\pyTEMlib\\Lib\\site-packages\\numpy-1.24.4.dist-info due to invalid metadata entry 'name'\n",
" WARNING: The script f2py.exe is installed in 'C:\\Users\\gduscher\\AppData\\Local\\anaconda3\\envs\\pyTEMlib\\Scripts' which is not on PATH.\n",
" Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.\n",
"ERROR: Cannot uninstall 'llvmlite'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.\n",
"WARNING: Skipping C:\\Users\\gduscher\\AppData\\Local\\anaconda3\\envs\\pyTEMlib\\Lib\\site-packages\\matplotlib-3.7.2.dist-info due to invalid metadata entry 'name'\n",
"WARNING: Skipping C:\\Users\\gduscher\\AppData\\Local\\anaconda3\\envs\\pyTEMlib\\Lib\\site-packages\\pywinpty-2.0.10.dist-info due to invalid metadata entry 'name'\n",
"WARNING: Skipping C:\\Users\\gduscher\\AppData\\Local\\anaconda3\\envs\\pyTEMlib\\Lib\\site-packages\\pyzmq-25.1.0.dist-info due to invalid metadata entry 'name'\n",
"WARNING: Skipping C:\\Users\\gduscher\\AppData\\Local\\anaconda3\\envs\\pyTEMlib\\Lib\\site-packages\\matplotlib-3.7.2.dist-info due to invalid metadata entry 'name'\n",
"WARNING: Skipping C:\\Users\\gduscher\\AppData\\Local\\anaconda3\\envs\\pyTEMlib\\Lib\\site-packages\\matplotlib-3.7.2.dist-info due to invalid metadata entry 'name'\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"done\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING: Skipping C:\\Users\\gduscher\\AppData\\Local\\anaconda3\\envs\\pyTEMlib\\Lib\\site-packages\\matplotlib-3.7.2.dist-info due to invalid metadata entry 'name'\n",
"WARNING: Skipping C:\\Users\\gduscher\\AppData\\Local\\anaconda3\\envs\\pyTEMlib\\Lib\\site-packages\\pywinpty-2.0.10.dist-info due to invalid metadata entry 'name'\n",
"WARNING: Skipping C:\\Users\\gduscher\\AppData\\Local\\anaconda3\\envs\\pyTEMlib\\Lib\\site-packages\\pyzmq-25.1.0.dist-info due to invalid metadata entry 'name'\n",
"WARNING: Skipping C:\\Users\\gduscher\\AppData\\Local\\anaconda3\\envs\\pyTEMlib\\Lib\\site-packages\\matplotlib-3.7.2.dist-info due to invalid metadata entry 'name'\n",
"WARNING: Skipping C:\\Users\\gduscher\\AppData\\Local\\anaconda3\\envs\\pyTEMlib\\Lib\\site-packages\\pywinpty-2.0.10.dist-info due to invalid metadata entry 'name'\n",
"WARNING: Skipping C:\\Users\\gduscher\\AppData\\Local\\anaconda3\\envs\\pyTEMlib\\Lib\\site-packages\\pyzmq-25.1.0.dist-info due to invalid metadata entry 'name'\n",
"WARNING: Skipping C:\\Users\\gduscher\\AppData\\Local\\anaconda3\\envs\\pyTEMlib\\Lib\\site-packages\\matplotlib-3.7.2.dist-info due to invalid metadata entry 'name'\n",
"WARNING: Skipping C:\\Users\\gduscher\\AppData\\Local\\anaconda3\\envs\\pyTEMlib\\Lib\\site-packages\\pywinpty-2.0.10.dist-info due to invalid metadata entry 'name'\n",
"WARNING: Skipping C:\\Users\\gduscher\\AppData\\Local\\anaconda3\\envs\\pyTEMlib\\Lib\\site-packages\\pyzmq-25.1.0.dist-info due to invalid metadata entry 'name'\n",
"ERROR: Cannot uninstall 'llvmlite'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.\n",
"WARNING: Skipping C:\\Users\\gduscher\\AppData\\Local\\anaconda3\\envs\\pyTEMlib\\Lib\\site-packages\\matplotlib-3.7.2.dist-info due to invalid metadata entry 'name'\n",
"WARNING: Skipping C:\\Users\\gduscher\\AppData\\Local\\anaconda3\\envs\\pyTEMlib\\Lib\\site-packages\\pywinpty-2.0.10.dist-info due to invalid metadata entry 'name'\n",
"WARNING: Skipping C:\\Users\\gduscher\\AppData\\Local\\anaconda3\\envs\\pyTEMlib\\Lib\\site-packages\\pyzmq-25.1.0.dist-info due to invalid metadata entry 'name'\n",
"WARNING: Skipping C:\\Users\\gduscher\\AppData\\Local\\anaconda3\\envs\\pyTEMlib\\Lib\\site-packages\\matplotlib-3.7.2.dist-info due to invalid metadata entry 'name'\n",
"WARNING: Skipping C:\\Users\\gduscher\\AppData\\Local\\anaconda3\\envs\\pyTEMlib\\Lib\\site-packages\\matplotlib-3.7.2.dist-info due to invalid metadata entry 'name'\n"
]
}
],
"source": [
Expand All @@ -88,7 +144,7 @@
" return version\n",
"\n",
"# pyTEMlib setup ------------------\n",
"if test_package('pyTEMlib') < '0.2023.9.1':\n",
"if test_package('pyTEMlib') < '0.2024.1.0':\n",
" print('installing pyTEMlib')\n",
" !{sys.executable} -m pip install --upgrade git+https://github.com/pycroscopy/SciFiReaders.git@main -q\n",
" !{sys.executable} -m pip install --upgrade git+https://github.com/pycroscopy/pyTEMlib.git@main -q --upgrade\n",
Expand All @@ -113,7 +169,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 5,
"metadata": {
"hideCode": false,
"hidePrompt": false,
Expand All @@ -124,10 +180,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
"You don't have igor2 installed. If you wish to open igor files, you will need to install it (pip install igor2) before attempting.\n",
"You don't have gwyfile installed. If you wish to open .gwy files, you will need to install it (pip install gwyfile) before attempting.\n",
"Symmetry functions of spglib enabled\n",
"Using kinematic_scattering library version {_version_ } by G.Duscher\n",
"The autoreload extension is already loaded. To reload it, use:\n",
" %reload_ext autoreload\n",
"pyTEM version: 0.2024.01.0\n"
]
}
Expand Down Expand Up @@ -180,26 +234,26 @@
},
{
"cell_type": "code",
"execution_count": 168,
"execution_count": 7,
"metadata": {
"hideCode": false,
"hidePrompt": false,
"tags": []
},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "c1cbca65c75a4c88b5ae89d4428bc3bd",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"VBox(children=(Dropdown(description='directory:', layout=Layout(width='90%'), options=('C:\\\\Users\\\\gduscher\\\\D…"
]
},
"metadata": {},
"output_type": "display_data"
"ename": "FileNotFoundError",
"evalue": "[WinError 3] The system cannot find the path specified: '../example_data'",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mFileNotFoundError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[1;32mIn[7], line 6\u001b[0m\n\u001b[0;32m 4\u001b[0m filename \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124m../../example_data/AL-DFoffset0.00.dm3\u001b[39m\u001b[38;5;124m'\u001b[39m\n\u001b[0;32m 5\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mpyTEMlib\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01minfo_widget\u001b[39;00m\n\u001b[1;32m----> 6\u001b[0m infoWidget\u001b[38;5;241m=\u001b[39m \u001b[43mpyTEMlib\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43minfo_widget\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mInfoWidget\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43m.\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m)\u001b[49m\n",
"File \u001b[1;32m~\\Documents\\Github\\pyTEMlib\\notebooks\\EELS\\../..\\pyTEMlib\\info_widget.py:565\u001b[0m, in \u001b[0;36mInfoWidget.__init__\u001b[1;34m(self, datasets)\u001b[0m\n\u001b[0;32m 562\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m__init__\u001b[39m(\u001b[38;5;28mself\u001b[39m, datasets\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m):\n\u001b[0;32m 564\u001b[0m sidebar \u001b[38;5;241m=\u001b[39m get_info_sidebar()\n\u001b[1;32m--> 565\u001b[0m \u001b[38;5;28;43msuper\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[38;5;21;43m__init__\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mdatasets\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43msidebar\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 566\u001b[0m \u001b[38;5;28msuper\u001b[39m()\u001b[38;5;241m.\u001b[39mset_dataset()\n\u001b[0;32m 567\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mset_action()\n",
"File \u001b[1;32m~\\Documents\\Github\\pyTEMlib\\notebooks\\EELS\\../..\\pyTEMlib\\info_widget.py:163\u001b[0m, in \u001b[0;36mEELSWidget.__init__\u001b[1;34m(self, datasets, sidebar, tab_title)\u001b[0m\n\u001b[0;32m 160\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m os\u001b[38;5;241m.\u001b[39mpath\u001b[38;5;241m.\u001b[39misdir(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdir_name):\n\u001b[0;32m 161\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdir_name \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124m.\u001b[39m\u001b[38;5;124m'\u001b[39m\n\u001b[1;32m--> 163\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_directory\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdir_name\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 164\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdir_list \u001b[38;5;241m=\u001b[39m [\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m.\u001b[39m\u001b[38;5;124m'\u001b[39m]\n\u001b[0;32m 165\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mextensions \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124m*\u001b[39m\u001b[38;5;124m'\u001b[39m\n",
"File \u001b[1;32m~\\Documents\\Github\\pyTEMlib\\notebooks\\EELS\\../..\\pyTEMlib\\info_widget.py:500\u001b[0m, in \u001b[0;36mEELSWidget.get_directory\u001b[1;34m(self, directory)\u001b[0m\n\u001b[0;32m 498\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdir_dictionary \u001b[38;5;241m=\u001b[39m {}\n\u001b[0;32m 499\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdir_list \u001b[38;5;241m=\u001b[39m []\n\u001b[1;32m--> 500\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdir_list \u001b[38;5;241m=\u001b[39m [\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m.\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124m..\u001b[39m\u001b[38;5;124m'\u001b[39m] \u001b[38;5;241m+\u001b[39m \u001b[43mos\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mlistdir\u001b[49m\u001b[43m(\u001b[49m\u001b[43mdirectory\u001b[49m\u001b[43m)\u001b[49m\n",
"\u001b[1;31mFileNotFoundError\u001b[0m: [WinError 3] The system cannot find the path specified: '../example_data'"
]
}
],
"source": [
Expand All @@ -208,7 +262,7 @@
" \n",
"filename = '../../example_data/AL-DFoffset0.00.dm3'\n",
"import pyTEMlib.info_widget\n",
"infoWidget= pyTEMlib.info_widget.InfoWidget()"
"infoWidget= pyTEMlib.info_widget.InfoWidget('.')"
]
},
{
Expand Down
5 changes: 3 additions & 2 deletions notebooks/Imaging/Register_Image_Stack.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,7 @@
"\n",
"import skimage\n",
"\n",
"if 'google.colab' in sys.modules:\n",
" drive.mount(\"/content/drive\")\n",
"\n",
" \n",
"# For archiving reasons it is a good idea to print the version numbers out at this point\n",
"print('pyTEM version: ',pyTEMlib.__version__)\n",
Expand Down Expand Up @@ -215,6 +214,8 @@
}
],
"source": [
"if 'google.colab' in sys.modules:\n",
" drive.mount(\"/content/drive\")\n",
"fileWidget = ft.FileWidget()"
]
},
Expand Down
1 change: 0 additions & 1 deletion pyTEMlib/config_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
config_dir: setup of directory ~/.pyTEMlib for custom sources and database
"""
import os
import numpy as np

# import wget
if os.name == 'posix':
Expand Down
4 changes: 3 additions & 1 deletion pyTEMlib/image_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ def diffractogram_spots(dset, spot_threshold, return_center = True, eps = 0.1):
# third row is angles
spots[:, 2] = np.arctan2(spots[:, 0], spots[:, 1])

center = [0, 0]

if return_center == True:
points = spots[:, 0:2]

Expand Down Expand Up @@ -802,7 +804,7 @@ def onclick(event):
else:
vmax = data.max()
vmin = data.min()
onselect(vmin, vmax)
onselect(vmin, vmax)

fig2 = plt.figure()

Expand Down
Loading

0 comments on commit 20083c5

Please sign in to comment.