From b0b4aae84a587c2f99cea2ba51bcb1342ef32f66 Mon Sep 17 00:00:00 2001 From: Daniel Otto Date: Tue, 29 Nov 2022 09:08:21 -0800 Subject: [PATCH] Updated define_glacier_region to handle a list of DEM sources (#1506) * Updated define_glacier_region to handle a list of DEM sources * Update PR number in whats-new.rst * Update gis.py small simplifications Co-authored-by: Fabien Maussion --- docs/whats-new.rst | 3 +++ oggm/core/gis.py | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/whats-new.rst b/docs/whats-new.rst index 2fae105e3..b9aa36cae 100644 --- a/docs/whats-new.rst +++ b/docs/whats-new.rst @@ -69,6 +69,9 @@ Bug fixes - corrected a but in ``apparent_mb_from_any_mb``, where only two years of MB would be used instead of a range of years (:pull:`1426`). By `Bowen `_ +- Corrected ``source`` argument in ``tasks.define_glacier_region`` to handle a + list of DEM sources. (:pull:`1506`). + By `Daniel Otto `_ Migrating guide ~~~~~~~~~~~~~~~ diff --git a/oggm/core/gis.py b/oggm/core/gis.py index 3fe4c03b5..65c5d1e72 100644 --- a/oggm/core/gis.py +++ b/oggm/core/gis.py @@ -333,7 +333,16 @@ def define_glacier_region(gdir, entity=None, source=None): # Open DEM # We test DEM availability for glacier only (maps can grow big) - if not is_dem_source_available(source, *gdir.extent_ll): + if isinstance(source, list): # when multiple sources are provided, try them sequentially + for src in source: + source_exists = is_dem_source_available(src, *gdir.extent_ll) + if source_exists: + source = src # pick the first source which exists + break + else: + source_exists = is_dem_source_available(source, *gdir.extent_ll) + + if not source_exists: raise InvalidWorkflowError(f'Source: {source} is not available for ' f'glacier {gdir.rgi_id} with border ' f"{cfg.PARAMS['border']}")