Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
933 changes: 933 additions & 0 deletions docs/_static/thumbnails/beer_mcstas_dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
933 changes: 933 additions & 0 deletions docs/_static/thumbnails/beer_mcstas_light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 6 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@

## Quick links

::::{grid} 3
::::{grid} 2

:::{grid-item-card} BEER
:link: user-guide/beer/index.md

:::

:::{grid-item-card} DREAM
:link: user-guide/dream/index.md
Expand Down
21 changes: 20 additions & 1 deletion docs/user-guide/beer/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,28 @@

## Reduction Workflows

::::{grid} 3

:::{grid-item-card} Chopper multiplexing McStas simulation
:link: beer_modulation_mcstas.ipynb
:text-align: center

```{image} ../../_static/thumbnails/beer_mcstas_light.svg
:class: only-light
:width: 75%
```
```{image} ../../_static/thumbnails/beer_mcstas_dark.svg
:class: only-dark
:width: 75%
```
:::

::::

```{toctree}
---
maxdepth: 1
hidden:
---

beer_modulation_mcstas
```
196 changes: 196 additions & 0 deletions tools/docs/beer-thumbnails.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "0",
"metadata": {},
"source": [
"# BEER thumbnails\n",
"\n",
"This notebook generates the thumbnails used in the BEER user guide."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1",
"metadata": {},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
"\n",
"import scipp as sc\n",
"\n",
"from ess.beer import BeerModMcStasWorkflow\n",
"from ess.beer.data import mcstas_duplex\n",
"from ess.reduce.nexus.types import Filename, SampleRun\n",
"from ess.beer.types import *\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2",
"metadata": {},
"outputs": [],
"source": [
"wf = BeerModMcStasWorkflow()\n",
"wf[Filename[SampleRun]] = mcstas_duplex(9)\n",
"histogram = wf.compute(DetectorData[SampleRun])['bank1'].hist(two_theta=1000, event_time_offset=1000)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3",
"metadata": {},
"outputs": [],
"source": [
"def basic_powder_plot(style: str):\n",
" with plt.style.context(style):\n",
" fig, ax = plt.subplots(layout='constrained', figsize=(3, 2.5))\n",
" _ = histogram.plot(ax=ax, norm='log')\n",
" ax.set_xlim((0.045,0.12))\n",
" ax.set_xlabel(r'$t$ [µs]')\n",
" ax.set_ylabel(r'$I(t)$')\n",
" return fig"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4",
"metadata": {},
"outputs": [],
"source": [
"fig = basic_powder_plot('default')\n",
"fig.savefig(\n",
" \"../../docs/_static/thumbnails/beer_mcstas_light.svg\",\n",
" transparent=True,\n",
")\n",
"fig"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5",
"metadata": {},
"outputs": [],
"source": [
"fig = basic_powder_plot('dark_background')\n",
"fig.savefig(\n",
" \"../../docs/_static/thumbnails/beer_mcstas_dark.svg\",\n",
" transparent=True,\n",
")\n",
"fig"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6",
"metadata": {},
"outputs": [],
"source": [
"detector_names = [\"mantle\", \"endcap_forward\", \"endcap_backward\", \"high_resolution\"]\n",
"two_theta_bins = [\n",
" sc.linspace(dim=\"two_theta\", unit=\"rad\", start=0.77, stop=2.36, num=70),\n",
" sc.linspace(dim=\"two_theta\", unit=\"rad\", start=0.24, stop=0.71, num=30),\n",
" sc.linspace(dim=\"two_theta\", unit=\"rad\", start=2.42, stop=2.91, num=50),\n",
" sc.linspace(dim=\"two_theta\", unit=\"rad\", start=2.91, stop=3.11, num=10),\n",
"]\n",
"parameter_table = pd.DataFrame(\n",
" {NeXusDetectorName: detector_names,\n",
" TwoThetaBins: two_theta_bins,\n",
" },\n",
" index=detector_names\n",
").rename_axis(index='detector')\n",
"\n",
"all_detector_workflow = workflow.copy()\n",
"mapped = all_detector_workflow[IofDspacingTwoTheta].map(parameter_table)\n",
"all_detector_workflow[IofDspacingTwoTheta] = mapped.reduce(func=powder.grouping.collect_detectors)\n",
"\n",
"result = all_detector_workflow.compute(IofDspacingTwoTheta)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7",
"metadata": {},
"outputs": [],
"source": [
"histogram = result.bin(dspacing=80).hist()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8",
"metadata": {},
"outputs": [],
"source": [
"def advanced_powder_plot(style: str):\n",
" with plt.style.context(style):\n",
" fig, ax = plt.subplots(layout='constrained', figsize=(3, 2.5))\n",
" pf = pp.imagefigure(*(pp.Node(da) for da in histogram.values()), norm='log', cbar=True, ax=ax)\n",
" pf.view.colormapper.ylabel = None\n",
" ax.set_xlabel(r'$d$ [Å]')\n",
" ax.set_ylabel(r'$2\\theta$ [rad]')\n",
" return fig"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9",
"metadata": {},
"outputs": [],
"source": [
"fig = advanced_powder_plot('default')\n",
"fig.savefig(\n",
" \"../../docs/_static/thumbnails/dream_advanced_powder_reduction_light.svg\",\n",
" transparent=True,\n",
")\n",
"fig"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "10",
"metadata": {},
"outputs": [],
"source": [
"fig = advanced_powder_plot('dark_background')\n",
"fig.savefig(\n",
" \"../../docs/_static/thumbnails/dream_advanced_powder_reduction_dark.svg\",\n",
" transparent=True,\n",
")\n",
"fig"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.13"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading