|
21 | 21 | "import numpy as np\n", |
22 | 22 | "import scipp as sc\n", |
23 | 23 | "import sciline\n", |
24 | | - "import scippnexus as snx\n", |
25 | 24 | "\n", |
26 | 25 | "from ess import bifrost\n", |
27 | 26 | "from ess.bifrost.data import (\n", |
|
36 | 35 | "id": "2", |
37 | 36 | "metadata": {}, |
38 | 37 | "source": [ |
39 | | - "BIFROST NeXus files store detector data in 45 separate NXdetector groups, one per detector triplet.\n", |
40 | | - "For the time being, we need to specify the names of these NXdetector groups when creating the workflow.\n", |
41 | | - "So load them from the input file:" |
42 | | - ] |
43 | | - }, |
44 | | - { |
45 | | - "cell_type": "code", |
46 | | - "execution_count": null, |
47 | | - "id": "3", |
48 | | - "metadata": {}, |
49 | | - "outputs": [], |
50 | | - "source": [ |
51 | | - "with snx.File(simulated_elastic_incoherent_with_phonon()) as f:\n", |
52 | | - " detector_names = list(f['entry/instrument'][snx.NXdetector])" |
53 | | - ] |
54 | | - }, |
55 | | - { |
56 | | - "cell_type": "markdown", |
57 | | - "id": "4", |
58 | | - "metadata": {}, |
59 | | - "source": [ |
60 | | - "Generally, we would use all triplets, but for this example, we only use the first two.\n", |
61 | | - "This reduces the size of the data and the time to compute it." |
62 | | - ] |
63 | | - }, |
64 | | - { |
65 | | - "cell_type": "code", |
66 | | - "execution_count": null, |
67 | | - "id": "5", |
68 | | - "metadata": {}, |
69 | | - "outputs": [], |
70 | | - "source": [ |
71 | | - "detector_names = detector_names[:2]" |
72 | | - ] |
73 | | - }, |
74 | | - { |
75 | | - "cell_type": "markdown", |
76 | | - "id": "6", |
77 | | - "metadata": {}, |
78 | | - "source": [ |
79 | | - "Next, construct the workflow which is a [sciline.Pipeline](https://scipp.github.io/sciline/generated/classes/sciline.Pipeline.html) and encodes the entire reduction procedure.\n", |
| 38 | + "Construct the workflow which is a [sciline.Pipeline](https://scipp.github.io/sciline/generated/classes/sciline.Pipeline.html) and encodes the entire reduction procedure.\n", |
80 | 39 | "We need to provide a couple of parameters so we can run the workflow:" |
81 | 40 | ] |
82 | 41 | }, |
83 | 42 | { |
84 | 43 | "cell_type": "code", |
85 | 44 | "execution_count": null, |
86 | | - "id": "7", |
| 45 | + "id": "3", |
87 | 46 | "metadata": {}, |
88 | 47 | "outputs": [], |
89 | 48 | "source": [ |
90 | | - "workflow = bifrost.BifrostSimulationWorkflow(detector_names)\n", |
| 49 | + "workflow = bifrost.BifrostSimulationWorkflow()\n", |
91 | 50 | "# Set the input file name:\n", |
92 | 51 | "workflow[Filename[SampleRun]] = simulated_elastic_incoherent_with_phonon()\n", |
93 | 52 | "# Set the lookup table for frame unwrapping:\n", |
|
107 | 66 | }, |
108 | 67 | { |
109 | 68 | "cell_type": "markdown", |
110 | | - "id": "8", |
| 69 | + "id": "4", |
111 | 70 | "metadata": {}, |
112 | 71 | "source": [ |
113 | 72 | "Next, draw the workflow as a graph to inspect the steps it will take to reduce the data.\n", |
|
119 | 78 | { |
120 | 79 | "cell_type": "code", |
121 | 80 | "execution_count": null, |
122 | | - "id": "9", |
| 81 | + "id": "5", |
123 | 82 | "metadata": {}, |
124 | 83 | "outputs": [], |
125 | 84 | "source": [ |
|
128 | 87 | }, |
129 | 88 | { |
130 | 89 | "cell_type": "markdown", |
131 | | - "id": "10", |
| 90 | + "id": "6", |
132 | 91 | "metadata": {}, |
133 | 92 | "source": [ |
134 | 93 | "We are ready to compute the reduced data.\n", |
|
139 | 98 | { |
140 | 99 | "cell_type": "code", |
141 | 100 | "execution_count": null, |
142 | | - "id": "11", |
| 101 | + "id": "7", |
143 | 102 | "metadata": {}, |
144 | 103 | "outputs": [], |
145 | 104 | "source": [ |
|
149 | 108 | }, |
150 | 109 | { |
151 | 110 | "cell_type": "markdown", |
152 | | - "id": "12", |
| 111 | + "id": "8", |
153 | 112 | "metadata": {}, |
154 | 113 | "source": [ |
155 | 114 | "The result contains coordinates for the sample table and detector rotation angles `a3` and `a4`, respectively.\n", |
|
159 | 118 | { |
160 | 119 | "cell_type": "code", |
161 | 120 | "execution_count": null, |
162 | | - "id": "13", |
| 121 | + "id": "9", |
163 | 122 | "metadata": {}, |
164 | 123 | "outputs": [], |
165 | 124 | "source": [ |
|
168 | 127 | }, |
169 | 128 | { |
170 | 129 | "cell_type": "markdown", |
171 | | - "id": "14", |
| 130 | + "id": "10", |
172 | 131 | "metadata": {}, |
173 | 132 | "source": [ |
174 | 133 | "We can plot the counts as a function of energy transfer and $a_3$ by removing the unused dimensions.\n", |
|
178 | 137 | { |
179 | 138 | "cell_type": "code", |
180 | 139 | "execution_count": null, |
181 | | - "id": "15", |
| 140 | + "id": "11", |
182 | 141 | "metadata": {}, |
183 | 142 | "outputs": [], |
184 | 143 | "source": [ |
|
191 | 150 | }, |
192 | 151 | { |
193 | 152 | "cell_type": "markdown", |
194 | | - "id": "16", |
| 153 | + "id": "12", |
195 | 154 | "metadata": {}, |
196 | 155 | "source": [ |
197 | 156 | "We can also plot the counts as a function of the momentum transfer in the sample table frame $Q$.\n", |
|
207 | 166 | { |
208 | 167 | "cell_type": "code", |
209 | 168 | "execution_count": null, |
210 | | - "id": "17", |
| 169 | + "id": "13", |
211 | 170 | "metadata": {}, |
212 | 171 | "outputs": [], |
213 | 172 | "source": [ |
|
0 commit comments