diff --git a/docs/_static/thumbnails/beer_mcstas_dark.svg b/docs/_static/thumbnails/beer_mcstas_dark.svg new file mode 100644 index 00000000..917e20f3 --- /dev/null +++ b/docs/_static/thumbnails/beer_mcstas_dark.svg @@ -0,0 +1,933 @@ + + + + + + + + 2025-09-19T17:43:36.175574 + image/svg+xml + + + Matplotlib v3.10.6, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/_static/thumbnails/beer_mcstas_light.svg b/docs/_static/thumbnails/beer_mcstas_light.svg new file mode 100644 index 00000000..af0026d1 --- /dev/null +++ b/docs/_static/thumbnails/beer_mcstas_light.svg @@ -0,0 +1,933 @@ + + + + + + + + 2025-09-19T17:43:35.627225 + image/svg+xml + + + Matplotlib v3.10.6, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/index.md b/docs/index.md index 7e41e665..a9893356 100644 --- a/docs/index.md +++ b/docs/index.md @@ -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 diff --git a/docs/user-guide/beer/index.md b/docs/user-guide/beer/index.md index 98c14b2d..dd6242b3 100644 --- a/docs/user-guide/beer/index.md +++ b/docs/user-guide/beer/index.md @@ -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 ``` diff --git a/tools/docs/beer-thumbnails.ipynb b/tools/docs/beer-thumbnails.ipynb new file mode 100644 index 00000000..cb9000e2 --- /dev/null +++ b/tools/docs/beer-thumbnails.ipynb @@ -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 +}