Skip to content

Commit 3267486

Browse files
authored
Merge pull request #207 from scipp/tofectomy
Tofectomy
2 parents 3bf0b26 + 63a008d commit 3267486

24 files changed

Lines changed: 219 additions & 270 deletions

docs/user-guide/estia/create-estia-tof-lookup-table.ipynb renamed to docs/user-guide/estia/create-estia-wavelength-lookup-table.ipynb

Lines changed: 25 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"id": "0",
66
"metadata": {},
77
"source": [
8-
"# Create a TOF lookup table for ESTIA\n",
8+
"# Create a wavelength lookup table for ESTIA\n",
99
"\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",
1111
"\n",
1212
"To reproduce the lookup table you will need to provide some instrument parameters like pulse stride and chopper position."
1313
]
@@ -19,28 +19,18 @@
1919
"metadata": {},
2020
"outputs": [],
2121
"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",
3323
"import scipp as sc\n",
3424
"import scipp.constants\n",
35-
"from ess.reduce import time_of_flight\n",
25+
"from ess.reduce import unwrap\n",
3626
"from ess.reduce.nexus.types import AnyRun\n",
3727
"from scippneutron.chopper import DiskChopper"
3828
]
3929
},
4030
{
4131
"cell_type": "code",
4232
"execution_count": null,
43-
"id": "3",
33+
"id": "2",
4434
"metadata": {},
4535
"outputs": [],
4636
"source": [
@@ -81,64 +71,64 @@
8171
{
8272
"cell_type": "code",
8373
"execution_count": null,
84-
"id": "4",
74+
"id": "3",
8575
"metadata": {},
8676
"outputs": [],
8777
"source": [
88-
"wf = time_of_flight.TofLookupTableWorkflow()\n",
78+
"wf = unwrap.LookupTableWorkflow()\n",
8979
"\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"
9989
]
10090
},
10191
{
10292
"cell_type": "code",
10393
"execution_count": null,
104-
"id": "5",
94+
"id": "4",
10595
"metadata": {},
10696
"outputs": [],
10797
"source": [
10898
"%%time\n",
109-
"table = wf.compute(time_of_flight.TimeOfFlightLookupTable)\n",
99+
"table = wf.compute(unwrap.LookupTable)\n",
110100
"table"
111101
]
112102
},
113103
{
114104
"cell_type": "code",
115105
"execution_count": null,
116-
"id": "6",
106+
"id": "5",
117107
"metadata": {},
118108
"outputs": [],
119109
"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",
121111
"table.array['distance', 100].plot()"
122112
]
123113
},
124114
{
125115
"cell_type": "code",
126116
"execution_count": null,
127-
"id": "7",
117+
"id": "6",
128118
"metadata": {},
129119
"outputs": [],
130120
"source": [
131-
"table.plot()"
121+
"(sc.stddevs(table.array)/sc.values(table.array)).plot()"
132122
]
133123
},
134124
{
135125
"cell_type": "code",
136126
"execution_count": null,
137-
"id": "8",
127+
"id": "7",
138128
"metadata": {},
139129
"outputs": [],
140130
"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')"
142132
]
143133
}
144134
],
@@ -158,7 +148,7 @@
158148
"name": "python",
159149
"nbconvert_exporter": "python",
160150
"pygments_lexer": "ipython3",
161-
"version": "3.11.10"
151+
"version": "3.11.13"
162152
}
163153
},
164154
"nbformat": 4,

0 commit comments

Comments
 (0)