Skip to content

Commit 00e2710

Browse files
committed
updated notebooks, using pygemc from latest image
1 parent bc4980b commit 00e2710

9 files changed

Lines changed: 111 additions & 184 deletions

File tree

Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
FROM ghcr.io/gemc/src:dev-ubuntu-24.04
1+
FROM ghcr.io/gemc/src:dev-ubuntu-26.04
22

33
USER root
44

55
RUN apt-get update && apt-get install -y --no-install-recommends \
66
python3-pip \
77
&& rm -rf /var/lib/apt/lists/*
88

9-
RUN pip install --no-cache-dir --break-system-packages \
9+
RUN DOCKER_ENTRYPOINT_SOURCE_ONLY=1 . /usr/local/bin/docker-entrypoint.sh \
10+
&& python3 -m pip install --no-cache-dir \
1011
'jupyterlab>=3' \
1112
ipywidgets \
13+
ipykernel \
1214
'pyvista[all,trame]' \
1315
jupyter-server-proxy \
1416
pandas \
@@ -24,4 +26,4 @@ WORKDIR /home/ubuntu
2426
COPY --chown=ubuntu:ubuntu notebooks/ /home/ubuntu/notebooks/
2527

2628

27-
CMD ["jupyter", "lab", "--ip=0.0.0.0", "--no-browser"]
29+
CMD ["python3", "-m", "jupyter", "lab", "--ip=0.0.0.0", "--no-browser"]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ GEMC Jupyter Notebooks Tutorials on Binder
44
# Build and run:
55

66
```shell
7-
docker pull ghcr.io/gemc/src:dev-ubuntu-24.04
7+
docker pull ghcr.io/gemc/src:dev-ubuntu-26.04
88
docker build -t gemc-binder .
99
docker run --rm -p 8888:8888 gemc-binder
1010
```

notebooks/basic/b1.ipynb

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,19 @@
2929
"# │ dosimeter digitization to store the accumulated dose on a detector. │\n",
3030
"# │ │\n",
3131
"# │ │\n",
32-
"# │ import PyVista and editor\n",
32+
"# │ Import notebook helpers \n",
3333
"# │ Copy basic/b1 example to local directory │\n",
3434
"# └────────────────────────────────────────────────────────────────────────┘\n",
3535
"\n",
36-
"import subprocess, warnings, sys, vtk\n",
37-
"import pyvista as pv\n",
38-
"vtk.vtkObject.GlobalWarningDisplayOff() # suppress warnings\n",
39-
"\n",
40-
"from pygemc.api.run_geometry import run_geometry\n",
36+
"import subprocess\n",
37+
"import sys\n",
4138
"from pathlib import Path\n",
39+
"from IPython.display import Image, display\n",
40+
"\n",
4241
"sys.path.insert(0, str(Path.cwd().parent))\n",
4342
"from notebook_tools import edit, setup_example\n",
43+
"\n",
44+
"from pygemc.api.run_geometry import run_geometry\n",
4445
"setup_example(\"examples/basic/b1\")\n"
4546
],
4647
"id": "70c84bea9eb56292"
@@ -76,9 +77,6 @@
7677
"# │ - Display generated screenshot if present │\n",
7778
"# └─────────────────────────────────────────────────────────┘\n",
7879
"\n",
79-
"from pathlib import Path\n",
80-
"from IPython.display import Image, display\n",
81-
"\n",
8280
"yaml='b1.yaml'\n",
8381
"driver='-g4view=[{driver: TOOLSSG_OFFSCREEN}]'\n",
8482
"camera='-g4camera=[{phi: -10*deg, theta: 250*deg}]'\n",
@@ -98,15 +96,7 @@
9896
" display(Image(filename=str(image_file)))\n",
9997
"else:\n",
10098
" print(f\"No GEMC image found: {image_file}\")\n",
101-
" \n",
102-
" \n",
103-
"result = subprocess.run(\n",
104-
"\t[\"ls\", \"-l\"],\n",
105-
"\tcapture_output=True,\n",
106-
"\ttext=True,\n",
107-
")\n",
108-
"\n",
109-
"print(result.stdout)\n"
99+
"\n"
110100
],
111101
"id": "289ce146d178545c"
112102
},
@@ -123,7 +113,8 @@
123113
"# │ histogram. │\n",
124114
"# └───────────────────────────────────────────────────────────────────────┘\n",
125115
"\n",
126-
"from pygemc import read_output, plot_variable; plot_variable(read_output(\"CO2_t0_digitized.csv\"), \"dose\", data=\"digitized\", bins=50, logy=False, show=True)\n"
116+
"from pygemc import read_output, plot_variable\n",
117+
"plot_variable(read_output(\"CO2_t0_digitized.csv\"), \"dose\", data=\"digitized\", bins=50, logy=False, show=True)\n"
127118
],
128119
"id": "b1-plot-totEdep-code"
129120
},
@@ -140,7 +131,8 @@
140131
"# │ histogram. │\n",
141132
"# └───────────────────────────────────────────────────────────────────────┘\n",
142133
"\n",
143-
"from pygemc import read_output, plot_variable; plot_variable(read_output(\"CO2_t0_digitized.csv\"), \"etot\", data=\"digitized\", bins=50, logy=True, show=True)\n"
134+
"from pygemc import read_output, plot_variable\n",
135+
"plot_variable(read_output(\"CO2_t0_digitized.csv\"), \"etot\", data=\"digitized\", bins=50, logy=True, show=True)\n"
144136
],
145137
"id": "b1-plot-pid-code"
146138
},

notebooks/basic/b2.ipynb

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,19 @@
3030
"# │ output. │\n",
3131
"# │ │\n",
3232
"# │ │\n",
33-
"# │ import PyVista and editor\n",
33+
"# │ Import notebook helpers \n",
3434
"# │ Copy basic/b2 example to local directory │\n",
3535
"# └────────────────────────────────────────────────────────────────────────┘\n",
3636
"\n",
37-
"import subprocess, warnings, sys, vtk\n",
38-
"import pyvista as pv\n",
39-
"vtk.vtkObject.GlobalWarningDisplayOff() # suppress warnings\n",
40-
"\n",
41-
"from pygemc.api.run_geometry import run_geometry\n",
37+
"import subprocess\n",
38+
"import sys\n",
4239
"from pathlib import Path\n",
40+
"from IPython.display import Image, display\n",
41+
"\n",
4342
"sys.path.insert(0, str(Path.cwd().parent))\n",
4443
"from notebook_tools import edit, setup_example\n",
44+
"\n",
45+
"from pygemc.api.run_geometry import run_geometry\n",
4546
"setup_example(\"examples/basic/b2\")\n"
4647
],
4748
"id": "eefd95102f38a3f2"
@@ -77,14 +78,11 @@
7778
"# │ - Display generated screenshot if present │\n",
7879
"# └─────────────────────────────────────────────────────────┘\n",
7980
"\n",
80-
"from pathlib import Path\n",
81-
"from IPython.display import Image, display\n",
82-
"\n",
8381
"yaml='b2.yaml'\n",
8482
"driver='-g4view=[{driver: TOOLSSG_OFFSCREEN}]'\n",
8583
"camera='-g4camera=[{phi: -10*deg, theta: 250*deg}]'\n",
8684
"light='-g4light=[{phi: 160*deg, theta: 120*deg}]'\n",
87-
"nevents=\"-n=1000\"\n",
85+
"nevents=\"-n=50\"\n",
8886
"nthreads=\"-nthreads=1\"\n",
8987
"\n",
9088
"result = subprocess.run([\"gemc\", yaml, driver, camera, light, nevents, nthreads], capture_output=True, text=True)\n",
@@ -99,15 +97,7 @@
9997
" display(Image(filename=str(image_file)))\n",
10098
"else:\n",
10199
" print(f\"No GEMC image found: {image_file}\")\n",
102-
" \n",
103-
" \n",
104-
"result = subprocess.run(\n",
105-
"\t[\"ls\", \"-l\"],\n",
106-
"\tcapture_output=True,\n",
107-
"\ttext=True,\n",
108-
")\n",
109-
"\n",
110-
"print(result.stdout)\n"
100+
"\n"
111101
],
112102
"id": "d4569ba806553c65"
113103
},
@@ -124,7 +114,8 @@
124114
"# │ histogram. │\n",
125115
"# └───────────────────────────────────────────────────────────────────────┘\n",
126116
"\n",
127-
"from pygemc import read_output, plot_variable; plot_variable(read_output(\"CO2_t0_digitized.csv\"), \"totEdep\", data=\"digitized\", bins=50, logy=False, show=True)\n"
117+
"from pygemc import read_output, plot_variable\n",
118+
"plot_variable(read_output(\"CO2_t0_digitized.csv\"), \"totEdep\", data=\"digitized\", bins=50, logy=True, show=True)\n"
128119
],
129120
"id": "b2-plot-totEdep-code"
130121
},
@@ -141,7 +132,8 @@
141132
"# │ histogram. │\n",
142133
"# └───────────────────────────────────────────────────────────────────────┘\n",
143134
"\n",
144-
"from pygemc import read_output, plot_variable; plot_variable(read_output(\"CO2_t0_true_info.csv\"), \"vz\", data=\"true_info\", bins=50, logy=False, show=True)\n"
135+
"from pygemc import read_output, plot_variable\n",
136+
"plot_variable(read_output(\"CO2_t0_true_info.csv\"), \"vz\", data=\"true_info\", bins=50, logy=False, show=True)\n"
145137
],
146138
"id": "b2-plot-pid-code"
147139
},

notebooks/basic/materials.ipynb

Lines changed: 8 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,19 @@
2525
"# │ molecular and fractional-mass materials, and optical material │\n",
2626
"# │ properties. │\n",
2727
"# │ │\n",
28-
"# │ import PyVista and editor\n",
28+
"# │ Import notebook helpers \n",
2929
"# │ Copy basic/material example to local directory │\n",
3030
"# └────────────────────────────────────────────────────────────────────────┘\n",
3131
"\n",
32-
"import subprocess, warnings, sys, vtk\n",
33-
"import pyvista as pv\n",
34-
"vtk.vtkObject.GlobalWarningDisplayOff() # suppress warnings\n",
35-
"\n",
36-
"from pygemc.api.run_geometry import run_geometry\n",
32+
"import subprocess\n",
33+
"import sys\n",
3734
"from pathlib import Path\n",
35+
"from IPython.display import Image, display\n",
36+
"\n",
3837
"sys.path.insert(0, str(Path.cwd().parent))\n",
3938
"from notebook_tools import edit, setup_example\n",
39+
"\n",
40+
"from pygemc.api.run_geometry import run_geometry\n",
4041
"setup_example(\"examples/basic/material\")\n"
4142
],
4243
"id": "29a4af82943c7d2"
@@ -72,9 +73,6 @@
7273
"# │ - Display generated screenshot if present │\n",
7374
"# └────────────────────────────────────────────────────────┘\n",
7475
"\n",
75-
"from pathlib import Path\n",
76-
"from IPython.display import Image, display\n",
77-
"\n",
7876
"yaml='materials.yaml'\n",
7977
"driver='-g4view=[{driver: TOOLSSG_OFFSCREEN}]'\n",
8078
"camera='-g4camera=[{phi: -10*deg, theta: 250*deg}]'\n",
@@ -94,52 +92,10 @@
9492
" display(Image(filename=str(image_file)))\n",
9593
"else:\n",
9694
" print(f\"No GEMC image found: {image_file}\")\n",
97-
" \n",
98-
" \n",
99-
"result = subprocess.run(\n",
100-
"\t[\"ls\", \"-l\"],\n",
101-
"\tcapture_output=True,\n",
102-
"\ttext=True,\n",
103-
")\n",
104-
"\n",
105-
"print(result.stdout)\n"
95+
"\n"
10696
],
10797
"id": "2bd23d4e8b022c78"
10898
},
109-
{
110-
"cell_type": "code",
111-
"execution_count": null,
112-
"metadata": {},
113-
"outputs": [],
114-
"id": "materials-plot-totEdep-code",
115-
"source": [
116-
"# ┌───────────────────────────────────────────────────────────────────┐\n",
117-
"# │ Cell 6 · Plot totEdep (Shift+Enter to run) │\n",
118-
"# │ │\n",
119-
"# │ Use the analyzer API on the digitized CSV file with a log-scale │\n",
120-
"# │ 50-bin histogram. │\n",
121-
"# └───────────────────────────────────────────────────────────────────┘\n",
122-
"\n",
123-
"from pygemc import read_output, plot_variable; plot_variable(read_output(\"material_t0_digitized.csv\"), \"totEdep\", data=\"digitized\", bins=50, logy=True, show=True)\n"
124-
]
125-
},
126-
{
127-
"cell_type": "code",
128-
"execution_count": null,
129-
"metadata": {},
130-
"outputs": [],
131-
"id": "materials-plot-energy-code",
132-
"source": [
133-
"# ┌───────────────────────────────────────────────────────────────────┐\n",
134-
"# │ Cell 7 · Plot E (Shift+Enter to run) │\n",
135-
"# │ │\n",
136-
"# │ Use the analyzer API on the digitized CSV file with a log-scale │\n",
137-
"# │ 50-bin histogram. │\n",
138-
"# └───────────────────────────────────────────────────────────────────┘\n",
139-
"\n",
140-
"from pygemc import read_output, plot_variable; plot_variable(read_output(\"material_t0_digitized.csv\"), \"E\", data=\"digitized\", bins=50, logy=True, show=True)\n"
141-
]
142-
},
14399
{
144100
"cell_type": "code",
145101
"execution_count": null,

0 commit comments

Comments
 (0)