hydromt_delft3dfm.DFlowFMModel#
- class hydromt_delft3dfm.DFlowFMModel(root: str | ~pathlib.Path, mode: str = 'w', config_fn: str = None, data_libs: ~typing.List[str] = [], crs: int | str = None, dimr_fn: str = None, network_snap_offset=25, snap_newbranches_to_branches_at_snapnodes=True, openwater_computation_node_distance=40, logger=<Logger hydromt_delft3dfm.dflowfm (WARNING)>)[source]#
API for Delft3D-FM models in HydroMT.
Initialize the DFlowFMModel.
- Parameters:
root (str or Path) – The model root location.
mode ({'w','r','r+'}) – Write/read/append mode. Default is “w”.
config_fn (str, optional) – The D-Flow FM model configuration file (.mdu). If None, default configuration file is used. Default is None.
data_libs (list of str, optional) – List of data catalog yaml files. Default is None.
crs (EPSG code, int) – EPSG code of the model.
dimr_fn (str, optional) – Path to the dimr configuration file. If None, default dimr configuration file is used. Default is None.
network_snap_offset (float, optional) – Global option for generation of the mesh1d network. Snapping tolerance to automatically connecting branches. By default 25 m.
snap_newbranches_to_branches_at_snapnodes (bool, optional) – Global option for generation of the mesh1d network. By default True.
openwater_computation_node_distance (float, optional) – Global option for generation of the mesh1d network. Distance to generate mesh1d nodes for open water system (rivers, channels). By default 40 m.
logger – The logger used to log messages.
- __init__(root: str | ~pathlib.Path, mode: str = 'w', config_fn: str = None, data_libs: ~typing.List[str] = [], crs: int | str = None, dimr_fn: str = None, network_snap_offset=25, snap_newbranches_to_branches_at_snapnodes=True, openwater_computation_node_distance=40, logger=<Logger hydromt_delft3dfm.dflowfm (WARNING)>)[source]#
Initialize the DFlowFMModel.
- Parameters:
root (str or Path) – The model root location.
mode ({'w','r','r+'}) – Write/read/append mode. Default is “w”.
config_fn (str, optional) – The D-Flow FM model configuration file (.mdu). If None, default configuration file is used. Default is None.
data_libs (list of str, optional) – List of data catalog yaml files. Default is None.
crs (EPSG code, int) – EPSG code of the model.
dimr_fn (str, optional) – Path to the dimr configuration file. If None, default dimr configuration file is used. Default is None.
network_snap_offset (float, optional) – Global option for generation of the mesh1d network. Snapping tolerance to automatically connecting branches. By default 25 m.
snap_newbranches_to_branches_at_snapnodes (bool, optional) – Global option for generation of the mesh1d network. By default True.
openwater_computation_node_distance (float, optional) – Global option for generation of the mesh1d network. Distance to generate mesh1d nodes for open water system (rivers, channels). By default 40 m.
logger – The logger used to log messages.
Methods
__init__
(root[, mode, config_fn, data_libs, ...])Initialize the DFlowFMModel.
build
([region, write, opt])Single method to build a model from scratch based on settings in opt.
get_config
(*args[, fallback, abs_path])Get a config value at key(s).
get_mesh
(grid_name[, include_data])Return a specific grid topology from mesh based on grid_name.
Return (refdate, tstart, tstop) tuple.
get_tables_merged
()Return all tables of a model merged into one dataframe.
Initialise the hydrolib-core FMModel object.
read
()Read the complete model schematization and configuration from file.
Use Hydrolib-core reader and return to dictionnary.
read_dimr
([dimr_fn])Read DIMR from file and else create from hydrolib-core.
Read forcing at <root/?/> and parse to dict of xr.DataArray.
Read model geometries files at <root>/<geoms> and add to geoms property.
Read maps from initialfield and parse to dict of xr.DataArray.
Read network file with Hydrolib-core and extract mesh/branches info.
read_nc
(fn[, mask_and_scale, ...])Read netcdf files at <root>/<fn> and return as dict of xarray.Dataset.
Read results at <root/?/> and parse to dict of xr.DataArray.
Read states at <root/?/> and parse to dict of xr.DataArray.
read_staticgeoms
()Read gemoetries from disk.
read_staticmaps
([fn])Read static model maps at <root>/<fn> and add to staticmaps property.
read_tables
([fn])Read table files at <root>/tables and parse to dict of dataframes.
set_branches
(branches)Update the branches object as well as the linked geoms.
set_branches_component
(name)Extract component name from branches and add it to geoms.
set_config
(*args)Update the config dictionary at key(s) with values.
set_crs
(crs)Set the coordinate reference system.
set_forcing
(data[, name, split_dataset])Add data to forcing attribute.
set_geoms
(geom, name)Add data to the geoms attribute.
set_link1d2d
(link1d2d)Add or replace the link1d2d in the model mesh.
set_maps
(data[, name, split_dataset])Add raster data to the maps component.
set_mesh
(data[, name, grid_name, overwrite_grid])Add data to mesh.
set_results
(data[, name, split_dataset])Add data to results attribute.
set_root
(root[, mode])Initialize the model root.
set_states
(data[, name, split_dataset])Add data to states attribute.
set_staticgeoms
(geom, name)Set the geometries.
set_staticmaps
(data[, name])Add data to staticmaps.
set_tables
(tables[, name])Add (a) table(s) <pandas.DataFrame> to model.
setup_1dboundary
([boundaries_geodataset_fn, ...])Prepare the 1D
boundary_type
boundaries using timeseries or a constant.setup_1dlateral_from_points
([...])Prepare the 1D lateral discharge from geodataset of point geometries.
Prepare the 1D lateral discharge from geodataset of polygons.
setup_2dboundary
([boundaries_fn, ...])Prepare the 2D boundaries from line geometries.
setup_basemaps
(*args, **kwargs)setup_bridges
([bridges_fn, ...])Prepare bridges, including bridge locations and bridge crossections.
setup_channels
(region, channels_fn[, ...])Prepare the 1D channels and adds to branches 1D network.
setup_config
(**cfdict)Update config with a dictionary.
setup_culverts
([culverts_fn, ...])Prepare culverts, including locations and crossections.
setup_link1d2d
([link_direction, link_type, ...])Generate 1d2d links that link mesh1d and mesh2d according UGRID conventions.
setup_manholes
([manholes_fn, ...])Prepare the 1D manholes to pipes or tunnels.
setup_maps_from_raster_reclass
(raster_fn, ...)Add data variable(s) to maps by reclassifying values from
raster_fn
.setup_maps_from_rasterdataset
(raster_fn[, ...])Add data variable(s) from
raster_fn
to maps object.setup_mesh2d
(region[, res])Create a 2D unstructured mesh according UGRID conventions.
setup_mesh2d_from_raster_reclass
(raster_fn, ...)HYDROMT CORE METHOD: Add data variable(s) to 2D
grid_name
in mesh object by reclassifying the data inraster_fn
based onreclass_table_fn
.setup_mesh2d_from_rasterdataset
(raster_fn[, ...])HYDROMT CORE METHOD: Add data variable(s) from
raster_fn
to 2Dgrid_name
in mesh object.setup_mesh2d_refine
([polygon_fn, sample_fn, ...])Refine the 2d mesh.
setup_pipes
(region, pipes_fn[, ...])Prepare the 1D pipes and adds to 1D branches.
setup_rainfall_from_constant
(constant_value)Prepare constant 2D daily rainfall_rate timeseries based on
constant_value
.Prepare spatially uniform 2D rainfall forcings from
meteo_timeseries_fn
.setup_region
(region)HYDROMT CORE METHOD NOT USED FOR DFlowFMModel.
setup_rivers
(region, rivers_fn[, ...])Prepare the 1D rivers and adds to 1D branches.
setup_rivers_from_dem
(region, hydrography_fn)Set the all river parameters from hydrograph and dem maps.
test_model_api
()Test compliance with HydroMT Model API.
update
([model_out, write, opt, ...])Single method to update a model based the settings in opt.
write
()Write the complete model schematization and configuration to file.
From config dict to Hydrolib MDU.
write_data_catalog
([root, data_lib_fn, ...])Write the data catalog to data_lib_fn.
write_dimr
([dimr_fn])Write the dmir file.
Write forcing into hydrolib-core ext and forcing models.
write_geoms
([write_mesh_gdf])Write model geometries to a GeoJSON file at <root>/<geoms>.
Write maps as tif files in maps folder and update initial fields.
write_mesh
([write_gui])Write 1D branches and 2D mesh at <root/dflowfm/fm_net.nc>.
write_nc
(nc_dict, fn[, gdal_compliant, ...])Write dictionnary of xarray.Dataset and/or xarray.DataArray to netcdf files.
write_results
()Write results at <root/?/> in model ready format.
Write states at <root/?/> in model ready format.
write_staticgeoms
()Write the geometries to disk.
write_staticmaps
([fn])Write static model maps to netcdf file at <root>/<fn>.
write_tables
([fn])Write tables at <root>/tables.
Attributes
api
boundaries
1D boundary locations.
Return model mesh bounds.
Return the branches (gpd.GeoDataFrame object) representing the 1D network.
Extract channels from branches.
Closed system branches (pipe, tunnel).
Model configuration.
coords
Returns the coordinates of model staticmaps.
Return model crs.
Hydrolib-core FMModel object.
DIMR file object.
dims
Returns spatial dimension names of staticmaps.
Model forcing.
Model geometries.
height
Returns the height of the model staticmaps.
Model maps.
Model static mesh data.
Dictionnary of grid names and corresponding UgridDataset topology and data variables in mesh.
Returns dict of geometry of grids in mesh as a gpd.GeoDataFrame.
Dictionnary of grid names and Ugrid topologies in mesh.
List of grid names in mesh.
Open system branches (river, channel).
Extract pipes from branches.
Return geometry of region of the model area of interest.
Resolution of the mesh2d.
Model results.
Extract rivers from branches.
Path to model folder.
shape
Returns the shape of the model staticmaps.
Model states.
staticgeoms
Access the geometryes.
staticmaps
Model static maps.
tables
Model tables.
transform
Returns the geospatial transform of the model staticmaps.
width
Returns the width of the model staticmaps.