diff --git a/docs/user-guide/dream/index.md b/docs/user-guide/dream/index.md index 5a5281f..4411af0 100644 --- a/docs/user-guide/dream/index.md +++ b/docs/user-guide/dream/index.md @@ -5,6 +5,7 @@ maxdepth: 1 --- +workflows/index dream-data-reduction dream-instrument-view workflow-widget-dream diff --git a/docs/user-guide/dream/workflows/dream-proton-charge-norm.ipynb b/docs/user-guide/dream/workflows/dream-proton-charge-norm.ipynb new file mode 100644 index 0000000..0af60e3 --- /dev/null +++ b/docs/user-guide/dream/workflows/dream-proton-charge-norm.ipynb @@ -0,0 +1,189 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "0", + "metadata": {}, + "source": [ + "# DREAM data reduction - Normalized by proton charge" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1", + "metadata": {}, + "outputs": [], + "source": [ + "import scipp as sc\n", + "\n", + "from ess import dream, powder\n", + "import ess.dream.data # noqa: F401\n", + "from ess.powder.types import *" + ] + }, + { + "cell_type": "markdown", + "id": "2", + "metadata": {}, + "source": [ + "## Create and configure the workflow" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "3", + "metadata": {}, + "outputs": [], + "source": [ + "workflow = dream.DreamGeant4Workflow(run_norm=powder.RunNormalization.proton_charge)" + ] + }, + { + "cell_type": "markdown", + "id": "4", + "metadata": {}, + "source": [ + "### Files" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5", + "metadata": {}, + "outputs": [], + "source": [ + "workflow[Filename[SampleRun]] = dream.data.simulated_diamond_sample()\n", + "workflow[Filename[VanadiumRun]] = dream.data.simulated_vanadium_sample()\n", + "workflow[Filename[BackgroundRun]] = dream.data.simulated_empty_can()\n", + "workflow[CalibrationFilename] = None" + ] + }, + { + "cell_type": "markdown", + "id": "6", + "metadata": {}, + "source": [ + "### Masks" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7", + "metadata": {}, + "outputs": [], + "source": [ + "workflow[TofMask] = lambda x: (x < sc.scalar(0.0, unit=\"ns\")) | (\n", + " x > sc.scalar(86e6, unit=\"ns\")\n", + ")\n", + "workflow[TwoThetaMask] = None\n", + "workflow[WavelengthMask] = None\n", + "workflow = powder.with_pixel_mask_filenames(workflow, [])" + ] + }, + { + "cell_type": "markdown", + "id": "8", + "metadata": {}, + "source": [ + "### Other parameters" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "9", + "metadata": {}, + "outputs": [], + "source": [ + "workflow[NeXusDetectorName] = \"mantle\"\n", + "workflow[UncertaintyBroadcastMode] = UncertaintyBroadcastMode.drop\n", + "workflow[DspacingBins] = sc.linspace(\"dspacing\", 0.0, 2.3434, 201, unit=\"angstrom\")" + ] + }, + { + "cell_type": "markdown", + "id": "10", + "metadata": {}, + "source": [ + "## Use the workflow" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "11", + "metadata": {}, + "outputs": [], + "source": [ + "results = workflow.compute([IofTof, ReducedTofCIF])" + ] + }, + { + "cell_type": "markdown", + "id": "12", + "metadata": {}, + "source": [ + "## Plot and save" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "13", + "metadata": {}, + "outputs": [], + "source": [ + "results[IofTof].hist().plot()" + ] + }, + { + "cell_type": "markdown", + "id": "14", + "metadata": {}, + "source": [ + "We can now save the result to disk:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "15", + "metadata": {}, + "outputs": [], + "source": [ + "cif_data = results[ReducedTofCIF]\n", + "\n", + "cif_data.comment = \"\"\"This file was generated with the DREAM data reduction user guide\n", + "in the documentation of ESSdiffraction.\n", + "See https://scipp.github.io/essdiffraction/\n", + "\"\"\"\n", + "cif_data.save('reduced.cif')" + ] + } + ], + "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.12.7" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/docs/user-guide/dream/workflows/index.md b/docs/user-guide/dream/workflows/index.md new file mode 100644 index 0000000..aa0ea0a --- /dev/null +++ b/docs/user-guide/dream/workflows/index.md @@ -0,0 +1,9 @@ +# DREAM reduction workflows + +```{toctree} +--- +maxdepth: 1 +--- + +dream-proton-charge-norm +```