Skip to content

Commit

Permalink
Checked supplementary examples
Browse files Browse the repository at this point in the history
  • Loading branch information
daurer committed Jun 10, 2024
1 parent a40546f commit 53665c2
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 31 deletions.
17 changes: 9 additions & 8 deletions notebooks/supplementary_examples/00_nearfield_ptychography.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "c7b8dac1-ec91-42b8-b609-66e8860fcb70",
"metadata": {},
Expand Down Expand Up @@ -168,7 +167,9 @@
"cell_type": "code",
"execution_count": null,
"id": "ee3cbe0e-7393-4e07-8e6c-a0063eb55dbe",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import ptypy, h5py, os\n",
Expand All @@ -178,7 +179,7 @@
"ptypy.load_ptyscan_module(\"hdf5_loader\")\n",
"\n",
"# This will import the GPU engines\n",
"ptypy.load_gpu_engines(\"cuda\") \n",
"ptypy.load_gpu_engines(\"cupy\") \n",
"\n",
"# Root directory of tutorial data\n",
"tutorial_data_home = \"../../data/\"\n",
Expand Down Expand Up @@ -260,7 +261,7 @@
"# Reconstruct using GPU-accelerated DM/ML engines\n",
"p.engines = u.Param()\n",
"p.engines.DM = u.Param()\n",
"p.engines.DM.name = 'DM_pycuda'\n",
"p.engines.DM.name = 'DM_cupy'\n",
"p.engines.DM.numiter = 500\n",
"p.engines.DM.numiter_contiguous = 10\n",
"p.engines.DM.probe_support = None\n",
Expand All @@ -269,7 +270,7 @@
"p.engines.DM.probe_update_start = 0\n",
"\n",
"p.engines.ML = u.Param()\n",
"p.engines.ML.name = 'ML_pycuda'\n",
"p.engines.ML.name = 'ML_cupy'\n",
"p.engines.ML.numiter = 500\n",
"p.engines.ML.numiter_contiguous = 10\n",
"p.engines.ML.ML_type = 'Gaussian'\n",
Expand All @@ -287,9 +288,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "PtyPy",
"display_name": "PtyPy (cupy)",
"language": "python",
"name": "ptypy_pycuda"
"name": "ptypy_cupy"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -301,7 +302,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.15"
"version": "3.11.8"
}
},
"nbformat": 4,
Expand Down
14 changes: 9 additions & 5 deletions notebooks/supplementary_examples/01_object_regularisation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@
"cell_type": "code",
"execution_count": null,
"id": "e5286f05-4595-4d85-857a-612274f213d9",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import h5py\n",
Expand Down Expand Up @@ -269,7 +271,9 @@
"cell_type": "code",
"execution_count": null,
"id": "a495ee4f-604b-4f68-a023-032061ae43dd",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import ptypy, h5py, os\n",
Expand All @@ -279,7 +283,7 @@
"ptypy.load_ptyscan_module(\"hdf5_loader\")\n",
"\n",
"# This will import the GPU engines\n",
"ptypy.load_gpu_engines(\"cuda\")\n",
"ptypy.load_gpu_engines(\"pycuda\")\n",
"\n",
"# Load custom engine\n",
"from ptypy.custom.DM_pycuda_object_regul import DM_pycuda_object_regul\n",
Expand Down Expand Up @@ -385,7 +389,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "PtyPy",
"display_name": "PtyPy (pycuda)",
"language": "python",
"name": "ptypy_pycuda"
},
Expand All @@ -399,7 +403,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.15"
"version": "3.11.4"
}
},
"nbformat": 4,
Expand Down
30 changes: 24 additions & 6 deletions notebooks/supplementary_examples/02_live_visualisation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@
"cell_type": "code",
"execution_count": null,
"id": "b81d242c-deda-4b5d-a577-b55b42e46ac9",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"with open(\"./ptypy_run_dls_i08_nanogold.py\", \"w\") as f:\n",
Expand All @@ -78,6 +80,18 @@
"\"\"\")"
]
},
{
"cell_type": "raw",
"id": "75d00b06-5dc5-46da-93a8-5b160285845b",
"metadata": {
"tags": []
},
"source": [
"# commands to copy into terminal\n",
"cd $HOME/tutorials/notebooks/supplementary_examples\n",
"srun -n 4 -c 2 --gpus-per-task=1 --gpu-bin=None python ptypy_run_dls_i08_nanogold.py"
]
},
{
"cell_type": "markdown",
"id": "6a288a19-ea65-41f6-9bb3-0337a00dde6a",
Expand Down Expand Up @@ -139,7 +153,9 @@
"cell_type": "code",
"execution_count": null,
"id": "ca168d91-e5b8-4d41-8b5d-1c37035f906a",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import ptypy\n",
Expand All @@ -160,7 +176,9 @@
"cell_type": "code",
"execution_count": null,
"id": "06fe8608-449e-4b66-a512-0f339ea7afe8",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"# Refresh this cell multiple time \n",
Expand All @@ -182,9 +200,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "PtyPy",
"display_name": "PtyPy (cupy)",
"language": "python",
"name": "ptypy_pycuda"
"name": "ptypy_cupy"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -196,7 +214,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.15"
"version": "3.11.8"
}
},
"nbformat": 4,
Expand Down
10 changes: 6 additions & 4 deletions notebooks/supplementary_examples/03_simulating_data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@
"cell_type": "code",
"execution_count": null,
"id": "3d920728-63e9-4070-bbab-455a97d8303b",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import ptypy\n",
Expand Down Expand Up @@ -262,9 +264,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel) [User Conda - cuda12.2]",
"display_name": "PtyPy (cupy)",
"language": "python",
"name": "conda-env-User_Conda_-_cuda12.2-python3"
"name": "ptypy_cupy"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -276,7 +278,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
"version": "3.11.8"
}
},
"nbformat": 4,
Expand Down
24 changes: 16 additions & 8 deletions notebooks/supplementary_examples/04_modified_initial_probe.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"id": "84411552-5a4e-4a26-a702-cdf0b23feab1",
"metadata": {},
"source": [
"This example builds on the data set used in [The Hdf5Loader](../experimental_xray_data/00_data_loading.ipynb) and shows how it is possible in PtyPy to set up a reconstruction, execute with ```level=4```, then modify the model of the initial probe and run the reconstruction via ```P.run()``` using the newly generated initial probe\n",
"This example is using the same data and parameters as in [Loading HDF5 Data](../experimental_xray_data/00_data_loading.ipynb) and shows how it is possible in PtyPy to set up a reconstruction, execute with ```level=4```, then modify the model of the initial probe and run the reconstruction via ```P.run()``` using the newly generated initial probe\n",
"\n",
"![](./_assets/modified_probe.png)"
]
Expand All @@ -31,7 +31,9 @@
"cell_type": "code",
"execution_count": null,
"id": "903a1bb0-5ff1-401a-8f49-a0b5913eabc1",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import ptypy, os\n",
Expand Down Expand Up @@ -137,7 +139,9 @@
"cell_type": "code",
"execution_count": null,
"id": "47c1927b-bc49-4dad-99bf-4746c1590bd1",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"from ptypy.core.illumination import _propagation, illumination_desc, aperture\n",
Expand Down Expand Up @@ -173,7 +177,9 @@
"cell_type": "code",
"execution_count": null,
"id": "715591d6-e765-498d-a7da-22e19db20a87",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
Expand All @@ -195,7 +201,9 @@
"cell_type": "code",
"execution_count": null,
"id": "17d9466c-1296-4fe8-bdf9-65541db9b8ef",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"# Run the reconstruction using the modified initial probe\n",
Expand All @@ -205,9 +213,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.10 [DLS Conda]",
"display_name": "PtyPy (cupy)",
"language": "python",
"name": "conda-env-DLS_Conda-python3.10-kernel.json"
"name": "ptypy_cupy"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -219,7 +227,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
"version": "3.11.8"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 53665c2

Please sign in to comment.