Skip to content

Commit

Permalink
Merge pull request #7 from cesaraustralia/fixes
Browse files Browse the repository at this point in the history
Fixes
  • Loading branch information
rafaqz committed Dec 9, 2020
2 parents c6f6253 + 8aed330 commit d16a72a
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/alwb/alwb.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ rasterpath(T::Type{<:ALWB}, layer, date) =
joinpath(rasterpath(T), rastername(T, layer, date))

rasterurl(T::Type{<:ALWB{M,P}}, layer, date) where {M,P} =
joinpath(ALWB_URI, _pathsegment(T), rastername(T, layer, date))
joinpath(ALWB_URI, _pathsegments(T)..., rastername(T, layer, date))

download_raster(T::Type{<:ALWB}, layers::Tuple=layers(T); kwargs...) =
map(l -> download_raster(T, l; kwargs...), layers)
Expand Down Expand Up @@ -158,7 +158,7 @@ _pathsegment(::Type{Evaporation{OpenWater}}) = "msl_wet"
# http://www.bom.gov.au/jsp/awra/thredds/fileServer/AWRACMS/values/day/dd_2017.nc
_pathsegment(::Type{DeepDrainage}) = "dd"

_pathsegment(::Type{ALWB{M,P}}) where {M,P} = joinpath(_pathsegment(M), _pathsegment(P))
_pathsegments(::Type{ALWB{M,P}}) where {M,P} = _pathsegment(M), _pathsegment(P)
_pathsegment(::Type{Values}) = "values"
_pathsegment(::Type{Deciles}) = "deciles"
_pathsegment(::Type{Day}) = "day"
Expand Down
2 changes: 1 addition & 1 deletion src/worldclim/bioclim.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

function download_raster(T::Type{WorldClim{BioClim}}; layer::Integer=1, resolution::String="10m")
function download_raster(T::Type{WorldClim{BioClim}}, layer::Integer; resolution::String="10m")
_check_layer(T, layer)
_check_resolution(T, resolution)

Expand Down
2 changes: 1 addition & 1 deletion src/worldclim/climate.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

download_raster(T::Type{WorldClim{Climate}}; layer::Symbol, resolution::String="10m", month=1:12) =
download_raster(T::Type{WorldClim{Climate}}, layer::Symbol; resolution::String="10m", month=1:12) =
_download_raster(T, layer, resolution, month)

function _download_raster(T::Type{WorldClim{Climate}}, layer, resolution, months)
Expand Down
2 changes: 1 addition & 1 deletion test/alwb.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@testset "AWAP" begin
@testset "ALWB" begin
using RasterDataSources: rastername, rasterurl, Values, Deciles,
SoilMoisture, Lower, Upper, Evapotrans, Potential, Areal, Actual, RefCrop, Tall,
DeepDrainage
Expand Down
9 changes: 5 additions & 4 deletions test/awap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
joinpath(ENV["RASTERDATASOURCES_PATH"], "AWAP", "vprp", "vprph09", "20010101.grid.Z")
@test zipname(AWAP, VapourPressure{H09}, Date(2001, 1)) == "20010101.grid.Z"

dates = DateTime(2001, 01, 01), DateTime(2001, 01, 02)
download_raster(AWAP, VapourPressure{H09}; dates=dates)

@test isfile(raster_file)
if Sys.islinux()
dates = DateTime(2001, 01, 01), DateTime(2001, 01, 02)
download_raster(AWAP, VapourPressure{H09}; dates=dates)
@test isfile(raster_file)
end
end
2 changes: 1 addition & 1 deletion test/chelsa-bioclim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

@test rastername(CHELSA{BioClim}, 5) == "CHELSA_bio10_05.tif"

bioclim_path = joinpath(ENV["RASTERDATASOURCES_PATH"], "CHELSA/BioClim")
bioclim_path = joinpath(ENV["RASTERDATASOURCES_PATH"], "CHELSA", "BioClim")
@test rasterpath(CHELSA{BioClim}) == bioclim_path
@test rasterpath(CHELSA{BioClim}, 5) == joinpath(bioclim_path, "CHELSA_bio10_05.tif")

Expand Down
2 changes: 1 addition & 1 deletion test/worldclim-bioclim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

raster_file = joinpath(ENV["RASTERDATASOURCES_PATH"], "WorldClim", "BioClim", "wc2.1_10m_bio_2.tif")
@test rasterpath(WorldClim{BioClim}, 2, "10m") == raster_file
@test download_raster(WorldClim{BioClim}; layer=2, resolution="10m") == raster_file
@test download_raster(WorldClim{BioClim}, 2; resolution="10m") == raster_file
@test isfile(raster_file)
end
2 changes: 1 addition & 1 deletion test/worldclim-climate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@

raster_file = joinpath(ENV["RASTERDATASOURCES_PATH"], "WorldClim", "Climate", "wind", "wc2.1_10m_wind_01.tif")
@test rasterpath(WorldClim{Climate}, :wind, "10m", 1) == raster_file
@test download_raster(WorldClim{Climate}; layer=:wind, resolution="10m", month=1) == raster_file
@test download_raster(WorldClim{Climate}, :wind; resolution="10m", month=1) == raster_file
@test isfile(raster_file)
end
4 changes: 2 additions & 2 deletions test/worldclim-weather.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

using RasterDataSources: rastername, zipurl, zipname, zippath

raster_file = joinpath(ENV["RASTERDATASOURCES_PATH"], "WorldClim/Weather/prec/wc2.1_2.5m_prec_2001-01.tif")
raster_file = joinpath(ENV["RASTERDATASOURCES_PATH"], "WorldClim", "Weather", "prec", "wc2.1_2.5m_prec_2001-01.tif")
@test rasterpath(WorldClim{Weather}, :prec, Date(2001, 1)) == raster_file
@test rastername(WorldClim{Weather}, :prec, Date(2001, 1)) == "wc2.1_2.5m_prec_2001-01.tif"

zip_file = joinpath(ENV["RASTERDATASOURCES_PATH"], "WorldClim/Weather/zips/wc2.1_2.5m_prec_2010-2018.zip")
zip_file = joinpath(ENV["RASTERDATASOURCES_PATH"], "WorldClim", "Weather", "zips", "wc2.1_2.5m_prec_2010-2018.zip")
@test zippath(WorldClim{Weather}, :prec, Date(2010)) == zip_file
@test zipurl(WorldClim{Weather}, :prec, Date(2010)) ==
URI(scheme="https", host="biogeo.ucdavis.edu", path="/data/worldclim/v2.1/hist/wc2.1_2.5m_prec_2010-2018.zip")
Expand Down

0 comments on commit d16a72a

Please sign in to comment.