|
5 | 5 | "id": "0", |
6 | 6 | "metadata": {}, |
7 | 7 | "source": [ |
8 | | - "# Create a TOF lookup table for ESTIA\n", |
| 8 | + "# Create a wavelength lookup table for ESTIA\n", |
9 | 9 | "\n", |
10 | | - "This notebook recreates the TOF lookup table that is used to compute time-of-flight from time-of-arrival for the ESTIA instrument.\n", |
| 10 | + "This notebook recreates the wavelength lookup table that is used to compute wavelength from time-of-arrival for the ESTIA instrument.\n", |
11 | 11 | "\n", |
12 | 12 | "To reproduce the lookup table you will need to provide some instrument parameters like pulse stride and chopper position." |
13 | 13 | ] |
|
19 | 19 | "metadata": {}, |
20 | 20 | "outputs": [], |
21 | 21 | "source": [ |
22 | | - "#%pip install tof" |
23 | | - ] |
24 | | - }, |
25 | | - { |
26 | | - "cell_type": "code", |
27 | | - "execution_count": null, |
28 | | - "id": "2", |
29 | | - "metadata": {}, |
30 | | - "outputs": [], |
31 | | - "source": [ |
32 | | - "#%matplotlib ipympl\n", |
| 22 | + "%matplotlib ipympl\n", |
33 | 23 | "import scipp as sc\n", |
34 | 24 | "import scipp.constants\n", |
35 | | - "from ess.reduce import time_of_flight\n", |
| 25 | + "from ess.reduce import unwrap\n", |
36 | 26 | "from ess.reduce.nexus.types import AnyRun\n", |
37 | 27 | "from scippneutron.chopper import DiskChopper" |
38 | 28 | ] |
39 | 29 | }, |
40 | 30 | { |
41 | 31 | "cell_type": "code", |
42 | 32 | "execution_count": null, |
43 | | - "id": "3", |
| 33 | + "id": "2", |
44 | 34 | "metadata": {}, |
45 | 35 | "outputs": [], |
46 | 36 | "source": [ |
|
81 | 71 | { |
82 | 72 | "cell_type": "code", |
83 | 73 | "execution_count": null, |
84 | | - "id": "4", |
| 74 | + "id": "3", |
85 | 75 | "metadata": {}, |
86 | 76 | "outputs": [], |
87 | 77 | "source": [ |
88 | | - "wf = time_of_flight.TofLookupTableWorkflow()\n", |
| 78 | + "wf = unwrap.LookupTableWorkflow()\n", |
89 | 79 | "\n", |
90 | | - "wf[time_of_flight.LtotalRange] = sc.scalar(35., unit=\"m\"), sc.scalar(45.0, unit=\"m\")\n", |
91 | | - "wf[time_of_flight.NumberOfSimulatedNeutrons] = 5000_000\n", |
92 | | - "wf[time_of_flight.SourcePosition] = sc.vector([0, 0, 0], unit='m')\n", |
93 | | - "wf[time_of_flight.DiskChoppers[AnyRun]] = disk_choppers\n", |
94 | | - "wf[time_of_flight.DistanceResolution] = sc.scalar(0.05, unit=\"m\")\n", |
95 | | - "wf[time_of_flight.TimeResolution] = sc.scalar(250.0, unit='us')\n", |
96 | | - "wf[time_of_flight.PulsePeriod] = 1.0 / sc.scalar(14.0, unit=\"Hz\")\n", |
97 | | - "wf[time_of_flight.PulseStride] = pulse_stride\n", |
98 | | - "wf[time_of_flight.PulseStrideOffset] = 0" |
| 80 | + "wf[unwrap.LtotalRange] = sc.scalar(35., unit=\"m\"), sc.scalar(45.0, unit=\"m\")\n", |
| 81 | + "wf[unwrap.NumberOfSimulatedNeutrons] = 10_000_000\n", |
| 82 | + "wf[unwrap.SourcePosition] = sc.vector([0, 0, 0], unit='m')\n", |
| 83 | + "wf[unwrap.DiskChoppers[AnyRun]] = disk_choppers\n", |
| 84 | + "wf[unwrap.DistanceResolution] = sc.scalar(0.05, unit=\"m\")\n", |
| 85 | + "wf[unwrap.TimeResolution] = 1.0 / sc.scalar(14.0, unit=\"Hz\") / 200\n", |
| 86 | + "wf[unwrap.PulsePeriod] = 1.0 / sc.scalar(14.0, unit=\"Hz\")\n", |
| 87 | + "wf[unwrap.PulseStride] = pulse_stride\n", |
| 88 | + "wf[unwrap.PulseStrideOffset] = 0" |
99 | 89 | ] |
100 | 90 | }, |
101 | 91 | { |
102 | 92 | "cell_type": "code", |
103 | 93 | "execution_count": null, |
104 | | - "id": "5", |
| 94 | + "id": "4", |
105 | 95 | "metadata": {}, |
106 | 96 | "outputs": [], |
107 | 97 | "source": [ |
108 | 98 | "%%time\n", |
109 | | - "table = wf.compute(time_of_flight.TimeOfFlightLookupTable)\n", |
| 99 | + "table = wf.compute(unwrap.LookupTable)\n", |
110 | 100 | "table" |
111 | 101 | ] |
112 | 102 | }, |
113 | 103 | { |
114 | 104 | "cell_type": "code", |
115 | 105 | "execution_count": null, |
116 | | - "id": "6", |
| 106 | + "id": "5", |
117 | 107 | "metadata": {}, |
118 | 108 | "outputs": [], |
119 | 109 | "source": [ |
120 | | - "# This is what the relationship between time-of-arrival and time-of-flight looks like at 40m (at the detector).\n", |
| 110 | + "# This is what the relationship between time-of-arrival and wavelength looks like at 40m (at the detector).\n", |
121 | 111 | "table.array['distance', 100].plot()" |
122 | 112 | ] |
123 | 113 | }, |
124 | 114 | { |
125 | 115 | "cell_type": "code", |
126 | 116 | "execution_count": null, |
127 | | - "id": "7", |
| 117 | + "id": "6", |
128 | 118 | "metadata": {}, |
129 | 119 | "outputs": [], |
130 | 120 | "source": [ |
131 | | - "table.plot()" |
| 121 | + "(sc.stddevs(table.array)/sc.values(table.array)).plot()" |
132 | 122 | ] |
133 | 123 | }, |
134 | 124 | { |
135 | 125 | "cell_type": "code", |
136 | 126 | "execution_count": null, |
137 | | - "id": "8", |
| 127 | + "id": "7", |
138 | 128 | "metadata": {}, |
139 | 129 | "outputs": [], |
140 | 130 | "source": [ |
141 | | - "table.save_hdf5(f'estia-tof-lookup-table-pulse-stride-{pulse_stride}.h5')" |
| 131 | + "table.save_hdf5(f'estia-lookup-table-pulse-stride-{pulse_stride}.h5')" |
142 | 132 | ] |
143 | 133 | } |
144 | 134 | ], |
|
158 | 148 | "name": "python", |
159 | 149 | "nbconvert_exporter": "python", |
160 | 150 | "pygments_lexer": "ipython3", |
161 | | - "version": "3.11.10" |
| 151 | + "version": "3.11.13" |
162 | 152 | } |
163 | 153 | }, |
164 | 154 | "nbformat": 4, |
|
0 commit comments