Example #1
0
    def tst_from_null_sweep(self):
        from dxtbx.datablock import DataBlockFactory
        from dxtbx.imageset import NullReader, ImageSweep, SweepFileList
        from dxtbx.model import Beam, Detector, Goniometer, Scan

        sweep = ImageSweep(
            NullReader(SweepFileList("template_%2d.cbf", (0, 10))))
        sweep.set_beam(Beam((0, 0, 1)))
        sweep.set_detector(Detector())
        sweep.set_goniometer(Goniometer((1, 0, 0)))
        sweep.set_scan(Scan((1, 10), (0, 0.1)))

        # Create the datablock
        datablock = DataBlockFactory.from_imageset(sweep)
        assert (len(datablock) == 1)
        datablock = datablock[0]

        sweeps = datablock.extract_sweeps()
        assert (len(sweeps) == 1)
        assert (sweeps[0].get_beam() == sweep.get_beam())
        assert (sweeps[0].get_detector() == sweep.get_detector())
        assert (sweeps[0].get_goniometer() == sweep.get_goniometer())
        assert (sweeps[0].get_scan() == sweep.get_scan())

        print 'OK'
Example #2
0
  def tst_null_reader_sweep(self):
    from dxtbx.imageset import NullReader, ImageSweep, SweepFileList
    from dxtbx.model import Beam, Detector, Goniometer, Scan

    template = 'hello_world_%d.cbf'
    paths = [template % 1]

    # Create the null reader
    reader = NullReader(SweepFileList(template, (0, 1)))

    # Create the imageset
    imageset = ImageSweep(reader)

    # Try to get an item
    try:
      imageset[0]
      assert(False)
    except Exception:
      print 'OK'

    # Try to slice the imageset
    imageset2 = imageset[0:1]
    print 'OK'

    # Try some functions which should work
    assert(len(imageset) == 1)
    assert(imageset == imageset)
    assert(imageset.indices() == [0])
    assert(imageset.is_valid())
    assert(imageset.get_template() == template)
    print 'OK'

    # Get the image paths
    assert(imageset.paths() == paths)
    assert(imageset.get_path(0) == paths[0])
    print 'OK'

    imageset.set_beam(Beam())
    imageset.set_detector(Detector())
    imageset.set_goniometer(Goniometer())
    imageset.set_scan(Scan((1,1), (0, 1)))
    assert(isinstance(imageset.get_beam(), Beam))
    assert(isinstance(imageset.get_detector(), Detector))
    assert(isinstance(imageset.get_goniometer(), Goniometer))
    assert(isinstance(imageset.get_scan(), Scan))
    print 'OK'
Example #3
0
  def tst_from_null_sweep(self):
    from dxtbx.datablock import DataBlockFactory
    from dxtbx.imageset import NullReader, ImageSweep, SweepFileList
    from dxtbx.model import Beam, Detector, Goniometer, Scan

    sweep = ImageSweep(NullReader(SweepFileList("template_%2d.cbf", (0, 10))))
    sweep.set_beam(Beam((0, 0, 1)))
    sweep.set_detector(Detector())
    sweep.set_goniometer(Goniometer((1, 0, 0)))
    sweep.set_scan(Scan((1, 10), (0, 0.1)))

    # Create the datablock
    datablock = DataBlockFactory.from_imageset(sweep)
    assert(len(datablock) == 1)
    datablock = datablock[0]

    sweeps = datablock.extract_sweeps()
    assert(len(sweeps) == 1)
    assert(sweeps[0].get_beam() == sweep.get_beam())
    assert(sweeps[0].get_detector() == sweep.get_detector())
    assert(sweeps[0].get_goniometer() == sweep.get_goniometer())
    assert(sweeps[0].get_scan() == sweep.get_scan())

    print 'OK'