本文整理汇总了Python中dxtbx.datablock.DataBlockFactory.from_filenames方法的典型用法代码示例。如果您正苦于以下问题:Python DataBlockFactory.from_filenames方法的具体用法?Python DataBlockFactory.from_filenames怎么用?Python DataBlockFactory.from_filenames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dxtbx.datablock.DataBlockFactory
的用法示例。
在下文中一共展示了DataBlockFactory.from_filenames方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: tst_json
# 需要导入模块: from dxtbx.datablock import DataBlockFactory [as 别名]
# 或者: from dxtbx.datablock.DataBlockFactory import from_filenames [as 别名]
def tst_json(self):
from dxtbx.datablock import DataBlockFactory
from dxtbx.imageset import ImageSweep
filenames = self.multiple_block_filenames()
blocks1 = DataBlockFactory.from_filenames(filenames)
blocks2 = self.encode_json_then_decode(blocks1)
assert(len(blocks2) == len(blocks1))
for b1, b2 in zip(blocks1, blocks2):
assert(b1.format_class() == b2.format_class())
assert(b1 == b2)
assert(blocks1 == blocks2)
filenames = self.multiple_block_filenames()
blocks1 = DataBlockFactory.from_filenames(filenames)
blocks2 = self.encode_json_then_decode(blocks1, check_format=False)
assert(len(blocks2) == len(blocks1))
for b1, b2 in zip(blocks1, blocks2):
for im1, im2 in zip(b1.extract_imagesets(), b2.extract_imagesets()):
assert(len(im1) == len(im2))
if isinstance(im1, ImageSweep):
assert(isinstance(im2, ImageSweep))
assert(im1.get_beam() == im2.get_beam())
assert(im1.get_detector() == im2.get_detector())
assert(im1.get_goniometer() == im2.get_goniometer())
assert(im1.get_scan() == im2.get_scan())
else:
assert(not isinstance(im2, ImageSweep))
for i in xrange(len(im1)):
assert(im1.get_beam(i) == im2.get_beam(i))
assert(im1.get_detector(i) == im2.get_detector(i))
print 'OK'
示例2: do_import
# 需要导入模块: from dxtbx.datablock import DataBlockFactory [as 别名]
# 或者: from dxtbx.datablock.DataBlockFactory import from_filenames [as 别名]
def do_import(filename):
info("Loading %s"%os.path.basename(filename))
datablocks = DataBlockFactory.from_filenames([filename])
if len(datablocks) == 0:
raise Abort("Could not load %s"%filename)
if len(datablocks) > 1:
raise Abort("Got multiple datablocks from file %s"%filename)
return datablocks[0]
示例3: __init__
# 需要导入模块: from dxtbx.datablock import DataBlockFactory [as 别名]
# 或者: from dxtbx.datablock.DataBlockFactory import from_filenames [as 别名]
def __init__(self,
source_image=None,
object_folder=None,
gain = 0.32,
params=None):
'''Initialise the script.'''
from dials.util.options import OptionParser
from dxtbx.datablock import DataBlockFactory
from dials.array_family import flex
from iotbx.phil import parse
from xfel.command_line.xfel_process import phil_scope
phil_scope = parse('''
include scope xfel.command_line.xtc_process.phil_scope
''', process_includes=True)
sub_phil_scope = parse('''
output {
cxi_merge_picklefile = None
.type = str
.help = Output integration results for each color data to separate cctbx.xfel-style pickle files
}
indexing {
stills {
ewald_proximity_resolution_cutoff = 2.0
.type = float
.help = For calculating the area under the green curve, or the acceptable
.help = volume of reciprocal space for spot prediction, use this high-resolution cutoff
}
}
cxi_merge {
include scope xfel.command_line.cxi_merge.master_phil
}
''', process_includes=True)
phil_scope.adopt_scope(sub_phil_scope)
# Create the parser
self.parser = OptionParser(
phil=phil_scope,
read_datablocks=True,
read_datablocks_from_images=True)
self.params = params
self.img = [source_image]
self.obj_base = object_folder
self.phil = phil_scope.extract()
with misc.Capturing() as junk_output:
self.datablock = DataBlockFactory.from_filenames(self.img)[0]
self.obj_filename = "int_{}".format(os.path.basename(self.img[0]))
self.phil.output.cxi_merge_picklefile = os.path.join(self.obj_base, self.img[0])
示例4: work
# 需要导入模块: from dxtbx.datablock import DataBlockFactory [as 别名]
# 或者: from dxtbx.datablock.DataBlockFactory import from_filenames [as 别名]
def work(filename, cl=[]):
from dials.command_line.find_spots import phil_scope as params
from dxtbx.datablock import DataBlockFactory
from dials.array_family import flex
interp = params.command_line_argument_interpreter()
for cla in cl:
params = params.fetch(interp.process(cla))
datablock = DataBlockFactory.from_filenames([filename])[0]
reflections = flex.reflection_table.from_observations(
datablock, params.extract())
detector = datablock.unique_detectors()[0]
beam = datablock.unique_beams()[0]
return analyse(reflections, detector, beam)
示例5: tst_pickling
# 需要导入模块: from dxtbx.datablock import DataBlockFactory [as 别名]
# 或者: from dxtbx.datablock.DataBlockFactory import from_filenames [as 别名]
def tst_pickling(self):
from dxtbx.datablock import DataBlockFactory
filenames = self.multiple_block_filenames()
blocks1 = DataBlockFactory.from_filenames(filenames)
blocks2 = self.pickle_then_unpickle(blocks1)
assert(len(blocks2) == len(blocks1))
for b1, b2 in zip(blocks1, blocks2):
assert(b1.format_class() == b2.format_class())
assert(b1 == b2)
assert(blocks1 == blocks2)
print 'OK'
示例6: tst_create_multiple_sweeps
# 需要导入模块: from dxtbx.datablock import DataBlockFactory [as 别名]
# 或者: from dxtbx.datablock.DataBlockFactory import from_filenames [as 别名]
def tst_create_multiple_sweeps(self):
from dxtbx.datablock import DataBlockFactory
filenames = self.multiple_sweep_filenames()
blocks = DataBlockFactory.from_filenames(filenames)
assert(len(blocks) == 1)
assert(blocks[0].num_images() == 6)
imageset = blocks[0].extract_imagesets()
assert(len(imageset) == 2)
sweeps = blocks[0].extract_sweeps()
assert(len(sweeps) == 2)
assert(len(sweeps[0]) == 3)
assert(len(sweeps[1]) == 3)
print 'OK'
示例7: OnChooseDirectory
# 需要导入模块: from dxtbx.datablock import DataBlockFactory [as 别名]
# 或者: from dxtbx.datablock.DataBlockFactory import from_filenames [as 别名]
def OnChooseDirectory (self, event) :
dir_name = self.dir_ctrl.GetPhilValue()
if (dir_name is not None) :
from dxtbx.datablock import DataBlockFactory
datablocks = DataBlockFactory.from_filenames([dir_name])
imagesets = datablocks[0].extract_imagesets()
self._imagesets = imagesets
#from iotbx.detectors import identify_dataset
#self._datasets = identify_dataset(dir_name)
#choices = [ d.format() for d in self._datasets ]
choices = [imgset.get_template() for imgset in self._imagesets]
self.stack_ctrl.SetItems(choices)
for i in range(len(choices)):
self.stack_ctrl.SetSelection(i)
示例8: __init__
# 需要导入模块: from dxtbx.datablock import DataBlockFactory [as 别名]
# 或者: from dxtbx.datablock.DataBlockFactory import from_filenames [as 别名]
def __init__(self,
source_image,
object_folder,
final_folder,
final_filename,
final,
logfile,
gain = 0.32,
params=None):
'''Initialise the script.'''
from dxtbx.datablock import DataBlockFactory
self.params = params
# Read settings from the DIALS target (.phil) file
# If none is provided, use default settings (and may God have mercy)
if self.params.dials.target != None:
with open(self.params.dials.target, 'r') as settings_file:
settings_file_contents = settings_file.read()
settings = parse(settings_file_contents)
current_phil = phil_scope.fetch(sources=[settings])
self.phil = current_phil.extract()
else:
self.phil = phil_scope.extract()
# Set general file-handling settings
file_basename = os.path.basename(source_image).split('.')[0]
self.phil.output.datablock_filename = "{}/{}.json".format(object_folder, file_basename)
self.phil.output.indexed_filename = "{}/{}_indexed.pickle".format(object_folder, file_basename)
self.phil.output.strong_filename = "{}/{}_strong.pickle".format(object_folder, file_basename)
self.phil.output.refined_experiments_filename = "{}/{}_refined_experiments.json".format(object_folder, file_basename)
self.phil.output.integrated_filename = "{}/{}_integrated.pickle".format(object_folder, file_basename)
self.phil.output.profile_filename = "{}/{}_profile.phil".format(object_folder, file_basename)
self.phil.output.integration_pickle = final_filename
self.int_log = logfile #"{}/int_{}.log".format(final_folder, file_basename)
self.img = [source_image]
self.obj_base = object_folder
self.gain = gain
self.fail = None
self.frame = None
self.final = final
self.final['final'] = final_filename
with misc.Capturing() as junk_output:
self.datablock = DataBlockFactory.from_filenames(self.img)[0]
self.obj_filename = "int_{}".format(os.path.basename(self.img[0]))
示例9: try_read_datablocks_from_images
# 需要导入模块: from dxtbx.datablock import DataBlockFactory [as 别名]
# 或者: from dxtbx.datablock.DataBlockFactory import from_filenames [as 别名]
def try_read_datablocks_from_images(self,
args,
verbose,
compare_beam,
compare_detector,
compare_goniometer,
scan_tolerance,
format_kwargs):
'''
Try to import images.
:param args: The input arguments
:param verbose: Print verbose output
:return: Unhandled arguments
'''
from dxtbx.datablock import DataBlockFactory
from dials.phil import FilenameDataWrapper, DataBlockConverters
from glob import glob
# If filenames contain wildcards, expand
args_new = []
for arg in args:
if "*" in arg:
args_new.extend(glob(arg))
else:
args_new.append(arg)
args = args_new
unhandled = []
datablocks = DataBlockFactory.from_filenames(
args,
verbose=verbose,
unhandled=unhandled,
compare_beam=compare_beam,
compare_detector=compare_detector,
compare_goniometer=compare_goniometer,
scan_tolerance=scan_tolerance,
format_kwargs=format_kwargs)
if len(datablocks) > 0:
filename = "<image files>"
obj = FilenameDataWrapper(filename, datablocks)
DataBlockConverters.cache[filename] = obj
self.datablocks.append(obj)
return unhandled
示例10: tst_create_multiple_blocks
# 需要导入模块: from dxtbx.datablock import DataBlockFactory [as 别名]
# 或者: from dxtbx.datablock.DataBlockFactory import from_filenames [as 别名]
def tst_create_multiple_blocks(self):
from dxtbx.datablock import DataBlockFactory
filenames = self.multiple_block_filenames()
blocks = DataBlockFactory.from_filenames(filenames, verbose=False)
assert(len(blocks) == 22)
# Block 1
assert(blocks[0].num_images() == 9)
imageset = blocks[0].extract_imagesets()
assert(len(imageset) == 1)
assert(len(imageset[0]) == 9)
sweeps = blocks[0].extract_sweeps()
assert(len(sweeps) == 1)
assert(len(sweeps[0]) == 9)
print 'OK'
示例11: __call__
# 需要导入模块: from dxtbx.datablock import DataBlockFactory [as 别名]
# 或者: from dxtbx.datablock.DataBlockFactory import from_filenames [as 别名]
def __call__(self):
'''
Import the datablocks
'''
from dxtbx.datablock import DataBlockTemplateImporter
from dxtbx.datablock import DataBlockFactory
from dials.util.options import flatten_datablocks
from libtbx.utils import Sorry
# Get the datablocks
datablocks = flatten_datablocks(self.params.input.datablock)
# Check we have some filenames
if len(datablocks) == 0:
format_kwargs = {
'dynamic_shadowing' : self.params.format.dynamic_shadowing
}
# Check if a template has been set and print help if not, otherwise try to
# import the images based on the template input
if len(self.params.input.template) > 0:
importer = DataBlockTemplateImporter(
self.params.input.template,
max(self.params.verbosity-1, 0),
format_kwargs=format_kwargs)
datablocks = importer.datablocks
if len(datablocks) == 0:
raise Sorry('No datablocks found matching template %s' % self.params.input.template)
elif len(self.params.input.directory) > 0:
datablocks = DataBlockFactory.from_filenames(
self.params.input.directory,
max(self.params.verbosity-1, 0),
format_kwargs=format_kwargs)
if len(datablocks) == 0:
raise Sorry('No datablocks found in directories %s' % self.params.input.directory)
else:
raise Sorry('No datablocks found')
if len(datablocks) > 1:
raise Sorry("More than 1 datablock found")
# Return the datablocks
return datablocks[0]
示例12: do_import
# 需要导入模块: from dxtbx.datablock import DataBlockFactory [as 别名]
# 或者: from dxtbx.datablock.DataBlockFactory import from_filenames [as 别名]
def do_import(filename):
logger.info("Loading %s"%os.path.basename(filename))
try:
datablocks = DataBlockFactory.from_json_file(filename)
except ValueError:
datablocks = DataBlockFactory.from_filenames([filename])
if len(datablocks) == 0:
raise Abort("Could not load %s"%filename)
if len(datablocks) > 1:
raise Abort("Got multiple datablocks from file %s"%filename)
# Ensure the indexer and downstream applications treat this as set of stills
from dxtbx.imageset import ImageSet
reset_sets = []
for imageset in datablocks[0].extract_imagesets():
imageset = ImageSet(imageset.reader(), imageset.indices())
imageset._models = imageset._models
imageset.set_scan(None)
imageset.set_goniometer(None)
reset_sets.append(imageset)
return DataBlockFactory.from_imageset(reset_sets)[0]
示例13: len
# 需要导入模块: from dxtbx.datablock import DataBlockFactory [as 别名]
# 或者: from dxtbx.datablock.DataBlockFactory import from_filenames [as 别名]
filenames = []
for arg in args:
if "indexing.data" in arg:
path = arg.split('=')[1]
if os.path.isdir(path):
for subfile in os.listdir(path):
subpath = os.path.join(path, subfile)
if os.path.isfile(subpath):
filenames.append(subpath)
else:
filenames.append(path)
print filenames
datablock = DataBlockFactory.from_filenames(filenames)[0]
observed = flex.reflection_table.from_observations(datablock, params)
observed.as_pickle("strong.pickle")
print "Number of observed reflections:", len(observed)
working_params = copy.deepcopy(params)
imagesets = datablock.extract_imagesets()
# old labelit
# from spotfinder.applications.xfel import cxi_phil
# horizons_phil = cxi_phil.cxi_versioned_extract(args)
print "indexing..."
t0 = clock()
示例14: index_from_files
# 需要导入模块: from dxtbx.datablock import DataBlockFactory [as 别名]
# 或者: from dxtbx.datablock.DataBlockFactory import from_filenames [as 别名]
def index_from_files(f_one,f_two,f_three):
import dxtbx
from iotbx.phil import parse
from dxtbx.datablock import DataBlockFactory
from dials.array_family import flex
from dials.algorithms.indexing.indexer import indexer_base
from dials.util.options import OptionParser
import copy
phil_scope_str='''
output {{
shoeboxes = True
.type = bool
.help = Save the raw pixel values inside the reflection shoeboxes.
}}
include scope dials.algorithms.spot_finding.factory.phil_scope
include scope dials.algorithms.indexing.indexer.index_only_phil_scope
include scope dials.algorithms.refinement.refiner.phil_scope
indexing.known_symmetry.unit_cell={0}
.type = unit_cell
indexing.known_symmetry.space_group={1}
.type = space_group
'''
phil_scope = parse(phil_scope_str.format(target_cell,target_sg), process_includes=True)
# from dials.util.options import OptionParser
parser = OptionParser(phil=phil_scope)
params, options = parser.parse_args(args=[], show_diff_phil=True)
params.refinement.parameterisation.scan_varying = False
params.indexing.method='real_space_grid_search'
# params.indexing.method='fft3d'
# params.indexing.max_cell=800
# params.spotfinder.filter.min_spot_size=3
filenames = [f_one,f_two,f_three]
datablock = DataBlockFactory.from_filenames(filenames)[0]
observed = flex.reflection_table.from_observations(datablock, params)
observed.as_pickle("strong.pickle")
print "Number of observed reflections:", len(observed)
working_params = copy.deepcopy(params)
imagesets = datablock.extract_imagesets()
print "indexing..."
t0 = time()
# new dials, fix by Aaron
idxr = indexer_base.from_parameters(observed, imagesets, params=params)
idxr.index()
tel = time()-t0
print "done indexing (",tel," sec)"
# new dials
indexed = idxr.refined_reflections
experiments = idxr.refined_experiments
print experiments.crystals()[0]
crystal_params = experiments.crystals()[0]
with open('crystal.pkl', 'wb') as output:
pickle.dump(crystal_params, output, pickle.HIGHEST_PROTOCOL)
return
示例15: run
# 需要导入模块: from dxtbx.datablock import DataBlockFactory [as 别名]
# 或者: from dxtbx.datablock.DataBlockFactory import from_filenames [as 别名]
#.........这里部分代码省略.........
if plot:
plot_stats(stats)
pyplot.clf()
if table:
print_table(stats)
print "Number of indexed lattices: ", (n_indexed > 0).count(True)
print "Number with valid d_min but failed indexing: ", (
(d_min_distl_method_1 > 0) &
(d_min_distl_method_2 > 0) &
(estimated_d_min > 0) &
(n_indexed == 0)).count(True)
n_rows = 10
n_rows = min(n_rows, len(n_spots_total))
perm_n_spots_total = flex.sort_permutation(n_spots_total, reverse=True)
print 'Top %i images sorted by number of spots:' %n_rows
print_table(stats, perm=perm_n_spots_total, n_rows=n_rows)
n_bins = 20
spot_count_histogram(
n_spots_total, n_bins=n_bins, filename='hist_n_spots_total.png', log=True)
spot_count_histogram(
n_spots_no_ice, n_bins=n_bins, filename='hist_n_spots_no_ice.png', log=True)
spot_count_histogram(
n_indexed.select(n_indexed > 0), n_bins=n_bins, filename='hist_n_indexed.png', log=False)
if len(crystals):
plot_unit_cell_histograms(crystals)
if params.stereographic_projections and len(crystals):
from dxtbx.datablock import DataBlockFactory
datablocks = DataBlockFactory.from_filenames(
[image_names[0]], verbose=False)
assert len(datablocks) == 1
imageset = datablocks[0].extract_imagesets()[0]
s0 = imageset.get_beam().get_s0()
# XXX what if no goniometer?
rotation_axis = imageset.get_goniometer().get_rotation_axis()
indices = ((1,0,0), (0,1,0), (0,0,1))
for i, index in enumerate(indices):
from cctbx import crystal, miller
from scitbx import matrix
miller_indices = flex.miller_index([index])
symmetry = crystal.symmetry(
unit_cell=crystals[0].get_unit_cell(),
space_group=crystals[0].get_space_group())
miller_set = miller.set(symmetry, miller_indices)
d_spacings = miller_set.d_spacings()
d_spacings = d_spacings.as_non_anomalous_array().expand_to_p1()
d_spacings = d_spacings.generate_bijvoet_mates()
miller_indices = d_spacings.indices()
# plane normal
d0 = matrix.col(s0).normalize()
d1 = d0.cross(matrix.col(rotation_axis)).normalize()
d2 = d1.cross(d0).normalize()
reference_poles = (d0, d1, d2)
from dials.command_line.stereographic_projection import stereographic_projection
projections = []
for cryst in crystals: