MaskSpec¶
- class photonforge.MaskSpec(operand1=None, operand2=None, operation='+', dilation=0)¶
Mask specification.
This class is mainly used when creating an
ExtrusionSpec
for aTechnology
.- Parameters:
operand1 – Layer tuple, mask specification, or iterable of those. If an iterable is used, the effective operand is the union of all the items.
operand2 – Layer tuple, mask specification, or iterable of those. If an iterable is used, the effective operand is the union of all the items.
operation – One of
"+"
(union),"*"
(intersection),"-"
(difference), or"^"
(symmetric difference).dilation – Dilation (erosion, if negative) applied to the mask.
Examples
Masks specifications can be combined using arithmetic operations:
>>> layer_1_0 = MaskSpec((1, 0)) >>> layer_2_0 = MaskSpec((2, 0), dilation=0.1) >>> difference = layer_1_0 - layer_2_0 >>> eroded_diff = difference ** -0.1 >>> eroded_diff MaskSpec(operand0=[MaskSpec((1, 0))], operand1=[MaskSpec((2, 0), dilation=0.1)], operation='-', dilation=-0.1)
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
([deep])Create a copy of this mask specification.
format
([layer_names, technology])Create a string expression for this mask using names instead of layers.
from_json
(json_str)Create a mask specification object from a json string.
parse
(expression[, technology])Parse a string expression into a mask specification.
Attributes
Mask dilation.
Json representation of this Mask specification.
First operand for this mask.
Second operand for this mask.
Mask generation operation.
- copy(deep=False)¶
Create a copy of this mask specification.
- Returns:
New copy.
- dilation¶
Mask dilation.
- format(layer_names=None, technology=None)¶
Create a string expression for this mask using names instead of layers.
- Parameters:
layer_names – 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
whose layers will be used to extract the layer names. Not used iflayer_names
is defined. If not specified, the current default technology is used.
- Returns:
Mask specification string.
Example
>>> mask = MaskSpec.parse("(0, 0) * (1, 0)") >>> mask.format({(0, 0): "A", (1, 0): "B"}) "('A' * 'B')"
- static from_json(json_str)¶
Create a mask specification object from a json string.
- Parameters:
json_str – Strig containing the json data.
- Returns:
MaskSpec instance.
- json¶
Json representation of this Mask specification.
- operand1¶
First operand for this mask.
- operand2¶
Second operand for this mask.
- operation¶
Mask generation operation.
- static parse(expression, technology=None)¶
Parse a string expression into a mask specification.
- Parameters:
expression – String expression to parse.
technology – Technology to be used for layer names in the expression.
- Returns:
MaskSpec
object.
Example
Invert layer (0, 0) and intersect the result with layer (10, 0):
>>> MaskSpec.parse("-(0, 0) * (10, 0)") MaskSpec(operand0=[MaskSpec(operand0=[MaskSpec(operand0=[], operand1=[], operation='+')], operand1=[MaskSpec((0, 0))], operation='-')], operand1=[MaskSpec((10, 0))], operation='*')
Difference between layers ‘SLAB’ and ‘WG_CORE’ intersected with (9, 10):
>>> MaskSpec.parse("('SLAB' - 'WG_CORE') * (9, 10)") MaskSpec(operand0=[MaskSpec(operand0=[MaskSpec((3, 0))], operand1=[MaskSpec((2, 0))], operation='-')], operand1=[MaskSpec((9, 10))], operation='*')
Union of ‘WG_CORE’ and ‘WG_CLAD’ eroded by 100 nm:
>>> MaskSpec.parse("('WG_CORE' + 'WG_CLAD') ** -0.1") MaskSpec(operand0=[MaskSpec((2, 0)), MaskSpec((1, 0))], operand1=[], operation='+', dilation=-0.1)