예제 #1
0
  def tst_dump_empty_sweep(self):
    from dxtbx.imageset import ImageSweep, NullReader, SweepFileList
    from dxtbx.model import Beam, Detector, Goniometer, Scan
    from dxtbx.model.crystal import crystal_model
    from uuid import uuid4

    imageset = ImageSweep(NullReader(SweepFileList("filename%01d.cbf", (0, 3))))
    imageset.set_beam(Beam((1, 0, 0)))
    imageset.set_detector(Detector())
    imageset.set_goniometer(Goniometer())
    imageset.set_scan(Scan((1, 3), (0.0, 1.0)))

    crystal = crystal_model((1, 0, 0), (0, 1, 0), (0, 0, 1), space_group_symbol=1)

    experiments = ExperimentListFactory.from_imageset_and_crystal(
      imageset, crystal)

    dump = ExperimentListDumper(experiments)
    filename = 'temp%s.json' % uuid4().hex
    dump.as_json(filename)
    experiments2 = ExperimentListFactory.from_json_file(filename,
                                                        check_format=False)
    self.check(experiments, experiments2)

    print 'OK'
예제 #2
0
  def tst_from_datablock(self):
    from dxtbx.imageset import ImageSweep, NullReader, SweepFileList
    from dxtbx.model import Beam, Detector, Goniometer, Scan
    from dxtbx.datablock import DataBlockFactory
    from dxtbx.model.crystal import crystal_model

    imageset = ImageSweep(NullReader(SweepFileList("filename%01d.cbf", (0, 2))))
    imageset.set_beam(Beam())
    imageset.set_detector(Detector())
    imageset.set_goniometer(Goniometer())
    imageset.set_scan(Scan((1, 2), (0, 1)))

    crystal = crystal_model((1, 0, 0), (0, 1, 0), (0, 0, 1), space_group_symbol=0)

    datablock = DataBlockFactory.from_imageset(imageset)

    experiments = ExperimentListFactory.from_datablock_and_crystal(
      datablock, crystal)

    assert(len(experiments) == 1)
    assert(experiments[0].imageset is not None)
    assert(experiments[0].beam is not None)
    assert(experiments[0].detector is not None)
    assert(experiments[0].goniometer is not None)
    assert(experiments[0].scan is not None)
    assert(experiments[0].crystal is not None)

    print 'OK'
예제 #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'
예제 #4
0
  def tst_null_reader_imageset(self):
    from dxtbx.imageset import NullReader, ImageSet
    from dxtbx.model import Beam, Detector

    paths = ['hello_world.cbf']

    # Create the null reader
    reader = NullReader(paths)

    # Create the imageset
    imageset = ImageSet(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())
    print 'OK'

    # Try to get models (expect failure)
    try:
      imageset.get_image_models(0)
      assert(False)
    except Exception:
      print 'OK'

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

    imageset.set_beam(Beam(), 0)
    imageset.set_detector(Detector(), 0)
    assert(isinstance(imageset.get_beam(0), Beam))
    assert(isinstance(imageset.get_detector(0), Detector))
    print 'OK'
예제 #5
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'
    def tst_from_imageset(self):
        from dxtbx.imageset import ImageSet, NullReader
        from dxtbx.model import Beam, Detector, Goniometer, Scan
        from dxtbx.model import Crystal

        imageset = ImageSet(NullReader(["filename.cbf"]))
        imageset.set_beam(Beam(), 0)
        imageset.set_detector(Detector(), 0)

        crystal = Crystal((1, 0, 0), (0, 1, 0), (0, 0, 1),
                          space_group_symbol="P1")

        experiments = ExperimentListFactory.from_imageset_and_crystal(
            imageset, crystal)

        assert (len(experiments) == 1)
        assert (experiments[0].imageset is not None)
        assert (experiments[0].beam is not None)
        assert (experiments[0].detector is not None)
        assert (experiments[0].crystal is not None)

        print 'OK'