hydromt_sfincs.SfincsModel#

class hydromt_sfincs.SfincsModel(root: str = None, mode: str = 'w', config_fn: str = 'sfincs.inp', write_gis: bool = True, data_libs: ~typing.List[str] | str = None, logger=<Logger hydromt_sfincs.sfincs (WARNING)>)[source]#

The SFINCS model class (SfincsModel) contains methods to read, write, setup and edit SFINCS models.

Parameters:
  • root (str, Path, optional) – Path to model folder

  • mode ({'w', 'r+', 'r'}) – Open model in write, append or reading mode, by default ‘w’

  • config_fn (str, Path, optional) – Filename of model config file, by default “sfincs.inp”

  • write_gis (bool) – Write model files additionally to geotiff and geojson, by default True

  • data_libs (List, str) – List of data catalog yaml files, by default None

__init__(root: str = None, mode: str = 'w', config_fn: str = 'sfincs.inp', write_gis: bool = True, data_libs: ~typing.List[str] | str = None, logger=<Logger hydromt_sfincs.sfincs (WARNING)>)[source]#

The SFINCS model class (SfincsModel) contains methods to read, write, setup and edit SFINCS models.

Parameters:
  • root (str, Path, optional) – Path to model folder

  • mode ({'w', 'r+', 'r'}) – Open model in write, append or reading mode, by default ‘w’

  • config_fn (str, Path, optional) – Filename of model config file, by default “sfincs.inp”

  • write_gis (bool) – Write model files additionally to geotiff and geojson, by default True

  • data_libs (List, str) – List of data catalog yaml files, by default None

Methods

__init__([root, mode, config_fn, write_gis, ...])

The SFINCS model class (SfincsModel) contains methods to read, write, setup and edit SFINCS models.

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

Return (tstart, tstop) tuple with parsed model start and end time

get_tables_merged()

Return all tables of a model merged into one dataframe.

plot_basemap([fn_out, variable, shaded, ...])

Create basemap plot.

plot_forcing([fn_out, forcings])

Plot model timeseries forcing.

read([epsg])

Read the complete model schematization and configuration from file.

read_config([config_fn, epsg])

Parse config from SFINCS input file.

read_forcing([data_vars])

Read forcing files and save to forcing attribute.

read_geoms()

Read geometry files and save to geoms attribute.

read_grid([data_vars])

Read SFINCS binary grid files and save to grid attribute.

read_maps([fn])

Read model map at <root>/<fn> and add to maps component.

read_nc(fn[, mask_and_scale, ...])

Read netcdf files at <root>/<fn> and return as dict of xarray.Dataset.

read_results([chunksize, drop, fn_map, fn_his])

Read results from sfincs_map.nc and sfincs_his.nc and save to the results attribute.

read_states()

Read waterlevel state (zsini) from binary file and save to states attribute.

read_staticgeoms()

Read gemoetries from disk.

read_staticmaps([fn])

Read static model maps at <root>/<fn> and add to staticmaps property.

read_subgrid()

Read SFINCS subgrid file and add to subgrid attribute.

read_tables([fn])

Read table files at <root>/tables and parse to dict of dataframes.

set_config(*args)

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

set_crs(crs)

Sets the model crs

set_forcing(data[, name, split_dataset])

Add data to forcing attribute.

set_forcing_1d([df_ts, gdf_locs, name, merge])

Set 1D forcing time series for 'bzs' or 'dis' boundary conditions.

set_geoms(geom, name)

Add data to the geoms attribute.

set_grid(data[, name])

Add data to grid.

set_maps(data[, name, split_dataset])

Add raster data to the maps component.

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_basemaps(*args, **kwargs)

setup_cn_infiltration(cn[, ...])

Setup model potential maximum soil moisture retention map (scsfile) from gridded curve number map.

setup_cn_infiltration_with_ks(lulc, hsg, ...)

Setup model the Soil Conservation Service (SCS) Curve Number (CN) files for SFINCS including recovery term based on the soil saturation

setup_config(**cfdict)

Update config with a dictionary.

setup_constant_infiltration([qinf, lulc, ...])

Setup spatially varying constant infiltration rate (qinffile).

setup_dep(datasets_dep[, buffer_cells, ...])

Interpolate topobathy (dep) data to the model grid.

setup_discharge_forcing([geodataset, ...])

Setup discharge forcing.

setup_discharge_forcing_from_grid(discharge)

Setup discharge forcing based on a gridded discharge dataset.

setup_drainage_structures(structures[, ...])

Setup drainage structures.

setup_grid(x0, y0, dx, dy, nmax, mmax, ...)

Setup a regular or quadtree grid.

setup_grid_from_constant(constant, name[, ...])

HYDROMT CORE METHOD: Adds a grid based on a constant value.

setup_grid_from_geodataframe(vector_fn[, ...])

HYDROMT CORE METHOD: Add data variable(s) to grid object by rasterizing the data from vector_fn.

setup_grid_from_raster_reclass(raster_fn, ...)

HYDROMT CORE METHOD: Add data variable(s) to grid object by reclassifying the data in raster_fn based on reclass_table_fn.

setup_grid_from_rasterdataset(raster_fn[, ...])

HYDROMT CORE METHOD: Add data variable(s) from raster_fn to grid object.

setup_grid_from_region(region[, res, crs, ...])

Setup a regular or quadtree grid from a region.

setup_manning_roughness([datasets_rgh, ...])

Setup model manning roughness map (manningfile) from gridded manning data or a combinataion of gridded land-use/land-cover map and manning roughness mapping table.

setup_maps_from_raster_reclass(raster_fn, ...)

HYDROMT CORE METHOD: Add data variable(s) to maps object by reclassifying the data in raster_fn based on reclass_table_fn.

setup_maps_from_rasterdataset(raster_fn[, ...])

HYDROMT CORE METHOD: Add data variable(s) from raster_fn to maps object.

setup_mask_active([mask, include_mask, ...])

Setup active model cells.

setup_mask_bounds([btype, include_mask, ...])

Set boundary cells in the model mask.

setup_observation_lines(locations[, merge])

Setup model observation lines (cross-sections) to monitor discharges.

setup_observation_points(locations[, merge])

Setup model observation point locations.

setup_precip_forcing([timeseries, magnitude])

Setup spatially uniform precipitation forcing (precip).

setup_precip_forcing_from_grid(precip[, ...])

Setup precipitation forcing from a gridded spatially varying data source.

setup_pressure_forcing_from_grid(press[, ...])

Setup pressure forcing from a gridded spatially varying data source.

setup_region(region[, hydrography_fn, ...])

Set the region of interest of the model.

setup_river_inflow([rivers, hydrography, ...])

Setup discharge (src) points where a river enters the model domain.

setup_river_outflow([rivers, hydrography, ...])

Setup open boundary cells (mask=3) where a river flows out of the model domain.

setup_storage_volume(storage_locs[, volume, ...])

Setup storage volume.

setup_structures(structures, stype[, dep, ...])

Setup thin dam or weir structures.

setup_subgrid(datasets_dep[, datasets_rgh, ...])

Setup method for subgrid tables based on a list of elevation and Manning's roughness datasets.

setup_tiles([path, region, datasets_dep, ...])

Create both index and topobathy tiles in webmercator format.

setup_waterlevel_bnd_from_mask([distance, merge])

Setup waterlevel boundary (bnd) points along model waterlevel boundary (msk=2).

setup_waterlevel_forcing([geodataset, ...])

Setup waterlevel forcing.

setup_wind_forcing([timeseries, magnitude, ...])

Setup spatially uniform wind forcing (wind).

setup_wind_forcing_from_grid(wind[, dst_res])

Setup pressure forcing from a gridded spatially varying data source.

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.

update_grid_from_config()

Update grid properties based on config (sfincs.inp) attributes

update_spatial_attrs()

Update geospatial config (sfincs.inp) attributes based on grid

write()

Write the complete model schematization and configuration to file.

write_config([config_fn])

Write config to <root/config_fn>

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

Write the data catalog to data_lib_fn.

write_forcing([data_vars])

Write forcing to ascii or netcdf (netampr) files.

write_geoms([data_vars])

Write geoms to bnd/src/obs xy files and thd/weir structure files.

write_grid([data_vars])

Write SFINCS grid to binary files including map index file.

write_maps([fn])

Write maps to netcdf file at <root>/<fn>.

write_nc(nc_dict, fn[, gdal_compliant, ...])

Write dictionnary of xarray.Dataset and/or xarray.DataArray to netcdf files.

write_raster([variables, root, driver, compress])

Write model 2D raster variables to geotiff files.

write_states()

Write waterlevel state (zsini) to binary map file.

write_staticgeoms()

Write the geometries to disk.

write_staticmaps([fn])

Write static model maps to netcdf file at <root>/<fn>.

write_subgrid()

Write SFINCS subgrid file.

write_tables([fn])

Write tables at <root>/tables.

write_vector([variables, root, gdf])

Write model vector (geoms) variables to geojson files.

Attributes

api

bounds

Returns the bounding box of the model grid.

config

Model configuration.

coords

Returns the coordinates of model staticmaps.

crs

Returns the model crs

dims

Returns spatial dimension names of staticmaps.

forcing

Model forcing.

geoms

Model geometries.

grid

Model static gridded data as xarray.Dataset.

height

Returns the height of the model staticmaps.

maps

Model maps.

mask

Returns model mask

region

Returns the geometry of the active model cells.

res

Returns the resolution of the model grid.

results

Model results.

root

Path to model folder.

shape

Returns the shape of the model staticmaps.

states

Model states.

staticgeoms

Access the geometryes.

staticmaps

Model static maps.

tables

Model tables.

transform

Returns spatial transform of the model grid.

width

Returns the width of the model staticmaps.