BindingsOggmModel#

class dtcg.integration.oggm_bindings.BindingsOggmModel(
base_url='https://cluster.klima.uni-bremen.de/~oggm/demo_gdirs',
working_dir='',
oggm_params=None,
)[source]#

Bases: object

Bindings for interacting with OGGM and web repositories.

Parameters:
  • base_url (str)

  • working_dir (str)

  • oggm_params (dict | None)

DEFAULT_BASE_URL#

Base URL for OGGM data.

Type:

str

SHAPEFILE_PATH#

Base URL for shapefile data.

Type:

str

WORKING_DIR#

Temporary working directory.

Type:

str, default None

oggm_params#

OGGM configuration parameters.

Type:

dict, default None

Methods

__init__([base_url, working_dir, oggm_params])

get_glacier_directories(rgi_ids, **kwargs)

Get OGGM glacier directories.

get_matching_region_codes([region_name, ...])

Get region and subregion codes matching a given subregion name.

get_outline_source_date(glacier_data)

Get the date for an outline's source.

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.

init_oggm(dirname, **kwargs)

Initialise OGGM run parameters.

set_flowlines(gdir)

Compute glacier flowlines if missing from glacier directory.

set_oggm_kwargs()

Set OGGM configuration.

set_oggm_params(**new_params)

Define OGGM configuration parameters.

__init__(
base_url='https://cluster.klima.uni-bremen.de/~oggm/demo_gdirs',
working_dir='',
oggm_params=None,
)[source]#
Parameters:
  • base_url (str)

  • working_dir (str)

  • oggm_params (dict | None)

get_glacier_directories(rgi_ids, **kwargs)[source]#

Get OGGM glacier directories.

Parameters:
  • rgi_ids (list) – RGI IDs of glaciers.

  • base_url (str, default empty string) – URL to OGGM data. If empty, uses the DEFAULT_BASE_URL attribute.

  • prepro_level (int, default 4) – File preprocessing level.

  • prepro_border (int, default 80) – Grid border buffer around the glacier.

  • **kwargs – Extra arguments to workflow.init_glacier_directories.

Returns:

Glacier directories for the given RGI IDs.

Return type:

list[GlacierDirectory]

get_matching_region_codes(
region_name='',
subregion_name='',
)[source]#

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_outline_source_date(glacier_data)[source]#

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_rgi_files_from_subregion(
region_name='',
subregion_name='',
)[source]#

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,
)[source]#

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='',
)[source]#

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.

init_oggm(dirname, **kwargs)[source]#

Initialise OGGM run parameters.

TODO: Add kwargs for cfg.PATH.

Parameters:
  • dirname (str) – Name of temporary directory

  • **kwargs – Extra arguments passed to OGGM’s configuration.

Return type:

None

set_flowlines(gdir)[source]#

Compute glacier flowlines if missing from glacier directory.

Parameters:

gdir (GlacierDirectory) – Glacier directory.

Return type:

None

set_oggm_kwargs()[source]#

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)[source]#

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