本文整理汇总了Python中dxtbx.datablock.DataBlockFactory.from_args方法的典型用法代码示例。如果您正苦于以下问题:Python DataBlockFactory.from_args方法的具体用法?Python DataBlockFactory.from_args怎么用?Python DataBlockFactory.from_args使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dxtbx.datablock.DataBlockFactory
的用法示例。
在下文中一共展示了DataBlockFactory.from_args方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: files
# 需要导入模块: from dxtbx.datablock import DataBlockFactory [as 别名]
# 或者: from dxtbx.datablock.DataBlockFactory import from_args [as 别名]
action = "store_false", default = True,
help = "Don't sort input files (default is True)")
# Parse the command line arguments
(options, args) = parser.parse_args()
if len(args) == 0:
parser.print_help()
# Sort arguments
if options.sort:
args = sorted(args)
# Get the data blocks from the input files
# We've set verbose to print out files as they're tested.
unhandled = []
datablocks = DataBlockFactory.from_args(args,
verbose=options.verbose, unhandled=unhandled)
# Print out any unhandled files
if len(unhandled) > 0:
print '-' * 80
print 'The following command line arguments were not handled:'
for filename in unhandled:
print ' %s' % filename
# Loop through the data blocks
for i, datablock in enumerate(datablocks):
# Extract any sweeps
sweeps = datablock.extract_sweeps()
# Extract any stills
示例2: assert
# 需要导入模块: from dxtbx.datablock import DataBlockFactory [as 别名]
# 或者: from dxtbx.datablock.DataBlockFactory import from_args [as 别名]
from __future__ import division
if __name__ == '__main__':
import sys
from dxtbx.datablock import DataBlockFactory
from dxtbx.model import ParallaxCorrectedPxMmStrategy
datablocks = DataBlockFactory.from_args(sys.argv[1:])
assert(len(datablocks) == 1)
detectors = datablocks[0].unique_detectors()
assert(len(detectors) == 1)
detector = detectors[0]
assert(len(detector) == 1)
px_mm = detector[0].get_px_mm_strategy()
assert(isinstance(px_mm, ParallaxCorrectedPxMmStrategy))
print "Mu: %f mm^-1 " % px_mm.mu()
print "t0: %f mm" % px_mm.t0()
from matplotlib import pylab
from scitbx.array_family import flex
image_size = detector[0].get_image_size()[::-1]
xcorr = flex.double(flex.grid(image_size))
ycorr = flex.double(flex.grid(image_size))
pixel_size = detector[0].get_pixel_size()
for j in range(xcorr.all()[0]):
for i in range(xcorr.all()[1]):
x1, y1 = detector[0].pixel_to_millimeter((i,j))
x0, y0 = i * pixel_size[0], j * pixel_size[1]
xcorr[j,i] = x1 - x0
ycorr[j,i] = y1 - y0
vmin = min([flex.min(xcorr), flex.min(ycorr)])
示例3: run
# 需要导入模块: from dxtbx.datablock import DataBlockFactory [as 别名]
# 或者: from dxtbx.datablock.DataBlockFactory import from_args [as 别名]
def run(args):
import os
from libtbx.phil import command_line
from libtbx.utils import Sorry, Usage
if len(args) == 0:
from cStringIO import StringIO
s = StringIO()
master_phil_scope.show(out=s)
raise Usage("""\
dxtbx.export_bitmaps image_files [options]
% s
""" %s.getvalue())
from dxtbx.datablock import DataBlockFactory
unhandled = []
datablocks = DataBlockFactory.from_args(
args, verbose=False, unhandled=unhandled)
assert len(datablocks) > 0
imagesets = datablocks[0].extract_imagesets()
cmd_line = command_line.argument_interpreter(master_params=master_phil_scope)
working_phil = cmd_line.process_and_fetch(args=unhandled)
working_phil.show()
params = working_phil.extract()
brightness = params.brightness / 100
vendortype = "made up"
# check that binning is a power of 2
binning = params.binning
if not (binning > 0 and ((binning & (binning - 1)) == 0)):
raise Sorry("binning must be a power of 2")
output_dir = params.output_dir
if output_dir is None:
output_dir = "."
elif not os.path.exists(output_dir):
os.makedirs(output_dir)
from rstbx.slip_viewer.tile_generation \
import _get_flex_image, _get_flex_image_multipanel
for imageset in imagesets:
detector = imageset.get_detector()
panel = detector[0]
# XXX is this inclusive or exclusive?
saturation = panel.get_trusted_range()[1]
for i_image, image in enumerate(imageset):
if len(detector) > 1:
# FIXME This doesn't work properly, as flex_image.size2() is incorrect
# also binning doesn't work
assert binning == 1
flex_image = _get_flex_image_multipanel(
brightness=brightness,
panels=detector,
raw_data=image)
else:
flex_image = _get_flex_image(
brightness=brightness,
data=image,
binning=binning,
saturation=saturation,
vendortype=vendortype)
flex_image.setWindow(0, 0, 1)
flex_image.adjust(color_scheme=colour_schemes.get(params.colour_scheme))
# now export as a bitmap
flex_image.prep_string()
import Image
# XXX is size//binning safe here?
pil_img = Image.fromstring(
'RGB', (flex_image.size2()//binning,
flex_image.size1()//binning),
flex_image.export_string)
basename = os.path.basename(os.path.splitext(imageset.paths()[i_image])[0])
path = os.path.join(
output_dir, basename + '.' + params.format)
print "Exporting %s" %path
tmp_stream = open(path, 'wb')
pil_img.save(tmp_stream, format=params.format)
tmp_stream.close()