コード例 #1
0
def test_ub_creation():
    u = mfl.UBMatrix(4, [1, 0, 0], [0, 1, 1])
    assert np.all(u.latparam == np.array([4, 4, 4, 90, 90, 90]))
    u = mfl.UBMatrix([4, 4.04, 4.9], [1, 0, 0], [0, 1, 0])
    assert np.all(u.latparam == np.array([4, 4.04, 4.9, 90, 90, 90]))
    u = mfl.UBMatrix([4, 4.04, 4.9, 90, 90, 120], [1, 0, 0], [0, 1, 0])
    assert np.all(u.latparam == np.array([4, 4.04, 4.9, 90, 90, 120]))
コード例 #2
0
def test_ub_ortho():
    u = mfl.UBMatrix(4.0, [1, 0, 0], [0, 0, 1])
    assert u.is_orthogonal
    coords = np.array([[1, 1, 0], [0, 1, 0], [2, 1, 0], [1, -1, 0]])
    assert u.convert(coords, 'rs', axis=0).shape == (4, 3)
    assert u.convert(coords.T, 'rs', axis=1).shape == (3, 4)
    assert np.isclose(u.theta, np.pi / 2)
コード例 #3
0
def test_ub_hex_ab():
    u = mfl.UBMatrix([4.0, 4.0, 5.0, 90, 90, 120], [1, 0, 0], [0, 1, 0],
                     [1, 0, 0], [0, 1, 0])
    assert not u.is_orthogonal
    coords = np.array([[1, 1, 0], [0, 1, 0], [2, 1, 0], [1, -1, 0]])
    assert u.convert(coords, 'rs', axis=0).shape == (4, 3)
    assert u.convert(coords.T, 'rs', axis=1).shape == (3, 4)
    assert np.isclose(u.theta, np.pi / 3)
    assert np.all(np.isclose(u.plot_x, [1, 0, 0]))
    assert np.all(np.isclose(u.plot_y_actual, [-0.5, 1, 0]))
    assert np.all(np.isclose(u.plot_y_nominal, [0, 1, 0]))
コード例 #4
0
def test_find_a3_a4():
    u = mfl.UBMatrix([3.9044, 3.9044, 3.9200, 90, 90, 90], [1, 1, 0],
                     [0, 0, 1])
    a3, a4 = mfl.ub.find_a3_a4([1, 1, 0],
                               ub_matrix=u,
                               ki=1.55,
                               kf=1.55,
                               sense=1)
    assert np.isclose(a3, -42.77, atol=0.1)
    assert np.isclose(a4, 94.47, atol=0.1)
    a3, a4 = mfl.ub.find_a3_a4([1, 1, 0],
                               ub_matrix=u,
                               ki=1.55,
                               kf=1.55,
                               sense=-1)
    assert np.isclose(a3, 42.77, atol=0.1)
    assert np.isclose(a4, -94.47, atol=0.1)
コード例 #5
0
# Apply custom UB-matrix and angle offsets without overriding raw data files, to save you headache 3 years later.
# By the way, using accidental Bragg reflection spurions is a great way to pinpoint offset values.
import multiflexxlib as mfl

# Creates a custom UB-matrix for when the one in data files is wrong.
u = mfl.UBMatrix(latparam=[4.87, 4.87, 3.3, 90, 90, 90],
                 hkl1=[1, 0, 0],
                 hkl2=[0, 0, 1])

a3_offset_dict = {
    58773: 2.0,
    '058774': 2.3
}  # Accepts integer or string for file names.
a4_offset = 1.2  # Just a number if the offset is consistent but non-zero.
df = mfl.read_and_bin(ub_matrix=u,
                      a3_offset=a3_offset_dict,
                      a4_offset=a4_offset)

# Now you can do your plotting.