nazca package

Subpackages

Submodules

nazca.cfg module

nazca.cfg.active_cell()

Get the active cell.

nazca.cfg.formatplot()
nazca.cfg.gds_cellname_cleanup(name)
nazca.cfg.trace_length(trace_id=None)
nazca.cfg.trace_start(trace_id=None)
nazca.cfg.trace_stop(trace_id=None)

nazca.clipper module

Module with grow and merge polygon functions.

nazca.clipper.diff_polygons(paths_A, paths_B, accuracy=0.001)

Subtract polygons and return a list with the resulting polygon(s).

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 polygons and return the grown 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.
  • accuracy determines the grid on which the grown path is drawn. (The) –
  • jointype – specifies the type of growing that is used.
  • jointype is one of 'round' (The) –
Returns:

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

Return type:

list

nazca.clipper.merge_polygons(paths, accuracy=0.001)

Merge polygons and return a list with the resulting polygon(s).

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.
  • is no good reason to deviate from the default (There) –
Returns:

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

Return type:

list

nazca.colormap module

Parsing Klayout lyp files into csv via DataFrames: lyp2csv. Generate a matplotlib colormap from the csv table: csv2colormap

nazca.colormap.lyp2csv(lypfile)

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 for Matplotlib output. A .lyp file may contain multiple tabs and each tab is exported to a separate .csv file.

Note that display logic in Klayout and Matplotlib are not the same. Hence, a layout will have a different “style” 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.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 as …nazca.txt

Author: Ronald Broeke 2017(c)

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

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

Files:list of filenames
Xs:xsection of connection
Win:waveguide width input side
Wout:waveguide width output side
nazca.convert_AWGtxt2nazca.convert_file(file, xs, win, wout)

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

nazca.convert_AWGtxt2nazca.get_txt_files(dir)

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

nazca.cp module

The ‘cp’ module provides short syntax methods to operate on current pointer cp.

nazca.cp.get_a()
nazca.cp.get_xy()
nazca.cp.get_xya()
nazca.cp.goto(x=0, y=0, a=0)
nazca.cp.here()
nazca.cp.mirror()
nazca.cp.move(x=0, y=0, a=0)
nazca.cp.move2(x=0, y=0, a=0)
nazca.cp.offset(x=0)
nazca.cp.os(x=0)
nazca.cp.pop()
nazca.cp.push()
nazca.cp.roll()
nazca.cp.rot(a=0)
nazca.cp.rotate(a=0)
nazca.cp.shift(x=0, y=0)
nazca.cp.show(d=10, w=1)
nazca.cp.skip(x=0)

nazca.font module

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()

Returns: str: string with all characters present in a font

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()
text(text='Text', height=50, layer=1, align='lb', box_layer=None, box_buf=None, instantiate=False)

Output a cell with text of specified dimensions and alignment.

In case of an exclusion box, it will be scaled with the text height unless a box_buf value is provided, which represent an absolute buffer between the text field and the exclusion edge in um.

Parameters:
  • text (str) – text to display
  • height (float) – height off the text in um
  • 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)
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)
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=50, layer=1, stretch=1, align='lb', linewidth=1, instantiate=False, box_layer=None, box_buf=None)

nazca.gds module

Module with higher level (cell level) routines to open a GDS stream and add cells and instances of cells to it.

Example

Create a simple gds stream with two empty cells with cell_1 under cell_2:

import nazca.gds as gds

strm = gds.layout_open()

strm += gds.cell_open(name='cell_1')
strm += gds.cell_close()

strm += gds.cell_open(name='cell_2')
strm += gds.cell_reference(xy=(0, 0), name='cell_1')
strm += gds.cell_close()

strm += gds.layout_close()

open(simple_stream.gds, 'bw').write(strm)
nazca.gds.layout_open(name='Nazca v0.3-dev')

Open a GDS stream.

Parameters:name (str) – name of the layout
Returns:stream for opening a layout
Return type:bytestring
nazca.gds.cell_open(name)

Open a GDS cell.

Parameters:name (str) – cell name
Returns:stream for cell opening
Return type:bytestring
nazca.gds.layout_close()

Close a GDS stream.

Returns:stream for closing a layout
Return type:bytestring
nazca.gds.cell_close()

Close a GDS cell.

Returns:stream for cell closure
Return type:bytestring
nazca.gds.cell_reference(xy, name, adeg=0, mag=1, flip=False, array=None)

Add a cell reference (instance) to a GDS cell.

Parameters:
  • () (xy) – (x, y) position of the instance
  • name (str) – cell name to instantiate
  • adeg (float); cell angle in degrees (default = 0) –
  • mag (float); scaling factor (default = 1.0) –
  • flip (bool) – flag is cell is mirrored (default = False)
  • array (dx, dy) – create an array reference if values are given
Returns:

stream for a cell reference

Return type:

bytestring

nazca.gds_base module

Low level GDSII routines

Gds_base is a module that holds routines which implement some of the basic GDSII functions. Currently it is limited to the following GDSII data types: - polyline (path) - polygon (boundary) - string (annotation)

nazca.gds_base.gds_angle(ang)
nazca.gds_base.gds_annotation(lay, xy, string, datatype=0)
nazca.gds_base.gds_aref()
nazca.gds_base.gds_bgnlib(lcltm=None)
nazca.gds_base.gds_bgnstr(lcltm=None)
nazca.gds_base.gds_boundary()
nazca.gds_base.gds_colrow(col, row)
nazca.gds_base.gds_datatype(datatype)
nazca.gds_base.gds_endel()
nazca.gds_base.gds_endlib()
nazca.gds_base.gds_endstr()
nazca.gds_base.gds_header()
nazca.gds_base.gds_layer(lay)
nazca.gds_base.gds_libname(string)
nazca.gds_base.gds_mag(mag)
nazca.gds_base.gds_nodata(rec)
nazca.gds_base.gds_path()
nazca.gds_base.gds_pathtype(pathtype)
nazca.gds_base.gds_polygon(xy, lay, datatype=0)
nazca.gds_base.gds_polyline(xy, w, lay, close=False, datatype=0, pathtype=0)
class nazca.gds_base.gds_record

Bases: object

Define gds record names.

ANGLE = 28
AREF = 11
ATTRTABLE = 35
BGNEXTN = 48
BGNLIB = 1
BGNSTR = 5
BORDER = 60
BOUNDARY = 8
BOX = 45
BOXTYPE = 46
COLROW = 19
CONTACT = 69
DATATYPE = 14
ELFLAGS = 38
ELKEY = 39
ENDEL = 17
ENDEXTN = 49
ENDLIB = 4
ENDMASKS = 56
ENDSTR = 7
FONTS = 32
FORMAT = 54
GENERATIONS = 34
HARDFENCE = 62
HARDWIRE = 64
HEADER = 0
LAYER = 13
LIBDIRSIZE = 57
LIBNAME = 2
LIBSECUR = 59
LINKKEYS = 41
LINKTYPE = 40
MAG = 27
MASK = 55
NODE = 21
NODEPORT = 66
NODETYPE = 42
PATH = 9
PATHPORT = 65
PATHTYPE = 33
PLEX = 47
PRESENTATION = 23
PROPATTR = 43
PROPVALUE = 44
REFLIBS = 31
RESERVED = 53
SNAME = 18
SOFTFENCE = 61
SOFTWIRE = 63
SPACER_ERROR = 68
SPACING = 24
SREF = 10
SRFNAME = 58
STRANS = 26
STRCLASS = 52
STRING = 25
STRNAME = 6
STRTYPE = 37
STYPTABLE = 36
TAPECODE = 51
TAPENUM = 50
TEXT = 12
TEXTNODE = 20
TEXTTYPE = 22
UINTEGER = 29
UNITS = 3
USERCONSTRAINT = 67
USTRING = 30
WIDTH = 15
XY = 16
name = ('header', 'bgnlib', 'libname', 'units', 'endlib', 'bgnstr', 'strname', 'endstr', 'boundary', 'path', 'sref', 'aref', 'text', 'layer', 'datatype', 'width', 'xy', 'endel', 'sname', 'colrow', 'textnode', 'node', 'texttype', 'presentation', 'spacing', 'string', 'strans', 'mag', 'angle', 'uinteger', 'ustring', 'reflibs', 'fonts', 'pathtype', 'generations', 'attrtable', 'styptable', 'strtype', 'elflags', 'elkey', 'linktype', 'linkkeys', 'nodetype', 'propattr', 'propvalue', 'box', 'boxtype', 'plex', 'bgnextn', 'endextn', 'tapenum', 'tapecode', 'strclass', 'reserved', 'format', 'mask', 'endmasks', 'libdirsize', 'srfname', 'libsecur', 'border', 'softfence', 'hardfence', 'softwire', 'hardwire', 'pathport', 'nodeport', 'userconstraint', 'spacer_error', 'contact')
nazca.gds_base.gds_sname(string)
nazca.gds_base.gds_sref()
nazca.gds_base.gds_strans(bits)
nazca.gds_base.gds_string(string)
nazca.gds_base.gds_strname(string)
nazca.gds_base.gds_text()
nazca.gds_base.gds_texttype(texttype)
nazca.gds_base.gds_units()
class nazca.gds_base.gds_value

Bases: object

Define gds record values.

ASCII = 6
BITARRAY = 1
INT16 = 2
INT32 = 3
NODATA = 0
REAL4 = 4
REAL8 = 5
name = ('nodata', 'bitarray', 'int16', 'int32', 'real4', 'real8', 'ascii')
nazca.gds_base.gds_width(w)
nazca.gds_base.gds_xy(XY, close, min_length=1)
nazca.gds_base.map_0_360(a)

Normalize angle into [0.360].

nazca.gds_base.pack_datime(lcltm=None)
nazca.gds_base.pack_int16(h)
nazca.gds_base.pack_int32(l)
nazca.gds_base.pack_padstring(bytestring)
nazca.gds_base.pack_real8(D)
nazca.gds_base.pack_uint16(H)
nazca.gds_base.pack_uint8(B)
nazca.gds_base.round_to_db_unit(x)

nazca.gds_import module

Module to read a GDSII file record by record.

Substitute cell names and/or layer names. Keep cell constructions.

The hierarchy is:

-Cell
-Element (polygon, polyline, annotation, cell-ref)
-Records (layer, XY, etc.)

GDSII files in nazca are a subset of the GDSII spec:

gdsii:
HEADER BGNLIB | this is “header” in nazca LIBNAME | UNITS / {<structure>}* > this is “cell” in nazca ENDLIB > this is “footer” in nazca
<structure>:
BGNSTR STRNAME {<element>}* ENDSTR
<element>:
{<boundary>|<path>|<sref>|<aref>|<text>|<otherstuff>} ENDEL

GDSII cells are a set of records: - start record - name record - various types of records that can also be references to other cells - end record

All GDSII records are structured as: - 16 bit int RECORD_LENGTH (number of bytes in record) - 8 bit int RECORD_TYPE - 8 bit int DATA_TYPE - the data: (RECORD_LENGTH - 4) / (DATA_TYPE length) elements

nazca.gds_import.DFS(graph)

Check if a cell is a DAG.

GDSII cells form a sorted graph that should not contain loops. This routine does a Depth First Search of all cells and returns an topologically sorted list.

exception nazca.gds_import.GDSII_Error

Bases: Exception

class nazca.gds_import.GDSII_cell

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) -footer stream

and a set of cell references <snames>

__init__()

Initialize a GDSII_cell.

Returns:None
addelem(elem)

Add an GDSII-element to the cell.

Parameters:elem (GDSII_element) –
Returns:None
name

**Returns* – str* – name of the cell

references(sname)

Add a cell reference <sname> to the cell.

Parameters:sname (str) – name of referenced cell
Returns:None
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.gds_import.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.

Elements are polylines, sref, aref, etc. Records are layer, XY, etc.

__init__(records=None)

Initialize a GDS element.

Parameters:records (list of GDSII_record) –
Returns:None
addrecord(record)

Add a GDSII-record to the GDSII_element.

Parameters:record (GDSII_record) –
Returns:None
annotation

Return the properties of an annotation.

Returns:layer, position (x, y), text
Return type:[int, tuple, str]
etype
polygon

Return the properties of a polygon.

Returns:layer, position (x, y)
Return type:[int, tuple]
polyline

Return the properties of a polyline.

Returns:layer, position (x, y)
Return type:[int, tuple]
stream

Create a stream of all records in the GDSII_element.

Returns:gds stream
Return type:bytearray
class nazca.gds_import.GDSII_record(strm, pos=0)

Bases: object

Class for storing a gdsii record in byte stream format.

Store GDS records.

__init__(strm, pos=0)

Construct a GDSII_record.

Parameters:
  • strm (bytearray) – stream
  • pos (int) – start of record in the stream
Returns:

None

data

Convert the gds stream into proper data.

Returns:None
dtype

Data type.

Returns:data type value
Return type:uint8
rlen
rtype

Record type.

Returns:record type value
Return type:uint8
stream

Return the proper bytestream for this record.

Returns:record
Return type:bytearray
class nazca.gds_import.GDSII_stream(filename, cellmap=None, layermap=None)

Bases: object

Class to read, modify and write a GDSII stream.

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

ASCII_write(filename=False)

Write the GDS in a human readable format.

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_stream_cell_and_under(strm, cellname, init=True)

Obtain a GDS stream of cell named <cellname>, and its children.

Iterative part of method CDSII_stream_cell.

Parameters:
  • strm (bytearrray) – gds stream being build, starting as bytearray()
  • cellname (str) – cell name of top cell
  • init (bool) – flag to check is a top cell level (default:True)
Returns:

gds stream

Return type:

bytearray

GDSII_write(filename)

Write a GDSII stream to file.

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

GDSII_write_cell_and_under(f, cellname, init=True)

Write gds stream of cell named <cellname> to file <f>.

Iterative part of method GDSII_write_cell.

Parameters:
  • f (file) – file handle of file to write to
  • cellname (str) – name of the cell to write to file
  • init (bool) – flag to check if in top cell
Returns:

None

__init__(filename, cellmap=None, layermap=None)

Initiliaze a GDSII_stream.

Parameters:
  • filename (str) – file name to read
  • 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 list of all cells in branch <cellname>.

Returns

count_srefs()

Print how many times cells have been instantiated.

gds_cell_iter(rec_iter)

Return an iterator over all cells.

Parameters:rec (GDSII_record iterator) – record
Yields:GDSII_cell
gds_elem_iter(rec_iter, cell)

Return an iterator over all the gds elements in <rec_iter> in <cell>.

Parameters:
  • rec (GDSII_record iterator) – list of records
  • cell (GDSII_cell) – cell
Yields:

GDSII_element

gds_record_iter(strm, strmlen, pos=0)

Return an iterator of the cell records.

Parameters:
  • strm (byrearray) –
  • strmlen (int) – length of the stream
  • pos (int) – position in the stream
Yields:

GDSII-record

gdsversion
libname
parse()

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

Returns:None
print_structure(name, level=0)

Print the cell tree in ascii format.

Parameters:
  • name (str) – cellname
  • level (int) – function internal recursive counter (default = 0)
Returns:

None

topcell()

Return all topcells.

Returns:list of all cell names that are top cells (are not referenced)
Return type:list of str
nazca.gds_import.eprint(*args, **kwargs)
nazca.gds_import.nx_int16(strm)
nazca.gds_import.nx_int32(strm)
nazca.gds_import.nx_real8(strm)
nazca.gds_import.nx_uint8(strm)
nazca.gds_import.unpack_int16(byte2)
nazca.gds_import.unpack_int32(byte4)
nazca.gds_import.unpack_real8(byte8)
nazca.gds_import.unpack_uint16(byte2)
nazca.gds_import.unpack_uint8(byte1)

nazca.gds_cellreplace module

Module for replacing cells, static and parametric cells.

nazca.gds_cellreplace.replaceCells(gdsin, gdsout=None, PcellFunctionMap=None, ScellMapping=(None, None), infolevel=0)

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

Replacement is Pcell (parametric cell) or Scell (static cell) based. Only apply one mapping per function call, Pcell or Scell, to keep track of the mapping order. Sequential calls are possible.

  • Pcells: Needs a mapping of the Pcell basename to a cell function.
  • Scells: 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 ((str, dict)) – (<ScellFile>, <ScellMap>) for black2white mapping
  • infolevel (int) – amount of debug info printed
Returns:

gds output filename of file with replaced cells

Return type:

str

nazca.geometries module

A set of funtions to create polygon geometries for shape like box, taper, arc, frame.

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.

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

Return parallelogram polygon.

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.trapezoid(length=10, height=4, angle1=45, angle2=45, position='1', shift=(0, 0))

Return trapezoid polygon.

nazca.interconnects module

Created on Sun Jan 15 11:24:14 2017

@author: rgb Interconnect module.

class nazca.interconnects.Interconnect(radius=None, width=None, angle=90, xs='nazca', layer=None, adapt_width=False, adapt_xs=False)

Bases: object

Interconnect class for drawing waveguides.

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:

ic1 = Interconnect(width=2.0, radius=20)
ic2 = Interconnect(width=1.0, radius=50)
__init__(radius=None, width=None, angle=90, xs='nazca', layer=None, adapt_width=False, adapt_xs=False)

Contruct an Interconnect object.

If a xsection is provided in <xs> then values for <radius> and <width> will be copied from <xs>. If <radius> and/or <width> are explicitly set in __init__ then they will take priority over the values in <xs>. If <xs> nor <radius> and/or <width> are set they default to values in the cfg module

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
  • adapt_width (bool) – adapt interconnect width to the pin in connects to (default = False)
  • adapt_xs (bool) – adapt interconnect width to the pin in connects to (default = False)
Returns:

None

arc(radius=10, width=1.0, angle=90, xs=None, layer=None, offset=None, name=None)
bend(radius=None, angle=None, width=None, pin=None, xs=None, name=None, arrow=True)

Create a bent waveguide (circular arc).

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
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, ictype='shortest', name=None, arrow=True)

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

Parameters:
  • pin1 (Node | Instance) – start pin (default = cp)
  • pin2 (Node | Instance) – 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’
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()
mamba(points, radius=None, width=None, pin=None, xs=None, N=1, pitch=10, offset=0, polyline=True, showpins=False, name=None, arrow=True)

Creates a snake-like interconnect along a list of points (x, y).

Start and end of a mamba are pins ‘a0’ and ‘b0’, respectively. To connect a mamba in absolute cell coordinates 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)
Returns:

mamba element through <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)
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
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) – optional straight starting section (default = 0)
  • length2 (float) – optional straight 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
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)

Calculate angle to rotate from <pin> to a certain reference direction <ref>.

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)
Returns:

angle to rotate from <pin> to <ref> + <a>

Return type:

float

sbend(radius=None, width=None, pin=None, xs=None, offset=20, Ltot=0, name=None, arrow=True)

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 taper
  • offset (float) – lateral offset of the sbend in um
  • Ltot (float) – optional total forward length of the sbend in um
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, name=None, arrow=True)

Create point-to-point s-bend interconnect.

The direction of the end pin is ignored.

Parameters:
  • pin1 (Node | Instance) – start pin (default = cp)
  • pin2 (Node | Instance) – 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
  • Lstart (float) – straight waveguide length at beginning (positive value) or end (negative value) of sbend
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()
strt(length=None, width=None, pin=None, xs=None, edge1=None, edge2=None, name=None, arrow=True)

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
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) – start pin (default = cp)
  • pin2 (Node | Instance) – end pin
  • radius (float) – optional bend radius in um
  • width (float) – optional waveguide width in um
  • xs (str) – optional xsection
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_p2p(pin1=None, pin2=None, width=None, xs=None, name=None, arrow=True)

Create point-to-point straight interconnect.

Parameters:
  • pin1 (Node | Instance) – start of waveguide
  • pin2 (Node | Instance) – end of waveguide
  • width (float) – width of waveguide
  • xs (str) – optional xsection of waveguide
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, 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
  • xs (str) – optional xsection of taper
  • pin (Node) – optional Node for modeling info
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()
ubend_p2p(pin1=None, pin2=None, radius=None, width=None, xs=None, length=0, name=None, arrow=True)

Create point-to-point u-bend interconnect.

Parameters:
  • pin1 (Node | Instance) – start pin (default = cp)
  • pin2 (Node | Instance) – 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)
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.NegRad(a)

Clip angle to <-360, 0]

nazca.interconnects.PosRad(a)

Clip angle to [0, 360>

nazca.layout module

Generate layout to gds or screen.

class nazca.layout.Export_layout

Bases: object

__init__()
add_annotations(netlist, cnode, trans, flip, infolevel=0)

Add annotation content to cell.

add_gdsfiles(netlist, cnode, trans, flip, infolevel=0)

Add gds instances to cell.

add_instances(instance_iter, level, infolevel=0)

Add instances to cell

add_polygons(netlist, cnode, trans, flip, infolevel=0)

Add polygons content to cell.

add_polylines(netlist, cnode, trans, flip, infolevel=0)

Add polylines content to cell.

close_cells(start_level, stop_level)

Close gds “export levels” up to the last branching.

export_topcells(topcells, show_cells)

Export topcells.

Loop over each topcell in the topcells list.

Returns:None
fliplast = False
generate_layout(topcells=None, filename='nazca_export.gds', do_ascii=False, infolevel=False, show_cells=False, gds_=True, flat=False, spt=False, plt=False, clear=False, title=None, output=None, path='')

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’)
  • do_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)
  • spt (bool) – export spt file (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

process_cell(netlist, cnode, orgtrans, level, instance, flip)

Process a cell (via its cnode) and generate content from it.

class nazca.layout.Matplot

Bases: object

Handle matplotlib export of masks.

__init__()

Construct an object handling Matplotlib exports.

add_polygon(layer, points)

Add a polygon to the plot.

Note that using linewidth > 0 significantly slows down drawing.

add_polyline(layer, points, width)

Add a polyline to the plot.

close()

Close plt and show plot.

open(cell=None, title=None)

Inititialize Matplotlib mask output

class nazca.layout.SPT

Bases: object

Handle spt compatible export of masks.

__init__()
add_line(cell, x, y, a, flip)

Add building block line to spt file.

close()

Close spt output routine.

open(filename)

Initialize spt file export.

nazca.layout.export(topcells=None, filename=None, do_ascii=False, infolevel=0, show_cells=False, gds=True, flat=False, spt=False, plt=False, info=True, clear=True, title=None, output=None, path='')

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’)
  • do_ascii (bool) – export ascii version of gds (default = False)
  • show_cells (bool) – (default = False)
  • gds (bool) – export gds (default = True)
  • flat (bool) – export flat gds, i.e. no hierarchy (default = False)
  • spt (bool) – export spt file (default = False)
  • plt (bool) – generate matplotlib based layout (default = False)
  • info (bool) – (default = True)
  • 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

nazca.layout.export_clear()

Clear the default topcell.

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

nazca.layout.export_gds(topcells=None, filename=None, flat=False, spt=False, clear=True, **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’)
  • flat (bool) – export flat gds, i.e. no hierarchy (default = False)
  • clear (bool) – clear mask layout between consecutive exports (default = True)
Returns:

None

nazca.layout.export_plt(topcells=None, clear=True, title=None, output=None, path='', **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_spt(topcells=None, filename=None)
nazca.layout.verify_topcells(topcells)

nazca.lowlevel module

Low-level Nazca routines.

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

Bases: object

Class to read, modify and write a GDSII stream.

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

ASCII_write(filename=False)

Write the GDS in a human readable format.

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_stream_cell_and_under(strm, cellname, init=True)

Obtain a GDS stream of cell named <cellname>, and its children.

Iterative part of method CDSII_stream_cell.

Parameters:
  • strm (bytearrray) – gds stream being build, starting as bytearray()
  • cellname (str) – cell name of top cell
  • init (bool) – flag to check is a top cell level (default:True)
Returns:

gds stream

Return type:

bytearray

GDSII_write(filename)

Write a GDSII stream to file.

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

GDSII_write_cell_and_under(f, cellname, init=True)

Write gds stream of cell named <cellname> to file <f>.

Iterative part of method GDSII_write_cell.

Parameters:
  • f (file) – file handle of file to write to
  • cellname (str) – name of the cell to write to file
  • init (bool) – flag to check if in top cell
Returns:

None

__init__(filename, cellmap=None, layermap=None)

Initiliaze a GDSII_stream.

Parameters:
  • filename (str) – file name to read
  • 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 list of all cells in branch <cellname>.

Returns

count_srefs()

Print how many times cells have been instantiated.

gds_cell_iter(rec_iter)

Return an iterator over all cells.

Parameters:rec (GDSII_record iterator) – record
Yields:GDSII_cell
gds_elem_iter(rec_iter, cell)

Return an iterator over all the gds elements in <rec_iter> in <cell>.

Parameters:
  • rec (GDSII_record iterator) – list of records
  • cell (GDSII_cell) – cell
Yields:

GDSII_element

gds_record_iter(strm, strmlen, pos=0)

Return an iterator of the cell records.

Parameters:
  • strm (byrearray) –
  • strmlen (int) – length of the stream
  • pos (int) – position in the stream
Yields:

GDSII-record

gdsversion
libname
parse()

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

Returns:None
print_structure(name, level=0)

Print the cell tree in ascii format.

Parameters:
  • name (str) – cellname
  • level (int) – function internal recursive counter (default = 0)
Returns:

None

topcell()

Return all topcells.

Returns:list of all cell names that are top cells (are not referenced)
Return type:list of str
class nazca.lowlevel.GDSII_cell

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) -footer stream

and a set of cell references <snames>

__init__()

Initialize a GDSII_cell.

Returns:None
addelem(elem)

Add an GDSII-element to the cell.

Parameters:elem (GDSII_element) –
Returns:None
name

**Returns* – str* – name of the cell

references(sname)

Add a cell reference <sname> to the cell.

Parameters:sname (str) – name of referenced cell
Returns:None
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.

Elements are polylines, sref, aref, etc. Records are layer, XY, etc.

__init__(records=None)

Initialize a GDS element.

Parameters:records (list of GDSII_record) –
Returns:None
addrecord(record)

Add a GDSII-record to the GDSII_element.

Parameters:record (GDSII_record) –
Returns:None
annotation

Return the properties of an annotation.

Returns:layer, position (x, y), text
Return type:[int, tuple, str]
etype
polygon

Return the properties of a polygon.

Returns:layer, position (x, y)
Return type:[int, tuple]
polyline

Return the properties of a polyline.

Returns:layer, position (x, y)
Return type:[int, tuple]
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.

Store GDS records.

__init__(strm, pos=0)

Construct a GDSII_record.

Parameters:
  • strm (bytearray) – stream
  • pos (int) – start of record in the stream
Returns:

None

data

Convert the gds stream into proper data.

Returns:None
dtype

Data type.

Returns:data type value
Return type:uint8
rlen
rtype

Record type.

Returns:record type value
Return type:uint8
stream

Return the proper bytestream for this record.

Returns:record
Return type:bytearray
nazca.lowlevel.get_cell_annotation(cell, convert=False)

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

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

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

Yields:int, tuple(int|float, int|float), str – annotation layer, position, text
nazca.lowlevel.get_cell_polyline(cell, convert=False)

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

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

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

Yields:int, tuple(int, int) or (float, float) – layer, XY
nazca.lowlevel.get_cell_polygon(cell, convert=False)

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

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

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

Yields:int, tuple(int, int) or (float, float) – layer, XY
nazca.lowlevel.parameters_to_string(param)

Create a string from a parameter dictionary.

param (dict): (parameter_name, value)

Returns:parameters as a string
Return type:str
nazca.lowlevel.string_to_parameters(string)

Convert a string to a parameter dictionaty.

Returns:<parameter_name: parameter_value>
Return type:ordered dict

nazca.lyp module

nazca.lyp.lypwrite(df, filename)

nazca.mask_elements module

Define mask elements such straight and bent waveguide via template functions.

This module is to define PDKs elements via closures on nested functions. It is not intended for use in mask design directly.

nazca.mask_elements.Tp_arc(radius=10, width=1.0, angle=90, xs=None, layer=None, offset=None, name=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 layername
  • 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

Return type:

function

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

Template for creating a parametrized parabolic taper function.

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 layername
Returns:

Function returning a Cell object with a ptaper

Return type:

function

nazca.mask_elements.Tp_straight(length=10, width=1.0, xs=None, layer=None, edge1=None, edge2=None, name=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
Returns:

Function returning a Cell object with a straight guide

Return type:

function

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

Template for creating a parametrized linear taper function.

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 layername
Returns:

Function returning a Cell object with a linear taper

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 layername
  • 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.layeriter(xs=None, layer=None, dogrowy=False)

Generator yielding all layers in a xsection.

Parameters:
  • xs (str) – xsection name
  • layer (int) – layer number
  • growy (bool) – temporary switch to also yield growy
Yields:

layer, growx, 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 layername
Returns:

parabolic taper element

Return type:

Cell

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

Create a straight waveguide element.

Parameters:
  • length (float) – length of waveguide
  • width (float) – width of waveguide
  • xs (str) – xsection of waveguide
  • 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
Returns:

straight element

Return type:

Cell

nazca.mask_elements.taper(length=100, width1=2, width2=3, 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
  • xs (str) – xsection of taper
  • layer (int | str) – layer number or layername
Returns:

taper element

Return type:

Cell

nazca.mask_elements.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.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’.

Ronald Broeke 2017(c)

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

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, accuracy=None, fab_name=None, origin=None, remark=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)

Create a new mask layer.

Parameters:
  • name (str) – layer name
  • layer (int | tuple) – layer number or (layer, datatype)
Returns:

Table of mask layers

Return type:

DataFrame

nazca.mask_layers.add_layer2xsection(xsection='name', layer=None, growx=None, growy=None, accuracy=0.001, fab_name=None, origin=None, 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.

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’
  • remark (str) – extra info about the layer
Returns:

Xsection object having name <xsection>

Return type:

Xsection

nazca.mask_layers.add_xs(xsection='name', layer=None, growx=None, growy=None, accuracy=0.001, fab_name=None, origin=None, 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.

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’
  • remark (str) – extra info about the layer
Returns:

Xsection object having name <xsection>

Return type:

Xsection

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

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, growy=None, accuracy=0.001, fab_name=None, origin=None, 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.

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’
  • remark (str) – extra info about the layer
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_layers()

Drop all rows from layers and xsection tables

nazca.mask_layers.clear_xsections()

Drop all rows from layers and xs tables

nazca.mask_layers.empty_xsections()

Delete info on all xs. Keep layer info.

nazca.mask_layers.get_layer(layer)

Get the layer number for specific layer reference.

If the <layername> does not exist a default layer number is returned.

Parameters:layer (str| tuple | int) – layer reference by name | (layer, datatype) | layer
Returns:(layer, datatype)
Return type:tuple
nazca.mask_layers.get_layers()
nazca.mask_layers.get_parameter(name)

get 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.load_bbmap(filename)

Load the mapping table for nazca to spt.

The spt format is used for third party OptoDesigner mask assembly.

Parameters:filename (str) – name of file containing bb-mapping in csv format
Returns:None
nazca.mask_layers.load_layercolors(filename)

Read colormap from a .csv Nazca color table.

nazca.mask_layers.load_layers(filename)

Load layer definitions from csv file.

Parameters:filename (str) – name of layer definition file in csv format
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() and 3. merge().

Parameters:
  • layer_file (str) – layer file name of csv file
  • xs_file (str) – xsection file name of csv file
Returns:

{xsection name: DataFrame with mask layer}

Return type:

dict

nazca.mask_layers.load_parameters(filename)
nazca.mask_layers.load_xsection_layer_map(filename)

Load the assignment of layers to xsections from <filename>.

Layers or xsections that do not yet exist are created automatically.

Parameters:filename (str) – xsection file in csv format
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 export.

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.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.

For missing values the default_colors will be applied.

Parameters:
  • layer (int | tuple) – layer number or (layer, datatype)
  • ..
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
  • cmap (str) – name of the colormap
  • N (int) – the number of colors in the map in case of a ‘linearSegmentedColormap’
  • alpha (float) – transparency of the cmap to see through layers.
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(pinname=None, layer=None, text='')

Bases: object

Annotation class.

__init__(pinname=None, layer=None, text='')

Construct an annotation object.

Parameters:
  • pinname (str) – name of the pin (obsolete)
  • layer (int) – layer number to put the Polyline in
  • text (str) – annotation text
Returns:

None

put(*args)
class nazca.netlist.Cell(name='cell', celltype='element', instantiate=True, hashme=False, cnt=False)

Bases: object

Cell object, corresponding to a GDS cell output (if instantiated).

A cell has a 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 place automatically at the origin.

When starting a new cell: cp = C.pin[‘org’]

A cell typically contain 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()
I = 0
__init__(name='cell', celltype='element', instantiate=True, hashme=False, cnt=False)

Construct a Cell.

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)
Returns:

None

Example

Create a cell:

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()
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
copy_cell2instance(parent_cnode, flip, array)

Copy all nodes from a Cell into an Instance.

Parameters:
  • parent_node (Node) – main cell node of the cell to copy.
  • flip (bool) – flip state of the instance.
  • array (list) – creates an array instance upon GDS output if not None. Format the array as [col#, [dx1, dy1], row#, [dx2, dy2]] (default = None)
Returns:

instance created from <parent_node>

Return type:

Instance

default_pins(pinin=None, pinout=None)

Set default input and output pin.

Parameters:
  • pinin (Node) – pin to set as default cell input pin
  • pinout (Node) – pin to set as default cell output pin
Returns:

None

get_pin(pinname=None, connect=None)

“Parse pinname and connect for put_polygon and put_gds methods.

Returns:Node
parse_instance_connection(C1, C2, C3, C4, C5, instance=None)

Parse up to five connection arguments into a pin1, pin2, (x,y,a) format.

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
  • C5 (float | Node | instance) – Parsing information
  • instance (Instance) – instance object to connect to
Returns:

pin, pin, translation

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 polygon, polyline, annotation and gds methods.

Parameters:C2, C3, C4 (C1,) – Parsing information
Returns:pin, translation
Return type:Node, (x, y, a)

Example

In case of provinding floats: * () * (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, array=None, **kwargs)

Instantiate a Cell object and put it in the active cell.

Parameters:
  • *args (float | Node | Instance) – a set of max. 5 unnamed parameters interpreted as a connection between two pins. (default = (), which connects to the current pin)
  • flip (bool) – mirror the instance (default = False)
  • 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]] (default = None)
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.put() # -> put('a0', cp)
    nd.export_plt()
    
  2. connect pin ‘b0’ of cell “example” to current pin (cp):

    import nazca as nd
    nd.example.put('b0') # -> put('b0', cp)
    nd.export_plt()
    
  3. connec default pin of cell “example” to its parent cell at org + (10, 20, 30):

    import nazca as nd
    nd.example.put(10, 20, 30) # -> put('a0').move(10, 20, 30)
    nd.export_plt()
    
  4. connect default pin of cell “example” to instance C at pin ‘b0’:

    import nazca as nd
    C = nd.example.put(0)
    nd.example.put(C.pin['b0']) # -> put('a0', C.pin['b0'])
    nd.export_plt()
    
  5. connect pin ‘b0’ of cell “example” to instance C at pin ‘b0’:

    import nazca as nd
    C = nd.example.put(0)
    nd.example.put('b0', C.pin['b0']) # -> put('b0', C.pin['b0'])
    nd.export_plt()
    
  6. connect pin ‘b0’ of cell “example” 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.put(0)
    nd.example.put('b0', C) # -> put('b0', C.pin['b0'])
    nd.export_plt()
    
put_annotation(pinname=None, connect=None, layer=None, text=None)

Add an annotation to the cell.

Parameters:pinname (str) – pinname to attach the annotation to.
Returns:None
put_gds(pinname=None, connect=None, filename=None, cellname=None, newcellname=None, layermap=None, cellmap=None, scale=1.0)

Add a GDS to the cell. Anchor it to a pin by the pinname (string).

Example:

cell_1.put_gds(pinname='a0', filename='path_to_file.gds',
    cellname='name', newcellname='new')
put_instance(C1, C2, C3, C4, C5, flip=False, array=None, **kwargs)

Instantiate a cell and put it in the active cell.

Returns:Instance object being put
Return type:Instance
put_pin(name=None, connect=None, xs=None, width=0, type=None, chain=1, show=False)

Add new pin and connect it to an existing pin.

Returns:pin being put
Return type:Node
put_polygon(pinname='', connect=(0, 0, 0), layer=[1111], points=None)

Add a polygon to the cell. Anchor it to a pin by the pinname (string).

Returns:None
put_polyline(pinname=None, connect=None, layer=[1111], width=None, pathtype=None, points=None)

Add a polyline to the cell. Anchor it to a pin by the pinname (string).

Returns:None
solve()

Solve the graph of the cell.

class nazca.netlist.Instance

Bases: object

Class to store pins of cell instantiations.

__init__()

Construct an Instance.

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 its pins are available inside parent P, but the 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.

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.

The version without raise_pins looks like this:

# put Pin
import nazca as nd

with nd.Cell('new_cell') as new_cell:
    instance1 = nd.example.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 with raise_pins on <instance1>, which also copies all pin attributes:

# raise pins
import nazca as nd

with nd.Cell('new_cell') as new_cell:
    instance1 = nd.example.put(100, 200)
    instance1.raise_pins()

instance2 = new_cell.put(0)
nd.bend(angle=90).put(instance2.pin['a0'])
nd.export_plt()

Raise and rename pins ‘a0’ and ‘b0’ of <instance1>. 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.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, infolevel=0)

Iterator for all annotations in a cell (cnode).

Yields:pointer, layer, text – Next Annotation and info to generate it
celltree_iter(cnode, level=0, position=None, infolevel=0)

Iterate over the cell hierarchy from the topcell at ‘cnode’. Deep-first search.

The tree decents from a ‘cell cnode’ into an ‘instance cnode’, To subsequently decent into an instance we - look up the cell object the instance is derived from, - loop up the ‘cell cnode’ of that cell object, - use that cnode to yield and seed the next cell level.

Yields:cnode, level, position, flip – Yields next cell, its level in the hierarchy and position.
gdsfile_iter(cnode, level=0, infolevel=0)

Iterator for all GDS files instantiated in a cell (cnode).

Yields:pointer, file, cell, newcell, layermap, cellmap, scale – Next gds file and info to generate it
polygon_iter(cnode, infolevel=0)

Iterater for all polygons in a cell (cnode).

Yields:pointer, layer, points – Next Polygon and info to generate it
polyline_iter(cnode, infolevel=0)

Iterator for all polylines (paths) in a cell (cnode).

Yields:pointer, width, layer, path type points – Next Polyline and info to generate it
solvecell(cell)

Set cell origin at (0, 0, 0) and solve the cell.

solvecell_core(node, cnode0=None)

Calculate the geometrical positions of nodes in a cell via the netlist.

This includes all nodes in all instantiated cells one level deep. A starting node ‘node’ has to be provided. cnode0 acts as the reference to the cell being solved. A good starting node is a cnode with its pointer set at (0, 0, 0).

Nodes that are being processed, in scope, adhere to the following condition: - 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.

Parameters:
  • node (Node) – start node for solving the cell.
  • cnode0 (Node) – cnode of the cell to solve (automatically obtained from node).
Returns:

None

class nazca.netlist.Node(name=None)

Bases: object

Node class for creating node objects.

The netlist of Nodes and connections between the nodes constructs the photonic circuit and or layout.f

__init__(name=None)

Contruct a Node.

Parameters:name (str) – optional Node name.
chain

Attribute to indicate if a Node is a chain connector.

cnode_nb_iter()

Get cnodes at the cell level below the cell level of the node.

Yields:Node – next cell
copy()

Copy a node.

Returns:copy of the node.
Return type:Node
ele_nb_iter()

Get electrical neighbours.

Yields:Node – next neighbor
geo_nb_iter()

Get geometrical neighbours.

Yields:Node – next neighbor
get_info()

Get information string.

Returns:information on the node.
Return type:str
goto(x=0, y=0, a=0)

Goto position (<x>, <y>, <a>) with repect to celll origin ‘org’.

Returns:a new Node after translating by vector (<x>, <y>, <a>)
Return type:Node
move(x=0, y=0, a=0)

Move pointer in Node by (<x>, <y>, <a>).

Returns:a new Node after translating by vector (<x>, <y>, <a>)
Return type:Node
offset(y=0)

Offset the pointer of the Node by <y> . :returns: new Node after translating by vector (0, <y>, 0) :rtype: Node

opt_nb_iter()

Get optical neighbours.

Yields:Node – next neighbor
os(y=0)

Offset the pointer of the Node by <y> . :returns: new Node after translating by vector (0, <y>, 0) :rtype: Node

print_neighbours()

Print neighbours of the node in the netlists.

Returns:information on neighbors of this node
Return type:str
rot(a=0)

Rotate pointer by <a>.

Parameters:a (float) – angle of rotation in degrees
Returns:a new Node after translating by vector (0, 0, <a>)
Return type:Node
rotate(a=0)

Rotate pointer by <a>.

Parameters:a (float) – angle of rotation in degrees
Returns:a new Node after translating by vector (0, 0, <a>)
Return type:Node
shift(x=0, y=0)

Shift pointer (<x>, <y>). keep orietation.

Returns:a new Node after translating by vector (<x>, <y,> 0)
Return type:Node
skip(x=0)

Skip pointer in Node a distance <x> in direction of the pointer.

Returns:a new Node after translating by vector (<x>, 0, 0)
Return type:Node
xya()

Get pointer position of the Node.

Returns:pointer position
Return type:(x, y, a)
class nazca.netlist.Pin(name=None, xs=None, width=None, type=None, pin=None, show=False, chain=1)

Bases: object

Pin class

__init__(name=None, xs=None, width=None, type=None, pin=None, show=False, chain=1)

Construct a Pin object.

Parameters:
  • name (str) –
  • xs (str) – xsection name assigned to the pin.
  • width (float) – width in um of the connection the pin represents
  • type (str) – extra proporty for the pin
  • pin (Node) –
  • chain (int) – indicate if pin is a chain or connector (1) or not (0) (default = 1)
put(*args)
class nazca.netlist.Pointer(x=0.0, y=0.0, a=0.0)

Bases: object

A pointer with state information.

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.

_static/Pointer.png:height:100px:alt:alternatetext

fig: pointer

Parameters:
  • x – x-coordinate of the pointer position [µm]
  • y – y-coordinate of the pointer position [µm]
  • a – angle of the pointer [degrees]
__init__(x=0.0, y=0.0, a=0.0)

Constructor.

Parameters:
  • x (float) – x coordinate
  • y (float) – y coordinate
  • a (float) – angle coordinate
a

Return angle a of the pointer.

chain180(chain)

Set the chain property of the pointer.

Returns:None
copy(flip=False)

Copy pointer.

Returns:copy of the Pointer
Return type:Pointer
flip()

Flip (mirror) the state of the pointer.

Returns:None
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()
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’ to 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.

Returns:None
rotate(a)

Rotate pointer by angle a.

Parameters:a (float) – angle of the pointer [degrees]
Returns:self
Return type:Pointer
set_a(a=0.0)

Move angle absolute.

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).

Returns:None
skip(s)

Translate a pointer in the direction it is pointing in.

Returns:self
Return type:Pointer
trans(mat)

Translate pointer by matrix <mat>.

Returns:translated by matrix <mat>
Return type:Pointer
x

Return position x of the pointer.

xya()

Return the pointer position as (x, y, a).

y

Return the position y of the pointer.

class nazca.netlist.Polygon(pinname=None, layer=None, points=None)

Bases: object

Polygon class.

__init__(pinname=None, layer=None, points=None)

Construct a Polygon object.

Parameters:
  • pinname (str) – name of the pin (obsolete)
  • layer (int) – layer number to put the Polygon in
  • points (list) – list of points [(x1, y1), (x2, y2), …]
Returns:

None

put(*args)
class nazca.netlist.Polyline(pinname=None, layer=None, width=None, pathtype=0, points=None)

Bases: object

Polyline (path) class.

__init__(pinname=None, layer=None, width=None, pathtype=0, points=None)

Construct a Polyline object.

Parameters:
  • pinname (str) – name of the pin (obsolete)
  • layer (int) – layer number to put the Polyline in
  • width (float) – width of the polyline
  • pathtype (int) – gds type of path: 1, 2, 3 or 4
  • points (list) – list of points [(x1, y1), (x2, y2), …]
Returns:

None

put(*args)
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
nazca.netlist.connect_cnode(n1, n2, s)

Generate cell connection.

Returns:None
nazca.netlist.connect_ele(n1, n2, val)

Generate electrical connection.

Returns:None
nazca.netlist.connect_geo(pin1, pin2, t=(0, 0, 0), chain_node=0, chain_connect=None, DRC=True)

Generate a geometrical edge between two Nodes.

Connects pin n1 and n2 with transformation t.

Parameters:
  • pin1 (Node) – 1st pin
  • pin2 (Node) – 2nd pin
  • chain_node – chain states for n1 and/or n2 if None.
  • chain_connect – overrules chain connect rules if None. chain_connect = 0 -> chain pin chain_connect = 1 -> no-chain pin (default = 0)

chain_pin1 & chain_pin2 = chain_connect

Returns:None
nazca.netlist.connect_opt(n1, n2, s)

Generate optical connection.

Returns:None
nazca.netlist.diff(node1, node2)

Calculate the difference between two nodes.

Parameters:
  • node1 (Node) – start node
  • node2 (Node) – end node
Returns:

difference vector <node2> - <node2> between their pointers

Return type:

(dx, dy, da)

nazca.netlist.gds_filter(filename, cellmap=None, layermap=None)

Filter layers and cells form gds and export a copy to file.

nazca.netlist.get_transformation(start=None, end=None)

Return the transformation matrix that connects two pointers.

nazca.netlist.inverse(mat)

Return inverse matrix

nazca.netlist.load_gds(filename, cellname, newcellname=None, layermap=None, cellmap=None, scale=1.0, prefix='', instantiate=False)

Load a GDS cell <celllname> (and its instances) from <filename> into a Nazca cell.

This function can prefix cell names in <filename> to avoid name classes between present cells and cells in <filename>.

Parameters:
  • filename (str) – filename of gds to load
  • cellname (str) – cellname in filename to load
  • newcellname (str) – new name for <cellname>
  • layermap (dict) – mapping {old_layernumber: new_layernumber}
  • cellmap (dict) – mapping {old_cellname: new_cellname}
  • scale (float) – scaling factor if the cell (not yet implemented)
  • prefix (str) – optional string to avoid name clashes
  • instantiate (bool) – instantiate the GDS (default = False)
Returns:

Cell containing the loaded gds cell(tree)

Return type:

Cell

Example

gds_load(filename=’path_to_file.gds’, cellname=’name’)

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.print_structure(filename, cellname, level=0)

Print gds structure in ascii art.

Rerturns:
None
nazca.netlist.put_annotation(pinname=None, connect=None, layer=None, text=None)

put_annotation in the active cell.

nazca.netlist.put_gds(pinname=None, connect=None, filename=None, cellname=None, newcellname=None, layermap=None, cellmap=None, scale=1.0)

put_polygon inthe active cell.

nazca.netlist.put_pin(name=None, connect=None, xs=None, width=None, type=None, chain=1)

put_pin in the active cell.

nazca.netlist.put_polygon(pinname=None, connect=None, layer=1111, points=None)

put_polygon in the active cell.

nazca.netlist.put_polyline(pinname=None, connect=None, layer=None, width=None, pathtype=0, points=None)

put_polyline in the active cell.

nazca.netlist.show_cp(r=10, w=1)
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))
nazca.netlist.to_mat(direction=1, chain=0, x=0, y=0, a=0)

Transform vector into matrix.

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.pdk_template_core module

Module with a set Buiding Block templates for faciliating PDK creation.

nazca.pdk_template_core.BB_Group

alias of Functional_group

class nazca.pdk_template_core.Functional_group(name='')

Bases: object

Class to group building blocks syntactically together.

e.g. a bb_splitters group with various splitter components:

bb_splitters.mmi1x2

bb_splitters.mmi2x2

bb_splitters.mmi3x3

__init__(name='')
nazca.pdk_template_core.addBBmap(name, params=(), trans=(0, 0, 0))

Apply building block mapping for Phoenix software.

Returns:None
Exceptions:
ValueError
nazca.pdk_template_core.bb_fingerprint(cellcall, export_png=False, path='', bbox_stubs=True, close_plt=True)

Generate a dict with parameter list and pin list of a list off BBs.

Parameters:
  • functioncall (list of str) – function calls to fingerprint
  • export_png (bool) – generate png output and save in <path>
  • path (str) – path for saveing png files
  • bbox_stubs (bool) – add stubs to the bbox (default = True) Only relevant with export_png True
Returns:

Dictionary with building block info, Structure is as follows:

{'<cellname>':
    {'pins':
        { '<pinname>':
            {'width': <value>,
             'xs'   : <value>
             'xya'  : (<x>, <y>, <a>)
             'show' : <values>
            }
            , ...
        },
     'parameters':
         {'<keywword>': <value>}
         , ...
     'paramsname'   : <value>,
     'basename'     : <value>,
     'groupname'    : <value>,
     'function'     : <value>,
     'length'       : <value>,
     'width'        : <value>
    }
}

Return type:

dict

nazca.pdk_template_core.cellname(cellname=None, length=0, width=None, align='lc')

Create text of the cellname and position current pin to place it.

Parameters:
  • cellname (str) – name of the cell
  • length (float) – length available for the BB name in um
  • align (str) – text alignment (see nazca.text, default = ‘lc’)
Returns:

text with cellname formated

Return type:

Cell

nazca.pdk_template_core.example_cell()

Create a Nazca example cell.

Returns:cell
nazca.pdk_template_core.hashme(*params)

Parametrize the decorator to send base name and parameter names.

Returns:decorator
nazca.pdk_template_core.load_gdsBB(gdsfilename, cellname, pinfilename=None, newcellname=None, layermap=None, flip=False, scale=1, stubs=True)

Load a GDS building block and its corresponding pin file.

If stubs == True then both the stubs and the loaded GDS are instantiated inside the Cell returned by load _gdsBB to keep them in sync under flipping.

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
  • layermap (dict) – mapping of layer {number_in: number_out}
  • flip (bool) – mirror the gds (default = False)
  • scale (float) – scaling factor (default = 1), not implemented
  • stubs (bool) – place stubs (default = True)
Returns:

Cell

nazca.pdk_template_core.make_pdk_lists(functioncalls)

Create a list of Cell and a dictionary of function calls strings.

Returns:list of Cell, dict of {Cell, functioncall_ string}
Return type:list, Dict
nazca.pdk_template_core.make_pincell(layer=None, pinshape=None, pinsize=None)

Create a cell with an arrow shape to indicate pin positions.

Parameters:
  • layer (float) – layer number to place the arrow
  • arrowtype (str) – geometry type of the arrow: full | lefthalf | righthalf
Returns:

None

nazca.pdk_template_core.makestub(xs_guide, width, length=2.0, shape=None, pinshape=None, pinsize=None, cell=None)

Factory for creating stubs in the logical layers.

Parameters:
  • xs_guide (str) – name of xsection
  • width (float) – stub width
  • thick (float) – thickness of stub into cell (length)
  • shape (str) – shape of the stub: circ | rect (default = ‘rect’)
Returns:

None

nazca.pdk_template_core.parameters(parameters=None)

Put parameter list as annotation in a building block.

Parameters:parameters (dict) – {parameter_name: value}
Returns:None
nazca.pdk_template_core.put_boundingbox(pinname, length, width, raise_pins=True, outline=True, align='lc', name=True, params=True, move=(0, 0, 0))

Create bounding box (bbox) cell.

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 pin <pinname> (default = ‘lc’)
Returns:

None

nazca.pdk_template_core.put_stub(pinname=None, length=2.0, shape='box', pinshape=None, pinsize=1.0, layer=None, annotation_layer=None)

Add a xsection stub to a pin.

The xsection and width of the stub is obtained from the pin attributes.

Parameters:
  • pinname (str | list of str) – name(s) of the pin(s) (default = None) If pinname is None all the chained pins will obtain a stub.
  • length (float) – length of the stub (thickness into cell)
Returns:

None

nazca.pdk_template_core.rangecheck(allowed_values)

Check if parameter values are in range.

Parameters:values (allowed) – {str: tuple} as {var_name: (low, var_value, high)}
Raises:ValueError if out of range.
Returns:None

Example

check 0 <= a <= 10 and -5 <= b <= 5:

def func(a, b):
    nd.rangecheck({
        'a', (0, a, 10),
        'b', (-5, a, 5)
    })
nazca.pdk_template_core.stubname(xs, width, thick, shape=None, size=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.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)

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)

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)

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)

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)

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

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(R=0, wl=1.55, pol=0)

Bases: object

__init__(R=0, wl=1.55, pol=0)

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)

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

Nbg
Neff(**kwargs)
Nr
Nsub
V
__init__(Mr=None, Mb=None, w=2.0, wl=1.55, name=None, points=100)
b
clip
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

maxModes
mode
numberOfGuidedModes
plot(title=None, ax=None, **kwargs)
pol
printAllModes()
printModeInfo(mode=-1)
w
wl

nazca.slabsolver module

Multi layer solver interface. Needs external c file.

class nazca.slabsolver.Slabsolver(wl=None, pol=None, mode=0, name='', layers=None, points=100, view='topview')

Bases: object

Multi-layer slabmode solver.

Neff(**kwargs)
__init__(wl=None, pol=None, mode=0, name='', layers=None, points=100, view='topview')
Wl:wavelength
Pol:polarization
Mode:optical mode
Name:name of the solver
Layers:list of layer tuples (material, width)
Points:point to calculate for a mode field
View:‘topview’ or ‘sideview’
field
getField()
plot(title=None, rotate=False, **kwargs)
set(wl=None, pol=None, mode=None, layers=None, points=None)

nazca.text module

nazca.textfont module

nazca.util module

nazca.util.parameters_to_string(param)

Create a string from a parameter dictionary.

param (dict): (parameter_name, value)

Returns:parameters as a string
Return type:str
nazca.util.string_to_parameters(string)

Convert a string to a parameter dictionaty.

Returns:<parameter_name: parameter_value>
Return type:ordered dict
nazca.util.get_cell_annotation(cell, convert=False)

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

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

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

Yields:int, tuple(int|float, int|float), str – annotation layer, position, text
nazca.util.get_cell_polyline(cell, convert=False)

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

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

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

Yields:int, tuple(int, int) or (float, float) – layer, XY
nazca.util.get_cell_polygon(cell, convert=False)

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

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

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

Yields:int, tuple(int, int) or (float, float) – layer, XY
nazca.util.md5(s, N=5)

Return first N characters of md5 hash of string s.

nazca.util.isnotebook()

Check if code is run in a Jupyter notebook.

Returns:wether call is made from a notebook (True)
Return type:bool
nazca.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)
# or
nd.export_gds(logo, filename='mylogo.gds')

nazca.xsection module

Module defining cross section -xsection- functionality.

class nazca.xsection.Material(Nmat=None, name='', rgb=())

Bases: object

Define a physical material.

Neff(**kwargs)
Returns:effective refractive index
Return type:float
Nmat(**kwargs)
Returns:materials its refractive index
Return type:float
__init__(Nmat=None, name='', rgb=())
color(rgb)

Assign a color to the material.

Returns:None
class nazca.xsection.Stack(layers=None, etchdepth=0, background=None, name='', function=None, solver=None, view='topview')

Bases: object

Define a layer stack.

The layers (optional) in stack are materials, each having a specific thickness in um. A refractive index function or solver (optional) can be assigned to the stack via a function or solver pointer.

Neff(**kwargs)
Returns:effective refractive index
Return type:float
__init__(layers=None, etchdepth=0, background=None, name='', function=None, solver=None, view='topview')
applyetch(layers, etchdepth)

Apply etch to the layer stack.

This reduces layer thickness or even removes layers.

Parameters:
  • layers (list) – list of layer tuples (material, width)
  • etchdepth (float) – etch depth measured from top of material
Returns:

list of tuples as (material, width)

Return type:

list

count()
reset()
set(layers=None, etchdepth=0, function=None, solver=None, name=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
  • solver (function) – solver object for the stack
  • name (str) – name of the stack
  • view (str) – ‘topview’ or ‘sideview’
Returns:

None

simplifylayers(layers)

Merge neighbouring layers with the same material.

Returns:list of tuples as (material, width)
Return type:list
class nazca.xsection.Xsection(background=None, layers=None, name='')

Bases: object

Define a cross sectional waveguide structure (XS).

A structure refers to a type of optical waveguide or metal line. The XS is defined as a horizontal stack ‘hstack’ of one or more ‘vertical’ layer stacks, ‘vstack’.

Example

3 vstacks in a hstack

Each vstack has one or more layers, each layer has a material assigned to it. A vstack stack has a width attribute.

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(**kwargs)

Return the effective index of the xsection.

Returns:effective refractive index
Return type:float
Nrte(wl)
Returns:effective refractive index of the ‘ridge’
Return type:float
__init__(background=None, layers=None, name='')

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 (function) – solver object for the stack
Returns:

None

add_vstack(layers=None, etchdepth=0, name='', function=None, solver=None)

Add a ‘sideview’ 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 (function) – solver object for the stack
Returns:

object describing stack layers

Return type:

Stack

background(mat)

Set the background material of the XS.

Returns:None
index_model
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.

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 minnimum refractive index of all material in the xsection.

Returns:minimum refractive index of all material in the xsection
Return type:float
reset()

Empty the xsectional structure.

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
showSolvers()

Show implemented solvers.

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)

Module contents

Nazca module for photonic integrated circuit design.