Skip to content

Commit

Permalink
construct RasterSeries from AbstractBasicDimArray (#826)
Browse files Browse the repository at this point in the history
* dispatch RasterSeries on AbstractBasicDimArray

* add a test

* add a line to the docs
  • Loading branch information
tiemvanderdeure authored Dec 8, 2024
1 parent 11c6a6c commit 5aa8914
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/series.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ DD.modify(f, A::AbstractRasterSeries) = map(child -> modify(f, child), values(A)
RasterSeries(paths::AbstractArray{<:AbstractString}, dims; child, duplicate_first, kw...)
RasterSeries(path:::AbstractString, dims; ext, separator, child, duplicate_first, kw...)
RasterSeries(objects::AbstractBasicDimArray; kw...)
Concrete implementation of [`AbstractRasterSeries`](@ref).
A `RasterSeries` is an array of `Raster`s or `RasterStack`s, along some dimension(s).
Expand Down Expand Up @@ -127,6 +129,8 @@ function RasterSeries(
) where {A<:AbstractArray{T,N},D<:Tuple,R<:Tuple} where {T,N}
RasterSeries{T,N,D,R,A}(data, dims, refdims)
end
RasterSeries(data::DD.AbstractBasicDimArray; kw...) =
RasterSeries(data, dims(data); kw...)
function RasterSeries(data::AbstractArray{<:Union{AbstractRasterStack,AbstractRaster}}, dims;
refdims=()
)
Expand Down
1 change: 1 addition & 0 deletions test/series.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ stack1 = RasterStack(r1, r2; name=(:r1, :r2))
stack2 = RasterStack(r1a, r2a; name=(:r1, :r2))
dates = [DateTime(2017), DateTime(2018)]
ser = RasterSeries([stack1, stack2], Ti(dates))
@test RasterSeries(DimArray([stack1, stack2],Ti(dates))) == ser
@test issorted(dates)

@testset "getindex returns the currect types" begin
Expand Down

0 comments on commit 5aa8914

Please sign in to comment.