Make a coastal sfincs model from scratch using hydromt

This notebook demonstrates how to prepare and inspect a SFINCS model from scratch. The notebook does not contain the SFINCS code or executables to run the model with.

We will make a schematization with the following features: * we only simulate coastal flooding, we do not consider any interactions with riverine flooding * we use the MERIT Hydro dataset as elevation * we include boundary conditions from the Global Tide and Surge Model by imposing a number of boundary points where forcing is expected

All lines in this notebook which start with ! are executed from the command line. Within jupyter (except for jupyter lab) the logging messages are shown after completion. You can also copy these lines and paste these in your shell to get more direct feedback.

HydroMT CLI build interface

First let us see what hydromt provides us with.

[1]:
!hydromt --help
Usage: hydromt [OPTIONS] COMMAND [ARGS]...

  Command line interface for hydromt models.

Options:
  --version  Show the version and exit.
  --models   Print availabe model plugins and exit.
  --help     Show this message and exit.

Commands:
  build   Build models
  clip    Clip models.
  update  Update models

With the models flag we can ask if hydroMT recognizes the SFINCS plugin (SFINCS should be mentioned):

[2]:
!hydromt --models
hydroMT model plugins: sfincs (v0.2.2.dev0)

It looks like we have several commands that we can consider. We want to build a model. How does that work? We can also call --help on the available hydroMT commands as follows.

[3]:
!hydromt build --help
Usage: hydromt build [OPTIONS] MODEL MODEL_ROOT REGION

  Build models from source data.

  Example usage:
  --------------

  To build a wflow model for a subbasin using and point coordinates snapped to cells with stream order >= 4
  hydromt build wflow /path/to/model_root "{'subbasin': [-7.24, 62.09], 'strord': 4}" -i /path/to/wflow_config.ini

  To build a wflow model based on basin ID
  hydromt build wflow /path/to/model_root "{'basin': 230001006}"

  To build a sfincs model based on a bbox (for Texel)
  hydromt build sfincs /path/to/model_root "{'bbox': [4.6891,52.9750,4.9576,53.1994]}"

Options:
  -r, --res FLOAT             Model resolution in model src.
  --build-base / --build-all  Deprecated!
  --opt TEXT                  Component specific keyword arguments, see the
                              setup_<component> method of the specific model
                              for more information about the arguments.
  -i, --config PATH           Path to hydroMT configuration file, for the
                              model specific implementation.
  -d, --data PATH             File path to yml data sources file. See
                              documentation for required yml file format.
  --dd, --deltares-data       Parse default deltares data yml from
                              https://github.com/DirkEilander/hydromt-
                              artifacts/releases
  -q, --quiet                 Decrease verbosity.
  -v, --verbose               Increase verbosity.
  --help                      Show this message and exit.

Building a first model (and getting an error when data is missing)

Let’s try to build an entire schematization, just from the command line (Awesome!!!). In the --help section, there is an example for making a model from a bounding box, which is very intuitive. Let’s try exactly that. We store the model on the local path ./texel_sfincs

[4]:
!hydromt build sfincs ./texel_sfincs "{'bbox': [4.68,52.97,4.96,53.20]}"
2022-07-01 15:20:50,607 - build - sfincs - ERROR - depfile = sfincs.dep not found
2022-07-01 15:20:50,608 - build - sfincs - ERROR - mskfile = sfincs.msk not found
2022-07-01 15:20:50,608 - build - sfincs - ERROR - indexfile = sfincs.ind not found

The above might have taken a few seconds, but then should have miserably crashed! What happened: * HydroMT was looking for a data catalog to use. * It did not find any and therefore, it automatically downloaded a sample data catalog which you can now find on your home folder under .hydromt_data * It tried to build a model in the Texel bounding box, but…alas, the sample dataset does not cover Texel at all! To add datasets covering the area outside the sample data extent, setup your own datasets using data yml files hydroMT data using --data PATH option, or if your are connected to the Deltares network --deltares-data flag.

Building a first model (and getting it right)

Let’s adapt the bounding box to an area that fits within the sample dataset. The dataset covers the Piave basin and its surroundings in Italy. A good place to get a CSV formatted bounding box is https://boundingbox.klokantech.com/

We also add -vv for extra verbosity

[5]:
!hydromt build sfincs ./venice_sfincs "{'bbox': [12.05,45.30,12.85,45.65]}" -vv
2022-07-01 15:20:57,004 - build - log - DEBUG - Writing log messages to new file /home/runner/work/hydromt_sfincs/hydromt_sfincs/docs/_examples/venice_sfincs/hydromt.log.
2022-07-01 15:20:57,004 - build - log - INFO - HydroMT version: 0.4.5
2022-07-01 15:20:57,004 - build - main - INFO - Building instance of sfincs model at /home/runner/work/hydromt_sfincs/hydromt_sfincs/docs/_examples/venice_sfincs.
2022-07-01 15:20:57,004 - build - main - INFO - User settings:
2022-07-01 15:20:57,007 - build - model_plugins - DEBUG - Loaded model plugin 'sfincs = hydromt_sfincs.sfincs.SfincsModel' (0.2.2.dev0)
2022-07-01 15:20:57,007 - build - model_api - INFO - Initializing sfincs model from hydromt_sfincs (v0.2.2.dev0).
2022-07-01 15:20:57,008 - build - model_api - INFO - setup_region.region: {'bbox': [12.05, 45.3, 12.85, 45.65]}
2022-07-01 15:20:57,008 - build - model_api - INFO - setup_region.hydrography_fn: merit_hydro
2022-07-01 15:20:57,008 - build - model_api - INFO - setup_region.basin_index_fn: merit_hydro_index
2022-07-01 15:20:57,008 - build - basin_mask - DEBUG - Parsed region (kind=bbox): {'bbox': [12.05, 45.3, 12.85, 45.65]}
2022-07-01 15:20:57,012 - build - sfincs - INFO - Writing model data to /home/runner/work/hydromt_sfincs/hydromt_sfincs/docs/_examples/venice_sfincs
2022-07-01 15:20:57,012 - build - sfincs - INFO - Write staticgeom files
2022-07-01 15:20:57,012 - build - sfincs - INFO - Write vector file(s) for staticgeoms to 'gis' subfolder
2022-07-01 15:20:57,056 - build - model_api - DEBUG - Default config read from /usr/share/miniconda/envs/hydromt-sfincs/lib/python3.9/site-packages/hydromt_sfincs/data/sfincs/sfincs.inp
2022-07-01 15:20:57,056 - build - sfincs - ERROR - depfile = sfincs.dep not found
2022-07-01 15:20:57,056 - build - sfincs - ERROR - mskfile = sfincs.msk not found
2022-07-01 15:20:57,056 - build - sfincs - ERROR - indexfile = sfincs.ind not found
2022-07-01 15:20:57,056 - build - model_api - INFO - Writing model config to /home/runner/work/hydromt_sfincs/hydromt_sfincs/docs/_examples/venice_sfincs/sfincs.inp
2022-07-01 15:20:57,057 - build - data_adapter - INFO - Adding sample data v0.0.6 from artifacts

This should work without any errors.

The example above means the following: run hydromt build with:

  • sfincs : i.e. build a SFINCS model

  • ./venice_sfincs : output model folder

  • "{'bbox': [12.05,45.30,12.85,45.65]}" : make a model that is active for the full given bounding box. All REGION options are described in the docs

  • -vv : give some extra verbosity (2 * v) to display feedback on screen. Now debug messages are provided.

NOTE: As we did not specify a model configuration, only the model region has been setup. To build a complete model we need the use a configuration ini-file.

When we inspect the newly created ./venice_sfincs folder we only find a log file and the gis folder containing the region geometry saved as geojson file.

[6]:
!ls ./venice_sfincs
gis  hydromt.log  hydromt_data.yml  sfincs.inp

Building a complete model (ready to run)

We can provide many more settings in an configuration (.ini) file instead of command line arguments. If you don’t provide an ini file (as done above), only the model region is determined. To complete your model you can add more model components to the model setup.

Let’s have a look a typical ini file for setting up coastal SFINCS model, where each [setup_<>] refers to a model component. All options which end with _fn refers to a data source from the data catalog or a path to data on your machine, see hydroMT data. In this case some sample data which is downloaded to your machine at $USER_ROOT/.hydromt_data

[7]:
fn_ini = "sfincs_coastal.ini"
with open(fn_ini, "r") as f:
    txt = f.read()
print(txt)
[setup_config]
tref = 20100201 000000
tstart = 20100201 000000
tstop = 20100210 000000
alpha = 0.5
zsini = 0.5

[setup_topobathy]
topobathy_fn = merit_hydro       # topobathy basemaps ['elevtn']
crs = utm                       # model CRS (must be UTM zone)

[setup_merge_topobathy]
topobathy_fn = gebco            # bathymetry ['elevtn']
mask_fn = osm_coastlines        # sea polygon describing where we want to use the new data
offset_fn = dtu10mdt_egm96      # mean dynamic topography to account for the difference in vertical datum between the current and new data
merge_method = first            # use valid new data where the current data has invalid (nodata) values
merge_buffer = 2                # buffer (cells) between elevation and bathymetry data filled with 'linear' interpolation

[setup_mask]
elv_min = -5                    # minimum elevation for valid cells

[setup_cn_infiltration]
cn_fn = gcn250                  # curve number source
antecedent_runoff_conditions = avg # for gcn250: {'dry', 'avg', 'wet'}

[setup_manning_roughness]
lulc_fn = vito                  # land-use land-cover source
map_fn = None                   # mapping file. read from hydromt/data/lulc/{lulc_fn}_mapping.csv if None

[setup_bounds]
btype = waterlevel              # boundary type ['waterlevel', 'outflow']
mask_fn = osm_coastlines        # sea polygon

[setup_h_forcing]
geodataset_fn = data/gtsm_locations.csv  # waterlevel gauge locations
timeseries_fn = data/gtsm_timeseries.csv  # waterlevel time series
buffer = 1e4                    # buffer around model region to select gauges

[setup_p_forcing_from_grid]
precip_fn = era5_hourly         # gridded precipitation data ['precip']
dst_res = None                  # output resolution (m)
aggregate = True                # if True return the aggregated mean as spatially uniform precip

You can see the following sections:

  • [setup_config]: arguments which are forwarded to the SFINCS model configuration file sfincs.inp

  • [setup_topobathy]: basic information required for the model domain grid and elevation. These are the minimal demanded static layers that any SFINCS model needs. Here you may for instance consider altering the elevation and bathymetry data for local data sources. These then have to be supplied in the data_catalog.yml.

  • [setup_merge_topobathy]: add additional data source for bathymetry data to merge with the basemap elevation data.

  • [setup_mask]: set valid model cells based on the topobathy data and a minimal depth boundary (more options available).

  • [setup_cn_infiltration]: potential maximum soil retention maps to be used in the curve number method, see SFINCS docs for more information

  • [setup_manning_roughness]: configuration of the Manning roughness values, typically consisting of a land use or land cover map, and a lookup table that relates land use classes to manning roughness values in sec m\(^{-1/3}\)

  • [setup_bounds]: set cells at the model domain edge and within the sea polygon to waterlevel boundary cells.

  • [setup_h_forcing]: water level forcing data. This can be provided from a set of csv files, see data_sources.yml, but also netcdf files, see hydroMT docs.

  • [setup_p_forcing_from_grid]: gridded precipitation data, that can be used to do compound flood simulations. The [setup_cn_infiltration] is then quite essential to include.

To build a model from scratch add the ini file to the command line hydromt build method at a 150 m resolution.

[8]:
!hydromt build sfincs ./venice_sfincs_150 "{'bbox': [12.05,45.30,12.85,45.65]}" -r 150 -i sfincs_coastal.ini -vv
2022-07-01 15:21:00,678 - build - log - DEBUG - Writing log messages to new file /home/runner/work/hydromt_sfincs/hydromt_sfincs/docs/_examples/venice_sfincs_150/hydromt.log.
2022-07-01 15:21:00,678 - build - log - INFO - HydroMT version: 0.4.5
2022-07-01 15:21:00,679 - build - main - INFO - Building instance of sfincs model at /home/runner/work/hydromt_sfincs/hydromt_sfincs/docs/_examples/venice_sfincs_150.
2022-07-01 15:21:00,679 - build - main - INFO - User settings:
2022-07-01 15:21:00,684 - build - model_plugins - DEBUG - Loaded model plugin 'sfincs = hydromt_sfincs.sfincs.SfincsModel' (0.2.2.dev0)
2022-07-01 15:21:00,684 - build - model_api - INFO - Initializing sfincs model from hydromt_sfincs (v0.2.2.dev0).
2022-07-01 15:21:00,684 - build - model_api - DEBUG - Setting model config options.
2022-07-01 15:21:00,686 - build - model_api - DEBUG - Default config read from /usr/share/miniconda/envs/hydromt-sfincs/lib/python3.9/site-packages/hydromt_sfincs/data/sfincs/sfincs.inp
2022-07-01 15:21:00,686 - build - model_api - INFO - setup_region.region: {'bbox': [12.05, 45.3, 12.85, 45.65]}
2022-07-01 15:21:00,686 - build - model_api - INFO - setup_region.hydrography_fn: merit_hydro
2022-07-01 15:21:00,686 - build - model_api - INFO - setup_region.basin_index_fn: merit_hydro_index
2022-07-01 15:21:00,686 - build - basin_mask - DEBUG - Parsed region (kind=bbox): {'bbox': [12.05, 45.3, 12.85, 45.65]}
2022-07-01 15:21:00,691 - build - model_api - INFO - setup_topobathy.topobathy_fn: merit_hydro
2022-07-01 15:21:00,691 - build - model_api - INFO - setup_topobathy.res: 150.0
2022-07-01 15:21:00,691 - build - model_api - INFO - setup_topobathy.crs: utm
2022-07-01 15:21:00,691 - build - model_api - INFO - setup_topobathy.reproj_method: bilinear
2022-07-01 15:21:00,804 - build - data_adapter - INFO - Adding sample data v0.0.6 from artifacts
2022-07-01 15:21:00,996 - build - data_adapter - INFO - DataCatalog: Getting merit_hydro RasterDataset raster data from /home/runner/.hydromt_data/data/v0.0.6/merit_hydro/{variable}.tif
2022-07-01 15:21:01,022 - build - data_adapter - DEBUG - RasterDataset: Clip with geom - [12.032, 45.282, 12.863, 45.668]
2022-07-01 15:21:01,087 - build - model_api - INFO - setup_merge_topobathy.topobathy_fn: gebco
2022-07-01 15:21:01,088 - build - model_api - INFO - setup_merge_topobathy.elv_min: None
2022-07-01 15:21:01,088 - build - model_api - INFO - setup_merge_topobathy.elv_max: None
2022-07-01 15:21:01,088 - build - model_api - INFO - setup_merge_topobathy.mask_fn: osm_coastlines
2022-07-01 15:21:01,088 - build - model_api - INFO - setup_merge_topobathy.max_width: 0
2022-07-01 15:21:01,088 - build - model_api - INFO - setup_merge_topobathy.offset_fn: dtu10mdt_egm96
2022-07-01 15:21:01,088 - build - model_api - INFO - setup_merge_topobathy.offset_constant: 0
2022-07-01 15:21:01,088 - build - model_api - INFO - setup_merge_topobathy.merge_buffer: 2
2022-07-01 15:21:01,088 - build - model_api - INFO - setup_merge_topobathy.merge_method: first
2022-07-01 15:21:01,088 - build - model_api - INFO - setup_merge_topobathy.reproj_method: bilinear
2022-07-01 15:21:01,088 - build - model_api - INFO - setup_merge_topobathy.interp_method: linear
2022-07-01 15:21:01,092 - build - data_adapter - INFO - DataCatalog: Getting gebco RasterDataset raster data from /home/runner/.hydromt_data/data/v0.0.6/gebco.tif
2022-07-01 15:21:01,105 - build - data_adapter - DEBUG - RasterDataset: Clip with geom - [12.031, 45.282, 12.862, 45.667]
2022-07-01 15:21:01,124 - build - data_adapter - INFO - DataCatalog: Getting osm_coastlines GeoDataFrame vector data from /home/runner/.hydromt_data/data/v0.0.6/osm_coastlines.gpkg
2022-07-01 15:21:01,124 - build - data_adapter - INFO - GeoDataFrame: Read vector data.
2022-07-01 15:21:01,194 - build - data_adapter - INFO - DataCatalog: Getting dtu10mdt_egm96 RasterDataset raster data from /home/runner/.hydromt_data/data/v0.0.6/dtu10mdt_egm96.tif
2022-07-01 15:21:01,207 - build - data_adapter - DEBUG - RasterDataset: Clip with geom - [12.031, 45.282, 12.862, 45.667]
2022-07-01 15:21:01,634 - build - bathymetry - DEBUG - Interpolate topobathy at 1075 cells
2022-07-01 15:21:04,785 - build - model_api - INFO - setup_mask.mask_fn: None
2022-07-01 15:21:04,785 - build - model_api - INFO - setup_mask.include_mask_fn: None
2022-07-01 15:21:04,785 - build - model_api - INFO - setup_mask.exclude_mask_fn: None
2022-07-01 15:21:04,786 - build - model_api - INFO - setup_mask.elv_min: -5
2022-07-01 15:21:04,786 - build - model_api - INFO - setup_mask.elv_max: None
2022-07-01 15:21:04,786 - build - model_api - INFO - setup_mask.fill_area: 10
2022-07-01 15:21:04,786 - build - model_api - INFO - setup_mask.drop_area: 0
2022-07-01 15:21:04,786 - build - model_api - INFO - setup_mask.connectivity: 8
2022-07-01 15:21:04,786 - build - model_api - INFO - setup_mask.all_touched: True
2022-07-01 15:21:04,786 - build - model_api - INFO - setup_mask.reset_mask: False
2022-07-01 15:21:04,810 - build - utils - DEBUG - 0 gaps outside valid elevation range < 10 km2.
2022-07-01 15:21:04,811 - build - sfincs - DEBUG - Mask with 79345 active cells set; updating staticmaps ...
2022-07-01 15:21:04,819 - build - sfincs - DEBUG - Derive region geometry based on active cells.
2022-07-01 15:21:04,830 - build - model_api - INFO - setup_cn_infiltration.cn_fn: gcn250
2022-07-01 15:21:04,830 - build - model_api - INFO - setup_cn_infiltration.antecedent_runoff_conditions: avg
2022-07-01 15:21:04,830 - build - data_adapter - INFO - DataCatalog: Getting gcn250 RasterDataset raster data from /home/runner/.hydromt_data/data/v0.0.6/gcn250/{variable}.tif
2022-07-01 15:21:04,842 - build - data_adapter - DEBUG - RasterDataset: Clip with geom - [12.031, 45.282, 12.852, 45.667]
2022-07-01 15:21:04,903 - build - model_api - INFO - setup_manning_roughness.lulc_fn: vito
2022-07-01 15:21:04,904 - build - model_api - INFO - setup_manning_roughness.map_fn: None
2022-07-01 15:21:04,904 - build - model_api - INFO - setup_manning_roughness.riv_man: 0.03
2022-07-01 15:21:04,904 - build - model_api - INFO - setup_manning_roughness.lnd_man: 0.1
2022-07-01 15:21:04,904 - build - model_api - INFO - setup_manning_roughness.sea_man: None
2022-07-01 15:21:04,905 - build - data_adapter - INFO - DataCatalog: Getting vito RasterDataset raster data from /home/runner/.hydromt_data/data/v0.0.6/vito.tif
2022-07-01 15:21:04,917 - build - data_adapter - DEBUG - RasterDataset: Clip with geom - [12.031, 45.282, 12.852, 45.667]
2022-07-01 15:21:04,949 - build - landuse - INFO - Deriving N using average resampling (nodata=-999.0).
2022-07-01 15:21:05,081 - build - model_api - INFO - setup_bounds.btype: waterlevel
2022-07-01 15:21:05,082 - build - model_api - INFO - setup_bounds.mask_fn: osm_coastlines
2022-07-01 15:21:05,082 - build - model_api - INFO - setup_bounds.include_mask_fn: None
2022-07-01 15:21:05,082 - build - model_api - INFO - setup_bounds.exclude_mask_fn: None
2022-07-01 15:21:05,082 - build - model_api - INFO - setup_bounds.elv_min: None
2022-07-01 15:21:05,082 - build - model_api - INFO - setup_bounds.elv_max: None
2022-07-01 15:21:05,082 - build - model_api - INFO - setup_bounds.mask_buffer: 0
2022-07-01 15:21:05,082 - build - model_api - INFO - setup_bounds.connectivity: 8
2022-07-01 15:21:05,082 - build - model_api - INFO - setup_bounds.reset_bounds: False
2022-07-01 15:21:05,088 - build - data_adapter - INFO - DataCatalog: Getting osm_coastlines GeoDataFrame vector data from /home/runner/.hydromt_data/data/v0.0.6/osm_coastlines.gpkg
2022-07-01 15:21:05,091 - build - data_adapter - INFO - GeoDataFrame: Read vector data and clip to bbox (epsg:4326) [12.031, 45.282, 12.852, 45.667].
2022-07-01 15:21:05,135 - build - sfincs - DEBUG - 510 waterlevel (mask=2) boundary cells set.
2022-07-01 15:21:05,136 - build - model_api - INFO - setup_h_forcing.geodataset_fn: /home/runner/work/hydromt_sfincs/hydromt_sfincs/docs/_examples/data/gtsm_locations.csv
2022-07-01 15:21:05,136 - build - model_api - INFO - setup_h_forcing.timeseries_fn: /home/runner/work/hydromt_sfincs/hydromt_sfincs/docs/_examples/data/gtsm_timeseries.csv
2022-07-01 15:21:05,136 - build - model_api - INFO - setup_h_forcing.offset_fn: None
2022-07-01 15:21:05,136 - build - model_api - INFO - setup_h_forcing.buffer: 10000.0
2022-07-01 15:21:05,148 - build - data_adapter - INFO - DataCatalog: Getting gtsm_locations GeoDataset vector data from /home/runner/work/hydromt_sfincs/hydromt_sfincs/docs/_examples/data/gtsm_locations.csv
2022-07-01 15:21:05,560 - build - data_adapter - INFO - GeoDataset: Read vector data and clip to geom (epsg:32633) [278900.000, 5008550.000, 342400.000, 5059900.000].
2022-07-01 15:21:05,579 - build - data_adapter - DEBUG - GeoDataset: Slicing time dim (datetime.datetime(2010, 2, 1, 0, 0), datetime.datetime(2010, 2, 10, 0, 0))
2022-07-01 15:21:05,584 - build - sfincs - DEBUG - waterlevel forcing: setting bnd data for 6 points.
2022-07-01 15:21:05,584 - build - sfincs - DEBUG - waterlevel forcing: setting bzs data.
2022-07-01 15:21:05,584 - build - model_api - INFO - setup_p_forcing_from_grid.precip_fn: era5_hourly
2022-07-01 15:21:05,584 - build - model_api - INFO - setup_p_forcing_from_grid.dst_res: None
2022-07-01 15:21:05,584 - build - model_api - INFO - setup_p_forcing_from_grid.aggregate: True
2022-07-01 15:21:05,584 - build - data_adapter - INFO - DataCatalog: Getting era5_hourly RasterDataset netcdf data from /home/runner/.hydromt_data/data/v0.0.6/era5_hourly.nc
2022-07-01 15:21:05,607 - build - data_adapter - DEBUG - RasterDataset: Slicing time dim (datetime.datetime(2010, 2, 1, 0, 0), datetime.datetime(2010, 2, 10, 0, 0))
2022-07-01 15:21:05,615 - build - data_adapter - DEBUG - RasterDataset: Clip with geom - [12.031, 45.282, 12.852, 45.667]
2022-07-01 15:21:05,634 - build - data_adapter - DEBUG - RasterDataset: Convert units for 1 variables.
2022-07-01 15:21:05,641 - build - sfincs - DEBUG - Aggregate precip using mean.
2022-07-01 15:21:05,675 - build - sfincs - INFO - Writing model data to /home/runner/work/hydromt_sfincs/hydromt_sfincs/docs/_examples/venice_sfincs_150
2022-07-01 15:21:05,711 - build - sfincs - DEBUG - Write binary map indices based on mask.
2022-07-01 15:21:05,713 - build - sfincs - DEBUG - Write binary map files: ['dep', 'msk', 'scs', 'manning'].
2022-07-01 15:21:05,749 - build - sfincs - INFO - Write raster file(s) for staticmaps to 'gis' subfolder
2022-07-01 15:21:05,851 - build - sfincs - INFO - Write staticgeom files
2022-07-01 15:21:05,851 - build - sfincs - INFO - Write vector file(s) for staticgeoms to 'gis' subfolder
2022-07-01 15:21:05,862 - build - sfincs - INFO - Write forcing files
2022-07-01 15:21:05,885 - build - sfincs - INFO - Write vector file(s) for forcing.bzs to 'gis' subfolder
2022-07-01 15:21:05,899 - build - model_api - INFO - Writing model config to /home/runner/work/hydromt_sfincs/hydromt_sfincs/docs/_examples/venice_sfincs_150/sfincs.inp

Let’s inspect the output folder. Notice that several SFINCS files have been written.

[9]:
!ls ./venice_sfincs_150
gis               sfincs.bnd  sfincs.ind  sfincs.msk
hydromt.log       sfincs.bzs  sfincs.inp  sfincs.precip
hydromt_data.yml  sfincs.dep  sfincs.man  sfincs.scs

One of the files is the SFINCS input file which defines the model, lets have a look:

[10]:
fn_inp = "./venice_sfincs_150/sfincs.inp"
with open(fn_inp, "r") as f:
    txt = f.read()

print(txt)
mmax            = 425
nmax            = 272
dx              = 150.0
dy              = 150.0
x0              = 268650.0
y0              = 5018550.0
rotation        = 0
epsg            = 32633
inputformat     = bin
outputformat    = net
tref            = 20100201 000000
tstart          = 20100201 000000
tstop           = 20100210 000000
dtout           = 3600
dthisout        = 600
dtmaxout        = 86400
advection       = 0
alpha           = 0.5
huthresh        = 0.05
theta           = 0.9
min_lev_hmax    = -1
zsini           = 0.5
depfile         = sfincs.dep
mskfile         = sfincs.msk
indexfile       = sfincs.ind
scsfile         = sfincs.scs
manningfile     = sfincs.man
precipfile      = sfincs.precip
bzsfile         = sfincs.bzs
bndfile         = sfincs.bnd


Inspecting the model

Let’s have a closer look at the model. To interact with a model within a notebook or python script, we need to load a number of modules.

[11]:
%matplotlib inline
from hydromt_sfincs import SfincsModel

Now we can load the model in memory and inspect it.

Note that based on the global datasets the lagoon bathymetry is not well represented. A better merge between MERIT hydro topography and GEBCO bathymetry can be achieved by providing an better coastline shapefile (by default OSM based) which together with the merge_method argument determines which dataset is used where.

[12]:
# define the model's configuration file
root = r"./venice_sfincs_150"

# read the model with hydromt methods
mod = SfincsModel(root=root, mode="r")
mod.read()
mod.plot_basemap(figsize=(13, 7), shaded=False)
[12]:
(<Figure size 936x504 with 2 Axes>,
 <GeoAxesSubplot:title={'center':'SFINCS dep map'}, xlabel='x coordinate UTM zone 33N [m]', ylabel='y coordinate UTM zone 33N [m]'>)
../_images/_examples_build_coastal_model_30_1.png

Next steps

You can update an existing model, e.g. to replace model layers or add forcing. this is described in a follow-up notebook sfincs_update_model.ipynb