-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add illustration of inhomogeneity from absorption #113
Open
jokasimr
wants to merge
9
commits into
main
Choose a base branch
from
display-transmission
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
53343f5
add illustration of inhomogeneity from absorption
jokasimr c3c0a60
fix: move visualization to separate notebook
jokasimr 3401b79
fix: text in notebook
jokasimr aee7dc8
Merge branch 'main' into display-transmission
jokasimr 1822947
docs: add to index
jokasimr f361d77
Merge branch 'display-transmission' of github.com:scipp/essdiffractio…
jokasimr 1cf402a
docs: change title and add disk section
jokasimr de85d7d
fix
jokasimr bd985c9
Merge branch 'main' into display-transmission
jokasimr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`:" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the text in here needs updating? (seems it was copied from the instrument view notebook) |
||
] | ||
}, | ||
{ | ||
"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 | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want this notebook to appear in the docs, you need to add it to the
dream/index.md
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgot that, thanks.