Skip to content

Instantly share code, notes, and snippets.

@graeme-winter
Created May 9, 2023 09:09
Show Gist options
  • Save graeme-winter/17d29d696c300f8127db830e13c6c74d to your computer and use it in GitHub Desktop.
Save graeme-winter/17d29d696c300f8127db830e13c6c74d to your computer and use it in GitHub Desktop.
Map strong spots to reciprocal space and print x, y, z positions
# Print reciprocal space positions from DIALS strong reflections
# after spot finding
#
# Usage:
#
# dials.import (data)
# dials.find_spots imported.expt
# dials.python reciprocal_xyz.py strong.refl imported.expt
#
# Prints long list of x, y, z positions
import sys
from dials.array_family import flex
from dxtbx.model.experiment_list import ExperimentList
def map_reflections(reflection_file, experiment_file):
reflections = flex.reflection_table.from_file(reflection_file)
experiments = ExperimentList.from_file(experiment_file)
reflections.centroid_px_to_mm(experiments)
reflections.map_centroids_to_reciprocal_space(experiments)
rlp = reflections["rlp"]
for x, y, z in rlp:
print(f"{x} {y} {z}")
if __name__ == "__main__":
map_reflections(sys.argv[1], sys.argv[2])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment