MaskSpec¶
- class photonforge.MaskSpec(operand1=None, operand2=None, operation='+', dilation=0, translation=(0, 0))¶
Mask specification.
This class is mainly used when creating an
ExtrusionSpecfor aTechnology.- Parameters:
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 – Dilation (erosion, if negative) applied to the mask.
translation – 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.
Methods
copy()Create a copy of this mask specification.
format([layer_names, technology])Create a string expression for this mask using names instead of layers.
parse(expression[, technology])Parse a string expression into a mask specification.
uses_translation(self)
Attributes
Mask dilation.
Mask layer (read only).
First operand for this mask.
Second operand for this mask.
Mask generation operation.
Object properties.
Mask translation.
- dilation¶
Mask dilation.
- Type:
float
- format(layer_names=None, technology=None)¶
Create a string expression for this mask using names instead of layers.
- Parameters:
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:
Mask specification string.
- Return type:
str
Example
>>> mask = pf.MaskSpec.parse("(0, 0) * (1, 0)") >>> mask.format({(0, 0): "A", (1, 0): "B"}) "'A' * 'B'"
- layer¶
Mask layer (read only).
- Type:
tuple[int, int] | None
- operation¶
Mask generation operation.
- Type:
Literal[“+”, “*”, “-”, “^”]
- static parse(expression, technology=None)¶
Parse a string expression into a mask specification.
- Parameters:
expression (str) – String expression to parse.
technology (Technology | None) – Technology to be used for layer names in the expression.
- Returns:
Resulting mask specification.
- Return type:
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")
- properties¶
Object properties.
- Type:
- translation¶
Mask translation.
- Type:
ndarray
- uses_translation()¶
uses_translation(self) –
Check whether this mask or sub-masks use any translation.
- Returns:
Mask translation indication.
- Return type:
bool