当前位置: 首页>>代码示例>>Python>>正文


Python experiment_list.ExperimentListFactory类代码示例

本文整理汇总了Python中dxtbx.model.experiment.experiment_list.ExperimentListFactory的典型用法代码示例。如果您正苦于以下问题:Python ExperimentListFactory类的具体用法?Python ExperimentListFactory怎么用?Python ExperimentListFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ExperimentListFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: tst_dump_formats

  def tst_dump_formats(self):
    from uuid import uuid4
    from os.path import join
    import os

    os.environ['DIALS_REGRESSION'] = self.path

    # Get all the filenames
    filename1 = join(self.path, 'experiment_test_data', 'experiment_1.json')

    # Read all the experiment lists in
    elist1 = ExperimentListFactory.from_json_file(filename1)

    # Create the experiment list dumper
    dump = ExperimentListDumper(elist1)

    # Dump as JSON file and reload
    filename = 'temp%s.json' % uuid4().hex
    dump.as_json(filename)
    elist2 = ExperimentListFactory.from_json_file(filename)
    self.check(elist1, elist2)

    # Dump as split JSON file and reload
    filename = 'temp%s.json' % uuid4().hex
    dump.as_json(filename, split=True)
    elist2 = ExperimentListFactory.from_json_file(filename)
    self.check(elist1, elist2)

    # Dump as pickle and reload
    filename = 'temp%s.pickle' % uuid4().hex
    dump.as_pickle(filename)
    elist2 = ExperimentListFactory.from_pickle_file(filename)
    self.check(elist1, elist2)
开发者ID:dalekreitler,项目名称:cctbx-playground,代码行数:33,代码来源:tst_experiment_list.py

示例2: tst_dump_empty_sweep

  def tst_dump_empty_sweep(self):
    from dxtbx.imageset import ImageSweep, NullReader, SweepFileList
    from dxtbx.model import Beam, Detector, Goniometer, Scan
    from dxtbx.model.crystal import crystal_model
    from uuid import uuid4

    imageset = ImageSweep(NullReader(SweepFileList("filename%01d.cbf", (0, 3))))
    imageset.set_beam(Beam((1, 0, 0)))
    imageset.set_detector(Detector())
    imageset.set_goniometer(Goniometer())
    imageset.set_scan(Scan((1, 3), (0.0, 1.0)))

    crystal = crystal_model((1, 0, 0), (0, 1, 0), (0, 0, 1), space_group_symbol=1)

    experiments = ExperimentListFactory.from_imageset_and_crystal(
      imageset, crystal)

    dump = ExperimentListDumper(experiments)
    filename = 'temp%s.json' % uuid4().hex
    dump.as_json(filename)
    experiments2 = ExperimentListFactory.from_json_file(filename,
                                                        check_format=False)
    self.check(experiments, experiments2)

    print 'OK'
开发者ID:dalekreitler,项目名称:cctbx-playground,代码行数:25,代码来源:tst_experiment_list.py

示例3: test1

def test1():

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

  data_dir = os.path.join(dials_regression, "refinement_test_data",
                          "multi_stills")
  experiments_path = os.path.join(data_dir, "combined_experiments.json")
  reflections_path = os.path.join(data_dir, "combined_reflections.pickle")
  cmd = "dials.refine " + experiments_path + " " + reflections_path
  print cmd

  # work in a temporary directory
  cwd = os.path.abspath(os.curdir)
  tmp_dir = open_tmp_directory(suffix="tst_refine_multi_stills1")
  os.chdir(tmp_dir)
  try:
    result = easy_run.fully_buffered(command=cmd).raise_if_errors()
    # load results
    reg_exp = ExperimentListFactory.from_json_file(
                os.path.join(data_dir, "regression_experiments.json"),
                check_format=False)
    ref_exp = ExperimentListFactory.from_json_file("refined_experiments.json",
                check_format=False)
  finally:
    os.chdir(cwd)
    # clean up tmp dir
    shutil.rmtree(tmp_dir)
  print "OK"

  # compare results
  tol = 1e-5
  for b1, b2 in zip(reg_exp.beams(), ref_exp.beams()):
    assert b1.is_similar_to(b2, wavelength_tolerance=tol,
                                direction_tolerance=tol,
                                polarization_normal_tolerance=tol,
                                polarization_fraction_tolerance=tol)
    s0_1 = matrix.col(b1.get_unit_s0())
    s0_2 = matrix.col(b2.get_unit_s0())
    assert s0_1.accute_angle(s0_2, deg=True) < 0.0057 # ~0.1 mrad
  for c1, c2 in zip(reg_exp.crystals(), ref_exp.crystals()):
    assert c1.is_similar_to(c2)

  for d1, d2 in zip(reg_exp.detectors(), ref_exp.detectors()):
    assert d1.is_similar_to(d2,
      fast_axis_tolerance=1e-4, slow_axis_tolerance=1e-4, origin_tolerance=1e-2)

  print "OK"

  return
开发者ID:biochem-fan,项目名称:dials,代码行数:51,代码来源:tst_refine_multi_stills.py

示例4: tst_from_datablock

  def tst_from_datablock(self):
    from dxtbx.imageset import ImageSweep, NullReader, SweepFileList
    from dxtbx.model import Beam, Detector, Goniometer, Scan
    from dxtbx.datablock import DataBlockFactory
    from dxtbx.model.crystal import crystal_model

    imageset = ImageSweep(NullReader(SweepFileList("filename%01d.cbf", (0, 2))))
    imageset.set_beam(Beam())
    imageset.set_detector(Detector())
    imageset.set_goniometer(Goniometer())
    imageset.set_scan(Scan((1, 2), (0, 1)))

    crystal = crystal_model((1, 0, 0), (0, 1, 0), (0, 0, 1), space_group_symbol=0)

    datablock = DataBlockFactory.from_imageset(imageset)

    experiments = ExperimentListFactory.from_datablock_and_crystal(
      datablock, crystal)

    assert(len(experiments) == 1)
    assert(experiments[0].imageset is not None)
    assert(experiments[0].beam is not None)
    assert(experiments[0].detector is not None)
    assert(experiments[0].goniometer is not None)
    assert(experiments[0].scan is not None)
    assert(experiments[0].crystal is not None)

    print 'OK'
    pass
开发者ID:dalekreitler,项目名称:cctbx-playground,代码行数:29,代码来源:tst_experiment_list.py

示例5: tst_from_args

  def tst_from_args(self):
    from os.path import join
    from glob import glob

    # Get all the filenames
    filenames = [
      join(self.path, 'experiment_test_data', 'experiment_1.json'),
      join(self.path, 'experiment_test_data', 'experiment_2.json'),
      join(self.path, 'experiment_test_data', 'experiment_3.json'),
      join(self.path, 'experiment_test_data', 'experiment_4.json')]

    # Get the experiments from a list of filenames
    experiments = ExperimentListFactory.from_args(filenames)

    # Have 4 experiment
    assert(len(experiments) == 4)
    for i in range(4):
      assert(experiments[i].imageset is not None)
      assert(experiments[i].beam is not None)
      assert(experiments[i].detector is not None)
      assert(experiments[i].goniometer is not None)
      assert(experiments[i].scan is not None)

    # Test passed
    print 'OK'
开发者ID:dalekreitler,项目名称:cctbx-playground,代码行数:25,代码来源:tst_experiment_list.py

示例6: from_dict

 def from_dict(cls, obj):
   import json
   assert obj['__id__'] == 'Refiner'
   return_obj = cls()
   for k, v in obj.iteritems():
     if k == '_refinr_indexers':
       v_new = {}
       for k_, v_ in v.iteritems():
         from libtbx.utils import import_python_object
         integrater_cls = import_python_object(
           import_path=".".join((v_['__module__'], v_['__name__'])),
           error_prefix='', target_must_be='', where_str='').object
         v_new[float(k_)] = integrater_cls.from_dict(v_)
       v = v_new
     elif k == '_refinr_payload':
       v_new = {}
       for k_, v_ in v.iteritems():
         try:
           v_new[float(k_)] = v_
         except ValueError, e:
           v_new[k_] = v_
       v = v_new
     if isinstance(v, dict):
       if v.get('__id__', None) == 'ExperimentList':
         from dxtbx.model.experiment.experiment_list import ExperimentListFactory
         v = ExperimentListFactory.from_dict(v, check_format=False)
     setattr(return_obj, k, v)
开发者ID:hainm,项目名称:xia2,代码行数:27,代码来源:Refiner.py

示例7: run

  def run(self):
    from os.path import join
    from libtbx import easy_run
    from dials.algorithms.profile_model.factory import phil_scope
    from libtbx.phil import parse
    from dxtbx.model.experiment.experiment_list import ExperimentListFactory

    # Call dials.create_profile_model
    easy_run.fully_buffered([
      'dials.create_profile_model',
      join(self.path, 'experiments.json'),
      join(self.path, 'indexed.pickle'),
    ]).raise_if_errors()


    experiments =  ExperimentListFactory.from_json_file(
      "experiments_with_profile_model.json",
      check_format=False)
    sigma_b = experiments[0].profile.sigma_b(deg=True)
    sigma_m = experiments[0].profile.sigma_m(deg=True)
    eps = 1e-3
    try:
      assert(abs(sigma_b - 0.02195) < eps)
      assert(abs(sigma_m - 0.06833) < eps)
    except Exception:
      print sigma_b
      print sigma_m
      raise
    print 'OK'
开发者ID:biochem-fan,项目名称:dials,代码行数:29,代码来源:tst_create_profile_model.py

示例8: test2

def test2():
  """Compare results of multiprocess vs single process refinement to ensure
  they are the same"""

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

  data_dir = os.path.join(dials_regression, "refinement_test_data",
                          "multi_stills")
  experiments_path = os.path.join(data_dir, "combined_experiments.json")
  reflections_path = os.path.join(data_dir, "combined_reflections.pickle")
  cmd = "dials.refine " + experiments_path + " " + reflections_path + \
        " outlier.algorithm=null engine=LBFGScurvs output.reflections=None "
  cmd1 = cmd + "output.experiments=refined_experiments_nproc1.json nproc=1"
  print cmd1

  cmd2= cmd + "output.experiments=refined_experiments_nproc4.json nproc=4"
  print cmd2
  # work in a temporary directory
  cwd = os.path.abspath(os.curdir)
  tmp_dir = open_tmp_directory(suffix="tst_refine_multi_stills2")
  os.chdir(tmp_dir)
  try:
    result1 = easy_run.fully_buffered(command=cmd1).raise_if_errors()
    result2 = easy_run.fully_buffered(command=cmd2).raise_if_errors()
    # load results
    nproc1 = ExperimentListFactory.from_json_file(
      "refined_experiments_nproc1.json", check_format=False)
    nproc4 = ExperimentListFactory.from_json_file(
      "refined_experiments_nproc4.json", check_format=False)
  finally:
    os.chdir(cwd)
    # clean up tmp dir
    shutil.rmtree(tmp_dir)
  print "OK"

  # compare results
  for b1, b2 in zip(nproc1.beams(), nproc4.beams()):
    assert b1.is_similar_to(b2)
  for c1, c2 in zip(nproc1.crystals(), nproc4.crystals()):
    assert c1.is_similar_to(c2)
  for d1, d2 in zip(nproc1.detectors(), nproc4.detectors()):
    assert d1.is_similar_to(d2,
      fast_axis_tolerance=5e-5, slow_axis_tolerance=5e-5, origin_tolerance=5e-5)
  print "OK"
  return
开发者ID:biochem-fan,项目名称:dials,代码行数:47,代码来源:tst_refine_multi_stills.py

示例9: tst_from_json

  def tst_from_json(self):
    from os.path import join
    import os

    os.environ['DIALS_REGRESSION'] = self.path

    # Get all the filenames
    filename1 = join(self.path, 'experiment_test_data', 'experiment_1.json')
    filename2 = join(self.path, 'experiment_test_data', 'experiment_2.json')
    filename3 = join(self.path, 'experiment_test_data', 'experiment_3.json')
    filename4 = join(self.path, 'experiment_test_data', 'experiment_4.json')

    # Read all the experiment lists in
    el1 = ExperimentListFactory.from_json_file(filename1)
    el2 = ExperimentListFactory.from_json_file(filename2)
    el3 = ExperimentListFactory.from_json_file(filename3)
    el4 = ExperimentListFactory.from_json_file(filename4)

    # All the experiment lists should be the same length
    assert(len(el1) == 1)
    assert(len(el1) == len(el2))
    assert(len(el1) == len(el3))
    assert(len(el1) == len(el4))

    # Check all the models are the same
    for e in zip(el1, el2, el3, el4):
      e1 = e[0]
      assert(e1.imageset is not None)
      assert(e1.beam is not None)
      assert(e1.detector is not None)
      assert(e1.goniometer is not None)
      assert(e1.scan is not None)
      assert(e1.crystal is not None)
      for ee in e[1:]:
        assert(e1.imageset == ee.imageset)
        assert(e1.beam == ee.beam)
        assert(e1.detector == ee.detector)
        assert(e1.goniometer == ee.goniometer)
        assert(e1.scan == ee.scan)
        assert(e1.crystal == ee.crystal)

    # test passed
    print 'OK'
开发者ID:dalekreitler,项目名称:cctbx-playground,代码行数:43,代码来源:tst_experiment_list.py

示例10: test1

def test1():

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

  # use the i04_weak_data for this test
  data_dir = os.path.join(dials_regression, "refinement_test_data", "i04_weak_data")
  experiments_path = os.path.join(data_dir, "experiments.json")
  pickle_path = os.path.join(data_dir, "indexed_strong.pickle")

  for pth in (experiments_path, pickle_path):
    assert os.path.exists(pth)

  # set close_to_spindle_cutoff to old default
  cmd = "dials.refine close_to_spindle_cutoff=0.05 reflections_per_degree=100 " + \
        experiments_path + " " + pickle_path
  print cmd

  # work in a temporary directory
  cwd = os.path.abspath(os.curdir)
  tmp_dir = open_tmp_directory(suffix="test_dials_refine")
  os.chdir(tmp_dir)
  try:
    result = easy_run.fully_buffered(command=cmd).raise_if_errors()
    # load results
    reg_exp = ExperimentListFactory.from_json_file(
                os.path.join(data_dir, "regression_experiments.json"),
                check_format=False)[0]
    ref_exp = ExperimentListFactory.from_json_file("refined_experiments.json",
                check_format=False)[0]
  finally:
    os.chdir(cwd)
    # clean up tmp dir
    shutil.rmtree(tmp_dir)

  # test refined models against expected
  assert reg_exp.crystal == ref_exp.crystal
  assert reg_exp.detector == ref_exp.detector
  assert reg_exp.beam == ref_exp.beam

  print "OK"
  return
开发者ID:biochem-fan,项目名称:dials,代码行数:43,代码来源:tst_refine.py

示例11: _refine

  def _refine(self):
    """Do refinement and load the results"""

    # turn off outlier rejection so that test takes about 4s rather than 10s
    # set close_to_spindle_cutoff to old default
    cmd = ("dials.refine combined_experiments.json combined_reflections.pickle"
           " outlier.algorithm=null close_to_spindle_cutoff=0.05")
    result = easy_run.fully_buffered(command=cmd).raise_if_errors()

    self._refined_experiments = ExperimentListFactory.from_json_file(
      "refined_experiments.json", check_format=False)
    return
开发者ID:dials,项目名称:dials,代码行数:12,代码来源:tst_refine_multi_wedges.py

示例12: from_string

 def from_string(self, s):
   from dxtbx.model.experiment.experiment_list import ExperimentListFactory
   from os.path import exists
   from libtbx.utils import Sorry
   if s is None:
     return None
   if s not in self.cache:
     if not exists(s):
       raise Sorry('File %s does not exist' % s)
     self.cache[s] = FilenameDataWrapper(s,
       ExperimentListFactory.from_json_file(s,
         check_format=self._check_format))
   return self.cache[s]
开发者ID:dials,项目名称:dials,代码行数:13,代码来源:phil.py

示例13: select_importer

 def select_importer(self, args):
   from os.path import split
   from dxtbx.model.experiment.experiment_list import ExperimentListFactory
   import libtbx.load_env
   path, filename = split(args[0])
   if filename == 'SPOT.XDS':
     return SpotXDSImporter(args[0])
   elif filename == 'INTEGRATE.HKL':
     assert(len(args) == 2)
     experiments = ExperimentListFactory.from_json_file(args[1])
     assert(len(experiments) == 1)
     return IntegrateHKLImporter(args[0], experiments[0])
   else:
     raise RuntimeError('expected (SPOT.XDS|INTEGRATE.HKL), got %s' % filename)
开发者ID:dials,项目名称:dials,代码行数:14,代码来源:import_xds.py

示例14: regression

  def regression(self):
    """Check results are as expected"""

    regression_experiments = ExperimentListFactory.from_json_file(
      os.path.join(self._data_dir, "regression_experiments.json"),
      check_format=False)

    for e1, e2 in zip(self._refined_experiments, regression_experiments):
      assert e1.crystal.is_similar_to(e2.crystal)
      # FIXME need is_similar_to for detector that checks geometry
      #assert e1.detector == e2.detector
      s0_1 = matrix.col(e1.beam.get_unit_s0())
      s0_2 = matrix.col(e1.beam.get_unit_s0())
      assert s0_1.accute_angle(s0_2, deg=True) < 0.0057 # ~0.1 mrad
    print "OK"
    return
开发者ID:dials,项目名称:dials,代码行数:16,代码来源:tst_refine_multi_wedges.py

示例15: _create_profile_model

 def _create_profile_model(self):
   info("\nCreating profile model...")
   command = [ "dials.create_profile_model", "experiments.json", "indexed.pickle" ]
   result = run_process(command, print_stdout=False, debug=procrunner_debug)
   debug("result = %s" % self._prettyprint_dictionary(result))
   if result['exitcode'] == 0:
     from dxtbx.model.experiment.experiment_list import ExperimentListFactory
     db = ExperimentListFactory.from_json_file('experiments_with_profile_model.json')[0]
     self._num_images = db.imageset.get_scan().get_num_images()
     self._oscillation = db.imageset.get_scan().get_oscillation()[1]
     self._sigma_m = db.profile.sigma_m()
     info("%d images, %s deg. oscillation, sigma_m=%.3f" % (self._num_images, str(self._oscillation), self._sigma_m))
     info("Successfully completed (%.1f sec)" % result['runtime'])
     return True
   else:
     warn("Failed with exit code %d" % result['exitcode'])
     return False
开发者ID:xia2,项目名称:i19,代码行数:17,代码来源:screen.py


注:本文中的dxtbx.model.experiment.experiment_list.ExperimentListFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。