Skip to content

Commit

Permalink
Update dials.slice_sequence and filter_reflections
Browse files Browse the repository at this point in the history
  • Loading branch information
jbeilstenedmands committed Dec 19, 2023
1 parent 0ea06b9 commit aa69ba4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
27 changes: 21 additions & 6 deletions src/dials/command_line/filter_reflections.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from tokenize import TokenError, generate_tokens, untokenize

from cctbx import uctbx
from dxtbx.model import ExperimentList
from libtbx.phil import parse

from dials.algorithms.integration import filtering
Expand Down Expand Up @@ -211,13 +212,27 @@ def run_filtering(params, experiments, reflections):
)
sel = reflections["id"] >= 0
if sel.count(False) > 0:
print(
"Removing {} reflections with negative experiment id".format(
sel.count(False)
)
)
print("Removing {} unindexed reflections".format(sel.count(False)))
reflections = reflections.select(sel)
reflections.compute_d(experiments)
if not all(
experiments.crystals()
): # handle potential crystalless expts
tables = reflections.split_by_experiment_id()
for expt, table in zip(experiments, tables):
table.reset_ids()
expts = ExperimentList([expt])
if expt.crystal:
table.compute_d(expts)
else:
if "rlp" not in table:
if "xyzobs.mm.value" not in table:
table.centroid_px_to_mm(expts)
table.map_centroids_to_reciprocal_space(expts)
d_star_sq = flex.pow2(table["rlp"].norms())
table["d"] = uctbx.d_star_sq_as_d(d_star_sq)
reflections = flex.reflection_table.concat(tables)
else:
reflections.compute_d(experiments)
elif experiments:
# Calculate d-spacings from the observed reflection centroids
if "rlp" not in reflections:
Expand Down
8 changes: 8 additions & 0 deletions src/dials/command_line/slice_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ def run(self, args=None):
reflections, experiments = reflections_and_experiments_from_files(
params.input.reflections, params.input.experiments
)
if experiments and any(experiments.crystals()):
from dials.util.multi_dataset_handling import Expeditor

experiments, reflections = Expeditor(
experiments, reflections
).filter_experiments_with_crystals()
if not reflections:
reflections = []

# Try to load the models and data
slice_exps = len(experiments) > 0
Expand Down

0 comments on commit aa69ba4

Please sign in to comment.