<commit_before>import pycbf
from scitbx import matrix
import libtbx.load_env
import os
import math

have_dials_regression = libtbx.env.has_module("dials_regression")
assert(have_dials_regression)

dials_regression = libtbx.env.find_in_repositories(
  relative_path="dials_regression",
  test=os.path.isdir)

test_file = os.path.join(dials_regression, 'image_examples', 'DLS_I19',
                         'I19_P300k_00001.cbf')

handle = pycbf.cbf_handle_struct()
handle.read_widefile(test_file, pycbf.MSG_DIGEST)
crystal = handle.get_crystal_id()
gonio = handle.construct_goniometer()

# go find gonio axis names

handle.rewind_datablock()
handle.find_category('diffrn_measurement_axis')
assert(handle.count_rows() == gonio.axes)

gonio_axes = []

for j in range(handle.count_rows()):
  handle.rewind_column()
  handle.select_row(j)
  handle.find_column('axis_id')
  gonio_axes.append(handle.get_value())

# now get the axis information for these

axis_table = { }
scan_axis = None

for axis in gonio_axes:
  start, delta = handle.get_axis_setting(axis)
  axis_no = handle.count_axis_ancestors(axis)
  axis_table[axis_no] = {'vector':matrix.col(handle.get_axis_vector(axis)),
                         'start':start, 'delta':delta, 'name':axis}
  if delta:
    assert(not scan_axis), (scan_axis, axis, delta)
    scan_axis = axis

# now compute the pre-rotation, scan-rotation, post-rotation

total_r_before = matrix.sqr((1, 0, 0, 0, 1, 0, 0, 0, 1))
total_r_scan = matrix.sqr((1, 0, 0, 0, 1, 0, 0, 0, 1))
total_r_after = matrix.sqr((1, 0, 0, 0, 1, 0, 0, 0, 1))

d2r = math.pi / 180.0

scan = False

for j in sorted(axis_table):
  v = axis_table[j]['vector']
  s = d2r * axis_table[j]['start']<commit_msg>FIXME need to make sure rotations applied in right order<commit_after>import pycbf
from scitbx import matrix
import libtbx.load_env
import os
import math

have_dials_regression = libtbx.env.has_module("dials_regression")
assert(have_dials_regression)

dials_regression = libtbx.env.find_in_repositories(
  relative_path="dials_regression",
  test=os.path.isdir)

test_file = os.path.join(dials_regression, 'image_examples', 'DLS_I19',
                         'I19_P300k_00001.cbf')

handle = pycbf.cbf_handle_struct()
handle.read_widefile(test_file, pycbf.MSG_DIGEST)
crystal = handle.get_crystal_id()
gonio = handle.construct_goniometer()

# go find gonio axis names

handle.rewind_datablock()
handle.find_category('diffrn_measurement_axis')
assert(handle.count_rows() == gonio.axes)

gonio_axes = []

for j in range(handle.count_rows()):
  handle.rewind_column()
  handle.select_row(j)
  handle.find_column('axis_id')
  gonio_axes.append(handle.get_value())

# now get the axis information for these

axis_table = { }
scan_axis = None

for axis in gonio_axes:
  start, delta = handle.get_axis_setting(axis)
  axis_no = handle.count_axis_ancestors(axis)
  axis_table[axis_no] = {'vector':matrix.col(handle.get_axis_vector(axis)),
                         'start':start, 'delta':delta, 'name':axis}
  if delta:
    assert(not scan_axis), (scan_axis, axis, delta)
    scan_axis = axis

# now compute the pre-rotation, scan-rotation, post-rotation - FIXME need to 
# make sure that orientation of axis is being correctly applied...

total_r_before = matrix.sqr((1, 0, 0, 0, 1, 0, 0, 0, 1))
total_r_scan = matrix.sqr((1, 0, 0, 0, 1, 0, 0, 0, 1))
total_r_after = matrix.sqr((1, 0, 0, 0, 1, 0, 0, 0, 1))

d2r = math.pi / 180.0

scan = False

for j in sorted(axis_table):
  v = axis_table[j]['vector']
  s = d2r * axis_table[j]['start']
{'fraction_non_alphanumeric': 0.12644978783592645, 'fraction_numerical': 0.02545968882602546, 'mean_word_length': 4.666666666666667, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6877914', 'n_tokens_mistral': 1422, 'n_tokens_neox': 1327, 'n_words': 287}