nazca package references

nazca.cfg module

nazca.cfg.active_cell()

Get the active cell.

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

Returns:active cell
Return type:Cell
nazca.cfg.formatplot()

update matplotlib plotting style for graphs.

nazca.cfg.gds_cellname_cleanup(name)

Placeholder function that can be overruled in a foundry PDK.

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

Parameters:name (str) – cellname
Returns:valid cellname
Return type:str
nazca.cfg.reset_pin_settings()

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. A polygon is list of coordinates (x, y).
  • accuracy (float) – accuracy [µm] of the location of the intermediate points. There is no good reason to deviate from the default (default = 0.001 µm).
Returns:

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

Return type:

list

nazca.colormap module

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

Generate a matplotlib colormap from the csv table: csv2colormap

nazca.colormap.csv2lyp(csvfiles, lypfile)

Write klayout .lyp layer properties file.

Parameters:
  • csvfiles (dict) – dictionary {tab-name: filename} which contains all csv files to be written to a single lyp file. Each tab-name is the name of the tab in the layers view in KLayout and each filename is the filename of the csv file to be read.
  • lypfile (str) – filename of the .lyp file. This file will be created if it does not yet exist. If it already exists, it will be overwritten.
Returns:

None

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

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

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

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

  • tranparency and opaqueness
  • visualization of edges
  • stipple
Parameters:lypfile (str) – name of Klayout .lyp file
Returns:dictionary {<tabname>: <csv_filename>}
Return type:dict
class nazca.colormap.lypdata

Bases: object

__init__()
layer2xml(row)
output(filename)
pop()
push(tag)
xml_tag(tag, close=False)
xml_value(tag, val=None)

nazca.convert_AWGtxt2nazca module

Convert BrightAWG coordinates.txt to nazca.txt

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

Rename port ‘in’ -> ‘a’ Rename port ‘out’ -> ‘b’ rotate ports ‘in’ 180 degree export as …nazca.txt
nazca.convert_AWGtxt2nazca.convert(files, xs, win, wout)

Loop .txt input files and write converted onne or more nazca output files.

Parameters:
  • files (str | list of str) – filename(s)
  • xs (float) – xsection of connection
  • win (float) – waveguide width input side
  • wout (float) – waveguide width output side
Returns:

None

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

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

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

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

Parameters:
  • file (str) – filename
  • xs (float) – xsection of connection
  • win (float) – waveguide width input side
  • wout (float) – waveguide width output side
Returns:

list containing table with pin data

Return type:

list

nazca.convert_AWGtxt2nazca.get_txt_files(dir)

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

Parameters:dir (str) – root directory to scan
Returns:list of filenames
Return type:list of str
nazca.convert_AWGtxt2nazca.put_pins(file, xs, win, wout, warm=None, stubs=False)

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

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

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

Parameters:
  • (str (file) – filename
  • xs (float) – xsection of connection
  • win (float) – waveguide width input side
  • wout (float) – waveguide width output side
Returns:

None

nazca.cp module

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

nazca.cp.a()
nazca.cp.get_a()
nazca.cp.get_xy()
nazca.cp.get_xya()
nazca.cp.goto(x=0, y=0, a=0)
nazca.cp.goto_pin(p)
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.cp.x()
nazca.cp.xy()
nazca.cp.xya()
nazca.cp.y()

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

Get all font characters.

Returns:string with all characters present in a font
Return type:str
linelength(text, height=50)

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

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

Return a cell with all characters present in a font.

Parameters:
  • height (float) – height off the text in um
  • layer (int | string) – layer number or name to place text in
  • instantiate (bool) – instantiate cell (default False)
Returns:

cell with a sample of all characters in the font.

Return type:

Cell

Example:

cousine = nd.Font("cousine")
sample = cousine.sample()
sample.put()
nd.export_plt()
text(text='Text', height=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 (NOFILL) box_layer, e.g. for tiling protection, the box will be scaled with the text height unless a box_buf value is provided. The box_buf represents an absolute buffer between the text field and the box edge in um.

Parameters:
  • text (str) – text to display
  • height (float) – height of the text in um
  • 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)
nd.export_plt()
textheight(text, height=50)

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

nazca.font.default_font(f='nazca')
nazca.font.linelength(text, height=50)
nazca.font.text(text='Text', height=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=None)

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

class nazca.gds_base.GDS_datatype

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')
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_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)
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()
nazca.gds_base.gds_width(w)
nazca.gds_base.gds_xy(XY, close, min_length=1, unique=True)

Create xy record.

Parameters:
  • XY (list (float, float)) – list of points (x, y)
  • close
  • min_length (int) – default=1
  • unique (bool) – remove consecutive duplicates (default = True). Keep False for e.g. AREF definitions.
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:

-<structure> (gds cell)
-<element>:
-element-type: polygon (boundary), polyline (path), annotation, sref (instantiation), etc. -element-property: layer, XY, etc. -data

Note that the cell identifier, element-type and element-property are all records.

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>} {data} ENDEL

GDSII cells are a set of records: - start record - name record - various types of records, which 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(pos=None)

Bases: object

Class for storing GDS cell content.

A cell contains three attributes that constitute all cell content
-header stream -list of element objects (sref, polygon, polyline, etc) -set of cell references <snames> -footer stream
__init__(pos=None)

Initialize a GDSII_cell.

Returns:None
addelem(elem)

Add an GDSII-element to the cell.

Parameters:elem (GDSII_element) –
Returns:None
name

Get cell name.

Returns:name of the cell
Return type:str
references(sname)

Add a cell reference <sname> to the cell.

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

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

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

__init__(records=None)

Initialize a GDS element.

Parameters:
  • records (list of GDSII_record) – records to store in the element
  • = None) ((default) –
Returns:

None

addrecord(record)

Add a GDSII-record to the GDSII_element.

Parameters:record (GDSII_record) – record to add
Returns:None
annotation

Get the properties of an annotation element.

Returns None if the element is not an annotation.

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

Get the properties of an AREF element.

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

Get the properties of a box element.

Returns None if the element is not an annotation.

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

Return element type.

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

instance

Get the properties of a SREF element.

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

Get the properties of a polygon.

Returns None if the element is not a polygon.

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

Get the properties of a polyline.

Returns None if the element is not a polyline.

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

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

byte 0, 1: record byte length

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

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

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

__init__(strm, pos=0)

Construct a GDSII_record.

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

None

data

Convert the gds stream into proper data.

Returns:None
dtype

Get GDS data-type.

Returns:data-type value
Return type:uint8
rlen

Return record length.

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

rtype

get GDS-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, parse=True)

Bases: object

Class to read, modify and write a GDSII stream.

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

ASCII_write(filename=False)

Write the GDS in a human readable format.

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

Parameters:filename (str) – output filename for ascii representation of gds (default = False)
Returns:gds in ascii representation
Return type:str
GDSII_stream_cell(cellname)

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

Parameters:cellname (str) – name of the cell to get the gds stream off
Returns:gds stream
Return type:bytearray
GDSII_write(filename)

Write a GDSII stream to file.

Parameters:filename (str) – output filename for binary gds
Returns:None
GDSII_write_cell(cellname, filename)

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

Parameters:
  • cellname (str) – name of the cell to write
  • filename (str) – name of the file the gds stream is saved in
Returns:

None

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

Initiliaze a GDSII_stream.

Parameters:
  • filename (str|bytes) – file name to read or buffer with contents of gds file, in bytes or bytesarray.
  • cellmap (dict) – {celname_old:cellname_new} optional dictionary to map cell names in <filename> onto new names in the stream
  • layermap (dict) – {layer_number_old:layer_number_new} optional dictionary to map layer numbers in <filename> onto new layer numbers in the stream
Returns:

None

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

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

Returns:cellnames
Return type:set
count_srefs()

Print how many times cells have been instantiated to stdout.

create_cellmap(cellmap)

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

The internal cellmap is stored in dict self.cellmap.

Parameters:(dict (cellmap) –

)

Returns:None
create_layermap(layermap)

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

The internal layermap is stored in dict self.layermap

Parameters:(dict (layermap) –

)

Returns:None
gds_record_iter(strm, strmlen, pos=0)

Generator over the cell records.

Parameters:
  • strm (bytearray) – GDS stream
  • strmlen (int) – length of the stream to iterate over
  • pos (int) – start position in the stream (default = 0)
Yields:

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

gdsversion
libname
parse()

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

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

Returns:None
print_structure(name=None, sort=False)

Print the cell tree in ascii format.

Parameters:
  • name (str | list of str) – cellname(s)
  • sort (bool) – sort cellnames alphabetically
Returns:

None

topcell()

Get all topcells in the stream.

Returns:list of all cell names that are top cells (are not referenced)
Return type:list of str
nazca.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, infolevel=0)

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

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

  • Pcell replacement: Needs a mapping of the Pcell basename to a cell function:
    {<black_cell_basename>, <white_cell_function_pointer>}
  • Scell replacement: Needs a gds library <ScellFile> and a map <ScellMap>:
    • ScellFile (str): filename of gds library
    • ScellMap (dict): {black_cellname: white_cellname}.
Parameters:
  • gdsin (str) – input filename
  • gdsout (str) – optional output filename
  • PcellMap (dict) – black2white dictionary {black_cellbasename: white_Pcell_function}
  • ScellMapping (dict) – {<ScellFile>: {<ScellMap>}} for black2white mapping of one or more cell libraries.
  • 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.MMI_iopoly(wmmi=10, o=None, wio=None, angle=53)

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

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

MMI layout polygon.

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

Parameters:
  • wmmi (float) – width of the MMI
  • lmmi (float) – length of the MMI
  • wi (float|list) – input waveguide width(s)
  • wo (float|list) – output waveguide width(s)
  • oi (list) – input waveguide offsets from center
  • oo (list) – output waveguide offsets from center
  • angle (float) – corner cut angle (degrees) where 90° is a standard MMI
Returns:

list of points of the MMI polygon.

Return type:

poly (list)

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

Return arc polygon.

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

Return box polygon.

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

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

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

Return point on the line between p1 and p2

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

Return a polygon with the Nazca monkey.

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

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

Return parallelogram polygon.

Parameters:
  • length (float) – length of base
  • height (float) – height of parallelogram
  • angle (float) – side angle where 90 degrees gives a rectangle
  • position (int) – 1-9, position of origin 3 6 9 2 5 8 1 4 7
  • shift (point) – (sx, sy) shift of origin
Returns:

4 parallelogram coordinate points

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

Return parallelogram polygon.

Parameters:
  • length (float) – length of bounding box of parallelogram
  • height (float) – height of parallelogram
  • angle (float) – side angle where 90 degrees gives a rectangle
  • position (int) – 1-9, position of origin 3 6 9 2 5 8 1 4 7
  • shift (point) – (sx, sy) shift of origin
Returns:

4 parallelogram coordinate points

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

Return arc polygon.

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

Return 4 corner points based on position

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

Return rectangle polygon.

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

Return rhombus polygon.

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

Return rectangle polygon with rounded corners.

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

Return square polygon.

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

Return taper polygon.

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

Return tetragon polygon.

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

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

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

Parameters:
  • polygon (list of (float, float)) – points (x, y)
  • center ((float, float, float)) – (x, y, a) as center of scaling (default = (0, 0, 0))
  • scale (float) – scaling factor (default = 1.0)
  • flipx (bool) – flip x coordinate x -> -x (default = False)
  • flipy (bool) – flip y coordinate y -> -y (default = False)
  • move ((float, float, float)) – (x, y, a) tranlation after any scaling and/or flipping (default = (0, 0, 0)).
Returns:

transformed polygon points

Return type:

(list of (float, float))

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

Return trapezoid polygon.

nazca.interconnects module

Nazca module for interconnecting guides.

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

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:

import nazca as nd
import nazca.interconnects as IC

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

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

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

nd.export_plt()
__init__(radius=None, width=None, angle=90, xs=None, 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 set in the cfg module and an interconnect with the name ‘nazca’ is created.

Parameters:
  • radius (float) – default radius in um
  • width (float) – default waveguide width im um
  • angle (float) – default angle of a bend (default = 90 degrees)
  • xs (str) – waveguide xsection (default = ‘nazca’)
  • layer (str) – layer to draw interconnect in. It is preferred to use a xs rather than a layer for Interconnects to store additional information like offset, index, etc. (default = None)
  • adapt_width (bool) – adapt interconnect width to the pin in connects to (default = False)
  • adapt_xs (bool) – adapt interconnect width to the pin in connects to (default = False)
Returns:

None

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

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
  • name (str) – optional new name for the component
  • arrow (bool) – draw connection arrows (default = True)
Returns:

circularly-bent waveguide element

Return type:

Cell

Example

Create and place a bend:

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

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

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

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

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

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

Parameters:
  • pin1 (Node | Instance | tuple(x, y, a)) – start pin (default = cp)
  • pin2 (Node | Instance | tuple(x, y, a)) – end pin
  • radius1 (float) – optional first bend radius in um
  • radius2 (float) – optional second bend radius im um
  • width (float) – optional waveguide width in um
  • xs (str) – optional xsection
  • ictype (str) – interconnection type (default = ‘shortest’) options: ‘shortest’, ‘ll’, ‘lr’, ‘rl’, rr’, ‘all’
  • name (str) – optional new name for the component
  • arrow (bool) – draw connection arrows (default = True)
Returns:

bend_strt_bend element

Return type:

Cell

Example

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

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

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

Create a cosine-bend interconnect.

Parameters:
  • width (float) – width of the interconnect in um
  • pin (Node) – optional Node for modeling info
  • xs (str) – xsection of cbend
  • distance (float) – total forward length of the cbend in um
  • offset (float) – lateral offset of the cbend in um
  • name (str) – optional new name for the component
  • arrow (bool) – draw connection arrows (default = True)
Returns:

cbend element

Return type:

Cell

Example

Create and place a cbend waveguide:

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

guide = ic.cbend(distance=100, offset=50)
guide.put()
nd.export_plt()
copy(ic=None)

Create a copy of the Interconnect object.

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

Returns:copy of self
Return type:Interconnect
mamba(points, radius=None, width=None, pin=None, xs=None, N=1, pitch=10, offset=0, polyline=True, showpins=False, name=None, arrow=True)

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

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

Parameters:
  • points – list of (x, y) positions to guide the mamba
  • radius (float) – optional waveguide radius (default self.radius)
  • width (float) – optional waveguide width (default self.width)
  • pin (Node) – optional Node for modeling info
  • xs (str) – optional xsection of mamba
  • N (int) – number of parallel guides in the mamba
  • pitch (float) – pitch of the guide if N>1
  • offset (float) – lateral offset in the position of all guides
  • polyline (bool) – boolean determining if the mamba is also drawn as polyline (default = True)
  • showpins (bool) – show the points as dots in the layout (default = False)
  • name (str) – optional new name for the component
  • arrow (bool) – draw connection arrows (default = True)
Returns:

Mamba element based on the provided <points>

Return type:

Cell

Example

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

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

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

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

guide.put('org', 0)
pcurve_p2p(pin1=None, pin2=None, width=None, radius1=0, radius2=0, offset1=None, offset2=None, xs=None, name=None, arrow=True)

Create point-to-point pcurve interconnect.

Parameters:
  • pin1 (Node | Instance | tuple(x, y, a)) – start pin (default = cp)
  • pin2 (Node | Instance | tuple(x, y, a)) – end pin
  • width (float) – optional waveguide width in um
  • xs (str) – optional xsection
  • radius1 (float) – radius at start of the pcurve (default = 0 -> inf)
  • radius2 (float) – radius at start of the pcurve (default = 0 -> inf)
  • offset1 (float) – lateral offset at pin1
  • offset2 (float) – lateral offset at pin2
  • name (str) – optional new cell name for the component
  • arrow (bool) – draw connection arrows (default = True)
Returns:

pcurve interconnect element

Return type:

Cell

Example

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

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

guide = ic.pcurve_p2p(pin1=(0, 0, 0), pin2=(40, 20, 90))
guide.put()
nd.export_plt()
ptaper(length=None, width1=None, width2=None, pin=None, xs=None, name=None, arrow=True)

Create a parabolic taper.

Parameters:
  • length (float) – length of taper
  • width1 (float) – start width of taper
  • width2 (float) – end width of taper
  • pin (Node) – optional Node for modeling info
  • xs (str) – optional xsection of taper
  • name (str) – optional new name for the component
  • arrow (bool) – draw connection arrows (default = True)
Returns:

parabolic taper element

Return type:

Cell

Example

Create and place a parabolic taper:

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

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

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

Parameters:
  • pin (Node) – starting pin (default = cp)
  • ref (Node) – reference pin (default = org)
  • angle (float) – rotation with repect to ref (default = 0)
  • length1 (float) – 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
  • name (str) – optional new name for the component
  • arrow (bool) – draw connection arrows (default = True)
Returns:

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

Return type:

Cell

Example

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

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

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

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

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

Parameters:
  • pin (Node) – starting pin (default = cp)
  • ref (Node) – reference pin (default = org)
  • angle (float) – rotation with repect to ref in [Degrees] (default = 0)
  • cw (bool) – angle direction clockwise or counter clockwise (default is shortest bend)
  • name (str) – optional new name for the component
  • arrow (bool) – draw connection arrows (default = True)
Returns:

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

Return type:

tuple, float

sbend(radius=None, width=None, pin=None, xs=None, offset=20, Ltot=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 sbend
  • offset (float) – lateral offset of the sbend in um
  • Ltot (float) – optional total forward length of the sbend in um. When positive/negative, additional length is added at the end/start of the s-bend, provided the forward length of the s-bend itself is shorter than abs(Ltot).
  • name (str) – optional new name for the component
  • arrow (bool) – draw connection arrows (default = True)
Returns:

sbend element

Return type:

Cell

Example

Create and place a sbend waveguide:

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

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

Create point-to-point s-bend interconnect.

The direction of the end pin is ignored.

Parameters:
  • pin1 (Node | Instance | tuple(x, y, a)) – start pin (default = cp)
  • pin2 (Node | Instance | tuple(x, y, a)) – end pin
  • width (float) – width of the interconnect in um
  • radius (float) – bend radius of the interconnect in um
  • xs (str) – optional xsection of sbend
  • doFirst (int) – (default = 1)
  • Amax (float) – maximum bend angle (default = 90)
  • Lstart (float) – straight waveguide length at beginning (positive value) or end (negative value) of sbend
  • ref (Node) – reference direction for the sbend (default = pin1).
  • name (str) – optional new name for the component
  • BendEndFlag (int) – (default = 1)
  • arrow (bool) – draw connection arrows (default = True)
Returns:

sbend element

Return type:

Cell

Example

Create and place a sbend to connect two specific points:

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

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

Create a (raised) sine-bend interconnect.

Parameters:
  • width (float) – width of the interconnect in um
  • pin (Node) – optional Node for modeling info
  • xs (str) – xsection of sinebend
  • distance (float) – total forward length of the sinebend in um
  • offset (float) – lateral offset of the sinebend in um
  • name (str) – optional new name for the component
  • arrow (bool) – draw connection arrows (default = True)
Returns:

sinebend element

Return type:

Cell

Example

Create and place a sinebend waveguide:

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

guide = ic.sinebend(distance=100, offset=50)
guide.put()
nd.export_plt()
strt(length=None, width=None, pin=None, xs=None, edge1=None, edge2=None, 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
  • name (str) – optional new name for the component
  • arrow (bool) – draw connection arrows (default = True)
Returns:

waveguide element

Return type:

Cell

Example

Create and place a straight waveguide:

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

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

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

Parameters:
  • pin1 (Node | Instance | tuple(x, y, a)) – start pin (default = cp)
  • pin2 (Node | Instance | tuple(x, y, a)) – end pin
  • radius (float) – optional bend radius in um
  • width (float) – optional waveguide width in um
  • xs (str) – optional xsection
  • name (str) – optional new name for the component
  • arrow (bool) – draw connection arrows (default = True)
Returns:

strt_bend_strt element

Return type:

Cell

Example

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

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

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

Create a straight guide to intersect a reference line.

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

Args:
pin (Node | Instance | tuple(x, y, a)): start pin (default = cp) ref (Node | Instance)| tuple(x, y, a)): the reference line to intersect width (float): width of the interconnect in um xs (str): optional xsection of sbend name (str): optional new name for the component arrow (bool): draw connection arrows (default = True) max_length (float): maximum length of the guide.
Example:

Create and place a straigth waveguide to intersect with a reference line:

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()
Returns:straight waveguide element.
Return type:Cell
strt_p2p(pin1=None, pin2=None, width=None, xs=None, name=None, arrow=True)

Create point-to-point straight interconnect.

Parameters:
  • pin1 (Node | Instance | tuple(x, y, a)) – start of waveguide
  • pin2 (Node | Instance | tuple(x, y, a)) – end of waveguide
  • width (float) – width of waveguide
  • xs (str) – optional xsection of waveguide
  • name (str) – optional new name for the component
  • arrow (bool) – draw connection arrows (default = True)
Returns:

straight waveguide element

Return type:

Cell

Example

Create and place a straight guide between points:

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

guide = ic.strt_p2p(pin1=(0, 0), pin2=(10, 10))
guide.put()
nd.export_plt()
taper(length=None, width1=None, width2=None, 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
  • name (str) – optional new name for the component
  • arrow (bool) – draw connection arrows (default = True)
Returns:

linear taper element

Return type:

Cell

Example

Create and place a linear taper:

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

guide = ic.taper(length=10, width1=2.0, width2=5.0)
guide.put()
nd.export_plt()
ubend_p2p(pin1=None, pin2=None, radius=None, width=None, xs=None, length=0, name=None, arrow=True, balance=0, end_angle=False)

Create point-to-point u-bend interconnect.

An extra straight length can be added to the ubend with <length>. If the sideways translation needed in the ubend is <2*radius, then the ubend automatically introduces a ‘horseshoe’ shape. The horseshoe can be made sidelobed by a <balance> parameter between -1 and 1, where 0 results in a symmetric shape. The orientation of the output pin does not matter

Parameters:
  • pin1 (Node | Instance | tuple(x, y, a)) – start pin (default = cp)
  • pin2 (Node | Instance | tuple(x, y, a)) – end pin
  • radius (float) – optional bend radius in um
  • width (float) – optional waveguide width in um
  • xs (str) – optional xsection of ubend
  • length (float) – extra straight section for longer ubend (default = 0)
  • balance (float) – for a ubend <2*radius sidewyas, shift the horseshoe shape (default = 0)
  • end_angle (bool) – Take pin2 angle into account when connecting if True (default = False)
Returns:

ubend element

Return type:

Cell

Example

Create and place a ubend to connect two specific points:

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

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

Clip angle to <-360, 0].

Parameters:a (float) – angle in degrees
Returns:angle in degrees
Return type:float
nazca.interconnects.negRad(a)

Clip angle to <-2pi, 0]

Parameters:a (float) – angle in radians
Returns:angle in radians
Return type:float
nazca.interconnects.posDeg(a)

Clip angle to [0, 360>.

Parameters:a (float) – angle in degrees
Returns:angle in degrees
Return type:float
nazca.interconnects.posRad(a)

Clip angle to [0, 2pi>.

Parameters:a (float) – angle in radians
Returns:angle in radians
Return type:float
nazca.interconnects.zeroDeg(a)

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

Parameters:a (float) – angle in degrees
Returns:angle in degrees
Return type:float
nazca.interconnects.zeroRad(a)

Clip angle to <-pi, pi].

Parameters:a (float) – angle in radians
Returns:angle in radians
Return type:float

nazca.layout module

Generate layout to gds or screen.

class nazca.layout.BBlock(filebasename)

Bases: object

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

__init__(filebasename)

Initialize BB file: open and add header.

Parameters:filebasename (str) – basename of the output file (without extension).
Returns:None
body(topcell)

Write BB file body of element.

Parameters:topcell (Cell) – topcell to export as BB
Returns:None
footer()

Write BB file footer.

Returns:None
class nazca.layout.ClsGDS

Bases: object

Helper class to handle gdsii compatible export of masks.

__init__()

Initialize a ClsGDS object.

Returns:None
open(filebasename)

Open ClsGDS file output.

Parameters:filebasename (str) – base filename
Returns:None
write(level)

Write to ClsGDS output file.

Parameters:level (int) – level in hierarchy to write to
Returns:None
class nazca.layout.ClsMatplotlib

Bases: object

Helper class to handle matplotlib export of masks.

__init__()

Construct an object handling Matplotlib exports.

Returns:None
add_polygon(layer, points, bbox)

Add a polygon to the plot.

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

Parameters:
  • layer (int, int) – mask layer
  • points (list of (float, float)) – polygon points
  • bbox (tuple of floats) – bounding box of polygon (x1, y1, x2, y2)
Returns:

None

add_polyline(layer, points, width, bbox)

Add a polyline to the plot.

Not implemented.

close()

Close plt and show plot.

Returns:None
open(cell=None, title=None)

Inititialize Matplotlib mask output.

Parameters:
  • cell (Cell) – Cell to draw
  • title (str) – title in Matplotlib output
Returns:

None

class nazca.layout.ClsNazca(instantiate=True, cellmap=None, layermap=None, flat=None, infolevel=0)

Bases: object

Helper class to handle Nazca cell tree transformations.

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

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

__init__(instantiate=True, cellmap=None, layermap=None, flat=None, infolevel=0)

Initialize a Clsazca object.

Parameters:
  • instantiate (bool) –
  • cellmap (dict) – mapping of old_cellname: new_cellname
  • layermap (dict) – mapping of old_layer: new_layer
  • flat (bool) – flatten mask output
  • infolevel (int) –
Returns:

None

add_annotation(text, layer, pos)

Add an annitation.

Parameters:
  • text (str) – text to use as annotation
  • layer (str) – layer name
  • pos ((float, float)) – annotation posistion (x, y)
Returns:

None

add_gds()

Not implemented.

Returns:None
add_instance(inode, xya, flip)

Add instance.

Parameters:
  • inode (instance Node) – Node as Instance reference
  • xya ((float, float, float)) – coordinate to put instance
  • flip (bool) – flip or mirror state of the instance placement
Returns:

None

add_polygon(layer, xy)

Add a polygon.

Parameters:
  • layer (str) – layername
  • xy (list of (float, float)) – list of (x, y)
Returns:

None

add_polyline(layer, xy)

Add a polyline.

Parameters:
  • layer (str) – layername
  • xy (list of (float, float)) – list of (x, y)
Returns:

None

close()

Close Cell object.

Returns:
Return type:ClsNazca
open(params)

Open new Cell object based on namedtuple <cellinfo>.

Parameters:
  • cell (Cell) – original cell to be copied/filtered
  • level (int) – cell level in hierarchy (0 is topcell)
Returns:

None

class nazca.layout.ClsSVG

Bases: object

Helper class to handle svg compatible export of masks.

__init__()

Initilaize a ClsSVG object.

Returns:None
add_polygon(layer, points, bbox)

Add a polygon to the SVG drawing.

Parameters:
  • layer (str) – layername
  • points (list of (float, float)) – polygon points [(x, y), …]
  • bbox ((list of (float, float)) – bounding box the points [(x, y), …]
Returns:

None

close()

Close the svg mask layout output file.

Returns:None
open(filebasename='nazca_export')

Open SVG.

Open after layer colors have been loaded.

Parameters:basename (str) – base filename.
Returns:None
class nazca.layout.Export_layout(layermap=None, layermapmode='all')

Bases: object

Class to export a mask layout.

__init__(layermap=None, layermapmode='all')

Initialize an Export_layout object.

Parameters:
  • layermap (dict) – layermap oldlayr:newlayer
  • layermapmode (str) – ‘all’: copy all layers, ‘none’: copy only mapped layers, remove others.
Returns:

None

add_annotations(anno_iter=None, level=None, create=False, cell=None, params=None)

Add annotation content to cell.

Parameters:
  • instantiate (bool) – the instantiation level of the cell where the annotation are from: To check for black boxes, which can’t be flattened.
  • params (namedtuple) – replaces all other parameters if not None
Returns:

None

add_gdsfiles(gdsfile_iter, level)

Add gds instances to cell.

Parameters:
  • gdsfile_iter (iter) – iterator over gdsfiles in the cell
  • level (int) – depth in the hierarchy
Returns:

None

add_instances(instance_iter=None, level=None, infolevel=0, params=None)

Add instances to cell.

Parameters:
  • instance_iter (iterator) – instance iterator
  • level (int) – hierarchy level
  • params (namedtuple) – replaces all other parameters if not None
Returns:

None

add_polygons(pgon_iter=None, level=None, params=None)

Add polygons content to cell.

Parameters:
  • pgon_iter (iterator) – polygon iterator
  • level (int) – hierarchy level
  • params (namedtuple) – replaces all other parameters if not None
Returns:

None

add_polylines(pline_iter=None, level=None, params=None)

Add polylines content to cell.

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

Parameters:
  • pline_iter (iterator) – polyline iterator
  • level (int) – hierarchy level
  • params (namedtuple) – replaces all other parameters if not None
Returns:

None

ascii

Get ascii export setting.

export_topcells(topcells)

Export topcells.

Loop over each topcell in the topcells list.

Parameters:topcells (list of Cell) – list of topcells
Returns:None
filebasename

Return filebasename.

Returns:filebasename
Return type:str
filename

Get filename for export.

Returns:filename
Return type:str
flat

Get flat export setting.

Returns:flat state
Return type:bool
gds

Get gds export setting.

Returns:plt export state
Return type:bool
generate_layout(topcells=None)

Internal wrapper function before exporting the layout.

Create final topcells list and set final flags for export.

Parameters:
  • topcells (Cell | list of Cells) – Cell(s) to export (default = None, which, exports the ‘nazca’ default gds cell)
  • filename (str) – gds output filename (default = ‘nazca_export.gds’)
  • ascii (bool) – export ascii version of gds (default = False)
  • show_cells (bool) – print exported cell names to stdout (default = False)
  • gds (bool) – export gds (default = True)
  • flat (bool) – export flat gds, i.e. no hierarchy (default = False)
  • 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

newtree()

Create a Nazca export object.

Returns:
Return type:ClsNazca
plt

Get plt export setting.

reset()

Reset export settings to defaults.

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

Create the layermap for export.

Layermap is set internally.

Parameters:
  • layermap (dict) – layermap oldlayr:newlayer
  • mode (str) – ‘all’ (default): copy all layers, ‘none’: copy only mapped layers, remove others.
Returns:

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

Return type:

dict

svg

Get svg export setting.

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

Alias for a Nelist celltree_iter2 function.

nazca.layout.clear_layout()

Remove all cell references to start a brand new layout.

A new topcell ‘nazca’ will be created.

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

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’)
  • clear (bool) – clear mask layout between consecutive exports (default = True)
  • gds (bool) – export gds (default = True)
  • ascii (bool) – export ascii version of gds (default = False)
  • svg (bool) – export spt file (default = False)
  • plt (bool) – generate matplotlib based layout (default = False)
  • spt (bool) – export spt file (default = False)
  • flat (bool) – export flat gds, i.e. no hierarchy (default = False)
  • infolevel (int) – amount of debug info to stdout (default = 0)
  • show_cells (bool) – (default = False)
  • info (bool) – (default = True)
  • title (str) – title for the layout if the format allows for a title
  • output (str) – type of output stream (screen, file …)
  • path (str) – output dir for saved Matplotlib plots (default = ‘’)
  • bb (bool) – export as a library bb (default = False)
Returns:

None

nazca.layout.export_clear()

Clear the default topcell.

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

Returns:None
nazca.layout.export_gds(topcells=None, filename=None, flat=False, spt=False, clear=None, bb=False, **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)
  • bb (bool) – Export design as a building block (default = False)’
Returns:

None

nazca.layout.export_plt(topcells=None, clear=None, 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_svg(topcells=None, title=None, path='', **kwargs)

Export layout to svg format (scalable vector graphics).

Parameters:
  • topcells (Cell | list of Cells) – Cell(s) to export (default = None, which exports the ‘nazca’ default gds cell)
  • title (str) – title for the layout if the format allows for a title
  • path (str) – output dir for saved Matplotlib plots (default = ‘’)
Returns:

None

nazca.layout.layout(layermap=None, layermapmode='all')

Create a layout object for rebuilding cells.’

Parameters:
  • layermap (dict) – layermap oldlayr:newlayer
  • layermapmode (str) – ‘all’: copy all layers, ‘none’: copy only mapped layers, remove others.
Returns:

layout object

Return type:

Export_layout

nazca.layout.rebuild(cell, instantiate=True, flat=False, layermap=None, layermapmode=None)

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

The original cell remains unchanged.

Parameters:
  • cell (Cell) – input cell(tree)
  • instantiate (bool) – instantiate the toplevel (True)
  • flat (bool) – flatten whole rebuild cell
  • layermap (dict) – layermap oldlayr:newlayer
  • layermapmode (str) – ‘all’: copy all layers, ‘none’: copy only mapped layers, remove others.
Returns:

rebuild input cell

Return type:

Cell

nazca.layout.verify_topcells(topcells)

Verify if <topcells> has the correct format.

Parameters:topcells (Cell | list of Cell) – variable to check
Returns:if topcells okay
Return type:None
Exceptions:
ValueError: topcells not valid

nazca.lowlevel module

Low-level Nazca routines.

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

Bases: object

Class to read, modify and write a GDSII stream.

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

ASCII_write(filename=False)

Write the GDS in a human readable format.

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

Parameters:filename (str) – output filename for ascii representation of gds (default = False)
Returns:gds in ascii representation
Return type:str
GDSII_stream_cell(cellname)

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

Parameters:cellname (str) – name of the cell to get the gds stream off
Returns:gds stream
Return type:bytearray
GDSII_write(filename)

Write a GDSII stream to file.

Parameters:filename (str) – output filename for binary gds
Returns:None
GDSII_write_cell(cellname, filename)

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

Parameters:
  • cellname (str) – name of the cell to write
  • filename (str) – name of the file the gds stream is saved in
Returns:

None

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

Initiliaze a GDSII_stream.

Parameters:
  • filename (str|bytes) – file name to read or buffer with contents of gds file, in bytes or bytesarray.
  • cellmap (dict) – {celname_old:cellname_new} optional dictionary to map cell names in <filename> onto new names in the stream
  • layermap (dict) – {layer_number_old:layer_number_new} optional dictionary to map layer numbers in <filename> onto new layer numbers in the stream
Returns:

None

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

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

Returns:cellnames
Return type:set
count_srefs()

Print how many times cells have been instantiated to stdout.

create_cellmap(cellmap)

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

The internal cellmap is stored in dict self.cellmap.

Parameters:(dict (cellmap) –

)

Returns:None
create_layermap(layermap)

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

The internal layermap is stored in dict self.layermap

Parameters:(dict (layermap) –

)

Returns:None
gds_record_iter(strm, strmlen, pos=0)

Generator over the cell records.

Parameters:
  • strm (bytearray) – GDS stream
  • strmlen (int) – length of the stream to iterate over
  • pos (int) – start position in the stream (default = 0)
Yields:

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

gdsversion
libname
parse()

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

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

Returns:None
print_structure(name=None, sort=False)

Print the cell tree in ascii format.

Parameters:
  • name (str | list of str) – cellname(s)
  • sort (bool) – sort cellnames alphabetically
Returns:

None

topcell()

Get all topcells in the stream.

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

Bases: object

Class for storing GDS cell content.

A cell contains three attributes that constitute all cell content
-header stream -list of element objects (sref, polygon, polyline, etc) -set of cell references <snames> -footer stream
__init__(pos=None)

Initialize a GDSII_cell.

Returns:None
addelem(elem)

Add an GDSII-element to the cell.

Parameters:elem (GDSII_element) –
Returns:None
name

Get cell name.

Returns:name of the cell
Return type:str
references(sname)

Add a cell reference <sname> to the cell.

Parameters:sname (str) – name of referenced cell
Returns:None
stream

Create the full stream of the cell.

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

Returns:stream of the cell
Return type:bytearray
class nazca.lowlevel.GDSII_element(records=None)

Bases: object

Class for GDS elements.

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

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

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

__init__(records=None)

Initialize a GDS element.

Parameters:
  • records (list of GDSII_record) – records to store in the element
  • = None) ((default) –
Returns:

None

addrecord(record)

Add a GDSII-record to the GDSII_element.

Parameters:record (GDSII_record) – record to add
Returns:None
annotation

Get the properties of an annotation element.

Returns None if the element is not an annotation.

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

Get the properties of an AREF element.

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

Get the properties of a box element.

Returns None if the element is not an annotation.

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

Return element type.

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

instance

Get the properties of a SREF element.

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

Get the properties of a polygon.

Returns None if the element is not a polygon.

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

Get the properties of a polyline.

Returns None if the element is not a polyline.

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

Create a stream of all records in the GDSII_element.

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

Bases: object

Class for storing a GDSii record in byte stream format.

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

byte 0, 1: record byte length

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

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

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

__init__(strm, pos=0)

Construct a GDSII_record.

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

None

data

Convert the gds stream into proper data.

Returns:None
dtype

Get GDS data-type.

Returns:data-type value
Return type:uint8
rlen

Return record length.

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

rtype

get GDS-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 convert is False then return XY as integers, as in GDSII file (nm). If convert is True then return XY as floats (um).

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

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

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

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

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

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

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

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

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

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

Create a string from a parameter dictionary.

param (dict): (parameter_name, value)

Format:

“Parameters: <parameter> = <value> <parameter> = <value> …”

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

Convert a string to a parameter dictionary.

The returned parameter values are represented as type str.

Expected format of <string>:

“parameters: <parameter> = <value> <parameter> = <value> …”

Header ‘parameters:’ is case incensitive and spaces will be stripped.

Parameters:string (str) – parameters
Returns:{<parameter_name>: <parameter_value>}
Return type:OrderedDict

nazca.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_ccurve(width=1, distance=200, offset=20, xs=None, layer=None, name=None)

Template for creating parametrized cosine curve waveguide function.

Parameters:
  • width (float) – width of the interconnect in um
  • pin (Node) – optional Node for modeling info
  • xs (str) – xsection of cbend
  • distance (float) – total forward length of the cbend in um
  • offset (float) – lateral offset of the cbend in um
  • xs – xsection of waveguide
  • layer (int | str) – layer number or layername
Returns:

Function returning a Cell object with the ccurve guide

Return type:

function

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

Template for creating parametrized pcurve waveguide function.

Parameters:
  • xya (point) – point to connect to from (0,0,0)
  • width (float) – width of waveguide
  • radius1 (float) – radius at start (0 is no curvature)
  • radius2 (float) – radius at end (0 is no curvature)
  • offset1 (float | function) – positive offset reduces radius. The offset can be a function F(width, radius) that returns a float
  • offset2 (float | function) – positive offset reduces radius. The offset can be a function F(width, radius) that returns a float
  • xs (str) – xsection of waveguide
  • layer (int | str) – layer number or layername
Returns:

Function returning a Cell object with the pcurve guide

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_sinecurve(width=1, distance=200, offset=20, xs=None, layer=None, name=None)

Template for creating parametrized cosine curve waveguide function.

Parameters:
  • width (float) – width of the interconnect in um
  • pin (Node) – optional Node for modeling info
  • xs (str) – xsection of cbend
  • distance (float) – total forward length of the cbend in um
  • offset (float) – lateral offset of the cbend in um
  • xs – xsection of waveguide
  • layer (int | str) – layer number or layername
Returns:

Function returning a Cell object with the sinecurve guide

Return type:

function

nazca.mask_elements.Tp_straight(length=10, width=1.0, xs=None, layer=None, edge1=None, edge2=None, 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.cbend(width=1, distance=200, offset=20, xs=None, layer=None, name=None)

Create a cosine bend waveguide element.

Parameters:
  • width (float) – width of the interconnect in um
  • pin (Node) – optional Node for modeling info
  • xs (str) – xsection of cbend
  • offset (float) – lateral offset of the cbend in um
  • distance (float) – total forward length of the cbend in um
  • xs – xsection of waveguide
  • layer (int | str) – layer number or layername
Returns:

ccurve 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.pcurve(xya=(100, 100, 10), width=1.0, radius1=0, radius2=0, offset1=None, offset2=None, xs=None, layer=None, name=None)

Create a parametric waveguide element.

Parameters:
  • xya (point) – point to connect to from (0,0,0)
  • width (float) – width of waveguide
  • xs (str) – xsection of waveguide
  • layer (int | str) – layer number or layername
Returns:

pcurve element

Return type:

Cell

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.sinebend(width=1, distance=200, offset=20, xs=None, layer=None, name=None)

Create a (raised) sine bend waveguide element.

Parameters:
  • width (float) – width of the interconnect in um
  • pin (Node) – optional Node for modeling info
  • xs (str) – xsection of sinebend
  • offset (float) – lateral offset of the sinebend in um
  • distance (float) – total forward length of the sinebend in um
  • xs – xsection of waveguide
  • layer (int | str) – layer number or layername
Returns:

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

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, tech=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, unknown=False, merge=True)

Create a new mask layer.

Parameters:
  • name (str) – layer name
  • layer (int | tuple) – layer number or (layer, datatype)
  • tech (str) – technology ID
  • accuracy (float) – mask resolution of the layer in um
  • fab_name (str) – optional name used by the foundry for this layer
  • origin (str) – who created the layer
  • remark (str) – extra info for the layer
  • unknown (bool) – True if redirected from get_layer (default = False)
  • merge (bool) – if True merge xscetion and layers (default is True)
  • .. – color attributes
Returns:

Table of mask layers

Return type:

DataFrame

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

Clear all objects with layer information.

Returns:None
nazca.mask_layers.clear_xsections()

Drop all rows from layers and xs tables.

Returns:None
nazca.mask_layers.empty_xsections()

Delete info on all xs. Keep layer info.

Returns:None
nazca.mask_layers.get_layer(layer)

Get the layer ID for a specific layer reference.

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

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

Get predefined selection of columns from layer_table DataFrame.

Returns:layer info [‘nazca_name’, ‘layer’, ‘datatype’, ‘tech’, ‘accuracy’]
Return type:DataFrame
nazca.mask_layers.get_parameter(name)

Obsolete.

Set parameter value for specific name.

nazca.mask_layers.get_xsection(name)

Return the Xsection object corresponding to <name>.

Parameters:name (str | Node) – xsection name or a pin object
Returns:Xsection object with name <name>
Return type:Xsection
nazca.mask_layers.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 file.

Parameters:filename (str) – filename
Returns:None
nazca.mask_layers.load_layers(filename, tech=None, clear=False, autocolor=False)

Load layer definitions from csv file into the Nazca layer table.

The load can replace existing layer definitions or extend them (default).

Parameters:
  • filename (str) – name of layer definition file in csv format
  • tech (str) – technology name
  • clear (bool) – clear existing layers (default = False)
  • autocolor (bool) – Create automated color settings per layer (default = False)
Returns:

table with layers

Return type:

DataFrame

nazca.mask_layers.load_masklayers(layer_file=None, xsection_layer_file=None)

Load layer and xsection files and merge them.

This function combines 1. load_layers() 2. load_xsection_layer_map() 3. merge()

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

{xsection name: DataFrame with mask layer}

Return type:

dict

nazca.mask_layers.load_parameters(filename)

Obsolete

nazca.mask_layers.load_xsection_layer_map(filename, tech=None)

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

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

Parameters:
  • filename (str) – xsection file in csv format
  • tech (str) – technology ID.
Returns:

merged xsections and layers.

Return type:

DataFrame

nazca.mask_layers.load_xsections(filename)

Load list of xsection from file with stub mapping.

In addition create a stub map dictionary of a xsection to its stub-xsection.

Parameters:filename (str) – xsection map filename in csv format
Returns:table with loaded xsections
Return type:DataFrame
nazca.mask_layers.merge_xsection_layers_with_layers()

Create a dictionary containing tables of xsections joined with layers.

The xsection names are the dictionary keys. The dictionary contains all attributes for mask 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.save_colormap(filename=None)

Save a colormap to csv file.

Parameters:filename (str) – output filename
Returns:None
nazca.mask_layers.set_layercolor(name='unknown', layer=None, frame_color=None, fill_color=None, frame_brightness=None, fill_brightness=None, dither_pattern=None, valid=None, visible=None, transparent=None, width=None, marked=None, animation=None, alpha=None)

Set layer color information.

Generate a tabel (DataFrame) with layer color information. For missing attribute values for fill_color and frame_color, the default_colors as specified in colormap cfg.plt_cmap are be applied. Note that the default colormap can be adjusted by the user.

Parameters:
  • name (str) – layername
  • layer (int | tuple) – layer number or (layer, datatype)
  • tech (str) – technology (default = None)
  • .. – attributes
Returns:

None

nazca.mask_layers.set_plt_properties(figsize=14, cmap=None, N=32, alpha=0.3)

Set the default colormap to use in Matplotlib output for mask layout.

Parameters:
  • figsize (float) – size of the matplotlib figure (default = 14)
  • cmap (str) – name of the colormap, (default = None uses cfg.plt_cmap_name)
  • N (int) – the number of colors in the map in case of a ‘linearSegmentedColormap’ default = 32)
  • alpha (float) – transparency of the cmap to see through layers (default = 0.3).
Returns:

None

nazca.mask_layers.show_layercolors()

Print the layercolor table.

nazca.mask_layers.show_layers()

Print the layer table.

nazca.mask_layers.show_mask_layers()

Print mask_layers dictionary with layer export definitions to stdout.

Returns:None
nazca.mask_layers.show_xsection_layer_map()

Print the xsection_layer_map table to stdout.

Returns:None
nazca.mask_layers.show_xsections()

Print the xsections table.

Returns:None

nazca.netlist module

Nazca classes to construct Nodes, Pointers and Cells, and from those the graphs/netlists of the design.

class nazca.netlist.Annotation(layer=None, text='')

Bases: object

Annotation class.

__init__(layer=None, text='')

Construct an annotation object.

Parameters:
  • layer (int) – layer number to put the annotation in
  • text (str) – annotation text (defualt = ‘’)
Returns:

None

put(*args)

Put an Annotation object in the layout.

class nazca.netlist.Cell(name='cell', celltype='element', instantiate=True, autobbox=False, store_pins=None, hashme=False, cnt=False, params=False)

Bases: object

Cell object, corresponding to a GDS cell when exported to GDS.

A cell has default pins:
‘org’: cell origin (non-chain) ‘a0’ : input pin (chain) ‘b0’ : output pin (chain)

It is up to the user to place ‘a0’ and ‘b0’ at sensible positions in the cell. If not provided, they will be placed at the origin automatically.

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

A cell typically contains one or more of the following objects:
  1. pins: A position w.r.t. the cell origin that can be used to connect to.
    method: Pin().put()
  2. cell instances: A reference to another cell
    method: Cell().put()
  3. polygons: A polygon assigned to a specific GDS layer.
    method: Polygon().put()
  4. polylines: A polyline/path assigned to a specific GDS layer.
    method: Polyline().put()
  5. annotations:
    method: Annotation().put()
ID = 1
__init__(name='cell', celltype='element', instantiate=True, autobbox=False, store_pins=None, hashme=False, cnt=False, params=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)
  • autobbox (bool) – create a cell bounding box (default = False)
  • () (store_pins) –
  • hashme (bool) – set True if cell obtains information from hasme decorator
  • cnt (bool) – append ordinal counter to cellname (default = False)
  • params (bool) – add parameter annotation in the cell (default = False) Note that autobbox = True will already add parameter annotation.
Returns:

None

Example

Create a cell with cell name ‘mycell’ and variable name C. Put the cell in the mask layout and export the layout:

import nazca as nd

with nd.Cell('mycell') as C:
    nd.strt(length=40).put(0)
    nd.bend(angle=15).put()

C.put(0)

nd.export_plt()
add_property(item)

Add item to the cell properties dictionary.

item (dict): new property

Returns:None
close()

Close the cell.

Solve the geometry of the nodes in the Cell. Set the cp back to the position before opening the cell. If default input and/or output pins have not been set yet they will be set on ‘org’, pointing in opposite directions.

Returns:self
Return type:Cell
default_pins(pinin=None, pinout=None)

Set default input and output pin.

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

None

filter(layers)

Create a new cell after applying a layer filter.

Parameters:layers (list of layer) – layers to keep
Returns:new cell with subset of original layers
Return type:Cell

To be implemented

get_pin(pinname=None, connect=None)

“Parse pinname and connect for put_polygon and put_gds methods.

Returns:pin position, new if needed
Return type:Node
ic_pins()

Generator over interconnect pins, filter out org and bounding box.

Yields:str, Pin – iterator over pins in cell
parse_instance_connection(C1, C2, C3, C4, C5, instance=None)

Connect a (closed) cell as an Instance object into the active cell.

Parse up to five connection arguments to extract: pin1, pin2 and (x,y,a):

Parameters:
  • C1 (float | Node | Instance) – connection information
  • C2 (float | Node | Instance) – connection information
  • C3 (float | Node | Instance) – connection information
  • C4 (float | Node | Instance) – connection information
  • C5 (float | Node | Instance) – connection information
  • instance (Instance) – instance object to connect to
Returns:

instance pin, cell pin, connection

Return type:

Node, Node, (x, y, a)

Notes

The connection has the following syntax:

[pin_inst [, translation]]

or

[pin_inst, ] translation [, pin_cell]

  • translation = x | x,y | x, y, a | (x) | (x, y) | (x, y, z), where translation is w.r.t. <pin_cell>
  • pin_inst: pinname of instance (default = ‘a0’)
  • pin_cell: pinname of cell (default = ‘org’)

Options:

  • ()
  • (node)
  • (instance)
  • (0,)
  • (0, 0)
  • (0, 0, 0)
  • ((0))
  • ((0, 0))
  • ((0, 0, 0))
  • (0, pin)
  • (0, 0, pin_cell)
  • (0, 0, 0, pin_cell)
  • ((0), pin_cell)
  • ((0, 0), pin_cell)
  • ((0, 0, 0), pin_cell)
  • (pin_inst)
  • (pin_inst, 0)
  • (pin_inst, 0, 0)
  • (pin_inst, 0, 0, 0)
  • (pin_inst, (0))
  • (pin_inst, (0, 0))
  • (pin_inst, (0, 0, 0))
  • (pin_inst, pin_cell)
  • (pin_inst, 0, pin)
  • (pin_inst, 0, 0, pin_cell)
  • (pin_inst, 0, 0, 0, pin_cell)
  • (pin_inst, (0), pin_cell)
  • (pin_inst, (0, 0), pin_cell)
  • (pin_inst, (0, 0, 0), pin_cell)
parse_pin_connection(C1, C2, C3, C4)

Parse pin connection for polygon, polyline, annotation and gds methods.

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

Example

Options: * () * (node) * (0,) * (0, 0) * (0, 0 ,0) * ((0)) * ((0, 0)) * ((0, 0 ,0)) * (0, ‘b0’) * (0, 0, ‘b0’) * (0, 0 ,0, ‘b0’) * ((0), ‘b0’) * ((0, 0), ‘b0’) * ((0, 0 ,0), ‘b0’)

put(*args, flip=False, flop=False, array=None, scale=1.0, **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) For more details see method ‘parse_instance_connection’.
  • flip (bool) – mirror the instance in the vector line (default = False) flip is preformed after any translation and/or rotation. Hint: for connecting waveguides you only need flip (not flop).
  • flop (bool) – mirror the instance in the line perpendicular to the vector (default = False) flop is performed after any translation and/or rotation. A flop is the same as rot(180) + a flip Hint: for mask assembly or connecting bbox pins you may find both flip and flop useful.
  • cp (str) – Set current pin cp to a specific pin after putting (default = ‘b0’). Example: cp=’b1’
  • array (list) – creates an array instance upon GDS output if not None. Format the array as [col#, [dx1, dy1], row#, [dx2, dy2]] dx1, dy1 is the column vector measured between adjacent elements. dx2, dy2 is the row vector measured between adjacent elements. (default = None)
  • scale (float) – set scaling factor of the instance (default = 1.0). In gds the scaling will be set as instance attribute. In case of flattening the instance, the scaling factor will be applied to the instance content.
Returns:

reference to the instance of the cell being put

Return type:

Instance

Examples

Below are different syntax examples for put.

In the examples we use the following objects:
  • nd.example: a pre-defined cell in Nazca
  • ‘a0’: default input pin name of “example”
  • ‘b0’: default output pin name of “example”
  1. connect the default pin of cell “example” to current pin (cp):

    import nazca as nd
    nd.example_cell().put() # -> put('a0', cp)
    nd.export_plt()
    
  2. connect pin ‘b0’ of cell “example_cell()” to current pin (cp):

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

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

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

    import nazca as nd
    C = nd.example_cell().put(0)
    nd.example_cell().put('b0', C.pin['b0']) # -> put('b0', C.pin['b0'])
    nd.export_plt()
    
  6. connect pin ‘b0’ of cell “example_cell()” to instance C at its default out pin, i.e. refering to instance C only without pin attribute is interpreted as connecting to the default output pin of C.:

    import nazca as nd
    C = nd.example_cell().put(0)
    nd.example.put('b0', C) # -> put('b0', C.pin['b0'])
    nd.export_plt()
    
rebuild(instantiate=True, flat=False, layermap=None, layermapmode=None, cellmap=None)

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

The original cell(tree) remains unchanged. This method operates at mask-element level. It contructs the output cell(tree) as geometrical info from the ground up, i.e. any circuit-type netlist information will not be copied. Rebuild can be used, for example, to place each layer of a cell at a different position in the mask layout.

Parameters:
  • instantiate (bool) – instantiate setting of returned (top)cell. (default = True)
  • flat (bool) – flatten cell(tree) (default = False)
  • layermap (dict) – {oldlayer, newlayer} mapping
  • cellmap (dict) – to be implemented
  • layermapmode ('all' | 'none') – start mapping with all layers included in the map: ‘all’, or an empty map ‘none’. (default = ‘all’)
Returns:

rebuilt input cell

Return type:

Cell

class nazca.netlist.Instance(name=None)

Bases: object

Class to store pins of cell instantiations.

ID = 0
__init__(name=None)

Construct an Instance.

ic_pins()

Generator over interconnect pins, filter out org and bounding box.

Yields:str, Pin – iterator over pins in cell
length_geo
raise_pins(namesin=None, namesout=None, show=True)

Copy pins of a cell instance to its parent cell.

If a cell A is “put” in cell P, then an instance of cell A is created inside “parent” cell P. Each instance of cell A, say A1, A2, …, contains a copy of all pins of cell A to represent cell A in P at a particular location, rotation, flip state and/or scaling. raise_pins automatically copies all pin attributes.

The instance pins are themselves not pins of cell P. Pins have to be explicitly set in P with nd.Pin.put(). Alternatively, all or part of the pins in an instance can be set at once in P by “raise_pins”, avoiding many nd.Pin().put() statements. This can very useful when an instance has a large number of pins that have to be “raised”.

Note

raise_pins is a method of Class Instance, not of Cell. Hence, it operates on a cell that has been put.

Parameters:
  • namesin (list of str) – list of pin names to raise (Default = all pins of the instance)
  • namesout (list of str) – list of new names of the raised pins (Default = <namesin>)
  • show (bool) – show the pins in the layout with an arrow (default = True)
Returns:

None

Example

Raise (copy) all pins of an instance to its parent cell. In the example a 90 degree bend is connected to port ‘a0’ of the new_cell.

Create pins without the raise_pins method looks like this:

# create and put Pins explicitly one by one:
import nazca as nd

with nd.Cell('new_cell') as new_cell:
    instance1 = nd.example_cell().put(100, 200)
    nd.Pin('a0').put(instance1.pin['a0'])
    nd.Pin('b0').put(instance1.pin['b0'])

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

Now raise pins with raise_pins on <instance1> in the new_cell. This also copies all pin attributes:

# raise pins
import nazca as nd

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

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

Now raise and rename pins ‘a0’ and ‘b0’ of <instance1> with method raise_pins. Note that the cell default pins, ‘a0’ and ‘b0’, are automatically added to <new_cell>:

# raise and rename pins
import nazca as nd

with nd.Cell('new_cell') as new_cell:
    instance1 = nd.example_cell().put(0)
    instance1.raise_pins(['a0', 'b0'], ['new_a0', 'new_b0'])

instance2 = new_cell.put(0)
nd.bend(angle=90).put(instance2.pin['new_a0'])
nd.bend(angle=-90).put(instance2.pin['a0'])
nd.export_plt()
class nazca.netlist.Netlist

Bases: object

Class for building the netlist.

__init__()

Construct a Netlist object. Singleton.

annotation_iter(cnode, infolevel=0)

Generator to iterate over all annotations in a cell (cnode).

Yields:(Pointer, annotation) – Next Annotation and its position
annotation_iter2(cnode, trans, flip, scale, apply=True, infolevel=0)

Generator to iterate over all annotations in a cell (cnode).

Parameters:
  • cnode (Node) – cnode to iterate
  • trans (tuple) – translation state of instance
  • flip (bool) – flip state of instance
  • apply (bool) – default=True: Apply translation and flipping
  • infolevel (int) – amount of debug info to display in stdout

Includes translation and flipping.

Yields:(Annotation, (float, float), int) – Next Annotation and its position as (x, y), and a flip multiplyer -1 (flip) or 1
celltree_iter(icnode, level=0, position=None, flat=False, infolevel=0)

Generator to iterate over cell of <cnode>, top-down, go deep first.

The tree decents from the provided cnode into instantiated cnode(s). For decending into an instance, the inode: - look up the cell object the instance represents, - take that cell’s cnode and use it to seed the next level.

Parameters:
  • icnode (Node) – cnode of cell or inode of instance to iterate into
  • level (int) – depth in cell tree, (default = 0)
  • position (Pointer) – (default = None)
  • flat (bool) – flatten array instances if True (default = False)
  • infolevel (int) – amount of runtime info to stdout (default = 0)
Yields:

(Node, int, Pointer, bool)

(cnode, level, position, flip).

Yields next cell, its level in the hierarchy and position

celltree_iter2(cell, level=0, position=None, flat=False, cells_visited=None, infolevel=0, cellmap=None)

Generator to iterate top-down over the celltree in <cell>.

Translation, flipping and flattening are applied. Go deep first. If a instantiation is found of a cell that already has been iterated over (cells_visited), then this cell will not be scanned again.

Iteration over this Generator with infolevel = 1 will print the Nazca hierarchy, cell-levels to stdout.

Yields:named_tuple – Info to build cells in a netlist branch.
gdsfile_iter(cnode, level=0, infolevel=0)

Generator to iterate over all GDS files instantiated in a cell (cnode).

Yields:

(Pointer, gdsinfo)

Next gds file and info to generate it.

gdsinfo = (filename, cell, newcell, layermap, cellmap, scale)

gdsfile_iter2(cnode, trans, flip, scale, apply, infolevel=0)

Generator to iterate over all GDS files instantiated in a cell (cnode).

Parameters:
  • cnode (Node) – cnode to iterate
  • trans (tuple) – translation state of instance
  • flip (bool) – flip state of instance
  • apply (bool) – ignored: always True
  • infolevel (int) – amount of debug info to display in stdout
Yields:

(Polyline, (float, float, float), bool) – Next gdsfile and its position (x, y, a), ‘a’ in degrees, and the flip state

instance_iter(cnode)

Generator to iterate over all instances in cell (cnode) one level deep.

Yields:Node – cnode of instance
instance_iter2(cnode, trans, flip, scale, apply=True, infolevel=0)

Generator to iterate over all instances one level deep.

Includes translation and flipping.

Parameters:
  • cnode (Node) – cnode to iterate
  • trans (tuple) – translation state of instance
  • flip (bool) – flip state of instance
  • apply (bool) – default=True: Apply translation and flipping
  • infolevel (int) – amount of debug info to display in stdout
Yields:

cnode, (float, float, float)

cnode of instance (inode),

and position (x, y, a), ‘a’ in degrees

polygon_iter(cnode, infolevel=0)

Generator to iterate over all polygons in a cell (cnode).

Yields:(Pointer, Polygom) – Next Polygon object and its position
polygon_iter2(cnode, trans, flip, scale, apply=True, hull=False, infolevel=0)

Generator to iterate over all polygons in a cell (cnode).

Parameters:
  • cnode (Node) – cnode
  • trans (tuple) – translation state w.r.t. to (new) parent
  • flip (bool) – flip state w.r.t. to (new) parent
  • scale (float) – scale state w.r.t. to (new) parent
  • apply (bool) – apply translation and flipping (default = True)
  • infolevel (int) – debug info level to stdout
Yields:

(Polygon, list((float, float)), tuple(4*float)) | (Polygon, tuple(3*float), tuple(4*float)):

if apply is True:

Polygon object, and the polygon points and the bbox w.r.t.
the (possibly new) parent cell.

if apply is False:

Polygon object, its position (x, y, a), 'a' in radians,
the flip state of the polygon
polyline_iter(cnode, infolevel=0)

Generator to iterate over all polylines (paths) in a cell (cnode).

Yields:(Pointer, Polyline) – Next Polyline object and its position
polyline_iter2(cnode, trans, flip, scale, apply=True, hull=False, infolevel=0)

Generator to iterate over all polylines in a cell (cnode).

Parameters:
  • cnode (Node) – cnode
  • trans (tuple) – translation state w.r.t. to (new) parent
  • flip (bool) – flip state w.r.t. to (new) parent
  • scale (float) – scale state w.r.t. to (new) parent
  • apply (bool) – apply translation and flipping (default = True)
  • infolevel – debug info level to stdout
solvecell(cell)

Solve the cell with. cnode position will be at (x, y, a) = (0, 0, 0).

Parameters:cell (Cell) – cell to solve
Returns:None
solvecell_core(node, _cnode0=None)

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

Include all nodes in the cell (level 0) and all nodes in instantiated cells (level 1). Hence, a node in scope adheres to one of the following conditions:

  • the node resides in same cell as the starting node (parent <cnode0>).
  • the node resides in an instance of the cell of the starting node.

A starting <node> has to be provided from where to solve. A good starting point in each cell is the cnode with its pointer position set at (x, y, a) = (0, 0, 0).

Parameters:
  • node (Node) – node from where to start solving the cell
  • _cnode0 (Node) – Internal parameter containing the cnode of the cell to solve. It is automatically obtained from <node> in theh first pass.
Returns:

None

class nazca.netlist.Node(name=None)

Bases: object

Node class for creating node objects.

The netlist of Nodes and connections between the nodes (edges) construct the photonic circuit and/or layout.

ID = 1
__init__(name=None)

Contruct a Node.

Parameters:name (str) – optional Node name (default is an integer counter)
Returns:None
a

Get pointer a-position of the Node.

Returns:pointer a-position with respect to the cell origin
Return type:tuple
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 object.

Returns:copy of the node with the same attributes as the original
Return type:Node

Example:

import nazca as nd

n1 = nd.Node()
n2 = n1.copy()
ele_nb_iter()

Get electrical neighbours.

Yields:Node – next neighbor
flip()

Create a new Node that is flipped.

A ‘flip’ mirrors the Node in the line of the pointer. Note that a flip state of a Node doesn’t matter in Nazca. Flipping is handled by ‘put’, hence this funtion is equivalent to a Node copy in place (pointer not effected).

Returns:a new Node flipped w.r.t. self
Return type:Node
flop()

Create a new Node that is flopped.

A ‘flop’ mirrors the Node pointer ‘backward’. A flop is effecively a flip + 180 degree rotation. Note that the flip state of a Node or not doesn’t matter in Nazca, hence this flop is equivalent to rot(180).

Returns:a new Node flopped w.r.t. self
Return type:Node
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)

Create a new Node at position (<x>, <y>, <a>) relative to the cell origin.

Parameters:
  • x (float) – x position in um
  • y (float) – y position in um
  • a (float) – angle a in degrees
Returns:

a new Node at (<x>, <y>, <a>) w.r.t. the cell’s origin

Return type:

Node

instance_iter()

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

Yields:Node – next cell
move(x=0, y=0, a=0)

Create a new Node translated by (<x>, <y>, <a>) with respect to self.

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

Create a new Node that is offset by <y>.

Returns:a new Node translated by vector (0, <y>, 0) w.r.t. self
Return type:Node
opt_nb_iter()

Get optical neighbours.

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

Create a new Node that is offset by <y>.

Returns:a new Node translated by vector (0, <y>, 0) w.r.t. self
Return type:Node
print_neighbours()

Print neighbours of the node in the netlists.

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

Create a new Node rotate pointer by <a>.

Parameters:a (float) – angle of rotation in degrees
Returns:a new Node translated by vector (0, 0, <a>) w.r.t. self
Return type:Node
rotate(a=0)

Create a new Node rotate pointer by <a>.

Parameters:a (float) – angle of rotation in degrees
Returns:a new Node translated by vector (0, 0, <a>) w.r.t. self
Return type:Node
shift(x=0, y=0)

Create a new Node shifting pointer (<x>, <y>), keeping orientation.

Returns:a new Node translated by vector (<x>, <y,> 0) w.r.t. self
Return type:Node
skip(x=0)

Create a new Node skipping <x> in direction of the pointer.

Returns:a new Node translated by vector (<x>, 0, 0) w.r.t. self
Return type:Node
x

Get pointer x-position of the Node.

Returns:pointer x-position with respect to the cell origin
Return type:tuple
xya()

Get pointer position of the Node.

Returns:pointer position (x, y, a) with respect to the cell origin
Return type:tuple
y

Get pointer y-position of the Node.

Returns:pointer y-position with respect to the cell origin
Return type:tuple
class nazca.netlist.Pin(name=None, xs=None, width=None, type=None, pin=None, show=None, remark=None, chain=None)

Bases: object

Pin class

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

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)

Put a Pin object in the layout.

class nazca.netlist.Pointer(x=0.0, y=0.0, a=0.0)

Bases: object

A pointer with state information.

The pointer has the positional information of a node. The positional information is kept in a matrix that holds the homogeneous coordinates. Structures are drawn in local coordinates and are easily converted to the global coordinate system by a matrix multiplication. By using homogeneous coordinates, translations are also described by a matrix multiplication.

__init__(x=0.0, y=0.0, a=0.0)

Constructor.

Parameters:
  • x (float) – x coordinate in um
  • y (float) – y coordinate in um
  • a (float) – angle coordinate un degrees
a

Return angle a of the pointer.

chain180(chain)

Set the chain property of the pointer.

Parameters:chain (bool) – True for chain connecting pins.
Returns:None
copy(flip=False)

Copy pointer.

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

Flip (mirror) the state of the pointer.

Returns:self, flipped
Return type:Pointer
get_xy(x=0, y=0)

Return the (x, y) position of the pointer.

get_xy_a()

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

get_xya()

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

goto(x, y, a=0.0)

Move pointer to a coordinate relative to the org.

Parameters:
  • x (float) – x-coordinate of the pointer position [µm]
  • y (float) – y-coordinate of the pointer position [µm]
  • a (float) – angle of the pointer [degrees]
Returns:

None

inv()

Inverse the matrix in the pointer. Returns the pointer.

Returns:self
Return type:Pointer
move(x=0, y=0, a=0.0)

Move pointer relative to current location.

Parameters:
  • x (float) – x-coordinate of the pointer position [µm]
  • y (float) – y-coordinate of the pointer position [µm]
  • a (float) – angle of the pointer [degrees]
Returns:

self

Return type:

Pointer

move_ptr(ptr)

Move pointer relative by a pointer ‘ptr’ 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.

Note that in a cartesian coordinate system while pointing/looking along the positive x-axis, a positive offset is in the left direction, i.e. along the positive y-axis.

Parameters:s (float) – move pointer along perpendicular direction by <s>
Returns:self, moved pointer
Return type:Pointer
rotate(a)

Rotate pointer by angle a.

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

Set angle absolute. Keep x, y position

Parameters:a (float) – angle of the pointer [degrees]
Returns:self
Return type:Pointer
set_mat(t)

Fill pointer matrix based on vector <t> = (x, y, a).

Parameters:t (tuple) – (x, y, a)
Returns:None
skip(s)

Translate a pointer in the direction it is pointing in.

Parameters:s (float) – move pointer along its direction by <s>
Returns:self, moved
Return type:Pointer
trans(mat)

Translate pointer by matrix <mat>.

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

Return position x of the pointer.

xy(x=0, y=0)

Return the (x, y) position of the pointer.

xya()

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

y

Return the position y of the pointer.

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

Bases: object

Polygon class.

__init__(points=None, layer=None)

Construct a Polygon object.

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

None

grow(grow=5, accuracy=0.1, jointype='square', layer=None)

Grow the polygon.

Returns:new Polygon with growth applied.
Return type:Polygon
put(*args, flip=False, flop=False, scale=1.0)

Put a Polygon object in the layout.

Parameters:
  • flip (bool) – flip state of the polygon put
  • flop (bool) – flop state of the polygon put
  • scale (float) – scaling factor of the Polygon. This scaling looks as if the whole cell the polygon would have scaled. Note that it may be more appropiate to use the ‘transform’ method to scale a Polygon.

Returns:

transform(center=(0, 0, 0), scale=1.0, flipx=False, flipy=False, move=(0, 0, 0), layer=None)

Transform the points in the Polygon object.

See nazca.geometries.transform().

Returns:new Polygon with transformed points.
Return type:Polygon
class nazca.netlist.Polyline(points=None, layer=None, width=None, pathtype=0)

Bases: object

Polyline (path) class.

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

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

grow(grow=5, accuracy=0.1, jointype='square', width=None, layer=None)

Grow the polyline.

Returns:new Polyline with growth applied.
Return type:Polyline
put(*args, flip=False, flop=False, scale=1.0)

Put a Polyline object in the layout.

Parameters:
  • flip (bool) – flip state of the polygon put
  • flop (bool) – flop state of the polygon put
scale (float): scaling factor of the Polygon. This scaling looks
as if the whole cell the polygon would have scaled. Note that it may be more appropiate to use the ‘transform’ method to scale a Polygon.

Returns:

transform(center=(0, 0, 0), scale=1.0, flipx=False, flipy=False, move=(0, 0, 0), width=None, pathtype=None, layer=None)

Transform the points in the Polyline object.

See nazca.geometries.transform().

Returns:new Polyline with transformed points.
Return type:Polyline
nazca.netlist.bbinfo(item=None, data=None)

Attach metadata to the Active cell in dictionary bbinfo.’

Parameters:
  • item (hashable object) – dictionary key
  • data – The value of the metadata
nazca.netlist.cell_iter(topcell, cellmap=None, flat=False, infolevel=0)

Get a cell iterator fo rebuilding cells.

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=False, solve=True)

Generate a geometrical edge between two Nodes.

Connect pin1 and pin2 with transformation geometrical t. Pins are only allowed to connect if they the have the same parent cell, same cell or are part of an instance placed in the same parent cell.

Parameters:
  • pin1 (Node) – 1st pin
  • pin2 (Node) – 2nd pin
  • t (tuple) – edge value: transformation (x, y, a) to get from pin1 to pin2
  • chain_node (int) – 1 if a chain node, 0 if not (default = 0)
  • chain_connect – overrules chain connect rules if None. chain_connect = 0 -> chain pin, chain_connect = 1 -> no-chain pin,
  • = None) ((default) –
  • DRC (bool) – apply DRC on the edge (default = True)
Returns:

None

Exceptions:
Pin connection out of scope.
nazca.netlist.connect_opt(n1, n2, s)

Generate optical connection.

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

Calculate the geometrical difference between two nodes.

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

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

Return type:

(dx, dy, da)

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

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

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

Return the transformation matrix that connects two pointers.

nazca.netlist.inverse(mat)

Return inverse matrix of <mat>

nazca.netlist.load_gds(filename, cellname=None, newcellname=None, asdict=False, select='top', layermap=None, cellmap=None, scale=1.0, prefix='', instantiate=True, native=True, bbox=False, bboxbuf=0, connect=None, flat=False)

Load one or more GDS cells (and its instances) from <filename> into a Nazca cell.

By default, load_gds returns a single cell in the specified gds file in <filename>, as specified in cellname, or the topcell, if only one exists.

Alternatively, when using a gds file as a library it is more efficient and convenient to call, load the GDS file only once. In that case use asdict=True in load_gds, which returns a dictionary with the keys referencing each cell by cellname, while keeping a distinction between topcells and subcells:

{‘topcells’: {<cellname>: Cell}, ‘subcells’: {<cellname>: Cell}}

load_gds checks for cellname clashes, because a cell(tree) loaded into the layout can not contain any cell name that already exists in the layout. There are three ways to avoid name clashes in case they occur:

1. Set a <newcellname>: changes only the name of the top cell; Note <newcellname> is ignored if a <cellmap> is provided as cellmap is then supposed to contain the renaming.

2. Provide a <cellmap>: maps original cell names one-by-one to new cell names. Cells names omitted will not be renamed.

3. Provide a cell name <prefix>: applies to all cells in a branch, except those in <newcellname> or <cellmap>.

Note, if you need to create a building block from GDS with pins and stubs, and you have the pin and xsection info available already (for example in a file) then you may prefer to use method ‘load_gdsBB’ instead.

Parameters:
  • filename (str|bytes) – filename of gds to load or bytes object that contains the gds byte stream.
  • cellname (str) – cellname in filename to load
  • newcellname (str) – new name for <cellname>
  • asdict (bool) – return a dict of cells if True (default = False). If True, the cellname keyword will be ignored.
  • select (str) – set the structure of the dictionary returned by this function. Only used when asdict is True.
  • layermap (dict) – layer mapping {old_layernumber: new_layernumber}
  • cellmap (dict) – ceelname mapping {old_cellname: new_cellname}
  • scale (float) – scaling factor of the cell (default=1.0). Scaling in this function will be applied directly to the polygon structures, not as a modifier attribute like scaling/magnification on a gds instance. For the latter use the scale keyword in ‘put()’. Warning, use scaling with care and basically only on structures like logos and text. Avoid (do not) use on library building blocks and/or optical components as their functionality may be compromised by scaling.
  • prefix (str) – optional string to avoid name clashes (default = ‘’)
  • instantiate (bool) – instantiate the GDS (default = False)
  • native (bool) – create native Nazca cells from GDS (default = True). Native cells provide full access to all elements in the gds.
  • bbox (bool) – add bounding box if True (default = False)
  • bboxbuf (float) – add a buffer to the bounding box (default = 0)
  • connect ((float, float, float)) – Only for native=False, move GDS origin by (x, y, a) when putting it into the layout.
  • moveorg ((float, float, float)) – alternative name for connect
Returns:

Nazca Cell containing the loaded gds cell(tree).

If asdict is True return a dictionary

Return type:

Cell or dict

Example:

cell1 = load_gds(filename='path_to_file.gds', cellname='name')
cell1.put()

# using asdict = True:

cellAll = load_gds(filename='path_to_file.gds', asdict=True)
cellAll[<cellname>].put()
nazca.netlist.load_gds_raw(filename, cellname=None, newcellname=None, layermap=None, cellmap=None, scale=1.0, prefix='', instantiate=False, bbox=False, connect=None, **kwargs)

Load GDS and always force native=False.

load_gds_raw(…) is the same as load_gds(…, native=False). See load_gds() for a detailed method description.

Returns:Nazca Cell containing the loaded gds cell(tree)
Return type:Cell
nazca.netlist.midpoint(node1, node2)

Calculate the geometrical center between two nodes.

See also midpointer.

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

mid-point between pointers of <node1> and <node2>

Return type:

(x, y, a)

nazca.netlist.midpointer(node1, node2)

Calculate the geometrical center between two nodes.

See also midpoint.

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

pointer in mid-point between pointers of <node1> and <node2>

Return type:

Pointer

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.

Returns:None
nazca.netlist.show_cp(radius=10, width=1)

Draw a ring in the layout to indicate/visualize the cp position.

Parameters:
  • radius (float) – radius of the ring shaped pin inidcator in um
  • width (float) – width of the ring-shaped pin indicator in um
Returns:

None

nazca.netlist.show_pin(pin=None, radius=10, width=1)

Draw a ring in the layout to indicate/visualize the pin position.

Parameters:
  • pin (node | str) – pin reference
  • radius (float) – radius of the ring shaped pin inidcator in um
  • width (float) – width of the ring-shaped pin indicator in um

If no pin is provided (None), cp will be use to apply the “show”.

Returns:None
class nazca.netlist.smatrix(tete=(0, 0), tmtm=(0, 0), tetm=(0, 0), tmte=(0, 0))

Bases: object

S-matrix tbd.

__init__(tete=(0, 0), tmtm=(0, 0), tetm=(0, 0), tmte=(0, 0))
nazca.netlist.to_mat(chain=0, x=0, y=0, a=0, inverse=False)

Transform vector into matrix.

nazca.netlist.validate_basename(basename)

Check if basename is unique on substring level.

This is only relevant for pcell replacement where no mistake between different basenames is allowed.

Parameters:basename (str) – basename of a cell’s name
Returns:True if basename is valid
Return type:bool

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

nazca.pdk_template_dbr module

Module defining black box templates for PDK implementation.

nazca.pdk_template_dbr.Tp_DBR(length=250, width=15, pinwidth=None, xs=None, name='dbr', groupname='', pitch=0.237, duty_cycle=0.5, icon=None)

Template for DBR building block.

This DBR has an option to set the duty cycle as free parameter.

Parameters:
  • length (float) –
  • width (float) –
  • pitch (float) –
  • duty_cycle (float) –
  • name (str) –
  • xs (str) –
Returns:

dbr(length, pitch, duty_cycle)

Return type:

function returning a Cell

nazca.pdk_template_dbr.Tp_DBR2(length=250, width=15, name='dbr', groupname='', pinwidth=None, xs=None, pitch=0.237, metal=True, icon=None)

Extented template for DBR building block.

Parameters:
  • length (float) –
  • width (float) –
  • pinwidth (dict) –
  • pitch (float) –
  • name (float) –
  • cshifty (float) –
  • metal (int) –
  • pad (int) –
  • DCmetalPad (int) –
  • DCmetalLine (int) –
  • xs (dict) –
  • xs_bb (str) –
  • xs_metal (str) –
Returns:

function that generates a Cell object

nazca.pdk_template_eopm module

Module defining black box templates for PDK implementation.

nazca.pdk_template_eopm.Tp_EOPM_DC(length=100, width=50, name='BBname', groupname='', pinwidth=None, xs=None, contacts=3, pads=True, icon=None)

Template for a EOPM_DC.

The EOMP has 1 input, 1output, and 3 contact ports. Metal pads to contact ports are optional.

Args:

Returns:function that generates a Cell object
nazca.pdk_template_eopm.Tp_EOPM_RF(length=100, width=50, rfpitch=10, pinwidth=None, xs=None, name='BBname', groupname='', dx_metal=0, dy_metal=0, pads=False, padangle1=-70, padangle2=70, RFpadType=None, bend_gsg_function=None, bend_gsg_params=None, icon=None)

Template for a EOPM_RF.

Has optica linput, output, and 2 GSG ports. Option to add RF GSG pads to GSF ports is added.

Parameters:??
Returns:eopm(length, pad, padangle1, padangle2)
Return type:function returning a cell

nazca.pdk_template_gsg module

Module defining black box templates for PDK implementation.

nazca.pdk_template_gsg.Tp_RFbendGSG(radius=50, angle=30, width_sig=10, width_gnd=10, gap=10, wext_bg=8, pinwidth=None, name='bend_gsg', groupname='', xs=None, xs_bg=None, xs_bg_width=None)

Template for GSG RF bend.

Returns:function that generates a Cell object
nazca.pdk_template_gsg.Tp_RFlineGSG(length=100, width_sig=10, width_gnd=10, gap=10, wext_bg=None, pinwidth=None, name='line_gsg', groupname='', xs=None, xs_bb=None, xs_bg=None, xs_bg_width=None)

Template for RF line GSG.

Returns:function that generates a Cell object
nazca.pdk_template_gsg.Tp_RFpadGSG(width_sig=10, width_gnd1=10, width_gnd2=None, gap1=10, gap2=62.5, height_tap=40, length_pad=75, width_pad_sig=45, width_pad_gnd=45, pinwidth=None, name='pad_gsg', groupname='', xs=None, layer=None)

Template for GSG RF pad cell.

Returns:function that generates a Cell object

nazca.pdk_template_mmi module

Module defining black box templates for PDK implementation.

nazca.pdk_template_mmi.Tp_MIR1p(length=40.2, width=35, pinwidth=None, name='mir1p', groupname='', xs=None, icon=None, version=None, store_pins=False)

Template for MMI1x2 in different xsections.

Returns:function that generates a Cell object
nazca.pdk_template_mmi.Tp_MIR2p(length=70.6, width=39, pinwidth=None, offset=1.5, name='mir2p', groupname='', xs=None, icon=None, version=None, store_pins=False)

Template for MMI1x2 in different xsections.

Returns:function that generates a Cell object
nazca.pdk_template_mmi.Tp_MMI1x2(length, width, pinwidth=None, offset=0, name='mmi1x2', groupname='', xs=None, icon=None, version=None, store_pins=False)

Template for MMI1x2 in different xsections.

Returns:function that generates a Cell object
nazca.pdk_template_mmi.Tp_MMI2x2(length, width, pinwidth=None, offset=0, name='mmi2x2', groupname='', xs=None, icon=None, version=None, store_pins=False)

Template for MMI2x2.

Returns:function that generates a Cell object
nazca.pdk_template_mmi.Tp_Modefilter(length=98.15, width=36, pinwidth=None, name='modefilter', groupname='', xs=None, icon=None, version=None, store_pins=False)

Template for Modefilter in different xsections.

Returns:function that generates a Cell object

nazca.pdk_template_pad module

Module defining black box templates for PDK implementation.

nazca.pdk_template_pad.Tp_DCpad_circle(diameter=100, pinwidth=None, buf_length=10, buf_width=10, name='DCpad', groupname='', xs=None, dclayer=None)

Template for DC pad in different xsections.

Args:

Returns:function generating a Cell
Return type:function
nazca.pdk_template_pad.Tp_DCpad_lw(length=100, width=100, pinwidth=None, name='DCpad_lw', xs=None, groupname='', metal_stub_length=2.0, dclayer=None)

Template for DC pad in different xsections.

The current standard BB only provides square BBs. Length and width are the actual metal size.

This is now actually a white BB, as it does not need replacement by the foundry. The building block has 5 micron extra space, since the design manual specifies 10 um minimum spacing between metal tracks/pads

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

nazca.util.parameters_to_string(param)

Create a string from a parameter dictionary.

param (dict): (parameter_name, value)

Format:

“Parameters: <parameter> = <value> <parameter> = <value> …”

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

Convert a string to a parameter dictionary.

The returned parameter values are represented as type str.

Expected format of <string>:

“parameters: <parameter> = <value> <parameter> = <value> …”

Header ‘parameters:’ is case incensitive and spaces will be stripped.

Parameters:string (str) – parameters
Returns:{<parameter_name>: <parameter_value>}
Return type:OrderedDict
nazca.util.get_cell_annotation(cell, convert=False)

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

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

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

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

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

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

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

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

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

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

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

Yields:int, (int, int) | (float, float) – layer, XY
nazca.util.make_iter(x)

Return x as tuple, if x is not a string and not iterable.

nazca.util.md5(x, N=5)

Return first N characters of md5 hash of argument x. It hashes the (default) string representation of the object.

nazca.util.isnotebook()

Check if code is run in a Jupyter notebook.

Returns:True if call is made from a notebook
Return type:bool

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