Skip to content

Commit

Permalink
update notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
nvaytet committed Nov 21, 2023
1 parent cd8876a commit 794b8e0
Showing 1 changed file with 43 additions and 20 deletions.
63 changes: 43 additions & 20 deletions docs/instruments/dream/dream-instrument-view.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"This notebook is a simple example on how to use the instrument view for the DREAM instrument.\n",
"\n",
"- The DREAM-specific instrument view is capable of slicing the data with a slider widget along a dimension (e.g. `tof`) by using the `dim` argument.\n",
"- There are also checkboxes to hide/show the different modules that make up the DREAM detectors."
"- There are also checkboxes to hide/show the different elements that make up the DREAM detectors."
]
},
{
Expand Down Expand Up @@ -55,55 +55,55 @@
]
},
{
"cell_type": "markdown",
"id": "49595486-ab4e-4662-86f7-d301aedcf974",
"cell_type": "code",
"execution_count": null,
"id": "e8325797-5651-43c1-b601-3db6d4348758",
"metadata": {
"editable": true,
"nbsphinx": "hidden",
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [],
"source": [
"## Instrument view\n",
"\n",
"We first histogram the data along the time-of-flight (`tof`) dimension,\n",
"making sure the same bins are used for all modules:"
"# Only plot half of the pixels to reduce html docs size\n",
"dg = dg['counter', 0]"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e85a8364-e0a1-4c10-8cae-c873f297e651",
"cell_type": "markdown",
"id": "49595486-ab4e-4662-86f7-d301aedcf974",
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [],
"source": [
"tof_edges = sc.linspace('tof', 1.0e7, 1.0e8, 51, unit='ns', dtype=int)\n",
"data = dg.hist(tof=tof_edges)"
"## Full instrument view\n",
"\n",
"We first histogram the data along the time-of-flight (`tof`) dimension,\n",
"making sure the same bins are used for all elements:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d78c9f16-16e6-4eee-bcf5-2cd26b5fa404",
"id": "e85a8364-e0a1-4c10-8cae-c873f297e651",
"metadata": {
"editable": true,
"nbsphinx": "hidden",
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [],
"source": [
"# Only plot half of the pixels to reduce html docs size\n",
"data = data['counter', 0]"
"tof_edges = sc.linspace('tof', 1.0e7, 1.0e8, 51, unit='ns', dtype=int)\n",
"data = dg.hist(tof=tof_edges)"
]
},
{
Expand Down Expand Up @@ -168,7 +168,9 @@
"source": [
"Note that it is possible to use any dimension for the slider instead of `tof`, such as `wavelength` (if present in the data).\n",
"\n",
"It is also possible to view a single detector module using"
"## Displaying individual detector elements\n",
"\n",
"It is also possible to view a single detector element, selecting e.g. `mantle` from the original data:"
]
},
{
Expand All @@ -184,7 +186,7 @@
},
"outputs": [],
"source": [
"mantle_view = dream.instrument_view(data['mantle'], dim='tof')\n",
"mantle_view = dream.instrument_view(dg['mantle'].hist(wavelength=50), dim='wavelength')\n",
"mantle_view"
]
},
Expand All @@ -202,7 +204,28 @@
},
"outputs": [],
"source": [
"mantle_view[1].controls['tof']['slider'].value = 35"
"mantle_view[1].controls['wavelength']['slider'].value = 43"
]
},
{
"cell_type": "markdown",
"id": "1df1aa56-5251-4555-a4f4-283145747198",
"metadata": {},
"source": [
"The instrument view is designed to be flexible in terms of what it accepts as input.\n",
"This means that you can easily inspect, for example, a single module by using the usual slicing notation for data arrays.\n",
"\n",
"Below, we display the first module in the backward end-cap detector:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0c86e491-3564-498d-9232-39485f5b95d7",
"metadata": {},
"outputs": [],
"source": [
"dream.instrument_view(dg['endcap_backward']['module', 0].hist(tof=1))"
]
}
],
Expand Down

0 comments on commit 794b8e0

Please sign in to comment.