コード例 #1
0
ファイル: test_create_res_sim.py プロジェクト: mfkiwl/fem
def test_extract_image_plane(sorted_nodes, axes):
    from fem.post.create_res_sim import extract_image_plane

    image_plane = extract_image_plane(sorted_nodes, axes, 0.0)

    assert image_plane.shape == (11, 11)
    assert image_plane[0][0] == 11
    assert image_plane[0][-1] == 1221
    assert image_plane[-1][0] == 121
    assert image_plane[-1][-1] == 1331

    # the ele_post kwarg is deprecated and should now raise a TypeError if
    # passed
    with pytest.raises(TypeError):
        image_plane = extract_image_plane(sorted_nodes, axes, ele_pos=0.0)

    assert image_plane.shape == (11, 11)
    assert image_plane[0][0] == 11
    assert image_plane[0][-1] == 1221
    assert image_plane[-1][0] == 121
    assert image_plane[-1][-1] == 1331

    image_plane = extract_image_plane(sorted_nodes,
                                      axes,
                                      plane_pos=0.0,
                                      direction=1)

    assert image_plane.shape == (11, 11)
    assert image_plane[0][0] == 1
    assert image_plane[0][-1] == 1211
    assert image_plane[-1][0] == 11
    assert image_plane[-1][-1] == 1221

    image_plane = extract_image_plane(sorted_nodes,
                                      axes,
                                      plane_pos=0.0,
                                      direction=2)

    assert image_plane.shape == (11, 11)
    assert image_plane[0][0] == 1211  #11
    assert image_plane[0][-1] == 1321  #121
    assert image_plane[-1][0] == 1221  #1
    assert image_plane[-1][-1] == 1331  #111

    with pytest.raises(ValueError):
        image_plane = extract_image_plane(sorted_nodes,
                                          axes,
                                          plane_pos=0.0,
                                          direction=3)
コード例 #2
0
def test_extract_arfi_data():
    """test extraction of arfi data at specific timesteps
    """
    from fem.post.create_res_sim import extract_arfi_data
    from fem.post.create_res_sim import read_header
    from fem.post.create_res_sim import extract_image_plane
    from fem.mesh.fem_mesh import load_nodeIDs_coords
    from fem.mesh.fem_mesh import SortNodeIDs
    from scipy.io import loadmat
    import numpy as np

    gauss_qsym_pml_example_path = examplesPath / "gauss_qsym_pml"
    dispout = gauss_qsym_pml_example_path / "disp.dat.xz"
    nodedyn = gauss_qsym_pml_example_path / "nodes.dyn"
    valid_data = loadmat(gauss_qsym_pml_example_path / "res_sim_valid.mat")['arfidata']
    
    header = read_header(dispout)
    node_id_coords = load_nodeIDs_coords(nodedyn)
    [snic, axes] = SortNodeIDs(node_id_coords)
    image_plane = extract_image_plane(snic, axes)

    test_data0 = extract_arfi_data(dispout, header, image_plane)
    test_data1 = extract_arfi_data(dispout, header, image_plane, specific_times=[1, 3])
    test_data2 = extract_arfi_data(dispout, header, image_plane, specific_times=[3, 2, 1])
    
    assert np.array_equal(test_data0, valid_data)
    assert np.array_equal(test_data1, valid_data[:, :, [0, 2]])
    assert np.array_equal(test_data2, np.flip(valid_data, axis=-1))
コード例 #3
0
ファイル: test_create_res_sim.py プロジェクト: mtubpeng1/fem
def test_preallocate_arfidata(sorted_nodes, axes):
    from fem.post.create_res_sim import __preallocate_arfidata

    from fem.post.create_res_sim import extract_image_plane
    image_plane = extract_image_plane(sorted_nodes, axes, 0.0)

    arfidata = __preallocate_arfidata(image_plane, 3)

    assert arfidata.shape == (11, 11, 3)
コード例 #4
0
ファイル: test_create_res_sim.py プロジェクト: mtubpeng1/fem
def test_extract_image_plane(sorted_nodes, axes):
    from fem.post.create_res_sim import extract_image_plane

    image_plane = extract_image_plane(sorted_nodes, axes, 0.0)

    assert image_plane.shape == (11, 11)
    assert image_plane[0][0] == 11
    assert image_plane[0][-1] == 1221
    assert image_plane[-1][0] == 121
    assert image_plane[-1][-1] == 1331