API reference#

DFlowFM model class#

Initialize#

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

API for Delft3D-FM models in HydroMT.

Setup components#

DFlowFMModel.setup_config(**cfdict)

Update config with a dictionary.

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(...)

Add data variable(s) from raster_fn to maps object.

DFlowFMModel.setup_maps_from_raster_reclass(...)

Add data variable(s) to maps by reclassifying values from raster_fn.

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 geometry of region of the model area of interest.

DFlowFMModel.crs

Return model crs.

DFlowFMModel.bounds

Return model mesh bounds.

DFlowFMModel.res

Resolution of the mesh2d.

DFlowFMModel.root

Path to model folder.

DFlowFMModel.config

Model configuration.

DFlowFMModel.maps

Model maps.

DFlowFMModel.geoms

Model geometries.

DFlowFMModel.forcing

Model forcing.

DFlowFMModel.states

Model states.

DFlowFMModel.results

Model results.

DFlowFMModel.mesh

Model static mesh data.

DFlowFMModel.dfmmodel

Hydrolib-core FMModel object.

DFlowFMModel.dimr

DIMR file object.

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).

DFlowFMModel.mesh_names

List of grid names in mesh.

DFlowFMModel.mesh_grids

Dictionnary of grid names and Ugrid topologies in mesh.

DFlowFMModel.mesh_datasets

Dictionnary of grid names and corresponding UgridDataset topology and data variables in mesh.

DFlowFMModel.mesh_gdf

Returns dict of geometry of grids in mesh as a gpd.GeoDataFrame.

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([region, write, opt])

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

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

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

DFlowFMModel.set_root(root[, mode])

Initialize the model root.

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

Write the data catalog to data_lib_fn.

General methods#

DFlowFMModel.get_config(*args[, fallback, ...])

Get a config value at key(s).

DFlowFMModel.set_config(*args)

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

DFlowFMModel.read_config()

Use Hydrolib-core reader and return to dictionnary.

DFlowFMModel.write_config()

From config dict to Hydrolib MDU.

DFlowFMModel.set_maps(data[, name, ...])

Add raster data to the maps component.

DFlowFMModel.read_maps()

Read maps from initialfield and parse to dict of xr.DataArray.

DFlowFMModel.write_maps()

Write maps as tif files in maps folder and update initial fields.

DFlowFMModel.set_geoms(geom, name)

Add data to the geoms attribute.

DFlowFMModel.read_geoms()

Read model geometries files at <root>/<geoms> and add to geoms property.

DFlowFMModel.write_geoms([write_mesh_gdf])

Write model geometries to a GeoJSON file at <root>/<geoms>.

DFlowFMModel.set_forcing(data[, name, ...])

Add data to forcing attribute.

DFlowFMModel.read_forcing()

Read forcing at <root/?/> and parse to dict of xr.DataArray.

DFlowFMModel.write_forcing()

Write forcing into hydrolib-core ext and forcing models.

DFlowFMModel.set_states(data[, name, ...])

Add data to states attribute.

DFlowFMModel.read_states()

Read states at <root/?/> and parse to dict of xr.DataArray.

DFlowFMModel.write_states()

Write states at <root/?/> in model ready format.

DFlowFMModel.set_results(data[, name, ...])

Add data to results attribute.

DFlowFMModel.read_results()

Read results at <root/?/> and parse to dict of xr.DataArray.

DFlowFMModel.get_mesh(grid_name[, include_data])

Return a specific grid topology from mesh based on grid_name.

DFlowFMModel.set_mesh(data[, name, ...])

Add data to mesh.

DFlowFMModel.set_link1d2d(link1d2d)

Add or replace the link1d2d in the model mesh.

DFlowFMModel.read_mesh()

Read network file with Hydrolib-core and extract mesh/branches info.

DFlowFMModel.write_mesh([write_gui])

Write 1D branches and 2D mesh at <root/dflowfm/fm_net.nc>.

DFlowFMModel.set_branches(branches)

Update the branches object as well as the linked geoms.

DFlowFMModel.read_dimr([dimr_fn])

Read DIMR from file and else create from hydrolib-core.

DFlowFMModel.write_dimr([dimr_fn])

Write the dmir file.

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[, logger])

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 stype 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.read_branches_gui(gdf, fm_model)

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

utils.write_branches_gui(gdf, savedir)

write branches.gui file from branches geodataframe.

utils.read_crosssections(gdf, fm_model)

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

utils.write_crosssections(gdf, savedir)

Write crosssections into hydrolib-core crsloc and crsdef objects.

utils.read_friction(gdf, fm_model)

Read friction files and add properties to branches geodataframe.

utils.write_friction(gdf, savedir)

write friction files from crosssections geodataframe.

utils.read_structures(branches, fm_model)

Read structures into hydrolib-core structures objects.

utils.write_structures(gdf, savedir)

write structures into hydrolib-core structures objects.

utils.read_manholes(gdf, fm_model)

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

utils.write_manholes(gdf, savedir)

write manholes into hydrolib-core storage nodes objects.

utils.read_1dboundary(df, quantity, nodes)

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

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

Write 1dboundary ext and boundary files from forcing dict.

utils.read_1dlateral(df[, quantity, branches])

Read a 1D lateral from external and forcing files.

utils.write_1dlateral(forcing[, savedir, ext_fn])

Write 1dlateral ext and bc files from forcing dict.

utils.read_2dboundary(df[, workdir])

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

utils.write_2dboundary(forcing, savedir[, ...])

Write 2 boundary forcings from forcing dict.

utils.read_meteo(df, quantity)

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

utils.write_meteo(forcing, savedir[, ext_fn])

Write 2d meteo forcing from forcing dict.

Mesh conversion methods#

mesh_utils.hydrolib_network_from_mesh(mesh)

Convert from xugrid mesh to hydrolib-core network object.

mesh_utils.mesh1d_network1d_from_hydrolib_network(...)

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

mesh_utils.links1d2d_from_hydrolib_network(network)

Extract link1d2d from hydrolib-core network object.

mesh_utils.mesh_from_hydrolib_network(...)

Create xugrid mesh from hydrolib-core network object.

mesh_utils.mesh1d_nodes_geodataframe(...)

Return the nodes of mesh 1D as geodataframe.

mesh_utils.network1d_nodes_geodataframe(...)

Get network1d nodes as gdp.

Graph methods#

graph_utils.gpd_to_digraph(data)

Convert a gpd.GeoDataFrame to a nx.DiGraph.

graph_utils.get_endnodes_from_lines(lines[, ...])

Get the possible boundary locations from the branches with id.

GIS methods#

gis_utils.split_lines(line, num_new_lines)

Get a list of lines splitted from a line.

gis_utils.cut_pieces(line, distances)

Cut a line into pieces based on distances.

gis_utils.check_gpd_attributes(gdf, ...[, ...])

Check if the geodataframe contains all required columns.

gis_utils.update_data_columns_attributes_based_on_filter(...)

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

gis_utils.get_gdf_from_branches(branches, df)

Get geodataframe from dataframe.