API reference#

DFlowFM model class#

Initialize#

DFlowFMModel(root[, mode, mdu_filename, ...])

API for Delft3D FM models in HydroMT.

Setup components#

DFlowFMModel.setup_config(**data)

Set the config dictionary at key(s) with values.

DFlowFMModel.setup_channels(region, channels_fn)

Prepare the 1D channels and adds to branches 1D network.

DFlowFMModel.setup_rivers_from_dem(region, ...)

Set the all river parameters from hydrograph and dem maps.

DFlowFMModel.setup_rivers(region, rivers_fn)

Prepare the 1D rivers and adds to 1D branches.

DFlowFMModel.setup_pipes(region, pipes_fn[, ...])

Prepare the 1D pipes and adds to 1D branches.

DFlowFMModel.setup_manholes([manholes_fn, ...])

Prepare the 1D manholes to pipes or tunnels.

DFlowFMModel.setup_1dboundary([...])

Prepare the 1D boundary_type boundaries using timeseries or a constant.

DFlowFMModel.setup_1dlateral_from_points([...])

Prepare the 1D lateral discharge from geodataset of point geometries.

DFlowFMModel.setup_1dlateral_from_polygons([...])

Prepare the 1D lateral discharge from geodataset of polygons.

DFlowFMModel.setup_bridges([bridges_fn, ...])

Prepare bridges, including bridge locations and bridge crossections.

DFlowFMModel.setup_culverts([culverts_fn, ...])

Prepare culverts, including locations and crossections.

DFlowFMModel.setup_mesh2d(region[, res])

Create a 2D unstructured mesh according UGRID conventions.

DFlowFMModel.setup_mesh2d_refine([...])

Refine the 2d mesh.

DFlowFMModel.setup_link1d2d([...])

Generate 1d2d links that link mesh1d and mesh2d according UGRID conventions.

DFlowFMModel.setup_maps_from_rasterdataset(**data)

add_raster_data_from_rasterdataset().

DFlowFMModel.setup_maps_from_raster_reclass(**data)

add_raster_data_from_raster_reclass().

DFlowFMModel.setup_2dboundary([...])

Prepare the 2D boundaries from line geometries.

DFlowFMModel.setup_rainfall_from_constant(...)

Prepare constant 2D daily rainfall_rate timeseries based on constant_value.

DFlowFMModel.setup_rainfall_from_uniform_timeseries(...)

Prepare spatially uniform 2D rainfall forcings from meteo_timeseries_fn.

Attributes#

DFlowFMModel.region

Return the model's region component.

DFlowFMModel.crs

Return model crs.

DFlowFMModel.bounds

Return model mesh bounds.

DFlowFMModel.root

Model root

DFlowFMModel.mdu

Return the mdu component.

DFlowFMModel.inifield

Return the inifield component.

DFlowFMModel.geoms

Return the geoms component.

DFlowFMModel.forcing

Return the forcing component.

DFlowFMModel.mesh

Return the mesh component.

DFlowFMModel.dfmmodel

Hydrolib-core FMModel object.

DFlowFMModel.dimr

Return the dimr component.

DFlowFMModel.branches

Return the branches (gpd.GeoDataFrame object) representing the 1D network.

DFlowFMModel.rivers

Extract rivers from branches.

DFlowFMModel.channels

Extract channels from branches.

DFlowFMModel.pipes

Extract pipes from branches.

DFlowFMModel.opensystem

Open system branches (river, channel).

DFlowFMModel.closedsystem

Closed system branches (pipe, tunnel).

High level methods#

DFlowFMModel.read()

Read the complete model schematization and configuration from file.

DFlowFMModel.write()

Write the complete model schematization and configuration to file.

DFlowFMModel.build(*[, write])

Single method to build a model from scratch based on settings in steps.

DFlowFMModel.update(*[, model_out, write, ...])

Single method to update a model based the settings in steps.

DFlowFMModel.write_data_catalog([root, ...])

Write the data catalog to data_lib_path.

General methods#

DFlowFMModel.set_branches(branches)

Update the branches object as well as the linked geoms.

DFlowFMModel.init_dfmmodel()

Initialise the hydrolib-core FMModel object.

DFlowFMModel.get_model_time()

Return (refdate, tstart, tstop) tuple.

DFlowFMModel workflows#

Boundaries#

workflows.get_boundaries_with_nodeid(...)

Get boundary locations from branches and associate with node IDs.

workflows.select_boundary_type(boundaries, ...)

Select boundary location per branch type and boundary type.

workflows.validate_boundaries(boundaries[, ...])

Validate boundaries per branch type.

workflows.compute_boundary_values(boundaries)

Compute 1d boundary values.

workflows.compute_2dboundary_values([...])

Compute 2d boundary timeseries.

workflows.compute_meteo_forcings([df_meteo, ...])

Compute meteo forcings.

workflows.compute_forcing_values_points(gdf)

Compute 1d forcing values.

workflows.compute_forcing_values_polygon(gdf)

Compute 1d forcing values.

workflows.get_geometry_coords_for_polygons(gdf)

Get xarray DataArray coordinates that describes polygon geometries.

Branches#

workflows.prepare_branches(gdf_br, params, ...)

Set all common steps to add branches type of objects.

workflows.process_branches(branches[, ...])

Process the branches.

workflows.validate_branches(branches)

Validate the branches.

workflows.add_branches(mesh1d, branches, ...)

Add branches to exisitng open system branches at mesh1d node locations.

workflows.find_nearest_branch(branches, ...)

Determine the nearest branch for each geometry.

workflows.update_data_columns_attributes(...)

Add or update columns in the branches geodataframe.

workflows.update_data_columns_attribute_from_query(...)

Update an attribute column of branches.

workflows.snap_newbranches_to_branches_at_snappednodes(...)

Snap new_branches to branches at snappednodes.

workflows.snap_geom_to_branches_and_drop_nonsnapped(...)

Snap geoms to branches and drop the ones that are not snapped.

Crosssections#

workflows.prepare_default_friction_and_crosssection(...)

Prepare the default uniform friction and crosssection for branches.

workflows.init_crosssections_options(...)

Initialise crosssection options from user input.

workflows.set_branch_crosssections(branches)

Set regular cross-sections for each branch.

workflows.set_xyz_crosssections(branches, ...)

Set up xyz crosssections.

workflows.set_point_crosssections(branches, ...)

Set regular cross-sections from point.

workflows.add_crosssections(crosssections, ...)

Add new_crossections to crosssections.

DEM#

workflows.invert_levels_from_dem(gdf, dem[, ...])

Compute up- and downstream invert levels for pipe lines in gdf.

workflows.get_river_bathymetry(ds, flwdir[, ...])

Estimate river bedlevel zb.

Manholes#

workflows.generate_manholes_on_branches(branches)

Generate manhole location and bedlevel from branches.

Mesh#

workflows.mesh1d_network1d_from_branches(...)

Return xugrid mesh1d and network1d UgridDataset from branches.

workflows.mesh1d_add_branch(network, ...[, ...])

Add branch to 1d mesh, from a (list of) (Multi)LineString geometry.

workflows.mesh2d_refine(mesh2d, res[, ...])

Refine mesh2d by adding new nodes and faces.

workflows.links1d2d_add_links_1d_to_2d(mesh)

Generate 1d2d links to network from 1d to 2d.

workflows.links1d2d_add_links_2d_to_1d_embedded(mesh)

Generate embedded links from 2d to 1d.

workflows.links1d2d_add_links_2d_to_1d_lateral(mesh)

Generate 1d2d links from the 2d mesh to the 1d mesh, with a lateral connection.

Region#

workflows.parse_region_geometry(region, crs)

Parse hydromt region argument into region geometry.

Roughness#

workflows.generate_roughness(roughness)

Generate roughness ID column based on frictiontype and frictionvalue.

Structures#

workflows.prepare_1dstructures(branches, ...)

Prepare 1D structures from geodataframe.

DFlowFM low-level methods#

Input/Output methods#

utils.io_utils.read_branches_gui(gdf, fm_model)

Read branches.gui and add the properties to branches geodataframe.

utils.io_utils.write_branches_gui(gdf, savedir)

write branches.gui file from branches geodataframe.

utils.io_utils.read_crosssections(gdf, fm_model)

Read crosssections from hydrolib-core crsloc and crsdef objects and add to branches.

utils.io_utils.write_crosssections(gdf, savedir)

Write crosssections into hydrolib-core crsloc and crsdef objects.

utils.io_utils.read_friction(gdf, fm_model)

Read friction files and add properties to branches geodataframe.

utils.io_utils.write_friction(gdf, savedir)

write friction files from crosssections geodataframe.

utils.io_utils.read_structures(branches, ...)

Read structures into hydrolib-core structures objects.

utils.io_utils.write_structures(gdf, savedir)

write structures into hydrolib-core structures objects.

utils.io_utils.read_manholes(gdf, fm_model)

Read manholes from hydrolib-core storagenodes and network 1d nodes for locations.

utils.io_utils.write_manholes(gdf, savedir)

write manholes into hydrolib-core storage nodes objects.

utils.io_utils.read_1dboundary(df, quantity, ...)

Read for a specific quantity the external and forcing files and parse to xarray.

utils.io_utils.write_1dboundary(forcing[, ...])

Write 1dboundary ext and boundary files from forcing dict.

utils.io_utils.read_1dlateral(df[, ...])

Read a 1D lateral from external and forcing files.

utils.io_utils.write_1dlateral(forcing[, ...])

Write 1dlateral ext and bc files from forcing dict.

utils.io_utils.read_2dboundary(df[, workdir])

Read a 2d boundary forcing location and values, and parse to xarray.

utils.io_utils.write_2dboundary(forcing, savedir)

Write 2 boundary forcings from forcing dict.

utils.io_utils.read_meteo(df, quantity)

Read for a specific quantity the external and forcing files and parse to xarray.

utils.io_utils.write_meteo(forcing, savedir)

Write 2d meteo forcing from forcing dict.

Mesh conversion methods#

utils.mesh_utils.hydrolib_network_from_mesh(mesh)

Convert from xugrid mesh to hydrolib-core network object.

utils.mesh_utils.mesh1d_network1d_from_hydrolib_network(...)

Create xugrid mesh1d and network1d UgridDataset from hydrolib-core network object.

utils.mesh_utils.links1d2d_from_hydrolib_network(...)

Extract link1d2d from hydrolib-core network object.

utils.mesh_utils.mesh_from_hydrolib_network(...)

Create xugrid mesh from hydrolib-core network object.

utils.mesh_utils.mesh1d_nodes_geodataframe(...)

Return the nodes of mesh 1D as geodataframe.

utils.mesh_utils.network1d_nodes_geodataframe(...)

Get network1d nodes as gdp.

Graph methods#

utils.graph_utils.gpd_to_digraph(data)

Convert a gpd.GeoDataFrame to a nx.DiGraph.

utils.graph_utils.get_endnodes_from_lines(lines)

Get the possible boundary locations from the branches with id.

GIS methods#

utils.gis_utils.split_lines(line, num_new_lines)

Get a list of lines splitted from a line.

utils.gis_utils.cut_pieces(line, distances)

Cut a line into pieces based on distances.

utils.gis_utils.check_gpd_attributes(gdf, ...)

Check if the geodataframe contains all required columns.

utils.gis_utils.update_data_columns_attributes_based_on_filter(...)

Add or update columns in gdf based on column and values in df.

utils.gis_utils.get_gdf_from_branches(...)

Get geodataframe from dataframe.