Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make cc1/2 in cctbx.xfel.merge deterministic #1006

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions xfel/merging/application/reflection_table_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import numpy as np
from six.moves import range
from dials.array_family import flex
import hashlib
import math
from simtbx.diffBragg.utils import is_outlier

Expand All @@ -26,17 +27,31 @@ def get_next_hkl_reflection_table(reflections):

yield reflections[i_begin:i+1]

@staticmethod
def is_even(identifier):
return ord(hashlib.md5(identifier.encode()).hexdigest()[-1]) % 2 == 0

@staticmethod
def select_odd_experiment_reflections(reflections, col='id'):
'Select reflections from experiments with odd ids.'
sel = reflections[col] % 2 == 1
'Select reflections from experiments with odd identifiers.'
id_map = reflections.experiment_identifiers()
reverse_map = {id_map[id_]: id_ for id_ in id_map.keys()}
sel = flex.bool(len(reflections), False)
for identifier in reverse_map:
if not reflection_table_utils.is_even(identifier):
sel |= reflections[col] == reverse_map[identifier]
reflections["is_odd_experiment"] = sel # store this for later use, NOTE this is un-prunable if expanded_bookkeeping=True
return reflections.select(sel)

@staticmethod
def select_even_experiment_reflections(reflections, col='id'):
'Select reflections from experiments with even ids'
sel = reflections[col] % 2 == 0
'Select reflections from experiments with even identifiers'
id_map = reflections.experiment_identifiers()
reverse_map = {id_map[id_]: id_ for id_ in id_map.keys()}
sel = flex.bool(len(reflections), False)
for identifier in reverse_map:
if reflection_table_utils.is_even(identifier):
sel |= reflections[col] == reverse_map[identifier]
return reflections.select(sel)

@staticmethod
Expand Down
Loading