API reference#
Data#
Data catalog#
General#
|
Catalog of DataAdapter sources to easily read from different files and keep track of files which have been accessed. |
Returns dictionary of DataAdapter sources. |
|
Returns list of data source names. |
|
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. |
Add data sources#
Read a data archive including a data_catalog.yml file |
|
|
Add data sources based on yaml file. |
|
Add data sources based on dictionary. |
|
Add data sources to library. |
Get data#
Returns a clipped, sliced and unified RasterDataset from the data catalog. |
|
Returns a clipped, sliced and unified GeoDataset from the data catalog. |
|
Returns a clipped and unified GeoDataFrame (vector) from the data catalog. |
RasterDataset#
|
Initiates data adapter for geospatial raster data. |
Returns a dictionary summary of the data adapter. |
|
Returns a clipped, sliced and unified RasterDataset based on the properties of this RasterDatasetAdapter. |
|
Returns a dictionary view of the data source. |
|
Save a data slice to file. |
GeoDataset#
|
Initiates data adapter for geospatial timeseries data. |
Returns a dictionary summary of the data adapter. |
|
Returns a clipped, sliced and unified GeoDataset based on the properties of this GeoDatasetAdapter. |
|
Returns a dictionary view of the data source. |
|
Save a data slice to file. |
GeoDataFrame#
|
Initiates data adapter for geospatial vector data. |
Returns a dictionary summary of the data adapter. |
|
Returns a clipped and unified GeoDataFrame (vector) based on the properties of this GeoDataFrameAdapter. |
|
Returns a dictionary view of the data source. |
|
Save a data slice to file. |
DataFrame#
|
Initiates data adapter for 2D tabular data. |
Returns a dictionary summary of the data adapter. |
|
Returns a DataFrame, optionally sliced by time and variables, based on the properties of this DataFrameAdapter. |
|
Returns a dictionary view of the data source. |
|
|
Save dataframe slice to file. |
Models#
Discovery#
Classes#
|
General and basic API for models in HydroMT |
|
Model class Grid Model for gridded models in HydroMT |
|
Model class Lumped Model for lumped models in HydroMT |
|
Model class Mesh Model for mesh 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 hydromt_data.yml |
Model components#
Model configuration. |
|
Model maps. |
|
Model geometries. |
|
Model forcing. |
|
Model states. |
|
Model results. |
|
Model static mesh data. |
|
Model static gridded data. |
|
Model response unit (lumped) data. |
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 |
|
Add data to mesh. |
|
Read model mesh data at <root>/<fn> and add to mesh property |
|
Write model grid data to netcdf file at <root>/<fn> |
|
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> |
|
Add data to response_units. |
|
Read model response units from combined netcdf file at <root>/<fn> and geojson file at <root>/<fn_geom>. |
|
Write model response units to combined netcdf file at <root>/<fn> and geojson file at <root>/<fn_geom>. |
Setup methods#
|
Update config with a dictionary |
|
This component sets the region of interest of the model. |
|
This component adds data variable(s) from |
|
This component adds data variable(s) to maps object by reclassifying the data in |
Workflows#
Basin mask#
Returns a geometry of the (sub)(inter)basin(s). |
|
|
Checks and returns parsed region arguments. |
River bathymetry#
|
Return segment average river width based on a river mask raster. |
|
Derive river depth estimates based bankfull discharge. |
Forcing#
Data handling#
|
Lazy reprojection of precipitation to model grid and resampling of time dimension to frequency. |
|
Lazy reprojection of temperature to model grid using lapse_rate for downscaling, and resampling of time dimension to frequency. |
|
Lazy reprojection of pressure to model grid and resampling of time dimension to frequency. |
|
Determines reference evapotranspiration (lazy reprojection on model grid and resampling of time dimension to frequency). |
Correction methods#
|
Pressure correction based on elevation lapse_rate. |
|
Temperature correction based on elevation data. |
Time resampling methods#
|
Resample data to destination frequency. |
|
Returns the relative difference between the dataset mean timestep and destination freq <1 : upsampling 1 : same >1 : downsampling |
Computation methods#
PET
|
Determines De Bruin (2016) reference evapotranspiration. |
|
Determnines Makkink reference evapotranspiration. |
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. |
|
Reads and merges raster tiles (potentially in different CRS) based on a tile index file as generated with gdaltindex. |
|
Open fiona-compatible geometry, csv, excel or xy file and parse to |
|
Read point geometry files from csv, xy or excel table files. |
|
Open point location GIS file and timeseries file combine a single xarray.Dataset. |
|
Open timeseries csv file and parse to xarray.DataArray. |
Raster writing methods#
|
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, if mismatching grid CRS or resolution, tiles are reprojected to match the output DataArray grid. |
|
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 Coordinate Reference System as |
|
Return the bounds (xmin, ymin, xmax, ymax) of the object. |
|
Return the affine transform of the object. |
|
Return resolution (x, y) 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 of the object. |
|
Return |
General methods#
|
Set the Coordinate Reference System. |
|
Set the geospatial dimensions of the object. |
Reset spatial dimension names and attributes to make CF-compliant Requires CRS attribute. |
|
Return True if other has an same grid as object (crs, transform, shape). |
|
Return True if other grid aligns with object grid (crs, resolution, origin), but with a smaller extent |
|
Updates 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 |
Returns raster flipped along y-axis |
|
|
Returns the grid cell area [m2]. |
Returns the density in [unit/m2] of raster(s). |
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 a bounding box. |
Clip object to region with mask values greater than zero. |
|
|
Clip object to the bounding box of the geometry and add geometry 'mask' coordinate. |
Reproject#
|
Reproject a DataArray with geospatial coordinates, powered by |
|
Return reprojected DataArray object based on simple reindexing using linear indices in |
|
Reproject a object to match the grid of |
|
Transform bounds from object to destination CRS. |
|
Prepare nearest index mapping for the reprojection of a gridded timeseries file, powered by pyproj and k-d tree lookup. |
Transform#
|
Return an object with input geometry values burned in. |
|
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 geopandas GeoDataFrame with a box for each grid cell. |
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 |
|
re-arange data along x dim |
Geospatial timeseries methods#
High level methods#
|
Parse GeoDataFrame object with point geometries to DataArray with geospatial attributes and merge with |
|
Return geopandas GeoDataFrame with Point geometry based on DataArray coordinates. |
|
Creates Dataset with geospatial coordinates. |
Attributes#
Return dictionary of spatial attributes |
|
Return Coordinate Reference System as |
|
Index dimension name. |
|
Time dimension name. |
|
Return the x coordinates |
|
Return the y coordinates |
|
Return the bounds (xmin, ymin, xmax, ymax) of the object. |
|
Return the bounds (xmin, ymin, xmax, ymax) of the object. |
|
General methods#
|
Set the Coordinate Reference System. |
|
Set the spatial and index dimensions of the object. |
Reset spatial dimension names and attributes to make CF-compliant Requires CRS attribute. |
Clip#
|
Select point locations to bounding box. |
|
Select point locations to geometry. |
Reproject#
|
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. |
|
Returns a mask of basin outlets/pits from a flow direction raster. |
|
Clip a dataset to a subbasin. |
|
Returns hydrologically conditioned elevation. |
General GIS methods#
Raster#
|
Returns values of da_obs spreaded to cells with nodata value within da_mask, powered by |
|
Returns the cell area [m2] for a regular grid based on its cell centres lat, lon coordinates. |
|
Return the area [m2] of cell based on the cell center latitude and its resolution in measured in degrees. |
|
Return the cell (x, y) resolution [m] based on cell center latitude and its resolution measured in degrees. |
CRS and transform#
|
|
|
Returns wkt string of nearest UTM projects |
|
Returs 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 in gdf2 for each geometry of gdf1. |
|
Merge attributes of gdf2 with the nearest feature of gdf1, optionally bounded by a maximumum distance max_dist. |
PCRaster I/O#
|
Write pcraster map files using pcr.report functionality. |
|
write pcraster clone file to a tmpdir using gdal |
Statistics#
Statistics and performance metrics#
|
Returns the bias between two time series. |
|
Returns the percentual bias between two time series. |
|
Returns the Nash-Sutcliffe model efficiency based on a simulated and observed time series. |
|
Returns the log Nash-Sutcliffe model efficiency based on simulated and observed time series. |
|
Returns the Pearson correlation coefficient of two time series. |
|
Returns the spearman rank correlation coefficient of two time series. |
|
Returns the Kling-Gupta Efficiency (KGE) of two time series |
|
Returns the Kling-Gupta Efficiency (KGE, 2012) of two time series |
|
Returns the Non Parametric Kling-Gupta Efficiency (KGE, 2018) of two time series with decomposed scores |
|
Returns the Non Parametric Kling-Gupta Efficiency (KGE, 2018) of two time series optimized for flood peaks using Pearson (see Pool et al., 2018) |
|
Returns the coefficient of determination of two time series. |
|
Returns the mean squared error (MSE) between two time series. |
|
Returns the root mean squared error between two time series. |
Utilities#
Configuration files#
|
Read configuration file and parse to (nested) dictionary. |
|
_summary_ |
Logging#
|