From a38b8a94246e95de086444f1f8ed05c159d023bf Mon Sep 17 00:00:00 2001 From: Fabien Maussion Date: Sun, 11 Dec 2022 13:19:42 +0100 Subject: [PATCH 1/2] Fix issue with TANDEM DEM and minor RGI7 issue --- oggm/utils/_downloads.py | 3 ++- oggm/utils/_workflow.py | 11 +++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/oggm/utils/_downloads.py b/oggm/utils/_downloads.py index e688d6309..57ea78d07 100644 --- a/oggm/utils/_downloads.py +++ b/oggm/utils/_downloads.py @@ -951,7 +951,7 @@ def _download_tandem_file_unlocked(zone): tmpdir = cfg.PATHS['tmp_dir'] mkdir(tmpdir) bname = zone.split('/')[-1] + '_DEM.tif' - wwwfile = ('https://download.geoservice.dlr.de/TDM90/files/' + wwwfile = ('https://download.geoservice.dlr.de/TDM90/files/DEM/' '{}.zip'.format(zone)) outpath = os.path.join(tmpdir, bname) @@ -1387,6 +1387,7 @@ def srtm_zone(lon_ex, lat_ex): def _tandem_path(lon_tile, lat_tile): # OK we have a proper tile now + # This changed in December 2022 # First folder level is sorted from S to N level_0 = 'S' if lat_tile < 0 else 'N' diff --git a/oggm/utils/_workflow.py b/oggm/utils/_workflow.py index ddcb3b839..35380567d 100644 --- a/oggm/utils/_workflow.py +++ b/oggm/utils/_workflow.py @@ -2586,9 +2586,6 @@ def __init__(self, rgi_entity, base_dir=None, reset=False, except AttributeError: pass - - - try: self.rgi_id = rgi_entity.rgi_id self.glims_id = rgi_entity.glims_id @@ -2596,6 +2593,7 @@ def __init__(self, rgi_entity, base_dir=None, reset=False, # RGI V6 self.rgi_id = rgi_entity.RGIId self.glims_id = rgi_entity.GLIMSId + # Do we want to use the RGI center point or ours? if cfg.PARAMS['use_rgi_area']: try: @@ -2639,7 +2637,6 @@ def __init__(self, rgi_entity, base_dir=None, reset=False, # temporary default for RGI V7: gtype = ['0', '0'] - try: gstatus = rgi_entity.RGIFlag[0] except AttributeError: @@ -2873,9 +2870,12 @@ def rgi_area_km2(self): """The glacier's RGI area (km2).""" try: _area = self.read_shapefile('outlines')['Area'] - return np.round(float(_area), decimals=3) except OSError: raise RuntimeError('No outlines available') + except KeyError: + # RGI V7 + _area = self.read_shapefile('outlines')['area_km2'] + return np.round(float(_area), decimals=3) @lazy_property def intersects_ids(self): @@ -3000,7 +3000,6 @@ def has_file(self, filename, filesuffix='', _deprecation_check=True): if not out and (filename == 'climate_info'): # Try pickle out = os.path.exists(fp.replace('.json', '.pkl')) - return out def _read_deprecated_climate_info(self): From 2a19b5c725be775795d6aef9f9b516a24bcf1561 Mon Sep 17 00:00:00 2001 From: Fabien Maussion Date: Wed, 4 Jan 2023 10:03:44 +0100 Subject: [PATCH 2/2] Test fix --- oggm/tests/test_utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/oggm/tests/test_utils.py b/oggm/tests/test_utils.py index 7deb18f7f..507e30a3a 100644 --- a/oggm/tests/test_utils.py +++ b/oggm/tests/test_utils.py @@ -2169,8 +2169,8 @@ def test_tandem(self): fakefile='TDM1_DEM__30_N60W146.tif') def down_check(url, *args, **kwargs): - expect = ('https://download.geoservice.dlr.de/TDM90/files/N60/' + - 'W140/' + 'TDM1_DEM__30_N60W146.zip') + expect = ('https://download.geoservice.dlr.de/TDM90/files/DEM/' + 'N60/W140/TDM1_DEM__30_N60W146.zip') self.assertEqual(url, expect) return tf @@ -2202,7 +2202,7 @@ def down_check(url, *args, **kwargs): file = tf.get(url.split('/')[-1]) self.assertIsNotNone(file) - expect = 'https://download.geoservice.dlr.de/TDM90/files/N60/W140/' + expect = 'https://download.geoservice.dlr.de/TDM90/files/DEM/N60/W140/' expect += file.split('/')[-1].replace('tif', '.zip') self.assertEqual(url, expect)