Skip to content

Commit

Permalink
change the COPDEM server to prism-dem-open.copernicus.eu; update the …
Browse files Browse the repository at this point in the history
…tests
  • Loading branch information
dcodrut committed Feb 1, 2024
1 parent 5f8a8c5 commit 0666d73
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
24 changes: 10 additions & 14 deletions oggm/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2225,8 +2225,7 @@ def test_copdem90(self):

# Make a fake topo file
deep_path = os.path.join(self.dldir,
'DEM1_SAR_DGE_90_20110517T170701_20140817T170857'
'_ADS_000000_3682.DEM',
'COP-DEM_GLO-90-DGED__2022_1',
'Copernicus_DSM_30_N46_00_E010_00', 'DEM')
utils.mkdir(deep_path)
upper_path = os.path.dirname(os.path.dirname(deep_path))
Expand All @@ -2237,14 +2236,13 @@ def test_copdem90(self):
archive='tar', extension='.tar')

def down_check(url, *args, **kwargs):
expected = ('ftps://cdsdata.copernicus.eu:990/datasets/'
'COP-DEM_GLO-90-DGED/2022_1/'
'DEM1_SAR_DGE_90_20110517T170701_20140817T170857_ADS_'
'000000_3682.DEM.tar')
expected = ('https://prism-dem-open.copernicus.eu/pd-desk-open-access/prismDownload/'
'COP-DEM_GLO-90-DGED__2022_1/'
'Copernicus_DSM_30_N46_00_E010_00.tar')
self.assertEqual(expected, url)
return tf

with FakeDownloadManager('download_with_authentication', down_check):
with FakeDownloadManager('file_downloader', down_check):
of, source = utils.get_topo_file([10.5, 10.8], [46.6, 46.8],
source='COPDEM90')

Expand All @@ -2255,8 +2253,7 @@ def test_copdem30(self):

# Make a fake topo file
deep_path = os.path.join(self.dldir,
'DEM1_SAR_DGE_30_20110517T170701_20140817T170857'
'_ADS_000000_bma2.DEM',
'COP-DEM_GLO-30-DGED__2022_1',
'Copernicus_DSM_10_N46_00_E010_00', 'DEM')
utils.mkdir(deep_path)
upper_path = os.path.dirname(os.path.dirname(deep_path))
Expand All @@ -2267,14 +2264,13 @@ def test_copdem30(self):
archive='tar', extension='.tar')

def down_check(url, *args, **kwargs):
expected = ('ftps://cdsdata.copernicus.eu:990/datasets/'
'COP-DEM_GLO-30-DGED/2022_1/'
'DEM1_SAR_DGE_30_20110517T170701_20140817T170857_ADS_'
'000000_bma2.DEM.tar')
expected = ('https://prism-dem-open.copernicus.eu/pd-desk-open-access/prismDownload/'
'COP-DEM_GLO-30-DGED__2022_1/'
'Copernicus_DSM_10_N46_00_E010_00.tar')
self.assertEqual(expected, url)
return tf

with FakeDownloadManager('download_with_authentication', down_check):
with FakeDownloadManager('file_downloader', down_check):
of, source = utils.get_topo_file([10.5, 10.8], [46.6, 46.8],
source='COPDEM30')

Expand Down
9 changes: 3 additions & 6 deletions oggm/utils/_downloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -1163,12 +1163,9 @@ def _download_copdem_file_unlocked(cppfile, tilename, source):
return demfile

# Did we download it yet?
ftpfile = ('ftps://cdsdata.copernicus.eu:990/' +
'datasets/COP-DEM_GLO-{}-DGED/2022_1/'.format(source[-2:]) +
cppfile)

dest_file = download_with_authentication(ftpfile,
'spacedata.copernicus.eu')
url = (f"https://prism-dem-open.copernicus.eu/pd-desk-open-access/prismDownload"
f"/COP-DEM_GLO-{source[-2:]}-DGED__2022_1/{tilename}.tar")
dest_file = file_downloader(url)

# None means we tried hard but we couldn't find it
if not dest_file:
Expand Down

0 comments on commit 0666d73

Please sign in to comment.