예제 #1
0
    def _goniometer(self):
        '''
    Create the goniometer model

    '''
        from dxtbx.model.goniometer import GoniometerFactory
        return GoniometerFactory.single_axis()
예제 #2
0
 def _goniometer(self):
     """
     Create the goniometer model
     """
     return GoniometerFactory.single_axis()
예제 #3
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])
예제 #4
0
def test_goniometer():
    """A test class for the goniometer class."""

    axis = (1, 0, 0)
    fixed = (1, 0, 0, 0, 1, 0, 0, 0, 1)

    xg = Goniometer(axis, fixed)

    assert len(xg.get_rotation_axis()) == 3
    assert len(xg.get_fixed_rotation()) == 9

    _compare_tuples(xg.get_rotation_axis(), axis)
    _compare_tuples(xg.get_fixed_rotation(), fixed)

    single = GoniometerFactory.single_axis()

    assert len(single.get_rotation_axis()) == 3
    assert len(single.get_fixed_rotation()) == 9

    _compare_tuples(single.get_rotation_axis(), axis)
    _compare_tuples(single.get_fixed_rotation(), fixed)

    kappa = GoniometerFactory.kappa(50.0, 0.0, 0.0, 0.0, "-y", "omega")

    assert len(kappa.get_rotation_axis()) == 3
    assert len(kappa.get_fixed_rotation()) == 9
    _compare_tuples(kappa.get_rotation_axis(), axis)
    _compare_tuples(kappa.get_fixed_rotation(), fixed)

    kappa = GoniometerFactory.kappa(50.0, 0.0, 0.0, 0.0, "-y", "omega")

    assert len(kappa.get_rotation_axis()) == 3
    assert len(kappa.get_fixed_rotation()) == 9

    _compare_tuples(kappa.get_rotation_axis(), axis)
    _compare_tuples(kappa.get_fixed_rotation(), fixed)

    kappa = GoniometerFactory.kappa(50.0, 0.0, 0.0, 0.0, "-y", "phi")

    assert len(kappa.get_rotation_axis()) == 3
    assert len(kappa.get_fixed_rotation()) == 9

    _compare_tuples(kappa.get_rotation_axis(), axis)
    _compare_tuples(kappa.get_fixed_rotation(), fixed)

    kappa = GoniometerFactory.kappa(50.0, 0.0, 30.0, 0.0, "-y", "omega")

    assert len(kappa.get_rotation_axis()) == 3
    assert len(kappa.get_fixed_rotation()) == 9

    _compare_tuples(kappa.get_rotation_axis(), axis)
    with pytest.raises(AssertionError):
        _compare_tuples(kappa.get_fixed_rotation(), fixed)

    import libtbx.load_env

    dxtbx_dir = libtbx.env.dist_path("dxtbx")

    image = os.path.join(dxtbx_dir, "tests", "phi_scan_001.cbf")
    assert GoniometerFactory.imgCIF(image)

    kappa = GoniometerFactory.kappa(50.0, -10.0, 30.0, 0.0, "-y", "phi")

    s = easy_pickle.dumps(kappa)
    kappa2 = easy_pickle.loads(s)
    assert kappa == kappa2

    image = os.path.join(dxtbx_dir, "tests", "omega_scan.cbf")
    assert GoniometerFactory.imgCIF(image)

    kappa = GoniometerFactory.kappa(50.0, -10.0, 30.0, 20.0, "-y", "omega")

    s = easy_pickle.dumps(kappa)
    kappa2 = easy_pickle.loads(s)
    assert kappa == kappa2
예제 #5
0
def test_goniometer():
    '''A test class for the goniometer class.'''

    axis = (1, 0, 0)
    fixed = (1, 0, 0, 0, 1, 0, 0, 0, 1)

    xg = Goniometer(axis, fixed)

    assert (len(xg.get_rotation_axis()) == 3)
    assert (len(xg.get_fixed_rotation()) == 9)

    assert (compare_tuples(xg.get_rotation_axis(), axis))
    assert (compare_tuples(xg.get_fixed_rotation(), fixed))

    single = GoniometerFactory.single_axis()

    assert (len(single.get_rotation_axis()) == 3)
    assert (len(single.get_fixed_rotation()) == 9)

    assert (compare_tuples(single.get_rotation_axis(), axis))
    assert (compare_tuples(single.get_fixed_rotation(), fixed))

    kappa = GoniometerFactory.kappa(50.0, 0.0, 0.0, 0.0, '-y', 'omega')

    assert (len(kappa.get_rotation_axis()) == 3)
    assert (len(kappa.get_fixed_rotation()) == 9)
    assert (compare_tuples(kappa.get_rotation_axis(), axis))
    assert (compare_tuples(kappa.get_fixed_rotation(), fixed))

    kappa = GoniometerFactory.kappa(50.0, 0.0, 0.0, 0.0, '-y', 'omega')

    assert (len(kappa.get_rotation_axis()) == 3)
    assert (len(kappa.get_fixed_rotation()) == 9)

    assert (compare_tuples(kappa.get_rotation_axis(), axis))
    assert (compare_tuples(kappa.get_fixed_rotation(), fixed))

    kappa = GoniometerFactory.kappa(50.0, 0.0, 0.0, 0.0, '-y', 'phi')

    assert (len(kappa.get_rotation_axis()) == 3)
    assert (len(kappa.get_fixed_rotation()) == 9)

    assert (compare_tuples(kappa.get_rotation_axis(), axis))
    assert (compare_tuples(kappa.get_fixed_rotation(), fixed))

    kappa = GoniometerFactory.kappa(50.0, 0.0, 30.0, 0.0, '-y', 'omega')

    assert (len(kappa.get_rotation_axis()) == 3)
    assert (len(kappa.get_fixed_rotation()) == 9)

    assert (compare_tuples(kappa.get_rotation_axis(), axis))
    assert (not compare_tuples(kappa.get_fixed_rotation(), fixed))

    import libtbx.load_env
    import os

    dxtbx_dir = libtbx.env.dist_path('dxtbx')

    image = os.path.join(dxtbx_dir, 'tests', 'phi_scan_001.cbf')
    cbf = GoniometerFactory.imgCIF(image)

    kappa = GoniometerFactory.kappa(50.0, -10.0, 30.0, 0.0, '-y', 'phi')

    s = easy_pickle.dumps(kappa)
    kappa2 = easy_pickle.loads(s)
    assert kappa == kappa2

    image = os.path.join(dxtbx_dir, 'tests', 'omega_scan.cbf')
    cbf = GoniometerFactory.imgCIF(image)

    kappa = GoniometerFactory.kappa(50.0, -10.0, 30.0, 20.0, '-y', 'omega')

    s = easy_pickle.dumps(kappa)
    kappa2 = easy_pickle.loads(s)
    assert kappa == kappa2

    print 'OK'
예제 #6
0
def test_goniometer():
    """A test class for the goniometer class."""

    axis = (1, 0, 0)
    fixed = (1, 0, 0, 0, 1, 0, 0, 0, 1)

    xg = Goniometer(axis, fixed)

    assert len(xg.get_rotation_axis()) == 3
    assert len(xg.get_fixed_rotation()) == 9

    _compare_tuples(xg.get_rotation_axis(), axis)
    _compare_tuples(xg.get_fixed_rotation(), fixed)

    single = GoniometerFactory.single_axis()

    assert len(single.get_rotation_axis()) == 3
    assert len(single.get_fixed_rotation()) == 9

    _compare_tuples(single.get_rotation_axis(), axis)
    _compare_tuples(single.get_fixed_rotation(), fixed)

    kappa = GoniometerFactory.kappa(50.0, 0.0, 0.0, 0.0, "-y", "omega")

    assert len(kappa.get_rotation_axis()) == 3
    assert len(kappa.get_fixed_rotation()) == 9
    _compare_tuples(kappa.get_rotation_axis(), axis)
    _compare_tuples(kappa.get_fixed_rotation(), fixed)

    kappa = GoniometerFactory.kappa(50.0, 0.0, 0.0, 0.0, "-y", "omega")

    assert len(kappa.get_rotation_axis()) == 3
    assert len(kappa.get_fixed_rotation()) == 9

    _compare_tuples(kappa.get_rotation_axis(), axis)
    _compare_tuples(kappa.get_fixed_rotation(), fixed)

    kappa = GoniometerFactory.kappa(50.0, 0.0, 0.0, 0.0, "-y", "phi")

    assert len(kappa.get_rotation_axis()) == 3
    assert len(kappa.get_fixed_rotation()) == 9

    _compare_tuples(kappa.get_rotation_axis(), axis)
    _compare_tuples(kappa.get_fixed_rotation(), fixed)

    kappa = GoniometerFactory.kappa(50.0, 0.0, 30.0, 0.0, "-y", "omega")

    assert len(kappa.get_rotation_axis()) == 3
    assert len(kappa.get_fixed_rotation()) == 9

    _compare_tuples(kappa.get_rotation_axis(), axis)
    with pytest.raises(AssertionError):
        _compare_tuples(kappa.get_fixed_rotation(), fixed)

    image = Path(__file__).parent / "phi_scan_001.cbf"
    assert GoniometerFactory.imgCIF(str(image))

    kappa = GoniometerFactory.kappa(50.0, -10.0, 30.0, 0.0, "-y", "phi")

    s = easy_pickle.dumps(kappa)
    kappa2 = easy_pickle.loads(s)
    assert kappa == kappa2

    image = Path(__file__).parent / "omega_scan.cbf"
    assert GoniometerFactory.imgCIF(str(image))

    kappa = GoniometerFactory.kappa(50.0, -10.0, 30.0, 20.0, "-y", "omega")

    s = easy_pickle.dumps(kappa)
    kappa2 = easy_pickle.loads(s)
    assert kappa == kappa2