diff --git a/src/dials/algorithms/indexing/indexer.py b/src/dials/algorithms/indexing/indexer.py index aabfffdefd..219963e7ae 100644 --- a/src/dials/algorithms/indexing/indexer.py +++ b/src/dials/algorithms/indexing/indexer.py @@ -888,6 +888,8 @@ def _xyzcal_mm_to_px(self, experiments, reflections): tof = expt.scan.get_property("time_of_flight") frames = list(range(len(tof))) tof_to_frame = tof_helpers.tof_to_frame_interpolator(tof, frames) + z.set_selected(z < min(tof), min(tof)) + z.set_selected(z > max(tof), max(tof)) z_px = flex.double(tof_to_frame(z)) else: z_px = expt.scan.get_array_index_from_angle(z, deg=False) diff --git a/src/dials/algorithms/refinement/prediction/managed_predictors.py b/src/dials/algorithms/refinement/prediction/managed_predictors.py index 6c604be47d..68016cdc4e 100644 --- a/src/dials/algorithms/refinement/prediction/managed_predictors.py +++ b/src/dials/algorithms/refinement/prediction/managed_predictors.py @@ -210,6 +210,8 @@ def _post_predict_one_experiment(self, experiment, reflections): expt_tof = experiment.scan.get_property("time_of_flight") # (usec) frames = list(range(len(expt_tof))) tof_to_frame = tof_helpers.tof_to_frame_interpolator(expt_tof, frames) + tof_cal.set_selected(tof_cal < min(expt_tof), min(expt_tof)) + tof_cal.set_selected(tof_cal > max(expt_tof), max(expt_tof)) reflection_frames = flex.double(tof_to_frame(tof_cal)) px, py, pz = reflections["xyzcal.px"].parts() reflections["xyzcal.px"] = flex.vec3_double(px, py, reflection_frames) diff --git a/src/dials/algorithms/refinement/refiner.py b/src/dials/algorithms/refinement/refiner.py index 27aba82ab4..9674bf89f7 100644 --- a/src/dials/algorithms/refinement/refiner.py +++ b/src/dials/algorithms/refinement/refiner.py @@ -914,8 +914,8 @@ def calc_exp_rmsd_table(self): # will convert other angles in radians to degrees (e.g. for # RMSD_DeltaPsi and RMSD_2theta) header.append(name + "\n(deg)") - elif name == "RMSD_wavelength" and units == "A": - header.append(name + "\n(A)") + elif name == "RMSD_wavelength" and units == "frame": + header.append(name + "\n(frame)") else: # skip other/unknown RMSDs pass @@ -954,7 +954,7 @@ def calc_exp_rmsd_table(self): rmsds.append(rmsd * px_per_mm[1]) elif name == "RMSD_Phi" and units == "rad": rmsds.append(rmsd * images_per_rad) - elif name == "RMSD_wavelength" and units == "A": + elif name == "RMSD_wavelength" and units == "frame": rmsds.append(rmsd) elif units == "rad": rmsds.append(rmsd * RAD2DEG) diff --git a/src/dials/algorithms/refinement/reflection_manager.py b/src/dials/algorithms/refinement/reflection_manager.py index be24ca4386..5e8e8f438a 100644 --- a/src/dials/algorithms/refinement/reflection_manager.py +++ b/src/dials/algorithms/refinement/reflection_manager.py @@ -1170,8 +1170,11 @@ def __init__( tof_to_frame_interpolators = [] sample_to_source_distances = [] + tof_ranges = [] for expt in self._experiments: tof = expt.scan.get_property("time_of_flight") # (usec) + tof_range = (min(tof), max(tof)) + tof_ranges.append(tof_range) frames = list(range(len(tof))) tof_to_frame = tof_helpers.tof_to_frame_interpolator(tof, frames) tof_to_frame_interpolators.append(tof_to_frame) @@ -1179,8 +1182,9 @@ def __init__( expt.beam.get_sample_to_source_distance() * 10**-3 # (m) ) - self.tof_to_frame_interpolators = tof_to_frame_interpolators - self.sample_to_source_distances = sample_to_source_distances + self._tof_to_frame_interpolators = tof_to_frame_interpolators + self._sample_to_source_distances = sample_to_source_distances + self._tof_ranges = tof_ranges def update_residuals(self): x_obs, y_obs, _ = self._reflections["xyzobs.mm.value"].parts() @@ -1202,16 +1206,32 @@ def update_residuals(self): r_expt = self._reflections["imageset_id"] == idx else: r_expt = self._reflections["id"] == idx - L_expt = self.sample_to_source_distances[idx] + L2.select(r_expt) + + L_expt = self._sample_to_source_distances[idx] + L2.select(r_expt) + tof_obs_expt = ( tof_helpers.tof_from_wavelength(L_expt, wavelength_obs.select(r_expt)) * 10**6 ) # (usec) + tof_obs_expt.set_selected( + tof_obs_expt < self._tof_ranges[idx][0], self._tof_ranges[idx][0] + ) + tof_obs_expt.set_selected( + tof_obs_expt > self._tof_ranges[idx][1], self._tof_ranges[idx][1] + ) + tof_cal_expt = ( tof_helpers.tof_from_wavelength(L_expt, wavelength_cal.select(r_expt)) * 10**6 ) # (usec) - tof_to_frame = self.tof_to_frame_interpolators[idx] + tof_cal_expt.set_selected( + tof_cal_expt < self._tof_ranges[idx][0], self._tof_ranges[idx][0] + ) + tof_cal_expt.set_selected( + tof_cal_expt > self._tof_ranges[idx][1], self._tof_ranges[idx][1] + ) + + tof_to_frame = self._tof_to_frame_interpolators[idx] frame_resid_expt = flex.double( tof_to_frame(tof_cal_expt) - tof_to_frame(tof_obs_expt) )