Skip to content

Commit

Permalink
Updated define_glacier_region to handle a list of DEM sources (#1506)
Browse files Browse the repository at this point in the history
* 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 <fabien.maussion@uibk.ac.at>
  • Loading branch information
d-otto and fmaussion committed Nov 29, 2022
1 parent fd6ce6c commit b0b4aae
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docs/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/bowenbelongstonature>`_
- Corrected ``source`` argument in ``tasks.define_glacier_region`` to handle a
list of DEM sources. (:pull:`1506`).
By `Daniel Otto <https://github.com/d-otto>`_

Migrating guide
~~~~~~~~~~~~~~~
Expand Down
11 changes: 10 additions & 1 deletion oggm/core/gis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']}")
Expand Down

0 comments on commit b0b4aae

Please sign in to comment.