Ejemplo n.º 1
0
def get_input_labels(
    io_gratings: List[ComponentReference],
    ordered_ports: List[Port],
    component_name: str,
    layer_label: Layer,
    gc_port_name: str,
    get_input_label_text_function=get_input_label_text,
) -> List[Label]:
    """Returns list of labels for a list of grating coupler references.

    Args:
        io_gratings: grating coupler references
        ordered_ports: list of ordered_ports
        component_name:
        layer_label:
        gc_port_name: gc_port_name port name
        get_input_label_function:
    """
    elements = []
    for i, g in enumerate(io_gratings):
        label = get_input_label(
            port=ordered_ports[i],
            gc=g,
            gc_index=i,
            component_name=component_name,
            layer_label=layer_label,
            gc_port_name=gc_port_name,
            get_input_label_text_function=get_input_label_text_function,
        )
        elements += [label]

    return elements
Ejemplo n.º 2
0
def test_add_labels_optical() -> Component:
    c = gf.components.straight()
    gc = gf.components.grating_coupler_elliptical_te()
    label1 = get_input_label(port=c.ports["o1"],
                             gc=gc,
                             gc_index=0,
                             layer_label=gf.LAYER.LABEL)
    label2 = get_input_label(port=c.ports["o2"],
                             gc=gc,
                             gc_index=1,
                             layer_label=gf.LAYER.LABEL)
    add_labels(c, get_label_function=get_input_label, gc=gc)
    labels_text = [c.labels[0].text, c.labels[1].text]
    # print(label1)
    # print(label2)

    assert label1.text in labels_text, f"{label1.text} not in {labels_text}"
    assert label2.text in labels_text, f"{label2.text} not in {labels_text}"
    return c
Ejemplo n.º 3
0
def loss_deembedding_ch13_24(
        pitch: float = 127.0,
        R: float = 10.0,
        grating_coupler_factory: ComponentFactory = grating_coupler_te,
        input_port_indexes: Tuple[int, ...] = (0, 1),
        cross_section: CrossSectionFactory = strip,
        **kwargs) -> Component:

    gc = grating_coupler_factory()
    c = gf.Component()
    dx = pitch
    gcs = [
        gc.ref(position=(i * dx, 0), port_id="o1", rotation=-90)
        for i in range(4)
    ]

    gc_ports = [g.ports["o1"] for g in gcs]
    c.add(gcs)

    c.add(
        get_route(gc_ports[0],
                  gc_ports[2],
                  start_straight=40.0,
                  taper_factory=None,
                  cross_section=cross_section,
                  **kwargs).references)

    gsi = gc.size_info
    p1 = gc_ports[1]
    p3 = gc_ports[3]
    a = R + 5.0  # 0.5
    b = max(2 * a, pitch / 2)
    y_bot_align_route = -gsi.width - 5.0

    c.add(
        connect_loopback(p1,
                         p3,
                         a,
                         b,
                         R,
                         y_bot_align_route,
                         cross_section=cross_section,
                         **kwargs))
    for i, index in enumerate(input_port_indexes):
        label = get_input_label(gc_ports[index],
                                gc,
                                i,
                                component_name=inspect.stack()[0][3])
        label.position = gc_ports[index].position
        c.add(label)

    return c
Ejemplo n.º 4
0
def loss_deembedding_ch14_23(
        pitch: float = 127.0,
        grating_coupler: ComponentFactory = grating_coupler_te,
        input_port_indexes: Tuple[int, ...] = (0, 1),
        **kwargs) -> Component:
    """Grating coupler test structure for fiber array.

    Connects channel 1->4, 2->3

    Args:
        pitch:
        grating_coupler:
        input_port_indexes:

    Keyword Args:
        cross_section settings
    """
    gc = grating_coupler()

    c = gf.Component()
    dx = pitch
    gcs = [
        gc.ref(position=(i * dx, 0), port_id="o1", rotation=-90)
        for i in range(4)
    ]

    gc_ports = [g.ports["o1"] for g in gcs]
    c.add(gcs)

    c.add(
        get_route(gc_ports[0],
                  gc_ports[3],
                  start_straight_length=40.0,
                  taper=None,
                  **kwargs).references)
    c.add(
        get_route(gc_ports[1],
                  gc_ports[2],
                  start_straight_length=30.0,
                  taper=None,
                  **kwargs).references)
    for i, index in enumerate(input_port_indexes):
        label = get_input_label(gc_ports[index],
                                gc,
                                i,
                                component_name=inspect.stack()[0][3])
        label.position = gc_ports[index].position
        c.add(label)
    return c
Ejemplo n.º 5
0
def grating_coupler_loss_fiber_array(
        pitch: float = 127.0,
        grating_coupler: ComponentFactory = grating_coupler_te,
        input_port_indexes: Tuple[int, ...] = (0, 1),
        **kwargs) -> Component:
    """Returns Grating coupler fiber array loopback.

    Args:
        pitch:
        grating_coupler:
        cross_section:
        input_port_indexes: adds test labels
        kwargs: cross_section settings
    """
    gc = grating_coupler()

    c = gf.Component()
    dx = pitch
    gcs = [
        gc.ref(position=(i * dx, 0), port_id="o1", rotation=-90)
        for i in range(2)
    ]

    gc_ports = [g.ports["o1"] for g in gcs]
    c.add(gcs)

    c.add(
        get_route(gc_ports[0],
                  gc_ports[1],
                  start_straight_length=40.0,
                  taper=None,
                  **kwargs).references)
    for i, index in enumerate(input_port_indexes):
        label = get_input_label(gc_ports[index],
                                gc,
                                i,
                                component_name=inspect.stack()[0][3])
        label.position = gc_ports[index].position
        c.add(label)
    return c
Ejemplo n.º 6
0
def loss_deembedding_ch14_23(
        pitch: float = 127.0,
        R: float = 10.0,
        grating_coupler_factory: ComponentFactory = grating_coupler_te,
        input_port_indexes: Tuple[int, ...] = (0, 1),
        **kwargs) -> Component:
    gc = grating_coupler_factory()

    c = gf.Component()
    dx = pitch
    gcs = [
        gc.ref(position=(i * dx, 0), port_id="o1", rotation=-90)
        for i in range(4)
    ]

    gc_ports = [g.ports["o1"] for g in gcs]
    c.add(gcs)

    c.add(
        get_route(gc_ports[0],
                  gc_ports[3],
                  start_straight=40.0,
                  taper_factory=None,
                  **kwargs).references)
    c.add(
        get_route(gc_ports[1],
                  gc_ports[2],
                  start_straight=30.0,
                  taper_factory=None,
                  **kwargs).references)
    for i, index in enumerate(input_port_indexes):
        label = get_input_label(gc_ports[index],
                                gc,
                                i,
                                component_name=inspect.stack()[0][3])
        label.position = gc_ports[index].position
        c.add(label)
    return c