def test_experimentlist_dumper_dump_empty_sweep(tmpdir):
  tmpdir.chdir()
  from dxtbx.model import Beam, Detector, Goniometer, Scan
  from dxtbx.model import Crystal
  from dxtbx.format.Format import Format

  filenames = ["filename_%01d.cbf" % (i+1) for i in range(0, 2)]

  imageset = Format.get_imageset(
    filenames,
    beam = Beam((1, 0, 0)),
    detector = Detector(),
    goniometer = Goniometer(),
    scan = Scan((1,2), (0.0, 1.0)),
    as_sweep=True)

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

  experiments = ExperimentListFactory.from_imageset_and_crystal(
    imageset, crystal)

  dump = ExperimentListDumper(experiments)
  filename = 'temp.json'
  dump.as_json(filename)
  experiments2 = ExperimentListFactory.from_json_file(filename,
                                                      check_format=False)
  check(experiments, experiments2)
Beispiel #2
0
def test_experimentlist_factory_from_datablock():
    filenames = ["filename_%01d.cbf" % (i + 1) for i in range(0, 2)]

    imageset = Format.get_imageset(
        filenames,
        beam=Beam(),
        detector=Detector(),
        goniometer=Goniometer(),
        scan=Scan((1, 2), (0, 1)),
        as_sequence=True,
    )

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

    datablock = DataBlockFactory.from_imageset(imageset)
    assert datablock[0].format_class()

    experiments = ExperimentListFactory.from_datablock_and_crystal(
        datablock, crystal)

    assert len(experiments) == 1
    assert experiments[0].imageset
    assert experiments[0].beam
    assert experiments[0].detector is not None
    assert experiments[0].goniometer
    assert experiments[0].scan
    assert experiments[0].crystal
def test_experimentlist_factory_from_datablock():
  from dxtbx.model import Beam, Detector, Goniometer, Scan
  from dxtbx.datablock import DataBlockFactory
  from dxtbx.model import Crystal
  from dxtbx.format.Format import Format

  filenames = ["filename_%01d.cbf" % (i+1) for i in range(0, 2)]

  imageset = Format.get_imageset(
    filenames,
    beam = Beam(),
    detector = Detector(),
    goniometer = Goniometer(),
    scan = Scan((1,2), (0,1)),
    as_sweep=True)

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

  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
Beispiel #4
0
  def tst_from_null_sweep(self):
    from dxtbx.format.Format import Format
    from dxtbx.imageset import ImageSweep
    from dxtbx.model import Beam, Detector, Goniometer, Scan

    filenames = ["template_%2d.cbf" % (i+1) for i in range(0, 10)]
    sweep = Format.get_imageset(
      filenames,
      beam = Beam((0, 0, 1)),
      detector = Detector(),
      goniometer = Goniometer((1, 0, 0)),
      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'
Beispiel #5
0
    def tst_from_sweep(self):
        from dxtbx.model import Beam, Detector, Goniometer, Scan
        from dxtbx.model import Crystal
        from dxtbx.format.Format import Format

        filenames = ["filename_%01d.cbf" % (i + 1) for i in range(0, 2)]

        imageset = Format.get_imageset(filenames,
                                       beam=Beam(),
                                       detector=Detector(),
                                       goniometer=Goniometer(),
                                       scan=Scan((1, 2), (0, 1)),
                                       as_sweep=True)

        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].goniometer is not None)
        assert (experiments[0].scan is not None)
        assert (experiments[0].crystal is not None)

        print 'OK'
def test_experimentlist_to_datablock_imageset(dials_data):
    filenames = [
        str(f) for f in dials_data("thaumatin_grid_scan").listdir(
            "thau_3_2_*.cbf.bz2")
    ]
    imageset = Format.get_imageset(filenames, as_imageset=True)
    expts = ExperimentListFactory.from_imageset_and_crystal(imageset,
                                                            crystal=None)
    datablocks = expts.to_datablocks()
    assert len(datablocks) == 1
    assert datablocks[0].num_images() == len(expts) == len(imageset)
    assert len(datablocks[0].extract_imagesets()) == len(expts)
Beispiel #7
0
def test_experimentlist_factory_from_imageset():
    imageset = Format.get_imageset(["filename.cbf"], as_imageset=True)
    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
    assert experiments[0].beam
    assert experiments[0].detector is not None
    assert experiments[0].crystal
def test_experimentlist_factory_from_imageset():
    from dxtbx.model import Beam, Detector, Goniometer, Scan
    from dxtbx.model import Crystal
    from dxtbx.format.Format import Format

    imageset = Format.get_imageset(["filename.cbf"], as_imageset=True)
    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
def test_from_null_sweep():
    filenames = ["template_%2d.cbf" % (i + 1) for i in range(0, 10)]
    sweep = Format.get_imageset(filenames,
                                beam=Beam((0, 0, 1)),
                                detector=Detector(),
                                goniometer=Goniometer((1, 0, 0)),
                                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()
Beispiel #10
0
def test_from_null_sequence():
    filenames = ["template_%2d.cbf" % (i + 1) for i in range(0, 10)]
    sequence = Format.get_imageset(
        filenames,
        beam=Beam((0, 0, 1)),
        detector=Detector(),
        goniometer=Goniometer((1, 0, 0)),
        scan=Scan((1, 10), (0, 0.1)),
    )

    # Create the experiments
    experiments = ExperimentListFactory.from_sequence_and_crystal(sequence,
                                                                  crystal=None)
    assert len(experiments) == 1
    imagesets = experiments.imagesets()
    assert imagesets[0].get_format_class()
    assert len(imagesets) == 1
    assert imagesets[0].get_beam() == sequence.get_beam()
    assert imagesets[0].get_detector() == sequence.get_detector()
    assert imagesets[0].get_goniometer() == sequence.get_goniometer()
    assert imagesets[0].get_scan() == sequence.get_scan()
Beispiel #11
0
def test_from_null_sequence():
    filenames = ["template_%2d.cbf" % (i + 1) for i in range(0, 10)]
    sequence = Format.get_imageset(
        filenames,
        beam=Beam((0, 0, 1)),
        detector=Detector(),
        goniometer=Goniometer((1, 0, 0)),
        scan=Scan((1, 10), (0, 0.1)),
    )

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

    sequences = datablock.extract_sequences()
    assert len(sequences) == 1
    assert sequences[0].get_beam() == sequence.get_beam()
    assert sequences[0].get_detector() == sequence.get_detector()
    assert sequences[0].get_goniometer() == sequence.get_goniometer()
    assert sequences[0].get_scan() == sequence.get_scan()
Beispiel #12
0
def test_experimentlist_dumper_dump_empty_sequence(tmp_path):
    filenames = [tmp_path / f"filename_{i}.cbf" for i in range(1, 3)]

    imageset = Format.get_imageset(
        filenames,
        beam=Beam((1, 0, 0)),
        detector=Detector(),
        goniometer=Goniometer(),
        scan=Scan((1, 2), (0.0, 1.0)),
        as_sequence=True,
    )

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

    experiments = ExperimentListFactory.from_imageset_and_crystal(
        imageset, crystal)

    filename = tmp_path / "temp.json"
    experiments.as_json(filename)
    experiments2 = ExperimentListFactory.from_json_file(filename,
                                                        check_format=False)
    check(experiments, experiments2)
Beispiel #13
0
def test_experimentlist_factory_from_sweep():
    filenames = ["filename_%01d.cbf" % (i + 1) for i in range(0, 2)]

    imageset = Format.get_imageset(
        filenames,
        beam=Beam(),
        detector=Detector(),
        goniometer=Goniometer(),
        scan=Scan((1, 2), (0, 1)),
        as_sweep=True,
    )

    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].goniometer is not None
    assert experiments[0].scan is not None
    assert experiments[0].crystal is not None