Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update chelsa url #71

Merged
merged 3 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/chelsa/future.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions src/chelsa/shared.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions test/chelsa-bioclim.jl
Original file line number Diff line number Diff line change
@@ -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,)
Expand All @@ -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,)
Expand All @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion test/chelsa-climate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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,)
Expand Down
6 changes: 3 additions & 3 deletions test/chelsa-future.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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,)]
Expand All @@ -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,)
Expand Down
Loading