Skip to content

Commit

Permalink
Merge pull request #29 from toastisme/add_wavelength_cal_to_refl
Browse files Browse the repository at this point in the history
Add wavelength_cal to reflection table.
  • Loading branch information
toastisme committed Sep 28, 2023
2 parents f245920 + ffe3f50 commit 28a3b8a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/dials/algorithms/indexing/bravais_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def as_dict(self):
"rmsd": item.rmsd,
"nspots": item.Nmatches,
"bravais": item["bravais"],
"volume": uc.volume(),
"unit_cell": uc.parameters(),
"cb_op": str(item["cb_op_inp_best"] * self.cb_op_to_primitive),
"max_cc": item.max_cc,
Expand Down
2 changes: 2 additions & 0 deletions src/dials/algorithms/indexing/indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,8 @@ def refine(self, experiments, reflections):
predicted = refiner.predict_for_indexed()
reflections["xyzcal.mm"] = predicted["xyzcal.mm"]
reflections["entering"] = predicted["entering"]
if "wavelength_cal" in predicted:
reflections["wavelength_cal"] = predicted["wavelength_cal"]
reflections.unset_flags(
flex.bool(len(reflections), True), reflections.flags.centroid_outlier
)
Expand Down
1 change: 1 addition & 0 deletions src/dials/algorithms/refinement/refiner.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ def _filter_reflections(reflections):
"shoebox",
"delpsical.weights",
"wavelength",
"wavelength_cal",
"tof",
"s0",
]
Expand Down
21 changes: 13 additions & 8 deletions src/dials/array_family/flex_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -1065,8 +1065,7 @@ def contains_tof_data(self):

def get_pixel_bbox_centroid_positions(
self, panel: int, pixel_pos: Tuple[int, int]
) -> Tuple[list, list, list]:

) -> Tuple[list, list, list, list]:
"""
Finds any bounding boxes within px and py on panel
and returns their pz positions along with
Expand All @@ -1080,11 +1079,16 @@ def get_pixel_bbox_centroid_positions(
centroids = self["xyzobs.px.value"].select(sel)
else:
centroids = None
if "miller_index" in self:
miller_indices = self["miller_index"].select(sel)
else:
miller_indices = None
py = int(pixel_pos[0])
px = int(pixel_pos[1])
bbox_pos = []
centroid_pos = []
refl_ids = []
selected_miller_indices = []
for i in range(len(x0)):
if px >= x0[i] and px <= x1[i]:
if py >= y0[i] and py <= y1[i]:
Expand All @@ -1095,7 +1099,12 @@ def get_pixel_bbox_centroid_positions(
ci = centroids[i][2]
x, y = z0[i], z1[i]
assert ci >= x and ci <= y, f"{ci} {x} {y}"
return bbox_pos, centroid_pos, refl_ids
if miller_indices:
selected_miller_indices.append(miller_indices[i])
else:
selected_miller_indices.append((0, 0, 0))

return bbox_pos, centroid_pos, refl_ids, selected_miller_indices

def find_overlaps(self, experiments=None, border=0):
"""
Expand Down Expand Up @@ -1337,7 +1346,6 @@ def centroid_px_to_mm(self, experiments):
self["xyzobs.mm.variance"].set_selected(sel, centroid_variance)

def add_beam_data(self, experiments):

"""
Adds wavelength, tof, s0, and unit_s0 columns to self.
All experiments with a TOFSequence have values set from their time-of-flight.
Expand Down Expand Up @@ -1519,10 +1527,7 @@ def map_centroids_to_reciprocal_space(
if self.contains_beam_data():
import numpy as np

if calculated:
wavelengths = self["wavelength_cal"].select(sel)
else:
wavelengths = self["wavelength"].select(sel)
wavelengths = self["wavelength"].select(sel)
S = cctbx.array_family.flex.vec3_double(len(s1))
s1 = s1 / s1.norms()
for s1_idx in range(len(s1)):
Expand Down
2 changes: 2 additions & 0 deletions src/dials/command_line/simple_tof_integrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,8 @@ def run_simple_integrate(params, experiments, reflections):
)
sel = predicted_reflections.get_flags(predicted_reflections.flags.reference_spot)
predicted_reflections = predicted_reflections.select(sel)
if "idx" in reflections:
predicted_reflections["idx"] = reflections["idx"]

"""
Create profile model and add it to erperiment.
Expand Down

0 comments on commit 28a3b8a

Please sign in to comment.