YAXArrays.jl
YAXArrays.jl copied to clipboard
How to make a moving Window with axis to one full axis additionally
I want to do a moving window on longitude and latitude but have an additional axis that would take the full axis along. This is needed for either time series comparisons or for spectral diversity.
Basically it is about replacing these indims definitions with the new MovingIntervals definition.
indims = InDims("Time",MovingWindow(latax,windowstep,windowstep),MovingWindow(lonax,windowstep,windowstep))
outdims=OutDims(CategoricalAxis("Distfuns", string.(distfuns)), backend=:zarr, path=path, overwrite=true)
vhcomp = mapCube(innerneighbors!, cube, distfuns, aggfun, normfun, timebuffer; indims, outdims)
I tried to define a MovingIntervals that would capture the whole dimension but I didn't succeed. I also trying to make an xmap with the result of windows but that failed with the following error:
julia> xmap(mean, meanwindows ⊘ :band)
ERROR: MethodError: no method matching windows(::YAXArrays.Xmap.DimWindowArray{YAXArray{…}, Tuple{…}, Tuple{…}, Tuple{…}}, ::Pair{Symbol, Whole})
The function `windows` exists, but no method is defined for this combination of argument types.
Closest candidates are:
windows(::Union{AbstractDimArray, AbstractDimStack}, ::Pair{<:Any, <:Union{Function, Type}}, Pair{<:Any, <:Union{Function, Type}}...)
@ YAXArrays ~/.julia/packages/YAXArrays/nQ22T/src/DAT/xmap.jl:25
windows(::Union{AbstractDimArray, AbstractDimStack}, ::Any)
@ YAXArrays ~/.julia/packages/YAXArrays/nQ22T/src/DAT/xmap.jl:23
windows(::Union{AbstractDimArray, AbstractDimStack}, ::Tuple{DimensionalData.Dimensions.Dimension, Vararg{DimensionalData.Dimensions.Dimension}})
@ YAXArrays ~/.julia/packages/YAXArrays/nQ22T/src/DAT/xmap.jl:33
...
Stacktrace:
[1] ⊘(a::YAXArrays.Xmap.DimWindowArray{YAXArray{…}, Tuple{…}, Tuple{…}, Tuple{…}}, b::Tuple{Symbol})
@ YAXArrays.Xmap ~/.julia/packages/YAXArrays/nQ22T/src/DAT/xmap.jl:20
[2] ⊘(a::YAXArrays.Xmap.DimWindowArray{YAXArray{…}, Tuple{…}, Tuple{…}, Tuple{…}}, b::Symbol)
@ YAXArrays.Xmap ~/.julia/packages/YAXArrays/nQ22T/src/DAT/xmap.jl:21
[3] top-level scope
@ REPL[78]:1
Some type information was truncated. Use `show(err)` to see complete types.
I think I found the MovingIntervals that captures the whole axis:
bandinterval = MovingIntervals(:closed, :closed, left=first(dband.val), right=last(dband.val), n=1)
Ah ok, I found Whole() the problem is, that this doesn't work if your dimension labels are not Numbers.