Skip to content

Commit

Permalink
critical fix of ncloading with arbitrary dates
Browse files Browse the repository at this point in the history
  • Loading branch information
Datseris committed Dec 7, 2020
1 parent 72e1fef commit 713c602
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/core/nc_io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ end
function vector2range(t::Vector{<:Dates.AbstractTime})
tsamp = temporal_sampling(t)
period = tsamp2period(tsamp)
isnothing(period) && return t
r = t[1]:period:t[end]
return r == t ? r : t
end
Expand Down
4 changes: 2 additions & 2 deletions src/physical_dimensions/temporal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ temporal_sampling(t::StepRange{<:Any,Day}) = :daily
temporal_sampling(t::StepRange{<:Any,Hour}) = :hourly
temporal_sampling(t::StepRange{<:Any,<:Any}) = :other

"return the appropriate subtype of Dates.Period."
"return the appropriate subtype of `Dates.Period` or `nothing`."
function tsamp2period(tsamp)
tsamp == :monthly && return Month(1)
tsamp == :yearly && return Year(1)
tsamp == :daily && return Day(1)
tsamp == :hourly && return Hour(1)
error("Don't know the period of $tsamp sampling!")
tsamp == :other && return nothing
end


Expand Down

0 comments on commit 713c602

Please sign in to comment.