Exemplo n.º 1
0
def plot_interfaces(dataset_name, save, noshow=False):
    conf = arim.io.load_conf(dataset_name)
    result_dir = conf["result_dir"]

    logger.info(f"dataset_name: {dataset_name}")

    probe = common.load_probe(conf)
    probe_p = probe.to_oriented_points()

    examination_object = arim.io.block_in_immersion_from_conf(conf)

    frontwall = examination_object.frontwall
    backwall = examination_object.backwall

    all_interfaces = [probe_p, frontwall, backwall]
    markers = [".", "-", "-"]

    try:
        all_interfaces.append(common.defect_oriented_point(conf))
        markers.append("d")
    except common.NoDefect:
        pass

    aplt.plot_interfaces(
        all_interfaces,
        show_orientations=False,
        show_last=True,
        markers=markers,
        filename=str(result_dir / "interfaces"),
        savefig=save,
    )
    if noshow:
        plt.close("all")
    else:
        plt.show()
Exemplo n.º 2
0
def test_plot_interfaces(show_plots, plot_interfaces_kwargs):
    # setup interfaces
    numinterface = 200
    numinterface2 = 200

    xmin = -5e-3
    xmax = 60e-3
    z_backwall = 20e-3

    points, orientations = arim.geometry.points_1d_wall_z(0,
                                                          12e-3,
                                                          z=0.0,
                                                          numpoints=64,
                                                          name="Probe")
    rot = g.rotation_matrix_y(np.deg2rad((12)))
    points = points.rotate(rot)
    points = points.translate((0, 0, -10e-3))
    orientations = orientations.rotate(rot)
    probe = arim.geometry.OrientedPoints(points, orientations)
    assert probe.orientations[0, 2, 0] > 0
    assert probe.orientations[0, 2, 2] > 0

    points, orientations = arim.geometry.points_1d_wall_z(
        xmin, xmax, z=0.0, numpoints=numinterface, name="Frontwall")
    frontwall = arim.geometry.OrientedPoints(points, orientations)

    points, orientations = arim.geometry.points_1d_wall_z(
        xmin, xmax, z=z_backwall, numpoints=numinterface2, name="Backwall")
    backwall = arim.geometry.OrientedPoints(points, orientations)

    grid_obj = arim.Grid(xmin, xmax, 0, 0, 0, z_backwall, 1e-3)
    grid = grid_obj.to_oriented_points()

    interfaces = [probe, frontwall, backwall, grid]
    # end setup interfaces

    aplt.plot_interfaces(interfaces, **plot_interfaces_kwargs)

    if show_plots:
        plt.show()
    else:
        plt.close("all")
Exemplo n.º 3
0
def compute_sensitivity(dataset_name, save):
    conf = arim.io.load_conf(dataset_name)
    result_dir = conf["result_dir"]

    probe = arim.io.probe_from_conf(conf)
    examination_object = arim.io.block_in_contact_from_conf(conf)
    tx, rx = arim.ut.fmc(probe.numelements)
    numtimetraces = len(tx)

    model_options = dict(frequency=probe.frequency,
                         probe_element_width=probe.dimensions.x[0])

    tic = time.time()
    grid = arim.io.grid_from_conf(conf)
    grid_p = grid.to_oriented_points()
    logger.info(f"grid numpoints: {grid.numpoints}")
    probe_p = probe.to_oriented_points()
    views = bic.make_views(
        examination_object,
        probe_p,
        grid_p,
        max_number_of_reflection=1,
        tfm_unique_only=True,
    )

    aplt.plot_interfaces(
        [
            probe_p, examination_object.frontwall, examination_object.backwall,
            grid_p
        ],
        show_orientations=False,
        show_last=True,
        # markers=[".", "-", "-"],
        filename=str(result_dir / "interfaces"),
        savefig=save,
    )

    arim.ray.ray_tracing(views.values(), convert_to_fortran_order=True)

    scat_obj = arim.scat.scat_factory(
        **conf["scatterer"]["specs"],
        material=examination_object.block_material)
    scat_angle = np.deg2rad(conf["scatterer"]["angle_deg"])
    with arim.helpers.timeit("Scattering matrices", logger=logger):
        scat_mat = scat_obj.as_single_freq_matrices(model_options["frequency"],
                                                    180)  # use precomputation

    with arim.helpers.timeit("Computation of ray weights for all paths",
                             logger=logger):
        ray_weights = bic.ray_weights_for_views(views, **model_options)

    sensitivity_images_dict = dict()
    timetrace_weights = np.ones(numtimetraces)

    for viewname, view in views.items():
        model_coefficients = arim.model.model_amplitudes_factory(
            tx.astype(int),
            rx.astype(int),
            view,
            ray_weights,
            scat_mat,
            scat_angle=scat_angle,
        )

        sensitivity_images_dict[
            viewname] = model_coefficients.sensitivity_uniform_tfm(
                timetrace_weights)

    toc = time.time()
    elapsed = toc - tic
    logger.info(
        f"Total time for sensitivity images: {elapsed:.2f} s ({grid.numpoints} points)"
    )

    # %%
    out = {"images": sensitivity_images_dict, "grid": grid}
    with open(result_dir / "sensitivity_images.pickle", "wb") as f:
        pickle.dump(out, f, pickle.HIGHEST_PROTOCOL)

    return sensitivity_images_dict
Exemplo n.º 4
0
# %% Load frame
frame = arim.io.frame_from_conf(conf, use_probe_from_conf=True)
frame = frame.apply_filter(
    (arim.signal.Hilbert() + arim.signal.ButterworthBandpass(
        **conf["filter_for_tfm"], time=frame.time)))
frame = frame.expand_frame_assuming_reciprocity()
probe_p = frame.probe.to_oriented_points()

# %% Plot interfaces
aplt.plot_interfaces(
    [
        probe_p, frame.examination_object.frontwall,
        frame.examination_object.backwall
    ],
    show_orientations=False,
    show_last=True,
    markers=[".", "-", "-"],
    filename=str(result_dir / "interfaces"),
    savefig=save,
)

# %% Ray tracing
grid = arim.io.grid_from_conf(conf)
grid_p = grid.to_oriented_points()

views = bic.make_views(
    frame.examination_object,
    probe_p,
    grid_p,
    tfm_unique_only=True,
Exemplo n.º 5
0
                conf["scatterer"]["location"]["z"],
            ]
        ],
        name="Scatterer",
    )
)

grid = arim.geometry.Grid(**conf["grid"], ymin=0.0, ymax=0.0)
grid_p = grid.to_oriented_points()

aplt.plot_interfaces(
    [
        probe.to_oriented_points(),
        examination_object.frontwall,
        examination_object.backwall,
        scatterer,
        grid_p,
    ],
    show_last=False,
    markers=[".", "-", "-", "d", ".k"],
)

#%% Ray tracing for scatterer
views = bim.make_views(
    examination_object,
    probe.to_oriented_points(),
    scatterer,
    max_number_of_reflection,
    tfm_unique_only,
)
# views = {viewname: view for viewname, view in views.items() if viewname in {"L-T", "T-L"}}  # debug