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


Python ExperimentListFactory.from_json_file方法代码示例

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


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

示例1: tst_dump_formats

# 需要导入模块: from dxtbx.model.experiment.experiment_list import ExperimentListFactory [as 别名]
# 或者: from dxtbx.model.experiment.experiment_list.ExperimentListFactory import from_json_file [as 别名]
  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,代码行数:35,代码来源:tst_experiment_list.py

示例2: test1

# 需要导入模块: from dxtbx.model.experiment.experiment_list import ExperimentListFactory [as 别名]
# 或者: from dxtbx.model.experiment.experiment_list.ExperimentListFactory import from_json_file [as 别名]
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,代码行数:53,代码来源:tst_refine_multi_stills.py

示例3: tst_dump_empty_sweep

# 需要导入模块: from dxtbx.model.experiment.experiment_list import ExperimentListFactory [as 别名]
# 或者: from dxtbx.model.experiment.experiment_list.ExperimentListFactory import from_json_file [as 别名]
  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,代码行数:27,代码来源:tst_experiment_list.py

示例4: run

# 需要导入模块: from dxtbx.model.experiment.experiment_list import ExperimentListFactory [as 别名]
# 或者: from dxtbx.model.experiment.experiment_list.ExperimentListFactory import from_json_file [as 别名]
  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,代码行数:31,代码来源:tst_create_profile_model.py

示例5: test2

# 需要导入模块: from dxtbx.model.experiment.experiment_list import ExperimentListFactory [as 别名]
# 或者: from dxtbx.model.experiment.experiment_list.ExperimentListFactory import from_json_file [as 别名]
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,代码行数:49,代码来源:tst_refine_multi_stills.py

示例6: tst_from_json

# 需要导入模块: from dxtbx.model.experiment.experiment_list import ExperimentListFactory [as 别名]
# 或者: from dxtbx.model.experiment.experiment_list.ExperimentListFactory import from_json_file [as 别名]
  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,代码行数:45,代码来源:tst_experiment_list.py

示例7: test1

# 需要导入模块: from dxtbx.model.experiment.experiment_list import ExperimentListFactory [as 别名]
# 或者: from dxtbx.model.experiment.experiment_list.ExperimentListFactory import from_json_file [as 别名]
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,代码行数:45,代码来源:tst_refine.py

示例8: _refine

# 需要导入模块: from dxtbx.model.experiment.experiment_list import ExperimentListFactory [as 别名]
# 或者: from dxtbx.model.experiment.experiment_list.ExperimentListFactory import from_json_file [as 别名]
  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,代码行数:14,代码来源:tst_refine_multi_wedges.py

示例9: from_string

# 需要导入模块: from dxtbx.model.experiment.experiment_list import ExperimentListFactory [as 别名]
# 或者: from dxtbx.model.experiment.experiment_list.ExperimentListFactory import from_json_file [as 别名]
 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,代码行数:15,代码来源:phil.py

示例10: select_importer

# 需要导入模块: from dxtbx.model.experiment.experiment_list import ExperimentListFactory [as 别名]
# 或者: from dxtbx.model.experiment.experiment_list.ExperimentListFactory import from_json_file [as 别名]
 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,代码行数:16,代码来源:import_xds.py

示例11: regression

# 需要导入模块: from dxtbx.model.experiment.experiment_list import ExperimentListFactory [as 别名]
# 或者: from dxtbx.model.experiment.experiment_list.ExperimentListFactory import from_json_file [as 别名]
  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,代码行数:18,代码来源:tst_refine_multi_wedges.py

示例12: _create_profile_model

# 需要导入模块: from dxtbx.model.experiment.experiment_list import ExperimentListFactory [as 别名]
# 或者: from dxtbx.model.experiment.experiment_list.ExperimentListFactory import from_json_file [as 别名]
 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,代码行数:19,代码来源:screen.py

示例13: load_reference_geometry

# 需要导入模块: from dxtbx.model.experiment.experiment_list import ExperimentListFactory [as 别名]
# 或者: from dxtbx.model.experiment.experiment_list.ExperimentListFactory import from_json_file [as 别名]
  def load_reference_geometry(self):
    if self.params.input.reference_geometry is None: return

    try:
      ref_datablocks = DataBlockFactory.from_json_file(self.params.input.reference_geometry, check_format=False)
    except Exception:
      ref_datablocks = None
    if ref_datablocks is None:
      from dxtbx.model.experiment.experiment_list import ExperimentListFactory
      try:
        ref_experiments = ExperimentListFactory.from_json_file(self.params.input.reference_geometry, check_format=False)
      except Exception:
        raise Sorry("Couldn't load geometry file %s"%self.params.input.reference_geometry)
      assert len(ref_experiments.detectors()) == 1
      self.reference_detector = ref_experiments.detectors()[0]
    else:
      assert len(ref_datablocks) == 1 and len(ref_datablocks[0].unique_detectors()) == 1
      self.reference_detector = ref_datablocks[0].unique_detectors()[0]
开发者ID:dials,项目名称:dials,代码行数:20,代码来源:stills_process.py

示例14: test1

# 需要导入模块: from dxtbx.model.experiment.experiment_list import ExperimentListFactory [as 别名]
# 或者: from dxtbx.model.experiment.experiment_list.ExperimentListFactory import from_json_file [as 别名]
def test1():

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

    # use multiple scan small molecule data for this test
    data_dir = os.path.join(dials_regression, "xia2-28")
    prefix = ["20", "25", "30", "35"]
    exp_path = [e + "_integrated_experiments.json" for e in prefix]
    exp_path = [os.path.join(data_dir, e) for e in exp_path]
    pkl_path = [e + "_integrated.pickle" for e in prefix]
    pkl_path = [os.path.join(data_dir, e) for e in pkl_path]

    for pth in exp_path + pkl_path:
        assert os.path.exists(pth), "%s missing" % pth

    cmd = "dials.two_theta_refine " + " ".join(exp_path) + " " + " ".join(pkl_path) + " cif=refined_cell.cif"
    print cmd

    # work in a temporary directory
    cwd = os.path.abspath(os.curdir)
    tmp_dir = open_tmp_directory(suffix="test_dials_two_theta_refine")
    os.chdir(tmp_dir)
    try:
        result = easy_run.fully_buffered(command=cmd).raise_if_errors()
        ref_exp = ExperimentListFactory.from_json_file("refined_cell.json", check_format=False)
    finally:
        os.chdir(cwd)

    xls = ref_exp.crystals()
    assert len(xls) == 1  # crystal models should have been combined
    xl = xls[0]

    # test refined crystal model against expected values
    assert approx_equal(xl.get_unit_cell().parameters(), (5.428022880, 8.144145476, 12.039666971, 90.0, 90.0, 90.0))
    assert approx_equal(xl.get_cell_parameter_sd(), (9.58081e-5, 0.000149909, 0.000215765, 0, 0, 0))
    assert approx_equal(xl.get_cell_volume_sd(), 0.0116254298)

    print "OK"
    return
开发者ID:dials,项目名称:dials,代码行数:41,代码来源:tst_two_theta_refine.py

示例15: test1

# 需要导入模块: from dxtbx.model.experiment.experiment_list import ExperimentListFactory [as 别名]
# 或者: from dxtbx.model.experiment.experiment_list.ExperimentListFactory import from_json_file [as 别名]
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)

  cmd = "dials.slice_sweep " + experiments_path + " " + pickle_path + \
  ' "scan_range=1 20"'
  print cmd

  # work in a temporary directory
  cwd = os.path.abspath(os.curdir)
  tmp_dir = open_tmp_directory(suffix="test_dials_slice_sweep")
  os.chdir(tmp_dir)
  try:
    result = easy_run.fully_buffered(command=cmd).raise_if_errors()
    # load results
    sliced_exp = ExperimentListFactory.from_json_file("experiments_1_20.json",
                check_format=False)[0]
    with open("indexed_strong_1_20.pickle", "r") as f:
      sliced_refs = pickle.load(f)
  finally:
    os.chdir(cwd)

  # simple test of results
  assert sliced_exp.scan.get_image_range() == (1, 20)
  assert len(sliced_refs) == 3670

  print "OK"
  return
开发者ID:dials,项目名称:dials,代码行数:40,代码来源:tst_slice_sweep.py


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