layout.models — typed layout objects
tempura/layout/models.py defines the two typed objects that carry data between
layout stages: LayoutData (the read result) and PreparedLayout (the build
handoff). Using typed objects instead of loose dictionaries keeps the field
names and derived geometry in one place.
LayoutData — the read result
LayoutData holds the normalized polygons from one file plus its unit metadata
(unit_scale_m, unit_source, units_known, source_format). It is what a
reader returns and what prepare_layout(...) consumes.
PreparedLayout — the build handoff
PreparedLayout holds the rasterized masks in gate_stencils, the internal
roi_size, and the physical grid_constant_m, and exposes the derived geometry
as read-only properties:
grid_stepis the internal XY spacing, fixed at \(1.0\): after rasterization one cell is one unit.grid_shapeis \((n_y, n_x)\) derived fromroi_size.roi_size_mconverts the internal ROI size back to meters through the grid constant, \(\ell_\text{m} = \ell_\text{cells} \cdot \texttt{grid\_constant\_m}\).gate_vertices_by_layerrecovers polygon vertices from the cropped inspection polygons for plotting.
This is the object build_device takes as input. For a
small synthetic handoff in a test or illustration you can construct a
PreparedLayout directly rather than running a file through prepare_layout.
API
models
Public layout workflow data objects.
LayoutData
dataclass
Normalized polygons and unit metadata loaded from one layout file.
Attributes:
| Name | Type | Description |
|---|---|---|
polygons_by_layer |
PolygonMap
|
Polygons grouped by normalized layer name. |
unit_scale_m |
float | None
|
Physical meters represented by one layout unit, when the source file provides unit metadata. |
unit_source |
str | None
|
Name of the file metadata field used for |
precision_m |
float | None
|
Layout database precision in meters, when available. |
units_known |
bool
|
Whether the source file provided enough metadata to derive physical sizes directly. |
source_format |
str
|
Lowercase layout format label, such as |
Source code in tempura/layout/models.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | |
PreparedLayout
dataclass
Prepared raster masks and geometry ready for device construction.
Attributes:
| Name | Type | Description |
|---|---|---|
gate_stencils |
MasksByLayer
|
Boolean masks grouped by source layer. Each mask uses
row-major |
roi_size |
tuple[float, float]
|
Rescaled ROI size as |
grid_constant_m |
float
|
Physical meters represented by one internal grid unit. |
cropped_polygons_by_layer |
PolygonMap | None
|
Optional cropped polygons kept for plotting and inspection after preparation. |
Source code in tempura/layout/models.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
gate_vertices_by_layer
property
Return polygon vertices derived from the cropped inspection polygons.
Returns:
| Type | Description |
|---|---|
VerticesByLayer
|
Plain nested vertex lists grouped by source layer. Returns an empty |
VerticesByLayer
|
mapping when no cropped polygons were retained. |
grid_shape
property
Return the (ny, nx) mask shape derived from roi_size.
Returns:
| Type | Description |
|---|---|
tuple[int, int]
|
Row-major mask shape matching every stencil in |
grid_step
property
Return the internal XY lattice spacing used for prepared masks.
Returns:
| Type | Description |
|---|---|
float
|
The fixed internal layout-grid spacing. Prepared masks always use |
float
|
unit spacing because |
roi_size_m
property
Return the physical ROI size in meters.
Returns:
| Type | Description |
|---|---|
float
|
Physical |
float
|
|