MeshSpec
MeshSpec(
cell_size,
domain,
refinement_areas=(),
transition_rows=1,
water_areas=(),
water_removal='centre',
crs=None,
origin=None,
output=None,
)
Everything refined-quads generate needs; one-to-one with the TOML file.
Attributes
| cell_size |
float |
Base cell size. |
| domain |
LayerSource |
Layer with the domain polygons. |
| refinement_areas |
tuple of RefinementSource |
Layers with refinement areas. |
| transition_rows |
int or tuple of int |
Transition rows per level step from coarse to fine, or one value for all. |
| water_areas |
tuple of LayerSource |
Layers with water areas. |
| water_removal |
str |
Water removal rule: "centre", "inside" or "touches". |
| crs |
str or None |
CRS of layers that have none. |
| origin |
tuple of float or None |
A lattice point, [x, y] in the TOML; by default a multiple of the cell size. |
| output |
pathlib.Path or None |
UGRID file to write. |
Examples
A TOML file, with paths relative to the file::
cell_size = 25.0
transition_rows = [1, 1, 2]
water_removal = "centre"
output = "mesh_net.nc"
[domain]
path = "model.gpkg"
layer = "modelgebied"
[[refinement_areas]]
path = "model.gpkg"
layer = "verfijning"
level = "refinement" # column name, or one integer level
[[water_areas]]
path = "model.gpkg"
layer = "water"
Methods
| from_dict |
Build a spec from the contents of a TOML file. |
| from_toml |
Read a spec from a TOML file. |
| generate |
Read the layers and generate the mesh. |
| replace |
Return a copy with some values replaced, validated like the TOML values. |
from_dict
MeshSpec.from_dict(data, base='.')
Build a spec from the contents of a TOML file.
Parameters
| data |
mapping |
The parsed TOML. |
required |
| base |
str or path - like |
Directory that relative paths are relative to. |
'.' |
Returns
|
MeshSpec |
The validated spec. |
Raises
|
InputError |
If a key is unknown, missing or has an invalid value. |
from_toml
Read a spec from a TOML file.
Parameters
| path |
str or path - like |
The TOML file. Relative paths in it are relative to its directory. |
required |
Returns
|
MeshSpec |
The validated spec. |
Raises
|
InputError |
If the file cannot be read, is not valid TOML, or a key is unknown, missing or has an invalid value; the message names the key and the reason. |
generate
MeshSpec.generate(progress=None)
Read the layers and generate the mesh.
Parameters
| progress |
callable |
Progress callback, as for :func:generate. |
None |
Returns
|
Mesh |
The mesh, in the CRS of the domain. |
Raises
|
InputError |
If a layer is invalid (see :func:read_domain and :func:generate). |
|
OrthogonalityRepairError |
If the orthogonality repair does not close. |
replace
MeshSpec.replace(**changes)
Return a copy with some values replaced, validated like the TOML values.
Parameters
| **changes |
Any |
New values for cell_size, transition_rows, water_removal, crs, origin or output. |
{} |
Raises
|
InputError |
If a value is invalid. |