@@ -19,7 +19,6 @@ def compute_wavelength_in_each_cluster(
1919 da : StreakClusteredData [RunType ],
2020 chopper_delay : WavelengthDefinitionChopperDelay ,
2121 mod_period : ModulationPeriod ,
22- graph : GeometryCoordTransformGraph ,
2322) -> WavelengthDetector [RunType ]:
2423 """Fits a line through each cluster, the intercept of the line is t0.
2524 The line is fitted using linear regression with an outlier removal procedure.
@@ -38,7 +37,7 @@ def compute_wavelength_in_each_cluster(
3837 if isinstance (da , sc .DataGroup ):
3938 return sc .DataGroup (
4039 {
41- k : compute_wavelength_in_each_cluster (v , mod_period )
40+ k : compute_wavelength_in_each_cluster (v , chopper_delay , mod_period )
4241 for k , v in da .items ()
4342 }
4443 )
@@ -133,7 +132,7 @@ def _compute_d_given_list_of_peaks(
133132 / (scipp .constants .h / scipp .constants .m_n )
134133 ).to (unit = f'{ time_of_arrival .unit } /angstrom' )
135134 for dhkl in dhkl_list :
136- dt = sc .abs (t - dhkl * const )
135+ dt = sc .abs (t - dhkl * const - pulse_length / 2 )
137136 dt_in_range = dt < pulse_length / 2
138137 no_dt_found = sc .isnan (dtfound )
139138 dtfound = sc .where (dt_in_range , sc .where (no_dt_found , dt , dtfound ), dtfound )
@@ -191,34 +190,16 @@ def _tof_from_dhkl(
191190 return out
192191
193192
194- def t0_estimate (
195- wavelength_estimate : sc .Variable ,
196- source_to_wavelength_definition_chopper_distance : sc .Variable ,
197- ) -> sc .Variable :
198- """
199- Computes the time a neutron reaches a chopper at
200- ``source_to_wavelength_chopper_distance`` distance from the source
201- if it has wavelength ``wavelength_estimate``.
202- """
203- return (
204- sc .constants .m_n
205- / sc .constants .h
206- * wavelength_estimate
207- * source_to_wavelength_definition_chopper_distance .to (
208- unit = wavelength_estimate .unit
209- )
210- ).to (unit = 's' )
211-
212-
213- def tof_from_t0_estimate_graph (
193+ def tof_from_nominal_time_at_chopper_graph (
214194 da : RawDetector [RunType ],
215195 gg : GeometryCoordTransformGraph ,
216196) -> ElasticCoordTransformGraph [RunType ]:
217197 """Graph for computing ``wavelength`` in pulse shaping chopper modes."""
218198 return {
219199 ** gg ,
220- 't0' : t0_estimate ,
221- 'tof' : lambda time_of_arrival , t0 : time_of_arrival - t0 ,
200+ 'tof' : lambda time_of_arrival , nominal_time_at_chopper : (
201+ time_of_arrival - nominal_time_at_chopper
202+ ),
222203 'time_of_arrival' : time_of_arrival ,
223204 }
224205
@@ -287,7 +268,7 @@ def wavelength_detector(
287268)
288269convert_pulse_shaping = (
289270 geometry_graph ,
290- tof_from_t0_estimate_graph ,
271+ tof_from_nominal_time_at_chopper_graph ,
291272 wavelength_detector ,
292273)
293274providers = (compute_wavelength_in_each_cluster , geometry_graph )
0 commit comments