8 Commits

Author SHA1 Message Date
21ea25a3d8 fix typo in README.md 2026-01-28 13:40:30 +01:00
d7c670d344 Update README.md 2026-01-28 13:39:38 +01:00
85f306a469 Merge branch 'dev' of github.com:pim-n/pg-rad into dev 2026-01-28 13:33:12 +01:00
c459b732bb update demo notebook 2026-01-28 13:32:25 +01:00
4632fe35c9 add mathjax javascript code 2026-01-28 13:24:23 +01:00
7cfbbb8792 move demo within docs 2026-01-28 13:22:42 +01:00
7290e241a2 Update ci-docs.yml 2026-01-28 12:34:53 +01:00
38318ad822 Merge pull request #2 from pim-n/main
to dev
2026-01-28 12:33:32 +01:00
7 changed files with 98 additions and 39 deletions

View File

@ -17,7 +17,7 @@ jobs:
git config user.email 41898282+github-actions[bot]@users.noreply.github.com git config user.email 41898282+github-actions[bot]@users.noreply.github.com
- uses: actions/setup-python@v5 - uses: actions/setup-python@v5
with: with:
python-version: 3.x python-version: 3.12.9
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
- uses: actions/cache@v4 - uses: actions/cache@v4
with: with:

View File

@ -23,13 +23,27 @@ With Python verion `>=3.12.4` and `<3.13`, create a virtual environment and inst
``` ```
python3 -m venv .venv python3 -m venv .venv
source .venv/bin/activate source .venv/bin/activate
(venv) pip install -e .[dev] ```
With the virtual environment activated, run:
```
pip install -e .[dev]
``` ```
## Tests ## Tests
Tests can be run with `pytest` from the root directory of the repository. Tests can be run with `pytest` from the root directory of the repository. With the virtual environment activated, run:
``` ```
(venv) pytest pytest
``` ```
## Local viewing of documentation
PG-RAD uses [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/) for generating documentation. It can be locally viewed by (in the venv) running:
```
mkdocs serve
```
where you can add the `--livereload` flag to automatically update the documentation as you write to the Markdown files.

View File

@ -0,0 +1,19 @@
window.MathJax = {
tex: {
inlineMath: [["\\(", "\\)"]],
displayMath: [["\\[", "\\]"]],
processEscapes: true,
processEnvironments: true
},
options: {
ignoreHtmlClass: ".*|",
processHtmlClass: "arithmatex"
}
};
document$.subscribe(() => {
MathJax.startup.output.clearCache()
MathJax.typesetClear()
MathJax.texReset()
MathJax.typesetPromise()
})

View File

@ -5,14 +5,22 @@
"id": "5e30f59a", "id": "5e30f59a",
"metadata": {}, "metadata": {},
"source": [ "source": [
"# Demo of PG-RAD\n", "# Using PG-RAD as a module\n",
"\n", "\n",
"This is a demo." "This discusses the overall design of the code to understand how different parts interact, doing so by an interactive notebook demo. For specific usage of functions and classes, consult the API documentation in the side bar (relevant API documentation sections will also be hyperlinked in the below explanation)."
]
},
{
"cell_type": "markdown",
"id": "f18912e5",
"metadata": {},
"source": [
"## Imports"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": 5,
"id": "415fdd25", "id": "415fdd25",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -22,7 +30,7 @@
"from pg_rad.dataloader import load_data\n", "from pg_rad.dataloader import load_data\n",
"from pg_rad.path import path_from_RT90\n", "from pg_rad.path import path_from_RT90\n",
"from pg_rad.landscape import Landscape\n", "from pg_rad.landscape import Landscape\n",
"from pg_rad.objects import Source\n", "from pg_rad.sources import PointSource\n",
"\n", "\n",
"from pg_rad.isotope import Isotope" "from pg_rad.isotope import Isotope"
] ]
@ -37,7 +45,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 6,
"id": "5a0e470a", "id": "5a0e470a",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -56,7 +64,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 7,
"id": "2ec97553", "id": "2ec97553",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@ -64,7 +72,7 @@
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"2026-01-27 20:48:51,754 - INFO: Piecewise regression reduced path from 105 to 4 segments.\n" "2026-01-28 13:31:03,130 - INFO: Piecewise regression reduced path from 105 to 4 segments.\n"
] ]
}, },
{ {
@ -79,8 +87,8 @@
} }
], ],
"source": [ "source": [
"p1 = path_from_RT90(df, east_col = \"East\", north_col = \"North\", simplify_path = False)\n", "p1 = path_from_RT90(df, east_col = \"East\", north_col = \"North\", path_simplify = False)\n",
"p2 = path_from_RT90(df, east_col = \"East\", north_col = \"North\", simplify_path = True)\n", "p2 = path_from_RT90(df, east_col = \"East\", north_col = \"North\", path_simplify = True)\n",
"\n", "\n",
"p1.plot(color='r', linestyle='-', linewidth = 10, label = \"Full path\")\n", "p1.plot(color='r', linestyle='-', linewidth = 10, label = \"Full path\")\n",
"p2.plot(color='b', linestyle='-', marker = 'o', label = \"Reduced path\")\n", "p2.plot(color='b', linestyle='-', marker = 'o', label = \"Reduced path\")\n",
@ -96,14 +104,20 @@
"id": "da8620fa", "id": "da8620fa",
"metadata": {}, "metadata": {},
"source": [ "source": [
"## Making a landscape\n", "## Landscape\n",
"\n", "\n",
"You can make a landscape with or without a path. Let's make an empty landscape." "The [Landscape](/API/landscape/landscape) is the starting point for the model. It is essentially an empty data structure which represents a cuboid space\n",
"\n",
"$$\n",
"C = [0, x_{\\max}] \\times [0, y_{\\max}] \\times [0, z_{\\max}] \\subset \\mathbb{R}^3\n",
"$$\n",
"\n",
"where $x_{\\max}, y_{\\max}, z_{\\max}$ are defined by the user upon creating the landscape object."
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": 8,
"id": "24f1159d", "id": "24f1159d",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@ -119,47 +133,57 @@
} }
], ],
"source": [ "source": [
"landscape = Landscape()\n", "my_landscape = Landscape(size = (500, 500, 500), scale = 'meters')\n",
"fig, ax = landscape.plot()\n", "fig, ax = my_landscape.plot()\n",
"plt.show()" "plt.show()"
] ]
}, },
{
"cell_type": "markdown",
"id": "a285a2b6",
"metadata": {},
"source": [
"Not much to see here, but we created the backbone of our simulation now."
]
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"id": "035b4f42", "id": "035b4f42",
"metadata": {}, "metadata": {},
"source": [ "source": [
"## Adding a source" "## Point sources\n",
"\n",
"A [PointSource](/API/sources/point_source) can be added to `my_landscape` in the following way:"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": 9,
"id": "91019da5", "id": "91019da5",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"[Source(name=Source 1, pos=(100, 100, 0), isotope=Cs137, A=100 MBq)]" "[PointSource(name=Source 1, pos=(100, 100, 0), isotope=Cs137, A=100 MBq)]"
] ]
}, },
"execution_count": 5, "execution_count": 9,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
], ],
"source": [ "source": [
"cs137 = Isotope(name = \"Cs137\", E = 662.66, b = 0.851)\n", "cs137 = Isotope(name = \"Cs137\", E = 662.66, b = 0.851)\n",
"my_source = Source(x = 100, y = 100, z = 0, activity = 100, isotope = cs137)\n", "my_source = PointSource(x = 100, y = 100, z = 0, activity = 100, isotope = cs137)\n",
"landscape.add_sources(my_source)\n", "my_landscape.add_sources(my_source)\n",
"\n", "\n",
"landscape.sources" "my_landscape.sources"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 6, "execution_count": 10,
"id": "7913fe1e", "id": "7913fe1e",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@ -170,7 +194,7 @@
" <Axes: xlabel='X [meters]', ylabel='Y [meters]'>)" " <Axes: xlabel='X [meters]', ylabel='Y [meters]'>)"
] ]
}, },
"execution_count": 6, "execution_count": 10,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
}, },
@ -186,12 +210,12 @@
} }
], ],
"source": [ "source": [
"landscape.plot()" "my_landscape.plot()"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 7, "execution_count": 11,
"id": "df4715c1", "id": "df4715c1",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@ -202,7 +226,7 @@
" <Axes: xlabel='X [meters]', ylabel='Y [meters]'>)" " <Axes: xlabel='X [meters]', ylabel='Y [meters]'>)"
] ]
}, },
"execution_count": 7, "execution_count": 11,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
}, },
@ -218,8 +242,8 @@
} }
], ],
"source": [ "source": [
"landscape.set_path(p2)\n", "my_landscape.set_path(p2)\n",
"landscape.plot()" "my_landscape.plot()"
] ]
}, },
{ {

View File

@ -1,5 +0,0 @@
---
title: Using PG-RAD as a module
---
Consult the API documentation in the side bar.

View File

@ -28,8 +28,15 @@ markdown_extensions:
- pymdownx.inlinehilite - pymdownx.inlinehilite
- pymdownx.snippets - pymdownx.snippets
- pymdownx.superfences - pymdownx.superfences
- pymdownx.arithmatex:
generic: true
extra_javascript:
- javascripts/mathjax.js
- https://unpkg.com/mathjax@3/es5/tex-mml-chtml.js
plugins: plugins:
- mkdocs-jupyter
- mkdocstrings: - mkdocstrings:
enabled: !ENV [ENABLE_MKDOCSTRINGS, true] enabled: !ENV [ENABLE_MKDOCSTRINGS, true]
default_handler: python default_handler: python

View File

@ -29,4 +29,4 @@ Homepage = "https://github.com/pim-n/pg-rad"
Issues = "https://github.com/pim-n/pg-rad/issues" Issues = "https://github.com/pim-n/pg-rad/issues"
[project.optional-dependencies] [project.optional-dependencies]
dev = ["pytest", "notebook", "mkdocs-material", "mkdocstrings-python"] dev = ["pytest", "notebook", "mkdocs-material", "mkdocstrings-python", "mkdocs-jupyter"]