Skip to main content

refined-quads

Generate and refine refined quad meshes for D-Flow FM: axis-aligned squares on a fixed lattice, locally refined by repeated halving, with transition cells only where refinement levels meet.

from shapely import Point, box

from refined_quads import check, generate, write_ugrid

quad_mesh = generate(
    box(155_000, 463_000, 155_640, 463_480),
    cell_size=32.0,
    refinement_areas=[(Point(155_250, 463_240).buffer(70), 3)],
    transition_rows=[1, 1, 1],
    crs="EPSG:28992",
)
print(check(quad_mesh).summary())
write_ugrid(quad_mesh, "mesh_net.nc")

Warning: do not call the result mesh in a D-HyDAMO script. Those scripts usually import from hydrolib.dhydamo.geometry import mesh (the module with mesh2d_clip, links1d2d_add_links_1d_to_2d and so on); mesh = generate(...) replaces that module, and the next mesh.<function>(...) fails with an AttributeError. That is why the examples use quad_mesh.

The package also refines an existing mesh (also one made by another program), checks a mesh for what D-Flow FM needs, reads its input from GIS layers and runs from a TOML file on the command line. See the documentation.

Status: pre-alpha. The API is not stable yet.

Install

pip install refined-quads

or, in a uv project, uv add refined-quads. All dependencies come as wheels; no separate GDAL installation is needed. The package is tested on Windows and Linux; on macOS the MeshKernel wheel needs OpenMP from Homebrew (brew install libomp).

Development

The project uses uv, which also installs Python.

Install uv on Windows
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
Install uv on Linux or macOS
curl -LsSf https://astral.sh/uv/install.sh | sh
uv sync --locked              # create .venv with all dependency groups
uv run pre-commit install     # run the checks below on every commit
uv run pytest                 # fast test suite
uv run pytest -m benchmark    # also: slow, realdata
uv run pre-commit run --all-files   # file hygiene, yamllint, ruff check and format
uv run mypy                   # strict type check of src/

The source in src/refined_quads/ is grouped by task: _generate/, _refine/, _check/, _io/ (GIS layers and UGRID files) and _common/ (shared building blocks). The public API is only what the top-level package exports. The tests in tests/ use the same folders; tests/golden/ holds the golden masters that guard the output.

Documentation

The site is built with Quarto, which is installed separately (on Windows: winget install Posit.Quarto):

cd docs
uv run quartodoc build           # API reference from the docstrings
uv run quarto preview            # live preview; `quarto render` builds docs/_site/

Quarto must be on your PATH. On Windows, make sure C:\Program Files\Quarto\bin is included in the Path environment variable. After updating it, open a new terminal or reload PATH in your current PowerShell session, then start the preview from docs/:

$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
uv run quarto preview

Releases

The version comes from Git tags (v0.1.0 → 0.1.0). Publishing a GitHub release uploads the package to PyPI.

Domain terms are defined in CONTEXT.md; architectural decisions are in docs/adr/.

Licence

refined-quads is developed by HKV lijn in water and Svasek Hydraulics and published under the GNU General Public License v3 or later.

Metadata

Release files for refined-quads 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for refined-quads 0.3.0
File Size Uploaded Provenance Actions
refined_quads-0.3.0.tar.gz 594.3 kB With provenance Details for refined_quads-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for refined-quads 0.3.0
File Interpreter ABI Platform Actions
refined_quads-0.3.0-py3-none-any.whl Python 3 none any Details for refined_quads-0.3.0-py3-none-any.whl

Total release size: 685.6 kB

Release files / refined_quads-0.3.0.tar.gz

Download URL refined_quads-0.3.0.tar.gz
Size 594.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f970fc6df9df08d6b25c2caf5a250b856ba90bab1c7ea2380c16e193a8ad3e2b
BLAKE2b-256 checksum
How to use checksums
82d9a54460ca203f960a5949b555a6de43e1cf4dab59bb6edb59f831ea2475eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Release files / refined_quads-0.3.0-py3-none-any.whl

Download URL refined_quads-0.3.0-py3-none-any.whl
Size 91.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bf81d67086a9fc7ea00b91537960b7992d1662bb8b6e31744350a31fe975485e
BLAKE2b-256 checksum
How to use checksums
704616831584416438b7add04eec492edc6019635322b7dc8b51dbcdb9c2a401
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Security for refined-quads 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for refined_quads-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page