Modeled groundwater levels#
Groundwater levels modeled with SGU-HYPE, available as client.levels.modeled.
See Groundwater levels for a walkthrough.
Methods#
Get modeled groundwater areas. |
|
Get a specific modeled groundwater area by ID. |
|
Get modeled groundwater levels. |
|
Get a specific modeled groundwater level by ID. |
|
Get modeled groundwater levels for a specific area. |
|
Get modeled groundwater levels for multiple areas. |
|
Get modeled groundwater levels for a specific coordinate. |
Models#
Collection of modeled groundwater areas (GeoJSON FeatureCollection). |
|
A modeled groundwater area (GeoJSON Feature). |
|
Properties for a modeled groundwater area. |
|
Collection of modeled groundwater levels (GeoJSON FeatureCollection). |
|
A modeled groundwater level (GeoJSON Feature). |
|
Properties for a modeled groundwater level. |
Client#
- class ModeledGroundwaterLevelClient(base_client)[source]#
Client for modeled groundwater level-related SGU API endpoints.
- get_areas(bbox=None, limit=None, filter_expr=None, sortby=None, **kwargs)[source]#
Get modeled groundwater areas.
- Parameters:
bbox (
list[float] |None) – Bounding box as [min_lon, min_lat, max_lon, max_lat]limit (
int|None) – Maximum number of features to return (automatically paginated if needed)sortby (
list[str] |None) – List of sort expressions (e.g., [‘+omrade_id’] - use Swedish field names for API)**kwargs (
Any) – Additional query parameters
- Return type:
- Returns:
Typed collection of modeled groundwater areas
Example
>>> from sgu_client import SGUClient >>> with SGUClient() as client: ... # get all modeled areas ... areas = client.levels.modeled.get_areas(limit=100) ... # get areas in a specific region ... areas = client.levels.modeled.get_areas( ... bbox=[15.0, 58.0, 17.0, 60.0] ... ) ... for area in areas.features: ... print(f"area: {area.properties.area_id}")
- get_area(area_id)[source]#
Get a specific modeled groundwater area by ID. This endpoint is provided by OGC API but not likely used by any user.
- Parameters:
area_id (
str) – Area identifier- Return type:
- Returns:
Typed modeled groundwater area
- Raises:
ValueError – If area not found or multiple areas returned
- get_levels(bbox=None, datetime=None, limit=None, filter_expr=None, sortby=None, tmin=None, tmax=None, **kwargs)[source]#
Get modeled groundwater levels.
- Parameters:
bbox (
list[float] |None) – Bounding box as [min_lon, min_lat, max_lon, max_lat]datetime (
str|None) – Raw OGC date/time filter; prefertmin/tmaxlimit (
int|None) – Maximum number of features to return (automatically paginated if needed)sortby (
list[str] |None) – List of sort expressions (e.g., [‘+datum’, ‘-omrade_id’] - use Swedish field names for API)tmin (
str|datetime|None) – Earliest date (ISO string or datetime object)tmax (
str|datetime|None) – Latest date (ISO string or datetime object)**kwargs (
Any) – Additional query parameters
- Return type:
- Returns:
Typed collection of modeled groundwater levels
Example
>>> from sgu_client import SGUClient >>> with SGUClient() as client: ... # get modeled levels ... levels = client.levels.modeled.get_levels(limit=100) ... # get levels for a specific time period ... levels = client.levels.modeled.get_levels( ... tmin="2023-01-01", ... tmax="2024-01-01", ... limit=1000 ... )
- get_level(level_id)[source]#
Get a specific modeled groundwater level by ID. This endpoint is provided by the OGC API but not likely used by any user.
- Parameters:
level_id (
str) – Level identifier- Return type:
- Returns:
Typed modeled groundwater level
- Raises:
ValueError – If level not found or multiple levels returned
- get_levels_by_area(area_id, tmin=None, tmax=None, **kwargs)[source]#
Get modeled groundwater levels for a specific area.
- Parameters:
- Return type:
- Returns:
Typed collection of modeled groundwater levels for the specified area
Example
>>> from sgu_client import SGUClient >>> with SGUClient() as client: ... # get all modeled levels for a specific area ... levels = client.levels.modeled.get_levels_by_area( ... area_id=30125, ... limit=500 ... ) ... # with time filtering ... levels = client.levels.modeled.get_levels_by_area( ... area_id=30125, ... tmin="2023-01-01", ... tmax="2024-01-01" ... )
- get_levels_by_areas(area_ids, tmin=None, tmax=None, **kwargs)[source]#
Get modeled groundwater levels for multiple areas.
- Parameters:
- Return type:
- Returns:
Typed collection of modeled groundwater levels for the specified areas
Example
>>> from sgu_client import SGUClient >>> with SGUClient() as client: ... levels = client.levels.modeled.get_levels_by_areas( ... area_ids=[30125, 30126], ... tmin="2024-09-30", ... tmax="2025-10-01" ... ) ... print(f"Found {len(levels.features)} modeled levels")
- get_levels_by_coords(lat, lon, buffer=0.01, tmin=None, tmax=None, **kwargs)[source]#
Get modeled groundwater levels for a specific coordinate.
This convenience function first finds relevant areas containing or near the specified coordinates, then retrieves modeled levels for those areas.
- Parameters:
lat (
float) – Latitude coordinate (WGS84)lon (
float) – Longitude coordinate (WGS84)buffer (
float) – Buffer distance in degrees around the point (default 0.01 ≈ 1km)tmin (
str|datetime|None) – Earliest date (ISO string or datetime object)tmax (
str|datetime|None) – Latest date (ISO string or datetime object)**kwargs (
Any) – Additional query parameters (limit, datetime, etc.)
- Return type:
- Returns:
Typed collection of modeled groundwater levels for areas near the coordinates
- Raises:
ValueError – If no areas found near the specified coordinates
Example
>>> from sgu_client import SGUClient >>> with SGUClient() as client: ... # get modeled levels for a specific location (Stockholm) ... levels = client.levels.modeled.get_levels_by_coords( ... lat=59.33, ... lon=18.07, ... limit=100 ... ) ... # increase buffer for larger search area ... levels = client.levels.modeled.get_levels_by_coords( ... lat=59.33, ... lon=18.07, ... buffer=0.05, # ~5km radius ... tmin="2023-01-01", ... tmax="2024-01-01" ... )
Model details#
Pydantic models for modeled groundwater data from SGU API.
- pydantic model ModeledGroundwaterLevelProperties[source]#
Properties for a modeled groundwater level.
-
field date:
Annotated[datetime|None] = None (alias 'datum')# Date (midnight UTC)
- Constraints:
func = <function _parse_api_datetime at 0x7fa47d9d60c0>
json_schema_input_type = PydanticUndefined
-
field deviation_small_resources:
int|None= None (alias 'grundvattensituation_sma')# Deviation for small resources (percentile 0-100)
-
field deviation_large_resources:
int|None= None (alias 'grundvattensituation_stora')# Deviation for large resources (percentile 0-100)
-
field relative_level_small_resources:
int|None= None (alias 'fyllnadsgrad_sma')# Relative level for small resources (percentile 0-100)
-
field date:
- pydantic model ModeledAreaCollection[source]#
Collection of modeled groundwater areas (GeoJSON FeatureCollection).
Areas are grid cells, so the DataFrame has
centroid_longitudeandcentroid_latitudecolumns: the centre of the cell. SGU sends only the cell’s outline; the centre is computed by sgu-client.Examples
>>> from sgu_client import SGUClient >>> with SGUClient() as client: ... areas = client.levels.modeled.get_areas(limit=10) ... df = areas.to_dataframe() ... print(df[['area_id', 'centroid_longitude', 'centroid_latitude']].head())
- pydantic model ModeledGroundwaterLevelCollection[source]#
Collection of modeled groundwater levels (GeoJSON FeatureCollection).
Its DataFrame has no geometry columns. Sorted by
date;to_series()defaults torelative_level_small_resources.Examples
>>> from sgu_client import SGUClient >>> with SGUClient() as client: ... levels = client.levels.modeled.get_levels(limit=100) ... df = levels.to_dataframe() ... print(df[['date', 'area_id', 'relative_level_small_resources']].head()) ... series = levels.to_series(data="relative_level_large_resources")