Ejemplo n.º 1
0
def test_find_probe_loc_from_frontwall_real(theta_deg):
    """Test move_probe_on_Oxy() with a 10 element linear points1"""
    standoff = -10.0

    numelements = 10

    # Setup: a 2-element points1
    probe = Probe.make_matrix_probe(numelements, 0.1, 1, 0.0, 1e6)

    locations_pcs = probe.locations

    # The point O(0., 0., 0.) is the 'centre' of the points1 (geometrical centre)
    assert np.allclose(np.mean(locations_pcs, axis=0), 0.0)

    # rotate and shift points1:
    locations_gcs = locations_pcs @ g.rotation_matrix_y(
        np.deg2rad(theta_deg)).T
    locations_gcs[:, 2] += standoff

    # empty fmc data
    tx, rx = arim.ut.fmc(numelements)
    time = Time(0.0, 1.0, 50)
    scanlines = np.zeros((len(tx), len(time)))
    frame = Frame(scanlines, time, tx, rx, probe,
                  ExaminationObject(Material(1.0)))

    # Distance to surface: orthogonal projection on Oxy
    distance_to_surface = np.full(len(tx), np.nan)
    distance_to_surface[tx == rx] = -locations_gcs[tx[tx == rx], 2]

    frame = reg.move_probe_over_flat_surface(frame, distance_to_surface)
    out_locations = frame.probe.locations

    assert np.allclose(out_locations, locations_gcs)
Ejemplo n.º 2
0
    def make_case(self, are_normals_zplus):
        """
        Source point: omega
        Dest points: 12 points along a circle of centre omega and radius 5 (points are
        spaced by  30°)

        Parameters
        ----------
        are_normals_zplus

        Returns
        -------

        """
        omega = np.array((3.0, 0.0, 5.0)) * 1e-2
        src_points = g.Points(omega.reshape([1, 3]), name="source")
        src_basis = g.default_orientations(src_points)
        src_basis = src_basis.rotate(g.rotation_matrix_y(np.pi / 6))
        source_interface = arim.Interface(
            src_points,
            src_basis,
            are_normals_on_out_rays_side=are_normals_zplus)

        # circle:
        dst_points = g.Points(np.zeros([len(self.circle_theta), 3]),
                              name="dest")
        dst_points.x[...] = omega[0]
        dst_points.y[...] = omega[1]
        dst_points.z[...] = omega[2]
        dst_points.x[...] += self.circle_radius * np.sin(self.circle_theta)
        dst_points.z[...] += self.circle_radius * np.cos(self.circle_theta)

        dst_basis = g.default_orientations(dst_points)

        dest_interface = arim.Interface(
            dst_points,
            dst_basis,
            are_normals_on_inc_rays_side=are_normals_zplus)

        material = arim.Material(1.0, metadata=dict(long_name="Dummy"))

        interfaces = [source_interface, dest_interface]

        # The i-th ray starts from the source and ends at the i-th destination point.
        shape = [len(source_interface.points), len(dest_interface.points)]
        ray_indices = np.zeros((0, *shape), arim.settings.INT)
        times = np.empty(shape, float)
        times.fill(np.nan)

        path = arim.Path(interfaces, [material], ["L"])
        ray = arim.ray.Rays(times, ray_indices, path.to_fermat_path())
        path.rays = ray
        ray_geometry = arim.ray.RayGeometry.from_path(path)
        return path, ray_geometry
Ejemplo n.º 3
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")