示例#1
0
def test_single_deprecation(image_test_dir):
    """Test out the ScanFactory."""

    with pytest.warns(DeprecationWarning):
        ScanFactory.single(
            scan_helper_image_files.template_directory_index_to_image(
                "image_###.dat", image_test_dir, 2
            ),
            None,
            1.0,
            18 + 0.5,
            0.5,
            1,
        )
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))
示例#3
0
    def _scan(self):
        """
        Create the scan object
        """
        from dxtbx.model.scan import ScanFactory

        configuration = self.header["configuration"]
        #   kappa_start = configuration['kappa_start']
        #   kappa_increment = configuration['kappa_increment']
        #   phi_start = configuration['phi_start']
        #   phi_increment = configuration['phi_increment']
        #   omega_start = configuration['omega_start']
        #   omega_increment = configuration['omega_increment']
        #   two_theta_start = configuration['two_theta_start']
        #   two_theta_increment = configuration['two_theta_increment']
        kappa_start = 0
        kappa_increment = 0
        phi_start = 0
        phi_increment = 0
        omega_start = 0
        omega_increment = 0
        two_theta_start = 0
        two_theta_increment = 0
        #   nimages = configuration['nimages']
        nimages = 1
        return ScanFactory.make_scan(
            image_range=(1, nimages),
            exposure_times=[0] * nimages,
            oscillation=(phi_start, phi_increment),
            epochs=[0] * nimages,
        )
示例#4
0
def work_xScanFactory():
    '''Test out the ScanFactory.'''

    import dxtbx
    directory = os.path.join(os.path.split(dxtbx.__file__)[0], 'tests')

    template = 'image_###.dat'

    xscans = [
        ScanFactory.single(
            scan_helper_image_files.template_directory_index_to_image(
                template, directory, j + 1),
            scan_helper_image_formats.FORMAT_CBF, 1.0, 18 + 0.5 * j, 0.5, j)
        for j in range(20)
    ]

    xscans.reverse()

    try:
        print sum(xscans[1:], xscans[0])
        print 'I should not see this message'
    except RuntimeError:
        pass

    xscans.sort()

    sum(xscans[1:], xscans[0])

    a = ScanFactory.add(xscans[:10])
    b = ScanFactory.add(xscans[10:])

    a + b

    filename = scan_helper_image_files.template_directory_index_to_image(
        template, directory, 1)

    assert (len(ScanFactory.search(filename)) == 20)

    (a + b)[1:5]
    (a + b)[:10]

    cbf = os.path.join(directory, 'phi_scan_001.cbf')

    print 'OK'
示例#5
0
def test_xScanFactory():
    """Test out the ScanFactory."""

    import dxtbx

    directory = os.path.join(os.path.split(dxtbx.__file__)[0], "tests")

    template = "image_###.dat"

    xscans = [
        ScanFactory.single(
            scan_helper_image_files.template_directory_index_to_image(
                template, directory, j + 1),
            scan_helper_image_formats.FORMAT_CBF,
            1.0,
            18 + 0.5 * j,
            0.5,
            j,
        ) for j in range(20)
    ]

    xscans.reverse()

    with pytest.raises(RuntimeError):
        print(sum(xscans[1:], xscans[0]))

    xscans.sort()

    sum(xscans[1:], xscans[0])

    a = ScanFactory.add(xscans[:10])
    b = ScanFactory.add(xscans[10:])

    a + b

    filename = scan_helper_image_files.template_directory_index_to_image(
        template, directory, 1)

    assert len(ScanFactory.search(filename)) == 20

    (a + b)[1:5]
    (a + b)[:10]
示例#6
0
def test_xScanFactory(image_test_dir):
    """Test out the ScanFactory."""

    template = "image_###.dat"

    xscans = [
        ScanFactory.single_file(
            scan_helper_image_files.template_directory_index_to_image(
                template, image_test_dir, j + 1
            ),
            1.0,
            18 + 0.5 * j,
            0.5,
            j,
        )
        for j in range(20)
    ]

    xscans.reverse()

    with pytest.raises(RuntimeError):
        print(sum(xscans[1:], xscans[0]))

    xscans.sort()

    sum(xscans[1:], xscans[0])

    a = ScanFactory.add(xscans[:10])
    b = ScanFactory.add(xscans[10:])

    a + b

    filename = scan_helper_image_files.template_directory_index_to_image(
        template, image_test_dir, 1
    )

    assert len(ScanFactory.search(filename)) == 20

    (a + b)[1:5]
    (a + b)[:10]
示例#7
0
 def _scan(self):
     """
     Create the scan object
     """
     phi_start = 0
     phi_increment = 0
     nimages = 1
     return ScanFactory.make_scan(
         image_range=(1, nimages),
         exposure_times=[0] * nimages,
         oscillation=(phi_start, phi_increment),
         epochs=[0] * nimages,
     )
示例#8
0
def work_xScanFactory():
  '''Test out the ScanFactory.'''

  import dxtbx
  directory = os.path.join(os.path.split(dxtbx.__file__)[0], 'tests')

  template = 'image_###.dat'

  xscans = [ScanFactory.single(
      scan_helper_image_files.template_directory_index_to_image(
          template, directory, j + 1), scan_helper_image_formats.FORMAT_CBF,
      1.0, 18 + 0.5 * j, 0.5, j) for j in range(20)]

  xscans.reverse()

  try:
    print sum(xscans[1:], xscans[0])
    print 'I should not see this message'
  except RuntimeError, e:
    pass
    def _scan(self):
        '''
    Create the scan object

    '''
        from dxtbx.model.scan import ScanFactory
        configuration = self.header['configuration']
        kappa_start = configuration['kappa_start']
        kappa_increment = configuration['kappa_increment']
        phi_start = configuration['phi_start']
        phi_increment = configuration['phi_increment']
        omega_start = configuration['omega_start']
        omega_increment = configuration['omega_increment']
        two_theta_start = configuration['two_theta_start']
        two_theta_increment = configuration['two_theta_increment']
        nimages = configuration['nimages']
        return ScanFactory.make_scan(image_range=(1, nimages),
                                     exposure_times=[0] * nimages,
                                     oscillation=(phi_start, phi_increment),
                                     epochs=[0] * nimages)
示例#10
0
          template, directory, j + 1), scan_helper_image_formats.FORMAT_CBF,
      1.0, 18 + 0.5 * j, 0.5, j) for j in range(20)]

  xscans.reverse()

  try:
    print sum(xscans[1:], xscans[0])
    print 'I should not see this message'
  except RuntimeError, e:
    pass

  xscans.sort()

  sum(xscans[1:], xscans[0])

  a = ScanFactory.add(xscans[:10])
  b = ScanFactory.add(xscans[10:])

  a + b

  filename = scan_helper_image_files.template_directory_index_to_image(
      template, directory, 1)

  assert(len(ScanFactory.search(filename)) == 20)

  (a + b)[1:5]
  (a + b)[:10]

  cbf = os.path.join(directory, 'phi_scan_001.cbf')

  print 'OK'
示例#11
0
    """
    include scope dials.test.algorithms.refinement.geometry_phil
    include scope dials.test.algorithms.refinement.minimiser_phil
    """,
    process_includes=True,
)

models = setup_geometry.Extract(master_phil, cmdline_args=args)

mydetector = models.detector
mygonio = models.goniometer
mycrystal = models.crystal
mybeam = models.beam

# Build a mock scan for a 180 degree sweep
sf = ScanFactory()
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)
temp = myscan.get_oscillation(deg=False)
im_width = temp[1] - temp[0]
assert sweep_range == (0.0, pi)
assert approx_equal(im_width, 0.1 * pi / 180.0)

# Build an experiment list
experiments = ExperimentList()
示例#12
0
from dxtbx.datablock import DataBlockFactory, DataBlockDumper
from dxtbx.imageset import ImageSetFactory, ImageSweep, ImageSetData
from dxtbx.model.goniometer import GoniometerFactory
from dxtbx.model.scan import ScanFactory
import glob, os, sys
"""
Modification of AB's prepare_sweep.py.
Usage: libtbx.python prepare_sweep.py img_dir start_img, end_img savefile
"""

root = sys.argv[1]
start, end = int(sys.argv[2]), int(sys.argv[3])

g = GoniometerFactory.single_axis()
s = ScanFactory.make_scan((start, end), 0, (0, 1), [0] * (end - start + 1))
sw = ImageSetFactory.from_template(template=os.path.join(
    root, "fft_frame_I_mf_####.cbf"),
                                   scan=s,
                                   goniometer=g,
                                   image_range=(start, end))
dump = DataBlockDumper(DataBlockFactory.from_imageset(sw))
dump.as_file(sys.argv[4])