API reference#
Command Line Interface#
Main command line interface of HydroMT. |
|
Build a model. |
|
Update an existing model. |
|
Clip/Extract a submodel from an existing model. |
|
Export data extract from a data catalog. |
|
Check if data catalog or configuration file are valid. |
Data#
Data catalog#
General#
|
Base class for the data catalog object. |
Return a data source. |
|
Return a flat list of all available data sources. |
|
Returns dictionary of DataAdapter sources. |
|
Returns list of data source names. |
|
Return all predefined catalogs. |
|
Export the data catalog to a dictionary. |
|
Return data catalog summary as DataFrame. |
|
|
Write data catalog to yaml format. |
|
Export a data slice of each dataset and a data_catalog.yml file to disk. |
Retrieve the bounding box and crs of the source. |
|
Detect the temporal range of the dataset. |
Add data sources#
|
Add a new data source to the data catalog. |
|
Add data sources to library or update them. |
Add data sources from a predefined data catalog. |
|
Read and cache a data archive including a data_catalog.yml file. |
|
|
Add data sources based on yaml file. |
|
Add data sources based on dictionary. |
Initialise the predefined catalogs. |
Get data#
Return a clipped, sliced and unified RasterDataset. |
|
Return a clipped, sliced and unified GeoDataset. |
|
Return a clipped and unified GeoDataFrame (vector). |
|
|
Return a unified and sliced DataFrame. |
|
Return a clipped, sliced and unified Dataset. |
DataAdapter#
General#
|
General Interface to data source for HydroMT. |
Return a dictionary summary of the data adapter. |
|
Return a dictionary view of the data source. |
RasterDataset#
|
Implementation for the RasterDatasetAdapter. |
Return a dictionary summary of the data adapter. |
|
Return a clipped, sliced and unified RasterDataset. |
|
Return a dictionary view of the data source. |
|
Save a data slice to file. |
|
Return the bounding box and espg code of the dataset. |
|
Detect the time range of the dataset. |
|
Detect the bounding box and crs of the dataset. |
|
Detect the temporal range of the dataset. |
|
Convert a rasterdataset into a STAC Catalog representation. |
GeoDataset#
|
DatasetAdapter for GeoDatasets. |
Return a dictionary summary of the data adapter. |
|
Return a clipped, sliced and unified GeoDataset. |
|
Return a dictionary view of the data source. |
|
Save a data slice to file. |
|
|
Return the bounding box and espg code of the dataset. |
Detect the time range of the dataset. |
|
Detect the bounding box and crs of the dataset. |
|
Detect the temporal range of the dataset. |
|
Convert a geodataset into a STAC Catalog representation. |
GeoDataFrame#
|
The Geodataframe adapter implementation. |
Return a dictionary summary of the data adapter. |
|
Return a clipped and unified GeoDataFrame (vector). |
|
Return a dictionary view of the data source. |
|
Save a data slice to file. |
|
Return the bounding box and espg code of the dataset. |
|
Detect the bounding box and crs of the dataset. |
|
Convert a geodataframe into a STAC Catalog representation. |
DataFrame#
|
DataAdapter implementation for Pandas Dataframes. |
Return a dictionary summary of the data adapter. |
|
Return a DataFrame. |
|
Return a dictionary view of the data source. |
|
|
Save a dataframe slice to a file. |
Convert a dataframe into a STAC Catalog representation. |
Dataset#
|
DatasetAdapter for non-spatial n-dimensional data. |
Return a dictionary summary of the data adapter. |
|
Return a clipped, sliced and unified Dataset. |
|
Return a dictionary view of the data source. |
|
|
Save a dataset slice to file. |
Convert a dataset into a STAC Catalog representation. |
Models#
Discovery#
The model catalogue provides access to plugins and their Model classes. |
Model#
Note that the base Model attributes and methods are available to all models.
|
General and basic API for models in HydroMT. |
High level methods#
|
Read the complete model schematization and configuration from model files. |
|
Write the complete model schematization and configuration to model files. |
|
Single method to build a model from scratch based on settings in opt. |
|
Single method to update a model based the settings in opt. |
|
Initialize the model root. |
|
Write the data catalog to data_lib_fn. |
Model attributes#
Returns coordinate reference system embedded in region. |
|
Returns the geometry of the model area of interest. |
|
Path to model folder. |
|
Model components and attributes#
Model configuration. |
|
Model maps. |
|
Model geometries. |
|
Model forcing. |
|
Model states. |
|
Model results. |
General methods#
|
Get a config value at key(s). |
|
Update the config dictionary at key(s) with values. |
|
Parse config from file. |
|
Write config to <root/config_fn>. |
|
Add raster data to the maps component. |
|
Read model map at <root>/<fn> and add to maps component. |
|
Write maps to netcdf file at <root>/<fn>. |
|
Add data to the geoms attribute. |
|
Read model geometries files at <root>/<fn> and add to geoms property. |
|
Write model geometries to a vector file (by default GeoJSON) at <root>/<fn>. |
|
Add data to forcing attribute. |
|
Read forcing at <root>/<fn> and add to forcing property. |
|
Write forcing to netcdf file at <root>/<fn>. |
|
Add data to states attribute. |
|
Read states at <root>/<fn> and add to states property. |
|
Write states to netcdf file at <root>/<fn>. |
|
Add data to results attribute. |
|
Read results at <root>/<fn> and add to results property. |
|
Read netcdf files at <root>/<fn> and return as dict of xarray.Dataset. |
|
Write dictionnary of xarray.Dataset and/or xarray.DataArray to netcdf files. |
Setup methods#
|
Update config with a dictionary. |
|
Set the region of interest of the model. |
|
HYDROMT CORE METHOD: Add data variable(s) from |
|
HYDROMT CORE METHOD: Add data variable(s) to maps object by reclassifying the data in |
GridModel#
|
Model class Grid Model for gridded models in HydroMT. |
Components and attributes#
Model static gridded data as xarray.Dataset. |
|
Returns coordinate reference system embedded in the model grid. |
|
Returns the geometry of the model area of interest. |
General methods#
|
Add data to grid. |
|
Read model grid data at <root>/<fn> and add to grid property. |
|
Write model grid data to netcdf file at <root>/<fn>. |
Setup methods#
|
Update config with a dictionary. |
|
Set the region of interest of the model. |
HYDROMT CORE METHOD: Add data variable(s) from |
|
HYDROMT CORE METHOD: Add data variable(s) to maps object by reclassifying the data in |
|
|
HYDROMT CORE METHOD: Create a 2D regular grid or reads an existing grid. |
|
HYDROMT CORE METHOD: Adds a grid based on a constant value. |
HYDROMT CORE METHOD: Add data variable(s) from |
|
HYDROMT CORE METHOD: Add data variable(s) to grid object by reclassifying the data in |
|
|
HYDROMT CORE METHOD: Add data variable(s) to grid object by rasterizing the data from |
VectorModel#
|
Model class Vector Model for vector (polygons) models in HydroMT. |
Components and attributes#
Model vector (polygon) data. |
|
Returns coordinate reference system embedded in region. |
|
Returns the geometry of the model area of interest. |
General methods#
|
Add data to vector. |
|
Read model vector from combined netcdf and geojson file. |
|
Write model vector to combined netcdf and geojson files. |
Setup methods#
|
Update config with a dictionary. |
|
Set the region of interest of the model. |
HYDROMT CORE METHOD: Add data variable(s) from |
|
HYDROMT CORE METHOD: Add data variable(s) to maps object by reclassifying the data in |
MeshModel#
|
Model class Mesh Model for mesh models in HydroMT. |
Components and attributes#
Model static mesh data. |
|
List of grid names in mesh. |
|
Dictionnary of grid names and Ugrid topologies in mesh. |
|
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. |
|
Returns model mesh crs. |
|
Returns geometry of region of the model area of interest based on mesh total bounds. |
|
Returns model mesh bounds. |
General methods#
|
Add data to mesh. |
|
Return a specific grid topology from mesh based on grid_name. |
|
Read model mesh data at <root>/<fn> and add to mesh property. |
|
Write model grid data to a netCDF file at <root>/<fn>. |
Setup methods#
|
Update config with a dictionary. |
|
Set the region of interest of the model. |
|
HYDROMT CORE METHOD: Create an 2D unstructured mesh or reads an existing 2D mesh according UGRID conventions. |
HYDROMT CORE METHOD: Add data variable(s) from |
|
HYDROMT CORE METHOD: Add data variable(s) to 2D |
|
HYDROMT CORE METHOD: Add data variable(s) from |
|
HYDROMT CORE METHOD: Add data variable(s) to maps object by reclassifying the data in |
Workflows#
Grid#
|
Prepare a grid based on a constant value. |
Prepare data by resampling ds to grid_like. |
|
Prepare data variable(s) resampled to grid_like object by reclassifying the data in |
|
|
Prepare data variable(s) resampled to grid_like object by rasterizing the data from |
Mesh#
|
Create an 2D unstructured mesh or reads an existing 2D mesh. |
Resamples data in ds to mesh2d. |
|
Resample data to |
Basin mask#
Return a geometry of the (sub)(inter)basin(s). |
|
|
Check and return parsed region arguments. |
River bathymetry#
|
Return average river width along a segment based on a river mask raster. |
|
Derive river depth estimates based bankfull discharge. |
Forcing#
Data handling#
|
Return the lazy reprojection of precipitation to model. |
|
Return lazy reprojection of temperature to model grid. |
|
Return lazy reprojection of pressure to model grid. |
|
Determine reference evapotranspiration. |
|
Return lazy reprojection of wind speed to model grid. |
Correction methods#
|
Pressure correction based on elevation lapse_rate. |
|
Temperature correction based on elevation data. |
Time resampling methods#
|
Resample data to destination frequency. |
|
Return relative difference between dataset mean timestep and destination freq. |
Computation methods#
PET
|
Determine De Bruin (2016) reference evapotranspiration. |
|
Determnines Makkink reference evapotranspiration. |
|
Estimate daily reference evapotranspiration (ETo). |
Reading/writing methods#
Reading methods#
|
Open a gdal-readable file with rasterio based on. |
|
Open multiple gdal-readable files as single Dataset with geospatial attributes. |
|
Read and merge raster tiles. |
|
Open fiona-compatible geometry, csv, parquet, excel or xy file and parse it. |
|
Read point geometry files from csv, parquet, xy or excel table files. |
|
Open and combine geometry location GIS file and timeseries file in a xr.Dataset. |
|
Open timeseries csv or parquet file and parse to xarray.DataArray. |
Raster writing methods#
|
Export rasterdataset to tiles in a xyz structure. |
|
Produce tiles in /zoom/x/y.<ext> structure (EPSG:3857). |
|
Write DataArray object to a gdal-writable raster file. |
|
Write the Dataset object to one gdal-writable raster files per variable. |
Raster methods#
High level methods#
|
Merge multiple tiles to a single DataArray. |
|
Return a full DataArray based on a geospatial coords dictionary. |
|
Return a full object with the same grid and geospatial attributes as |
|
Return a full DataArray based on a geospatial transform and shape. |
|
Transform a 2D/3D numpy array into a DataArray with geospatial attributes. |
|
Transform multiple numpy arrays to a Dataset object. |
Attributes#
Return dictionary of spatial attributes. |
|
Return horizontal Coordinate Reference System. |
|
Return the bounds (xmin, ymin, xmax, ymax) of the object. |
|
Return the affine transform of the object. |
|
Return resolution (x, y) tuple. |
|
Return rotation of grid (degrees). |
|
Return origin of grid (x0, y0) tuple. |
|
Nodata value of the DataArray. |
|
Return tuple of geospatial dimensions names. |
|
Return dict of geospatial dimensions coordinates. |
|
Return the non geospatial dimension name. |
|
Return the y dimension name. |
|
Return the x dimension name. |
|
Return the x coordinates. |
|
Return the y coordinates. |
|
Return shape of geospatial dimension (height, width). |
|
Return size of geospatial grid. |
|
Return the width of the object (x dimension size). |
|
Return the height of the object (y dimension size). |
|
Return the internal bounds (left, bottom, right, top) the object. |
|
Return |
General methods#
|
Set the Coordinate Reference System. |
|
Set the geospatial dimensions of the object. |
Reset spatial dimension names and attributes. |
|
Return True if other has an same grid as object (crs, transform, shape). |
|
Check if other grid aligns with object grid (crs, resolution, origin). |
|
Update attributes to get GDAL compliant NetCDF files. |
|
|
Return x,y coordinates at linear index. |
|
Return linear index of x, y coordinates. |
|
Return row, col indices of x, y coordinates. |
|
Return x,y coordinates at cell center of row, col indices. |
Return raster flipped along y dimension. |
|
|
Return the grid cell area [m2]. |
Return the density in [unit/m2] of raster(s). |
|
|
Reclass columns in df from raster map (DataArray). |
Nodata handling and interpolation#
|
Set the nodata value as CF compliant attribute of the DataArray. |
|
Mask nodata values with fill_value (default np.nan). |
|
Interpolate missing data. |
Clip#
|
Clip object based on slices. |
|
Clip object based on a bounding box. |
|
Clip object to region with mask values greater than zero. |
|
Clip object to bounding box of the geometry. |
Reproject#
|
Reproject a DataArray with geospatial coordinates. |
|
Return reprojected DataArray object based on simple reindexing. |
|
Reproject a object to match the grid of |
|
Transform bounds from object to destination CRS. |
|
Prepare nearest index mapping for reprojection of a gridded timeseries file. |
Transform#
|
Return an object with input geometry values burned in. |
|
Return an object with the fraction of the grid cells covered by geometry. |
|
Return a grid with True values where shapes overlap pixels. |
|
Return geometry of grouped pixels with the same value in a DataArray object. |
|
Return a vector representation of the grid. |
Sampling and zonal stats#
|
Sample from map at point locations with optional window around the points. |
|
Calculate zonal statistics of raster samples aggregated for geometries. |
Low level methods#
|
Provide CF-compliant variable names and metadata for axes. |
|
Shift data along the x-axis of global datasets to avoid issues along the 180 meridian. |
GeoDataset methods#
High level methods#
|
Parse GeoDataFrame object with point geometries to DataArray. |
|
Return geopandas GeoDataFrame with Point geometry. |
|
Read netcdf file or convert xr.DataArray as GeoDataArray. |
|
Export geodataset vectordata to an ogr compliant netCDF4 file. |
|
Create Dataset with geospatial coordinates. |
|
Return geopandas GeoDataFrame with Point geometry. |
|
Create GeoDataset from ogr compliant netCDF4 file or xr.Dataset. |
|
Export geodataset vectordata to an ogr compliant netCDF4 file. |
Attributes#
Return dictionary of spatial attributes. |
|
Return horizontal Coordinate Reference System. |
|
Index dimension name. |
|
Time dimension name. |
|
Name of x coordinate; only for point geometries in xy format. |
|
Name of y coordinate; only for point geometries in xy format. |
|
Name of geometry coordinate; only for 'wkt' and 'geom' formats. |
|
Return geometry type. |
|
Name of geometry coordinate; only for 'wkt' and 'geom' formats. |
|
Return the index values. |
|
Return the bounds (xmin, ymin, xmax, ymax) of the object. |
|
Return the length of the index array. |
|
Return the spatial index of the geometry. |
|
Return the geometry of the dataset or array as GeoSeries. |
|
Return dictionary of spatial attributes. |
|
Return horizontal Coordinate Reference System. |
|
Index dimension name. |
|
Time dimension name. |
|
Name of x coordinate; only for point geometries in xy format. |
|
Name of y coordinate; only for point geometries in xy format. |
|
Name of geometry coordinate; only for 'wkt' and 'geom' formats. |
|
Return geometry type. |
|
Name of geometry coordinate; only for 'wkt' and 'geom' formats. |
|
Return the index values. |
|
Return the bounds (xmin, ymin, xmax, ymax) of the object. |
|
Return the length of the index array. |
|
Return the spatial index of the geometry. |
|
Return the geometry of the dataset or array as GeoSeries. |
Conversion#
|
Create a Dataset/Array which is understood by OGR. |
|
Update the geometry in the Dataset/Array with a new geometry. |
|
Convert Dataset/ DataArray with xy or wkt geometries to shapely Geometries. |
|
Convert Dataset/ DataArray with Point geometries to x,y structure. |
|
Convert geometries in Dataset/DataArray to wkt strings. |
|
Create a Dataset/Array which is understood by OGR. |
|
Update the geometry in the Dataset/Array with a new geometry. |
|
Convert Dataset/ DataArray with xy or wkt geometries to shapely Geometries. |
|
Convert Dataset/ DataArray with Point geometries to x,y structure. |
|
Convert geometries in Dataset/DataArray to wkt strings. |
General methods#
|
Set the Coordinate Reference System. |
Set the spatial and index dimensions of the object. |
|
|
Set the Coordinate Reference System. |
|
Set the spatial and index dimensions of the object. |
Clip#
|
Select point locations to bounding box. |
|
Select all geometries that intersect with the input geometry. |
|
Select point locations to bounding box. |
|
Select all geometries that intersect with the input geometry. |
Reproject#
|
Transform spatial coordinates to a new coordinate reference system. |
|
Transform spatial coordinates to a new coordinate reference system. |
Flow direction methods#
These methods are based on the pyflwdir library. For more flow direction based methods visit the pyflwdir docs.
|
Parse dataarray to flow direction raster object. |
|
Derive D8 flow directions grid from an elevation grid. |
|
Reproject flow direction and upstream area data to the da_elv crs and grid. |
|
Upscale flow direction network to lower resolution. |
|
Return a stream mask DataArray. |
|
Return a (sub)basin map, with unique non-zero IDs for each subbasin. |
|
Return map with unique gauge IDs. |
|
Return a mask of basin outlets/pits from a flow direction raster. |
|
Clip a dataset to a subbasin. |
|
Return hydrologically conditioned elevation. |
General GIS methods#
Raster#
|
Create a .vrt file from a list op raster datasets. |
|
Return values of da_obs spreaded to cells with nodata value within da_mask. |
|
Return the cell area [m2] for a regular grid based on its cell centres lat, lon. |
|
Return the area [m2] of cell based on its center latitude and resolution in degrees. |
|
Return the cell (x, y) resolution [m]. |
CRS and transform#
|
|
|
Return wkt string of nearest UTM projects. |
|
Return a raster axis with pixel center coordinates based on the transform. |
Vector#
|
Filter GeoDataFrame geometries based on geometry mask or bounding box. |
|
Return the index of and distance [m] to the nearest geometry. |
|
Merge attributes of gdf2 with the nearest feature of gdf1. |
Statistics and Extreme Value Analysis#
Statistics and performance metrics#
|
Return the bias between two time series. |
|
Return the percentual bias between two time series. |
|
Return the volumetric error between two time series. |
|
Return the Nash-Sutcliffe model efficiency. |
|
Return the log Nash-Sutcliffe model efficiency. |
|
Return the Pearson correlation coefficient of two time series. |
|
Return the spearman rank correlation coefficient of two time series. |
|
Return the Kling-Gupta Efficiency (KGE) of two time series. |
|
Return the Kling-Gupta Efficiency (KGE, 2012) of two time series. |
|
Return the Non Parametric Kling-Gupta Efficiency (KGE, 2018). |
|
Return the Non Parametric Kling-Gupta Efficiency (KGE, 2018) of two time series. |
|
Return the coefficient of determination of two time series. |
|
Return the mean squared error (MSE) between two time series. |
|
Return the root mean squared error between two time series. |
|
Return the RMSE-observations standard deviation (RSR) between two time series. |
Extreme Value Analysis#
|
Return peaks from time series. |
|
Return distribution fit from extremes. |
|
Return return value based on EVA. |
|
Return Extreme Value Analysis. |
Design Events#
Return peak hydrographs. |
Utilities#
Configuration files#
|
Read configuration/workflow file and parse to (nested) dictionary. |
|
Write configuration/workflow dictionary to file. |
Logging#
|
Set up the logging on sys.stdout and file if path is given. |