Introduction#
The purpose of these tutorials is to provide a comprehensive collection of examples targeting a wide range of scientists and engineers interested in ptychography, from experimental users to algorithm and code developers.
Overview#
The table below gives an overview of all examples with associated data and a link for downloading the data.
Tutorial |
Download Data |
File Size |
Reference |
|---|---|---|---|
The Basics |
|||
No Data Required |
- |
- |
|
No Data Required |
- |
- |
|
No Data Required |
- |
- |
|
No Data Required |
- |
- |
|
No Data Required |
- |
- |
|
No Data Required |
- |
- |
|
No Data Required |
- |
- |
|
No Data Required |
- |
- |
|
Experimental X-ray Data |
|||
126 MB |
|||
1.11 GB |
|||
126 MB |
|||
1.11 GB |
|||
3.68 GB |
|||
993 MB |
|||
286 MB |
|||
1.11 GB |
|||
TBA |
4.8 GB |
TBA |
|
TBA |
4.8 GB |
TBA |
|
NanoMax example dataset 10_keV.zip |
432 MB |
||
565 MB |
|||
463 MB |
|||
Electron Ptychography Data |
|||
270 MB |
|||
270 MB |
|||
270 MB |
|||
Advanced Examples |
|||
esrf_id16_AlNi_nearfield.zip |
532 MB |
TBA |
|
esrf_id16_AlNi_nearfield.zip |
532 MB |
TBA |
|
1.11 GB |
|||
No Data Required |
- |
- |
|
126 MB |
|||
User Examples |
|||
- |
- |
- |
|
67 MB |
Jupyter Lab/Notebooks#
Note
Most of the content of this tutorial has been created in the form of Jupyter Notebooks and the JupyterLab interface is the recommended way of working through these examples. JupyterLab is very easy to use, should you wish to learn more about the Jupyter project and the tools it provides, visit: https://jupyter.org.
As a minimal introduction, a few words about Jupyter Notebooks, which offer a convenient way to provide executable code (e.g. Python) alongside formatted text (using markdown). All notebooks used here are structured in the same way, with some informative content at the top and a full code example at the bottom, separated by a horizontal line:
In order to execute the code cell (or any other cell), simply select the cell and type SHIFT+ENTER or ALT+ENTER
Working with this tutorial within an HPC environment#
It might not always be possible to run Jupyter Notebooks with access to accelerated GPU hardware, for example in the case of only having terminal-based access to an HPC cluster. Below are a few pointers as to how best to run the PtyPy tutorials on an interactive HPC compute node, e.g. using Slurm.
Start an interactive session in the terminal, e.g. single GPU on slurm:
srun --ntasks 1 --cpus-per-task 1 --gpus 1 --time 02:00:00 --pty bashCreate a new Python file and paste the full-length code block at the end of the Jupyter-based tutorial into it
Some of the settings in the PtyPy parameter tree are optimised for running it as a Jupyter Notebook, in particular the following should be modified when running interactively with Python
# Give your reconstruction a name
p.run = "test"
# Set verbose level to info
p.verbose_level = "info"
# Set io settings (no files saved)
p.io = u.Param()
p.io.home = "./"
p.io.rfile = "recons/%(run)s/%(run)s_%(engine)s_%(iterations)04d.ptyr"
p.io.autosave = u.Param(active=False)
p.io.interaction = u.Param(active=False)
p.io.autoplot = u.Param(active=False)
this will turn off all interactive plotting that is configured in all Jupyter Notebook tutorials, and it will save the results in a folder called recons in the folder defined as p.io.home.
How to visualise PtyPy output from a .ptyr file#
From a terminal with Graphics#
The simplest way to inspect the reconstruction results saved in the .ptyr file is to use the following command from a terminal with access to Graphics
ptypy.plot <PATH-TO-PTYR-FILE>
From a Jupyter Notebook or a Python script#
An alternative approach is to visualise the results in a Jupyter Notebook or from a Python script using the following code
import os
import ptypy.utils.plot_client as pc
ptyr_filename = "<PATH-TO-PTYR-FILE>"
fig = pc.figure_from_ptyr(ptyr_filename)