本文整理汇总了Python中dxtbx.datablock.DataBlockFactory.from_serialized_format方法的典型用法代码示例。如果您正苦于以下问题:Python DataBlockFactory.from_serialized_format方法的具体用法?Python DataBlockFactory.from_serialized_format怎么用?Python DataBlockFactory.from_serialized_format使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dxtbx.datablock.DataBlockFactory
的用法示例。
在下文中一共展示了DataBlockFactory.from_serialized_format方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: datablock
# 需要导入模块: from dxtbx.datablock import DataBlockFactory [as 别名]
# 或者: from dxtbx.datablock.DataBlockFactory import from_serialized_format [as 别名]
def datablock(filename, check_format=True):
''' Load a given JSON or pickle file.
Params:
filename The input filename
Returns:
The datablock
'''
from dxtbx.datablock import DataBlockFactory
return DataBlockFactory.from_serialized_format(
filename, check_format=check_format)
示例2: deepcopy
# 需要导入模块: from dxtbx.datablock import DataBlockFactory [as 别名]
# 或者: from dxtbx.datablock.DataBlockFactory import from_serialized_format [as 别名]
print mycrystal
# get a CS-PAD detector for testing
import os
import libtbx.load_env
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",
"hierarchy_test")
datablock_path = os.path.join(data_dir, "datablock.json")
assert os.path.exists(datablock_path)
# load models
from dxtbx.datablock import DataBlockFactory
datablock = DataBlockFactory.from_serialized_format(datablock_path, check_format=False)
im_set = datablock[0].extract_imagesets()[0]
from copy import deepcopy
cspad = deepcopy(im_set.get_detector())
# get also a hierarchical type P6M detector
data_dir = os.path.join(dials_regression, "refinement_test_data",
"metrology", "i03-2.5A-thaumatin-20140514-split")
datablock_path = os.path.join(data_dir, "datablock.json")
datablock = DataBlockFactory.from_serialized_format(datablock_path, check_format=False)
im_set = datablock[0].extract_imagesets()[0]
from copy import deepcopy
p6m = deepcopy(im_set.get_detector())
print p6m[0]
# get a P12M (cropped to middle 18 modules)
示例3: test_refinement
# 需要导入模块: from dxtbx.datablock import DataBlockFactory [as 别名]
# 或者: from dxtbx.datablock.DataBlockFactory import from_serialized_format [as 别名]
def test_refinement():
'''Test a refinement run'''
dials_regression = libtbx.env.find_in_repositories(
relative_path="dials_regression",
test=os.path.isdir)
# Get a beam and detector from a datablock. This one has a CS-PAD, but that
# is irrelevant
data_dir = os.path.join(dials_regression, "refinement_test_data",
"hierarchy_test")
datablock_path = os.path.join(data_dir, "datablock.json")
assert os.path.exists(datablock_path)
# load models
from dxtbx.datablock import DataBlockFactory
datablock = DataBlockFactory.from_serialized_format(datablock_path, check_format=False)
im_set = datablock[0].extract_imagesets()[0]
from copy import deepcopy
detector = deepcopy(im_set.get_detector())
beam = im_set.get_beam()
# Invent a crystal, goniometer and scan for this test
from dxtbx.model.crystal import crystal_model
crystal = crystal_model((40.,0.,0.) ,(0.,40.,0.), (0.,0.,40.),
space_group_symbol = "P1")
orig_xl = deepcopy(crystal)
from dxtbx.model.experiment import goniometer_factory
goniometer = goniometer_factory.known_axis((1., 0., 0.))
# Build a mock scan for a 180 degree sweep
from dxtbx.model.scan import scan_factory
sf = scan_factory()
scan = sf.make_scan(image_range = (1,1800),
exposure_times = 0.1,
oscillation = (0, 0.1),
epochs = range(1800),
deg = True)
sweep_range = scan.get_oscillation_range(deg=False)
im_width = scan.get_oscillation(deg=False)[1]
assert sweep_range == (0., pi)
assert approx_equal(im_width, 0.1 * pi / 180.)
from dxtbx.model.experiment.experiment_list import ExperimentList, Experiment
# Build an experiment list
experiments = ExperimentList()
experiments.append(Experiment(
beam=beam, detector=detector, goniometer=goniometer,
scan=scan, crystal=crystal, imageset=None))
# simulate some reflections
refs, _ = generate_reflections(experiments)
# change unit cell a bit (=0.1 Angstrom length upsets, 0.1 degree of
# alpha and beta angles)
from dials.algorithms.refinement.parameterisation.crystal_parameters import \
CrystalUnitCellParameterisation
xluc_param = CrystalUnitCellParameterisation(crystal)
xluc_p_vals = xluc_param.get_param_vals()
cell_params = crystal.get_unit_cell().parameters()
cell_params = [a + b for a, b in zip(cell_params, [0.1, -0.1, 0.1, 0.1,
-0.1, 0.0])]
from cctbx.uctbx import unit_cell
from rstbx.symmetry.constraints.parameter_reduction import \
symmetrize_reduce_enlarge
from scitbx import matrix
new_uc = unit_cell(cell_params)
newB = matrix.sqr(new_uc.fractionalization_matrix()).transpose()
S = symmetrize_reduce_enlarge(crystal.get_space_group())
S.set_orientation(orientation=newB)
X = tuple([e * 1.e5 for e in S.forward_independent_parameters()])
xluc_param.set_param_vals(X)
# reparameterise the crystal at the perturbed geometry
xluc_param = CrystalUnitCellParameterisation(crystal)
# Dummy parameterisations for other models
beam_param = None
xlo_param = None
det_param = None
# parameterisation of the prediction equation
from dials.algorithms.refinement.parameterisation.parameter_report import \
ParameterReporter
pred_param = TwoThetaPredictionParameterisation(experiments,
det_param, beam_param, xlo_param, [xluc_param])
param_reporter = ParameterReporter(det_param, beam_param,
xlo_param, [xluc_param])
# reflection manager
refman = TwoThetaReflectionManager(refs, experiments, nref_per_degree=20,
verbosity=2)
# reflection predictor
ref_predictor = TwoThetaExperimentsPredictor(experiments)
# target function
target = TwoThetaTarget(experiments, ref_predictor, refman, pred_param)
#.........这里部分代码省略.........
示例4: test1
# 需要导入模块: from dxtbx.datablock import DataBlockFactory [as 别名]
# 或者: from dxtbx.datablock.DataBlockFactory import from_serialized_format [as 别名]
def test1():
dials_regression = libtbx.env.find_in_repositories(
relative_path="dials_regression",
test=os.path.isdir)
# use a datablock that contains a CS-PAD detector description
data_dir = os.path.join(dials_regression, "refinement_test_data",
"hierarchy_test")
datablock_path = os.path.join(data_dir, "datablock.json")
assert os.path.exists(datablock_path)
# load models
from dxtbx.datablock import DataBlockFactory
datablock = DataBlockFactory.from_serialized_format(datablock_path, check_format=False)
im_set = datablock[0].extract_imagesets()[0]
from copy import deepcopy
detector = deepcopy(im_set.get_detector())
beam = im_set.get_beam()
# we'll invent a crystal, goniometer and scan for this test
from dxtbx.model.crystal import crystal_model
crystal = crystal_model((40.,0.,0.) ,(0.,40.,0.), (0.,0.,40.),
space_group_symbol = "P1")
from dxtbx.model.experiment import goniometer_factory
goniometer = goniometer_factory.known_axis((1., 0., 0.))
# Build a mock scan for a 180 degree sweep
from dxtbx.model.scan import scan_factory
sf = scan_factory()
scan = sf.make_scan(image_range = (1,1800),
exposure_times = 0.1,
oscillation = (0, 0.1),
epochs = range(1800),
deg = True)
sweep_range = scan.get_oscillation_range(deg=False)
im_width = scan.get_oscillation(deg=False)[1]
assert sweep_range == (0., pi)
assert approx_equal(im_width, 0.1 * pi / 180.)
from dxtbx.model.experiment.experiment_list import ExperimentList, Experiment
# Build an experiment list
experiments = ExperimentList()
experiments.append(Experiment(
beam=beam, detector=detector, goniometer=goniometer,
scan=scan, crystal=crystal, imageset=None))
# simulate some reflections
refs, ref_predictor = generate_reflections(experiments)
# move the detector quadrants apart by 2mm both horizontally and vertically
from dials.algorithms.refinement.parameterisation \
import DetectorParameterisationHierarchical
det_param = DetectorParameterisationHierarchical(detector, level=1)
det_p_vals = det_param.get_param_vals()
p_vals = list(det_p_vals)
p_vals[1] += 2
p_vals[2] -= 2
p_vals[7] += 2
p_vals[8] += 2
p_vals[13] -= 2
p_vals[14] += 2
p_vals[19] -= 2
p_vals[20] -= 2
det_param.set_param_vals(p_vals)
# reparameterise the detector at the new perturbed geometry
det_param = DetectorParameterisationHierarchical(detector, level=1)
# parameterise other models
from dials.algorithms.refinement.parameterisation.beam_parameters import \
BeamParameterisation
from dials.algorithms.refinement.parameterisation.crystal_parameters import \
CrystalOrientationParameterisation, CrystalUnitCellParameterisation
beam_param = BeamParameterisation(beam, goniometer)
xlo_param = CrystalOrientationParameterisation(crystal)
xluc_param = CrystalUnitCellParameterisation(crystal)
# fix beam
beam_param.set_fixed([True]*3)
# fix crystal
xluc_param.set_fixed([True]*6)
xlo_param.set_fixed([True]*3)
# parameterisation of the prediction equation
from dials.algorithms.refinement.parameterisation.prediction_parameters import \
XYPhiPredictionParameterisation
from dials.algorithms.refinement.parameterisation.parameter_report import \
ParameterReporter
pred_param = XYPhiPredictionParameterisation(experiments,
[det_param], [beam_param], [xlo_param], [xluc_param])
param_reporter = ParameterReporter([det_param], [beam_param],
[xlo_param], [xluc_param])
# reflection manager and target function
from dials.algorithms.refinement.target import \
LeastSquaresPositionalResidualWithRmsdCutoff
#.........这里部分代码省略.........