Skip to content

Commit

Permalink
Fixed bugs and issues
Browse files Browse the repository at this point in the history
  • Loading branch information
daurer committed Jun 3, 2024
1 parent 038cdae commit ac4fc43
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ dmypy.json
docs/_build

# Specific folders
docs/notebooks
admin
converted
data
tmp
6 changes: 3 additions & 3 deletions docs/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ followed by running this set up command
/global/common/software/ntrain3/ptypy_workshop_setup.sh
```

Now that we have cloned the tutorials and set up the correct environment, we can simply navigate to ```tutorials``` in the file panel on the left and open the [first tutorial](./notebooks/Getting_Started_with_PtyPy/1_the_parameter_tree) from within the ```notebooks``` folder.
Now that we have cloned the tutorials and set up the correct environment, we can simply navigate to ```tutorials``` in the file panel on the left and open the [first tutorial](./notebooks/01_05_Getting_Started_with_PtyPy/1_the_parameter_tree) from within the ```notebooks``` folder.


## How to use a Jupyter Notebook
Before we get started with PtyPy, 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:

```{figure} ./jupyter_notebook_1.PNG
:name: jupyterlab
:name: jupyterlab1
```

In order to execute the code cell (or any other cell), simply select the cell and type **SHIFT+ENTER** or **ALT+ENTER**

```{figure} ./jupyter_notebook_2.PNG
:name: jupyterlab
:name: jupyterlab2
```

## Table of Contents
Expand Down
6 changes: 4 additions & 2 deletions docs/scripts/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
if args.actions:
notebook_dir = os.path.dirname(__file__) + "/../notebooks/"
else:
notebook_dir = os.path.dirname(__file__) + "/../converted/"
notebook_dir = os.path.dirname(__file__) + "/../../converted/"
notebooks = glob.glob(notebook_dir + "*/*.ipynb")
print(notebooks, notebook_dir)

def replace_div_with_admonition(cell, label="Note", type="note"):
text = cell["source"][1:-1]
Expand All @@ -27,7 +28,8 @@ def replace_div_with_admonition(cell, label="Note", type="note"):
new[2:2] = text
cell["source"] = new

for name in notebooks:
for name in notebooks:
print(f"Converting {name}")
nb = json.load(open(name))
for cell in nb["cells"]:
if cell["cell_type"] == "markdown":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"metadata": {},
"source": [
"## Making a Python run script for PtyPy\n",
"Revisiting the earlier example on using [JSON/YAML Config Files](../01_05_Getting_Started_With_PtyPy/2_yaml_json_config.ipynb) we have saved the parameter tree from the previous example on [Working With Large Data](./10_working_with_large_data.ipynb) into a config file named [./config/dls_i08_nanogold_spiral.yml](./config/dls_i08_nanogold_spiral.yml) making a few changes, i.e. switching to ```verbose_level=info``` and providing ```p.io.rfile``` for saving the output of the reconstruction. We can then generate a simple Python script\n",
"Revisiting the earlier example on using [JSON/YAML Config Files](../01_05_Getting_Started_with_PtyPy/2_yaml_json_config.ipynb) we have saved the parameter tree from the previous example on [Working With Large Data](./10_working_with_large_data.ipynb) into a config file named [./config/dls_i08_nanogold_spiral.yaml](./config/dls_i08_nanogold_spiral.yaml) making a few changes, i.e. switching to ```verbose_level=info``` and providing ```p.io.rfile``` for saving the output of the reconstruction. We can then generate a simple Python script\n",
"\n",
"```python\n",
"with open(\"./ptypy_run_dls_i08_nanogold.py\", \"w\") as f:\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"source": [
"## Running the reconstruction in Python script\n",
"\n",
"First, we copy a YAML config file [config/dls_nanogold_spiral.yaml](config/dls_nanogold_spiral.yaml) from one of the previous examples making sure that we turn on the interaction server ```p.io.interaction.server``` \n",
"First, we copy a YAML config file [./config/dls_i08_nanogold_spiral.yaml](./config/dls_i08_nanogold_spiral.yaml) from one of the previous examples making sure that we turn on the interaction server ```p.io.interaction.server``` \n",
"\n",
"```python\n",
"p.io = u.Param()\n",
Expand Down
2 changes: 1 addition & 1 deletion notebooks/18_21_Advanced_Topics/20_simulating_data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"source": [
"## The data\n",
"\n",
"For the simulation, we can use an image of a [painting](../../data//small_data/painting.jpg) for the object and a real probe from the I08-1 instrument\n",
"For the simulation, we can use an image of a [painting](./_assets/painting.jpg) for the object and a real probe from the I08-1 instrument\n",
"\n",
"```python\n",
"path_to_probe = \"small_data/dls_i08_nanogold_recon.ptyr\"\n",
Expand Down
2 changes: 1 addition & 1 deletion scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ cd ./docs/
cp -r ../notebooks/* ../converted/
rm ./notebooks
ln -s ../converted ./notebooks
cd ../

# Convert notebooks
module load ptypy
python ./scripts/convert.py

# Build Jupyter book
cd ../
jupyter-book build docs/

0 comments on commit ac4fc43

Please sign in to comment.