Skip to content

Commit

Permalink
Merge pull request #67 from scipp/require-chopper-name
Browse files Browse the repository at this point in the history
Require name for Chopper constructor
  • Loading branch information
nvaytet authored Nov 27, 2024
2 parents f574d3b + 7415c98 commit 3c9f8b2
Show file tree
Hide file tree
Showing 12 changed files with 215 additions and 191 deletions.
18 changes: 9 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.6.0
hooks:
- id: check-added-large-files
- id: check-json
Expand All @@ -14,41 +14,41 @@ repos:
args: [ --markdown-linebreak-ext=md ]
exclude: '\.svg'
- repo: https://github.com/pycqa/isort
rev: 5.12.0
rev: 5.13.0
hooks:
- id: isort
name: isort (python)
- repo: https://github.com/psf/black
rev: 23.1.0
rev: 24.10.0
hooks:
- id: black
- repo: https://github.com/kynan/nbstripout
rev: 0.6.0
rev: 0.8.1
hooks:
- id: nbstripout
types: [ "jupyter" ]
args: [ "--drop-empty-cells",
"--extra-keys 'metadata.language_info.version cell.metadata.jp-MarkdownHeadingCollapsed cell.metadata.pycharm'" ]
- repo: https://github.com/pycqa/flake8
rev: 4.0.1
rev: 7.1.1
hooks:
- id: flake8
types: ["python"]
additional_dependencies: ["flake8-bugbear==22.10.27"]
additional_dependencies: ["flake8-bugbear==24.10.31"]
- repo: https://github.com/pycqa/bandit
rev: 1.7.4
rev: 1.8.0
hooks:
- id: bandit
additional_dependencies: ["bandit[toml]"]
args: ["-c", "pyproject.toml"]
- repo: https://github.com/codespell-project/codespell
rev: v2.2.2
rev: v2.3.0
hooks:
- id: codespell
additional_dependencies:
- tomli
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
rev: v1.10.0
hooks:
- id: python-no-eval
exclude: "object_list.py"
Expand Down
68 changes: 34 additions & 34 deletions docs/components.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "32ad7110-b627-4e52-b014-a70ad3d5193a",
"id": "0",
"metadata": {},
"source": [
"# Component guide\n",
Expand All @@ -14,7 +14,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "1d69bb0a-4b4d-47c6-9465-318c21e72e7c",
"id": "1",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -29,7 +29,7 @@
},
{
"cell_type": "markdown",
"id": "0543c13d-847d-4642-8736-14a75ed5fd01",
"id": "2",
"metadata": {},
"source": [
"We begin by making a source pulse using the profile from ESS."
Expand All @@ -38,7 +38,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "35b39244-c45b-4bdb-8138-7d0e56a40478",
"id": "3",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -48,7 +48,7 @@
},
{
"cell_type": "markdown",
"id": "3c6ecb82-a47f-4f66-a067-9224e9d67be9",
"id": "4",
"metadata": {},
"source": [
"## Adding a detector\n",
Expand All @@ -60,11 +60,11 @@
{
"cell_type": "code",
"execution_count": null,
"id": "e2ced2be-d642-4886-9281-37cd90102c31",
"id": "5",
"metadata": {},
"outputs": [],
"source": [
"detector = tof.Detector(distance=30.0 * meter)\n",
"detector = tof.Detector(distance=30.0 * meter, name='detector')\n",
"\n",
"# Build the instrument model\n",
"model = tof.Model(source=source, detectors=[detector])\n",
Expand All @@ -74,7 +74,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "75dd1359-d990-482c-b0d6-4a0ae094b0fc",
"id": "6",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -85,7 +85,7 @@
},
{
"cell_type": "markdown",
"id": "a2c80ee1-5729-4a09-88c0-3c4e04610772",
"id": "7",
"metadata": {},
"source": [
"As expected, the detector sees all the neutrons from the pulse.\n",
Expand All @@ -96,7 +96,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "112124d4-689b-408a-9be6-de1bef8a6205",
"id": "8",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -105,7 +105,7 @@
},
{
"cell_type": "markdown",
"id": "34267819-4f83-48c6-b51b-9f13742ac3da",
"id": "9",
"metadata": {},
"source": [
"The data itself is available via the `.toas`, `.wavelengths`, `.birth_times`, and `.speeds` properties,\n",
Expand All @@ -119,7 +119,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "bbda2581-ebfa-44ce-ae58-1f4f2db832d9",
"id": "10",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -128,7 +128,7 @@
},
{
"cell_type": "markdown",
"id": "89ad197a-4304-4cff-a332-e865a2c93f43",
"id": "11",
"metadata": {},
"source": [
"## Adding a chopper\n",
Expand All @@ -141,7 +141,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "e7e49cac-affd-4c01-860f-03934bc348e9",
"id": "12",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -166,7 +166,7 @@
},
{
"cell_type": "markdown",
"id": "6893e0a2-70c9-424f-aeb2-aac010fc02bd",
"id": "13",
"metadata": {},
"source": [
"We can directly set this on our existing model, and re-run the simulation."
Expand All @@ -175,7 +175,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "48909c2a-51e8-4532-a8eb-7c7bbba7544d",
"id": "14",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -186,7 +186,7 @@
},
{
"cell_type": "markdown",
"id": "3155b564-12e1-4d06-a2dd-d376314713f4",
"id": "15",
"metadata": {},
"source": [
"As expected, the two openings now create two bursts of neutrons,\n",
Expand All @@ -198,7 +198,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "94bc5f13-4e58-4ae4-ba15-86078ab8311d",
"id": "16",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -207,7 +207,7 @@
},
{
"cell_type": "markdown",
"id": "7ce2e25e-e21f-442b-b729-9b1c7a97893b",
"id": "17",
"metadata": {},
"source": [
"we notice that the chopper sees all the incoming neutrons,\n",
Expand All @@ -219,7 +219,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "90341882-625a-432d-8625-3d0850403f85",
"id": "18",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -228,7 +228,7 @@
},
{
"cell_type": "markdown",
"id": "68e35c62-6072-47b1-8c3e-e610826da008",
"id": "19",
"metadata": {},
"source": [
"## Multiple choppers\n",
Expand All @@ -241,7 +241,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "ac5f9697-a2a6-45a8-ad99-af6ad1a60be7",
"id": "20",
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -269,7 +269,7 @@
},
{
"cell_type": "markdown",
"id": "62d721c5-3c3e-457c-ab05-60659fccdaaa",
"id": "21",
"metadata": {},
"source": [
"The distribution of neutrons that are blocked and pass through the second chopper looks as follows:"
Expand All @@ -278,7 +278,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "ab11bd09-73ba-4bf8-9b52-e503d77f3f5c",
"id": "22",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -287,7 +287,7 @@
},
{
"cell_type": "markdown",
"id": "09d6cbef-f2f3-48db-a696-b4ed912817c8",
"id": "23",
"metadata": {},
"source": [
"while the detector now sees 4 peaks"
Expand All @@ -296,7 +296,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "20349f5e-bfd3-4ccb-bde4-119f3e3d423a",
"id": "24",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -305,7 +305,7 @@
},
{
"cell_type": "markdown",
"id": "55c8ca14-e885-43b2-8409-48c1eb964625",
"id": "25",
"metadata": {},
"source": [
"To view the blocked rays on the time-distance diagram of the model, use"
Expand All @@ -314,7 +314,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "a3e040c6-afee-495f-a32f-7fdcad506df1",
"id": "26",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -323,7 +323,7 @@
},
{
"cell_type": "markdown",
"id": "b3c4a5fb-010b-4d6a-a391-4fb48aa4b1d2",
"id": "27",
"metadata": {},
"source": [
"## Adding a monitor\n",
Expand All @@ -335,7 +335,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "1c8bdc32-583a-4c7c-8c6d-34dab8061c6f",
"id": "28",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -349,7 +349,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "2f008516-af80-4c55-a6bb-a71a86fa9132",
"id": "29",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -358,7 +358,7 @@
},
{
"cell_type": "markdown",
"id": "021f81eb-42c3-4094-981e-ada20eca3fdb",
"id": "30",
"metadata": {},
"source": [
"## Counter-rotating chopper\n",
Expand All @@ -373,7 +373,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "0e978761-f2de-423e-9e43-a9e664a85a48",
"id": "31",
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -402,7 +402,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "354e87fd-05e4-4237-84d7-3599610e3403",
"id": "32",
"metadata": {},
"outputs": [],
"source": [
Expand Down
Loading

0 comments on commit 3c9f8b2

Please sign in to comment.