nazca module references

An overview of the Nazca modules.

nazca.cfg module

This module is for configuring Nazca settings and sharing variables between Nazca modules.

nazca.cfg.active_cell()

Get the active cell.

The ‘active cell’ is the last opened Cell object that has not been closed yet.

Returns

active cell

Return type

Cell

nazca.cfg.formatplot()

update matplotlib plotting style for graphs.

Returns

None

nazca.cfg.gds_cellname_cleanup(name)

Placeholder function that can be overruled in a foundry PDK.

This function should make sure only valid cellnames are used, i.e. formats excepted by the foundry.

Parameters

name (str) – cellname

Returns

valid cellname

Return type

str

nazca.cfg.reset_pinstyles()

nazca.clipper module

Module with boolean operations on polygons and grow/shrink.

Documentation of pyclipper is minimum and that of the library is better. That can be found at: http://www.angusj.com/delphi/clipper/documentation e.g. documentation/Docs/Units/ClipperLib/Types/PolyFillType.htm has useful information.

nazca.clipper.clip_polygons(paths_A, paths_B, accuracy=1e-08)

Clip polygons and return a list with the resulting polygon(s). This function returns the intersection of the polygons (paths_A AND paths_B).

Parameters
  • paths_A (list) – list of polygons that each have a list of (x,y) coordinates.

  • paths_B (list) – list of polygons that each have a list of (x,y) coordinates.

  • accuracy (float) – accuracy [µm] of the location of the intermediate points.

  • is no good reason to deviate from the default (There) –

Returns

List of polygons that result from clipping: paths_A AND paths_B.

Return type

list

nazca.clipper.diff_polygons(paths_A, paths_B, accuracy=1e-08)

Subtract polygons and return a list with the resulting polygon(s). This function returns the subtraction of the polygons (paths_A NOT paths_B)

Parameters
  • paths_A (list) – list of polygons that each have a list of (x,y) coordinates.

  • paths_B (list) – list of polygons that each have a list of (x,y) coordinates.

  • accuracy (float) – accuracy [µm] of the location of the intermediate points.

  • is no good reason to deviate from the default (There) –

Returns

List of polygons that result from subtraction: paths_A - paths_B.

Return type

list

nazca.clipper.grow_polygons(paths, grow=5, accuracy=0.1, jointype='round')

Grow or shrink polygons and return the resulting structures.

Parameters
  • paths (list) – list of polygons that each have a list of (x,y) coordinates.

  • accuracy (float) – accuracy [µm] of the location of the intermediate points. The accuracy determines the grid on which the grown path is drawn.

  • jointype – specifies the type of growing that is used. The jointype is one of ‘round’ (default), ‘square’ or ‘miter’.

Returns

list of points [(x1, y1), (x2, y2), …]

Return type

list

nazca.clipper.merge_polygons(paths, accuracy=1e-08)

Merge polygons and return a list with the resulting polygon(s). This function returns the union of the polygons (logical OR of all paths).

Parameters
  • paths (list) – list of polygons. A polygon is list of coordinates (x, y).

  • accuracy (float) – accuracy [µm] of the location of the intermediate points. There is no good reason to deviate from the default (default = 1e-8 µm).

Returns

list of polygons [ [(x1, y1), (x2, y2), …], […], … ]

Return type

list

nazca.clipper.polygons_AND(paths_A, paths_B, accuracy=1e-08)

Clip polygons and return a list with the resulting polygon(s). This function returns the intersection of the polygons (paths_A AND paths_B).

Parameters
  • paths_A (list) – list of polygons that each have a list of (x,y) coordinates.

  • paths_B (list) – list of polygons that each have a list of (x,y) coordinates.

  • accuracy (float) – accuracy [µm] of the location of the intermediate points.

  • is no good reason to deviate from the default (There) –

Returns

List of polygons that result from clipping: paths_A AND paths_B.

Return type

list

nazca.clipper.polygons_NOT(paths_A, paths_B, accuracy=1e-08)

Subtract polygons and return a list with the resulting polygon(s). This function returns the subtraction of the polygons (paths_A NOT paths_B)

Parameters
  • paths_A (list) – list of polygons that each have a list of (x,y) coordinates.

  • paths_B (list) – list of polygons that each have a list of (x,y) coordinates.

  • accuracy (float) – accuracy [µm] of the location of the intermediate points.

  • is no good reason to deviate from the default (There) –

Returns

List of polygons that result from subtraction: paths_A - paths_B.

Return type

list

nazca.clipper.polygons_OR(paths, accuracy=1e-08)

Merge polygons and return a list with the resulting polygon(s). This function returns the union of the polygons (logical OR of all paths).

Parameters
  • paths (list) – list of polygons. A polygon is list of coordinates (x, y).

  • accuracy (float) – accuracy [µm] of the location of the intermediate points. There is no good reason to deviate from the default (default = 1e-8 µm).

Returns

list of polygons [ [(x1, y1), (x2, y2), …], […], … ]

Return type

list

nazca.clipper.polygons_XOR(paths_A, paths_B, accuracy=1e-08)

This function returns a list of polygons that result form the logical XOR operation: paths_A XOR paths_B.

Parameters
  • paths (list) – list of polygons. A polygon is list of coordinates (x, y).

  • accuracy (float) – accuracy [µm] of the location of the intermediate points. There is no good reason to deviate from the default (default = 1e-8 µm).

Returns

list of polygons [ [(x1, y1), (x2, y2), …], […], … ]

Return type

list

nazca.clipper.xor_polygons(paths_A, paths_B, accuracy=1e-08)

This function returns a list of polygons that result form the logical XOR operation: paths_A XOR paths_B.

Parameters
  • paths (list) – list of polygons. A polygon is list of coordinates (x, y).

  • accuracy (float) – accuracy [µm] of the location of the intermediate points. There is no good reason to deviate from the default (default = 1e-8 µm).

Returns

list of polygons [ [(x1, y1), (x2, y2), …], […], … ]

Return type

list

nazca.colormap module

Module to parse Klayout lyp files into csv via DataFrames: lyp2csv

Generate a matplotlib colormap from the csv table: csv2colormap

class nazca.colormap.Lypdata

Bases: object

Class to export layer infomation to a Klayout lyp file.

A lyp file is a layer properties file.

__init__()

Initialize a Lypdate object.

Returns

None

layer2xml(row)

Append layer entry.

Returns

None

output(filename)

Save lyp file.

Parameters

filename (str) – output filename

Returns

None

pop()
push(tag)
xml_tag(tag, close=False)

Append xml tag.

Parameters
  • tag (str) –

  • close (bool) –

Returns

None

xml_value(tag, val=None)

Append xml value.

Parameters
  • tag (str) –

  • () (val) – value

Returns

None

nazca.colormap.csv2lyp(csvfiles, lypfile)

Write klayout .lyp layer properties file.

Parameters
  • csvfiles (dict) – dictionary {tab-name: filename} which contains all csv files to be written to a single lyp file. Each tab-name is the name of the tab in the layers view in KLayout and each filename is the filename of the csv file to be read.

  • lypfile (str) – filename of the .lyp file. This file will be created if it does not yet exist. If it already exists, it will be overwritten.

Returns

None

nazca.colormap.lyp2csv(lypfile, infolevel=0)

Convert a Klayout .lyp file into a .csv Nazca color table.

This function makes it possible to use a Klayout color definition (in xml) inside Nazca, e.g. for Matplotlib output. A .lyp file may contain multiple tabs and each tab is exported to a separate .csv file.

Note that display method in Klayout and Matplotlib are not the same. Hence, a layout will have a different “style” to it. for things like:

  • tranparency and opaqueness

  • visualization of edges

  • stipple

Parameters

lypfile (str) – name of Klayout .lyp file

Returns

dictionary {<tabname>: <csv_filename>}

Return type

dict

nazca.colormap.lyp2pd(lypfile, infolevel=0)

Convert a Klayout .lyp file into a Nazca color table.

This function makes it possible to use a Klayout color definition (in xml) inside Nazca, e.g. for Matplotlib output. A .lyp file may contain multiple tabs and each tab is exported to a separate pandas dataframe.

Note that display method in Klayout and Matplotlib are not the same. Hence, a layout will have a different “style” to it. for things like:

  • tranparency and opaqueness

  • visualization of edges

  • stipple

Parameters

lypfile (str) – name of Klayout .lyp file

Returns

dictionary {<tabname>: <tab_dataframe>}

Return type

dict

nazca.colormap.nazca2csv(colors, filename)

Save nazca colormap to csv file.

Parameters
  • colors (DataFrame) – color information

  • filename (str) – name of csv output file

Returns

None

nazca.colormap.nazca2lyp(filename)

Export the Nazca color DataFrame to .lyp file.

Generate a csv file from the Nazca color DataFrame and a lyp file from that csv file

Parameters

filename (str) – basename of the output csv and lyp files

Returns

None

nazca.colormap.pd2lyp(tabs, lypfile)

Write klayout .lyp layer properties file.

Parameters
  • csvfiles (dict) – dictionary {tab-name: filename} which contains all csv files to be written to a single lyp file. Each tab-name is the name of the tab in the layers view in KLayout and each filename is the filename of the csv file to be read.

  • lypfile (str) – filename of the .lyp file. This file will be created if it does not yet exist. If it already exists, it will be overwritten.

Returns

None

nazca.convert_AWGtxt2nazca module

Convert BrightAWG coordinates.txt to nazca.txt

Reformat the AWG coordinates from the BrightAWG .txt outfile into Nazca format for all .txt. files in a specified directory.

Rename port ‘in’ -> ‘a’

Rename port ‘out’ -> ‘b’

rotate ports ‘in’ 180 degree

export with suffix .nazca.txt

nazca.convert_AWGtxt2nazca.convert(files, xs, win, wout)

Loop .txt input files and write converted nazca compatible pin output files.

Parameters
  • files (str | list of str) – filename(s)

  • xs (float) – xsection of connection (if not in file)

  • win (float) – waveguide width input side (if not in file)

  • wout (float) – waveguide width output side (if not in file)

Returns

list of filenames of the converted files

Return type

list of str

nazca.convert_AWGtxt2nazca.convert_file(file, xs, win, wout, warm=None)

Reformat the AWG coordinates from the OD BrightAWG .txt file into Nazca format.

Output format: port, x, y, a, xs, w

A header row is included in the output. OD port names are renamed to nazca pin names, e.g. in0 -> a0, out4 -> b4. Also, input port will undergo a 180 degree rotation to adhere to the Nazca philosophy of “outward pointing” pins.

If the input file has the xsection and width included than those values are used. Otherwise the arguments xs, win and wout are used.

Parameters
  • file (str) – filename

  • xs (float) – xsection of connection (if not in file)

  • win (float) – waveguide width input side (if not in file)

  • wout (float) – waveguide width output side (if not in file)

Returns

list containing table with pin data

Return type

list

nazca.convert_AWGtxt2nazca.get_txt_files(dir)

Get all .txt. files in directory path ‘dir’.

Parameters

dir (str) – root directory to scan

Returns

list of filenames

Return type

list of str

nazca.convert_AWGtxt2nazca.put_pins(file, xs, win, wout, warm=None, stubs=False)

Load the OD BrightAWG .txt file and place the pins in the active cell.

This function skips the converstion to a file with Nazca coordinates. Can be usefull as a shortcut.

To generate a new converted file use method ‘convert’ with the same parameters, except put_pins only accepts one file at a time.

Parameters
  • (str (file) – filename

  • xs (float) – xsection of connection (if not in file)

  • win (float) – waveguide width input side (if not in file)

  • wout (float) – waveguide width output side (if not in file)

Returns

None

nazca.cp module

The ‘cp’ module provides short syntax methods to operate on current pointer cp. The cp holds position of the standard output of the last element in a mask layout. This module should be rarely needed be designers as translations of positions can typically be best obtained by applying the translation methods of the Pin object.

nazca.cp.a()

Get cp coordinates a.

Returns

a

Return type

float

nazca.cp.get_a()

Get cp coordinates a.

Returns

a

Return type

float

nazca.cp.get_xy()

Get cp coordinates x, y.

Returns

x, y

Return type

(float, float)

nazca.cp.get_xya()

Get cp coordinates x, y, a.

Returns

x, y, a

Return type

(float, float, float)

nazca.cp.goto(x=0, y=0, a=0)

Goto absolute position with cp.

Parameters
  • x (float) – x-position

  • y (float) – y-position

  • a (float) – a-position

Returns

cp at goto position

Return type

Node

nazca.cp.goto_pin(p)

Goto absolute position with cp.

Parameters

p (Node) – (x, y, a) position

Returns

cp at goto position

Return type

Node

nazca.cp.here()

Get cp.

Returns

cp

Return type

Node

nazca.cp.move(x=0, y=0, a=0)

Move relative with respect cp.

Parameters
  • x (float) – x-position

  • y (float) – y-position

  • a (float) – a-position

Returns

cp at goto position

Return type

Node

nazca.cp.offset(y=0)

Move perpendicular with respect to cp.

Parameters

y (float) – delta y

Returns

cp at offset position

Return type

Node

nazca.cp.os(y=0)

Move perpendicular with respect to cp.

Parameters

y (float) – delta y

Returns

cp at offset position

Return type

Node

nazca.cp.pop()

Pop cp from the FILO stack.

Returns

popped cp

Return type

Node

nazca.cp.push()

Push cp on the FILO stack.

Returns

pushed cp

Return type

Node

nazca.cp.rot(a=0)

Rotate the cp.

Parameters

a (float) – a-position

Returns

cp at rotated position

Return type

Node

nazca.cp.rotate(a=0)

Rotate the cp.

Parameters

a (float) – a-position

Returns

cp at rotated position

Return type

Node

nazca.cp.shift(x=0, y=0)

Move relative with respect cp by x, y.

Parameters
  • x (float) – delta x

  • y (float) – delta y

Returns

cp at shifted position

Return type

Node

nazca.cp.show(radius=10, width=1)

Show location of cp by drawing a circle around it.

Parameters
  • radius (float) – radius of the circle

  • width (float) – width of the circle line

Returns

Node: cp

nazca.cp.skip(x=0)

Move in the direction of cp.

Parameters

x (float) – delta x

Returns

cp at skip position

Return type

Node

nazca.cp.x()

Get cp coordinates x.

Returns

x

Return type

float

nazca.cp.xy()

Get cp coordinates x, y.

Returns

x, y

Return type

(float, float)

nazca.cp.xya()

Get cp coordinates x, y, a.

Returns

x, y, a

Return type

(float, float, float)

nazca.cp.y()

Get cp coordinates y.

Returns

y

Return type

float

nazca.font module

Module to add text to a layout.

Example

A simple way to put text in the layout using default settings:

import nazca as nd

nd.text(text='Hello world').put(0)
nd.export_plt()
class nazca.font.Font(fontfile='nazca', box_layer=None, box_buf=None)

Bases: object

Class to define text object in various fonts.

Nazca font files have the following structure: version: font file version number height: total height of the font space: interword space (=0 for fixed fonts)

font: dictionary of characters:

key: character w: width of that character p: list of polygons, of which each is a list of (x,y) coordinate points

__init__(fontfile='nazca', box_layer=None, box_buf=None)

Initialize a font object.

Parameters
  • fontfile (str) – name of the fontfile (.nft)

  • box_layer (str | int | tuple) – layer reference to generate a square box in behind the text, e.g. for NOFILL (default = None)

  • box_buf (float) – extra buffer for the box_layer in um

Returns

None

characters()

Get all font characters.

Returns

string with all characters present in a font

Return type

str

linelength(text, height=50)

Returns: float: total linelength of longest line in (multiline) text

sample(height=50, layer=1, instantiate=False)

Return a cell with all characters present in a font.

Parameters
  • height (float) – height off the text in um

  • layer (int | string) – layer number or name to place text in

  • instantiate (bool) – instantiate cell (default False)

Returns

cell with a sample of all characters in the font.

Return type

Cell

Example:

cousine = nd.Font("cousine")
sample = cousine.sample()
sample.put()
nd.export_plt()
text(text='Text', height=None, strokewidth=None, layer=1, align='lb', box_layer=None, box_buf=None, instantiate=False, cellname=None)

Output a cell with text of specified dimensions and alignment.

In case of an exclusion (NOFILL) box_layer, e.g. for tiling protection, the box will be scaled with the text height unless a box_buf value is provided. The box_buf represents an absolute buffer between the text field and the box edge in um.

Parameters
  • text (str) – text to display

  • height (float) – height of the text in um (default 50)

  • strokewidth (float) – approximate font stroke width in um (height takes precedence if both are specified)

  • layer (int | string) – layer number or name to place text in

  • align (str) – relative placement: regex: [lcr][bct] (default = ‘lb’) examples: ‘lc’, ‘cc’, ‘tr’

  • box_layer (str | int | tuple) – layer reference to generate a square box in behind the text, e.g. for NOFILL (default = None)

  • box_buf (float) – extra buffer for the box_layer in um

  • instantiate (bool) – instantiate cell (default=False)

  • cellname (str) – overrule the standard hash text cell naming (default=None) Set instantiate=True to get the text as a cell in the gds export.

  • xs (str) – not yet implemented. optional xsection to place text in. Useful to copy text to multiple layers, e.g. a logical layer.

Returns

cell with text as provided in <text>

Return type

Cell

Example:

import nazca as nd

message = nd.text(text='Hello world', align='cc')
message.put(0)
nd.export_plt()
textheight(text, height=50)

Returns: float: total textheight of line(s) in text

nazca.font.default_font(f='nazca')
nazca.font.linelength(text, height=50)
nazca.font.text(text='Text', height=None, strokewidth=None, layer=1, stretch=1, align='lb', linewidth=1, instantiate=False, box_layer=None, box_buf=None, cellname=None)

nazca.gds_cellreplace module

Module for replacing static cells and parametric cells.

nazca.gds_cellreplace.replaceCells(gdsin, gdsout=None, PcellFunctionMap=None, ScellMapping=None, md5=False, md5suffix='.md5', suffix='_white', addtime=True, infolevel=0, layermap=None, layermapmode=None)

Replace black with white cells in file <gdsin> and export result to <gdsout>.

The replacement is Pcell (parametric cell) or a Scell (static cell) based. Note: Only apply one mapping per function call, Pcell or Scell, to stay in control of the mapping order. Sequential calls to this function are perfectly fine, but the order may matters for the outcome.

  • Pcell replacement: Needs a mapping of the Pcell basename to a cell function:

    {<black_cell_basename>, <white_cell_function_pointer>}

  • Scell replacement: Needs a gds library <ScellFile> and a map <ScellMap>:
    • ScellFile (str): filename of gds library

    • ScellMap (dict): {black_cellname: white_cellname}.

Parameters
  • gdsin (str) – input filename

  • gdsout (str) – optional output filename

  • PcellMap (dict) – black2white dictionary {black_cellbasename: white_Pcell_function}

  • ScellMapping (dict) – {<ScellFile>: {<ScellMap>}} for black2white mapping of one or more cell libraries.

  • md5 (bool) – save md5sum. Default=False

  • md5suffix (str) – suffix for md5sum file. Default = “_md5”

  • suffix (str) – suffix of the output gds. Default = “_white”

  • addtime (bool) – add time (date) as last suffix. Default = True

  • infolevel (int) – amount of debug info printed

Returns

gds output filename of file with replaced cells

Return type

str

nazca.generic_bend module

Module to generate parametric waveguide curves or ‘pcurves’ and sine bends.

Polyline approximations of the curve are generated.

The pcurves are based on Francois Ladouceur and Pierre Labeye, “A New General Approach to Optical Waveguide Path Design”, Journal of Lightwave Technology, vol. 13, no. 3, march 1995.

The algorithm tries to construct a curve that matches the input and output radius, and position, while maximizing the radius along the curve. Patent expired.

The radius arguments in this module are sensitive to the sign. A positive radius indicates a counter-clockwise direction.

nazca.generic_bend.curve2polyline(fie, xya, acc, args=())

Generate a polyline from a parameterized curve.

Use a sufficient number of points to ensure that the deviation of the sampled curve from the real curve is less than the specified accuracy.

Parameters
  • fie (function) – the curve function that takes one parameter that runs from 0 to 1 as first argument. The curve starts at the origin at 0 angle.

  • xya (tuple) – the position (x, y, a) of the end point of the curve. Angle a in degrees.

  • acc (float) – desired accuracy in micrometer.

  • args (tuple) – additional arguments to be passed to the curve function.

Returns

list of points (x, y);

a polyline approximation of the curve

Return type

list of (float, float)

nazca.generic_bend.curve_AB(Lp)

Calculate array A and array B for given L.

Parameters

Lp (float) – scaled curve-parameter point

Returns

six elements A, six elements B

Return type

(list of float, list of float)

nazca.generic_bend.distance_point2line(P, A, B)

Calculate the shortest distance of point P to a line through A and B.

Note that the shortest distance is the perpendicular distance from P to line AB.

Parameters
  • P (float, float) – (x, y) target point

  • A (float, float) – (x, y) first point on line

  • B (float, float) – (x, y) second point on line

Returns

distance

Return type

float

nazca.generic_bend.gb_coefficients(xya, radius1=0, radius2=0)

Calculate coefficients A, B and L.

Determine the optimum curve length so that the minimum Radius along the curve is maximized. The center of the curve is defined by a polynomial with coefficients A[] for x, and B[] for y. The independent variable runs from 0 to L.

Parameters
  • xya (tuple) – (x, y, a) coordinate of final position

  • radius1 (float) – radius of curvature at start

  • radius2 (float) – radius of curvature at end

Returns

array of six A, array of six B, L

Return type

list of float, list of float, float

nazca.generic_bend.gb_point(t, A, B, Lp)

Calculate generic-bend point for parameter t.

Parameters
  • () (t) – normalized parameter in range [0, 1].

  • A (list of float) – array of six.

  • B (list of float) – array of six.

  • Lp (float) – scaled curve-parameter point, scales t.

Returns

generic bend point

Return type

(float, float)

nazca.generic_bend.getCurvature(A, B, Lp)

Get the local curvature at a given point Lp of the parametrized curve.

P(Lp) = (A(Lp), B(Lp)) along the P-Curve.

For local curvature see: http://en.wikipedia.org/wiki/Curvature#Local_expressions

Parameters
  • A (list of float) – six coefficients

  • B (list of float) – six coefficients

  • Lp (float) – scaled curve-parameter point

Returns

local curvature

Return type

float

nazca.generic_bend.invert_matrix(Lp)

Helper function returning the solution matrix as a function of Lp.

Parameters

Lp (float) – scaled curve-parameter point

Returns

6x6 matrix

Return type

tuple of float

nazca.generic_bend.max_curvature(L)

Calculate the maximum curvature along L.

There is an ambiguity when the maximum curvature occurs at the input or output position. Many paths in between then satisfy the curvature requirement. We therefore multiply by log(length) to favor short connections without affecting the result much.

Parameters

L (float) – scaled curve-parameter size

Returns

maximum curvature

Return type

float

nazca.generic_bend.sinebend_point(t, distance, offset)

Calculate sine bend point for parameter t. This bend has zero curvature at both ends. It provides an S-shape connection.

Parameters
  • t (float) – normalized parameter in range [0, 1].

  • distance (float) – scaling factor of x with t.

  • offset (float) – scaling factor of y with t.

Returns

point (x, y) for given t

Return type

(float, float)

nazca.geometries module

A set of funtions to create polygon geometries for shapes like box, taper, arc, frame. When drawing waveguide structures do not use this module but instead the interconnects module or the one level deeper mask_elements module.

nazca.geometries.MMI_iopoly(wmmi=10, o=None, wio=None, angle=53)

MMI_iopoly: helper routine which generates one side of an MMI outline polygon, from bottom to top. This side needs to be joined with the other side.

nazca.geometries.MMI_poly(wmmi=10, lmmi=100, wi=None, wo=None, oi=None, oo=None, angle=53)

MMI layout polygon.

Returns an MMI polygon outline with angled corners for reduced reflections. The input and output waveguides either have all the same width (in which case wi and wo are a single float value) or they are specified in a list or tuple of length equal to len(oi) and len(oo).

Parameters
  • wmmi (float) – width of the MMI

  • lmmi (float) – length of the MMI

  • wi (float|list) – input waveguide width(s)

  • wo (float|list) – output waveguide width(s)

  • oi (list) – input waveguide offsets from center

  • oo (list) – output waveguide offsets from center

  • angle (float) – corner cut angle (degrees) where 90° is a standard MMI

Returns

list of points of the MMI polygon.

Return type

poly (list)

nazca.geometries.arc(radius=5, width=2, angle=180, grow=0, N=20)

Return arc polygon.

nazca.geometries.box(length=10, width=7, grow=0)

Return box polygon.

nazca.geometries.circle(radius=5, N=20)
nazca.geometries.frame(sizew=2, sizel=10, sizeh=10, grow=0)

Return frame polygon with of size length, height and thickness width.

nazca.geometries.mid_pts(p1, p2, factor=0)

Return point on the line between p1 and p2

nazca.geometries.monkey(width=1000, height=1000)

Return a polygon with the Nazca monkey.

The width and height parameters define the size of the bounding box that will hold the polygon. The aspect ratio is not changed.

nazca.geometries.parallelogram(length=10, height=5, angle=45, position=1, shift=0, 0)

Return parallelogram polygon.

Parameters
  • length (float) – length of base

  • height (float) – height of parallelogram

  • angle (float) – side angle where 90 degrees gives a rectangle

  • position (int) – 1-9, position of origin 3 6 9 2 5 8 1 4 7

  • shift (point) – (sx, sy) shift of origin

Returns

4 parallelogram coordinate points

nazca.geometries.parallelogram2(length=10, height=5, angle=45, position=1, shift=0, 0)

Return parallelogram polygon.

Parameters
  • length (float) – length of bounding box of parallelogram

  • height (float) – height of parallelogram

  • angle (float) – side angle where 90 degrees gives a rectangle

  • position (int) – 1-9, position of origin 3 6 9 2 5 8 1 4 7

  • shift (point) – (sx, sy) shift of origin

Returns

4 parallelogram coordinate points

nazca.geometries.pie(radius=5, angle=310, N=20)

Return arc polygon.

nazca.geometries.read_4positions(position=1, pts={}, shift=0, 0)

Return 4 corner points based on position

nazca.geometries.rectangle(length=10, height=5, position=1, shift=0, 0)

Return rectangle polygon.

nazca.geometries.rhombus(length=10, angle=45, position=1, shift=0, 0)

Return rhombus polygon.

nazca.geometries.ring(radius=5, width=2, grow=0, N=20)
nazca.geometries.rounded_rect(length=10, height=7, position=1, shift=0, 0, shrink=0.1, accuracy=0.05)

Return rectangle polygon with rounded corners.

nazca.geometries.square(length=10, position=1, shift=0, 0)

Return square polygon.

nazca.geometries.taper(length=10, width1=2, width2=8, grow=0)

Return taper polygon.

nazca.geometries.tetragon(length=5, height=10, dx=4, x=10, position=1, shift=0, 0)

Return tetragon polygon.

nazca.geometries.transform(points, center=0, 0, 0, scale=1.0, flipx=False, flipy=False, move=0, 0, 0)

Transform a polygon by translation, rotation, scaling and/or flipping.

The transformation first relocates the origin to the point in the <center> position. Subsequently, the scale, rotate and flips are applied, where order does not matter. Finally, a (x, y) translation is performed.

Parameters
  • polygon (list of (float, float)) – points (x, y)

  • center ((float, float, float)) – (x, y, a) as center of scaling (default = (0, 0, 0))

  • scale (float) – scaling factor (default = 1.0)

  • flipx (bool) – flip x coordinate x -> -x (default = False)

  • flipy (bool) – flip y coordinate y -> -y (default = False)

  • move ((float, float, float)) – (x, y, a) translation after any scaling and/or flipping (default = (0, 0, 0)).

Returns

transformed polygon points

Return type

(list of (float, float))

nazca.geometries.trapezoid(length=10, height=4, angle1=45, angle2=45, position=1, shift=0, 0)

Return trapezoid polygon.

nazca.icons module

Module to create icons for building blocks from template functions.

nazca.icons.Tp_icon_MZI(bufx=None, bufy=None, layer=None, move=0, 0, 0)

Template for functions to draw MZI icons.

Parameters

() (layer) – layer to draw the icon in

Returns

function

nazca.icons.Tp_icon_Yjunction(bufx=None, bufy=None, layer=None, move=0, 0, 0)

Template for functions to draw Y-junction icons.

Parameters

() (layer) – layer to draw the icon in

Returns

function

nazca.icons.Tp_icon_circ_pad(bufx=None, bufy=None, layer=None, move=0, 0, 0)

Template to draw circular pad icons.

Returns

function

nazca.icons.Tp_icon_diode(layer=None, move=0, 0, 0)

Template for functions to draw photo-diode icons.

Parameters

() (layer) – layer to draw the icon in

Returns

function

nazca.icons.Tp_icon_diode_gsg(layer=None, move=0, 0, 0)

Template to draw GSG diode icons.

Parameters

() (layer) – layer to draw the icon in

Returns

function

nazca.icons.Tp_icon_directional_coupler(bufx=None, bufy=None, layer1=None, layer2=None, move=0, 0, 0)

Template for functions to draw directional coupler icons.

Parameters
  • () (layer2) – layer-1 to draw the icon in

  • () – layer-2 to draw the icon in

Returns

function

nazca.icons.Tp_icon_grating(layer=None, move=0, 0, 0)

Template to grating icons.

Parameters

() (layer) – layer to draw the icon in

Returns

function

nazca.icons.Tp_icon_mir(Nin=2, bufx=None, bufy=None, layer=None, move=0, 0, 0)

Template to draw icons for a N-port MIR shape.

Parameters
  • Nin (int) – number of input guides

  • Nout (int) – number of output guides

  • layer (int | tuple) – layer to draw icon in

Returns

function returning a Polygon with MIR shape

Return type

function

nazca.icons.Tp_icon_mmi(Nin=2, Nout=2, bufx=None, bufy=None, layer=None, move=0, 0, 0)

Template to draw icons for a NxM MMI shape.

Parameters
  • Nin (int) – number of input guides

  • Nout (int) – number of output guides

  • layer (int | tuple) – layer to draw icon in

Returns

function returning a Polygon with MMI shape

Return type

function

nazca.icons.Tp_icon_rounded_pad(bufx=None, bufy=None, layer=None, move=0, 0, 0)

Template to draw rounded pad icons.

Returns

function

nazca.icons.Tp_icon_ssc(layer=None, move=0, 0, 0)

Template to draw spot-size convertor icons.

Parameters

() (layer) – layer to draw the icon in

Returns

function

nazca.icons.Tp_icon_strt(bufx=0, bufy=0, layer=None, move=0, 0, 0)

Template to draw straight waveguide icons.

Returns

function

nazca.icons.Tp_xsection_transition(layer1=None, layer2=None, move=0, 0, 0)

Template to draw waveguide transistion icons.

Returns

function

nazca.icons.calc_buf(length, width, bufx=None, bufy=None)

Calculate icon size and buffer between the icon and the BB edge.

If no buffer value is provided (None) the icon will be scaled to the size of the BB based on module parameters ‘scale_length’ and ‘scale_width’.

If a positive buffer value is provided the icon will adjust to accomodate this buffer between the icon and BB at both sides of the icon.

If a negative buffer value is provided it is interpreted as the absolute size of the icon. Hence, bufy=-10 results in an icon of size 10 in the y-direction.

Parameters
  • length (float) – bb-length (x-direction)

  • width (float) – bb_width (y-direction)

  • bufx (float) – space between the icon and the bb-edge in the x-direction. (default = None)

  • bufy (float) – space between the icon and the bb-edge in the y-direction. (default = None)

Returns

icon-length (x), icon-width (y), side-buffer x, side-bufferf y

Return type

float, float, float, float

nazca.icons.icon_strt(length, width, layer, bufx=None, bufy=None)
nazca.icons.xsection_transition(length, width, layer1, layer2, move=0, 0, 0)

Create an icon for an xs transition.

Returns

icon

Return type

Cell

nazca.interconnects module

Nazca module for interconnecting guides.

class nazca.interconnects.Interconnect(radius=None, width=None, angle=90, xs=None, layer=None, adapt_width=False, adapt_xs=False, instantiate=False, pinstyle=None, offset=None, varname=None, doc='', PCB=False, modes=None)

Bases: object

Interconnect class for drawing waveguides and metal lines.

An Interconnect object can be configured to match a specifc foundry. This includes properties like width, xsection, straight-bend offset and others.

Example

Create two Interconnect objects, each for a different kind of waveguide:

import nazca as nd
import nazca.interconnects as IC

ic1 = IC.Interconnect(width=2.0, radius=20)
ic2 = IC.Interconnect(width=1.0, radius=50)

# use the interconnect objects to create layout:
ic1.strt(length=10).put(0)
ic1.bend(angle=45).put()

ic2.strt(length=20).put(20)
ic2.bend(angle=45).put()

nd.export_plt()
Tp_viper(x, y, w, width1=None, width2=None, xs=None, layer=None, N=200, epsilon=1e-06, name='viper', arrow=True, anglei=None, angleo=None, **kwargs)

Add a viper method to the interconnect’s name space.

Args:

Returns

Viper

Return type

function

__init__(radius=None, width=None, angle=90, xs=None, layer=None, adapt_width=False, adapt_xs=False, instantiate=False, pinstyle=None, offset=None, varname=None, doc='', PCB=False, modes=None)

Construct an Interconnect object.

If a xsection value <xs> is provided for ‘xs’ then values for ‘radius’ and ‘width’ are copied from the <xs> attributes if present.

Any values radius and/or width that are explicitly set in __init__ take priority over values in <xs>.

If xs nor radius and/or width are set an interconnect with the name ‘nazca’ is created and the values are set in via the the values in the cfg module.

Inside interconnects an arrow (‘pinshape’) is placed at the beginning and the end pin of the interconnect.

Parameters
  • radius (float) – default radius in um

  • width (float) – default waveguide width im um

  • angle (float) – default angle of a bend (default=90 degrees)

  • xs (str) – waveguide xsection (default=’nazca’)

  • layer (str) – layer to draw interconnect in. It is preferred to use a xs rather than a layer for Interconnects to store additional information like offset, index, etc. (default=None)

  • adapt_width (bool) – adapt interconnect width to the pin it connects to (default=False)

  • adapt_xs (bool) – adapt interconnect width to the pin it connects to (default=False)

  • instantiate (bool) – instantiate the interconnect cell (default=False)

  • pinstyle – visualisation style of the interconnect pin. default=None uses the default pinstyle from cfg

  • offset (value | func) – if not None then overide the xsection’s straight-bend offset with the provided offset value or function (default=None).

  • PCB (bool) – if true, set maximum angle in bends equal to 45 deg (default=False).

  • modes (list) – list of integers, containing the label of netlist modes for this interconnects

Returns

None

bend(radius=None, angle=None, width=None, pin=None, xs=None, length1=0, length2=0, name=None, arrow=True, offset=None)

Create a bent waveguide (circular arc) with optinal in/out strt sections.

Parameters
  • radius (float) – radius at the center line of the arc in um

  • width (float) – width of the arc in um

  • angle (float) – angle of arc in degree (default=90)

  • pin (Node) – optional Node for modeling info

  • xs (str) – optiinal xsection of bend

  • name (str) – optional new name for the component

  • arrow (bool) – draw connection arrows (default=True)

  • offset (float) – optional new offset for this bend only.

  • length1 (float) – length of an optional straight section before the bend

  • length2 (float) – length of an optional straight section after the bend

Returns

circularly-bent waveguide element

Return type

Cell

Example

Create and place a bend:

import nazca as nd
from nazca.interconnects import Interconnect
ic = Interconnect(width=2.0, radius=10.0)

guide = ic.bend(angle=45)
guide.put()
nd.export_plt()
bend_p2l(radius=None, angle=None, width=None, pin=None, xs=None, length1=0, ref=None, name=None, arrow=True, offset=None, max_length=None)

Create a bent waveguide (circular arc) with optional strt input and ending at a line.

Parameters
  • radius (float) – radius at the center line of the arc in um

  • width (float) – width of the arc in um

  • angle (float) – angle of arc in degree (default=90)

  • pin (Node) – optional Node for modeling info

  • xs (str) – optiinal xsection of bend

  • name (str) – optional new name for the component

  • arrow (bool) – draw connection arrows (default=True)

  • offset (float) – optional new offset for this bend only.

  • length1 (float) – length of an optional straight section before the bend

  • length2 (float) – length of an optional straight section after the bend

  • ref (Node | Instance)| tuple(x, y, a)) – the reference line to intersect

Returns

circularly-bent waveguide element

Return type

Cell

Example

Create and place a bend:

import nazca as nd
from nazca.interconnects import Interconnect
ic = Interconnect(width=2.0, radius=10.0)

guide = ic.bend(angle=45)
guide.put()
nd.export_plt()
bend_strt_bend(pin=None, radius=None, radius1=None, radius2=None, width=None, xs=None, ictype='shortest', name=None, arrow=True)

Generate a bend-straight-bend connection starting at the current pointer.

This is the same connection as ‘bend_strt_bend_p2p’ with pin1 = cp.

bend_strt_bend_p2p(pin1=None, pin2=None, radius=None, radius1=None, radius2=None, width=None, xs=None, length1=0, length2=0, ictype='shortest', name=None, arrow=True)

Generate a point-to-point bend-straight-bend interconnect.

Parameters
  • pin1 (Node | Instance | tuple(x, y, a)) – start pin (default=cp)

  • pin2 (Node | Instance | tuple(x, y, a)) – end pin

  • radius1 (float) – optional first bend radius in um

  • radius2 (float) – optional second bend radius im um

  • width (float) – optional waveguide width in um

  • xs (str) – optional xsection

  • ictype (str) – interconnection type (default=’shortest’) options: ‘shortest’, ‘ll’, ‘lr’, ‘rl’, rr’, ‘all’

  • name (str) – optional new name for the component

  • arrow (bool) – draw connection arrows (default=True)

Returns

bend_strt_bend element

Return type

Cell

Example

Create and place a bend-straight-bend guide to connect two specific points:

import nazca as nd
from nazca.interconnects import Interconnect
ic = Interconnect(width=2.0, radius=10.0)

guide = ic.bend_strt_bend_p2p(pin1=(0, 0, 0), pin2=(40, 20, 90))
guide.put()
nd.export_plt()
cobra_p2p(pin1=None, pin2=None, width1=None, width2=None, radius1=0, radius2=0, offset1=None, offset2=None, xs=None, name=None, arrow=True)

Create point-to-point cobra interconnect with a smooth curve and option to change the width along the curve.

Parameters
  • pin1 (Node | Instance | tuple(x, y, a)) – start pin (default=cp)

  • pin2 (Node | Instance | tuple(x, y, a)) – end pin

  • width1 (float|function) – optional waveguide width in um. This can be a function, w(t). In that case width2 is not used.

  • width2 (float) – optional waveguide width in um at end

  • xs (str) – optional xsection

  • radius1 (float) – radius at start of the cobra (default=0 -> inf)

  • radius2 (float) – radius at start of the cobra (default=0 -> inf)

  • offset1 (float) – lateral offset at pin1

  • offset2 (float) – lateral offset at pin2

  • name (str) – optional new cell name for the component

  • arrow (bool) – draw connection arrows (default=True)

Returns

cobra interconnect element

Return type

Cell

Example

Create and place a cobra waveguide to connect two specific points:

import nazca as nd
from nazca.interconnects import Interconnect
ic = Interconnect(width=2.0, radius=10.0)

guide = ic.cobra_p2p(pin1=(0, 0, 0), pin2=(40, 20, 90))
guide.put()
nd.export_plt()
connect(length=10, width1=None, width2=None, ic=None, name=None)

Connect two different interconnects using tapered shapes.

The xsections of the interconnects need to have the same order and number of guides in the same layers.

Parameters
  • ic (Interconnect) – mandatory interconnect to connect to

  • length (float) – lenght of taper

  • width1 (float) – width of interconnect ‘self’

  • width2 (float) – width of interconnect ‘ic’

  • name (str) – name of cell. Default=’connect’

Returns

taper between two different interconnects ‘self’ -> ‘ic’

Return type

Cell

copy(ic=None)

Create a copy of the Interconnect object.

The copy is created by initializing a new Interconnect with __init__ using only the parameters send to init.

Returns

copy of self

Return type

Interconnect

Example

Create a new interconnect based on an existing interconnect with a different bend radius but otherwise unchanged settings:

import nazca as nd
import nazca.interconnects as IC

ic1 = IC.Interconnect(width=2.0, radius=20)
ic2 = ic1.copy()
ic2.radius = 100
euler(pin=None, width=None, width2=None, radius=None, angle=90, xs=None, name=None, arrow=True)

Create an Euler bend from a straight guide to a curvature of radius at angle.

Parameters
  • pin1 (Node | Instance | tuple(x, y, a)) – start pin (default=cp)

  • width1 (float|function) – optional waveguide width in um. This can be a function, w(t). In that case width2 is not used.

  • width2 (float) – optional waveguide width in um at end

  • angle (float) – end angle

  • radius (float) – end radius

  • xs (str) – optional xsection

  • radius – radius at start of the cobra (default=0 -> inf)

  • name (str) – optional new cell name for the component

  • arrow (bool) – draw connection arrows (default=True)

Returns

Euler interconnect element

Return type

Cell

Example

Create and place a cobra waveguide to connect two specific points:

import nazca as nd
from nazca.interconnects import Interconnect
ic = Interconnect(width=2.0, radius=10.0)

guide = ic.euler(angle=45)
guide.put()
nd.export_plt()
euler2(pin=None, width=None, width2=None, radius=None, angle=45, xs=None, name=None, arrow=True)

Create a symmetric Euler bend with no curacture at the start and minimum curvature radius.

mamba(points, radius=None, width=None, pin=None, xs=None, N=1, pitch=10, offset=0, polyline=True, showpins=False, name=None, arrow=True)

Create a snake-like interconnect guided by a list of points (x, y).

Start and end of a mamba are set as pins ‘a0’ and ‘b0’, respectively. To put the Mamba in the layout in absolute cell coordinates, i.e. on the literal coordinates as provided in <points> use: mamba(…).put(‘org’, 0).

Parameters
  • points – list of (x, y) positions to guide the mamba

  • radius (float) – optional waveguide radius (default self.radius)

  • width (float) – optional waveguide width (default self.width)

  • pin (Node) – optional Node for modeling info

  • xs (str) – optional xsection of mamba

  • N (int) – number of parallel guides in the mamba

  • pitch (float) – pitch of the guide if N>1

  • offset (float) – lateral offset in the position of all guides

  • polyline (bool) – boolean determining if the mamba is also drawn as polyline (default=True)

  • showpins (bool) – show the points as dots in the layout (default=False)

  • name (str) – optional new name for the component

  • arrow (bool) – draw connection arrows (default=True)

Returns

Mamba element based on the provided <points>

Return type

Cell

Example

Create a Mamba and attach the first point to the current pin:

import nazca as nd
from nazca.interconnects import Interconnect
ic = Interconnect(width=2.0, radius=10.0)

guide = ic.mamba(points=[(10, 10), (20, 20), (20, 50), (10, 50)])
guide.put(0) # put first mamba point 'a0' on a pin
guide.put('org', 0) # put mamba 'org' in 0 for absolute coordinates
nd.export_plt()

Hence to put a mamba at absolute coordinates of <points> in the cell:

guide.put('org', 0)
num = 0
pcurve_p2p(pin1=None, pin2=None, width=None, radius1=0, radius2=0, offset1=None, offset2=None, xs=None, name=None, arrow=True)
print_warning = True
ptaper(length=None, width1=None, width2=None, pin=None, xs=None, name=None, arrow=True)

Create a parabolic taper.

Parameters
  • length (float) – length of taper

  • width1 (float) – start width of taper

  • width2 (float) – end width of taper

  • pin (Node) – optional Node for modeling info

  • xs (str) – optional xsection of taper

  • name (str) – optional new name for the component

  • arrow (bool) – draw connection arrows (default=True)

Returns

parabolic taper element

Return type

Cell

Example

Create and place a parabolic taper:

import nazca as nd
from nazca.interconnects import Interconnect
ic = Interconnect(width=2.0, radius=10.0)

guide = ic.ptaper(length=10, width1=2.0, width2=5.0)
guide.put()
nd.export_plt()
rot2ref(pin=None, ref=None, angle=0, length1=0, length2=0, cw=None, width=None, xs=None, radius=None, name=None, arrow=True)

Rotate a waveguide from <pin> to a specific <angle> with respect to reference <ref>.

Parameters
  • pin (Node) – starting pin (default=cp)

  • ref (Node) – reference pin (default=org)

  • angle (float) – rotation with repect to ref (default=0)

  • length1 (float) – length of straight waveguide starting section (default=0)

  • length2 (float) – length of straight waveguide ending section (default=0)

  • cw (bool) – angle direction clockwise or counter clockwise (default is shortest bend)

  • width (float) – width of waveguide

  • xs (str) – optional xsection of waveguide

  • radius (float) – radius at the center line of the bend in um

  • name (str) – optional new name for the component (default=rot2ref)

  • arrow (bool) – draw connection arrows (default=True)

Returns

waveguide element rotating from <pin> into to the desired direction

Return type

Cell

Example

Rotate to angle 125 degree w.r.t. ‘org’ after a straight guide of 100 um:

import nazca as nd
from nazca.interconnects import Interconnect
ic = Interconnect(width=2.0, radius=10.0)

guide = ic.rot2ref(angle=125, length1=10)
guide.put()
nd.export_plt()
rot2ref_solve(pin=None, ref=None, angle=0, cw=None, length1=0, length2=0, width=None, radius=None, xs=None)

Calculate and return the angle to rotate from <pin> to reference direction <ref>.

Note that only the angle part of <ref> is used in the calcuation.

Parameters
  • pin (Node) – starting pin (default=cp)

  • ref (Node) – reference pin (default=org)

  • angle (float) – rotation with repect to ref in [Degrees] (default=0)

  • cw (bool) – angle direction clockwise or counter clockwise (default is shortest bend)

  • name (str) – optional new name for the component

  • arrow (bool) – draw connection arrows (default=True)

Returns

parse-info, angle to rotate from <pin> to <ref> + <a>

Return type

tuple, float

sbend(radius=None, width=None, pin=None, xs=None, offset=20, Ltot=None, length1=None, length2=None, name=None, arrow=True, Amax=90.0)

Create an s-bend interconnect.

Parameters
  • radius (float) – bend radius at the center line of the arc in um

  • width (float) – width of the interconnect in um

  • pin (Node) – optional Node for modeling info

  • xs (str) – xsection of sbend

  • offset (float) – lateral offset of the sbend in um

  • Ltot (float) – optional total forward length of the sbend in um. When positive, additional length is added at the end of the s-bend, when positive it is added at the end, all provided the forward length of the s-bend itself is shorter than abs(Ltot).

  • length1 (float) –

  • length2 (float) –

  • name (str) – optional new name for the component

  • arrow (bool) – draw connection arrows (default=True)

  • Amax – maximum angle of bends. default is 90

Returns

sbend element

Return type

Cell

Example

Create and place a sbend waveguide:

import nazca as nd
from nazca.interconnects import Interconnect
ic = Interconnect(width=2.0, radius=10.0)

guide = ic.sbend(offset=20)
guide.put()
nd.export_plt()
sbend_p2p(pin1=None, pin2=None, width=None, radius=None, Amax=90, xs=None, doStrFirst=1, Lstart=0, BendEndFlag=1, ref=None, name=None, arrow=True, bsb=True)

Create point-to-point s-bend interconnect.

The direction of the end pin is ignored.

Parameters
  • pin1 (Node | Instance | tuple(x, y, a)) – start pin (default=cp)

  • pin2 (Node | Instance | tuple(x, y, a)) – end pin

  • width (float) – width of the interconnect in um

  • radius (float) – bend radius of the interconnect in um

  • xs (str) – optional xsection of sbend

  • doFirst (int) – (default=1)

  • Amax (float) – maximum bend angle (default=90)

  • Lstart (float) – straight waveguide length at beginning (positive value) or end (negative value) of sbend

  • ref (Node) – reference direction for the sbend (default=pin1).

  • name (str) – optional new name for the component

  • BendEndFlag (int) – (default=1)

  • arrow (bool) – draw connection arrows (default=True)

  • bsb (bool) – If True, use bend_straight_bend_p2p() as fallback (default=True)

Returns

sbend element

Return type

Cell

Example

Create and place a sbend to connect two specific points:

import nazca as nd
from nazca.interconnects import Interconnect
ic = Interconnect(width=2.0, radius=10.0)

guide = ic.sbend_p2p(pin1=(0), pin2=(40, 20))
guide.put()
nd.export_plt()
sinebend(width=None, pin=None, xs=None, distance=200, offset=20, name=None, arrow=True)

Create a sine-bend interconnect.

This interconnect has zero curvature at both ends and can be connected without offsets to straight waveguides.

Parameters
  • width (float) – width of the interconnect in um

  • pin (Node) – optional Node for modeling info

  • xs (str) – xsection of sinebend

  • distance (float) – total forward length of the sinebend in um

  • offset (float) – lateral offset of the sinebend in um

  • name (str) – optional new name for the component

  • arrow (bool) – draw connection arrows (default=True)

Returns

sinebend element

Return type

Cell

Example

Create and place a sinebend waveguide:

import nazca as nd
from nazca.interconnects import Interconnect
ic = Interconnect(width=2.0, radius=10.0)

guide = ic.sinebend(distance=100, offset=50)
guide.put()
nd.export_plt()
strt(length=None, width=None, pin=None, xs=None, edge1=None, edge2=None, edgepoints=50, name=None, arrow=True, gridpatch=None)

Create a straight waveguide.

Parameters
  • length (float) – length of guide in um

  • width (float) – width of guide in um

  • pin (Node) – optional Node for modeling info

  • xs (str) – optionals xsection of guide

  • layer (int | str) – layer number or layername

  • edge1 (function) – optional function F(t) describing edge1 of the waveguide

  • edge2 (function) – optional function G(t) describing edge2 of the waveguide

  • edgepoints (int) – optional number of points for edge1 and edge2 (default=50)

  • name (str) – optional new name for the component

  • arrow (bool) – draw connection arrows (default=True)

  • gridpatch (float) – patch gridsnap jumps at grid disconnect of cells with chamfers of size gridpatch. Default=0 is no patch.

Returns

waveguide element

Return type

Cell

Example

Create and place a straight waveguide:

import nazca as nd
from nazca.interconnects import Interconnect
ic = Interconnect(width=2.0, radius=10.0)

guide = ic.strt(length=20)
guide.put()
nd.export_plt()
strt_bend_strt_p2p(pin1=None, pin2=None, radius=None, width=None, xs=None, name=None, arrow=True)

Create point-to-point straight-bend-straight interconnect.

Parameters
  • pin1 (Node | Instance | tuple(x, y, a)) – start pin (default=cp)

  • pin2 (Node | Instance | tuple(x, y, a)) – end pin

  • radius (float) – optional bend radius in um

  • width (float) – optional waveguide width in um

  • xs (str) – optional xsection

  • name (str) – optional new name for the component

  • arrow (bool) – draw connection arrows (default=True)

Returns

strt_bend_strt element

Return type

Cell

Example

Create and place a straight-bend-straight guide to connect two specific points:

import nazca as nd
from nazca.interconnects import Interconnect
ic = Interconnect(width=2.0, radius=10.0)

guide = ic.strt_bend_strt_p2p(pin1=(0, 0, 0), pin2=(40, 20, 90))
guide.put()
nd.export_plt()
strt_p2l(pin=None, ref=None, width=None, xs=None, name=None, arrow=True, max_length=None)

Create a straight guide to intersect a reference line.

p2l: point-to-line. Note there is no solution for a reference line parallel to the pointer in pin. To avoid huge (near parallel) lines, a max-length can be specified.

Parameters
  • pin (Node | Instance | tuple(x, y, a)) – start pin (default=cp)

  • ref (Node | Instance)| tuple(x, y, a)) – the reference line to intersect

  • width (float) – width of the interconnect in um

  • xs (str) – optional xsection of the strt

  • name (str) – optional new name for the component

  • arrow (bool) – draw connection arrows (default=True)

  • max_length – maximum length of the guide

Returns

straight waveguide element

Return type

Cell

strt_p2p(pin1=None, pin2=None, width=None, xs=None, name=None, arrow=True)

Create point-to-point straight interconnect.

Parameters
  • pin1 (Node | Instance | tuple(x, y, a)) – start of waveguide

  • pin2 (Node | Instance | tuple(x, y, a)) – end of waveguide

  • width (float) – width of waveguide

  • xs (str) – optional xsection of waveguide

  • name (str) – optional new name for the component

  • arrow (bool) – draw connection arrows (default=True)

Returns

straight waveguide element

Return type

Cell

Example

Create and place a straight guide between points:

import nazca as nd
from nazca.interconnects import Interconnect
ic = Interconnect(width=2.0, radius=10.0)

guide = ic.strt_p2p(pin1=(0, 0), pin2=(10, 10))
guide.put()
nd.export_plt()
taper(length=None, width1=None, width2=None, shift=0, xs=None, pin=None, name=None, arrow=True)

Create a linear taper.

Parameters
  • length (float) – length of taper

  • width1 (float) – start width of taper

  • width2 (float) – end width of taper

  • shift (float) – lateral shift of taper end

  • xs (str) – optional xsection of taper

  • pin (Node) – optional Node for modeling info

  • name (str) – optional new name for the component

  • arrow (bool) – draw connection arrows (default=True)

Returns

linear taper element

Return type

Cell

Example

Create and place a linear taper:

import nazca as nd
from nazca.interconnects import Interconnect
ic = Interconnect(width=2.0, radius=10.0)

guide = ic.taper(length=10, width1=2.0, width2=5.0)
guide.put()
nd.export_plt()
taper_p2p(pin1=None, pin2=None, width1=None, width2=None, xs=None, name=None, arrow=True)

Create point-to-point (angled) taper interconnect.

Parameters
  • pin1 (Node | Instance | tuple(x, y, a)) – start pin (default=cp)

  • pin2 (Node | Instance | tuple(x, y, a)) – end pin

  • width1 (float) – width at start (taken from pin1 if None)

  • width2 (float) – width at end (taken from pin2 if None)

  • xs (str) – optional xsection of taper

  • name (str) – optional new name for the component

  • BendEndFlag (int) – (default=1)

  • arrow (bool) – draw connection arrows (default=True)

Returns

taper element

Return type

Cell

Example

Create and place a taper to connect two specific points:

import nazca as nd
from nazca.interconnects import Interconnect
ic = Interconnect(width=2, radius=10)

guide = ic.taper_p2p(pin1=(0), pin2=(40, 10), width2=4)
guide.put()
nd.export_plt()
tube(geo, showpins=False, name=None, xs=None, arrow=True)

draw interconnect based on symbols.

Returns

Tube element based on the provided elements

Return type

Cell

ubend(pin=None, offset=20.0, radius=None, width=None, xs=None, length=0, name=None, arrow=True, balance=0, end_angle=False)

Create u-bend interconnect from an offset.

An extra straight length can be added to the ubend with <length>.

If the sideways translation needed in the ubend is <2*radius, then the ubend automatically introduces a ‘horseshoe’ shape. The horseshoe can be made sidelobed by a <balance> parameter between -1 and 1, where 0 results in a symmetric shape.

The orientation of the output pin does not matter unless end_angle=True is set (default=False). If True an extra bend is introduced on pin2 to align its direction with pin1 before drawing an orthogonal ubend.

Parameters
  • pin (Node | Instance | tuple(x, y, a)) – start pin (default=cp)

  • offset (float) – offset of the u-bend

  • radius (float) – optional bend radius in um

  • width (float) – optional waveguide width in um

  • xs (str) – optional xsection of ubend

  • length (float) – extra straight section for longer ubend (default=0)

  • balance (float) – for a ubend <2*radius sidewyas, shift the horseshoe shape (default=0)

  • end_angle (bool) – Take pin2 angle into account when connecting if True (default=False)

Returns

ubend element

Return type

Cell

ubend_p2p(pin1=None, pin2=None, radius=None, width=None, xs=None, length=0, name=None, arrow=True, balance=0, end_angle=False)

Create point-to-point u-bend interconnect.

An extra straight length can be added to the ubend with <length>.

If the sideways translation needed in the ubend is <2*radius, then the ubend automatically introduces a ‘horseshoe’ shape. The horseshoe can be made sidelobed by a <balance> parameter between -1 and 1, where 0 results in a symmetric shape.

The orientation of the output pin does not matter unless end_angle=True is set (default=False). If True an extra bend is introduced on pin2 to align its direction with pin1 before drawing an orthogonal ubend.

Parameters
  • pin1 (Node | Instance | tuple(x, y, a)) – start pin (default=cp)

  • pin2 (Node | Instance | tuple(x, y, a)) – end pin

  • radius (float) – optional bend radius in um

  • width (float) – optional waveguide width in um

  • xs (str) – optional xsection of ubend

  • length (float) – extra straight section for longer ubend (default=0)

  • balance (float) – for a ubend <2*radius sidewyas, shift the horseshoe shape (default=0)

  • end_angle (bool) – Take pin2 angle into account when connecting if True (default=False)

Returns

ubend element

Return type

Cell

Example

Create and place a ubend to connect two specific points:

import nazca as nd
from nazca.interconnects import Interconnect
ic = Interconnect(width=2.0, radius=10.0)

guide = ic.ubend_p2p(pin1=(0, 0, 0), pin2=(10, 20, 90), length=10)
guide.put()
nd.export_plt()
nazca.interconnects.ic_exception(msg='')

Raise interconnect exception if conditions apply.

nazca.interconnects.negDeg(a)

Clip angle to <-360, 0].

Parameters

a (float) – angle in degrees

Returns

angle in degrees

Return type

float

nazca.interconnects.negRad(a)

Clip angle to <-2pi, 0]

Parameters

a (float) – angle in radians

Returns

angle in radians

Return type

float

nazca.interconnects.posDeg(a)

Clip angle to [0, 360>.

Parameters

a (float) – angle in degrees

Returns

angle in degrees

Return type

float

nazca.interconnects.posRad(a)

Clip angle to [0, 2pi>.

Parameters

a (float) – angle in radians

Returns

angle in radians

Return type

float

nazca.interconnects.zeroDeg(a)

Clip angle in degrees between <-180, 180].

Parameters

a (float) – angle in degrees

Returns

angle in degrees

Return type

float

nazca.interconnects.zeroRad(a)

Clip angle to <-pi, pi].

Parameters

a (float) – angle in radians

Returns

angle in radians

Return type

float

nazca.layout module

Generate layout to gds, plt, svg or python script.

Example:

import nazca as nd

nd.export_gds()
nd.export_plt()
nd.export_svg()
class nazca.layout.BBlock(filebasename, outpath='', bbpath='')

Bases: object

Helper class to export a layout as a Nazca GDS building block.

The class create a .py module with a Cell loading the GDS file and placing the pins. Set bb=True in export_gds() to use it.

__init__(filebasename, outpath='', bbpath='')

Initialize BB file: open and add header.

Parameters
  • filebasename (str) – basename of the output file (without extension and no path).

  • outpath (str) – output directory

  • bbpath (str) – path to gds files on the gds py module that loads the BB.

Returns

None

body(topcell)

Write BB file body of element.

Parameters

topcell (Cell) – topcell to export as BB

Returns

None

footer()

Write BB file footer.

Returns

None

class nazca.layout.ClsGDS

Bases: object

Helper class to handle gdsii compatible export of masks.

__init__()

Initialize a ClsGDS object.

Returns

None

open(filebasename)

Open ClsGDS file output.

Parameters

filebasename (str) – base filename

Returns

None

write(level)

Write to ClsGDS output file.

Parameters

level (int) – level in hierarchy to write to

Returns

None

class nazca.layout.ClsMatplotlib

Bases: object

Helper class to handle matplotlib export of masks.

__init__()

Construct an object handling Matplotlib exports.

Returns

None

add_polygon(layer, points, bbox)

Add a polygon to the plot.

Note that using linewidth > 0 significantly slows down drawing in Matplotlib.

Parameters
  • layer (int, int) – mask layer

  • points (list of (float, float)) – polygon points

  • bbox (tuple of floats) – bounding box of polygon (x1, y1, x2, y2)

Returns

None

add_polyline(layer, points, width, bbox)

Add a polyline to the plot.

Not implemented. Polylines are transformed into polygons and send there.

close()

Close plt and show plot.

Returns

None

open(cell=None, title=None, show_pins=True)

Inititialize Matplotlib mask output.

Parameters
  • cell (Cell) – Cell to draw

  • title (str) – title in Matplotlib output

Returns

None

class nazca.layout.ClsNazca(instantiate=True, cellmap=None, layermap=None, flat=None, hierarchy=None, infolevel=0, prefix='', suffix='_N')

Bases: object

Helper class to handle Nazca cell tree transformations.

Note that this class does not reconstruct the netlist in the cell it returns, but manipulates it on element and layer level for the purpose of GDS export.

Use cases: flatten a celltree, change and/or delete or filter layers, cell names, and masl elements.

__init__(instantiate=True, cellmap=None, layermap=None, flat=None, hierarchy=None, infolevel=0, prefix='', suffix='_N')

Initialize a Clsazca object.

Parameters
  • instantiate (bool) –

  • cellmap (dict) – mapping of old_cellname: new_cellname

  • layermap (dict) – mapping of old_layer: new_layer

  • flat (bool) – flatten mask output

  • infolevel (int) –

Returns

None

add_annotation(text, layer, pos)

Add an annitation.

Parameters
  • text (str) – text to use as annotation

  • layer (str) – layer name

  • pos ((float, float)) – annotation posistion (x, y)

Returns

None

add_gds()

Not implemented.

Returns

None

add_instance(inode, xya, flip)

Add instance.

Parameters
  • inode (instance Node) – Node as Instance reference

  • xya ((float, float, float)) – coordinate to put instance

  • flip (bool) – flip or mirror state of the instance placement

Returns

None

add_polygon(layer, xy)

Add a polygon.

Parameters
  • layer (str) – layername

  • xy (list of (float, float)) – list of (x, y)

Returns

None

add_polyline(layer, xy, width=1.0)

Add a polyline.

Parameters
  • layer (str) – layername

  • xy (list of (float, float)) – list of (x, y)

Returns

None

close(params)

Close Cell object.

Returns

Return type

ClsNazca

open(params, new_cell_name=None)

Open new Cell object based on namedtuple <cellinfo>.

Parameters
  • cell (Cell) – original cell to be copied/filtered

  • level (int) – cell level in hierarchy (0 is topcell)

  • new_cell_name (str) – overrule params.new_cell_name

Returns

None

class nazca.layout.ClsPlotlylib

Bases: object

Helper class to handle Plotly export of masks.

Need to be run in a Jupyter notebook due to JavaScript output interface.

__init__()

Construct an object handling Plotly exports.

Returns

None

add_polygon(layer, points, bbox)

Add a polygon to the plot.

Parameters
  • layer (int, int) – mask layer

  • points (list of (float, float)) – polygon points

  • bbox (tuple of floats) – bounding box of polygon (x1, y1, x2, y2)

Returns

None

add_polyline(layer, points, width, bbox)

Add a polyline to the plot.

Not implemented. Polylines are transformed into polygons and send there.

close()

Close ploy and show plot.

Returns

None

open(cell=None, title=None, show_pins=True)

Inititialize Plotly mask output.

Parameters
  • cell (Cell) – Cell to draw

  • title (str) – title in Matplotlib output

Returns

None

class nazca.layout.ClsSVG

Bases: object

Helper class to handle svg compatible export of masks.

__init__()

Initilaize a ClsSVG object.

Returns

None

add_polygon(layer, points, bbox)

Add a polygon to the SVG drawing.

Parameters
  • layer (str) – layername

  • points (list of (float, float)) – polygon points [(x, y), …]

  • bbox ((list of (float, float)) – bounding box the points [(x, y), …]

Returns

None

close()

Close the svg mask layout output file.

Returns

None

open(filebasename='nazca_export')

Open SVG.

Open after layer colors have been loaded.

Parameters

basename (str) – base filename.

Returns

None

class nazca.layout.Export_layout(layermap=None, layermapmode='all', prefix='', suffix='_N')

Bases: object

Class to export a mask layout to various formats.

Export types:

gds plt svg nazca

The Class makes use of one or more of the following class objects in the layout.py module to handle format specific output:

GDS
PLT
SVG
self.CELL
__init__(layermap=None, layermapmode='all', prefix='', suffix='_N')

Initialize an Export_layout object.

Parameters
  • layermap (dict) – layermap oldlayr:newlayer

  • layermapmode (str) – ‘all’: copy all layers, ‘none’: copy only mapped layers, remove others.

Returns

None

add_annotation(*args, **kwargs)
add_annotations(params)

Add annotation content to cell.

Parameters
  • instantiate (bool) – the instantiation level of the cell where the annotation are from: To check for black boxes, which can’t be flattened.

  • params (namedtuple) – replaces all other parameters if not None

Returns

None

add_gds(*args, **kwargs)
add_gdsfiles(params)

Add gds instances to cell.

Parameters
  • gdsfile_iter (iter) – iterator over gdsfiles in the cell

  • level (int) – depth in the hierarchy

Returns

None

add_instance(inode, trans, flip)
add_instances(params)

Add instances to cell.

Parameters
  • instance_iter (iterator) – instance iterator

  • level (int) – hierarchy level

  • params (namedtuple) – replaces all other parameters if not None

Returns

None

add_polygon(layer, points)
add_polygons(params)

Add polygons content to cell.

Parameters
  • pgon_iter (iterator) – polygon iterator

  • level (int) – hierarchy level

  • params (namedtuple) – replaces all other parameters if not None

Returns

None

add_polyline(layer, points, width)
add_polylines(params)

Add polylines content to cell.

In Matplotlib and svg output the polylines are converted to polygons.

Parameters
  • pline_iter (iterator) – polyline iterator

  • level (int) – hierarchy level

  • params (namedtuple) – replaces all other parameters if not None

Returns

None

property ascii

Get ascii export setting.

cell_close(params)

Alias for self.CELL.open if self.nazca = True

Returns

Return type

ClsNazca

cell_open(params, new_cell_name=None)

Alias for self.CELL.open if self.nazca = True

Returns

None

close(params)

Alias for self.CELL.open if self.nazca = True

Returns

Return type

ClsNazca

export_topcells(topcells)

Export topcells.

Loop over each topcell in the topcells list.

Parameters

topcells (list of Cell) – list of topcells

Returns

None

property filebasename

Return filebasename.

Returns

filebasename

Return type

str

property filename

Get filename for export.

Returns

filename

Return type

str

property flat

Get flat export setting.

Returns

flat state

Return type

bool

property gds

Get gds export setting.

Returns

plt export state

Return type

bool

generate_layout(topcells=None)

Internal wrapper function before exporting the layout.

Create final topcells list and set final flags for export.

Parameters
  • topcells (Cell | list of Cells) – Cell(s) to export (default = None, which, exports the ‘nazca’ default gds cell)

  • filename (str) – gds output filename (default = ‘nazca_export.gds’)

  • ascii (bool) – export ascii version of gds (default = False)

  • show_cells (bool) – print exported cell names to stdout (default = False)

  • gds (bool) – export gds (default = True)

  • flat (bool) – export flat gds, i.e. no hierarchy (default = False)

  • plt (bool) – generate matplotlib based layout (default = False)

  • clear (bool) – clear mask layout between consecutive exports (default = True)

  • title (str) – title for the layout if the format allows for a title

  • output (str) – type of output stream (screen, file …)

  • path (str) – output dir for saved Matplotlib plots (default = ‘’)

Returns

None

open(params, new_cell_name=None)

Alias for self.CELL.open if self.nazca = True

Returns

None

property plotly

Get plotly export setting.

property plt

Get plt export setting.

put(*args, **kwargs)
reset()

Reset export settings to defaults.

Returns

None

setlayermap(layermap=None, mode='all')

Create the layermap for export.

Layermap is set internally.

Parameters
  • layermap (dict) – layermap oldlayr:newlayer

  • mode (str) – ‘all’ (default): copy all layers, ‘none’: copy only mapped layers, remove others. Values are case insensitive.

Returns

{layer: export_layer}, layermap as reference for the user

Return type

dict

property svg

Get svg export setting.

topcell()
class nazca.layout.UPDK(filebasename)

Bases: object

Helper class to export a layout as a Nazca uPDK building block.

__init__(filebasename)

Initialize uPDK file: open and add header.

Parameters

filebasename (str) – basename of the output file (without extension).

Returns

None

body(topcell)

Write uPDK file body of element.

Parameters

topcell (Cell) – topcell to export as uPDK

Returns

None

footer()

Write uPDK file footer.

Returns

None

roundlist(L, digits=6)

Avoid very small fractions in floats.

nazca.layout.celltree_iter(cell, level=0, position=None, flat=False, cells_visited=None, infolevel=0)

Alias for a Nelist celltree_iter2 function.

nazca.layout.clear_layout()

Remove all cell references to start a brand new layout.

A new topcell ‘nazca’ will be created.

Returns

None

nazca.layout.export(topcells=None, filename=None, gds=False, ascii=False, plt=False, svg=False, plotly=False, flat=False, infolevel=0, show_cells=False, info=True, clear=None, title=None, output=None, path='', bb=False, bbpath='', uPDK=False, cellmap=None, layermap=None, layermapmode=None, md5=True, submit=False, show_pins=True, hierarchy='apply')

Export layout to gds file for all cells in <topcells>.

Parameters
  • topcells (Cell | list of Cells) – Cell(s) to export (default = None, which, exports the ‘nazca’ default gds cell)

  • filename (str) – gds output filename (default = ‘nazca_export.gds’) The file name may include a path, in which case case the path becomes the base directory. Missing directories will be created.

  • clear (bool) – clear mask layout between consecutive exports (default = True)

  • gds (bool) – export gds (default = True)

  • ascii (bool) – export ascii version of gds (default = False)

  • svg (bool) – export svg file (default = False)

  • plt (bool) – generate matplotlib based layout (default = False)

  • plotly (bool) – generate plotly based layout (default = False)

  • flat (bool) – export flat gds, i.e. no hierarchy (default = False)

  • infolevel (int) – amount of debug info to stdout (default = 0)

  • show_cells (bool) – (default = False)

  • info (bool) – (default = True)

  • title (str) – title for the layout if the format allows for a title

  • output (str) – type of output stream (screen, file …)

  • path (str) – output dir for saved Matplotlib plots (default = ‘’)

  • bb (bool) – export as a library bb (default = False)

  • bbpath (str) – path to use to load a gds for bb=True generated modules (default=””)

  • cellmap (dict) –

  • show_pins (bool) – show pins in the output (default=True)

Returns

None

nazca.layout.export_clear()

Clear the default topcell.

Note that export_clear does not clear or delete any other cells.

Returns

None

nazca.layout.export_gds(topcells=None, filename=None, flat=False, clear=None, bb=False, uPDK=False, md5=False, submit=False, bbpath='', **kwargs)

Export layout to gds file for all cells in <topcells>.

Parameters
  • topcells (Cell | list of Cells) – Cell(s) to export (default = None, which exports the ‘nazca’ default gds cell)

  • filename (str) – gds output filename (default = ‘nazca_export.gds’) The filename may include a path, in which case case the path becomes the base directory. Missing directories will be created.

  • flat (bool) – export flat gds, i.e. no hierarchy (default = False)

  • clear (bool) – clear mask layout between consecutive exports (default = True)

  • bb (bool) – Export design as a building block (default = False)’

  • submit (bool) – create a complete fileset for foundry submission (default=False)

  • md5 (bool) – create md5sum (default=False)

  • bbpath (str) – path to use to load a gds for bb=True generated modules (default=””)

Returns

None

nazca.layout.export_plotly(topcells=None, clear=None, title=None, output=None, path='', show_pins=True, hierarchy='flat', **kwargs)

Export layout with Matplotlib for all cells in <topcells>.

Parameters
  • topcells (Cell | list of Cells) – Cell(s) to export (default = None, which exports the ‘nazca’ default gds cell)

  • clear (bool) – clear mask layout between consecutive exports (default = True)

  • title (str) – title for the layout if the format allows for a title

  • output (str) – Matplotlib output stream (screen, file …) (default = None -> screen)

  • path (str) – output dir for saved Matplotlib plots (default = ‘’)

Returns

None

nazca.layout.export_plt(topcells=None, clear=None, title=None, output=None, path='', show_pins=True, hierarchy='flat', **kwargs)

Export layout with Matplotlib for all cells in <topcells>.

Parameters
  • topcells (Cell | list of Cells) – Cell(s) to export (default = None, which exports the ‘nazca’ default gds cell)

  • clear (bool) – clear mask layout between consecutive exports (default = True)

  • title (str) – title for the layout if the format allows for a title

  • output (str) – Matplotlib output stream (screen, file …) (default = None -> screen)

  • path (str) – output dir for saved Matplotlib plots (default = ‘’)

Returns

None

nazca.layout.export_png(topcells=None, clear=None, title=None, output=None, path='', show_pins=True, hierarchy='flat', **kwargs)

Export layout with Matplotlib for all cells in <topcells>.

Parameters
  • topcells (Cell | list of Cells) – Cell(s) to export (default = None, which exports the ‘nazca’ default gds cell)

  • clear (bool) – clear mask layout between consecutive exports (default = True)

  • title (str) – title for the layout if the format allows for a title

  • output (str) – Matplotlib output stream (screen, file …) (default = None -> screen)

  • path (str) – output dir for saved Matplotlib plots (default = ‘’)

Returns

None

nazca.layout.export_svg(topcells=None, title=None, path='', **kwargs)

Export layout to svg format (scalable vector graphics).

Parameters
  • topcells (Cell | list of Cells) – Cell(s) to export (default = None, which exports the ‘nazca’ default gds cell)

  • title (str) – title for the layout if the format allows for a title

  • path (str) – output dir for saved Matplotlib plots (default = ‘’)

Returns

None

nazca.layout.layout(layermap=None, layermapmode='all', infolevel=0, prefix='', suffix='_N')

Create a layout object for rebuilding cells.’

Parameters
  • layermap (dict) – layermap oldlayer: newlayer

  • layermapmode (str) – ‘all’: copy all layers, ‘none’: copy only mapped layers, remove others.

Returns

layout object

Return type

Export_layout

nazca.layout.rebuild(cell, instantiate=True, flat=False, layermap=None, layermapmode=None, hierarchy='self', infolevel=0, clear=False)

Flatten, rename, relayer, reshape and/or filter a Nazca Cell object.

The original cell remains unchanged.

Parameters
  • cell (Cell) – input cell(tree)

  • instantiate (bool) – instantiate the toplevel (True)

  • flat (bool) – flatten whole rebuild cell

  • layermap (dict) – layermap oldlayer:newlayer

  • layermapmode (str) – ‘all’: copy all layers, ‘none’: copy only mapped layers, remove others.

  • clear (bool) – clear all cells after rebuild (default=False)

Returns

rebuilt input cell

Return type

Cell

nazca.layout.verify_topcells(topcells)

Verify if <topcells> has the correct format.

Parameters

topcells (Cell | list of Cell) – variable to check

Returns

if topcells okay

Return type

None

Exceptions:

ValueError: topcells not valid

nazca.logging module

Set up logging to stdout or a file of the output from Nazca.

Logging is based on the standard Python logging concepts.

nazca.logging.logfile(name='nazca.log', level='INFO', formatter=None, stdout=True, create=False)

Create a file for logging run output.

To log as soon as possible the logger should be placed directly after import nazca and before loading e.g. a PDK.

Parameters
  • name (str) – filename of the logfile. If the name does not and with ‘.log’ it will be added automatically.

  • level (str) – minimum log level (case insensitive) reported: DEBUG, INFO (default), WARNING, ERROR, CRITICAL

  • formatter (str) – format string, if None a default formatter will be used

  • stdout (bool) – set False to switch off a copy of the log to stdout (default=True)

  • create (bool) –

Example

Create a filehandler with the filename of your python file and switch off streamhandler to standard output (stdout):

import nazca as nd
nd.logfile(name=__file__, stdout=False)

# rest of code
Returns

logger

Return type

logger

nazca.logging.newlogfile(name='nazca.log', level='INFO', formatter=None, stdout=True)
nazca.logging.nolog2stdout()

Switch off the logger’s stdout stream.

By default the stdout is on. It is recommended to always use a log file and use the logfile() method instead with stdout=False setting.

Returns

None

nazca.logging.summary(filename='', plot=True)

Summarize errors and warnings in the logfile.

Adds log info entry for number of warning and errors in the logfile.

Parameters
  • filename (str) – logfile, default the main logger.

  • plot (bool) – show warnings + errors in a bar chart, default=True

Retrun:

None

nazca.lowlevel module

Low-level Nazca routines.

class nazca.lowlevel.GDSII_cell(pos=None)

Bases: object

Class for storing GDS cell content.

A cell contains three attributes that constitute all cell content

-header stream -list of element objects (sref, polygon, polyline, etc) -set of cell references <snames> -footer stream

__init__(pos=None)

Initialize a GDSII_cell.

Returns

None

addelem(elem)

Add an GDSII-element to the cell.

Parameters

elem (GDSII_element) –

Returns

None

property name

Get cell name.

Returns

name of the cell

Return type

str

references(sname)

Add a cell reference <sname> to the cell.

Parameters

sname (str) – name of referenced cell

Returns

None

property stream

Create the full stream of the cell.

Concatenate the list of streams of headers, elements and the footer.

Returns

stream of the cell

Return type

bytearray

class nazca.lowlevel.GDSII_element(records=None)

Bases: object

Class for GDS elements.

A GDSii_element object stores a list of GDSII_records and a number of methods to read out the properties (layer and xy position) of each record.

The byte-content of the element is a number of records. The content start and end are identified by a record, i.e. they are the first (element type) and last record (endel) of the element.

Element types are polylines, polygons, sref, aref, etc. Element properties are identifiers like layer, XY, etc., followed by data of the property.

__init__(records=None)

Initialize a GDS element.

Parameters
  • records (list of GDSII_record) – records to store in the element

  • = None) ((default) –

Returns

None

addrecord(record)

Add a GDSII-record to the GDSII_element.

Parameters

record (GDSII_record) – record to add

Returns

None

property annotation

Get the properties of an annotation element.

Returns None if the element is not an annotation.

Returns

layer, position (x, y), text

Return type

[int, tuple, str]

property array

Get the properties of an AREF element.

Returns

layer, position (x, y), text

Return type

[int, tuple, str]

property box

Get the properties of a box element.

Returns None if the element is not an annotation.

Returns

layer, position (x, y)

Return type

[int, tuple, str]

property etype

Return element type.

The element type is the first record in the ‘records’ list. Element types are in set ‘elm_open’.

property instance

Get the properties of a SREF element.

Returns

layer, position (x, y), text

Return type

[int, tuple, str]

property polygon

Get the properties of a polygon.

Returns None if the element is not a polygon.

Returns

layer, position (x, y)

Return type

[int, tuple]

property polyline

Get the properties of a polyline.

Returns None if the element is not a polyline.

Returns

layer, position (x, y)

Return type

[int, tuple]

property stream

Create a stream of all records in the GDSII_element.

Returns

gds stream

Return type

bytearray

class nazca.lowlevel.GDSII_record(strm, pos=0)

Bases: object

Class for storing a GDSii record in byte stream format.

Note that cells and elements are (build from) records. Records have the following structure:

byte 0, 1: record byte length

byte 2, 3: record-type (GDS-records)

byte 4, 5: data-type (GDS_datatype). NODATA when there is no data.

byte 6, rlen: data, or nothing when data-type is NODATA

__init__(strm, pos=0)

Construct a GDSII_record.

Parameters
  • strm (bytearray) – stream

  • pos (int) – start of record in the stream

Returns

None

property data

Convert the gds stream into proper data.

Returns

None

property dtype

Get GDS data-type.

Returns

data-type value

Return type

uint8

property rlen

Return record length.

GDSII spec defines length as signed 2-byte int, but the sign does not make sense and there are GDSII files with large (> 0x8000) record lengths. By using unsigned here (uint16), we can also read those files.

property rtype

get GDS-record-type

Returns

record-type value

Return type

uint8

property stream

Return the proper bytestream for this record.

Returns

record

Return type

bytearray

class nazca.lowlevel.GDSII_stream(filename, cellmap=None, layermap=None, layermapmode=None, parse=True)

Bases: object

Class to read, modify and write a GDSII stream.

A stream consists of a header, cells with elements and a footer.

ASCII_write(filename=False)

Write the GDS in a human readable format.

If no filename is given (False) output is directed to stdout.

Parameters

filename (str) – output filename for ascii representation of gds (default = False)

Returns

gds in ascii representation

Return type

str

GDSII_stream_cell(cellname)

Return the GDSII stream of the cell with name <cellname> and below.

Parameters

cellname (str) – name of the cell to get the gds stream off

Returns

gds stream

Return type

bytearray

GDSII_write(filename)

Write a GDSII stream to file.

Parameters

filename (str) – output filename for binary gds

Returns

None

GDSII_write_cell(cellname, filename)

Write a cell (and the cells referenced by it).

Parameters
  • cellname (str) – name of the cell to write

  • filename (str) – name of the file the gds stream is saved in

Returns

None

__init__(filename, cellmap=None, layermap=None, layermapmode=None, parse=True)

Initiliaze a GDSII_stream.

Parameters
  • filename (str|bytes) – file name to read or buffer with contents of gds file, in bytes or bytesarray.

  • cellmap (dict) – {celname_old:cellname_new} optional dictionary to map cell names in <filename> onto new names in the stream

  • layermap (dict) – {layer_number_old:layer_number_new} optional dictionary to map layer numbers in <filename> onto new layer numbers in the stream

Returns

None

cell_branch(cellname, cellnames=None, level=0)

Create a set of cellnames of all cells in branch <cellname>.

Returns

cellnames

Return type

set

count_srefs()

Print how many times cells have been instantiated to stdout.

create_cellmap(cellmap)

Create a valid internal cellmap from the provided <cellmap>.

The internal cellmap is stored in dict self.cellmap.

Parameters

(dict (cellmap) –

)

Returns

None

create_layermap(layermap, layermapmode)

Create a valid internal layermap from the provided <layermap>.

The internal layermap is stored in dict self.layermap

Parameters

(dict (layermap) –

)

Returns

None

gds_record_iter(strm, strmlen, pos=0)

Generator over the cell records.

Parameters
  • strm (bytearray) – GDS stream

  • strmlen (int) – length of the stream to iterate over

  • pos (int) – start position in the stream (default = 0)

Yields

GDSII-record – next record object, be it cell, element or element-property

property gdsversion
property libname
parse()

Find all the cells in a GDS and add them to an internal dictionary.

This method uses a record iterator to scan its GDS stream and construct an internal dictionary of GDS cells and elements with cell mapping and layer, datatype mapping applied.

Returns

None

print_structure(name=None, sort=False)

Print the cell tree in ascii format.

Parameters
  • name (str | list of str) – cellname(s)

  • sort (bool) – sort cellnames alphabetically

Returns

None

topcell()

Get all topcells in the stream.

Returns

list of all cell names that are top cells (are not referenced)

Return type

list of str

nazca.lowlevel.get_cell_annotation(cell, convert=False)

Yield the <cell>’s annotations one by one.

If convert is False then return XY as integers, as in GDSII file (nm). If convert is True then return XY as floats (um).

cell (str): GDS cell name convert (bool): default convert=False

Yields

int, (int, int) | (float, float) – annotation layer, position, text

nazca.lowlevel.get_cell_polygon(cell, convert=False)

Yield the <cell>’s polygons one by one.

If convert is False then return XY as integers, as in GDSII file (nm). If convert is True then return XY as floats (um).

cell (str): GDS cell name convert (bool): convert polygon’s values to float (default = False)

Yields

int, (int, int) | (float, float) – layer, XY

nazca.lowlevel.get_cell_polyline(cell, convert=False)

Yield the <cell>’s polylines one by one.

If convert is False then return XY as integers, as in GDSII file (nm). If convert is True then return XY as floats (um).

cell (str): GDS cell name convert (bool): convert polyline’s values to float (default = False)

Yields

int, (int, int) | (float, float) – layer, XY

nazca.mask_elements module

This module defines mask elements such as straight and bend waveguides via template functions.

Functions in mask_elements work with closures on nested functions. They are templates functions and not specifically intended for use in mask design directly by the designer. Instead use the interconnect module and/or the predefined interconnects in design kits.

However, a number of waveguide functions have been predefined in this module for quick access and skipping Interconnect objects:

  • strt = Tp_straight()

  • bend = Tp_arc()

  • ptaper = Tp_ptaper()

  • taper = Tp_taper()

  • cobra = Tp_cobra()

  • sinebend = Tp_sinecurve()

nazca.mask_elements.Tp_arc(radius=10, width=1.0, angle=90, xs=None, layer=None, offset=None, name=None, modes=None)

Template for creating a parametrized circular arc waveguide function.

Parameters
  • radius (float) – radius at the center line of the arc in um.

  • width (float) – width of the arc in um.

  • angle (float) – angle of arc in degree (default = 90).

  • xs (str) – xsection of taper

  • layer (int | str) – layer number or layer name

  • offset (float | function) – positive offset reduces radius. The offset can be a function F(width, radius) that returns a float

  • modes (list) – list of integers, containing the labels of netlist modes

Returns

Function returning a Cell object with an arc

Return type

function

nazca.mask_elements.Tp_arc2(radius=10, width=1.0, angle=90, xs=None, layer=None, offset=None, name=None)

Template for creating a parametrized angled arc waveguide function.

The arc is composed of straight sections. Minimum angle between sections is 45 deg.

Parameters
  • radius (float) – radius at the center line of the arc in um.

  • width (float) – width of the arc in um.

  • angle (float) – angle of arc in degree (default = 90).

  • xs (str) – xsection of taper

  • layer (int | str) – layer number or layer name

  • offset (float | function) – positive offset reduces radius. The offset can be a function F(width, radius) that returns a float

Returns

Function returning a Cell object with an arc composed of straight sections

Return type

function

nazca.mask_elements.Tp_cobra(xya=100, 100, 10, width1=1.0, width2=1.0, radius1=0, radius2=0, offset1=None, offset2=None, xs=None, layer=None, name=None)

Template for creating parametrized cobra waveguide function.

Parameters
  • xya (point) – point to connect to from (0,0,0)

  • width1 (float) – width of waveguide

  • width2 (float) – width of waveguide at end

  • radius1 (float) – radius at start (0 is no curvature)

  • radius2 (float) – radius at end (0 is no curvature)

  • offset1 (float | function) – positive offset reduces radius. The offset can be a function F(width, radius) that returns a float

  • offset2 (float | function) – positive offset reduces radius. The offset can be a function F(width, radius) that returns a float

  • xs (str) – xsection of waveguide

  • layer (str | tuple | int) – layer number or layer name

Returns

Function returning a Cell object with the cobra guide

Return type

function

nazca.mask_elements.Tp_euler(width1=1.0, width2=1.0, radius=50, angle=90, xs=None, layer=None, name='euler', modes=None)

Template for creating an Euler bend.

Call the template with which <radius> to achieve at a specified <angle>. The Euler function will then always follow that same shape, also for partial angles.

Parameters
  • width1 (float) – begin width

  • width2 (float) – end width

  • radius (float) – end radius for calibration

  • angle (float) – end angle for calibration

  • xs (str) – xsection na,e

  • layer (str | tuple | int) – mask layer

  • name (str) – element name (default=’euler’)

Returns

Function returning a Cell object with the Euler guide

Return type

function

nazca.mask_elements.Tp_ptaper(length=100, width1=1.0, width2=3.0, xs=None, layer=None, name=None, modes=None)

Template for creating a parametrized parabolic taper function.

Note that zero length taper segments may seem to overlook width pin2pin DRC.

Parameters
  • length (float) – length of the taper

  • width1 (float) – width at start

  • width2 (float) – width at end

  • xs (str) – xsection of taper

  • layer (int | str) – layer number or layer name

Returns

Function returning a Cell object with a ptaper

Return type

function

nazca.mask_elements.Tp_sinecurve(width=1.0, distance=200, offset=20, xs=None, layer=None, name=None)

Template for creating parametrized sine curve waveguide function.

Parameters
  • width (float) – width of the interconnect in um

  • pin (Node) – optional Node for modeling info

  • xs (str) – xsection of sinebend

  • distance (float) – total forward length of the sinebend in um

  • offset (float) – lateral offset of the sinebend in um

  • xs – xsection of waveguide

  • layer (int | str) – layer number or layer name

Returns

Function returning a Cell object with the sinecurve guide

Return type

function

nazca.mask_elements.Tp_straight(length=10, width=1.0, xs=None, layer=None, edge1=None, edge2=None, edgepoints=50, name=None, modes=None)

Template for creating parametrized straight waveguide function.

Parameters
  • length (float) – length of waveguide

  • width (float) – width of waveguide

  • xs (str) – xsection of taper

  • layer (int | str) – layer number or layername

  • edge1 (function) – optional function F(t) describing edge1 of the waveguide

  • edge2 (function) – optional function G(t) describing edge2 of the waveguide

  • edgepoints (int) – number of edge point per edge if the edge is set (default=50)

  • modes (list) – list of integers, containing the labels of netlist modes

Returns

Function returning a Cell object with a straight guide

Return type

function

nazca.mask_elements.Tp_taper(length=100, width1=2, width2=3, shift=0, xs=None, layer=None, name=None, modes=None)

Template for creating a parametrized linear taper function.

Note that zero length taper segments may seem to overlook width pin2pin DRC.

Parameters
  • length (float) – length of the taper

  • width1 (float) – width at start

  • width2 (float) – width at end

  • shift (float) – lateral shift at taper end resulting in a skew taper

  • xs (str) – xsection of taper

  • layer (int | str) – layer number or layer name

Returns

Function returning a Cell object with a linear taper

Return type

function

nazca.mask_elements.Tp_viper(x, y, w, width1=None, width2=None, xs=None, layer=None, N=200, epsilon=1e-06, name='viper', params={}, anglei=None, angleo=None, **kwargs)

Template for a specific Viper implementation.

Free parameter in function x, y, and w are provides via ** kwarg. Note that when using Tp_Viper all free parameters used in x, y, and w methodsmust be provided.

The input and output facet of the polygon are calculated from the discretised points. This may differt from the actual angle at the facets. The angles can be set explicitly by providing angles via “anglei” and “angleo”.

Parameters
  • x (function) – function in at least t, t in [0,1]

  • y (function) – function in at least t, t in [0,1]

  • w (function) – function in at least t, t in [0,1]

  • width1 (float) – begin width

  • width2 (float) – end width

  • xs (str) – xsection na,e

  • layer (str | tuple | int) – mask layer

  • name (str) – element name (default=’viper’)

  • N (int) – number of polygon points (default=200)

  • epsilon (float) – infinitesimal step size to calucalte the begin and end ange

  • anglei (float) – set explicit angle of the input facet

  • angleo (float) – set explicit angle of the output facet

  • **kwarg – free parameters

Returns

Function returning a Cell object with the Viper

Return type

function

nazca.mask_elements.bend(radius=10, width=1.0, angle=90, xs=None, layer=None, offset=None, name=None)

Create a circular arc element.

A straight-bend offset is included when it has been defined in the xsection used.

Parameters
  • radius (float) – radius at the center line of the arc in um.

  • width (float) – width of the arc in um.

  • angle (float) – angle of arc in degree (default = 90).

  • xs (str) – xsection of taper

  • layer (int | str) – layer number or layer name

  • offset (float | function) – positive offset reduces radius. The offset can be a function F(width, radius) that returns a float

Returns

circular arc element

Return type

Cell

nazca.mask_elements.cobra(xya=100, 100, 10, width1=1.0, width2=1.0, radius1=0, radius2=0, offset1=None, offset2=None, xs=None, layer=None, name=None)

Create a parametric waveguide element.

Parameters
  • xya (point) – point to connect to from (0,0,0)

  • width (float) – width of waveguide

  • xs (str) – xsection of waveguide

  • layer (int | str) – layer number or layer name

Returns

cobra element

Return type

Cell

nazca.mask_elements.euler(width1=1.0, width2=1.0, radius=None, angle=90, xs=None, layer=None, name='euler')

Create an Euler bend element.

Args: width1 (float): begin width width2 (float): end width radius (float): optional to overrule the end-radius calibraton value. angle (float): end angle xs (str): xsection name layer (str | tuple | int): mask layer name (str): optional new element name

Returns

Euler bend element

Return type

Cell

nazca.mask_elements.handle_missing_xs(xs)

Handle missing xsections or xsection missing mask_layers.

If xsection <xs> is not defined, create a xsection with layer. A warning is issued, expect if the Nazca default xsection ‘nazca’ is created.

If the xsection exists but has not mask_layer attribute this function will add a default layer to the xsection. The xsextions ‘dump’ and ‘error’ are special cases.

Returns

layer if any has been created in this method.

Return type

layer

nazca.mask_elements.layeriter(xs=None, layer=None)

Generator yielding all layers in a xsection.

Parameters
  • xs (str) – xsection name

  • layer (int) – layer number

Yields

layer, growx, growy, accuracy – iterate over all layers in <xs> and <layer>

nazca.mask_elements.ptaper(length=100, width1=1.0, width2=3.0, xs=None, layer=None, name=None)

Create a parabolic taper element.

Parameters
  • length (float) – length of taper

  • width1 (float) – start width of taper

  • width2 (float) – end width of taper

  • xs (str) – xsection of taper

  • layer (int | str) – layer number or layer name

Returns

parabolic taper element

Return type

Cell

nazca.mask_elements.sinebend(width=1.0, distance=200, offset=20, xs=None, layer=None, name=None)

Create a (raised) sine bend waveguide element.

Parameters
  • width (float) – width of the interconnect in um

  • pin (Node) – optional Node for modeling info

  • xs (str) – xsection of sinebend

  • offset (float) – lateral offset of the sinebend in um

  • distance (float) – total forward length of the sinebend in um

  • xs – xsection of waveguide

  • layer (int | str) – layer number or layer name

Returns

sinecurve element

Return type

Cell

nazca.mask_elements.strt(length=10, width=1.0, xs=None, layer=None, edge1=None, edge2=None, edgepoints=50, name=None, gridpatch=0)

Create a straight waveguide element.

The edge option allow for defining parametrized edges as a perturbation of the standard edges. If the edges have to interpreted as an absolute value, then set width=0. Note that if edge1 function is defined and edge2 is not then edge2 is -edge1.

Parameters
  • length (float) – length of waveguide

  • width (float) – width of waveguide

  • xs (str) – xsection of waveguide

  • layer (int | str) – layer number or layer name

  • edge1 (function) – optional function F(t) describing edge1 of the waveguide

  • edge2 (function) – optional function G(t) describing edge2 of the waveguide

  • edgepoints (int) – number of edge points per edge if edge1 is set (default=50)

Returns

straight element

Return type

Cell

nazca.mask_elements.taper(length=100, width1=2, width2=3, shift=0, xs=None, layer=None, name=None)

Create a taper element.

Parameters
  • length (float) – length of taper

  • width1 (float) – start width of taper

  • width2 (float) – end width of taper

  • shift (float) – lateral shift at taper end resulting in a skew taper

  • xs (str) – xsection of taper

  • layer (int | str) – layer number or layer name

Returns

taper element

Return type

Cell

nazca.mask_layers module

This module defines 1- layers in DataFrame ‘layer_table’ 2- xsections in DataFrame ‘xsection_table. 3- xsection layers in DataFrame ‘xsection_layer table’, adding layers to each ‘xs’ 4- The ‘layer_table’ and ‘xsection_layer table’ are joined using the ‘layer2xsection table’.

The result is stored in a dictionary containing the xsection-layer information per ‘xs’ needed in layout: ‘xsection_layers’

Layers and xsection can be added in two ways 1 - Loading from csv file: load_layers, load_xs 2 - Functions add_layer, add_xsection When adding layers to a ‘xs’ the xs_map is built automatically.

It is also possible to first load layers and xs, and then extend them via ‘add_layer’ and/or ‘add_layer2xsection’.

nazca.mask_layers.add_XSdict(name, name_foundry=None, origin='add_xsection', stub=None, description='')

Create a new Xsection object named <name>.

If a Xsection with <name> already exists, the existing Xsection is returned.

Parameters
  • name (str) – xsection name.

  • name_foundry (str) – optional xsection name used by the foundry

  • origin (str) – source/creator of the layer, e.g. ‘user’, ‘foundry’ or any string.

  • stub – xsection name to be used for the stub of this xsection

Returns

Xsection object with name <name>

Return type

Xsection

nazca.mask_layers.add_layer(name=None, layer=None, tech=None, accuracy=None, fab_name=None, origin=None, remark=None, description='', overwrite=False, frame_color=None, fill_color=None, frame_brightness=None, fill_brightness=None, dither_pattern=None, valid=None, visible=None, transparent=None, width=None, marked=None, animation=None, alpha=None, unknown=False, merge=True)

Create a new mask layer.

Parameters
  • name (str) – layer name

  • layer (int | tuple) – layer number or (layer, datatype)

  • tech (str) – technology ID

  • accuracy (float) – mask resolution of the layer in um

  • fab_name (str) – optional name used by the foundry for this layer

  • origin (str) – who created the layer

  • remark (str) – extra info for the layer

  • overwrite (bool) – overwrite an existing layer if True (default=False)

  • unknown (bool) – True if redirected from get_layer (default = False)

  • merge (bool) – if True merge xscetion and layers (default is True)

  • .. – color attributes

  • skip_color – skip setting of color attributes if True

Returns

Table of mask layers

Return type

DataFrame

nazca.mask_layers.add_layer2xsection(xsection='name', layer=None, growx=None, leftedge=None, rightedge=None, growy=None, growy1=None, growy2=None, accuracy=None, fab_name=None, origin=None, overwrite=False, polyline=False, remark=None)

Add a layer to the Xsection object with name <xsection>.

If <xsection> does not exist yet it will be created. The layer entry is described by (layer, datatype). If the (layer, datatype) does not exist yet it will be created. The keyword ‘accuracy’ is only processed in case of a new layer.

The “leftedge” and “rightedge” keywords describe the the waveguide sidewalls by the distance of the guide sidewalls. The waveguide in this concept is oriented on the direction of the positive x-axis and the sidewalls are expressed as the y-coordinate as a*width+b, or in short (a, b), where width is the width of the guide. For a standard waveguide we have leftedge=(0.5, 0.0) and rightedge = (-0.5, 0.0). Swapping the values of leftedge and rightedge generate the same polygon, so the naming is indicative only.

NOTE: growy (or growy1 and growy2 for that matter) will only have an effect on the straight guide and the linear taper.

Parameters
  • xsection (str) – xsection name for use in nazca

  • layer (int | tuple) – layer number or (layer, datatype)

  • growx (float) – growth in x-direction of polygon in the (layer, datatype) (default = 0.0)

  • growy (float) – growth in y-direction of polygon in the (layer, datatype) (default = 0.0)

  • accurary (float) – accuracy of the grid in um of the (layer, datatype) (default = 0.001)

  • fab_name (str) – technology xsection name, e.g. the foundry name for the layer

  • origin (str) – source/creator of the layer, e.g. ‘user’, ‘foundry’

  • overwrite (bool) – Overwrite a layer if it already exists (default=False)

  • polylilne (bool); Render the structures a polyline rather than polygon (defaul=False) –

  • remark (str) – extra info about the layer

  • leftedge (float | (float, float)) – b or (a, b) for an edge at a*width+b, a=0.5 by default

  • rightedge (float | (float, float)) – b or (a, b) for an edge at a*width+b, a=-0.5 by default

Returns

Xsection object having name <xsection>

Return type

Xsection

nazca.mask_layers.add_xsection(name, name_foundry=None, origin='add_xsection', stub=None, description='')

Create a new Xsection object named <name>.

If a Xsection with <name> already exists, the existing Xsection is returned.

Parameters
  • name (str) – xsection name.

  • name_foundry (str) – optional xsection name used by the foundry

  • origin (str) – source/creator of the layer, e.g. ‘user’, ‘foundry’ or any string.

  • stub – xsection name to be used for the stub of this xsection

Returns

Xsection object with name <name>

Return type

Xsection

nazca.mask_layers.add_xsection_layer(xsection='name', layer=None, growx=None, leftedge=None, rightedge=None, growy=None, growy1=None, growy2=None, accuracy=None, fab_name=None, origin=None, overwrite=False, polyline=False, remark=None)

Add a layer to the Xsection object with name <xsection>.

If <xsection> does not exist yet it will be created. The layer entry is described by (layer, datatype). If the (layer, datatype) does not exist yet it will be created. The keyword ‘accuracy’ is only processed in case of a new layer.

The “leftedge” and “rightedge” keywords describe the the waveguide sidewalls by the distance of the guide sidewalls. The waveguide in this concept is oriented on the direction of the positive x-axis and the sidewalls are expressed as the y-coordinate as a*width+b, or in short (a, b), where width is the width of the guide. For a standard waveguide we have leftedge=(0.5, 0.0) and rightedge = (-0.5, 0.0). Swapping the values of leftedge and rightedge generate the same polygon, so the naming is indicative only.

NOTE: growy (or growy1 and growy2 for that matter) will only have an effect on the straight guide and the linear taper.

Parameters
  • xsection (str) – xsection name for use in nazca

  • layer (int | tuple) – layer number or (layer, datatype)

  • growx (float) – growth in x-direction of polygon in the (layer, datatype) (default = 0.0)

  • growy (float) – growth in y-direction of polygon in the (layer, datatype) (default = 0.0)

  • accurary (float) – accuracy of the grid in um of the (layer, datatype) (default = 0.001)

  • fab_name (str) – technology xsection name, e.g. the foundry name for the layer

  • origin (str) – source/creator of the layer, e.g. ‘user’, ‘foundry’

  • overwrite (bool) – Overwrite a layer if it already exists (default=False)

  • polylilne (bool); Render the structures a polyline rather than polygon (defaul=False) –

  • remark (str) – extra info about the layer

  • leftedge (float | (float, float)) – b or (a, b) for an edge at a*width+b, a=0.5 by default

  • rightedge (float | (float, float)) – b or (a, b) for an edge at a*width+b, a=-0.5 by default

Returns

Xsection object having name <xsection>

Return type

Xsection

nazca.mask_layers.add_xsection_stub(xsection, stub)

Assign a stub xsection to a xsection.

The default stub is the xsection itself.

nazca.mask_layers.clear_all()

Clear Nazca layer and xsection structures.

For now only call certain funtions.

Returns

None

nazca.mask_layers.clear_layers()

Clear all objects with layer information.

Returns

None

nazca.mask_layers.clear_xsection_layers()

Drop all rows from layers and xs tables.

Returns

None

nazca.mask_layers.clear_xsections()

Clear xsection dict

nazca.mask_layers.empty_xsections()

Delete info on all xs. Keep layer info.

Returns

None

nazca.mask_layers.get_layer(layer, aslist=False)

Get the layer ID for a specific layer reference.

If the <layername> does not exist a default layer ID is returned.

Parameters
  • layer (str | tuple | int) – layer reference by name | (layer, datatype) | layer

  • aslist (bool) – return layer IDs as a list, which may include multiple entries. default=False.

Returns

layer_ID (layer_name) (or a list of matching layer_names is aslist=True)

Return type

str

nazca.mask_layers.get_layer_tuple(layer)

Get layer information as tuple components (layer, datatype, technology).

Returns

layer info (L, D, T) as a named tuple

Return type

layer_tuple

nazca.mask_layers.get_layers()

Get predefined selection of columns from layer_table DataFrame.

Returns

layer info [‘layer_name’, ‘layer’, ‘datatype’, ‘tech’, ‘accuracy’]

Return type

DataFrame

nazca.mask_layers.get_parameter(name)

Obsolete.

Set parameter value for specific name.

nazca.mask_layers.get_xsection(name)

Return the Xsection object corresponding to <name>.

Parameters

name (str | Node) – xsection name or a pin object

Returns

Xsection object with name <name>

Return type

Xsection

nazca.mask_layers.layer_tuple

alias of nazca.mask_layers.layer_info

nazca.mask_layers.load_layercolors(filename)

Read colormap from a .csv Nazca color table file.

Parameters

filename (str) – filename

Returns

None

nazca.mask_layers.load_layers(filename, tech=None, clear=False, autocolor=False)

Load layer definitions from csv file into the Nazca layer table.

The load can replace existing layer definitions or extend them (default).

Expected csv file format (no spaces after thhe comma!):

layer_name, layer_name_foundry, layer, datatype, accuracy, origin, remark name1,name_alias,2,10,0.001,nazca,this is a remark

Columns may be omitted but at the least use

layer_name,layer,datatype,accuracy name1,2,10,0.001

layer_name: layer name used in Nazca layer_name_foundry: layer name as used by the foundry, if applicable layer: layer number datatype: datatype number accuracy: mask layer resolution in um origin: indicates who defines the layer (foundry, nazca, you?) remark: optional information on the layer

Parameters
  • filename (str) – name of layer definition file in csv format

  • tech (str) – technology name

  • clear (bool) – clear existing layers (default = False)

  • autocolor (bool) – Create automated color settings per layer (default = False)

Returns

table with layers

Return type

DataFrame

nazca.mask_layers.load_masklayers(layer_file=None, xsection_layer_file=None)

Load layer and xsection files and merge them.

This function combines 1. load_layers() 2. load_xsection_layer_map() 3. merge()

Parameters
  • layer_file (str) – layer file name of csv file

  • xsection_layer_file (str) – xsection file name of csv file

Returns

{xsection name: DataFrame with mask layer}

Return type

dict

nazca.mask_layers.load_parameters(filename)

Obsolete

nazca.mask_layers.load_xsection_layer_map(filename, tech=None)

Load the assignment of layers to xsections from <filename>.

Layers or xsections in the file that do not yet exist are created automatically.

Parameters
  • filename (str) – xsection file in csv format

  • tech (str) – technology ID.

Returns

merged xsections and layers.

Return type

DataFrame

nazca.mask_layers.load_xsections(filename)

Load list of xsection from file with stub mapping.

In addition create a stub map dictionary of a xsection to its stub-xsection.

Parameters

filename (str) – xsection map filename in csv format

Returns

table with loaded xsections

Return type

DataFrame

nazca.mask_layers.merge_xsection_layers_with_layers()

Create a dictionary containing tables of xsections joined with layers.

The xsection names are the dictionary keys. The dictionary contains all attributes for mask rightedgefactor, rightedgeoffsetexport.

Left-join xsection table with layer table on (layer, datatype) and chop it up into a dictionay with xsection as key and the join result as values.

Returns

None

nazca.mask_layers.parse_grow(edge, side, default)

Parse growth parameter into a tuple.

Returns

(a, b) grow information as a*width+b

Return type

tuple

nazca.mask_layers.save_colormap(filename=None)

Save a colormap to csv file.

Parameters

filename (str) – output filename

Returns

None

nazca.mask_layers.set_layercolor(layer=None, frame_color=None, fill_color=None, frame_brightness=None, fill_brightness=None, dither_pattern=None, valid=None, visible=None, transparent=None, width=None, marked=None, animation=None, alpha=None)

Set layer color information.

Generate a tabel (DataFrame) with layer color information. For missing attribute values for fill_color and frame_color, the default_colors as specified in colormap cfg.plt_cmap are be applied. Note that the default colormap can be adjusted by the user.

Parameters
  • layer (int | tuple | str) – mask layer

  • tech (str) – technology (default = None)

  • .. – attributes

Returns

None

nazca.mask_layers.set_plt_properties(figsize=14, cmap=None, N=32, alpha=0.3)

Set the default colormap to use in Matplotlib output for mask layout.

Parameters
  • figsize (float) – size of the matplotlib figure (default = 14)

  • cmap (str) – name of the colormap, (default = None uses cfg.plt_cmap_name)

  • N (int) – the number of colors in the map in case of a ‘linearSegmentedColormap’ default = 32)

  • alpha (float) – transparency of the cmap to see through layers (default = 0.3).

Returns

None

nazca.mask_layers.show_layercolors()

Print the layercolor table.

nazca.mask_layers.show_layers()

Print the layer table.

nazca.mask_layers.show_mask_layers()

Print mask_layers dictionary with layer export definitions to stdout.

Returns

None

nazca.mask_layers.show_xsection_layer_map()

Print the xsection_layer_map table to stdout.

Returns

None

nazca.mask_layers.show_xsections()

Print the xsections table.

Returns

None

nazca.netlist module

Nazca classes to construct Nodes, Pointers and Cells, and from those the graphs/netlists of the design.

class nazca.netlist.Annotation(layer=None, text='')

Bases: object

Annotation class.

__init__(layer=None, text='')

Construct an annotation object.

Parameters
  • layer (int | (int, int) | str) – layer number, (layer, datatype) tuple or layer name to put the Polygon in.

  • text (str) – annotation text (default = ‘’)

Returns

None

put(*args)

Put an Annotation object in the layout.

class nazca.netlist.Cell(name='cell', celltype='element', instantiate=True, autobbox=False, hull=None, store_pins=None, hashme=False, cnt=False, params=False, show_hull=False, hull_based_bbox=None)

Bases: object

Cell object, corresponding to a GDS cell when exported to GDS.

A cell has default pins:

‘org’: cell origin (non-chain) ‘a0’ : input pin (chain) ‘b0’ : output pin (chain)

It is up to the user to place ‘a0’ and ‘b0’ at sensible positions in the cell. If not provided, they will be placed at the origin automatically.

When starting a new cell: cp = C.pin[‘org’]

A cell typically contains one or more of the following objects:
  1. pins: A position w.r.t. the cell origin that can be used to connect to.

    method: Pin().put()

  2. cell instances: A reference to another cell

    method: Cell().put()

  3. polygons: A polygon assigned to a specific GDS layer.

    method: Polygon().put()

  4. polylines: A polyline/path assigned to a specific GDS layer.

    method: Polyline().put()

  5. annotations:

    method: Annotation().put()

__init__(name='cell', celltype='element', instantiate=True, autobbox=False, hull=None, store_pins=None, hashme=False, cnt=False, params=False, show_hull=False, hull_based_bbox=None)

Construct a Cell object.

Cell definitions can be nested.

If the cell is defined as the first cell inside a function that has a @hashme decorator, the cell obtains its (unique) name from hashme.

Parameters
  • name (str) – cell name (default=’cell’)

  • celltype (str) – type of cell, option ‘element’, ‘mask’ (default=’element’)

  • instantiate (bool) – flag if the cell is instantiated (default=True)

  • autobbox (bool) – create a cell bounding box (default=False)

  • hull (bool) – calculate bbox as a convex hull (may be slower)

  • store_pins (bool) – store cell pins in annotation inside GDS

  • hashme (bool) – optionally set True if cell obtains information from hashme decorator, but this is autodetected as well.

  • cnt (bool) – append ordinal counter to the cellname (default=False)

  • params (bool) – add parameter annotation in the cell (default=False) Note that autobbox = True will already add parameter annotation.

Returns

None

Example

Create a cell with cell name ‘mycell’ and variable name C. Put the cell in the mask layout and export the layout:

import nazca as nd

with nd.Cell('mycell') as C:
    nd.strt(length=40).put(0)
    nd.bend(angle=15).put()

C.put(0)

nd.export_plt()
add_property(item)

Add item to the cell properties dictionary.

item (dict): new property

Returns

None

close()

Close the cell.

Solve the geometry of the nodes in the Cell. Set the cp back to the position before opening the cell. If default input and/or output pins have not been set yet they will be set on ‘org’, pointing in opposite directions.

Returns

self

Return type

Cell

default_pins(pinin=None, pinout=None)

Set default input and output pin.

Parameters
  • pinin (Node | str) – pin to set as default cell input pin

  • pinout (Node | str) – pin to set as default cell output pin

Returns

None

filter()

Create a new cell after applying a layer filter.

Parameters

layers (list of layer) – layers to keep

Returns

new cell with subset of original layers

Return type

Cell

To be implemented

get_pin(pinname=None, connect=None)

“Parse pinname and connect for put_polygon and put_gds methods.

Returns

pin position, new if needed

Return type

Node

ic_pins()

Generator over interconnect pins, filter out org and bounding box.

Yields

str, Pin – iterator over pins in cell

id = 1
parse_instance_connection(C1, C2, C3, C4, C5, instance=None)

Connect a (closed) cell as an Instance object into the active cell.

Parse up to five connection arguments to extract: pin1, pin2 and (x,y,a):

Parameters
  • C1 (float | Node | Instance) – connection information

  • C2 (float | Node | Instance) – connection information

  • C3 (float | Node | Instance) – connection information

  • C4 (float | Node | Instance) – connection information

  • C5 (float | Node | Instance) – connection information

  • instance (Instance) – instance object to connect to

Returns

instance pin, cell pin, connection

Return type

Node, Node, (x, y, a)

Notes

The connection has the following syntax:

[pin_inst [, translation]]

or

[pin_inst, ] translation [, pin_cell]

  • translation = x | x,y | x, y, a | (x) | (x, y) | (x, y, z), where translation is w.r.t. <pin_cell>

  • pin_inst: pinname of instance (default=’a0’)

  • pin_cell: pinname of cell (default=’org’)

Options:

  • ()

  • (node)

  • (instance)

  • (0,)

  • (0, 0)

  • (0, 0, 0)

  • ((0))

  • ((0, 0))

  • ((0, 0, 0))

  • (0, pin)

  • (0, 0, pin_cell)

  • (0, 0, 0, pin_cell)

  • ((0), pin_cell)

  • ((0, 0), pin_cell)

  • ((0, 0, 0), pin_cell)

  • (pin_inst)

  • (pin_inst, 0)

  • (pin_inst, 0, 0)

  • (pin_inst, 0, 0, 0)

  • (pin_inst, (0))

  • (pin_inst, (0, 0))

  • (pin_inst, (0, 0, 0))

  • (pin_inst, pin_cell)

  • (pin_inst, 0, pin)

  • (pin_inst, 0, 0, pin_cell)

  • (pin_inst, 0, 0, 0, pin_cell)

  • (pin_inst, (0), pin_cell)

  • (pin_inst, (0, 0), pin_cell)

  • (pin_inst, (0, 0, 0), pin_cell)

parse_pin_connection(C1, C2, C3, C4)

Parse pin connection for polygon, polyline, annotation and gds methods.

Parameters
  • C1 (float | Node | instance) – Parsing information

  • C2 (float | Node | instance) – Parsing information

  • C3 (float | Node | instance) – Parsing information

  • C4 (float | Node | instance) – Parsing information

Returns

pin, translation

Return type

Node, (x, y, a)

Example

Options:

  • ()

  • (node)

  • (0,)

  • (0, 0)

  • (0, 0 ,0)

  • ((0))

  • ((0, 0))

  • ((0, 0 ,0))

  • (0, ‘b0’)

  • (0, 0, ‘b0’)

  • (0, 0 ,0, ‘b0’)

  • ((0), ‘b0’)

  • ((0, 0), ‘b0’)

  • ((0, 0 ,0), ‘b0’)

put(*args, flip=False, flop=False, array=None, scale=1.0, drc=None, **kwargs)

Instantiate a Cell object and put it in the active cell.

Parameters
  • *args (float | Node | Instance) – a set of maximum 5 unnamed parameters interpreted as a connection between two pins, where put() connects to the current pin cp For more details see method ‘parse_instance_connection’.

  • flip (bool) – mirror the instance in the vector line (default=False) flip is preformed after any translation and/or rotation. Hint: for connecting waveguides you only need flip (not flop).

  • flop (bool) – mirror the instance in the line perpendicular to the vector (default=False) flop is performed after any translation and/or rotation. A flop is the same as rot(180) + a flip Hint: for mask assembly or connecting bbox pins you may find both flip and flop useful.

  • cp (str) – Set current pin cp to a specific pin after putting (default=’b0’). Example: cp=’b1’

  • array (list) – creates an array instance upon GDS output if not None. Format the array as [col#, [dx1, dy1], row#, [dx2, dy2]] dx1, dy1 is the column vector measured between adjacent elements. dx2, dy2 is the row vector measured between adjacent elements. (default=None)

  • scale (float) – set scaling factor of the instance (default=1.0). In gds the scaling will be set as instance attribute. In case of flattening the instance, the scaling factor will be applied to the instance content.

Returns

reference to the instance of the cell being put

Return type

Instance

Examples

Below are different syntax examples for put.

In the examples we use the following objects:
  • nd.example: a pre-defined cell in Nazca

  • ‘a0’: default input pin name of “example”

  • ‘b0’: default output pin name of “example”

  1. connect the default pin of cell “example” to current pin (cp):

    import nazca as nd
    nd.example_cell().put() # -> put('a0', cp)
    nd.export_plt()
    
  2. connect pin ‘b0’ of cell “example_cell()” to current pin (cp):

    import nazca as nd
    nd.example_cell().put('b0') # -> put('b0', cp)
    nd.export_plt()
    
  3. connect default pin of cell “example_cell()” to its parent cell at org + (10, 20, 30):

    import nazca as nd
    nd.example_cell().put(10, 20, 30) # -> put('a0').move(10, 20, 30)
    nd.export_plt()
    
  4. connect default pin of cell “example_cell()” to instance C at pin ‘b0’:

    import nazca as nd
    C = nd.example_cell().put(0)
    nd.example.put(C.pin['b0']) # -> put('a0', C.pin['b0'])
    nd.export_plt()
    
  5. connect pin ‘b0’ of cell “example_cell()” to instance C at pin ‘b0’:

    import nazca as nd
    C = nd.example_cell().put(0)
    nd.example_cell().put('b0', C.pin['b0']) # -> put('b0', C.pin['b0'])
    nd.export_plt()
    
  6. connect pin ‘b0’ of cell “example_cell()” to instance C at its default out pin, i.e. refering to instance C only without pin attribute is interpreted as connecting to the default output pin of C.:

    import nazca as nd
    C = nd.example_cell().put(0)
    nd.example.put('b0', C) # -> put('b0', C.pin['b0'])
    nd.export_plt()
    
rebuild(instantiate=True, flat=False, layermap=None, layermapmode=None, cellmap=None, infolevel=0, clear=False)

Flatten, rename, relayer, reshape and/or filter a Nazca Cell object.

The original cell(tree) remains unchanged. This method operates at mask-element level. It contructs the output cell(tree) as geometrical info from the ground up, i.e. any circuit-type netlist information will not be copied. Rebuild can be used, for example, to place each layer of a cell at a different position in the mask layout.

Parameters
  • instantiate (bool) – instantiate setting of returned (top)cell. (default=True)

  • flat (bool) – flatten cell(tree) (default=False)

  • layermap (dict) – {oldlayer, newlayer} mapping

  • cellmap (dict) – to be implemented

  • layermapmode ('all' | 'none') – start mapping with all layers included in the map: ‘all’, or an empty map ‘none’. (default=’all’)

Returns

rebuilt input cell

Return type

Cell

class nazca.netlist.Instance(name=None)

Bases: object

Class to store pin information and properties of cell instantiations.

__init__(name=None)

Construct an Instance object.

Returns

None

ic_pins()

Generator over interconnect pins, filter out org and bounding box.

Yields

str, Pin – iterator over pins in cell

id = 0
property length_geo
raise_pins(namesin=None, namesout=None, show=True)

Copy pins of a cell instance to its parent cell.

If a cell A is “put” in cell P, then an instance of cell A is created inside “parent” cell P. Each instance of cell A, say A1, A2, …, contains a copy of all pins of cell A to represent cell A in P at a particular location, rotation, flip state and/or scaling. raise_pins automatically copies all pin attributes.

The instance pins are themselves not pins of cell P. Pins have to be explicitly set in P with nd.Pin.put(). Alternatively, all or part of the pins in an instance can be set at once in P by “raise_pins”, avoiding many nd.Pin().put() statements. This can very useful when an instance has a large number of pins that have to be “raised”.

Note

raise_pins is a method of Class Instance, not of Cell. Hence, it operates on a cell that has been put.

Parameters
  • namesin (list of str) – list of pin names to raise (default=all pins of the instance)

  • namesout (list of str) – list of new names of the raised pins (default=<namesin>)

  • show (bool) – show the pins in the layout with an arrow (default=True)

Returns

None

Example

Raise (copy) all pins of an instance to its parent cell. In the example a 90 degree bend is connected to port ‘a0’ of the new_cell.

Create pins without the raise_pins method looks like this:

# create and put Pins explicitly one by one:
import nazca as nd

with nd.Cell('new_cell') as new_cell:
    instance1 = nd.example_cell().put(100, 200)
    nd.Pin('a0').put(instance1.pin['a0'])
    nd.Pin('b0').put(instance1.pin['b0'])

instance2 = new_cell.put(0)
nd.bend(angle=90).put(instance2.pin['a0'])
nd.export_plt()

Now raise pins with raise_pins on <instance1> in the new_cell. This also copies all pin attributes:

# raise pins
import nazca as nd

with nd.Cell('new_cell') as new_cell:
    instance1 = nd.example_cell().put(100, 200)
    instance1.raise_pins()

instance2 = new_cell.put(0)
nd.bend(angle=90).put(instance2.pin['a0'])
nd.export_plt()

Now raise and rename pins ‘a0’ and ‘b0’ of <instance1> with method raise_pins. Note that the cell default pins, ‘a0’ and ‘b0’, are automatically added to <new_cell>:

# raise and rename pins
import nazca as nd

with nd.Cell('new_cell') as new_cell:
    instance1 = nd.example_cell().put(0)
    instance1.raise_pins(['a0', 'b0'], ['new_a0', 'new_b0'])

instance2 = new_cell.put(0)
nd.bend(angle=90).put(instance2.pin['new_a0'])
nd.bend(angle=-90).put(instance2.pin['a0'])
nd.export_plt()
class nazca.netlist.Netlist

Bases: object

Class for building the netlist.

__init__()

Construct a Netlist object. Singleton.

annotation_iter(cnode, level, infolevel=0)

Generator to iterate over all annotations in a cell (cnode).

Yields

(Pointer, annotation) – Next Annotation and its position

annotation_transflip_iter(cnode, trans, flip, scale, level=0, apply=True, hierarchy='self', infolevel=0)

Generator to iterate over all annotations in a cell (cnode).

Parameters
  • cnode (Node) – cnode to iterate

  • trans (tuple) – translation state of instance

  • flip (bool) – flip state of instance

  • apply (bool) – default=True: Apply translation and flipping

  • infolevel (int) – amount of debug info to display in stdout

Includes translation and flipping.

Yields

(Annotation, (float, float), int) – Next Annotation and its position as (x, y), and a flip multiplyer -1 (flip) or 1

celltree_iter(cell, position=None, hierarchy='self', cells_visited=None, infolevel=0, cellmap=None, topdown=False, revisit=False)

Generator to iterate top-down or bottom-up (default) over the celltree in <cell>.

Translation, flipping and flattening are applied. Go deep first. If a instantiation is found of a cell that already has been iterated over (cells_visited), then this cell will not be scanned again but reused.

Iteration over this Generator with infolevel = 1 will print the Nazca hierarchy, cell-levels to stdout.

Parameters
  • cell (Cell) – topcell to iterate into

  • position ((float, float float)) – xya starting postition of the topcell. default=None, which translates into (0, 0, 0)

  • hierarchy (str) – ‘flat’, ‘self’ (default) or full’. Determines the handling of the instatiate cell attribute: None: follow the cells instaniate setting to flatten cells or not. ‘flat’: collapses the hierarcy into a single level corresponding to setting instantiate=False in all cells. ‘self’ (default): reproduces all cells explicitly while maintaining their instantiate setting. ‘full’: instantiates all cells. This setting is particular relevant when adding instances to a cell as based in this setting. Coordinates returned will be relative to the first instantiated parent as set by this keyword.

  • cells_visited (set) – list of cells_visited. The iterator will skip cells in this set and not iterate into them.

  • infolevel (int) – amount of info printed when iterating

  • cellmap (dict) – Optional dict to rename cells {oldname: newname}. default=None

  • topdown (bool) – indicate topdown (True) or bottom up yielding iteration (False, default)

  • revisit (bool) – go into each instance of each cell (default=False)

Yields

named_tuple – Info to (re)build cells in a netlist branch.

celltree_iter_base(icnode, hierarchy='full', position=None, level=0, infolevel=0)

Generator to iterate over cell of <cnode>, top-down, go deep first.

The tree descents from the provided cnode into instantiated cnode(s) until the no deeper instances are available. For decending into an instance, the inode: - look up the cell object the instance represents, - take that cell’s cnode and use it to seed the next level.

Parameters
  • icnode (Node) – cnode of cell or inode of instance to iterate into

  • level (int) – depth in cell tree, (default=0)

  • position (Pointer) – (default=None)

  • flat (bool) – flatten array instances if True (default=False)

  • infolevel (int) – amount of runtime info to stdout (default=0)

Yields

(Node, int, Pointer, bool, scale)

(cnode, level, position, flip).

Yields next cell, its level in the hierarchy and position

gdsfile_iter(cnode, level, infolevel=0)

Generator to iterate over all GDS files instantiated in a cell (cnode).

Yields

(Pointer, gdsinfo)

Next gds file and info to generate it.

gdsinfo = (filename, cell, newcell, layermap, cellmap, scale)

gdsfile_transflip_iter(cnode, trans, flip, scale, apply, level=0, hierarchy='self', infolevel=0)

Generator to iterate over all GDS files instantiated in a cell (cnode).

Parameters
  • cnode (Node) – cnode to iterate

  • trans (tuple) – translation state of instance

  • flip (bool) – flip state of instance

  • apply (bool) – ignored: always True

  • infolevel (int) – amount of debug info to display in stdout

Yields

(Polyline, (float, float, float), bool) – Next gdsfile and its position (x, y, a), ‘a’ in degrees, and the flip state

instance_iter(cnode)

Generator to iterate over all instances in cell (cnode) one level deep.

Yields

Node – cnode of instance

instance_transflip_iter(cnode, trans, flip, scale, level=0, apply=True, hierarchy='self', infolevel=0)

Generator to iterate over all instances one level deep.

Includes translation and flipping.

Parameters
  • cnode (Node) – cnode to iterate.

  • trans (tuple) – translation state of instance.

  • flip (bool) – flip state of instance.

  • scale (float) – scaling factor.

  • apply (bool) – default=True: Apply translation and flipping.

  • infolevel (int) – amount of debug info to display in stdout.

  • hierarchy (str) – setting on how to process the hierarchy.

Yields

cnode, (float, float, float), bool

cnode of instance (inode),

position (x, y, a), ‘a’ in degrees, flip state

polygon_iter(cnode, level, infolevel=0)

Generator to iterate over all polygons in a cell (cnode).

Yields

(Pointer, Polygom) – Next Polygon object and its position

polygon_transflip_iter(cnode, trans, flip, scale, level=0, apply=True, hierarchy='self', infolevel=0, hull=False)

Generator to iterate over all polygons in a cell (cnode).

Parameters
  • cnode (Node) – cnode

  • trans (tuple) – translation state w.r.t. to (new) parent

  • flip (bool) – flip state w.r.t. to (new) parent

  • scale (float) – scale state w.r.t. to (new) parent

  • apply (bool) – apply translation and flipping (default=True)

  • infolevel (int) – debug info level to stdout

Yields

(Polygon, list((float, float)), tuple(4*float)) | (Polygon, tuple(3*float), tuple(4*float)):

if apply is True (default):

Polygon object, and the polygon points & the bbox w.r.t.
the (possibly new) parent cell.

if apply is False:

Polygon object, its position (x, y, a), 'a' in radians,
the flip state of the polygon
polyline_iter(cnode, level, infolevel=0)

Generator to iterate over all polylines (paths) in a cell (cnode).

Yields

(Pointer, Polyline) – Next Polyline object and its position

polyline_transflip_iter(cnode, trans, flip, scale, level=0, apply=True, hierarchy='self', infolevel=0, hull=False, polygon=False)

Generator to iterate over all polylines in a cell (cnode).

Parameters
  • cnode (Node) – cnode

  • trans (tuple) – translation state w.r.t. to (new) parent

  • flip (bool) – flip state w.r.t. to (new) parent

  • scale (float) – scale state w.r.t. to (new) parent

  • apply (bool) – apply translation and flipping (default=True)

  • hull (bool) – if True work with hull points

  • polygon (bool) – if True work with the polygon rather then polyline points

  • infolevel (int) – debug info level to stdout

Yields

(Polyline, list((float, float)), tuple(4*float)) | (Polyline, tuple(3*float), tuple(4*float)):

if apply is True (default):

Polyline object, and the polyline points & the bbox w.r.t. the (possibly new) parent cell.

if apply is False:

Polyline object, its position (x, y, a), ‘a’ in radians, the flip state of the polyline

solvecell(cell)

Solve the cell with. cnode position will be at (x, y, a) = (0, 0, 0).

Parameters

cell (Cell) – cell to solve

Returns

None

solvecell_core(node, _cnode0=None)

Calculate the geometrical position of nodes in a cell via the netlist.

Include all nodes in the cell (level 0) and all nodes in instantiated cells (level 1). Hence, a node in scope adheres to one of the following conditions:

  • the node resides in same cell as the starting node (parent <cnode0>).

  • the node resides in an instance of the cell of the starting node.

A starting <node> has to be provided from where to solve. A good starting point in each cell is the cnode with its pointer position set at (x, y, a) = (0, 0, 0).

Parameters
  • node (Node) – node from where to start solving the cell

  • _cnode0 (Node) – Internal parameter containing the cnode of the cell to solve. It is automatically obtained from <node> in theh first pass.

Returns

None

class nazca.netlist.Node(name=None)

Bases: object

Node class for creating node objects.

Note that pins in the Nazca design terminology are actually Node objects.

The netlist of Nodes and connections between the nodes (edges) construct the photonic circuit and/or layout.

__init__(name=None)

Contruct a Node.

Parameters

name (str) – optional Node name (default is an integer counter)

Returns

None

property a

Get pointer a-position of the Node.

Returns

pointer a-position with respect to the cell origin

Return type

tuple

angle(angle)

Get pointer a-position of the Node.

Returns

pointer a-position with respect to the cell origin

Return type

tuple

property chain

Attribute to indicate if a Node is a chain connector.

cnode_nb_iter(end=None, auxiliary=None)

Get cnodes at the cell level below the cell level of the node.

Parameters
  • end (bool or None) – include last element

  • auxiliary (bool or None) – filter on auxiliary flag. Ignore flag if None

Yields

Node – next cell node

copy(inplace=False)

Copy a Node object into the active cell or inplace.

Parameters

inplace (bool) – Copy the node into the same cell if False (True) or the active cell (default).

Returns

copy of the node with the same attributes as the original

Return type

Node

Example:

import nazca as nd

n1 = nd.Node()
n2 = n1.copy()
flip()

Create a new Node that is flipped.

A ‘flip’ mirrors the Node in the line of the pointer. Note that a flip state of a Node doesn’t matter in Nazca. Flipping is handled by ‘put’, hence this funtion is equivalent to a Node copy in place (pointer not effected).

Returns

a new Node flipped w.r.t. self

Return type

Node

flop()

Create a new Node that is flopped.

A ‘flop’ mirrors the Node pointer ‘backward’. A flop is effecively a flip + 180 degree rotation. Note that the flip state of a Node or not doesn’t matter in Nazca, hence this flop is equivalent to rot(180).

Returns

a new Node flopped w.r.t. self

Return type

Node

fxy(digits=3)

Get formatted pointer position (x, y) of the Node.

Returns

formatted pointer position (x, y) with respect to the cell origin

Return type

str

fxya(digits=3)

Get formatted pointer position (x, y, a) of the Node.

Returns

formatted pointer position (x, y, a) with respect to the cell origin

Return type

str

geo_nb_iter()

Get geometrical neighbours.

Yields

Node – next neighbour

get_info()

Get information string.

Returns

information on the node.

Return type

str

goto(x=0, y=0, a=0)

Create a new Node at position (<x>, <y>, <a>) relative to the cell origin.

Parameters
  • x (float) – x position in um

  • y (float) – y position in um

  • a (float) – angle a in degrees

Returns

a new Node at (<x>, <y>, <a>) w.r.t. the cell’s origin

Return type

Node

instance_iter(end=None, auxiliary=None)

Get cnodes at the cell level below the cell level of the node.

Parameters
  • end (bool or None) – include last element

  • auxiliary (bool or None) – filter on auxiliary flag. Ignore flag if None

Yields

Node – next cell node

move(x=0, y=0, a=0, xs=0, width=0, radius=0, drc=True)

Create a new Node translated by (<x>, <y>, <a>) with respect to self.

Also ‘width’ and ‘xs’ attributes of the can be ‘moved’. This is for controling DRC on pin2pin connections; It allows for explicitly connecting pins having a different width and or xs without raising a DRC error.

Parameters
  • x (float) – move in x-direction

  • y (float) – move in y-direction

  • a (float) – angle of rotation in degree

  • xs (str) – move to xs

  • width (float) – move to width

  • radius (float) – move to radius

  • drc (bool) – switch off drc if False (default=True)

Returns

a new Node translated by vector (<x>, <y>, <a>)

Return type

Node

offset(y=0, xs=0, width=0, radius=0, drc=True)

Create a new Node that is offset by <y>.

Also ‘width’ and ‘xs’ attributes of the can be ‘moved’. This is for controling DRC on pin2pin connections; It allows for explicitly connecting pins having a different width and or xs without raising a DRC error.

Parameters
  • y (float) – move in y-direction

  • xs (str) – move to xs

  • width (float) – move to width

  • radius (float) – move to radius

  • drc (bool) – switch off drc if False (default=True)

Returns

a new Node translated by vector (0, <y>, 0) w.r.t. self

Return type

Node

os(y=0, xs=0, width=0, radius=0, drc=True)

Create a new Node that is offset by <y>.

Also ‘width’ and ‘xs’ attributes of the can be ‘moved’. This is for controling DRC on pin2pin connections; It allows for explicitly connecting pins having a different width and or xs without raising a DRC error.

Parameters
  • y (float) – move in y-direction

  • xs (str) – move to xs

  • width (float) – move to width

  • radius (float) – move to radius

  • drc (bool) – switch off drc if False (default=True)

Returns

a new Node translated by vector (0, <y>, 0) w.r.t. self

Return type

Node

path_nb_iter(sigtype)

Get path neighbours.

Parameters

sigtype (str) – type of neighbour connections to traverse

Yields

Node – next neighbor

print_neighbours()

Print neighbours of the node in the netlists.

Returns

information on neighbors of this node

Return type

str

rot(a=0, xs=0, width=0, radius=0, drc=True)

Create a new Node rotate pointer by <a>.

Also ‘width’ and ‘xs’ attributes of the can be ‘moved’. This is for controling DRC on pin2pin connections; It allows for explicitly connecting pins having a different width and or xs without raising a DRC error.

Parameters
  • a (float) – angle of rotation in degree

  • xs (str) – move to xs

  • width (float) – move to width

  • radius (float) – move to radius

  • drc (bool) – switch off drc if False (default=True)

Returns

a new Node translated by vector (0, 0, <a>) w.r.t. self

Return type

Node

rot2ref(angle=0.0, ref=None, xs=0, width=0, radius=0, drc=True)

Create a new Node rotate pointer by <a> with respect to node ref.

Also ‘width’ and ‘xs’ attributes of the can be ‘moved’. This is for controling DRC on pin2pin connections; It allows for explicitly connecting pins having a different width and or xs without raising a DRC error.

Parameters
  • angle (float) – angle of rotation in degree w.r.t. ref (default is 0)

  • ref (Node) – if None, org of current cell is assumed

  • xs (str) – move to xs

  • width (float) – move to width

  • radius (float) – move to radius

  • drc (bool) – switch off drc if False (default=True)

Returns

a new Node translated by vector (0, 0, <a>) w.r.t. ref

Return type

Node

rotate(a=0, xs=0, width=0, radius=0, drc=True)

Create a new Node rotate pointer by <a>.

Also ‘width’ and ‘xs’ attributes of the can be ‘moved’. This is for controling DRC on pin2pin connections; It allows for explicitly connecting pins having a different width and or xs without raising a DRC error.

Parameters
  • a (float) – angle of rotation in degree

  • xs (str) – move to xs

  • width (float) – move to width

  • radius (float) – move to radius

  • drc (bool) – switch off drc if False (default=True)

Returns

a new Node translated by vector (0, 0, <a>) w.r.t. self

Return type

Node

shift(x=0, y=0, xs=0, width=0, radius=0, drc=True)

Create a new Node shifting pointer (<x>, <y>), keeping orientation.

Also ‘width’ and ‘xs’ attributes of the can be ‘moved’. This is for controling DRC on pin2pin connections; It allows for explicitly connecting pins having a different width and or xs without raising a DRC error.

Parameters
  • x (float) – move in x-direction

  • y (float) – move in y-direction

  • xs (str) – move to xs

  • width (float) – move to width

  • radius (float) – move to radius

  • drc (bool) – switch off drc if False (default=True)

Returns

a new Node translated by vector (<x>, <y,> 0) w.r.t. self

Return type

Node

skip(x=0, xs=0, width=0, radius=0, drc=True)

Create a new Node skipping <x> in direction of the pointer.

Also ‘width’ and ‘xs’ attributes of the can be ‘moved’. This is for controling DRC on pin2pin connections; It allows for explicitly connecting pins having a different width and or xs without raising a DRC error.

Parameters
  • x (float) – move in x-direction

  • xs (str) – move to xs

  • width (float) – move to width

  • radius (float) – move to radius

  • drc (bool) – switch off drc if False (default=True)

Returns

a new Node translated by vector (<x>, 0, 0) w.r.t. self

Return type

Node

property x

Get pointer x-position of the Node.

Returns

pointer x-position with respect to the cell origin

Return type

tuple

xya()

Get pointer position of the Node.

Returns

pointer position (x, y, a) with respect to the cell origin

Return type

tuple

property y

Get pointer y-position of the Node.

Returns

pointer y-position with respect to the cell origin

Return type

tuple

class nazca.netlist.Pin(name=None, xs=None, layer=None, width=None, radius=None, type=None, pin=None, io=None, flip=False, show=None, remark=None, chain=None)

Bases: object

Pin class

__init__(name=None, xs=None, layer=None, width=None, radius=None, type=None, pin=None, io=None, flip=False, show=None, remark=None, chain=None)

Construct a Pin object.

A Pin object (capital P to denote the class object) holds information to describe a Node object. Nodes are the objects that are connected in a graph to connect layout elements. The Node object is created inside the active cell via the put() method of the Pin. When a Node is created in the active cell it is stored in the pin attribute of the active cell (not to be confused with the Pin object). The pin attribute is a dictionary with the string name of the Pin object as key and the Node object as the value.

Note that Pin represenation in a layout is defined by the pinstyle of the xsection of the pin. The pinstyle maps the xs to the visualisation layer.

Parameters
  • name (str) – name of the Pin to refer to it.

  • xs (str) – xsection name assigned to the pin.

  • layer (str or number) – optional layer to represent the pin. This will add an xs pinstyle. If no xs is provided it will use the default xs. Note that layer is not a pin property.

  • width (float) – width in um of the connection the pin represents

  • radius (float) – radius of curvature at the pin in um.

  • type (str) – extra property for the pin

  • pin (Node) –

  • chain (int) – indicate if pin is a chain or connector (1) or not (0) (default=1)

  • remark (str) – short optional documentation of the Pin (default=None)

  • io (int) – connectivity info in bit form

  • flip (bool) –

    symmetry state of the pin. This flip is only relevant

    for stub representation and DRC checks of assymmetric interconnects,

    default=False.

Returns

None

Example

Create a Pin object and put it in the active cell to create a Node. Subsequently, retreive the Node by name ‘a0’ via cell pin attribute and print properties as set in the Pin object:

import nazca as nd

nd.Cell(name=’test’) as C:

nd.Pin(name=’a0’, width=2.0).put()

p = C.pin[‘a0’] print(p.name) print(p.width) # ‘a0’ # 2.0

put(*args)

Put a Pin object in the layout.

class nazca.netlist.Pointer(x=0.0, y=0.0, a=0.0)

Bases: object

A pointer with state information.

Note: For normal Nazca usage avoid using this class directly and use the methods provided in the Node class instead.

The pointer has the positional information of a node. The positional information is kept in a matrix that holds the homogeneous coordinates. Structures are drawn in local coordinates and are easily converted to the global coordinate system by a matrix multiplication. By using homogeneous coordinates, translations are also described by a matrix multiplication.

__init__(x=0.0, y=0.0, a=0.0)

Constructor.

Parameters
  • x (float) – x coordinate in um

  • y (float) – y coordinate in um

  • a (float) – angle coordinate un degrees

property a

Return angle a of the pointer.

chain180(chain)

Set the chain property of the pointer.

Parameters

chain (bool) – True for chain connecting pins.

Returns

None

copy(flip=False)

Copy pointer.

Returns

copy of the Pointer

Return type

Pointer

flip()

Flip (mirror) the state of the pointer.

Returns

self, flipped

Return type

Pointer

fxya(digits=3)

Get formatted pointer position (x, y, a) of the Node.

Returns

formatted pointer position (x, y, a)

Return type

str

get_xy(x=0, y=0)

Return the (x, y) position of the pointer.

get_xy_a()

Return the pointer position as (x, y, a).

get_xya()

Return the pointer position as (x, y, a).

goto(x, y, a=0.0)

Move pointer to a coordinate relative to the org.

Parameters
  • x (float) – x-coordinate of the pointer position [µm]

  • y (float) – y-coordinate of the pointer position [µm]

  • a (float) – angle of the pointer [degrees]

Returns

None

inv()

Inverse the matrix in the pointer. Returns the pointer.

Returns

self

Return type

Pointer

move(x=0, y=0, a=0.0)

Move pointer relative to current location.

Parameters
  • x (float) – x-coordinate of the pointer position [µm]

  • y (float) – y-coordinate of the pointer position [µm]

  • a (float) – angle of the pointer [degrees]

Returns

self

Return type

Pointer

move_ptr(ptr)

Move pointer relative by a pointer ‘ptr’ w.r.t. current location.

Parameters

ptr (Pointer) – move by value in pointer

Returns

self

Return type

Pointer

multiply_ptr(ptr)

Multiply the pointer by the matrix in <ptr>.

Parameters

ptr (Pointer) – multiply by <ptr>

Returns

self

Return type

Pointer

offset(s)

Translate a pointer perpendicular to the direction it is pointing in.

Note that in a cartesian coordinate system while pointing/looking along the positive x-axis, a positive offset is in the left direction, i.e. along the positive y-axis.

Parameters

s (float) – move pointer along perpendicular direction by <s>

Returns

self, moved pointer

Return type

Pointer

rotate(a)

Rotate pointer by angle a.

Parameters

a (float) – angle of the pointer [degrees]

Returns

self, rotated

Return type

Pointer

set_a(a=0.0)

Set angle absolute. Keep x, y position

Parameters

a (float) – angle of the pointer [degrees]

Returns

self

Return type

Pointer

set_mat(t)

Fill pointer matrix based on vector <t> = (x, y, a).

Parameters

t (tuple) – (x, y, a)

Returns

None

skip(s)

Translate a pointer in the direction it is pointing in.

Parameters

s (float) – move pointer along its direction by <s>

Returns

self, moved

Return type

Pointer

trans(mat)

Translate pointer by matrix <mat>.

Returns

translated by matrix <mat>

Return type

Pointer

property x

Return position x of the pointer.

xy(x=0, y=0)

Return the (x, y) position of the pointer.

xya()

Return the pointer position as (x, y, a).

property y

Return the position y of the pointer.

class nazca.netlist.Polygon(points=None, layer=None)

Bases: object

Polygon class.

__init__(points=None, layer=None)

Construct a Polygon object.

Parameters
  • pinname (str) – name of the pin (obsolete)

  • layer (int | (int, int) | str) – layer number, (layer, datatype) tuple or layer name to put the Polygon in.

  • points (list) – list of points [(x1, y1), (x2, y2), …]

Returns

None

grow(grow=5, accuracy=0.1, jointype='square', layer=None)

Grow the polygon.

Returns

new Polygon with growth applied.

Return type

Polygon

put(*args, flip=False, flop=False, scale=1.0)

Put a Polygon object in the layout.

Parameters
  • flip (bool) – flip state of the polygon put

  • flop (bool) – flop state of the polygon put

  • scale (float) – scaling factor of the Polygon. This scaling looks as if the whole cell the polygon would have scaled. Note that it may be more appropiate to use the ‘transform’ method to scale a Polygon.

Returns:

transform(center=0, 0, 0, scale=1.0, flipx=False, flipy=False, move=0, 0, 0, layer=None)

Transform the points in the Polygon object.

See nazca.geometries.transform().

Returns

new Polygon with transformed points.

Return type

Polygon

class nazca.netlist.Polyline(points=None, layer=None, width=None, pathtype=0, miter=0.5)

Bases: object

Polyline (path) class.

__init__(points=None, layer=None, width=None, pathtype=0, miter=0.5)

Construct a Polyline object.

Parameters
  • pinname (str) – name of the pin (obsolete)

  • layer (int | (int, int) | str) – layer number, (layer, datatype) tuple or layer name to put the Polygon in.

  • width (float) – width of the polyline

  • pathtype (int) – gds type of path: 0 (flush), 1 (round), 2, 3

  • points (list) – list of points [(x1, y1), (x2, y2), …]

  • miter (float) – length at joint of two straight sections (default=0.5)

Returns

None

grow(grow=5, accuracy=0.1, jointype='square', width=None, layer=None)

Grow the polyline.

Returns

new Polyline with growth applied.

Return type

Polyline

put(*args, flip=False, flop=False, scale=1.0)

Put a Polyline object in the layout.

Parameters
  • flip (bool) – flip state of the polygon put

  • flop (bool) – flop state of the polygon put

scale (float): scaling factor of the Polygon. This scaling looks

as if the whole cell the polygon would have scaled. Note that it may be more appropiate to use the ‘transform’ method to scale a Polygon.

Returns:

transform(center=0, 0, 0, scale=1.0, flipx=False, flipy=False, move=0, 0, 0, width=None, pathtype=None, layer=None)

Transform the points in the Polyline object.

See nazca.geometries.transform().

Returns

new Polyline with transformed points.

Return type

Polyline

nazca.netlist.bbinfo(item=None, data=None)

Attach metadata to the Active cell in dictionary bbinfo.’

Parameters
  • item (hashable object) – dictionary key

  • data – The value of the metadata

Returns

None

nazca.netlist.cell_iter(topcell, cellmap=None, flat=False, hierarchy='self', infolevel=0, topdown=False, revisit=False)

Get a cell iterator fo rebuilding cells.

Parameters
  • topcell (Cell) – cell to iterate into.

  • cellmap (dict) – Optional dict to rename cells {oldname: newname}. default=None.

  • flat (bool) – for backward compatibility, same as hierarchy=’flat’ if True and hierarchy not provided, but ignored if hierarchy is provided explicitly.

  • hierarchy (str) – ‘flat’, ‘self’ (default), ‘full’, or ‘apply’.

  • topdown (bool) – indicate topdown (True) or bottom up iteration (False, default)

  • revisit (bool) – go into each instance of each cell (default=False)

Returns

celltree_iter()

Return type

Iterator

nazca.netlist.connect_cnode(n1, n2, s)

Generate cell connection.

Returns

None

nazca.netlist.connect_geo(pin1, pin2, t=0, 0, 0, chain_node=0, chain_connect=None, drc=True, solve=True)

Generate a geometrical edge between two Nodes.

Connect pin1 and pin2 with geometrical transformation t. Pins are only allowed to connect if they the have the same parent cell, same cell or are part of an instance placed in the same parent cell.

Parameters
  • pin1 (Node) – 1st pin

  • pin2 (Node) – 2nd pin

  • t (tuple) – edge value: transformation (x, y, a) to get from pin1 to pin2

  • chain_node (int) – 1 if a chain node, 0 if not (default=0)

  • chain_connect – overrules chain connect rules if None. chain_connect = 0 -> chain pin, chain_connect = 1 -> no-chain pin,

  • (default=None)

  • DRC (bool) – apply DRC on the edge (default=True)

Returns

None

Exceptions:

Pin connection out of scope.

nazca.netlist.connect_optical_path(n1, n2, s, sigtype=None, path=None)

Generate a connection/edge between n1 and n1 with edge s.

n1 (Node): first node n2 (Node): second node s (float): connection value sigtype (str): signal type, e.g. optical (‘opt’) or electrical (‘dc’) path(): list of pins for visualization

Returns

None

nazca.netlist.connect_path(n1, n2, s, sigtype=None, path=None)

Generate a connection/edge between n1 and n1 with edge s.

n1 (Node): first node n2 (Node): second node s (float): connection value sigtype (str): signal type, e.g. optical (‘opt’) or electrical (‘dc’) path(): list of pins for visualization

Returns

None

nazca.netlist.diff(node1, node2)

Calculate the geometrical difference between two nodes.

Parameters
  • node1 (Node) – start node

  • node2 (Node) – end node

Example

Obtain dx, dy, da from p1 to p2:

import nazca as nd

p1 = nd.Pin().put(10, 10, 0)
p2 = nd.Pin().put(20, 30, 45)
dx, dy, da = nd.diff(p1, p2)
print(dx, dy, da)
# (10.0, 20.0, 45.0)
Returns

difference vector <node2> - <node1> between their pointers

Return type

(dx, dy, da)

nazca.netlist.drc_instance_angle(rule, cell=None)

Set design rule for the angle of an instantiated cell.

nazca.netlist.gds_filter(filename, cellmap=None, layermap=None)

Filter layers and cells from gds and export a copy to file.

nazca.netlist.get_transformation(start=None, end=None)

Return the transformation matrix that connects two pointers.

Returns

]: translation matrix

Return type

float[

nazca.netlist.interconnect_logger(msg='', level='info')

Log or raise an interconnect exception if conditions apply.

Parameters
  • msg (str) – log message

  • level (str) – log level: ‘debug’, ‘info’ (default), ‘error’, or ‘exception’.

Raises
  • Exception if the "exception number" is set and matching this log entry.

  • Exception if unknown level is provided

Returns

None

nazca.netlist.interconnect_raise(num=0, on=True)

Switch on or off exceptions for interconnect warnings and errors.

The traceback can be used to find the cause of the netlist error.

Parameters
  • num (int) – if provided, raise exception on drc number <num> (default=None) if num is set then raise=True unless explicitly set to False

  • on (bool) – raise exception for trace back if True (default=True)

Returns

None

nazca.netlist.inverse(mat)

Return inverse matrix of <mat>

nazca.netlist.load_gds(filename, cellname=None, newcellname=None, asdict=False, topcellsonly=True, select='top', layermap=None, cellmap=None, scale=None, prefix='', instantiate=True, native=True, bbox=False, bboxbuf=0, hull=None, show_hull=False, hull_based_bbox=None, connect=None, flat=False, reuse=False, cellsnotreused=None, cellsreused=None, layermapmode=None)

Load one or more GDS cells (and its instances) from <filename> into a Nazca cell.

By default, load_gds returns a single cell in the specified gds file in <filename>, as specified in cellname, or the topcell, if only one exists.

Alternatively, when using a gds file as a library it is more efficient and convenient to call, load the GDS file only once. In that case use asdict=True in load_gds, which returns a dictionary with the keys referencing each cell by cellname, while keeping a distinction between topcells and subcells:

{‘topcells’: {<cellname>: Cell}, ‘subcells’: {<cellname>: Cell}}

load_gds checks for cellname clashes, because a cell(tree) loaded into the layout can not contain any cell name that already exists in the layout. There are three ways to avoid name clashes in case they occur:

1. Set a <newcellname>: changes only the name of the top cell; Note <newcellname> is ignored if a <cellmap> is provided as cellmap is then supposed to contain the renaming.

2. Provide a <cellmap>: maps original cell names one-by-one to new cell names. Cells names omitted will not be renamed.

3. Provide a cell name <prefix>: applies to all cells in a branch, except those in <newcellname> or <cellmap>.

Note, if you need to create a building block from GDS with pins and stubs, and you have the pin and xsection info available already (for example in a file) then you may prefer to use method ‘load_gdsBB’ instead.

Parameters
  • filename (str|bytes) – filename of gds to load or bytes object that contains the gds byte stream.

  • cellname (str) – cellname in filename to load

  • newcellname (str) – new name for <cellname>

  • asdict (bool) – return a dict of cells if True (default=False). If True, the cellname keyword will be ignored.

  • select (str) – set the structure of the dictionary returned by this function. Only used when asdict is True.

  • layermap (dict) – layer mapping {old_layernumber: new_layernumber}

  • cellmap (dict) – cellname mapping {old_cellname: new_cellname}

  • scale (float) – scaling factor of the cell (default=1.0). Scaling in this function will be applied directly to the polygon structures, not as a modifier attribute like scaling/magnification on a gds instance. For the latter use the scale keyword in ‘put()’. Warning, use scaling with care and basically only on structures like logos and text. Avoid (do not) use on library building blocks and/or optical components as their functionality may be compromised by scaling.

  • prefix (str) – optional string to avoid name clashes (default=’’)

  • instantiate (bool) – instantiate the GDS (default=False)

  • native (bool) – create native Nazca cells from GDS (default=True). Native cells provide full access to all elements in the gds.

  • bbox (bool) – add bounding box if True (default=False)

  • bboxbuf (float) – add a buffer to the bounding box (default=0)

  • connect ((float, float, float)) – Only for native=False, move GDS origin by (x, y, a) when putting it into the layout.

  • moveorg ((float, float, float)) – alternative name for connect

  • reuse (bool) – default is False. If True, load gds assumes cells with the same name are the same cell and it resolves conficts by using only the first cell occurance. Setting reuse=True is dangerous.

  • cellsnotreused (list of str) – list of cellnames to ignore for reuse if reuse=True

  • cellsreused (list of str) – list of cellnames to reuse. If set all other cells will not be reused and reuse and cellsnotreused will be ignored.

  • topcellsonly (bool) – default=True

Returns

Cell}: Nazca Cell containing the loaded gds cell(tree).

If asdict is True return a dictionary.

Return type

Cell | {cellname

Example:

cell1 = load_gds(filename='path_to_file.gds', cellname='name')
cell1.put()

# using asdict = True:
cellAll = load_gds(filename='path_to_file.gds', asdict=True)
cellAll[<cellname>].put()
nazca.netlist.load_gds_raw(filename, cellname=None, newcellname=None, layermap=None, cellmap=None, scale=1.0, prefix='', instantiate=False, bbox=False, hull=None, hull_based_bbox=None, connect=None, use_first=False, layermapmode='all', **kwargs)

Load GDS and always force native=False.

load_gds_raw(…) is the same as load_gds(…, native=False). See load_gds() for a detailed method description.

Returns

Nazca Cell containing the loaded gds cell(tree)

Return type

Cell

nazca.netlist.log_pin(pin=None, label='', show=True, layer='dump')

Generate log string where a pin is (cell + location) and lable it.

Optionally visualize the location of the pin with the label in the layout.

Parameters
  • pin (Node) – pin to log. default=cp

  • label (str) – label to identify the log

  • show (bool) – show the pin in the layout

  • layer (str | int | (int, int)) – layer indentifier for visualization. default=’dump’

Returns

message to put in a logfile, e.g. via nd.logging.info(…)

Return type

str

nazca.netlist.main_logger(msg, level='info', _redirect=False)

Log or raise an exception if conditions apply.

This message handler will take care of loggin any error or warning. It will raise an exception if the error counter = errnum (if errnum has been set) for debugging/trace back purposes.

Arg:

msg (str): log message level (str): log level: ‘debug’, ‘info’ (default), ‘error’, or ‘exception’. _redirect (bool): internal variable for counting messages.

Returns

None

nazca.netlist.midpoint(node1, node2)

Calculate the geometrical center between two nodes.

See also function midpointer.

Parameters
  • node1 (Node) – start node

  • node2 (Node) – end node

Returns

mid-point between pointers of <node1> and <node2>

Return type

(x, y, a)

Example:

import nazca as nd

p1 = nd.Pin().put(10, 20, 0)
p2 = nd.Pin().put(20, 40, 90)

x, y, a = nd.midpoint(p1, p2)
print(x, y, a)
# 15.0, 30.0, 45.0
nazca.netlist.midpointer(node1, node2)

Calculate the geometrical center between two nodes.

See also midpoint.

Parameters
  • node1 (Node) – start node

  • node2 (Node) – end node

Returns

pointer in mid-point between pointers of <node1> and <node2>

Return type

Pointer

Example:

import nazca as nd

p1 = nd.Pin().put(10, 20, 0)
p2 = nd.Pin().put(20, 40, 90)

p3 = nd.midpointer(p1, p2)
print(p3.xya())
# (15.0, 30.0, 45.0)
nazca.netlist.nazca_raise(num=0, on=True)

Raise an exception for any design related Nazca error.

Parameters
  • num (int) – if provided, raise exception on drc number <num> (default=None) if num is set then raise=True unless explicitly set to False

  • on (bool) – raise exception for trace back if True (default=True)

Returns

None

nazca.netlist.netlist_logger(msg='', level='info')

Raise netlist exception if conditions apply.

Parameters
  • msg (str) – log message

  • level (str) – log level: ‘debug’, ‘info’ (default), ‘error’, or ‘exception’.

Returns

None

nazca.netlist.netlist_raise(num=0, on=True)

Switch on or off exceptions for netlist errors.

The traceback can be used to find the cause of the netlist error.

Parameters
  • num (int) – if provided, raise exception on drc number <num> (default=None) if num is set then raise=True unless explicitly set to False

  • on (bool) – raise exception for trace back if True (default=True)

Returns

None

nazca.netlist.parse_pin(C1=None, C2=None, C3=None, C4=None, instance=None, rot=False, default='out')

Parse the part of the put statement after a potential first string arg.

Parameters
  • C1 – tuple of floats, len<=3; C2 = pinname

  • to C[i] (C1) – 1<=i<=3 are floats; C[i+1] = pinname

  • instance (Instance object) – Instance object to connect to

  • rot (bool) – Add an extra rotation for end pins in p2p connections if True

Returns

describes a point at ‘translation’ from ‘pin’.

default=’org’, (0, 0, 0).

Return type

pin, (x, y, a)

Examples

Allowed input formats:

  • ()

  • (Node)

  • ((0))

  • ((0, 0))

  • ((0, 0, 0))

  • (0,)

  • (0, 0)

  • (0, 0, 0)

  • ‘pin’ can be referred to by a Node, Instance or string name.

  • (pin)

  • (None, pin)

  • ((0), pin)

  • ((0, 0), pin)

  • ((0, 0, 0), pin)

  • (0, pin)

  • (0, 0, pin)

  • (0, 0, 0, pin)

nazca.netlist.pin2pin_drc(on=True)

Switch pin2pin DRC on.

NOTE: the drc error maybe in a connection that is not exported to (gds) output

and, therefor, not show up in that specific layout view.

Parameters
  • on (bool) – raise exception for trace back if True (default=True)

  • num (int) – if provided, raise exception on drc number <num> (default=None) if num is set then raise=True unless explicitly set to False

Returns

None

nazca.netlist.pin2pin_drc_off()
nazca.netlist.pin2pin_drc_on(exception=None, num=None)
nazca.netlist.pin2pin_drc_raise(num=0)
nazca.netlist.pin_drc(pin1, pin2, t)

Perform DRC on pin-pin connections.

Pin2pin DRC can be turned on and off. Included DRC are xsection, width and angle DRC.

Parameters
  • pin1 (Node) – first pin

  • pin2 (Node) – second pin

  • t (tuple) – (x, y, a) distance between pins, needed for angle.

Returns

None

nazca.netlist.print_structure(filename, cellname, level=0)

Print gds structure in ascii art.

Returns

None

nazca.netlist.raise_interconnect(num=0, on=True)

Switch on or off exceptions for interconnect warnings and errors.

The traceback can be used to find the cause of the netlist error.

Parameters
  • num (int) – if provided, raise exception on drc number <num> (default=None) if num is set then raise=True unless explicitly set to False

  • on (bool) – raise exception for trace back if True (default=True)

Returns

None

nazca.netlist.raise_nazca(num=0, on=True)

Raise an exception for any design related Nazca error.

Parameters
  • num (int) – if provided, raise exception on drc number <num> (default=None) if num is set then raise=True unless explicitly set to False

  • on (bool) – raise exception for trace back if True (default=True)

Returns

None

nazca.netlist.raise_netlist(num=0, on=True)

Switch on or off exceptions for netlist errors.

The traceback can be used to find the cause of the netlist error.

Parameters
  • num (int) – if provided, raise exception on drc number <num> (default=None) if num is set then raise=True unless explicitly set to False

  • on (bool) – raise exception for trace back if True (default=True)

Returns

None

nazca.netlist.raise_pin2pin_drc(num=0)
nazca.netlist.set_db_unit()
nazca.netlist.set_db_user()
nazca.netlist.show_cp(radius=10, width=1, layer='dump')

Draw a ring in the layout to indicate/visualize the cp position.

Parameters
  • radius (float) – radius of the ring shaped pin inidcator in um

  • width (float) – width of the ring-shaped pin indicator in um

Returns

None

nazca.netlist.show_pin(pin=None, radius=10, width=1, layer='dump')

Draw a ring in the layout to indicate/visualize the pin position.

Parameters
  • pin (node | str) – pin reference

  • radius (float) – radius of the ring shaped pin inidcator in um

  • width (float) – width of the ring-shaped pin indicator in um

If no pin is provided (None), cp will be use to apply the “show”.

Returns

None

class nazca.netlist.smatrix(tete=0, 0, tmtm=0, 0, tetm=0, 0, tmte=0, 0)

Bases: object

S-matrix tbd.

__init__(tete=0, 0, tmtm=0, 0, tetm=0, 0, tmte=0, 0)

Initialize self. See help(type(self)) for accurate signature.

nazca.netlist.to_mat(chain=0, x=0, y=0, a=0, inverse=False)

Transform vector into matrix.

nazca.netlist.validate_basename(basename)

Check if basename is unique on substring level.

This is only relevant for pcell replacement where no mistake between different basenames is allowed.

Parameters

basename (str) – basename of a cell’s name

Returns

True if basename is valid

Return type

bool

nazca.netlist.varinfo(min, default, max, type, unit, doc)

Set parameter value info.

Experimental function.

Returns

var info

Return type

dict

nazca.netlist.whereami(text='here', size=100, pin=None)

Show current pointer position as arrow in the layout.

Parameters
  • text (str) – annotation text

  • size (float) – size of the annotation

Returns

None

nazca.pdk_template module

Module defining black box templates for PDK implementation.

nazca.pdk_template_bb module

Module defining black box templates for PDK implementation.

nazca.pdk_template_bb.Tp_BB1x1(length=100, width=50, pinwidth=None, name='BBname', groupname='', xs=None, xs_bb=None, ashift=0, bshift=0, parameters=None)

Template for a 1 input and 1 output Building Block.

Returns

function that generates a Cell object

nazca.pdk_template_bb.Tp_BB3ports(length=100, width=50, pinwidth=None, name='BBname', groupname='', xs=None, xs_bb=None, ashift=0, bshift=0, cshiftx=0, cshifty=0, parameters=None)

Template Block with 3 ports: input, output, contact.

Returns

function that generates a Cell object

nazca.pdk_template_bb.Tp_BB4ports(length=100, width=50, pinwidth=None, name='BBname', groupname='', xs=None, xs_bb=None, ashift=0, bshift=0, cshiftx=0, cshifty=0, parameters=None)

Template for a Block with 4 ports: input, output, 2 x contacts.

Returns

function that generates a Cell object

nazca.pdk_template_bb.Tp_CellBoundary(length=4600, height=4000, cleave=100, coatingW='NO', coatingE='NO', name='cell_boundary', groupname='', xs=None)

Template for a cell boundary.

Args:

Returns

die template with cleave street

Return type

function generating a Cell

nazca.pdk_template_bb.Tp_CellBoundary2(length=5000, height=5000, cleave=100, name='cell_boundary', groupname='', pitch=None, xs=None)

Template for a cell boundary.

Returns

function that generates a Cell object

nazca.pdk_template_bb.Tp_CellID(width=200, length=200, ID='xx', name='Cell_ID', groupname='', xs=None)

Smart Photonics CellID.

Returns

function that generates a Cell object

nazca.pdk_template_bb.Tp_IO(length=100, width=3.5, angle=- 7, pinwidth=None, name='io', groupname='', xs=None)

Template trapezoidal IO.

Returns

function that generates a Cell object

nazca.pdk_template_bb.Tp_IO2(length=100, width=3.5, angle=7, pinwidth=None, name='io', groupname='', xs=None)

Template trapezoidal IO, but flipped (XL).

Returns

function that generates a Cell object

nazca.pdk_template_bb.Tp_IOtrapezoid(length=100, width=3.5, angle=- 7, pinwidth=None, name='io', groupname='', xs=None)

Template trapezoidal IO.

Returns

function that generates a Cell object

nazca.pdk_template_bb.Tp_Isolation(length=30, width=20, pinwidth=None, name='iso', groupname='', xs=None)

Template for Isolation section in different xsection.

Returns

function that generates a Cell object

nazca.pdk_template_bb.Tp_XStransition(length=33, width=30, pinwidth=None, name='xs1_to_xs2', groupname='', xs=None, icon=None)

Template for waveguide transitions between xsections.

Returns

function that generates a Cell object

nazca.bb_util module

Module with a set of Buiding Block templates for faciliating PDK creation.

nazca.bb_util.BB_Group

alias of nazca.bb_util.Functional_group

class nazca.bb_util.Functional_group(name='')

Bases: object

Class to group building blocks syntactically together.

Example

Create bb_splitters group with various splitter components such that the mmi can be found under bb_splitters.<tab>:

bb_splitters = Functional_group()
bb_splitters.mmi1x2 = mmi1x2
bb_splitters.mmi2x2 = mmi2x2
bb_splitters.mmi3x3 = mmi3x3
__init__(name='')

Create a Functional group object.

nazca.bb_util.add_pinshape(name, shape, overwrite=True)

Add a pin shape to the pinshapes dict.

Parameters
  • name (str) – reference name of the shape

  • shape (list of (float, float)) – pin shape [(x1, y1), …]

Returns

None

nazca.bb_util.add_pinstyle(name, styledict)

Set a custom pin style for a technology.

Start with the style in <name> if existing, otherwise with the default cfg.pinstyle settings and overrule these for the keywords provided in the <styledict>.

Each pinstyle name will point to a unique dictionary internally.

Parameters
  • name (str) – pinstyle name

  • styledict (dict) – pinstyle

Returns

None

nazca.bb_util.bb_fingerprint(cellcalls, save=False, filename='fingerprint.json', infolevel=0)

Generate a dict with parameter list and pin list of a list off BBs.

This generates a blueprint (aka fingerprint).

Parameters

cellcalls (dict) – All the cells {function_call_str: cell_from_call}

Returns

Dictionary with building block info, Structure is as follows:

{'<cellname>':
    {'pins':
        { '<pinname>':
            {'width': <value>,
             'xs'   : <value>
             'xya'  : (<x>, <y>, <a>)
             'show' : <values>
            }
            , ...
        },
     'parameters':
         {'<keyword>': <value>}
         , ...
     'paramsname'   : <value>,
     'basename'     : <value>,
     'groupname'    : <value>,
     'module'       : <value>,
     'function'     : <value>,
     'length'       : <value>,
     'width'        : <value>
    }
}

Return type

dict

nazca.bb_util.bbox_layers_ignore(layers=None, reset=False)

Set the layers that should be ignore in bbox calculations.

nazca.bb_util.cellname(cellname=None, length=0, width=None, align='lc', name_layer=None)

Create the cellname as a text cell.

Parameters
  • cellname (str) – name of the cell

  • length (float) – length available for the BB name in um

  • width (float) –

  • align (str) – text alignment (see nazca.text, default = ‘lc’)

  • name_layer (str) – name of the layer to be used for bbox name

Returns

text with cellname

Return type

Cell

nazca.bb_util.example_cell()

Create a Nazca example cell.

Returns

cell

nazca.bb_util.export_bb2png(cellcalls, path='', close=True, bbox_pins=True)

Create png image for all cells in <cellcalls>.

Only the Cell objects are used from <cellcalls>, but it does accept as well the dict as needed in method ‘bb_fingerprint’.

cellcalls (dict | list of Cells): All the cells {function_call_str: cell_from_call} | list of Cells close (bool): close cell immediately after drawing (default = True) path (str): path for saving png files bbox_pins (bool): add pins to the bbox (default = True)

Returns

None

nazca.bb_util.get_Cell(name)

Get Cell object by providing cell name.

Parameters

name (str) – cell name

Returns

cell having cellname <name>

Return type

Cell

nazca.bb_util.hashme(*params)

Decorator to not regenerate a building block (cell) based on the same parameters.

The @hashme decorator can be used in cases of parametrized cells. It checks if a function call (that returns a CEll) occured before with the same parameters. If that is the case @hashme will return a reference to the previously created cell with these parameters, rather than creating a full copy with a new cell name.

Example

Usage of the hashme decorator:

@hashme('mycellname')
def parametrized_cell(W, L):
    with nd.Cell(hashme=True) as C:
        # cell stuff
        nd.strt(length=L, width=W).put()
    return C

parametrized_cell(W=3.0, L=10.0)
# cell_name ='mycellname'

Usage of hashme with adding keyword values to the cellname:

@hashme('mycellname', 'L', 'W')
    def parametrized_cell(W, L):
        with nd.Cell(hashme=True) as C:
            # cell stuff
            nd.strt(length=L, width=W).put()
        return C

parametrized_cell(W=3.0, L=10.0)
# cell_name ='mycellname_10.0_3.0'

Parameters in the @hashme are str types. The first parameter in @hashme is the cellname. The 2nd and more parameters are optional names of the function call keywords. If keyword names are added, the cellname will include them. This is useful to add key metrics to the cell name. In the decorated function the Cell creation can automatically access the info created by @hashme, such as the cell name via nd.Cell(hashme=True).

Note: do not use any global parameters in a paramtrized function that is decorated with hashme. I.e. put all parameters that may change the cell in the function call. The reason is that a change of a global parameter could possibly cause a different result of the generated cell without being noticed.

Returns

decorator

nazca.bb_util.image(name, layer=1, size=256, pixelsize=1, threshold=0.5, cellname=None, invert=False, align='cc', box_layer=None, box_buf=0)

Read an image file and return a nazca cell with the image.

Image format can be png, jpg, gif, bpm, eps and others, as supported by Pillow. Note that the output resolution (size) does not exceed the image resolution. Increase <pixelsize> in this case to obtain a larger logo in gds.

A rectangular box can be added around the logo by providing a <box_layer>. This box can be enlarged beyond the original image size by setting <box_buf> > 0.

Parameters
  • name (str) – name of the image file

  • layer (int) – layer number that the image will be written to (default 1)

  • size (int) – maximum bounding box size in pixels (default 256)

  • pixelsize (float) – pixel size in micron (default 1)

  • threshold (float) – black/white threshold (default 0.5)

  • cellname (str) – Nazca cell name (default image filename)

  • invert (bool) – flag to invert black & white (default False)

  • align (str) – two character string for image alignment (default ‘cc’) allowed: lt, ct, rt, lc, cc, rc, lb, cb, rb

  • box_layer (str | int | tuple) – layer reference to generate a rectangular box behind the text, e.g. for tiling exclusion areas (NOFILL) (default = None)

  • box_buf (float) – extra buffer for the box_layer in um

Returns

cell with image

Return type

Cell

Examples

Load a logo in a cell and put and/or export it to gds:

import nazca as nd

logo = nd.image('mylogo.png', align='lb') # left/bottom alignment
logo.put(0)
nd.export_gds()

or:

import nazca as nd

nd.export_gds(logo, filename='mylogo.gds')
nazca.bb_util.load_gdsBB(gdsfilename, cellname, pinfilename=None, newcellname=None, layermap=None, cellmap=None, flip=False, flop=False, scale=None, stubs=True, native=True, bbox=False, bboxbuf=0, hull=None, prefix='', suffix='_stubs', instantiate=None, flat=False, layermapmode=None)

Load a gds cell and the corresponding pin info from file.

This function uses method ‘load_gds’ for loading the gds file and adds pins and stubs to the cell according to the pinfile. This creates building block cell with connectivity. If there is not pinfile available, then use method ‘load_gds” instead.

Format of the pin file, including the single line header:

port, x, y, a, xs, w a0, 100, 0, 90, nazca, 2.0 …

If stubs == True then both the stubs and the loaded GDS are instantiated inside the cell returned by this function. This to ensure that for this cell that the gds and stubs remain aligned under flipping and flopping.

Parameters
  • gdsfilename (str) – gds filename to import from

  • cellname (str) – cellname to import

  • pinfilename (str) – optional name of csv file containing pin info for stubs.

  • newcellname (str) – new cell name

  • cellmap (dict) – mapping of cellnames {cellname_in: celllname_out}

  • layermap (dict) – mapping of layer {number_in: number_out}

  • flip (bool) – mirror the gds without changing pin direction (default = False)

  • flop (bool) – mirror the gds with reversing pin direction (default = False)

  • scale (float) – scaling factor (default = 1.0). Use with great care as scaled building blocks will not make much sense from a functional prespective. pin positions will be scaled along with the gds, however, xs information, like ‘width’ will not be scaled

  • stubs (bool) – place stubs in the cell (default = True). The stub value also set the instantiation value of the returned cell

  • native (bool) – load gds into a Nazca native format (default = True)

  • bbox (bool) – add a bounding box if True (default = False)

  • bboxbuf (float) – add a buffer layer around the structure and the bounding box.

  • prefix (str) – prefix to add the cell name to avoid cellname clashes. See help(nazca.load_gds)) more info on cellname resolution

  • suffix (str) – suffix to indicate it is cell wuth stubs added (default = ‘_stubs’)

  • instantiate (bool) – intantiate the returned cell

Returns

Nazca Cell with the loaded gds and (if provided) pins and stubs.

Return type

Cell

nazca.bb_util.make_pincell(layer=None, shape=None, size=None, style=None)

Create a cell to indicate a pin position.

The cell contains a shape, e.g. an arrow, to point out a location in the layout. Available pin shapes are in a dictionary in cfg.pinshapes: {name: polygon}. The predefined shapes have been normalized to unit size.

Parameters
  • layer (float) – layer number to place the pin symbol/shape

  • shape (str) – name (dict key) of the pin symbol/shape

  • size (float) – scaling factor of the pin symbol/shape

  • style (str) –

Returns

cell with pin symbol

Return type

Cell

Return the nazca logo as a cell.

Parameters
  • layers (dict) – gds layers of the logo. default = {‘ring’:1, ‘box’:2, ‘bird’:3}

  • cell_name (str) – default = ‘nazca_logo’

  • scale (float) – scaling factor (default = 1)

nazca.bb_util.parameters_to_string(param)

Create a string from a parameter dictionary.

Parameters

param (dict) – (parameter_name, value)

Note that the output format, i.e. inside the annotation object) may be foundry specific depending on the setting of cfg.parameter_style

‘default’ output format:

Parameters: <parameter> = <value> <parameter> = <value> …

‘yaml’ output format:

<parameter>: <value> <parameter>: <value> …

Returns

parameters as a string

Return type

str

nazca.bb_util.put_boundingbox(pinname, length, width, raise_pins=True, outline=True, align='lc', name=True, params=True, move=0, 0, 0, name_layer=None)

Create bounding box (bbox) cell inside the active cell.

This function places a bbox cell and raises by default the bbox pins into the active cell. The bbox displays a bbox outline (can be switched off). By default it also adds the active cellname and parameters.

Parameters
  • pin (str) – pin to place bbox on (center left of bbox)

  • length (float) – length of the bbox

  • with (float) – width of the bbox

  • raise_pins (bool) – raise bbox pins into active cell (default = True)

  • outline (bool) – draw bbox outline (default = True)

  • align (str) – align the bbox on the specified bbox pin <pinname> (default = ‘lc’)

  • name (bool) – display the (active) cell name in the bbox. (default = True)

  • params (bool) – add parameter annotation to the bbox

  • move (tuple) – move the bbox placement by (float, float, float)

  • name_layer (str) – name of the layer to be used for bbox name

Returns

None

nazca.bb_util.put_parameters(parameters=None, pin=None)

Put a parameter list as annotation in a building block.

Parameters

parameters (dict) – {parameter_name: value}

Returns

Annotation object with the parameterlist

Return type

Annotation

nazca.bb_util.put_stub(pinname=None, length=None, shape='box', pinshape=None, pinsize=None, pinlayer=None, pinshow=True, annotation_layer=None, pinstyle=None)

Add a xsection stub to one or more pins.

The xsection and width of the stub is obtained from its pin attributes. If no attributes are set, the stub layers are empty and the stubcell only contains the pincell. It is possible to supply a list of pins.

The pinstyle is determined by the following sequence: 1. use the pinstyle of the xsection, if set 2. use the pinstyle ‘default’ 3. update the pinstyle with explicit settings via the keyword parameters

The pinshape is one of the following:

  1. A reference to a key in the cfg.pinshapes dictionary which contains

    the raisepin polygon description of which a pin cell is created.

  2. A cell.

For a pin having attribute xs=None only the pin is drawn.

Parameters
  • pinname (str | list of str | None) – name(s) of the pin(s) (default = None) For pinname=None (default) all chain-pins will obtain a stub.

  • length (float) – length of the stub (thickness into cell)

  • shape (string | cell) – shape of the stub ‘box’ | ‘cirlce’ (default = ‘box’)

  • pinshape (string) – pinshape used in the stub

  • pinsize (float) – scaling factor of the pinshape (default = 1)

  • layer (str | int | (int, int)) – pin layer

  • annotation_layer (str | int | (int, int)) – annotation layer

  • pinstyle (str) – pin style used. Default it will look in the xsection pinstyle setting. f that is None the pinstyle ‘default’ is used

  • pinshow (bool) – set the pin show attribute (default=True)

Returns

None

nazca.bb_util.rangecheck(allowed_values)

Check if parameter values are in range.

A dictionary with the allowed values for parameters is sent to rangecheck. If any parameter is out of range, a ValueError will be raised and relevant error info is provided to solve the issue.

Parameters
  • allowed_values (dict) – {‘<var_name>’: (low, <var_name>, high)},

  • the key is the <varname> in a str type (where) –

:param : :param and low and high are the min and max values:

Raises

ValueError if out of range.

Returns

None

Example

Add a check in a function on 0 <= a <= 10 and -5 <= b <= 5. The call will raise a ValueError:

def func(a, b):
    nd.rangecheck({'a': (0, a, 10), 'b': (-5, b, 5)})

func(a=100, b=100)

# output:
# ValueError: a=100 too large. Allowed values: 0<=a<=10
# b=100 too large. Allowed values: -5<=b<=5
nazca.bb_util.set_default_pinstyle(stylename)

Provide the name to use for the standard pinstyle.

The default standard style utilized in ‘default’.

Returns

None

nazca.bb_util.set_pinstyle(name, styledict)
nazca.bb_util.string_to_parameters(string)

Convert a string to a parameter dictionary.

The returned parameter values are represented as type str.

Expected format of <string>:

“parameters: <parameter> = <value> <parameter> = <value> …”

Header ‘parameters:’ is case incensitive and spaces will be stripped.

Parameters

string (str) – parameters

Returns

{<parameter_name>: <parameter_value>}

Return type

OrderedDict

nazca.bb_util.stubname(xs, width, thick, stubshape=None, pinshape=None, pinsize=None, pinlayer=None)

Construct a stub name.

Parameters
  • xs (str) –

  • width (float) – stub width

  • thick (float) – thickness of stub into cell (length)

Returns

stub name

Return type

str

nazca.bb_util.validate_black_to_white_mapping(black2whiteMap, allBBcells, infolevel=0)

Validate if all white and black boxes are mapped.

By increasing the infolevel more information will be displayed on where black <-> white mappings are missing.

Parameters
  • black2whiteMap (dict) – {blackbox-basename: whitebox-function}

  • allBBcells (list of Cell) – all black box cells.

  • infolevel – amount of feedback to stdout (default = 0)

Returns

True if mapping is successful.

Return type

bool

nazca.bb_util.validation_style(on=True, stub_layer=None, pin_style=None, validation_layermapmode='none', validation_layermap=None)

Set layers and pinstyle and layermap for BB validation stubs.

Parameters
  • on (bool) – default=True, turn on validation style

  • stub_layer (int, (int, int), str) – layer of the stub.

  • pin_style (dict) – optional pinstyle dict for the arrow and stub.

  • validation_layermapmode (str) –

  • validation_layermap (dict) – {in_layer: out_layer}

Returns

None

nazca.pdk_template_dbr module

Module defining black box templates for PDK implementation.

nazca.pdk_template_dbr.Tp_DBR(length=250, width=15, pinwidth=None, xs=None, name='dbr', groupname='', pitch=0.237, duty_cycle=0.5, icon=None)

Template for DBR building block.

This DBR has an option to set the duty cycle as free parameter.

Parameters
  • length (float) –

  • width (float) –

  • pitch (float) –

  • duty_cycle (float) –

  • name (str) –

  • xs (str) –

Returns

dbr(length, pitch, duty_cycle)

Return type

function returning a Cell

nazca.pdk_template_dbr.Tp_DBR2(length=250, width=15, name='dbr', groupname='', pinwidth=None, xs=None, pitch=0.237, metal=True, icon=None)

Extented template for DBR building block.

Parameters
  • length (float) –

  • width (float) –

  • pinwidth (dict) –

  • pitch (float) –

  • name (float) –

  • cshifty (float) –

  • metal (int) –

  • pad (int) –

  • DCmetalPad (int) –

  • DCmetalLine (int) –

  • xs (dict) –

  • xs_bb (str) –

  • xs_metal (str) –

Returns

function that generates a Cell object

nazca.pdk_template_eopm module

Module defining black box templates for PDK implementation.

nazca.pdk_template_eopm.Tp_EOPM_DC(length=100, width=50, name='BBname', groupname='', pinwidth=None, xs=None, contacts=3, pads=True, icon=None)

Template for a EOPM_DC.

The EOMP has 1 input, 1output, and 3 contact ports. Metal pads to contact ports are optional.

Args:

Returns

function that generates a Cell object

nazca.pdk_template_eopm.Tp_EOPM_RF(length=100, width=50, rfpitch=10, pinwidth=None, xs=None, name='BBname', groupname='', dx_metal=0, dy_metal=0, pads=False, padangle1=- 70, padangle2=70, RFpadType=None, bend_gsg_function=None, bend_gsg_params=None, icon=None)

Template for a EOPM_RF.

Has optica linput, output, and 2 GSG ports. Option to add RF GSG pads to GSF ports is added.

Parameters

??

Returns

eopm(length, pad, padangle1, padangle2)

Return type

function returning a cell

nazca.pdk_template_gsg module

Module defining black box templates for PDK implementation.

nazca.pdk_template_gsg.Tp_RFbendGSG(radius=50, angle=30, width_sig=10, width_gnd=10, gap=10, wext_bg=8, pinwidth=None, name='bend_gsg', groupname='', xs=None, xs_bg=None, xs_bg_width=None)

Template for GSG RF bend.

Returns

function that generates a Cell object

nazca.pdk_template_gsg.Tp_RFlineGSG(length=100, width_sig=10, width_gnd=10, gap=10, wext_bg=None, pinwidth=None, name='line_gsg', groupname='', xs=None, xs_bb=None, xs_bg=None, xs_bg_width=None)

Template for RF line GSG.

Returns

function that generates a Cell object

nazca.pdk_template_gsg.Tp_RFpadGSG(width_sig=10, width_gnd1=10, width_gnd2=None, gap1=10, gap2=62.5, height_tap=40, length_pad=75, width_pad_sig=45, width_pad_gnd=45, pinwidth=None, name='pad_gsg', groupname='', xs=None, layer=None)

Template for GSG RF pad cell.

Returns

function that generates a Cell object

nazca.pdk_template_mmi module

Module defining black box templates for PDK implementation.

nazca.pdk_template_mmi.Tp_MIR1p(length=40.2, width=35, pinwidth=None, name='mir1p', groupname='', xs=None, icon=None, version=None, store_pins=False)

Template for MMI1x2 in different xsections.

Returns

function that generates a Cell object

nazca.pdk_template_mmi.Tp_MIR2p(length=70.6, width=39, pinwidth=None, offset=1.5, name='mir2p', groupname='', xs=None, icon=None, version=None, store_pins=False)

Template for MMI1x2 in different xsections.

Returns

function that generates a Cell object

nazca.pdk_template_mmi.Tp_MMI1x2(length, width, pinwidth=None, offset=0, name='mmi1x2', groupname='', xs=None, icon=None, version=None, store_pins=False)

Template for MMI1x2 in different xsections.

Returns

function that generates a Cell object

nazca.pdk_template_mmi.Tp_MMI2x2(length, width, pinwidth=None, offset=0, name='mmi2x2', groupname='', xs=None, icon=None, version=None, store_pins=False)

Template for MMI2x2.

Returns

function that generates a Cell object

nazca.pdk_template_mmi.Tp_Modefilter(length=98.15, width=36, pinwidth=None, name='modefilter', groupname='', xs=None, icon=None, version=None, store_pins=False)

Template for Modefilter in different xsections.

Returns

function that generates a Cell object

nazca.pdk_template_pad module

Module defining black box templates for PDK implementation.

nazca.pdk_template_pad.Tp_DCpad_circle(diameter=100, pinwidth=None, buf_length=10, buf_width=10, name='DCpad', groupname='', xs=None, dclayer=None)

Template for DC pad in different xsections.

Args:

Returns

function generating a Cell

Return type

function

nazca.pdk_template_pad.Tp_DCpad_lw(length=100, width=100, pinwidth=None, name='DCpad_lw', xs=None, groupname='', metal_stub_length=2.0, dclayer=None)

Template for DC pad in different xsections.

The current standard BB only provides square BBs. Length and width are the actual metal size.

This is now actually a white BB, as it does not need replacement by the foundry. The building block has 5 micron extra space, since the design manual specifies 10 um minimum spacing between metal tracks/pads

Parameters
  • xs (dict) – {pin_name: xsection_name}

  • pinwidth (dict) – {pin_name: pin_width}

Returns

pdc pad F(lengh, width)

Return type

function returning a Cell

nazca.pdk_template_pad.Tp_DCpad_rectangle(length=100, tab_width=0, buf_length=10, buf_width=10, pinwidth=None, name='DCpad', groupname='', xs=None, metal_stub_length=2.0, dclayer=None, icon=None)

Template for a SQUARE DC pad in different xsections.

Length and width are the actual metal size inside the BB. The buffers buf_x and buf_y are to provide extra BB space.

Returns

pdc pad F(lengh, width)

Return type

function returning a Cell

nazca.pdk_template_pad.Tp_RFpad(length=100, width=100, pinwidth=None, name='pad_rf', groupname='', xs=None, icon=None)

Template for RF pad in different xsections.

Returns

function that generates a Cell object

nazca.pdk_template_photodiode module

Module defining black box templates for PDK implementation.

nazca.pdk_template_photodiode.Tp_PhotoDetector(length=100, width=50, buf=20, name='BBname', groupname='', pinwidth=None, xs=None, icon=None)

Template for a photodetector with option to draw a metal DC pad.

Returns

function that generates a Cell object

nazca.pdk_template_photodiode.Tp_PhotoDetectorRF(length=100, width=50, name='BBname', groupname='', pinwidth=None, xs=None, spaceGS=10, icon=None)

Template for a photodetector with an option to draw a metal RF GSG pad.

Returns

function that generates a Cell object

nazca.pdk_template_soa module

Module defining black box templates for PDK implementation.

nazca.pdk_template_soa.Tp_SOA(length=250, width=50, padwidth=200, pinwidth=None, dy_io=45, name='soa', groupname='', xs=None, xs_bb=None, pads=False, metallayer='BB', drawmetal=False, icon=None)

Template for SOA building block.

Returns

function that generates a Cell object

nazca.plotting module

nazca.plotting.plotProperty(F, ax=None, **kwargs)

nazca.simglobal module

class nazca.simglobal.Sim(wl=1.55, pol=0, modes=0, 1)

Bases: object

__init__(wl=1.55, pol=0, modes=0, 1)

“Initilialize golbl simulation settings.

Parameters
  • wl (float) –

  • pol (int) – polarization

  • modes (tuple) – list of modes to built a netlist for. Set to () for none.

Returns

None

nazca.slabmode module

Simple slab mode solver.

class nazca.slabmode.EIM(Mr=None, Mb=None, w=2.0, wl=1.55, name=None, points=100, view=None)

Bases: object

Simple 3 layer symmetric slab solver.

E(x, wl=1.55, pol=0)

Calculate Efield at position <x> for wavelength <wl> and polarization <pol>.

Parameters
  • x (float) – spatial postional along

  • wl (float) – optional, wavelength in um

  • pol (int) – optional, polarization (TE=0, TM=1)

Returns

E field strength at <x>, normalized per um

Return type

float

Efield()
property Nbg
Neff(**kwargs)
property Nr
property Nsub
property V
__init__(Mr=None, Mb=None, w=2.0, wl=1.55, name=None, points=100, view=None)

Initialize self. See help(type(self)) for accurate signature.

property b
property clip
property dbmin
getEwidth(Efrac=0.5)

Find width where field has fraction Efrac left w.r.t. center of guide.

Parameters

Efrac (float) – fraction between 0 and 1 (defailt = 0.5, HWHM)

Returns

distance of mode center where filds strength drops to Efrac

Return type

float

getField()
initSlab(Nr, Nbg, w, wl, pol=0, mode=0, clip=0.0)

Initialize a slab waveguide.

Parameters
  • Nr (float) – ridge index

  • Nbg (float) – background index

  • w (float) – waveguide width in um

  • wl (float) – wavelength in um

  • pol (int) – polarization (TE=0, TM=1)

  • mode (int) – mode number

Returns

maximum number of guides modes in the slab

Return type

int

property maxModes
property mode
property numberOfGuidedModes
plot(title=None, ax=None, **kwargs)
property pol
printAllModes()
printModeInfo(mode=- 1)
property w
property wl

nazca.slabsolver module

nazca.trace module

Module for tracing path lengths.

The example below shows how to start and stop a trace and how to query it for the length of all the components (cells) that are put in the layout between the start and stop calls. Note that cells must have a length_geo attribute, which is the case for at least all components in mask_elements and all interconnects.

Example:

import nazca as nd

nd.trace.trace_start()
nd.strt(length=100).put()
nd.bend(angle=90).put()
nd.trace.trace_stop()
print(nd.trace.trace_length())
nazca.trace.trace_append(elm)

Add an element to the active trace.

nazca.trace.trace_length(name=None)

Calculate the trace length.

If no trace name is provided in <name> the last closed trace will be used.

Returns

trace length

Return type

float

nazca.trace.trace_start(name=None)

Start recording a trace.

If no trace <name> is provided an ordinal number will be selected.

Parameters

name (str | int) – optional id of the trace to stop

Returns

None

nazca.trace.trace_stop(name=None)

Stop recording on trace.

If no trace_id is given the last started trace is stopped.

Parameters

trace_id (str | int) – id of the trace to stop

Returns

None

nazca.util module

nazca.util.get_cell_annotation(cell, convert=False)

Yield the <cell>’s annotations one by one.

If convert is False then return XY as integers, as in GDSII file (nm). If convert is True then return XY as floats (um).

cell (str): GDS cell name convert (bool): default convert=False

Yields

int, (int, int) | (float, float) – annotation layer, position, text

nazca.util.get_cell_polygon(cell, convert=False)

Yield the <cell>’s polygons one by one.

If convert is False then return XY as integers, as in GDSII file (nm). If convert is True then return XY as floats (um).

cell (str): GDS cell name convert (bool): convert polygon’s values to float (default = False)

Yields

int, (int, int) | (float, float) – layer, XY

nazca.util.get_cell_polyline(cell, convert=False)

Yield the <cell>’s polylines one by one.

If convert is False then return XY as integers, as in GDSII file (nm). If convert is True then return XY as floats (um).

cell (str): GDS cell name convert (bool): convert polyline’s values to float (default = False)

Yields

int, (int, int) | (float, float) – layer, XY

nazca.util.isnotebook()

Check if code is run in a Jupyter notebook.

Returns

True if call is made from a notebook

Return type

bool

nazca.util.make_iter(x)

Return x as tuple, if x is not a string and not iterable.

nazca.util.md5(x, N=None)

Return first N characters of md5 hash of argument x.

If no N is given the fill md5 is returned.

The function hashes the (default) string representation of the object.

Parameters
  • x (str) – string to hash

  • N (int) – number of characters in the hash

Returns

hash

Return type

str

nazca.xsection module

Module defining xsection (cross section) functionality.

This includes the Material class.

class nazca.xsection.Material(Nmat=None, name='', rgb=())

Bases: object

Define a material.

The material can be a physical material or a virtual material.

A virtual material is e.g. a slab layer stack and its index is function of wavelength and polarization.

The material contains the Neff and color.

Neff(**kwargs)

Get the index of the material.

Returns

effective refractive index

Return type

float

Nmat(**kwargs)
Returns

materials its refractive index

Return type

float

__init__(Nmat=None, name='', rgb=())

Initialize the material.

Parameters
  • Nmat (float) – refractive index of the material

  • name (str) – name of the material e.g. ‘air’

  • () (rgb) – color to display material. Value None give a random color

Returns

None

color(rgb)

Assign a color to the material.

Parameters

rgb (tuple) – (red, green, blue), values in [0, 1]

Returns

None

class nazca.xsection.Material_util

Bases: object

Class with utilities to define the effective index on material data.

__init__()

Initialize self. See help(type(self)) for accurate signature.

data_spline(wl, name, n_type='real')

Returns the effective index based on material model <name>.

Reads the <name>.csv and interpolates the effective index for the given wavelength.

Parameters
  • wl (float) – wavelength to be interpolated in um.

  • name (str) – name of the material model .csv file.

  • n_type (str) – determines if the output is “real” or “complex” (if available). Default value is “real”, complex values slow calculations down.

Returns

Interpolated effective index at wavelength wl.

Return type

float

spline(wl, name, dat)

Generate an interpolated effective index based on material data.

Generate an cubic spline if the input wavelength is in the data range. Evaluates the cubic spline at the input wavelength.

Parameters
  • wl (float) – wavelength to be interpolated in um.

  • name (str) – the name of the material data.

  • dat (pd.DataFrame) – data on known wavelength-Neff relation

Returns

Return type

float

wl_check(wl, wlmin, wlmax, name)

Check if wavelength (wl) is in the allowed domain.

Validates wl with the range of wlmin to wlmax.

Parameters
  • wl (float) – the wavelength to be checked in um.

  • wlmin (float) – the minimum wavelength of the data for interpolation.

  • wlmax (float) – the maximum wavelength of the data for interpolation.

  • name (str) – the name of the material data.

Returns

True if the wavelength check is passed.

Return type

bool

class nazca.xsection.Stack(layers=None, etchdepth=0, background=None, name='', solver=None, view='topview')

Bases: object

Class to define layer stacks.

A Stack is a list of layers as [(material, width), …], bottom up with the width (or height) in um.

Note that the material act like a “virtual material”. The Stack can be assigned a slab solver having method Neff.

A stack has an etch function to optionally remove layers from the top depending on a specified etch depth.

Neff(wl=None, pol=None, mode=None)

Add Neff to the stack to act like a virtual material.

__init__(layers=None, etchdepth=0, background=None, name='', solver=None, view='topview')

Initialize a stack object.

Parameters
  • layers (list) – list of tuples as (material, width)

  • solver (class | function | float) – slab solver class derived from class SolverBase.

Returns

None

applyetch(layers, etchdepth=0)

Apply etch to the layer stack.

This reduces layer thickness or even removes layers if the etchdepth is larger than the layer thickness. The etch material is replaced with background material.

Parameters
  • layers (list) – list of layer tuples (material, width)

  • etchdepth (float) – etch depth measured from top of material

Returns

layers after etch, list of tuples as (material, width)

Return type

list

count()
reset()
set(layers=None, etchdepth=0, name=None, solver=None, view='')

Set the layer stack parameters.

Parameters
  • layers (list) – list of tuples (material, thickness)

  • etchdepth (float) – etchdepth into the stack measure from the top layer

  • function (function) – index function of the stack

  • name (str) – name of the stack

  • solver (class, function, float) – optional solver to obtain Neff for the stack.

  • view (str) – ‘topview’ or ‘sideview’

Returns

None

simplifylayers(layers)

Merge neighbouring layers with the same material.

Returns

layers, a list of tuples as (material, width)

Return type

list

class nazca.xsection.Xsection(background=None, layers=None, name='', origin='', description='')

Bases: object

Define a cross sectional waveguide structure (XS).

A structure refers to a type of optical waveguide or metal line.

The xsection can hold multiple properties:

- A table of (gds) mask layers needed to draw the xsection.
- A set of Stack objects that describe the xsection's physical geometry in 1D or 2D.

Note that for e.g. mode simulation gds layers are not needed and vise versa.

The XS xsection waveguide geometry in this class is defined as a horizontal stack (hstack) of one or more ‘vertical’ layer stacks (vstack). This description can be used for 1D and 2D EIM.

Example:

three vstacks in a hstack

Each vstack has one or more layers, and each layer has a material assigned to it. A vstack stack has a width attribute to express its with in the hstack.

A function or mode solver can be assigned to materials, vstacks and hstacks to provide or calculate properties like the refractive index, mode profiles, etc.

Neff(wl=1.55, pol=0, radius=0.0, **kwargs)

Return the effective index of the xsection.

Parameters
  • wl (float) – Wavelength in um.

  • pol (int) – Polarization. 0 for “TE” or 1 for “TM”.

  • radius (float) – Bending radius at the center of the waveguide. Default is 0.0 (straight waveguide).

Returns

effective refractive index

Return type

float

__init__(background=None, layers=None, name='', origin='', description='')

Construct a xsection.

Parameters
  • () (layers) –

  • ()

  • name (str) – xsection name

add_hstack(layers, name='', function=None, solver=None)

Define the hstack of the xsection.

Parameters
  • layers (list) – list of tuples (material, thickness)

  • name (str) – name of the stack

  • function (function) – index function of the stack returning a float

  • solver (class) – slab solver class to use for the stack

Returns

horizontal stack

Return type

Stack

add_vstack(layers=None, etchdepth=0, name='', solver=None)

Add a ‘sideview’ layer stack to the xsection.

Parameters
  • layers (list) – list of tuples (material, thickness)

  • etchdepth (float) – etchdepth into the stack measure from the top layer

  • name (str) – name of the stack

  • function (function) – index function of the stack returning a float

  • solver (class) – slab solver class to use for the stack

Returns

object describing stack layers

Return type

Stack

background(mat)

Set the background material of the xsection.

Returns

None

info()

Create a string with information on the xsection.

For printing the settings of all stacks and hstacks.

Returns

information on the xsection

Return type

str

levelhstack()

Make all vertical layers the same height.

Fill the difference with background material.

Returns

None

maxNeff()

Obtain maximum refractive index of all material in the xsection.

Returns

maximum refractive index of all material in the xsection

Return type

float

minNeff()

Obtain minimum refractive index of all material in the xsection.

Returns

minimum refractive index of all material in the xsection

Return type

float

reset()

Empty the xsection structure vstack and hstack.

Returns

None

showGuide2D(draw_index=False, ax=None)

Display a 2D representation of xsection.

Returns

None

showGuide3D(draw_index=False)

Display a 2D representation of xsection.

Returns

None

stack_iter()

Returns: Interator over the stacks

nazca.xsection.modaldata(XSfunc, width, modes=None)

Calculate Neff against waveguide <width> for <modes> number of modes.

Parameters
  • XSfunction (function) – function F(width) to calculate Neff

  • width (list of float) – waveguide width in um

  • modes (int) – number of modes to calculate (if existing)

Returns

index = width, columns = modes, data = Neff

Return type

DataFrame

nazca.xsection.modalplot(buildXS, width, modes=None)