Metadata-Version: 2.5
Name: d3dplot
Version: 0.2.0
Summary: Postprocess and plot D-Flow FM and SMT simulation results.
Project-URL: Documentation, https://v-chavarrias.github.io/Delft3D_plot/
Project-URL: Repository, https://github.com/V-Chavarrias/Delft3D_plot
Project-URL: Issues, https://github.com/V-Chavarrias/Delft3D_plot/issues
License-Expression: GPL-3.0-or-later
License-File: LICENSE
Keywords: D-Flow FM,Delft3D,SMT,plotting,post-processing
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Visualization
Requires-Python: <3.14,>=3.11
Requires-Dist: dfm-tools>=0.47.0
Requires-Dist: geopandas>=1.1.0
Requires-Dist: matplotlib>=3.10.7
Requires-Dist: netcdf4>=1.7.5
Requires-Dist: numpy>=2.0
Requires-Dist: pandas>=2.2.2
Requires-Dist: psutil<8,>=6
Requires-Dist: pydantic<3,>=2.5
Requires-Dist: pyogrio>=0.12.0
Requires-Dist: pyyaml<7,>=6.0.2
Requires-Dist: rasterio>=1.4
Requires-Dist: rich>=13
Requires-Dist: scipy>=1.13.0
Requires-Dist: shapely>=2.1.1
Requires-Dist: typer>=0.12
Requires-Dist: xarray>=2024.7.0
Requires-Dist: xugrid>=0.15.3
Provides-Extra: dev
Requires-Dist: commitizen<5,>=4; extra == 'dev'
Requires-Dist: hypothesis>=6; extra == 'dev'
Requires-Dist: mypy<2,>=1.13; extra == 'dev'
Requires-Dist: pre-commit<5,>=4; extra == 'dev'
Requires-Dist: pytest-benchmark<6,>=5; extra == 'dev'
Requires-Dist: pytest-cov<8,>=7; extra == 'dev'
Requires-Dist: pytest-mpl<1,>=0.17; extra == 'dev'
Requires-Dist: pytest-xdist<4,>=3; extra == 'dev'
Requires-Dist: pytest<10,>=9; extra == 'dev'
Requires-Dist: ruff<1,>=0.11; extra == 'dev'
Requires-Dist: types-psutil<8,>=7; extra == 'dev'
Requires-Dist: types-pyyaml>=6.0.12; extra == 'dev'
Provides-Extra: docs
Requires-Dist: mkdocs-material<10,>=9.5; extra == 'docs'
Requires-Dist: mkdocstrings[python]<1,>=0.28; extra == 'docs'
Provides-Extra: movies
Requires-Dist: imageio-ffmpeg>=0.6; extra == 'movies'
Requires-Dist: imageio>=2.37; extra == 'movies'
Provides-Extra: tiles
Requires-Dist: contextily>=1.7.1; extra == 'tiles'
Requires-Dist: platformdirs>=4; extra == 'tiles'
Requires-Dist: rioxarray>=0.15; extra == 'tiles'
Description-Content-Type: text/markdown

# Delft3D_plot

Python tool to postprocess and plot Delft3D (D-Flow FM / SMT) results. Version 1 covers 2D maps (`map2d`) and river-km statistics (`river_km_statistics`).

> **Status:** v1 is implemented locally (map2d, river-km statistics, map1d, measurements, and the native `prepare`/`process`/`run` pipeline). d3dplot reads model input with its own readers and does not depend on HYDROLIB-core at run time. The [architecture plan](docs/architecture.md) holds the design and status; the [synthetic SMT test case generator](tools/synthetic_smt/README.md) is available for development.

## Goals

- Script-based workflow (Python script or YAML + CLI).
- **Process first, plot later**: raw results are processed once into a cache, and figures are made (and remade) from that cache.
- **Validate all input up front** before any heavy processing starts.
- Parallel processing and plotting (local process pool; SLURM job arrays on Linux clusters).
- Reads model input with its own readers (no run-time dependency on [HYDROLIB-core](https://github.com/Deltares/HYDROLIB-core)) and reuses [dfm_tools](https://github.com/Deltares/dfm_tools) and xugrid for model output instead of re-implementing them.
- Runs on Linux and Windows.

The functional reference is the Matlab tool `D3D_plot` in [OpenEarthTools](https://github.com/openearth/matlab-tools/blob/main/applications/vtools/D3D/plot/D3D_plot.m). This is not a one-to-one translation.

## How model output is assembled

Partitioned D-Flow FM output contains one map file per partition. Each file
contains local face and edge numbers, including ghost cells. Before values are
processed, d3dplot creates `cache/grid.nc` and `cache/merge_plan.nc`.

`grid.nc` contains the combined mesh geometry. `merge_plan.nc` contains the
lookup needed to place values from the partition files into that combined mesh:

```text
local value in a partition
        |
        |  owned_local
        v
global position in the combined grid
        |
        |  global_pos
        v
one value in the output array
```

The plan also stores the equivalent lookup for edges, including edge
orientation. It stores indexes and mappings only; it does not store bed levels,
other model variables, or times. Those remain in the model map files and in
`cache/times.nc`.

### Sub-runs and plans

An SMT simulation has several sub-runs, usually representing successive model
periods or restarts. The simulation has one mapping recipe between local
partition indices and its combined global grid. Every sub-run uses that same
simulation-wide recipe:

```text
SMT with one common grid:

sub-runs:        [0, 1, 2, 3]
merge plan:      one plan in merge_plan.nc
```

The grid and merge plan are built from sub-run 0. Time and `morft` metadata are
still read from every sub-run. Different simulations have separate output
roots and therefore separate `grid.nc` and `merge_plan.nc` files.

A non-SMT (plain FM) simulation is represented as one sub-run:

```text
sub-runs:        [0]
merge plan:      one plan in merge_plan.nc
```

If that plain-FM run is partitioned, the plan still contains one entry for
each map partition. If it has one unpartitioned map file, the mapping is
effectively an identity mapping: local face 0 goes to global face 0, local
face 1 goes to global face 1, and so on.

See the [output-store documentation](docs/output-store.md) and the
[architecture plan](docs/architecture.md#76-reading-model-output-merge-plan-d21-d23)
for the cache layout and implementation details.

## Documentation

- [User guide](docs/user-guide.md)
- [From Matlab `D3D_plot`](docs/from-matlab.md)
- [Gallery](docs/gallery.md)
- [Maintainer release guide](docs/releasing.md)
- [Reference](docs/reference.md)
- [Project documentation](docs/index.md)
- [Architecture proposal](docs/architecture.md)
- [Synthetic SMT test case generator](tools/synthetic_smt/README.md)
- [Contributing guide](CONTRIBUTING.md)

## Development workspace

[Delft3D_plot.code-workspace](Delft3D_plot.code-workspace) opens this repository together with sibling checkouts of the reference repositories:

```
checkouts/
├─ Delft3D_plot/     (this repository)
├─ oet_matlab/       https://github.com/openearth/matlab-tools
├─ HYDROLIB-core/    https://github.com/Deltares/HYDROLIB-core (reference only)
└─ dfm_tools/        https://github.com/Deltares/dfm_tools
```

## Licence

[GPL-3.0-or-later](LICENSE).
