Esempio n. 1
0
  def __init__(self,
               pickle_path,
               sweep_path,
               extra_args,
               expected_unit_cell,
               expected_rmsds,
               expected_hall_symbol,
               n_expected_lattices=1,
               relative_length_tolerance=0.005,
               absolute_angle_tolerance=0.5):

    args = ["dials.index", pickle_path, sweep_path] + extra_args

    cwd = os.path.abspath(os.curdir)
    tmp_dir = open_tmp_directory(suffix="test_dials_index")
    os.chdir(tmp_dir)
    command = " ".join(args)
    print command
    result = easy_run.fully_buffered(command=command).raise_if_errors()
    os.chdir(cwd)
    assert os.path.exists(os.path.join(tmp_dir, "experiments.json"))
    experiments_list = dxtbx_load.experiment_list(
      os.path.join(tmp_dir, "experiments.json"), check_format=False)
    assert len(experiments_list.crystals()) == n_expected_lattices, (
      len(experiments_list.crystals()), n_expected_lattices)
    assert os.path.exists(os.path.join(tmp_dir, "indexed.pickle"))
    from libtbx.utils import time_log
    unpickling_timer = time_log("unpickling")
    self.calc_rmsds_timer = time_log("calc_rmsds")
    unpickling_timer.start()
    self.indexed_reflections = load.reflections(os.path.join(tmp_dir, "indexed.pickle"))
    unpickling_timer.stop()
    for i in range(len(experiments_list)):
      experiment = experiments_list[i]
      self.crystal_model = experiment.crystal
      #assert self.crystal_model.get_unit_cell().is_similar_to(
        #expected_unit_cell,
        #relative_length_tolerance=relative_length_tolerance,
        #absolute_angle_tolerance=absolute_angle_tolerance), (
          #self.crystal_model.get_unit_cell().parameters(),
          #expected_unit_cell.parameters())
      assert unit_cells_are_similar(
        self.crystal_model.get_unit_cell(),expected_unit_cell,
        relative_length_tolerance=relative_length_tolerance,
        absolute_angle_tolerance=absolute_angle_tolerance), (
          self.crystal_model.get_unit_cell().parameters(),
          expected_unit_cell.parameters())
      sg = self.crystal_model.get_space_group()
      assert sg.type().hall_symbol() == expected_hall_symbol, (
        sg.type().hall_symbol(), expected_hall_symbol)
      reflections = self.indexed_reflections.select(
        self.indexed_reflections['id'] == i)
      mi = reflections['miller_index']
      assert (mi != (0,0,0)).count(False) == 0
      reflections = reflections.select(mi != (0,0,0))
      self.rmsds = self.get_rmsds_obs_pred(reflections, experiment)
      for actual, expected in zip(self.rmsds, expected_rmsds):
        assert actual <= expected, "%s %s" %(self.rmsds, expected_rmsds)
    if 0:
      print self.calc_rmsds_timer.legend
      print unpickling_timer.report()
      print self.calc_rmsds_timer.report()
def load_input(exp_path, ref_path):
  refs = load_dials.reflections(ref_path)
  exp = load_dxtbx.experiment_list(exp_path , check_format=False)[0]
  return refs, exp
Esempio n. 3
0
def load_input(exp_path, ref_path):

    refs = load_dials.reflections(ref_path)
    exp = load_dxtbx.experiment_list(exp_path, check_format=False)[0]
    return refs, exp
Esempio n. 4
0
from __future__ import division


if __name__ == '__main__':
  import sys
  from dials.model.serialize import load
  from matplotlib import pylab
  from scitbx.array_family import flex
  rlist = load.reflections(sys.argv[1])
  I = [r.intensity for r in rlist]
  for r in rlist:
    print "Background: %f, Intensity: %f" % (
      flex.mean(r.shoebox_background), r.intensity)
  pylab.plot(I)
  pylab.show()
Esempio n. 5
0



from dials.model.serialize import load
spots2 = load.reflections('strong2.pickle')
print spots2[52776]
#for i, s in enumerate(spots2):
#    x, y, z = s.centroid_position
#    if z >= 357 and z < 372:
#        if x >= 1240 and x < 1250:
#            print i, x, y, z
#    if i == 49807:
#        print s

spots = load.reflections('strong.pickle')

#dx, dy, dz = [], [], []
#for s1, s2 in zip(spots, spots2):
#    dx.append(s1.centroid_variance[0] - s2.centroid_variance[0])
#    dx.append(s1.centroid_variance[1] - s2.centroid_variance[1])
#    dx.append(s1.centroid_variance[2] - s2.centroid_variance[2])

#from matplotlib import pylab
#pylab.plot(dx)
#pylab.show()

#for s1, s2 in zip(spots, spots2):
#    print s1.centroid_variance, s2.centroid_variance

#from dials.algorithms.centroid import ComputeCentroid
    try:
        assert(abs(a - b) < eps)
    except Exception, e:
        print a, b
        raise e

import sys
from dials.model.data import ReflectionList

filename1 = sys.argv[1]
filename2 = sys.argv[2]

from dials.model.serialize import load
from cctbx.array_family import flex

refl1 = load.reflections(filename1)
refl2 = load.reflections(filename2)

print "Length: ", len(refl1), len(refl2)
#assert(len(refl1) == len(refl2))

refl1 = ReflectionList([r for r in refl1 if r.is_valid()])
refl2 = ReflectionList([r for r in refl2 if r.is_valid()])

num_valid1 = len([r for r in refl1 if r.is_valid()])
num_valid2 = len([r for r in refl2 if r.is_valid()])
print "Valid: ", num_valid1, num_valid2
assert(num_valid1 == num_valid2)
from scitbx import matrix
print "Checking"
for r1, r2 in zip(refl1, refl2):
Esempio n. 7
0
from __future__ import division
from __future__ import print_function

if __name__ == "__main__":
    import sys
    from dials.model.serialize import load
    from matplotlib import pylab
    from scitbx.array_family import flex

    rlist = load.reflections(sys.argv[1])
    I = [r.intensity for r in rlist]
    for r in rlist:
        print("Background: %f, Intensity: %f" %
              (flex.mean(r.shoebox_background), r.intensity))
    pylab.plot(I)
    pylab.show()
Esempio n. 8
0
    def __init__(self,
                 pickle_path,
                 sweep_path,
                 extra_args,
                 expected_unit_cell,
                 expected_rmsds,
                 expected_hall_symbol,
                 n_expected_lattices=1,
                 relative_length_tolerance=0.005,
                 absolute_angle_tolerance=0.5):

        args = ["dials.index", pickle_path, sweep_path] + extra_args

        cwd = os.path.abspath(os.curdir)
        tmp_dir = open_tmp_directory(suffix="test_dials_index")
        os.chdir(tmp_dir)
        command = " ".join(args)
        print command
        result = easy_run.fully_buffered(command=command).raise_if_errors()
        os.chdir(cwd)
        assert os.path.exists(os.path.join(tmp_dir, "experiments.json"))
        experiments_list = dxtbx_load.experiment_list(os.path.join(
            tmp_dir, "experiments.json"),
                                                      check_format=False)
        assert len(experiments_list.crystals()) == n_expected_lattices, (len(
            experiments_list.crystals()), n_expected_lattices)
        assert os.path.exists(os.path.join(tmp_dir, "indexed.pickle"))
        from libtbx.utils import time_log
        unpickling_timer = time_log("unpickling")
        self.calc_rmsds_timer = time_log("calc_rmsds")
        unpickling_timer.start()
        self.indexed_reflections = load.reflections(
            os.path.join(tmp_dir, "indexed.pickle"))
        unpickling_timer.stop()
        for i in range(len(experiments_list)):
            experiment = experiments_list[i]
            self.crystal_model = experiment.crystal
            #assert self.crystal_model.get_unit_cell().is_similar_to(
            #expected_unit_cell,
            #relative_length_tolerance=relative_length_tolerance,
            #absolute_angle_tolerance=absolute_angle_tolerance), (
            #self.crystal_model.get_unit_cell().parameters(),
            #expected_unit_cell.parameters())
            assert unit_cells_are_similar(
                self.crystal_model.get_unit_cell(),
                expected_unit_cell,
                relative_length_tolerance=relative_length_tolerance,
                absolute_angle_tolerance=absolute_angle_tolerance), (
                    self.crystal_model.get_unit_cell().parameters(),
                    expected_unit_cell.parameters())
            sg = self.crystal_model.get_space_group()
            assert sg.type().hall_symbol() == expected_hall_symbol, (
                sg.type().hall_symbol(), expected_hall_symbol)
            reflections = self.indexed_reflections.select(
                self.indexed_reflections['id'] == i)
            mi = reflections['miller_index']
            assert (mi != (0, 0, 0)).count(False) == 0
            reflections = reflections.select(mi != (0, 0, 0))
            self.rmsds = self.get_rmsds_obs_pred(reflections, experiment)
            for actual, expected in zip(self.rmsds, expected_rmsds):
                assert actual <= expected, "%s %s" % (self.rmsds,
                                                      expected_rmsds)
        if 0:
            print self.calc_rmsds_timer.legend
            print unpickling_timer.report()
            print self.calc_rmsds_timer.report()
Esempio n. 9
0
        assert abs(a - b) < eps
    except Exception as e:
        print(a, b)
        raise e


import sys
from dials.model.data import ReflectionList

filename1 = sys.argv[1]
filename2 = sys.argv[2]

from dials.model.serialize import load
from cctbx.array_family import flex

refl1 = load.reflections(filename1)
refl2 = load.reflections(filename2)

print("Length: ", len(refl1), len(refl2))
# assert(len(refl1) == len(refl2))

refl1 = ReflectionList([r for r in refl1 if r.is_valid()])
refl2 = ReflectionList([r for r in refl2 if r.is_valid()])

num_valid1 = len([r for r in refl1 if r.is_valid()])
num_valid2 = len([r for r in refl2 if r.is_valid()])
print("Valid: ", num_valid1, num_valid2)
assert num_valid1 == num_valid2
from scitbx import matrix

print("Checking")
Esempio n. 10
0
from __future__ import print_function

from dials.model.serialize import load

spots2 = load.reflections("strong2.pickle")
print(spots2[52776])
# for i, s in enumerate(spots2):
#    x, y, z = s.centroid_position
#    if z >= 357 and z < 372:
#        if x >= 1240 and x < 1250:
#            print i, x, y, z
#    if i == 49807:
#        print s

spots = load.reflections("strong.pickle")

# dx, dy, dz = [], [], []
# for s1, s2 in zip(spots, spots2):
#    dx.append(s1.centroid_variance[0] - s2.centroid_variance[0])
#    dx.append(s1.centroid_variance[1] - s2.centroid_variance[1])
#    dx.append(s1.centroid_variance[2] - s2.centroid_variance[2])

# from matplotlib import pylab
# pylab.plot(dx)
# pylab.show()

# for s1, s2 in zip(spots, spots2):
#    print s1.centroid_variance, s2.centroid_variance

# from dials.algorithms.centroid import ComputeCentroid