Skip to content

Commit

Permalink
allow symbol layers for chelsa future bioclim (#70)
Browse files Browse the repository at this point in the history
* add dispatch for chelsa future bioclim with symbol layer

* better tests for future bioclim(plus)
  • Loading branch information
tiemvanderdeure authored Sep 20, 2024
1 parent eebcd2e commit ff18c0e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/chelsa/future.jl
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ end
function _getraster(T::Type{<:CHELSA{<:Future}}, layers::Tuple; kw...)
_map_layers(T, layers; kw...)
end
_getraster(T::Type{<:CHELSA{<:Future{BioClim}}}, layer::Symbol; kw...) = _getraster(T, bioclim_int(layer); kw...)
function _getraster(T::Type{<:CHELSA{<:Future}}, layer::Union{Symbol,Integer}; kw...)
_check_layer(T, layer)
path = rasterpath(T, layer; kw...)
Expand Down
8 changes: 7 additions & 1 deletion test/chelsa-future.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ end
@testset "CHELSA Future BioClim CMIP6" begin
bioclim_name = "CHELSA_bio5_2041-2070_mri-esm2-0_ssp126_V.2.1.tif"
@test rastername(CHELSA{Future{BioClim,CMIP6,MRIESM2,SSP126}}, 5; date=Date(2050)) == bioclim_name

bioclim_path = joinpath(ENV["RASTERDATASOURCES_PATH"], "CHELSA", "Future", "BioClim", "SSP126", "MRIESM2")
@test rasterpath(CHELSA{Future{BioClim,CMIP6,MRIESM2,SSP126}}) == bioclim_path

Expand All @@ -31,7 +30,14 @@ end
@test getraster(CHELSA{Future{BioClim,CMIP6,MRIESM2,SSP126}}, [5]; date=Date(2050)) == (bio5=raster_path,)
@test getraster(CHELSA{Future{BioClim,CMIP6,MRIESM2,SSP126}}, (5,); date=[Date(2050)]) ==
[(bio5=raster_path,)]
@test getraster(CHELSA{Future{BioClim,CMIP6,MRIESM2,SSP126}}, :bio5; date=Date(2050)) == raster_path
@test getraster(CHELSA{Future{BioClim,CMIP6,MRIESM2,SSP126}}, (:bio5,); date=Date(2050)) == (bio5=raster_path,)
@test getraster(CHELSA{Future{BioClimPlus,CMIP6,MRIESM2,SSP126}}, :bio5; date=Date(2050)) == raster_path
@test getraster(CHELSA{Future{BioClimPlus,CMIP6,MRIESM2,SSP126}}, (:bio5,); date=Date(2050)) == (bio5=raster_path,)
@test isfile(raster_path)

# bioclimplus requires symbol input
@test_throws ArgumentError getraster(CHELSA{Future{BioClimPlus,CMIP6,MRIESM2,SSP126}}, 5; date=Date(2050))
end

@testset "CHELSA Future Climate CMIP5" begin
Expand Down

0 comments on commit ff18c0e

Please sign in to comment.