Deltares / hydromt_delft3dfm

Delft3D FM plugin for HydroMT
https://deltares.github.io/hydromt_delft3dfm/
GNU General Public License v3.0
7 stars 1 forks source link

friction values are not assigned to branches when a model is read #168

Open shartgring opened 3 days ago

shartgring commented 3 days ago

Version checks

Reproducible Example

The workflow for setting point cross-sections, which is used for cross-sections but also bridges and culverts, relies on the branches containing the columns ["frictionid", "frictiontype", "frictionvalue"]. In workflows.crosssections.py:

        crosssections = crosssections.merge(
            branches[["frictionid", "frictiontype", "frictionvalue"]],
            left_on="branch_id",
            right_index=True,
        )

https://github.com/Deltares/hydromt_delft3dfm/blob/8862432e235ff5740c83dd322d76d22f6b22271b/hydromt_delft3dfm/workflows/crosssections.py#L594C1-L598C6

However, when a DFlowFM model is read using read_model, these attributes are not read, and only columns found in the branches.gui file are included. I looked at prepare_default_friction_and_crosssection() but I think it that we might be looking for something else

Current behaviour

When a model is read, no friction info is added to the branches. This info is used by other parts of the code

Desired behaviour

Either change workflows such that the friction info is not needed, or enhance model reading such that the friction of the branches can be inferred from a model. A possible (easy) solution is reading the branches geom, but this will then not work with DFlowFM models that are not built using hydromt_delft3dfm. Either way, I think there are multiple solutions and that therefore some extra thinking is required for finding the best solution

Additional context

No response

shartgring commented 3 days ago

See also the tests in #169 where this problem was found. Ideally, the tests of setup_bridges and setup_culverts should be able to run directly after reading the test model, without first calling the setup_channels method