API#
SFINCS Model class#
The hydromt_sfincs.SfincsModel class is the main entry point to read, write, build, and update SFINCS models using HydroMT.
It uses the functionalities provided by the reusable components defined in the hydromt_sfincs.components module.
|
SFINCS model class. |
Methods#
Read SfincsModel from disk. |
|
Write SfincsModel to disk. |
|
|
Single method to build a model from scratch based on settings in steps. |
|
Single method to update a model based the settings in steps. |
Plot methods#
|
Create basemap plot. |
|
Plot model timeseries forcing. |
Attributes#
Model root |
|
Returns the model crs |
|
Returns the geometry of the active model cells. |
|
Returns the bounding box in WGS 84 of the model grid. |
Components#
The hydromt_sfincs.components module defines reusable data container classes
that represent configuration, grid, geometries, boundary conditions, outputs,
and other model data.
Configuration#
" Class to read and write SFINCS configuration files (sfincs.inp). |
|
Return the Pydantic SfincsConfigVariables object. |
|
Read a text file with the sfincs configuration from the root folder and populate the SfincsConfigVariables. |
|
Write the SfincsConfigVariables to a text file in the root folder of the model. |
|
Update attributes using a dictionary or keyword arguments. |
|
Update the grid properties from the configuration. |
|
|
Get the value for a specific key with validation check. |
|
Set a value for a specific key with validation using Pydantic's model_validate. |
Return the absolute file path for a given 'key'. |
|
Create a new model by parsing and validating input data from keyword arguments. |
Grid#
|
Regular grid component of the SfincsModel class. |
Model static gridded data as xarray.Dataset. |
|
|
Read SFINCS binary grid files and save to data attribute. |
|
Write SFINCS grid to binary files including map index file. |
|
Create a regular grid for the SfincsModel. |
Create a regular grid for the SfincsModel based on a region. |
|
SFINCS Elevation Component. |
|
Interpolate topobathy (dep) data to the model grid. |
|
|
SFINCS Mask Component. |
Create an integer mask with inactive (mask=0) and active (mask=1) cells, optionally bounded by several criteria. |
|
Set boundary cells in the model mask. |
|
SFINCS Roughness Component. |
|
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. |
|
SFINCS Infiltration Component. |
|
Create spatially varying constant infiltration rate (qinffile). |
|
Create model potential maximum soil moisture retention map (scsfile) from gridded curve number map. |
|
|
Create model the Soil Conservation Service (SCS) Curve Number (CN) files for SFINCS including recovery term based on the soil saturation |
SFINCS Initial Conditions Component. |
|
Setup spatially varying initial water level (inifile). |
|
SFINCS Storage Volume Component. |
|
Create storage volume. |
|
|
SFINCS Subgrid Table Component. |
Model static gridded data as xarray.Dataset. |
|
Load subgrid table from file for a regular grid with given mask. |
|
Write subgrid table to file for a regular grid with given mask. |
|
Create method for subgrid tables based on a list of elevation and Manning's roughness datasets. |
Geometries#
SFINCS Observation Points Component. |
|
Observation point data, returned as a GeoDataFrame. |
|
Read SFINCS observation points (.obs) file. |
|
Write SFINCS observation points (.obs) file, and set obsfile in config (if it was not already set) |
|
Create model observation point locations. |
|
SFINCS Cross-Sections Component. |
|
Cross-section lines data, returned as a GeoDataFrame. |
|
Read ascii SFINCS cross-sections (.crs) file. |
|
Write ascii SFINCS cross-sections (.crs) file, and set crsfile in config (if it was not already set). |
|
Create model cross-sections (old name: setup_observation_lines) |
|
SFINCS thin dams geometry component. |
|
Thin dam data, returned as a GeoDataFrame. |
|
Read SFINCS thin dams (.thd) file. |
|
Write SFINCS thin dams (.thd) file, and set thdfile in config (if it was not already set) |
|
Create model thin dams (old name: setup_structures). |
|
SFINCS weir geometry component. |
|
Weirs lines data, returned as a GeoDataFrame. |
|
Read SFINCS weir (.weir) file. |
|
Write SFINCS weir (.weir) file, and set weirfile in config (if it was not already set). |
|
Create model weir lines (old name: setup_structures). |
|
SFINCS drainage structures component. |
|
Drainage structures data, returns geopandas.GeoDataFrame |
|
Read SFINCS drainage structures (.drn) file. |
|
Write SFINCS drainage structures (.drn) file, and make sure drnfile is in config (if it was not already set). |
|
Create drainage structures such as pumps, culverts, or valves (old name: setup_drainage_structures). |
Forcing#
Water level boundary component for SFINCS models. |
|
Get the internal xarray dataset/dataarray containing point timeseries and geometry information. |
|
Read SFINCS boundary conditions (.bnd, .bzs, .bca files) or netcdf file. |
|
Write SFINCS boundary conditions (.bnd, .bzs, .bca files) or netcdf file. |
|
Setup waterlevel forcing. |
|
|
Applies time series boundary conditions for each point Create numpy datetime64 array for time series with python datetime.datetime objects |
|
Generates boundary time series file from astronomical components |
|
Get boundary points from mask in quadtree grid. |
Discharge point component for SFINCS models. |
|
Get the internal xarray dataset/dataarray containing point timeseries and geometry information. |
|
Read SFINCS discharge points (.dis, .src files) or netcdf file. |
|
Write SFINCS discharges (.src, .dis files) or netcdf file. |
|
Setup discharge forcing. |
|
|
Applies time series discharges for each point Create numpy datetime64 array for time series with python datetime.datetime objects |
SFINCS precipitation forcing. |
|
Meteo data. |
|
Read precipitation data from file. |
|
Write meteo data to file. |
|
Setup precipitation forcing from a gridded spatially varying data source. |
|
|
Setup spatially uniform precipitation forcing (precip). |
Meteo data. |
|
Read meteo data from file. |
|
Write meteo data to file. |
|
Setup pressure forcing from a gridded spatially varying data source. |
|
Meteo data. |
|
|
Read meteo data from file. |
Write meteo data to file. |
|
|
Setup wind forcing from a gridded spatially varying data source. |
Setup spatially uniform wind forcing (wind). |
|
This class contains functions to create and manage river inflow/outflow points in the SFINCS model. |
|
River geometry data. |
|
Read the file(s) into the component. |
|
Write the river inflow data to a gis-file. |
|
Setup discharge (src) points where a river enters the model domain. |
Output#
SFINCS model output component. |
SFINCS workflows#
|
Merge a list of data arrays by reprojecting these to a common destination grid and combine valid values. |
|
Return merged data from two data arrays. |
|
Burn rivers with a rectangular cross profile into a DEM. |
|
Snaps point locations to grid cell with smallest difference in upstream area within wdw around the original location if the local cell does not meet the error criteria. |
|
Returns the locations where a river flows in (inflow=True) or out (inflow=False) of the model gdf_mask. |
Returns the centerline of rivers based on a flow direction raster data (da_flwdir). |
|
Landuse related workflows for SFINCS. |
|
|
Convert Curve Numbers to potential maximum soil moisture retention S [inch]. |
|
Create webmercator topobathy tiles for a given region. |
SFINCS low-level methods#
Input/Output methods#
|
Read binary map. |
|
Write binary map file. |
|
Read binary map index file. |
|
Write flat index of binary map file. |
Read ascii map |
|
|
Write ascii map |
|
Read ascii timeseries files such as sfincs.bzs, sfincs.dis and sfincs.precip. |
|
Write pandas.DataFrame to fixed width ascii timeseries files such as sfincs.bzs, sfincs.dis and sfincs.precip. |
|
Read sfincs xy files and parse to GeoDataFrame. |
|
Write geopandas.GeoDataFrame with Point geometries to point xy files. |
|
|
|
|
|
Read structure files to list of dictionaries. |
|
Write list of structure dictionaries to file |
|
Read drainage structure files to geodataframe. |
|
Write structure files from list of dictionaries. |
|
Read sfincs_map.nc staggered grid netcdf files and parse to two hydromt.RasterDataset objects: one with face and one with edge variables. |
|
Read sfincs_his.nc point timeseries netcdf file and parse to hydromt.GeoDataset object. |
Utilities#
|
Checks and/or parses datetime from a string, default sfincs datetime string format |
|
Convert GeoDataFrame[LineString] to list of structure dictionaries |
|
Convert list of structure dictionaries to GeoDataFrame[LineString] |
|
Convert GeoDataFrame[Polygon] to list of structure dictionaries |
|
Convert list of structure dictionaries to GeoDataFrame[Polygon] |
|
Get bounds of vectorized mask as GeoDataFrame. |
|
Convert a boolean mask to a GeoDataFrame of polygons. |
|
Returns the origin (x0, y0), shape (mmax, nmax) and rotation of the rotated grid fitted to the minimum rotated rectangle around the area of interest (pol). |
Visualization#
|
Create basemap plot. |
|
Plot model timeseries forcing. |
|
Create a downscaled floodmap for (model) region. |
Create a downscaled floodmap for (model) region in webmercator tile format |