From 14cad9832a77c91d02f66df2458cd5a8c787471f Mon Sep 17 00:00:00 2001 From: Xiaohan Li Date: Wed, 15 Nov 2023 11:01:49 +0100 Subject: [PATCH] update documentation and changelog --- docs/changelog.rst | 2 ++ hydromt_delft3dfm/dflowfm.py | 30 ++++++++++-------------------- hydromt_delft3dfm/utils.py | 4 ++++ 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index f02554b..4f563a5 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -11,9 +11,11 @@ Unreleased Added ----- +- Support reading and writing of compound structures. (PR#113) Changed ------- +- Support multiple structures at the same location. (PR#113) Fixed ----- diff --git a/hydromt_delft3dfm/dflowfm.py b/hydromt_delft3dfm/dflowfm.py index e92b2f1..85bfcef 100644 --- a/hydromt_delft3dfm/dflowfm.py +++ b/hydromt_delft3dfm/dflowfm.py @@ -1494,19 +1494,18 @@ def setup_bridges( bridge_filter: Optional[str] = None, snap_offset: Optional[float] = None, ): - """Prepares bridges, including bridge locations and bridge crossections. + """Prepare bridges, including bridge locations and bridge crossections. The bridges are read from ``bridges_fn`` and if any missing, filled with information provided in ``bridges_defaults_fn``. When reading ``bridges_fn``, only locations within the region will be read. - Read locations are then filtered for value specified in ``bridge_filter`` on the column "structure_type" . + Read locations are then filtered for value specified in ``bridge_filter`` on the column "structure_type". Remaining locations are snapped to the existing network within a max distance defined in ``snap_offset`` and will be dropped if not snapped. A default rectangle bridge profile can be found in ``bridges_defaults_fn`` as an example. Structure attributes ['structure_id', 'structure_type'] are either taken from data or generated in the script. - Structure attributes ['shape', 'diameter', 'width', 't_width', 'height', 'closed', 'shift', 'length', 'pillarwidth', 'formfactor', 'friction_type', 'friction_value', 'allowedflowdir', 'inletlosscoeff', 'outletlosscoeff'] - are either taken from data, or in case of missing read from defaults. + Structure attributes ['shape', 'diameter', 'width', 't_width', 'height', 'closed', 'shift', 'length', 'pillarwidth', 'formfactor', 'friction_type', 'friction_value', 'allowedflowdir', 'inletlosscoeff', 'outletlosscoeff'] are either taken from data, or in case of missing read from defaults. Adds/Updates model layers: * **bridges** geom: 1D bridges vector @@ -1535,7 +1534,7 @@ def setup_bridges( See Also -------- dflowfm._setup_1dstructures - """ + """ # noqa: E501 snap_offset = self._network_snap_offset if snap_offset is None else snap_offset _st_type = "bridge" _allowed_columns = [ @@ -1607,7 +1606,7 @@ def setup_culverts( culvert_filter: Optional[str] = None, snap_offset: Optional[float] = None, ): - """Prepares culverts, including locations and crossections. Note that only subtype culvert is supported, i.e. inverted siphon is not supported. + """Prepare culverts, including locations and crossections. Note that only subtype culvert is supported, i.e. inverted siphon is not supported. The culverts are read from ``culverts_fn`` and if any missing, filled with information provided in ``culverts_defaults_fn``. @@ -1618,10 +1617,7 @@ def setup_culverts( A default ``culverts_defaults_fn`` that defines a circle culvert profile can be found in dflowfm.data.culverts as an example. Structure attributes ['structure_id', 'structure_type'] are either taken from data or generated in the script. - Structure attributes ['shape', 'diameter', 'width', 't_width', 'height', 'closed', 'leftlevel', 'rightlevel', 'length', - 'valveonoff', 'valveopeningheight', 'numlosscoeff', 'relopening', 'losscoeff', - 'friction_type', 'friction_value', 'allowedflowdir', 'inletlosscoeff', 'outletlosscoeff'] - are either taken from data, or in case of missing read from defaults. + Structure attributes ['shape', 'diameter', 'width', 't_width', 'height', 'closed', 'leftlevel', 'rightlevel', 'length','valveonoff', 'valveopeningheight', 'numlosscoeff', 'relopening', 'losscoeff', 'friction_type', 'friction_value', 'allowedflowdir', 'inletlosscoeff', 'outletlosscoeff'] are either taken from data, or in case of missing read from defaults. Adds/Updates model layers: * **culverts** geom: 1D culverts vector @@ -1632,32 +1628,26 @@ def setup_culverts( Path or data source name for culverts, see data/data_sources.yml. Note only the points that are within the region polygon will be used. - * Optional variables: ['structure_id', 'structure_type', 'shape', 'diameter', 'width', 't_width', 'height', 'closed', - 'leftlevel', 'rightlevel', 'length', 'valveonoff', 'valveopeningheight', - 'numlosscoeff', 'relopening', 'losscoeff', - 'friction_type', 'friction_value', 'allowedflowdir', 'inletlosscoeff', 'outletlosscoeff'] + * Optional variables: ['structure_id', 'structure_type', 'shape', 'diameter', 'width', 't_width', 'height', 'closed', 'leftlevel', 'rightlevel', 'length', 'valveonoff', 'valveopeningheight', 'numlosscoeff', 'relopening', 'losscoeff', 'friction_type', 'friction_value', 'allowedflowdir', 'inletlosscoeff', 'outletlosscoeff'] culverts_defaults_fn : str Path, optional Path to a csv file containing all defaults values per "structure_type". By default `hydrolib.hydromt_delft3dfm.data.culverts.culverts_defaults.csv` is used. This file describes a default circle culvert profile. - * Allowed variables: ['structure_type', 'shape', 'diameter', 'width', 't_width', 'height', 'closed', - 'leftlevel', 'rightlevel', 'length', 'valveonoff', 'valveopeningheight', - 'numlosscoeff', 'relopening', 'losscoeff', - 'friction_type', 'friction_value', 'allowedflowdir', 'inletlosscoeff', 'outletlosscoeff'] + * Allowed variables: ['structure_type', 'shape', 'diameter', 'width', 't_width', 'height', 'closed', 'leftlevel', 'rightlevel', 'length', 'valveonoff', 'valveopeningheight', 'numlosscoeff', 'relopening', 'losscoeff', 'friction_type', 'friction_value', 'allowedflowdir', 'inletlosscoeff', 'outletlosscoeff'] culvert_filter: str, optional Keyword in "structure_type" column of ``culverts_fn`` used to filter culvert features. If None all features are used (default). snap_offset: float, optional Snapping tolenrance to automatically snap culverts to network and add ['branchid', 'chainage'] attributes. - By default None. In this case, global variable "network_snap_offset" will be used.. + By default None. In this case, global variable "network_snap_offset" will be used. See Also -------- dflowfm._setup_1dstructures - """ + """ # noqa: E501 snap_offset = self._network_snap_offset if snap_offset is None else snap_offset _st_type = "culvert" _allowed_columns = [ diff --git a/hydromt_delft3dfm/utils.py b/hydromt_delft3dfm/utils.py index 0d3a9ce..c31bcb3 100644 --- a/hydromt_delft3dfm/utils.py +++ b/hydromt_delft3dfm/utils.py @@ -414,6 +414,8 @@ def read_structures(branches: gpd.GeoDataFrame, fm_model: FMModel) -> gpd.GeoDat Read structures into hydrolib-core structures objects Returns structures geodataframe. + Will drop compound structures. + Parameters ---------- branches: geopandas.GeoDataFrame @@ -454,6 +456,8 @@ def write_structures(gdf: gpd.GeoDataFrame, savedir: str) -> str: """ write structures into hydrolib-core structures objects. + Will add compound structures. + Parameters ---------- gdf: geopandas.GeoDataFrame