diff --git a/Project.toml b/Project.toml index cb10fc26..20363e5f 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ClimateBase" uuid = "35604d93-0fb8-4872-9436-495b01d137e2" authors = ["Datseris ", "Philippe Roy "] -version = "0.14.3" +version = "0.14.4" [deps] Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" diff --git a/src/core/nc_io.jl b/src/core/nc_io.jl index 0a068c34..d6e219cc 100644 --- a/src/core/nc_io.jl +++ b/src/core/nc_io.jl @@ -281,8 +281,8 @@ function vector2range(t::Vector{<:Dates.AbstractTime}) tsamp = temporal_sampling(t) period = tsamp2period(tsamp) isnothing(period) && return t - t1 = period == :hourly ? t[1] : Date(t[1]) - tf = period == :hourly ? t[end] : Date(t[end]) + t1 = tsamp == :hourly ? t[1] : Date(t[1]) + tf = tsamp == :hourly ? t[end] : Date(t[end]) r = t1:period:tf return r == t ? r : t # final safety check to ensure equal values end diff --git a/src/physical_dimensions/spatial.jl b/src/physical_dimensions/spatial.jl index 690b7137..bb7efb02 100644 --- a/src/physical_dimensions/spatial.jl +++ b/src/physical_dimensions/spatial.jl @@ -129,7 +129,7 @@ using StatsBase """ spacemean(A::ClimArray [, W]) = spaceagg(mean, A, W) -Average given `A` over its spatial coordinates. +Average `A` over its spatial coordinates. Optionally provide statistical weights in `W`. """ spacemean(A, exw=nothing) = spaceagg(mean, A, exw) @@ -147,7 +147,7 @@ function spaceagg(::OrthogonalSpace, f, A::AbDimArray, w=nothing) wtype = spaceweightassert(A, w) cosweights = repeat(cosd.(dims(A, Lat).val)', size(A, Lon)) if dimindex(A, Lon) > dimindex(A, Lat) - error("At the moment this function assumes that Lon preceeds Lat, use `permutdims`.") + error("At the moment this function assumes that Lon preceeds Lat, use `permutedims`.") end other = otherdims(A, (Lon, Lat)) # pre-calculate weights if possible diff --git a/test/io_tests.jl b/test/io_tests.jl index 83243c82..16260711 100644 --- a/test/io_tests.jl +++ b/test/io_tests.jl @@ -1,4 +1,11 @@ -@testset "NetCDF IO" begin +@testset "NetCDF IO" begin + +@testset "vector2range" begin + th = collect(thourly) + th2 = ClimateBase.vector2range(th) + @test th2 isa AbstractRange + @test th2 == th +end @testset "NetCDF standard tests" begin globat = Dict("history" => "test") diff --git a/test/runtests.jl b/test/runtests.jl index 97d1f0f9..7b88dd7c 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -15,6 +15,7 @@ lats = -86:4:86 lons = collect(0.5:10:360) t = Date(2000, 3, 15):Month(1):Date(2020, 2, 15) tdaily = Date(2000, 3, 15):Day(1):Date(2020, 3, 14) +thourly = DateTime(2000, 3, 15):Hour(1):DateTime(2000, 6, 14) d = (Lon(lons), Lat(lats), Time(t)) A = zeros([length(x) for x in (lons, lats, t)]...)