Skip to content

Commit

Permalink
display info when downloading new data
Browse files Browse the repository at this point in the history
  • Loading branch information
tiemvanderdeure committed Feb 28, 2024
1 parent 09a4e4a commit 37a1ada
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/chelsa/bioclim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function _getraster(T::Type{CHELSA{BioClim}}, layer::Integer, version, patch)
_check_layer(T, layer)
path = rasterpath(T, layer, version, patch)
url = rasterurl(T, layer, version, patch)
CHELSA_warn_version(T, layer, version, patch, path)
return _maybe_download(url, path)
end

Expand Down
9 changes: 8 additions & 1 deletion src/chelsa/shared.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,11 @@ const CHELSA_KEYWORDS = """
"""

CHELSA_invalid_version(v, valid_versions = [1,2]) =
throw(ArgumentError("Version $v is not available for CHELSA. Available versions: $valid_versions."))
throw(ArgumentError("Version $v is not available for CHELSA. Available versions: $valid_versions."))

function CHELSA_warn_version(T, layer, version, patch, path)
if version == 2 && !isfile(path) && isfile(rasterpath(T, layer, 1, 2))
@info "File for CHELSA v1.2 detected, but requested version is CHELSA v$version.$patch.
To load data for CHELSA v1.2 instead, set version keyword to 1"
end
end

0 comments on commit 37a1ada

Please sign in to comment.