Beispiel #1
0
def test_strain_mapping_affine_transform():
    latt = diffpy.structure.lattice.Lattice(3, 3, 3, 90, 90, 90)
    atom = diffpy.structure.atom.Atom(atype='Zn', xyz=[0, 0, 0], lattice=latt)
    structure = diffpy.structure.Structure(atoms=[atom], lattice=latt)
    ediff = DiffractionGenerator(300., 0.025)
    affines = [[[1, 0, 0], [0, 1, 0], [0, 0, 1]],
               [[1.04, 0, 0], [0, 1, 0], [0, 0, 1]],
               [[1.08, 0, 0], [0, 1, 0], [0, 0, 1]],
               [[1.12, 0, 0], [0, 1, 0], [0, 0, 1]]]

    data = []
    for affine in affines:
        # same coords as used for latt above
        latt_rot = diffpy.structure.lattice.Lattice(3, 3, 3, 90, 90, 90, baserot=affine)
        structure.placeInLattice(latt_rot)

        diff_dat = ediff.calculate_ed_data(structure, 2.5)
        dpi = sim_as_signal(diff_dat, 64, 0.02, 2.5)
        data.append(dpi.data)
    data = np.array(data)
    dp = ElectronDiffraction2D(data.reshape((2, 2, 64, 64)))

    m = dp.create_model()
    ref = ScalableReferencePattern(dp.inav[0, 0])
    m.append(ref)
    m.multifit()
    disp_grad = ref.construct_displacement_gradient()

    assert disp_grad.data.shape == np.asarray(affines).reshape(2, 2, 3, 3).shape
Beispiel #2
0
def test_function(diffraction_pattern):
    ref = ScalableReferencePattern(diffraction_pattern)
    x, y = _index_coords(diffraction_pattern.data)
    func = ref.function(x=x, y=y)
    np.testing.assert_almost_equal(func, diffraction_pattern.data)
Beispiel #3
0
def test_scalable_reference_pattern_init(diffraction_pattern):
    ref = ScalableReferencePattern(diffraction_pattern)
    assert isinstance(ref, ScalableReferencePattern)