Skip to content

Commit 9a259ff

Browse files
committed
update docs index
1 parent 34f4996 commit 9a259ff

File tree

3 files changed

+199
-0
lines changed

3 files changed

+199
-0
lines changed

docs/user-guide/dream/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
maxdepth: 1
66
---
77
8+
workflows/index
89
dream-data-reduction
910
dream-instrument-view
1011
workflow-widget-dream
Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "0",
6+
"metadata": {},
7+
"source": [
8+
"# DREAM data reduction - Normalized by proton charge"
9+
]
10+
},
11+
{
12+
"cell_type": "code",
13+
"execution_count": null,
14+
"id": "1",
15+
"metadata": {},
16+
"outputs": [],
17+
"source": [
18+
"import scipp as sc\n",
19+
"\n",
20+
"from ess import dream, powder\n",
21+
"import ess.dream.data # noqa: F401\n",
22+
"from ess.powder.types import *"
23+
]
24+
},
25+
{
26+
"cell_type": "markdown",
27+
"id": "2",
28+
"metadata": {},
29+
"source": [
30+
"## Create and configure the workflow"
31+
]
32+
},
33+
{
34+
"cell_type": "code",
35+
"execution_count": null,
36+
"id": "3",
37+
"metadata": {},
38+
"outputs": [],
39+
"source": [
40+
"workflow = dream.DreamGeant4Workflow(run_norm=powder.RunNormalization.proton_charge)"
41+
]
42+
},
43+
{
44+
"cell_type": "markdown",
45+
"id": "4",
46+
"metadata": {},
47+
"source": [
48+
"### Files"
49+
]
50+
},
51+
{
52+
"cell_type": "code",
53+
"execution_count": null,
54+
"id": "c9f1994d-a646-41d6-9197-8c7f1d22d738",
55+
"metadata": {},
56+
"outputs": [],
57+
"source": [
58+
"workflow[Filename[SampleRun]] = dream.data.simulated_diamond_sample()\n",
59+
"workflow[Filename[VanadiumRun]] = dream.data.simulated_vanadium_sample()\n",
60+
"workflow[Filename[BackgroundRun]] = dream.data.simulated_empty_can()\n",
61+
"workflow[CalibrationFilename] = None"
62+
]
63+
},
64+
{
65+
"cell_type": "markdown",
66+
"id": "a8163eb6-a981-4463-b16c-85afdd5d8091",
67+
"metadata": {},
68+
"source": [
69+
"### Masks"
70+
]
71+
},
72+
{
73+
"cell_type": "code",
74+
"execution_count": null,
75+
"id": "76f070d3-35ff-473d-aebd-013cd254713b",
76+
"metadata": {},
77+
"outputs": [],
78+
"source": [
79+
"workflow[TofMask] = lambda x: (x < sc.scalar(0.0, unit=\"ns\")) | (\n",
80+
" x > sc.scalar(86e6, unit=\"ns\")\n",
81+
")\n",
82+
"workflow[TwoThetaMask] = None\n",
83+
"workflow[WavelengthMask] = None\n",
84+
"workflow = powder.with_pixel_mask_filenames(workflow, [])"
85+
]
86+
},
87+
{
88+
"cell_type": "markdown",
89+
"id": "7a7ad64d-b124-49e2-b655-92ba8d5669c1",
90+
"metadata": {},
91+
"source": [
92+
"### Other parameters"
93+
]
94+
},
95+
{
96+
"cell_type": "code",
97+
"execution_count": null,
98+
"id": "2b6b8d3b-d196-490f-b89f-762616958110",
99+
"metadata": {},
100+
"outputs": [],
101+
"source": [
102+
"workflow[NeXusDetectorName] = \"mantle\"\n",
103+
"workflow[UncertaintyBroadcastMode] = UncertaintyBroadcastMode.drop\n",
104+
"workflow[DspacingBins] = sc.linspace(\"dspacing\", 0.0, 2.3434, 201, unit=\"angstrom\")"
105+
]
106+
},
107+
{
108+
"cell_type": "markdown",
109+
"id": "6",
110+
"metadata": {},
111+
"source": [
112+
"## Use the workflow"
113+
]
114+
},
115+
{
116+
"cell_type": "code",
117+
"execution_count": null,
118+
"id": "9",
119+
"metadata": {},
120+
"outputs": [],
121+
"source": [
122+
"results = workflow.compute([IofTof, ReducedTofCIF])"
123+
]
124+
},
125+
{
126+
"cell_type": "markdown",
127+
"id": "37d94b62-8068-4301-939d-01c97ce1cfed",
128+
"metadata": {},
129+
"source": [
130+
"## Plot and save"
131+
]
132+
},
133+
{
134+
"cell_type": "code",
135+
"execution_count": null,
136+
"id": "10",
137+
"metadata": {},
138+
"outputs": [],
139+
"source": [
140+
"results[IofTof].hist().plot()"
141+
]
142+
},
143+
{
144+
"cell_type": "markdown",
145+
"id": "11",
146+
"metadata": {},
147+
"source": [
148+
"We can now save the result to disk:"
149+
]
150+
},
151+
{
152+
"cell_type": "code",
153+
"execution_count": null,
154+
"id": "12",
155+
"metadata": {},
156+
"outputs": [],
157+
"source": [
158+
"cif_data = results[ReducedTofCIF]\n",
159+
"\n",
160+
"cif_data.comment = \"\"\"This file was generated with the DREAM data reduction user guide\n",
161+
"in the documentation of ESSdiffraction.\n",
162+
"See https://scipp.github.io/essdiffraction/\n",
163+
"\"\"\"\n",
164+
"cif_data.save('reduced.cif')"
165+
]
166+
}
167+
],
168+
"metadata": {
169+
"kernelspec": {
170+
"display_name": "Python 3 (ipykernel)",
171+
"language": "python",
172+
"name": "python3"
173+
},
174+
"language_info": {
175+
"codemirror_mode": {
176+
"name": "ipython",
177+
"version": 3
178+
},
179+
"file_extension": ".py",
180+
"mimetype": "text/x-python",
181+
"name": "python",
182+
"nbconvert_exporter": "python",
183+
"pygments_lexer": "ipython3",
184+
"version": "3.12.7"
185+
}
186+
},
187+
"nbformat": 4,
188+
"nbformat_minor": 5
189+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# DREAM reduction workflows
2+
3+
```{toctree}
4+
---
5+
maxdepth: 1
6+
---
7+
8+
dream-proton-charge-norm
9+
```

0 commit comments

Comments
 (0)