From 53343f59c20c6843fd8b97b22b42881f062cde0b Mon Sep 17 00:00:00 2001 From: Johannes Kasimir Date: Tue, 10 Dec 2024 13:15:40 +0100 Subject: [PATCH 1/6] add illustration of inhomogeneity from absorption --- .../dream/dream-instrument-view.ipynb | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/docs/user-guide/dream/dream-instrument-view.ipynb b/docs/user-guide/dream/dream-instrument-view.ipynb index 0241d6db..9466d457 100644 --- a/docs/user-guide/dream/dream-instrument-view.ipynb +++ b/docs/user-guide/dream/dream-instrument-view.ipynb @@ -229,6 +229,65 @@ "source": [ "dream.instrument_view(dg[\"endcap_backward\"][\"module\", 0].hist(tof=1))" ] + }, + { + "cell_type": "markdown", + "id": "15", + "metadata": {}, + "source": [ + "## Display inhomogeneity from absorption\n", + "\n", + "If the sample absorbs or scatters a large fraction of the incoming neutrons the intensity in the detector will vary even if the scattering is inhomogeneous.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "16", + "metadata": {}, + "outputs": [], + "source": [ + "import scipp as sc\n", + "\n", + "from scippneutron.absorption import compute_transmission_map\n", + "from scippneutron.absorption.cylinder import Cylinder\n", + "from scippneutron.absorption.material import Material\n", + "from scippneutron.atoms import ScatteringParams\n", + "\n", + "\n", + "material = Material(\n", + " scattering_params=ScatteringParams.for_isotope('V'),\n", + " effective_sample_number_density=sc.scalar(0.07192, unit='1/angstrom**3')\n", + ")\n", + "sample_shape = Cylinder(\n", + " symmetry_line=sc.vector([0, 1, 0]),\n", + " center_of_base=sc.vector([0, -.5, 0], unit='cm'),\n", + " radius=sc.scalar(1, unit='cm'),\n", + " height=sc.scalar(5., unit='cm')\n", + ")\n", + "\n", + "transmission_fraction = compute_transmission_map(\n", + " sample_shape,\n", + " material,\n", + " beam_direction=sc.vector([0, 0, 1]),\n", + " wavelength=sc.linspace('wavelength', 4, 8, 20, unit='angstrom'),\n", + " detector_position=dg['mantle'].coords['position']['strip', ::4]['wire', ::2].copy(),\n", + " quadrature_kind='cheap',\n", + ")\n", + "\n", + "transmission_fraction.coords['position'] = transmission_fraction.coords.pop('detector_position')\n", + "dream.instrument_view(transmission_fraction.transpose((*set(transmission_fraction.dims) - {'wavelength'}, 'wavelength')), dim='wavelength')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "17", + "metadata": {}, + "outputs": [], + "source": [ + "transmission_fraction" + ] } ], "metadata": { From c3c0a6032cf48e0ac97c4fc1d034e27c49eb4dea Mon Sep 17 00:00:00 2001 From: Johannes Kasimir Date: Tue, 17 Dec 2024 10:49:53 +0100 Subject: [PATCH 2/6] fix: move visualization to separate notebook --- .../dream/dream-instrument-view.ipynb | 59 -------- .../dream/dream-visualize-absorption.ipynb | 140 ++++++++++++++++++ 2 files changed, 140 insertions(+), 59 deletions(-) create mode 100644 docs/user-guide/dream/dream-visualize-absorption.ipynb diff --git a/docs/user-guide/dream/dream-instrument-view.ipynb b/docs/user-guide/dream/dream-instrument-view.ipynb index 9466d457..0241d6db 100644 --- a/docs/user-guide/dream/dream-instrument-view.ipynb +++ b/docs/user-guide/dream/dream-instrument-view.ipynb @@ -229,65 +229,6 @@ "source": [ "dream.instrument_view(dg[\"endcap_backward\"][\"module\", 0].hist(tof=1))" ] - }, - { - "cell_type": "markdown", - "id": "15", - "metadata": {}, - "source": [ - "## Display inhomogeneity from absorption\n", - "\n", - "If the sample absorbs or scatters a large fraction of the incoming neutrons the intensity in the detector will vary even if the scattering is inhomogeneous.\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "16", - "metadata": {}, - "outputs": [], - "source": [ - "import scipp as sc\n", - "\n", - "from scippneutron.absorption import compute_transmission_map\n", - "from scippneutron.absorption.cylinder import Cylinder\n", - "from scippneutron.absorption.material import Material\n", - "from scippneutron.atoms import ScatteringParams\n", - "\n", - "\n", - "material = Material(\n", - " scattering_params=ScatteringParams.for_isotope('V'),\n", - " effective_sample_number_density=sc.scalar(0.07192, unit='1/angstrom**3')\n", - ")\n", - "sample_shape = Cylinder(\n", - " symmetry_line=sc.vector([0, 1, 0]),\n", - " center_of_base=sc.vector([0, -.5, 0], unit='cm'),\n", - " radius=sc.scalar(1, unit='cm'),\n", - " height=sc.scalar(5., unit='cm')\n", - ")\n", - "\n", - "transmission_fraction = compute_transmission_map(\n", - " sample_shape,\n", - " material,\n", - " beam_direction=sc.vector([0, 0, 1]),\n", - " wavelength=sc.linspace('wavelength', 4, 8, 20, unit='angstrom'),\n", - " detector_position=dg['mantle'].coords['position']['strip', ::4]['wire', ::2].copy(),\n", - " quadrature_kind='cheap',\n", - ")\n", - "\n", - "transmission_fraction.coords['position'] = transmission_fraction.coords.pop('detector_position')\n", - "dream.instrument_view(transmission_fraction.transpose((*set(transmission_fraction.dims) - {'wavelength'}, 'wavelength')), dim='wavelength')" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "17", - "metadata": {}, - "outputs": [], - "source": [ - "transmission_fraction" - ] } ], "metadata": { diff --git a/docs/user-guide/dream/dream-visualize-absorption.ipynb b/docs/user-guide/dream/dream-visualize-absorption.ipynb new file mode 100644 index 00000000..d93d441d --- /dev/null +++ b/docs/user-guide/dream/dream-visualize-absorption.ipynb @@ -0,0 +1,140 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "0", + "metadata": {}, + "source": [ + "# DREAM instrument view\n", + "\n", + "This notebook is a simple example of 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 elements that make up the DREAM detectors.\n", + "\n", + "We begin with relevant imports.\n", + "We will be using tutorial data downloaded with `pooch`.\n", + "If you get an error about a missing module `pooch`, you can install it with `!pip install pooch`:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1", + "metadata": {}, + "outputs": [], + "source": [ + "import scipp as sc\n", + "from ess import dream\n", + "import ess.dream.data # noqa: F401" + ] + }, + { + "cell_type": "markdown", + "id": "2", + "metadata": {}, + "source": [ + "## Load the data\n", + "\n", + "We load a dataset from a Geant4 simulation (stored as a `.csv` file).\n", + "In each detector bank, the data is organised by `wire`, `strip`, `module`, `segment`, and `counter`.\n", + "The high resolution detector also has an additional `sector` dimension." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "3", + "metadata": {}, + "outputs": [], + "source": [ + "dg = dream.io.load_geant4_csv(dream.data.get_path(\"data_dream0_new_hkl_Si_pwd.csv.zip\"))\n", + "dg = dg[\"instrument\"] # Extract the instrument data\n", + "\n", + "# Extract the events from nested data groups\n", + "dg = sc.DataGroup({key: detector[\"events\"] for key, detector in dg.items()})\n", + "dg" + ] + }, + { + "cell_type": "markdown", + "id": "4", + "metadata": {}, + "source": [ + "## Display inhomogeneity from absorption\n", + "\n", + "If the sample absorbs or scatters a large fraction of the incoming neutrons the intensity in the detector will vary even if the scattering is inhomogeneous.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5", + "metadata": {}, + "outputs": [], + "source": [ + "import scipp as sc\n", + "\n", + "from scippneutron.absorption import compute_transmission_map\n", + "from scippneutron.absorption.cylinder import Cylinder\n", + "from scippneutron.absorption.material import Material\n", + "from scippneutron.atoms import ScatteringParams\n", + "\n", + "\n", + "material = Material(\n", + " scattering_params=ScatteringParams.for_isotope('V'),\n", + " effective_sample_number_density=sc.scalar(0.07192, unit='1/angstrom**3')\n", + ")\n", + "sample_shape = Cylinder(\n", + " symmetry_line=sc.vector([0, 1, 0]),\n", + " center_of_base=sc.vector([0, -2.5, 0], unit='cm'),\n", + " radius=sc.scalar(1, unit='cm'),\n", + " height=sc.scalar(5., unit='cm')\n", + ")\n", + "\n", + "transmission_fraction = compute_transmission_map(\n", + " sample_shape,\n", + " material,\n", + " beam_direction=sc.vector([0, 0, 1]),\n", + " wavelength=sc.linspace('wavelength', 4, 8, 20, unit='angstrom'),\n", + " detector_position=dg['mantle'].coords['position']['strip', ::4]['wire', ::2].copy(),\n", + " quadrature_kind='cheap',\n", + ")\n", + "\n", + "transmission_fraction.coords['position'] = transmission_fraction.coords.pop('detector_position')\n", + "dream.instrument_view(transmission_fraction.transpose((*set(transmission_fraction.dims) - {'wavelength'}, 'wavelength')), dim='wavelength')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6", + "metadata": {}, + "outputs": [], + "source": [ + "transmission_fraction" + ] + } + ], + "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.10.14" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} From 3401b79a0fb593049f184d8914c5127a6a38fb54 Mon Sep 17 00:00:00 2001 From: Johannes Kasimir Date: Mon, 20 Jan 2025 09:38:27 +0100 Subject: [PATCH 3/6] fix: text in notebook --- .../dream/dream-visualize-absorption.ipynb | 97 ++++++++++++------- 1 file changed, 64 insertions(+), 33 deletions(-) diff --git a/docs/user-guide/dream/dream-visualize-absorption.ipynb b/docs/user-guide/dream/dream-visualize-absorption.ipynb index d93d441d..f658f632 100644 --- a/docs/user-guide/dream/dream-visualize-absorption.ipynb +++ b/docs/user-guide/dream/dream-visualize-absorption.ipynb @@ -7,14 +7,11 @@ "source": [ "# DREAM instrument view\n", "\n", - "This notebook is a simple example of how to use the instrument view for the DREAM instrument.\n", + "This notebook is an example of how to use the `compute_transmission_map` function to visualize the effect of (sample) absorption on the intensity in the detector.\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 elements that make up the DREAM detectors.\n", + "Note that the `compute_transmission_map` function only accounts for the effect of absorption. The measured intensity in the detector can also be impacted by other effects, such as the effect of the solid angle being different for different detector pixels.\n", "\n", - "We begin with relevant imports.\n", - "We will be using tutorial data downloaded with `pooch`.\n", - "If you get an error about a missing module `pooch`, you can install it with `!pip install pooch`:" + "For more details, see https://scipp.github.io/scippneutron/user-guide/absorption-correction.html." ] }, { @@ -25,8 +22,16 @@ "outputs": [], "source": [ "import scipp as sc\n", + "\n", + "from plopp.graphics import Camera\n", + "\n", "from ess import dream\n", - "import ess.dream.data # noqa: F401" + "import ess.dream.data # noqa: F401\n", + "\n", + "from scippneutron.absorption import compute_transmission_map\n", + "from scippneutron.absorption.cylinder import Cylinder\n", + "from scippneutron.absorption.material import Material\n", + "from scippneutron.atoms import ScatteringParams" ] }, { @@ -36,9 +41,7 @@ "source": [ "## Load the data\n", "\n", - "We load a dataset from a Geant4 simulation (stored as a `.csv` file).\n", - "In each detector bank, the data is organised by `wire`, `strip`, `module`, `segment`, and `counter`.\n", - "The high resolution detector also has an additional `sector` dimension." + "We load a dataset from a Geant4 simulation only to get access to the detector geometry." ] }, { @@ -48,10 +51,7 @@ "metadata": {}, "outputs": [], "source": [ - "dg = dream.io.load_geant4_csv(dream.data.get_path(\"data_dream0_new_hkl_Si_pwd.csv.zip\"))\n", - "dg = dg[\"instrument\"] # Extract the instrument data\n", - "\n", - "# Extract the events from nested data groups\n", + "dg = dream.io.load_geant4_csv(dream.data.get_path(\"data_dream0_new_hkl_Si_pwd.csv.zip\"))[\"instrument\"]\n", "dg = sc.DataGroup({key: detector[\"events\"] for key, detector in dg.items()})\n", "dg" ] @@ -63,7 +63,7 @@ "source": [ "## Display inhomogeneity from absorption\n", "\n", - "If the sample absorbs or scatters a large fraction of the incoming neutrons the intensity in the detector will vary even if the scattering is inhomogeneous.\n" + "If the sample absorbs or scatters a large fraction of the incoming neutrons, the intensity in the detector will vary even if the scattering is inhomogeneous.\n" ] }, { @@ -73,46 +73,77 @@ "metadata": {}, "outputs": [], "source": [ - "import scipp as sc\n", - "\n", - "from scippneutron.absorption import compute_transmission_map\n", - "from scippneutron.absorption.cylinder import Cylinder\n", - "from scippneutron.absorption.material import Material\n", - "from scippneutron.atoms import ScatteringParams\n", - "\n", - "\n", "material = Material(\n", " scattering_params=ScatteringParams.for_isotope('V'),\n", " effective_sample_number_density=sc.scalar(0.07192, unit='1/angstrom**3')\n", ")\n", "sample_shape = Cylinder(\n", - " symmetry_line=sc.vector([0, 1, 0]),\n", - " center_of_base=sc.vector([0, -2.5, 0], unit='cm'),\n", " radius=sc.scalar(1, unit='cm'),\n", - " height=sc.scalar(5., unit='cm')\n", - ")\n", - "\n", - "transmission_fraction = compute_transmission_map(\n", + " height=(height := sc.scalar(5., unit='cm')),\n", + " # Cylinder is oriented along the x-axis\n", + " symmetry_line=(symmetry_line := sc.vector([1, 0, 0])),\n", + " center_of_base=-height * symmetry_line / 2,\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6", + "metadata": {}, + "outputs": [], + "source": [ + "transmission_fraction_mantle = compute_transmission_map(\n", " sample_shape,\n", " material,\n", " beam_direction=sc.vector([0, 0, 1]),\n", " wavelength=sc.linspace('wavelength', 4, 8, 20, unit='angstrom'),\n", + " # To make it faster, don't compute the transmission fraction for every detector pixel, it's not necessary for the visualization.\n", " detector_position=dg['mantle'].coords['position']['strip', ::4]['wire', ::2].copy(),\n", " quadrature_kind='cheap',\n", ")\n", "\n", - "transmission_fraction.coords['position'] = transmission_fraction.coords.pop('detector_position')\n", - "dream.instrument_view(transmission_fraction.transpose((*set(transmission_fraction.dims) - {'wavelength'}, 'wavelength')), dim='wavelength')" + "# The visualization expects the `position` coord to denote detector positions, and `wavelength` to be the last dimension.\n", + "transmission_fraction_mantle.coords['position'] = transmission_fraction_mantle.coords.pop('detector_position')\n", + "dream.instrument_view(transmission_fraction_mantle.transpose((*set(transmission_fraction_mantle.dims) - {'wavelength'}, 'wavelength')), dim='wavelength', camera=Camera(position=sc.vector((-1.5, 1.5, -1.5), unit='m'), look_at=sc.vector((1, -1/3, 1/2), unit='m')))" ] }, { "cell_type": "code", "execution_count": null, - "id": "6", + "id": "7", + "metadata": {}, + "outputs": [], + "source": [ + "transmission_fraction_mantle" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "8", "metadata": {}, "outputs": [], "source": [ - "transmission_fraction" + "transmission_fraction_endcap = compute_transmission_map(\n", + " sample_shape,\n", + " material,\n", + " beam_direction=sc.vector([0, 0, 1]),\n", + " wavelength=sc.linspace('wavelength', 4, 8, 20, unit='angstrom'),\n", + " detector_position=dg['endcap_backward'].coords['position']['strip', 0].copy(),\n", + " quadrature_kind='cheap',\n", + ")\n", + "\n", + "transmission_fraction_endcap.coords['position'] = transmission_fraction_endcap.coords.pop('detector_position')\n", + "dream.instrument_view(transmission_fraction_endcap.transpose((*set(transmission_fraction_endcap.dims) - {'wavelength'}, 'wavelength')), dim='wavelength', camera=Camera(position=sc.vector((-1, 1, -3), unit='m'), look_at=sc.vector((0.3, -0.3, 1), unit='m')))" + ] + }, + { + "cell_type": "markdown", + "id": "9", + "metadata": {}, + "source": [ + "As expected the impact of absorption on the inhomgenity of the intensity is not nearly as large for the endcap detector as it is for the mantle detector." ] } ], From 1822947f71bd97c4bd669e1ef83e8a94c94f490c Mon Sep 17 00:00:00 2001 From: Johannes Kasimir Date: Thu, 23 Jan 2025 08:54:12 +0100 Subject: [PATCH 4/6] docs: add to index --- docs/user-guide/dream/index.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/user-guide/dream/index.md b/docs/user-guide/dream/index.md index 5a5281fc..24fe156e 100644 --- a/docs/user-guide/dream/index.md +++ b/docs/user-guide/dream/index.md @@ -9,4 +9,5 @@ dream-data-reduction dream-instrument-view workflow-widget-dream dream-detector-diagnostics +dream-visualize-absorption ``` From 1cf402a4489b921428c1f2a0f83070d70e33ff59 Mon Sep 17 00:00:00 2001 From: Johannes Kasimir Date: Thu, 23 Jan 2025 09:23:46 +0100 Subject: [PATCH 5/6] docs: change title and add disk section --- .../dream/dream-visualize-absorption.ipynb | 88 +++++++++++++++---- 1 file changed, 72 insertions(+), 16 deletions(-) diff --git a/docs/user-guide/dream/dream-visualize-absorption.ipynb b/docs/user-guide/dream/dream-visualize-absorption.ipynb index f658f632..711849cb 100644 --- a/docs/user-guide/dream/dream-visualize-absorption.ipynb +++ b/docs/user-guide/dream/dream-visualize-absorption.ipynb @@ -5,7 +5,7 @@ "id": "0", "metadata": {}, "source": [ - "# DREAM instrument view\n", + "# Visualize effect of absorption\n", "\n", "This notebook is an example of how to use the `compute_transmission_map` function to visualize the effect of (sample) absorption on the intensity in the detector.\n", "\n", @@ -53,7 +53,7 @@ "source": [ "dg = dream.io.load_geant4_csv(dream.data.get_path(\"data_dream0_new_hkl_Si_pwd.csv.zip\"))[\"instrument\"]\n", "dg = sc.DataGroup({key: detector[\"events\"] for key, detector in dg.items()})\n", - "dg" + "dg.keys()" ] }, { @@ -61,23 +61,33 @@ "id": "4", "metadata": {}, "source": [ - "## Display inhomogeneity from absorption\n", + "## Inhomogeneity from absorption in mantle detector\n", "\n", "If the sample absorbs or scatters a large fraction of the incoming neutrons, the intensity in the detector will vary even if the scattering is inhomogeneous.\n" ] }, + { + "cell_type": "markdown", + "id": "5", + "metadata": {}, + "source": [ + "### Rod-like sample oriented along x-axis" + ] + }, { "cell_type": "code", "execution_count": null, - "id": "5", + "id": "6", "metadata": {}, "outputs": [], "source": [ - "material = Material(\n", + "# The material determines the rate of absorption and scattering\n", + "vanadium = Material(\n", " scattering_params=ScatteringParams.for_isotope('V'),\n", " effective_sample_number_density=sc.scalar(0.07192, unit='1/angstrom**3')\n", ")\n", - "sample_shape = Cylinder(\n", + "# The shape determines the shape and the orientation of the sample\n", + "rod_shape = Cylinder(\n", " radius=sc.scalar(1, unit='cm'),\n", " height=(height := sc.scalar(5., unit='cm')),\n", " # Cylinder is oriented along the x-axis\n", @@ -89,13 +99,13 @@ { "cell_type": "code", "execution_count": null, - "id": "6", + "id": "7", "metadata": {}, "outputs": [], "source": [ "transmission_fraction_mantle = compute_transmission_map(\n", - " sample_shape,\n", - " material,\n", + " rod_shape,\n", + " vanadium,\n", " beam_direction=sc.vector([0, 0, 1]),\n", " wavelength=sc.linspace('wavelength', 4, 8, 20, unit='angstrom'),\n", " # To make it faster, don't compute the transmission fraction for every detector pixel, it's not necessary for the visualization.\n", @@ -105,29 +115,75 @@ "\n", "# The visualization expects the `position` coord to denote detector positions, and `wavelength` to be the last dimension.\n", "transmission_fraction_mantle.coords['position'] = transmission_fraction_mantle.coords.pop('detector_position')\n", - "dream.instrument_view(transmission_fraction_mantle.transpose((*set(transmission_fraction_mantle.dims) - {'wavelength'}, 'wavelength')), dim='wavelength', camera=Camera(position=sc.vector((-1.5, 1.5, -1.5), unit='m'), look_at=sc.vector((1, -1/3, 1/2), unit='m')))" + "dream.instrument_view(transmission_fraction_mantle.transpose((*set(transmission_fraction_mantle.dims) - {'wavelength'}, 'wavelength')), dim='wavelength', camera=Camera(position=sc.vector((-2, 2, -2), unit='m'), look_at=sc.vector((1, -1/3, 1/2), unit='m')))" ] }, { "cell_type": "code", "execution_count": null, - "id": "7", + "id": "8", "metadata": {}, "outputs": [], "source": [ "transmission_fraction_mantle" ] }, + { + "cell_type": "markdown", + "id": "9", + "metadata": {}, + "source": [ + "# Disk-like sample oriented along x-axis" + ] + }, { "cell_type": "code", "execution_count": null, - "id": "8", + "id": "10", + "metadata": {}, + "outputs": [], + "source": [ + "disk_shape = Cylinder(\n", + " radius=sc.scalar(5, unit='cm'),\n", + " height=(height := sc.scalar(1., unit='cm')),\n", + " # Cylinder is oriented along the x-axis\n", + " symmetry_line=(symmetry_line := sc.vector([1, 0, 0])),\n", + " center_of_base=-height * symmetry_line / 2,\n", + ")\n", + "\n", + "transmission_fraction_mantle = compute_transmission_map(\n", + " disk_shape,\n", + " vanadium,\n", + " beam_direction=sc.vector([0, 0, 1]),\n", + " wavelength=sc.linspace('wavelength', 4, 8, 20, unit='angstrom'),\n", + " # To make it faster, don't compute the transmission fraction for every detector pixel, it's not necessary for the visualization.\n", + " detector_position=dg['mantle'].coords['position']['strip', ::4]['wire', ::2].copy(),\n", + " quadrature_kind='cheap',\n", + ")\n", + "\n", + "# The visualization expects the `position` coord to denote detector positions, and `wavelength` to be the last dimension.\n", + "transmission_fraction_mantle.coords['position'] = transmission_fraction_mantle.coords.pop('detector_position')\n", + "dream.instrument_view(transmission_fraction_mantle.transpose((*set(transmission_fraction_mantle.dims) - {'wavelength'}, 'wavelength')), dim='wavelength', camera=Camera(position=sc.vector((-2, 2, -2), unit='m'), look_at=sc.vector((1, -1/3, 1/2), unit='m')))" + ] + }, + { + "cell_type": "markdown", + "id": "11", + "metadata": {}, + "source": [ + "## Does absorption influence the intensity in the endcap detector?" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "12", "metadata": {}, "outputs": [], "source": [ "transmission_fraction_endcap = compute_transmission_map(\n", - " sample_shape,\n", - " material,\n", + " rod_shape,\n", + " vanadium,\n", " beam_direction=sc.vector([0, 0, 1]),\n", " wavelength=sc.linspace('wavelength', 4, 8, 20, unit='angstrom'),\n", " detector_position=dg['endcap_backward'].coords['position']['strip', 0].copy(),\n", @@ -140,10 +196,10 @@ }, { "cell_type": "markdown", - "id": "9", + "id": "13", "metadata": {}, "source": [ - "As expected the impact of absorption on the inhomgenity of the intensity is not nearly as large for the endcap detector as it is for the mantle detector." + "As expected the impact of absorption on on the intensity in the endcap detector is close to uniform." ] } ], From de85d7d2f247ac08f99718b648e9426a3bd0cf09 Mon Sep 17 00:00:00 2001 From: Johannes Kasimir Date: Thu, 23 Jan 2025 09:31:03 +0100 Subject: [PATCH 6/6] fix --- docs/user-guide/dream/dream-visualize-absorption.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/dream/dream-visualize-absorption.ipynb b/docs/user-guide/dream/dream-visualize-absorption.ipynb index 711849cb..fe2b2751 100644 --- a/docs/user-guide/dream/dream-visualize-absorption.ipynb +++ b/docs/user-guide/dream/dream-visualize-absorption.ipynb @@ -133,7 +133,7 @@ "id": "9", "metadata": {}, "source": [ - "# Disk-like sample oriented along x-axis" + "## Disk-like sample oriented along x-axis" ] }, {