def test_lazy(self):
     vs = self.vs.as_lazy()
     vs_ref = vs.inav[0, 0]
     D = get_DisplacementGradientMap(vs, vs_ref)
     assert D.axes_manager.navigation_shape == (2, 4)
     assert D.axes_manager.signal_shape == (3, 3)
     strain_map = D.get_strain_maps()
def test_trivial_weight_function_case(xy_vectors):
    """ If weights are [1,1,1,1] the result should be the same as weights=None"""
    weights = [1, 1, 1, 1]
    four_vectors = np.asarray([[1, 0, 1, 1], [0, 1, -1, 1]])
    deformed = hs.signals.Signal2D(generate_test_vectors(four_vectors))
    weight_strain_map = get_DisplacementGradientMap(
        deformed, four_vectors, weights=weights
    ).get_strain_maps()
    np.testing.assert_almost_equal(xy_vectors.data, weight_strain_map.data, decimal=2)
def test_weight_function_behaviour():
    """ Confirms that  a weight function [1,1,2,2] on [a,a,b,b] gives (2a+4b)/6 as the strain"""
    multi_vector_array = np.asarray([[1, 0, 1, 1], [0, 1, -1, 1]])
    strained_by_1pc_in_x = vector_operation(multi_vector_array,
                                            np.asarray([[1.01, 0],
                                                        [0, 1]]))  # first  2
    strained_by_2pc_in_x = vector_operation(multi_vector_array,
                                            np.asarray([[1.02, 0],
                                                        [0, 1]]))  # second 2
    weights = [1, 1, 2, 2]  # ((0.1*2 + 0.2*4)/6) = 0.166666
    vectors = np.concatenate(
        (strained_by_1pc_in_x[:, :2], strained_by_2pc_in_x[:, 2:]), axis=1)
    deformed = hs.signals.Signal2D(
        np.asarray([[vectors, vectors], [vectors, vectors]]))
    strain_map = get_DisplacementGradientMap(
        deformed, multi_vector_array, weights=weights).get_strain_maps()
    np.testing.assert_almost_equal(strain_map.inav[0].isig[0, 0].data[0],
                                   -1.0166666 + 1,
                                   decimal=2)
Beispiel #4
0
def Displacement_Grad_Map():
    xy = np.asarray([[1, 0], [0, 1]])
    deformed = hs.signals.Signal2D(generate_test_vectors(xy))
    D = get_DisplacementGradientMap(deformed, xy)
    return D
def generate_strain_map(vectors):
    deformed = hs.signals.Signal2D(generate_test_vectors(vectors))
    return get_DisplacementGradientMap(deformed, vectors).get_strain_maps()