def tst_from_phil(): from dxtbx.model.scan import ScanFactory, scan_phil_scope from libtbx.phil import parse params = scan_phil_scope.fetch( parse(''' scan { image_range = 1, 10 oscillation = (-4, 0.1) } ''')).extract() s1 = ScanFactory.from_phil(params) assert s1.get_num_images() == 10 assert s1.get_image_range() == (1, 10) assert s1.get_oscillation() == (-4, 0.1) params = scan_phil_scope.fetch( parse(''' scan { image_range = 1, 20 extrapolate_scan = True oscillation = (20, 0.01) } ''')).extract() s2 = ScanFactory.from_phil(params, s1) assert s2.get_num_images() == 20 assert s2.get_image_range() == (1, 20) assert s2.get_oscillation() == (20, 0.01) print 'OK'
def test_from_phil(): from dxtbx.model.scan import ScanFactory, scan_phil_scope from libtbx.phil import parse params = scan_phil_scope.fetch( parse( """ scan { image_range = 1, 10 oscillation = (-4, 0.1) } """ ) ).extract() s1 = ScanFactory.from_phil(params) assert s1.get_num_images() == 10 assert s1.get_image_range() == (1, 10) assert s1.get_oscillation() == (-4, 0.1) assert s1.get_batch_offset() == 0 assert s1.get_batch_range() == s1.get_image_range() for i in range(s1.get_image_range()[0], s1.get_image_range()[1] + 1): assert s1.get_batch_for_image_index(i) == i assert s1.get_batch_for_array_index(i - 1) == i params = scan_phil_scope.fetch( parse( """ scan { image_range = 1, 20 extrapolate_scan = True oscillation = (20, 0.01) batch_offset = 10 } """ ) ).extract() s2 = ScanFactory.from_phil(params, s1) assert s2.get_num_images() == 20 assert s2.get_image_range() == (1, 20) assert s2.get_oscillation() == (20, 0.01) assert s2.get_batch_offset() == 10 assert s2.get_batch_range() == (11, 30) ir1, ir2 = s2.get_image_range() for i in range(ir1, ir2): assert s2.get_batch_for_image_index(i) == i + s2.get_batch_offset() assert s2.is_batch_valid(s2.get_batch_for_image_index(i))