From 51066cf6c58d0b5bf44edabd8947b5ca9ca34783 Mon Sep 17 00:00:00 2001 From: Tiem van der Deure Date: Tue, 1 Oct 2024 16:18:56 +0200 Subject: [PATCH] update chelsa url (#71) * change rasterurl(::CHELSA) * also fix for future * update tests --- src/chelsa/future.jl | 4 ++-- src/chelsa/shared.jl | 6 +++--- test/chelsa-bioclim.jl | 14 +++++++------- test/chelsa-climate.jl | 2 +- test/chelsa-future.jl | 6 +++--- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/chelsa/future.jl b/src/chelsa/future.jl index 9f561ba..4d1a8a9 100644 --- a/src/chelsa/future.jl +++ b/src/chelsa/future.jl @@ -212,14 +212,14 @@ _chelsa_layer(::Type{<:BioClimPlus}, layer) = :bio _chelsa_layer(::Type{<:Climate}, layer) = layer function _urlpath(::Type{CMIP5}, T::Type{<:CHELSA{<:Future}}, name, date_str) - return "chelsa_V1/cmip5/$date_str/$name/" + return "chelsav1/cmip5/$date_str/$name/" end function _urlpath(::Type{CMIP6}, T::Type{<:CHELSA{<:Future}}, name, date_str) # The model is in uppercase in the URL for CMIP6 mod = uppercase(_format(CHELSA, _model(T))) scen = _format(CHELSA, _scenario(T)) key = CHELSAKEY[name] - return "chelsa_V2/GLOBAL/climatologies/$date_str/$mod/$scen/$key/" + return "chelsav2/GLOBAL/climatologies/$date_str/$mod/$scen/$key/" end function _date_string(::Type{CMIP5}, date) diff --git a/src/chelsa/shared.jl b/src/chelsa/shared.jl index 249e15b..6c7b9f3 100644 --- a/src/chelsa/shared.jl +++ b/src/chelsa/shared.jl @@ -12,14 +12,14 @@ struct CHELSA{X} <: RasterDataSource end rasterpath(::Type{CHELSA}) = joinpath(rasterpath(), "CHELSA") function rasterurl(T::Type{CHELSA}, version) if version == 1 - joinpath(rasterurl(T), "chelsa_V1") + joinpath(rasterurl(T), "chelsav1") elseif version == 2 - joinpath(rasterurl(T), "chelsa_V2/GLOBAL") + joinpath(rasterurl(T), "chelsav2/GLOBAL") else CHELSA_invalid_version(version) end end -rasterurl(::Type{CHELSA}) = URI(scheme="https", host="os.zhdk.cloud.switch.ch", path="/envicloud/chelsa/") +rasterurl(::Type{CHELSA}) = URI(scheme="https", host="os.zhdk.cloud.switch.ch", path="") function latest_patch(::Type{<:CHELSA}, v) if v == 1 diff --git a/test/chelsa-bioclim.jl b/test/chelsa-bioclim.jl index 2becdf0..2f8d4f1 100644 --- a/test/chelsa-bioclim.jl +++ b/test/chelsa-bioclim.jl @@ -1,18 +1,18 @@ using RasterDataSources, URIs, Test, Dates -using RasterDataSources: rastername, rasterpath, rasterurl, CHELSA_warn_version +using RasterDataSources: rastername, rasterpath, rasterurl, CHELSA_warn_version, layers bioclim_path = joinpath(ENV["RASTERDATASOURCES_PATH"], "CHELSA", "BioClim") @testset "CHELSEA BioClim" begin @test rasterpath(CHELSA{BioClim}) == bioclim_path @test rasterurl(CHELSA) == - URI(scheme="https", host="os.zhdk.cloud.switch.ch", path="/envicloud/chelsa/") + URI(scheme="https", host="os.zhdk.cloud.switch.ch", path="") # version 1 @test rastername(CHELSA{BioClim}, 5; version = 1) == "CHELSA_bio10_05.tif" # version 1 @test rasterpath(CHELSA{BioClim}, 5; version = 1) == joinpath(bioclim_path, "CHELSA_bio10_05.tif") @test rasterurl(CHELSA{BioClim}, 5; version = 1) == - URI(scheme="https", host="os.zhdk.cloud.switch.ch", path="/envicloud/chelsa/chelsa_V1/climatologies/bio/CHELSA_bio10_05.tif") + URI(scheme="https", host="os.zhdk.cloud.switch.ch", path="/chelsav1/climatologies/bio/CHELSA_bio10_05.tif") raster_path = joinpath(bioclim_path, "CHELSA_bio10_05.tif") @test getraster(CHELSA{BioClim}, :bio5; version = 1) == raster_path @test getraster(CHELSA{BioClim}, (5,); version = 1) == (bio5=raster_path,) @@ -29,7 +29,7 @@ bioclim_path = joinpath(ENV["RASTERDATASOURCES_PATH"], "CHELSA", "BioClim") @test rastername(CHELSA{BioClim}, 6) == "CHELSA_bio6_1981-2010_V.2.1.tif" # version 2 @test rasterpath(CHELSA{BioClim}, 6) == joinpath(bioclim_path, "CHELSA_bio6_1981-2010_V.2.1.tif") @test rasterurl(CHELSA{BioClim}, 6) == - URI(scheme="https", host="os.zhdk.cloud.switch.ch", path="/envicloud/chelsa/chelsa_V2/GLOBAL/climatologies/1981-2010/bio/CHELSA_bio6_1981-2010_V.2.1.tif") + URI(scheme="https", host="os.zhdk.cloud.switch.ch", path="/chelsav2/GLOBAL/climatologies/1981-2010/bio/CHELSA_bio6_1981-2010_V.2.1.tif") raster_path = joinpath(bioclim_path, "CHELSA_bio6_1981-2010_V.2.1.tif") @test getraster(CHELSA{BioClim}, :bio6) == raster_path @test getraster(CHELSA{BioClim}, (6,)) == (bio6=raster_path,) @@ -51,7 +51,7 @@ end @test rasterpath(CHELSA{BioClimPlus}, :clt_mean) == joinpath(bioclim_path, "CHELSA_clt_mean_1981-2010_V.2.1.tif") @test rasterurl(CHELSA{BioClimPlus}, :clt_mean) == - URI(scheme="https", host="os.zhdk.cloud.switch.ch", path="/envicloud/chelsa/chelsa_V2/GLOBAL/climatologies/1981-2010/bio/CHELSA_clt_mean_1981-2010_V.2.1.tif") + URI(scheme="https", host="os.zhdk.cloud.switch.ch", path="/chelsav2/GLOBAL/climatologies/1981-2010/bio/CHELSA_clt_mean_1981-2010_V.2.1.tif") raster_path = joinpath(bioclim_path, "CHELSA_clt_mean_1981-2010_V.2.1.tif") @test getraster(CHELSA{BioClimPlus}, :clt_mean) == raster_path @@ -60,6 +60,6 @@ end @test RasterDataSources.getraster_keywords(CHELSA{BioClimPlus}) == (:version, :patch) - @test length(RasterDataSources.BIOCLIMPLUS_LAYERS) == 75 - @test length(RasterDataSources.BIOCLIMPLUS_LAYERS_FUTURE) == 46 + @test length(layers(CHELSA{BioClimPlus})) == 75 + @test length(layers(CHELSA{Future{BioClimPlus}})) == 46 end \ No newline at end of file diff --git a/test/chelsa-climate.jl b/test/chelsa-climate.jl index 1d732d8..b05dc7f 100644 --- a/test/chelsa-climate.jl +++ b/test/chelsa-climate.jl @@ -12,7 +12,7 @@ using RasterDataSources: rastername, rasterpath, rasterurl, layers @test rasterpath(CHELSA{Climate}, :tasmax; month=7) == raster_path @test rasterurl(CHELSA{Climate}, :pr; month=6) |> string == - "https://os.zhdk.cloud.switch.ch/envicloud/chelsa/chelsa_V2/GLOBAL/climatologies/1981-2010/pr/CHELSA_pr_06_1981-2010_V.2.1.tif" + "https://os.zhdk.cloud.switch.ch/chelsav2/GLOBAL/climatologies/1981-2010/pr/CHELSA_pr_06_1981-2010_V.2.1.tif" @test getraster(CHELSA{Climate}, :tasmax; month=7) == raster_path @test getraster(CHELSA{Climate}, [:tasmax]; month=7) == (tasmax=raster_path,) diff --git a/test/chelsa-future.jl b/test/chelsa-future.jl index 932513c..48a378d 100644 --- a/test/chelsa-future.jl +++ b/test/chelsa-future.jl @@ -50,9 +50,9 @@ end raster_path = joinpath(climate_path, tmax_name) @test rasterpath(CHELSA{Future{Climate,CMIP5,CCSM4,RCP60}}, :tmax; date=Date(2050), month=7) == raster_path @test rasterurl(CHELSA{Future{Climate,CMIP5,CCSM4,RCP45}}, :prec; date=Date(2050), month=6) |> string == - "https://os.zhdk.cloud.switch.ch/envicloud/chelsa/chelsa_V1/cmip5/2041-2060/prec/CHELSA_pr_mon_CCSM4_rcp45_r1i1p1_g025.nc_6_2041-2060.tif" + "https://os.zhdk.cloud.switch.ch/chelsav1/cmip5/2041-2060/prec/CHELSA_pr_mon_CCSM4_rcp45_r1i1p1_g025.nc_6_2041-2060.tif" @test rasterurl(CHELSA{Future{Climate,CMIP5,CCSM4,RCP45}}, :tmin; date=Date(2050), month=1) |> string == - "https://os.zhdk.cloud.switch.ch/envicloud/chelsa/chelsa_V1/cmip5/2041-2060/tmin/CHELSA_tasmin_mon_CCSM4_rcp45_r1i1p1_g025.nc_1_2041-2060_V1.2.tif" + "https://os.zhdk.cloud.switch.ch/chelsav1/cmip5/2041-2060/tmin/CHELSA_tasmin_mon_CCSM4_rcp45_r1i1p1_g025.nc_1_2041-2060_V1.2.tif" @test getraster(CHELSA{Future{Climate,CMIP5,CCSM4,RCP60}}, :tmax; date=Date(2050), month=7) == raster_path @test getraster(CHELSA{Future{Climate,CMIP5,CCSM4,RCP60}}, [:tmax]; date=Date(2050), month=7) == (tmax=raster_path,) @test getraster(CHELSA{Future{Climate,CMIP5,CCSM4,RCP60}}, (:tmax,); date=Date(2050), month=7:7) == [(tmax=raster_path,)] @@ -78,7 +78,7 @@ end month_path2 = joinpath(climate_path, month_name2) @test rasterpath(CHELSA{Future{Climate,CMIP6,GFDLESM4,SSP585}}, :temp; date=Date(2030), month=1) == date_path @test rasterpath(CHELSA{Future{Climate,CMIP6,GFDLESM4,SSP585}}, :temp; date=Date(2030), month=1) == date_path - date_url = "https://os.zhdk.cloud.switch.ch/envicloud/chelsa/chelsa_V2/GLOBAL/climatologies/2011-2040/GFDL-ESM4/ssp585/tas/" * date_name + date_url = "https://os.zhdk.cloud.switch.ch/chelsav2/GLOBAL/climatologies/2011-2040/GFDL-ESM4/ssp585/tas/" * date_name @test rasterurl(CHELSA{Future{Climate,CMIP6,GFDLESM4,SSP585}}, :temp; date=Date(2030), month=1) |> string == date_url @test getraster(CHELSA{Future{Climate,CMIP6,GFDLESM4,SSP585}}, :temp; date=Date(2030), month=1) == date_path @test getraster(CHELSA{Future{Climate,CMIP6,GFDLESM4,SSP585}}, (:temp,); date=Date(2030), month=1) == (temp=date_path,)