Skip to content

Commit

Permalink
Set minimum frame value to calculated reflections below interpolation…
Browse files Browse the repository at this point in the history
… range.
  • Loading branch information
toastisme committed Mar 28, 2024
1 parent 01e97a5 commit 8c524b3
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/dials/algorithms/indexing/indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions src/dials/algorithms/refinement/refiner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
28 changes: 24 additions & 4 deletions src/dials/algorithms/refinement/reflection_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1170,17 +1170,21 @@ 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)
sample_to_source_distances.append(
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()
Expand All @@ -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)
)
Expand Down

0 comments on commit 8c524b3

Please sign in to comment.