Skip to main content

RefineSpec

RefineSpec(
    refinement_areas,
    transition_rows=1,
    domain=None,
    water_areas=(),
    water_removal='centre',
    crs=None,
    output=None,
)

Everything refined-quads refine needs besides the mesh; one-to-one with the TOML.

Attributes

Name Type Description
refinement_areas tuple of RefinementSource Layers with the new refinement areas.
transition_rows int or tuple of int Transition rows per level step from coarse to fine, or one value for all.
domain LayerSource or None Optional domain: new cells outside it go, its holes are clipped like water.
water_areas tuple of LayerSource Layers with water areas; they clip new cells only.
water_removal str Water removal rule: "centre", "inside" or "touches".
crs str or None CRS of layers that have none.
output pathlib.Path or None UGRID file to write.

Examples

A TOML file, with paths relative to the file::

transition_rows = 1
output = "mesh_v2_net.nc"

[[refinement_areas]]
path = "extra.gpkg"
layer = "verfijning_nieuw"
level = 3

Methods

Name Description
from_dict Build a refine spec from the contents of a TOML file.
from_toml Read a refine spec from a TOML file (see :meth:MeshSpec.from_toml).
refine Read the layers and refine the mesh.
replace Return a copy with some values replaced, validated like the TOML values.

from_dict

RefineSpec.from_dict(data, base='.')

Build a refine spec from the contents of a TOML file.

Parameters

Name Type Description Default
data mapping The parsed TOML. required
base str or path - like Directory that relative paths are relative to. '.'

Returns

Name Type Description
RefineSpec The validated spec.

Raises

Name Type Description
InputError If a key is unknown, missing or has an invalid value.

from_toml

RefineSpec.from_toml(path)

Read a refine spec from a TOML file (see :meth:MeshSpec.from_toml).

Parameters

Name Type Description Default
path str or path - like The TOML file. Relative paths in it are relative to its directory. required

Returns

Name Type Description
RefineSpec The validated spec.

Raises

Name Type Description
InputError If the file cannot be read, is not valid TOML, or a key is unknown, missing or has an invalid value.

refine

RefineSpec.refine(mesh, progress=None)

Read the layers and refine the mesh.

Parameters

Name Type Description Default
mesh Mesh The existing mesh. required
progress callable Progress callback, as for :func:generate. None

Returns

Name Type Description
RefineResult The refined mesh and the replacement map.

Raises

Name Type Description
InputError If a layer is invalid, or the mesh cannot be recognised (MeshRecognitionError).
OrthogonalityRepairError If the orthogonality repair does not close.

replace

RefineSpec.replace(**changes)

Return a copy with some values replaced, validated like the TOML values.

Parameters

Name Type Description Default
**changes Any New values for transition_rows, water_removal, crs or output. {}

Returns

Name Type Description
RefineSpec The new spec.

Raises

Name Type Description
InputError If a value is invalid.