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
operand1through 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_diffMaskSpec(...)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.
Methods
Section titled “Methods”| Method | Description |
|---|---|
copy | Create a copy of this mask specification. |
format | Create a string expression for this mask using names instead of layers. |
get_layers | Get the set of all layers referenced by this mask specification. |
parse | Parse a string expression into a mask specification. |
uses_translation | uses_translation(self) |
copy(self)Create a copy of this mask specification.
Returns
MaskSpec: New copy.
format
Section titled “format”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):
Technologywhose layers will be used to extract the layer names. Not used iflayer_namesis 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
Section titled “get_layers”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
Section titled “uses_translation”uses_translation(self, /)uses_translation(self)
Section titled “uses_translation(self)”Check whether this mask or sub-masks use any translation.
Returns
bool: Mask translation indication.
Attributes
Section titled “Attributes”| Attribute | Description |
|---|---|
dilation | float: Mask dilation. |
layer | tuple[int, int] | None: Mask layer (read only). |
operand1 | list[MaskSpec]: First operand for this mask. |
operand2 | list[MaskSpec]: Second operand for this mask. |
operation | Literal[”+”, ”*”, ”-”, ”^”]: Mask generation operation. |
properties | Properties: Object properties. |
translation | ndarray: Mask translation. |
dilation
Section titled “dilation”float: Mask dilation.
tuple[int, int] | None: Mask layer (read only).
operand1
Section titled “operand1”list[MaskSpec]: First operand for this mask.
operand2
Section titled “operand2”list[MaskSpec]: Second operand for this mask.
operation
Section titled “operation”Literal[”+”, ”*”, ”-”, ”^”]: Mask generation operation.
properties
Section titled “properties”Properties: Object properties.
translation
Section titled “translation”ndarray: Mask translation.