class kqcircuits.masks.mask_set.MaskSet(layout=None, name='MaskSet', version=1, with_grid=False, export_drc=False, mask_export_layers=None, debug=False)[source]

Bases: object

Class representing a set of masks for different chip faces.

A mask set consists of one or more MaskLayouts, each of which is for a certain face.

To create a mask, add mask layouts to the mask set using add_mask_layout() and add chips to these mask layouts using add_chips() or add_chip(). These functions also export some files for each chip. Then call build() to create the cell hierarchy of the entire mask, and finally export mask files by calling export().


mask = MaskSet(…) mask.add_mask_layout(…) mask.add_mask_layout(…) mask.add_chips(…) mask.build() mask.export(…)


pya.Layout of this mask set


Name of the mask set


Version of the mask set


Boolean determining if ground grid is generated


Boolean determining if DRC report is exported


Dictionary where keys are chip names, values are chip cells


list of MaskLayout objects in this mask set


list of names of the layers which are exported for each MaskLayout


similar to chips_map_legend, but only includes chips which are actually used in mask layouts

add_mask_layout(chips_map, face_id='1t1', mask_layout_type=<class 'kqcircuits.masks.mask_layout.MaskLayout'>, **kwargs)[source]

Creates a mask layout from chips_map and adds it to self.mask_layouts.

  • chips_map – List of lists (2D-array) of strings, each string is a chip name (or — for no chip)

  • face_id – face_id of the mask layout

  • mask_layout_type – type of the mask layout (MaskLayout or a child class of it)

  • kwargs – keyword arguments passed to the mask layout


the created mask layout


Load GDS or OASIS cell from file.

Load a cell (usually a chip) from the specified file.


file_name – name of the file (with path) to be loaded


the loaded cell

add_chips(chips, threads=None)[source]

Adds a list of chips with parameters to self.chips_map_legend and exports the files for each chip.

  • chips – List of tuples that add_chip uses. Parameters are optional. For example, (QualityFactor, "QDG", parameters).

  • threads – Number of parallel threads to use for generation. By default uses os.cpu_count() threads. Uses subprocesses and consequently a lot of memory.


It is advised to lower the thread number if your system has a lot of CPU cores but not a lot of memory. The same applies for exporting large and complex geometry.

add_chip(chip, variant_name, **kwargs)[source]

Adds a chip with the given name and parameters to self.chips_map_legend and exports chip files.

  • chip – the chip type class (for PCell chip), or a chip cell (for manually designed chip)

  • variant_name – name for specific variant, the same as in the mask layout

  • **kwargs – any parameters passed to the chip PCell

variant_definition(chip_class, variant_name, **kwargs)[source]

Returns chip variant definition with default mask specific parameters.

  • chip_class – the chip type class

  • variant_name – name for specific variant, the same as in the mask layout

  • **kwargs – any parameters passed to the chip PCell


dictionary compatible with mask map structure


Builds the mask set.

Creates cells for the mask based on self.mask_layouts and self.chips_map_legend. Optionally removes guiding shapes from the layout. Populates self.used_chips with the chips used in the mask layouts.


remove_guiding_shapes (Boolean) – determines if the guiding shapes are removed

export(path, view=None)[source]

Exports designs, bitmaps and documentation of this mask set.

Assumes that self.build() has been called before.

  • path – path where the folder for this mask set is created

  • view – KLayout view object

static chips_map_from_box_map(box_map, mask_map)[source]

Returns the chips_map created from box_map and mask_map.

Given NxN box map and MxM mask_map, creates chips_map of size MNxMN. So each element of mask map is “replaced” by a box in the box map. Assumes that box_map and mask_map are square.

  • box_map – dictionary where keys are strings identifying the box type, and values are 2D arrays (lists of lists) where each element is a string identifying the chip type

  • mask_map – 2D array (list of lists), where each element is a string identifying the box type