コード例 #1
0
import tfrt.drawing as drawing
from tfrt.spectrumRGB import rgb

angular_size = itertools.cycle(
    np.array([PI / 2, PI / 3, PI / 4, PI / 8, PI / 12, PI / 48],
             dtype=np.float64))
angle_samples = itertools.cycle([5, 9, 25])
center = itertools.cycle([(0, 0), (3, 0), (0, 3)])
central_angle = itertools.cycle([0, PI / 4, PI / 2, PI, -PI / 2])
beam_samples = itertools.cycle([5, 9, 25])

# build the source rays
start_angle = next(angular_size)
angles = distributions.StaticUniformAngularDistribution(
    -start_angle, start_angle, next(angle_samples))
base_points = distributions.StaticUniformBeam(-.5, .5, next(beam_samples))
#base_points = distributions.StaticUniformSquare(.1,5,y_size=.3,y_res=10)
#base_points = distributions.StaticUniformCircle(next(beam_samples))
source = sources.AngularSource(
    2,
    next(center),
    next(central_angle),
    angles,
    base_points,
    [drawing.YELLOW],
    dense=True,
)

fig, ax = plt.subplots(1, 1, figsize=(8, 6))
ax.set_aspect("equal")
ax.set_xbound(-4, 4)
コード例 #2
0
    def build_segs(pts=segment_points):
        return (pts.base_points_x[:-1], pts.base_points_y[:-1],
                pts.base_points_x[1:], pts.base_points_y[1:])

    segments.update_function = build_segs
    segments.update_handles.append(segment_points.update)
    eng.annotation_helper(segments, "mat_in", 1, "x_start", dtype=tf.int64)
    eng.annotation_helper(segments, "mat_out", 0, "x_start", dtype=tf.int64)

    # build the target
    target = boundaries.ManualSegmentBoundary()
    target.feed_segments(np.array([[10, -5, 10, 5]], dtype=np.float64))
    target.frozen = True

    # build the source rays
    beam_points = distributions.StaticUniformBeam(-1.5, 1.5, 10)
    angles = distributions.StaticUniformAngularDistribution(0, 0, 1)
    source = sources.AngularSource((-1.0, 0.0), 0.0, angles, beam_points,
                                   drawing.RAINBOW_6)

    # build the system
    system = eng.OpticalSystem2D()
    system.optical_segments = [segments]
    system.sources = [source]
    system.target_segments = [target]
    system.materials = [{"n": materials.vacuum}, {"n": materials.acrylic}]

    trace_engine = eng.OpticalEngine(
        2, [op.StandardReaction()],
        simple_ray_inheritance={"angle_ranks", "wavelength"})
    trace_engine.optical_system = system
コード例 #3
0
import numpy as np
import tensorflow as tf

import tfrt.sources as sources
import tfrt.distributions as distributions
from tfrt.drawing import RAINBOW_6

angles = distributions.StaticUniformAngularDistribution(-1, 1, 11)
base_points = distributions.StaticUniformBeam(-1, 1, 9)
source = sources.AngularSource(2, (0, 0),
                               0,
                               angles,
                               base_points,
                               RAINBOW_6,
                               dense=True)

print("source printout:")
for key, value in source.items():
    print(f"{key}: {value.shape}")

pcs = sources.PrecompiledSource(source)
print("precompiled source printout:")
for key, value in pcs.items():
    print(f"{key}: {value.shape}")

pcs.save("./data/precompiled_source_test.dat")
コード例 #4
0
import numpy as np
import tensorflow as tf

import tfrt.distributions as distributions
import tfrt.boundaries as boundaries
import tfrt.engine as eng
import tfrt.sources as sources

# build the source rays
beam_points = distributions.StaticUniformBeam(-.5, .5, 3)
angles = distributions.StaticUniformAngularDistribution(-.2, .2, 7)
source = sources.AngularSource((-1.0, 0.0), 0.0, angles, beam_points, [500])


def print_source():
    for key in source.keys():
        print(f"{key}: {source[key].shape}")


print(f"source rays printout")
print_source()
print("------------")

eng.annotation_helper(source, "foo", 1, "x_start")
source.update()

print(f"use annotate helper:")
print_source()
print("------------")

beam_points.sample_count = 5
コード例 #5
0
if __name__ == "__main__":
    drawing.disable_figure_key_commands()
    # set up the figure and axes
    fig, ax = plt.subplots(1, 1, figsize=(9, 9))

    # configure axes
    ax.set_aspect("equal")
    ax.set_xbound(-2, 2)
    ax.set_ybound(-2, 2)

    # build the source rays
    angular_distribution = distributions.StaticUniformAngularDistribution(
        -PI / 4.0, PI / 4.0, 6, name="StaticUniformAngularDistribution"
    )
    base_point_distribution = distributions.StaticUniformBeam(
        -1.0, 1.0, 6
    )
    movable_source = sources.AngularSource(
        [0.0, 0.0],
        0.0,
        angular_distribution,
        base_point_distribution,
        drawing.RAINBOW_6,
        name="AngularSource",
        dense=True,
        start_on_base=True,
        ray_length=1.0,
    )
    
    angles_2 = distributions.RandomUniformAngularDistribution(
        -PI / 4.0, PI / 4.0, 6, name="StaticUniformAngularDistribution"