Skip to content

MaskSpec

MaskSpec(
operand1=None,
operand2=None,
operation='+',
dilation=0,
translation=(0, 0),
)

Mask specification.

This class is mainly used when creating an ExtrusionSpec for a Technology.

Args

  • operand1 (str | tuple[int, int] | MaskSpec | Iterable[str | tuple[int, int] | MaskSpec]): Layers or sub-masks that compose this maks specification that are joined to create this specification.
  • operand2 (str | tuple[int, int] | MaskSpec | Iterable[str | tuple[int, int] | MaskSpec]): Layers or sub-masks that can be combined with operand1 through a boolean operation.
  • operation (Literal[”+”, "", ”-”, ”^”]): One of ”+” (union), "" (intersection), ”-” (difference), or ”^” (symmetric difference).
  • dilation (float): Dilation (erosion, if negative) applied to the mask.
  • translation (Sequence[float] | complex): Translation applied to the mask.

Examples

Masks specifications can be combined using arithmetic operations:

>>> layer_1_0 = pf.MaskSpec((1, 0))
>>> layer_2_0 = pf.MaskSpec((2, 0), dilation=0.1)
>>> difference = layer_1_0 - layer_2_0
>>> eroded_diff = difference ** -0.1
>>> eroded_diff
MaskSpec(...)

Note

An empty list of operands indicates the full component bounds. The inversion of a layer is indicated by subtracting it from the component bounds.

MethodDescription
copyCreate a copy of this mask specification.
formatCreate a string expression for this mask using names instead of layers.
get_layersGet the set of all layers referenced by this mask specification.
parseParse a string expression into a mask specification.
uses_translationuses_translation(self)

copy(self)

Create a copy of this mask specification.

Returns

MaskSpec: New copy.

format(self, layer_names=None, technology=None)

Create a string expression for this mask using names instead of layers.

Args

  • layer_names (dict[tuple[int, int], str] | None): Dictionary mapping layer tuples to names, that will replace the layer tuples in the resulting expression. If not set, the technology layer names are used instead.
  • technology (Technology | None): Technology whose layers will be used to extract the layer names. Not used if layer_names is defined. If not specified, the current default technology is used.

Returns

str: Mask specification string.

Example

>>> mask = pf.MaskSpec.parse("(0, 0) * (1, 0)")
>>> mask.format({(0, 0): "A", (1, 0): "B"})
"'A' * 'B'"

get_layers(self)

Get the set of all layers referenced by this mask specification.

Returns

set[tuple[int, int]]: Layer set.

parse(expression, technology=None)

Parse a string expression into a mask specification.

Args

  • expression (str): String expression to parse.
  • technology (Technology | None): Technology to be used for layer names in the expression.

Returns

MaskSpec: Resulting mask specification.

Example

Invert layer (0, 0) and intersect the result with layer (10, 0):

>>> pf.MaskSpec.parse("-(0, 0) * (10, 0)")

Difference between layers ‘SLAB’ and ‘WG_CORE’ intersected with (9, 10):

>>> pf.MaskSpec.parse("('SLAB' - 'WG_CORE') * (9, 10)")

Union of ‘WG_CORE’ and ‘WG_CLAD’ eroded by 100 nm:

>>> pf.MaskSpec.parse("('WG_CORE' + 'WG_CLAD') ** -0.1")

uses_translation(self, /)

Check whether this mask or sub-masks use any translation.

Returns

bool: Mask translation indication.

AttributeDescription
dilationfloat: Mask dilation.
layertuple[int, int] | None: Mask layer (read only).
operand1list[MaskSpec]: First operand for this mask.
operand2list[MaskSpec]: Second operand for this mask.
operationLiteral[”+”, ”*”, ”-”, ”^”]: Mask generation operation.
propertiesProperties: Object properties.
translationndarray: Mask translation.

float: Mask dilation.

tuple[int, int] | None: Mask layer (read only).

list[MaskSpec]: First operand for this mask.

list[MaskSpec]: Second operand for this mask.

Literal[”+”, ”*”, ”-”, ”^”]: Mask generation operation.

Properties: Object properties.

ndarray: Mask translation.