Skip to content

Commit

Permalink
update wfm and dream notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
nvaytet committed Jan 20, 2025
1 parent dde1b78 commit 8e5074c
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 45 deletions.
70 changes: 40 additions & 30 deletions docs/user-guide/tof/dream.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,20 @@
"workflow.visualize(time_of_flight.TofData)"
]
},
{
"cell_type": "markdown",
"id": "19",
"metadata": {},
"source": [
"We can see from the workflow diagram that we are still missing the simulated neutrons that are used to build the lookup table.\n",
"\n",
"Those are obtained by running a quick `tof` simulation of the beamline:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "19",
"id": "20",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -311,7 +321,7 @@
},
{
"cell_type": "markdown",
"id": "20",
"id": "21",
"metadata": {},
"source": [
"### Inspecting the lookup table\n",
Expand All @@ -328,7 +338,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "21",
"id": "22",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -349,7 +359,7 @@
},
{
"cell_type": "markdown",
"id": "22",
"id": "23",
"metadata": {},
"source": [
"The lookup table is then obtained by computing the weighted mean of the time-of-flight inside each time-of-arrival bin.\n",
Expand All @@ -360,7 +370,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "23",
"id": "24",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -373,7 +383,7 @@
{
"attachments": {},
"cell_type": "markdown",
"id": "24",
"id": "25",
"metadata": {},
"source": [
"### Computing a time-of-flight coordinate\n",
Expand All @@ -384,7 +394,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "25",
"id": "26",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -394,7 +404,7 @@
},
{
"cell_type": "markdown",
"id": "26",
"id": "27",
"metadata": {},
"source": [
"Histogramming the data for a plot should show a profile with 6 bumps that correspond to the frames:"
Expand All @@ -403,7 +413,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "27",
"id": "28",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -412,7 +422,7 @@
},
{
"cell_type": "markdown",
"id": "28",
"id": "29",
"metadata": {},
"source": [
"### Converting to wavelength\n",
Expand All @@ -423,7 +433,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "29",
"id": "30",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -442,7 +452,7 @@
},
{
"cell_type": "markdown",
"id": "30",
"id": "31",
"metadata": {},
"source": [
"### Comparing to the ground truth\n",
Expand All @@ -454,7 +464,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "31",
"id": "32",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -471,7 +481,7 @@
},
{
"cell_type": "markdown",
"id": "32",
"id": "33",
"metadata": {},
"source": [
"## Multiple detector pixels\n",
Expand All @@ -487,7 +497,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "33",
"id": "34",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -504,7 +514,7 @@
},
{
"cell_type": "markdown",
"id": "34",
"id": "35",
"metadata": {},
"source": [
"Our raw data has now a `detector_number` dimension of length 2.\n",
Expand All @@ -515,7 +525,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "35",
"id": "36",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -534,7 +544,7 @@
},
{
"cell_type": "markdown",
"id": "36",
"id": "37",
"metadata": {},
"source": [
"Computing time-of-flight is done in the same way as above.\n",
Expand All @@ -544,7 +554,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "37",
"id": "38",
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -577,7 +587,7 @@
},
{
"cell_type": "markdown",
"id": "38",
"id": "39",
"metadata": {},
"source": [
"## Handling time overlap between subframes\n",
Expand All @@ -597,7 +607,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "39",
"id": "40",
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -627,7 +637,7 @@
},
{
"cell_type": "markdown",
"id": "40",
"id": "41",
"metadata": {},
"source": [
"We can now see that there is no longer a gap between the two frames at the center of each pulse (green region).\n",
Expand All @@ -639,14 +649,14 @@
{
"cell_type": "code",
"execution_count": null,
"id": "41",
"id": "42",
"metadata": {},
"outputs": [],
"source": [
"# Update workflow\n",
"workflow[time_of_flight.SimulationResults] = time_of_flight.simulate_beamline(\n",
" choppers=disk_choppers,\n",
" neutrons=2_000_000\n",
" number_of_neutrons=2_000_000\n",
")\n",
"workflow[time_of_flight.RawData] = ess_beamline.get_monitor(\"detector\")[0]\n",
"\n",
Expand All @@ -665,7 +675,7 @@
},
{
"cell_type": "markdown",
"id": "42",
"id": "43",
"metadata": {},
"source": [
"The data in the lookup table contains both the mean time-of-flight for each distance and time-of-arrival bin,\n",
Expand All @@ -682,7 +692,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "43",
"id": "44",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -692,7 +702,7 @@
},
{
"cell_type": "markdown",
"id": "44",
"id": "45",
"metadata": {},
"source": [
"The workflow has a parameter which is used to mask out regions where the standard deviation is above a certain threshold.\n",
Expand All @@ -706,7 +716,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "45",
"id": "46",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -717,7 +727,7 @@
},
{
"cell_type": "markdown",
"id": "46",
"id": "47",
"metadata": {},
"source": [
"We can now see that the central region is masked out.\n",
Expand All @@ -732,7 +742,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "47",
"id": "48",
"metadata": {},
"outputs": [],
"source": [
Expand Down
Loading

0 comments on commit 8e5074c

Please sign in to comment.