Skip to content

Commit

Permalink
Changed predicted reflections calculation during tof_integrate.
Browse files Browse the repository at this point in the history
  • Loading branch information
toastisme committed Sep 10, 2024
1 parent 94fd2d3 commit e30f9af
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 9 deletions.
34 changes: 34 additions & 0 deletions src/dials/algorithms/spot_prediction/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,40 @@ def post_prediction(self, reflections):

return reflections

def indices_for_ub(self, indices):
reflection_table = self.predictor(indices)
reflection_table = self.post_prediction(reflection_table)

interpolation_tof = self.experiment.scan.get_property("time_of_flight")
interpolation_frames = list(range(len(interpolation_tof)))
tof_to_frame = tof_helpers.tof_to_frame_interpolator(
interpolation_tof, interpolation_frames
)
L0 = self.experiment.beam.get_sample_to_source_distance() * 10**-3 # (m)

reflection_tof = (
tof_helpers.tof_from_wavelength(
reflection_table["wavelength_cal"],
L0 + reflection_table["L1"] * 10**-3,
)
* 10**6
)

reflection_table = reflection_table.select(
(reflection_tof > min(interpolation_tof))
& (reflection_tof < max(interpolation_tof))
)

reflection_tof = reflection_tof.select(
(reflection_tof > min(interpolation_tof))
& (reflection_tof < max(interpolation_tof))
)
reflection_frames = flumpy.from_numpy(tof_to_frame(reflection_tof))
x, y, _ = reflection_table["xyzcal.px"].parts()
reflection_table["xyzcal.px"] = flex.vec3_double(x, y, reflection_frames)

return reflection_table

def for_ub(self, ub):

reflection_table = self.predictor.for_ub(ub)
Expand Down
17 changes: 8 additions & 9 deletions src/dials/command_line/tof_integrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
ComputeEsdBeamDivergence,
)
from dials.algorithms.shoebox import MaskCode
from dials.algorithms.spot_prediction import TOFReflectionPredictor
from dials.array_family import flex
from dials.command_line.integrate import process_reference
from dials.extensions.simple_background_ext import SimpleBackgroundExt
Expand Down Expand Up @@ -330,22 +331,20 @@ def run_integrate(params, experiments, reflections):
dmin = expt_dmin

predicted_reflections = None
miller_indices = reflections["miller_index"]
for idx, experiment in enumerate(experiments):

predictor = TOFReflectionPredictor(experiment, dmin)
if predicted_reflections is None:
predicted_reflections = flex.reflection_table.from_predictions(
experiment, padding=1.0, dmin=dmin
)
predicted_reflections = predictor.indices_for_ub(miller_indices)
predicted_reflections["id"] = cctbx.array_family.flex.int(
len(predicted_reflections), idx
)
predicted_reflections["imageset_id"] = cctbx.array_family.flex.int(
len(predicted_reflections), idx
)
else:
r = flex.reflection_table.from_predictions(
experiment, padding=1.0, dmin=dmin
)
r = predictor.indices_for_ub(miller_indices)
r["id"] = cctbx.array_family.flex.int(len(r), idx)
r["imageset_id"] = cctbx.array_family.flex.int(len(r), idx)
predicted_reflections.extend(r)
Expand Down Expand Up @@ -497,7 +496,7 @@ def run_integrate(params, experiments, reflections):
expt_reflections.compute_summed_intensity()

if params.method.line_profile_fitting:
print("Calculating line profile fitted intensities")
print(f"Calculating line profile fitted intensities for expt {idx}")
expt_reflections = compute_line_profile_intensity(expt_reflections)
predicted_reflections.set_selected(sel, expt_reflections)
else:
Expand Down Expand Up @@ -539,7 +538,7 @@ def run_integrate(params, experiments, reflections):
expt_reflections.compute_summed_intensity()

if params.method.line_profile_fitting:
print("Calculating line profile fitted intensities")
print(f"Calculating line profile fitted intensities for expt {idx}")
expt_reflections = compute_line_profile_intensity(expt_reflections)
predicted_reflections.set_selected(sel, expt_reflections)
else:
Expand Down Expand Up @@ -581,7 +580,7 @@ def run_integrate(params, experiments, reflections):
expt_reflections.compute_summed_intensity()

if params.method.line_profile_fitting:
print("Calculating line profile fitted intensities")
print(f"Calculating line profile fitted intensities for expt {idx}")
expt_reflections = compute_line_profile_intensity(expt_reflections)
predicted_reflections.set_selected(sel, expt_reflections)

Expand Down

0 comments on commit e30f9af

Please sign in to comment.