本文整理汇总了Python中dxtbx.model.experiment.experiment_list.ExperimentList.append方法的典型用法代码示例。如果您正苦于以下问题:Python ExperimentList.append方法的具体用法?Python ExperimentList.append怎么用?Python ExperimentList.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dxtbx.model.experiment.experiment_list.ExperimentList
的用法示例。
在下文中一共展示了ExperimentList.append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generate_reflections
# 需要导入模块: from dxtbx.model.experiment.experiment_list import ExperimentList [as 别名]
# 或者: from dxtbx.model.experiment.experiment_list.ExperimentList import append [as 别名]
def generate_reflections(self):
# Build a mock scan for a 3 degree sweep
from dxtbx.model.scan import scan_factory
sf = scan_factory()
self.scan = sf.make_scan(image_range = (1,1),
exposure_times = 0.1,
oscillation = (0, 3.0),
epochs = range(1),
deg = True)
sweep_range = self.scan.get_oscillation_range(deg=False)
# Create a scans ExperimentList, only for generating reflections
experiments = ExperimentList()
experiments.append(Experiment(
beam=self.beam, detector=self.detector, goniometer=self.gonio, scan=self.scan,
crystal=self.crystal, imageset=None))
# Create a ScansRayPredictor
ray_predictor = ScansRayPredictor(experiments, sweep_range)
# Generate rays - only to work out which hkls are predicted
resolution = 2.0
index_generator = IndexGenerator(self.crystal.get_unit_cell(),
space_group(space_group_symbols(1).hall()).type(),
resolution)
indices = index_generator.to_array()
rays = ray_predictor.predict(indices)
# Make a standard reflection_table and copy in the ray data
self.reflections = flex.reflection_table.empty_standard(len(rays))
self.reflections.update(rays)
return
示例2: setup_models
# 需要导入模块: from dxtbx.model.experiment.experiment_list import ExperimentList [as 别名]
# 或者: from dxtbx.model.experiment.experiment_list.ExperimentList import append [as 别名]
def setup_models(args):
"""setup the experimental models"""
# Setup experimental models
master_phil = parse("""
include scope dials.test.algorithms.refinement.geometry_phil
""", process_includes=True)
models = setup_geometry.Extract(master_phil, cmdline_args = args)
detector = models.detector
goniometer = models.goniometer
crystal = models.crystal
beam = models.beam
# Build a mock scan for a 180 degree sweep
sf = scan_factory()
scan = sf.make_scan(image_range = (1,180),
exposure_times = 0.1,
oscillation = (0, 1.0),
epochs = range(180),
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, 1.0 * pi / 180.)
experiments = ExperimentList()
experiments.append(Experiment(
beam=beam, detector=detector, goniometer=goniometer,
scan=scan, crystal=crystal, imageset=None))
return experiments
示例3: experiment_list_for_crystal
# 需要导入模块: from dxtbx.model.experiment.experiment_list import ExperimentList [as 别名]
# 或者: from dxtbx.model.experiment.experiment_list.ExperimentList import append [as 别名]
def experiment_list_for_crystal(self, crystal):
experiments = ExperimentList()
for imageset in self.imagesets:
experiments.append(Experiment(imageset=imageset,
beam=imageset.get_beam(),
detector=imageset.get_detector(),
goniometer=imageset.get_goniometer(),
scan=imageset.get_scan(),
crystal=crystal))
return experiments
示例4: find_lattices
# 需要导入模块: from dxtbx.model.experiment.experiment_list import ExperimentList [as 别名]
# 或者: from dxtbx.model.experiment.experiment_list.ExperimentList import append [as 别名]
def find_lattices(self):
self.real_space_grid_search()
crystal_models = self.candidate_crystal_models
experiments = ExperimentList()
for cm in crystal_models:
for imageset in self.imagesets:
experiments.append(Experiment(imageset=imageset,
beam=imageset.get_beam(),
detector=imageset.get_detector(),
goniometer=imageset.get_goniometer(),
scan=imageset.get_scan(),
crystal=cm))
return experiments
示例5: combine_crystals
# 需要导入模块: from dxtbx.model.experiment.experiment_list import ExperimentList [as 别名]
# 或者: from dxtbx.model.experiment.experiment_list.ExperimentList import append [as 别名]
def combine_crystals(experiments):
'''Replace all crystals in the experiments list with the first crystal'''
from dxtbx.model.experiment.experiment_list import Experiment, ExperimentList
new_experiments=ExperimentList()
ref_crystal = experiments[0].crystal
for exp in experiments:
new_experiments.append(Experiment(beam=exp.beam,
detector=exp.detector,
scan=exp.scan,
goniometer=exp.goniometer,
crystal=ref_crystal,
imageset=exp.imageset))
return new_experiments
示例6: find_lattices
# 需要导入模块: from dxtbx.model.experiment.experiment_list import ExperimentList [as 别名]
# 或者: from dxtbx.model.experiment.experiment_list.ExperimentList import append [as 别名]
def find_lattices(self):
experiments = ExperimentList()
for cm in self.known_orientations:
# indexer expects crystals to be in primitive setting
space_group = cm.get_space_group()
cb_op_to_primitive \
= space_group.info().change_of_basis_op_to_primitive_setting()
cm = cm.change_basis(cb_op_to_primitive)
for imageset in self.imagesets:
experiments.append(Experiment(imageset=imageset,
beam=imageset.get_beam(),
detector=imageset.get_detector(),
goniometer=imageset.get_goniometer(),
scan=imageset.get_scan(),
crystal=cm))
return experiments
示例7: generate
# 需要导入模块: from dxtbx.model.experiment.experiment_list import ExperimentList [as 别名]
# 或者: from dxtbx.model.experiment.experiment_list.ExperimentList import append [as 别名]
def generate(self):
from dxtbx.model import Beam, Detector, Goniometer, Scan
# Initialise a list of experiments
experiments = ExperimentList()
# Create a few beams
b1 = Beam()
b2 = Beam()
b3 = Beam()
# Create a few detectors
d1 = Detector()
d2 = Detector()
d3 = Detector()
# Create a few goniometers
g1 = Goniometer()
g2 = Goniometer()
g3 = Goniometer()
# Create a few scans
s1 = Scan()
s2 = Scan()
s3 = Scan()
# Create a list of models
b = [b1, b2, b3, b2, b1]
d = [d1, d2, d3, d2, d1]
g = [g1, g2, g3, g2, g1]
s = [s1, s2, s3, s2, s1]
# Populate with various experiments
for i in range(5):
experiments.append(Experiment(
beam=b[i],
detector=d[i],
goniometer=g[i],
scan=s[i]))
# Return the list of experiments
return experiments
示例8: prepare_dxtbx_models
# 需要导入模块: from dxtbx.model.experiment.experiment_list import ExperimentList [as 别名]
# 或者: from dxtbx.model.experiment.experiment_list.ExperimentList import append [as 别名]
def prepare_dxtbx_models(self,setting_specific_ai,sg,isoform=None):
from dxtbx.model.beam import beam_factory
beam = beam_factory.simple(wavelength = self.inputai.wavelength)
from dxtbx.model.detector import detector_factory
detector = detector_factory.simple(
sensor = detector_factory.sensor("PAD"),
distance = setting_specific_ai.distance(),
beam_centre = [setting_specific_ai.xbeam(), setting_specific_ai.ybeam()],
fast_direction = "+x",
slow_direction = "+y",
pixel_size = [self.pixel_size,self.pixel_size],
image_size = [self.inputpd['size1'],self.inputpd['size1']],
)
direct = matrix.sqr(setting_specific_ai.getOrientation().direct_matrix())
from dxtbx.model.crystal import crystal_model
crystal = crystal_model(
real_space_a = matrix.row(direct[0:3]),
real_space_b = matrix.row(direct[3:6]),
real_space_c = matrix.row(direct[6:9]),
space_group_symbol = sg,
mosaicity = setting_specific_ai.getMosaicity()
)
if isoform is not None:
newB = matrix.sqr(isoform.fractionalization_matrix()).transpose()
crystal.set_B(newB)
from dxtbx.model.experiment.experiment_list import Experiment, ExperimentList
experiments = ExperimentList()
experiments.append(Experiment(beam=beam,
detector=detector,
crystal=crystal))
print beam
print detector
print crystal
return experiments
示例9: __call__
# 需要导入模块: from dxtbx.model.experiment.experiment_list import ExperimentList [as 别名]
# 或者: from dxtbx.model.experiment.experiment_list.ExperimentList import append [as 别名]
def __call__(self, experiments, reflections):
self.working_phil.show()
params = self.working_phil.extract()
for iexp, exp in enumerate(experiments):
print "Refining crystal", iexp
# reflection subset for a single experiment
refs = reflections.select(reflections['id'] == iexp)
refs['id'] = flex.size_t(len(refs),0)
# experiment list for a single experiment
exps=ExperimentList()
exps.append(exp)
refiner = RefinerFactory.from_parameters_data_experiments(
params, refs, exps, verbosity=1)
# do refinement
refiner.run()
refined_exps = refiner.get_experiments()
# replace this experiment with the refined one
experiments[iexp] = refined_exps[0]
return experiments
示例10: find_lattices
# 需要导入模块: from dxtbx.model.experiment.experiment_list import ExperimentList [as 别名]
# 或者: from dxtbx.model.experiment.experiment_list.ExperimentList import append [as 别名]
def find_lattices(self):
self.d_min = self.params.refinement_protocol.d_min_start
from rstbx.phil.phil_preferences import indexing_api_defs
import iotbx.phil
hardcoded_phil = iotbx.phil.parse(
input_string=indexing_api_defs).extract()
sel = (self.reflections['id'] == -1)
if self.d_min is not None:
sel &= (1/self.reflections['rlp'].norms() > self.d_min)
reflections = self.reflections.select(sel)
solutions = candidate_basis_vectors_fft1d(
reflections['rlp'], hardcoded_phil, max_cell=self.params.max_cell)
self.candidate_basis_vectors = solutions[0]
self.debug_show_candidate_basis_vectors()
if self.params.debug_plots:
self.debug_plot_candidate_basis_vectors()
self.candidate_crystal_models = self.find_candidate_orientation_matrices(
self.candidate_basis_vectors,
max_combinations=self.params.basis_vector_combinations.max_try)
crystal_model, n_indexed = self.choose_best_orientation_matrix(
self.candidate_crystal_models)
if crystal_model is not None:
crystal_models = [crystal_model]
else:
crystal_models = []
experiments = ExperimentList()
for cm in crystal_models:
for imageset in self.imagesets:
experiments.append(Experiment(imageset=imageset,
beam=imageset.get_beam(),
detector=imageset.get_detector(),
goniometer=imageset.get_goniometer(),
scan=imageset.get_scan(),
crystal=cm))
return experiments
示例11: do_work
# 需要导入模块: from dxtbx.model.experiment.experiment_list import ExperimentList [as 别名]
# 或者: from dxtbx.model.experiment.experiment_list.ExperimentList import append [as 别名]
def do_work(item):
iexp, exp = item
print "Refining crystal", iexp
# reflection subset for a single experiment
refs = reflections.select(reflections['id'] == iexp)
refs['id'] = flex.int(len(refs),0)
# DGW commented out as reflections.minimum_number_of_reflections no longer exists
#if len(refs) < params.refinement.reflections.minimum_number_of_reflections:
# print "Not enough reflections to refine experiment"
# return
# experiment list for a single experiment
exps=ExperimentList()
exps.append(exp)
try:
refiner = RefinerFactory.from_parameters_data_experiments(
params, refs, exps)
# do refinement
refiner.run()
except Exception, e:
print "Error,", str(e)
return
示例12: predict_reflections
# 需要导入模块: from dxtbx.model.experiment.experiment_list import ExperimentList [as 别名]
# 或者: from dxtbx.model.experiment.experiment_list.ExperimentList import append [as 别名]
def predict_reflections(self):
from dials.algorithms import shoebox
from dials.array_family import flex
from dxtbx.model.experiment.experiment_list import ExperimentList
from dxtbx.model.experiment.experiment_list import Experiment
from dials.algorithms.profile_model.gaussian_rs import Model
# Get models from the sweep
self.beam = self.sweep.get_beam()
self.detector = self.sweep.get_detector()
self.gonio = self.sweep.get_goniometer()
self.scan = self.sweep.get_scan()
sigma_b = self.beam.get_sigma_divergence(deg=True)
sigma_m = self.crystal.get_mosaicity(deg=True)
exlist = ExperimentList()
exlist.append(Experiment(
imageset=self.sweep,
beam=self.beam,
detector=self.detector,
goniometer=self.gonio,
scan=self.scan,
crystal=self.crystal,
profile=Model(
None, 3, sigma_b, sigma_m, deg=True)))
predicted = flex.reflection_table.from_predictions(exlist[0])
predicted['id'] = flex.int(len(predicted), 0)
predicted.compute_bbox(exlist)
# Find overlapping reflections
overlaps = shoebox.find_overlapping(predicted['bbox'])
# Return the reflections and overlaps
return predicted, overlaps
示例13: run
# 需要导入模块: from dxtbx.model.experiment.experiment_list import ExperimentList [as 别名]
# 或者: from dxtbx.model.experiment.experiment_list.ExperimentList import append [as 别名]
def run(verbose = False):
# Build models, with a larger crystal than default in order to get plenty of
# reflections on the 'still' image
overrides = """
geometry.parameters.crystal.a.length.range=40 50;
geometry.parameters.crystal.b.length.range=40 50;
geometry.parameters.crystal.c.length.range=40 50;
geometry.parameters.random_seed = 42"""
master_phil = parse("""
include scope dials.test.algorithms.refinement.geometry_phil
""", process_includes=True)
models = Extract(master_phil, overrides)
mydetector = models.detector
mygonio = models.goniometer
mycrystal = models.crystal
mybeam = models.beam
# Build a mock scan for a 3 degree sweep
from dxtbx.model.scan import scan_factory
sf = scan_factory()
myscan = sf.make_scan(image_range = (1,1),
exposure_times = 0.1,
oscillation = (0, 3.0),
epochs = range(1),
deg = True)
sweep_range = myscan.get_oscillation_range(deg=False)
# Create parameterisations of these models
det_param = DetectorParameterisationSinglePanel(mydetector)
s0_param = BeamParameterisation(mybeam, mygonio)
xlo_param = CrystalOrientationParameterisation(mycrystal)
xluc_param = CrystalUnitCellParameterisation(mycrystal)
# Create a scans ExperimentList, only for generating reflections
experiments = ExperimentList()
experiments.append(Experiment(
beam=mybeam, detector=mydetector, goniometer=mygonio, scan=myscan,
crystal=mycrystal, imageset=None))
# Create a stills ExperimentList
stills_experiments = ExperimentList()
stills_experiments.append(Experiment(
beam=mybeam, detector=mydetector, crystal=mycrystal, imageset=None))
# Generate rays - only to work out which hkls are predicted
ray_predictor = ScansRayPredictor(experiments, sweep_range)
resolution = 2.0
index_generator = IndexGenerator(mycrystal.get_unit_cell(),
space_group(space_group_symbols(1).hall()).type(),
resolution)
indices = index_generator.to_array()
rays = ray_predictor.predict(indices)
# Make a standard reflection_table and copy in the ray data
reflections = flex.reflection_table.empty_standard(len(rays))
reflections.update(rays)
# Build a standard prediction parameterisation for the stills experiment to do
# FD calculation (not used for its analytical gradients)
pred_param = StillsPredictionParameterisation(stills_experiments,
detector_parameterisations = [det_param],
beam_parameterisations = [s0_param],
xl_orientation_parameterisations = [xlo_param],
xl_unit_cell_parameterisations = [xluc_param])
# Make a managed SphericalRelpStillsReflectionPredictor reflection predictor
# for the first (only) experiment
ref_predictor = Predictor(stills_experiments)
# Predict these reflections in place. Must do this ahead of calculating
# the analytical gradients so quantities like s1 are correct
ref_predictor.update()
ref_predictor.predict(reflections)
# calculate analytical gradients
ag = AnalyticalGradients(stills_experiments,
detector_parameterisation=det_param,
beam_parameterisation=s0_param,
xl_orientation_parameterisation=xlo_param,
xl_unit_cell_parameterisation=xluc_param)
an_grads = ag.get_beam_gradients(reflections)
an_grads.update(ag.get_crystal_orientation_gradients(reflections))
an_grads.update(ag.get_crystal_unit_cell_gradients(reflections))
# get finite difference gradients
p_vals = pred_param.get_param_vals()
deltas = [1.e-7] * len(p_vals)
fd_grads = []
p_names = pred_param.get_param_names()
for i in range(len(deltas)):
# save parameter value
val = p_vals[i]
# calc reverse state
#.........这里部分代码省略.........
示例14: test1
# 需要导入模块: from dxtbx.model.experiment.experiment_list import ExperimentList [as 别名]
# 或者: from dxtbx.model.experiment.experiment_list.ExperimentList import append [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
#.........这里部分代码省略.........
示例15: scan_factory
# 需要导入模块: from dxtbx.model.experiment.experiment_list import ExperimentList [as 别名]
# 或者: from dxtbx.model.experiment.experiment_list.ExperimentList import append [as 别名]
sf = scan_factory()
myscan = sf.make_scan(image_range = (1,1800),
exposure_times = 0.1,
oscillation = (0, 0.1),
epochs = range(1800),
deg = True)
sweep_range = myscan.get_oscillation_range(deg=False)
im_width = myscan.get_oscillation(deg=False)[1]
assert sweep_range == (0., pi)
assert approx_equal(im_width, 0.1 * pi / 180.)
# Build ExperimentLists
experiments_single_panel = ExperimentList()
experiments_multi_panel = ExperimentList()
experiments_single_panel.append(Experiment(
beam=mybeam, detector=single_panel_detector, goniometer=mygonio,
scan=myscan, crystal=mycrystal, imageset=None))
experiments_multi_panel.append(Experiment(
beam=mybeam, detector=multi_panel_detector, goniometer=mygonio,
scan=myscan, crystal=mycrystal, imageset=None))
###########################
# Parameterise the models #
###########################
det_param = DetectorParameterisationSinglePanel(single_panel_detector)
s0_param = BeamParameterisation(mybeam, mygonio)
xlo_param = CrystalOrientationParameterisation(mycrystal)
xluc_param = CrystalUnitCellParameterisation(mycrystal)
multi_det_param = DetectorParameterisationMultiPanel(multi_panel_detector, mybeam)