-
Notifications
You must be signed in to change notification settings - Fork 3
Add illustration of inhomogeneity from absorption #113
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
Changes from 2 commits
53343f5
c3c0a60
3401b79
aee7dc8
1822947
f361d77
1cf402a
de85d7d
bd985c9
9e0dd35
25a5ea6
7ac6968
7721efb
95cd61d
747a159
0bf788c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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,31 +53,41 @@ | |
| "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()" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "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')))" | ||
|
jokasimr marked this conversation as resolved.
Outdated
|
||
| ] | ||
| }, | ||
| { | ||
| "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')))" | ||
|
jokasimr marked this conversation as resolved.
Outdated
|
||
| ] | ||
| }, | ||
| { | ||
| "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." | ||
|
Member
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. It doesn't look so uniform when you look at the figure... until you look at the colorbar. Should we use some common colorbar limits for all 3 views? Also, do we really have to use the heavy instrument view, or could we use 2d scatter plots instead? The 3d views dramatically increase the size of the docs, and thus the repository itself.
Contributor
Author
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.
No I don't think that's important. It's better to keep it simple and to make it look like something they might encounter in their own notebook.
Did you check how much the repo size is increased? We could make it 2d, it's not good to make the repo cumbersome to download. Byt the 3d view is nicer to play around with.
Contributor
Author
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. Took a look at the sizes now, after building the docs locally I have the following files: So it seems the absorption visualization notebook is significantly smaller than the instrument view notebook. I also tried cloning Compressed it seems the size (of the current repo) is closer to 10Mb. Overall I get the impression that it doesn't really matter if we put this file here, it's unlikely to make the repo hard to download for anyone.
Member
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. 10Mb is a lot. Maybe we should really reduce the size of the instrument view notebook?
It might be nice to play with, but I don't think it adds any information to what we are viewing? I think the views might be clearer in 2D. I will have a go at making them and we can compare.
Contributor
Author
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.
Let's just ask Celine if this solves her use-case? Then we don't have to guess and re-implement something that already works. |
||
| ] | ||
| } | ||
| ], | ||
|
|
||

Uh oh!
There was an error while loading. Please reload this page.