From 75f6433351df6fdcbef9f577bcf8f13610fa7afc Mon Sep 17 00:00:00 2001 From: Daniel Otto Date: Wed, 16 Nov 2022 15:14:37 -0800 Subject: [PATCH 1/2] Updated define_glacier_region to handle a list of DEM sources --- 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..3ebf20d28 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:`1503`). + By `Daniel Otto `_ Migrating guide ~~~~~~~~~~~~~~~ diff --git a/oggm/core/gis.py b/oggm/core/gis.py index 3fe4c03b5..c23a531b3 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 i, src in enumerate(source): + source_exists = is_dem_source_available(src, *gdir.extent_ll) + if source_exists: + source = source[i] # pick the first source which exists + break + else: + source_exists = is_dem_source_available(source, *gdir.extent_ll) + + if source_exists is False: raise InvalidWorkflowError(f'Source: {source} is not available for ' f'glacier {gdir.rgi_id} with border ' f"{cfg.PARAMS['border']}") From d4ff09ee2109c50c9bfd922467721e5b84d90430 Mon Sep 17 00:00:00 2001 From: Daniel Otto Date: Wed, 16 Nov 2022 16:22:43 -0800 Subject: [PATCH 2/2] Update PR number in whats-new.rst --- docs/whats-new.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/whats-new.rst b/docs/whats-new.rst index 3ebf20d28..b9aa36cae 100644 --- a/docs/whats-new.rst +++ b/docs/whats-new.rst @@ -70,7 +70,7 @@ Bug fixes 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:`1503`). + list of DEM sources. (:pull:`1506`). By `Daniel Otto `_ Migrating guide