BindingsOggmWrangler#
- class dtcg.integration.oggm_bindings.BindingsOggmWrangler(
- base_url='https://cluster.klima.uni-bremen.de/~dtcg/gdirs/v2025.2/',
- working_dir='',
- oggm_params=None,
- shapefile_path='https://cluster.klima.uni-bremen.de/~dtcg/test_files/case_study_regions/austria',
Bases:
BindingsOggmModelWrangles input data for OGGM workflows.
- Parameters:
base_url (str)
working_dir (str)
oggm_params (dict)
shapefile_path (str)
- SHAPEFILE_PATH#
Region or subregion’s glacier outlines.
- Type:
str
Methods
__init__([base_url, working_dir, ...])add_data(datacube_manager, **kwargs)add_rgi_id_to_dataset(dataset)get_cached_outline_data(cache_path)Get glacier outlines.
get_gdir_by_name(data, name, **kwargs)Get glacier directory from a glacier's name or RGI ID.
get_glacier_by_name(data, name)Get glacier data by full name or RGI ID.
get_glacier_by_rgi_id(data, rgi_id)Get glacier data by RGI ID.
get_glacier_directories(rgi_ids[, ...])Get OGGM glacier directories.
get_glaciers_in_subregion(region, subregion)Get only the glaciers in a given subregion.
get_matching_region_codes([region_name, ...])Get region and subregion codes matching a given subregion name.
get_named_glaciers(glaciers)Get all glaciers with a full name.
get_oggm_datacube(gdir)get_outline_details(polygon)get_outline_source_date(glacier_data)Get the date for an outline's source.
get_polygon_difference(frame)Get the difference of overlapping polygons.
get_rgi_files_from_subregion([region_name, ...])Get RGI shapefile from a subregion name.
get_rgi_metadata([path, from_web])Get RGI metadata.
get_rgi_region_codes([region_name, ...])Get RGI region and subregion codes from a subregion name.
get_shapefile(path)Get shapefile from user path.
get_shapefile_from_web(shapefile_name)Placeholder for getting shapefiles from an online repository.
get_shapefile_metadata(shapefile)Get metadata from a catchment shapefile.
get_user_subregion([region_name, ...])Get user-selected subregion in a catchment area.
init_oggm([working_dir, ...])Initialise OGGM run parameters.
set_flowlines(gdir)Compute glacier flowlines if missing from glacier directory.
Set OGGM configuration.
set_oggm_params(**new_params)Define OGGM configuration parameters.
set_polygon_overlap(frame)Set overlapping boundaries.
set_subregion_constraints(region, subregion)Reproject subregional data to match regional data, and optionally mask by subregion name.
- __init__(
- base_url='https://cluster.klima.uni-bremen.de/~dtcg/gdirs/v2025.2/',
- working_dir='',
- oggm_params=None,
- shapefile_path='https://cluster.klima.uni-bremen.de/~dtcg/test_files/case_study_regions/austria',
- Parameters:
base_url (str)
working_dir (str)
oggm_params (dict)
shapefile_path (str)
- add_rgi_id_to_dataset(dataset)#
- Parameters:
dataset
- get_cached_outline_data(cache_path)[source]#
Get glacier outlines.
This is identical to
gdir.read_shapefile, so the CRS should later be converted to EPSG:4236- Parameters:
cache_path (Path)
- Return type:
GeoDataFrame
- get_gdir_by_name(data, name, **kwargs)[source]#
Get glacier directory from a glacier’s name or RGI ID.
- Parameters:
data (gpd.GeoDataFrame) – Glacier data.
name (str) – Name or RGI ID of glacier.
**kwargs – Additional arguments passed to
workflow.init_glacier_directories.
- get_glacier_by_name(data, name)[source]#
Get glacier data by full name or RGI ID.
- Parameters:
data (gpd.GeoDataFrame) – Glacier data.
name (str) – Full name or RGI ID of glacier.
- Returns:
Glacier with matching name or RGI ID.
- Return type:
gpd.GeoDataFrame
- get_glacier_by_rgi_id(data, rgi_id)[source]#
Get glacier data by RGI ID.
- Parameters:
data (gpd.GeoDataFrame) – Glacier data.
rgi_id (str) – RGI ID of glacier.
- Returns:
Glacier with matching RGI ID.
- Return type:
gpd.GeoDataFrame
- get_glacier_directories(
- rgi_ids,
- prepro_base_url=None,
- from_prepro_level=3,
- prepro_border=80,
- add_daily_w5e5=True,
- **kwargs,
Get OGGM glacier directories.
- Parameters:
rgi_ids (list) – RGI IDs of glaciers.
prepro_base_url (str, optional) – URL to OGGM data. If empty, uses the
DEFAULT_BASE_URLattribute.prepro_level (int, default 4) – File preprocessing level.
prepro_border (int, default 80) – Grid border buffer around the glacier.
add_daily_w5e5 (bool, default True) – Add daily W5E5 data.
**kwargs – Extra arguments to
workflow.init_glacier_directories.from_prepro_level (int)
- Returns:
Glacier directories for the given RGI IDs.
- Return type:
list[GlacierDirectory]
- get_glaciers_in_subregion(
- region,
- subregion,
Get only the glaciers in a given subregion.
- Parameters:
region (gpd.GeoDataFrame) – Contains all glaciers in a region.
subregion (gpd.GeoDataFrame) – Subregion shapefile.
- Returns:
Only glaciers inside the given subregion.
- Return type:
gpd.GeoDataFrame
- get_matching_region_codes(
- region_name='',
- subregion_name='',
Get region and subregion codes matching a given subregion name.
Subregion names take priority over region names.
- Parameters:
region_name (str) – The full name of a region.
subregion_name (str) – The full name of a subregion.
- Returns:
All pairs of region and subregion codes matching the given subregion or region’s name.
- Return type:
set[str]
- Raises:
KeyError – If the region or subregion name is not found.
ValueError – If no valid region or subregion name is supplied.
- get_named_glaciers(glaciers)[source]#
Get all glaciers with a full name.
- Parameters:
glaciers (gpd.GeoDataFrame) – Glacier data.
- Returns:
All named glaciers.
- Return type:
gpd.GeoDataFrame
- get_outline_source_date(glacier_data)#
Get the date for an outline’s source.
- Parameters:
glacier_data (gpd.GeoDataFrame) – Outline data for a glacier. Must conform to RGI60 specifications.
- Returns:
The year the outline’s source data was published.
- Return type:
int
- get_polygon_difference(frame)[source]#
Get the difference of overlapping polygons.
Note
GPD’s overlay() only acts on GeoDataFrames, but this function manipulates GeoSeries.
- Parameters:
frame (gpd.GeoDataFrame) – Overlapping polygons.
- Returns:
Polygon geometries adjusted so no areas overlap.
- Return type:
gpd.GeoSeries
- get_rgi_files_from_subregion(
- region_name='',
- subregion_name='',
Get RGI shapefile from a subregion name.
- Parameters:
region_name (str, optional) – Name of RGI region.
subregion_name (str, optional) – Name of RGI subregion.
- Returns:
RGI shapefiles.
- Return type:
list
- Raises:
KeyError – If no glaciers are found for the given subregion.
- get_rgi_metadata(
- path='rgi_subregions_V6.csv',
- from_web=False,
Get RGI metadata.
TODO: Replace with call to
oggm.utils.parse_rgi_meta.- Parameters:
path (str, default "rgi_subregions_V6.csv".) – Path to database with subregion names and O1/O2 codes.
from_web (bool, default False) – Use data from oggm-sample-data.
- Returns:
RGI metadata for all glaciers.
- Return type:
list
- get_rgi_region_codes(
- region_name='',
- subregion_name='',
Get RGI region and subregion codes from a subregion name.
This can be replaced with OGGM backend if available.
- Parameters:
region_name (str, optional) – Name of RGI region.
subregion_name (str, optional) – Name of RGI subregion.
- Returns:
RGI region (O1) and subregion (O2) codes.
- Return type:
set[str]
- Raises:
KeyError – If the subregion name is not available.
TypeError – If subregion name is not a string.
- get_shapefile(path)[source]#
Get shapefile from user path.
- Parameters:
path (str) – Path to shapefile.
- Return type:
GeoDataFrame
- get_shapefile_from_web(shapefile_name)[source]#
Placeholder for getting shapefiles from an online repository.
- Parameters:
shapefile_name (str) – Name of file in
oggm-sample-datarepository.- Return type:
GeoDataFrame
- get_shapefile_metadata(shapefile)[source]#
Get metadata from a catchment shapefile.
- Parameters:
shapefile (GeoDataFrame)
- Return type:
dict
- get_user_subregion(
- region_name='',
- subregion_name='',
- shapefile_path='',
- **oggm_params,
Get user-selected subregion in a catchment area.
This should be called via gateway.
- Parameters:
region_name (str, optional) – Name of RGI region.
subregion_name (str, optional) – Name of RGI subregion.
shapefile_path (str, optional) – Path to shapefile with catchment area outlines.
**oggm_params – Additional OGGM configuration parameters.
- Return type:
dict
- init_oggm(
- working_dir=None,
- use_multiprocessing=True,
- continue_on_error=True,
- **kwargs,
Initialise OGGM run parameters.
TODO: Add kwargs for cfg.PATH.
- Parameters:
working_dir (str) – Name of temporary directory
**kwargs – Extra arguments passed to OGGM’s configuration.
use_multiprocessing (bool)
continue_on_error (bool)
- Return type:
None
- set_flowlines(gdir)#
Compute glacier flowlines if missing from glacier directory.
- Parameters:
gdir (GlacierDirectory) – Glacier directory.
- Return type:
None
- set_oggm_kwargs()#
Set OGGM configuration.
Note
This may eventually be moved to
api.internal._parse_oggm.- Parameters:
oggm_params (dict) – Key/value pairs corresponding to valid OGGM configuration parameters.
- Return type:
None
- set_oggm_params(**new_params)#
Define OGGM configuration parameters.
This will overwrite existing values that have the same key. To configure OGGM, use
set_oggm_kwargs().- Parameters:
**new_params (dict) – Parameters passed to OGGM’s configuration.
- Return type:
None
- set_polygon_overlap(frame)[source]#
Set overlapping boundaries.
If two polygons overlap, the overlapping area is removed from the second polygon.
- Parameters:
frame (gpd.GeoDataFrame) – Contains overlapping polygons.
- Returns:
Polygon geometries adjusted so no areas overlap.
- Return type:
gpd.GeoDataFrame
- set_subregion_constraints(
- region,
- subregion,
- subregion_id='',
Reproject subregional data to match regional data, and optionally mask by subregion name.
- Parameters:
region (gpd.GeoDataFrame) – Shapefile data for region.
subregion (gpd.GeoDataFrame) – Shapefile data for subregion.
subregion_id (str, optional) – Subregion id.
- Returns:
Reprojected subregion data, optionally masked to a specific subregion name.
- Return type:
gpd.GeoDataFrame
