Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

concatenation error #391

Open
gaelforget opened this issue May 3, 2024 · 1 comment
Open

concatenation error #391

gaelforget opened this issue May 3, 2024 · 1 comment
Labels
documentation Improvements or additions to documentation

Comments

@gaelforget
Copy link

Shouldn't this work?

using YAXArrays

axlist1 = (
    Dim{:time}(range(1, 20, length=20)),
    Dim{:lon}(range(1, 10, length=10)),
    Dim{:lat}(range(1, 5, length=15))
    )
data1 = rand(20, 10, 15)
ds1 = YAXArray(axlist1, data1)

axlist2 = (
    Dim{:time}(range(21, 40, length=20)),
    Dim{:lon}(range(1, 10, length=10)),
    Dim{:lat}(range(1, 5, length=15))
    )
data2 = rand(20, 10, 15)
ds2 = YAXArray(axlist2, data2)

YAXArrays.Datasets.merge_datasets([ds1 ds2])

It gives this error :

julia> YAXArrays.Datasets.merge_datasets([ds1 ds2])
ERROR: MethodError: no method matching _cat(::Val{2}, ::YAXArray{Float64, 3, Array{…}, Tuple{…}, Dict{…}}, ::YAXArray{Float64, 3, Array{…}, Tuple{…}, Dict{…}})
You may have intended to import Base._cat

Closest candidates are:
  _cat(::Tuple, ::DimensionalData.AbstractDimArray, ::DimensionalData.AbstractDimArray...)
   @ DimensionalData ~/.julia/packages/DimensionalData/yZgLJ/src/array/methods.jl:271
  _cat(::Union{Int64, Symbol, Type{<:DimensionalData.Dimensions.Dimension}, DimensionalData.Dimensions.Dimension}, ::DimensionalData.AbstractDimArray, ::DimensionalData.AbstractDimArray...)
   @ DimensionalData ~/.julia/packages/DimensionalData/yZgLJ/src/array/methods.jl:268

Stacktrace:
 [1] cat(A1::YAXArray{…}, As::YAXArray{…}; dims::Val{…})
   @ DimensionalData ~/.julia/packages/DimensionalData/yZgLJ/src/array/methods.jl:266
 [2] hcat(A::YAXArray{Float64, 3, Array{…}, Tuple{…}, Dict{…}}, B::YAXArray{Float64, 3, Array{…}, Tuple{…}, Dict{…}})
   @ Base ./abstractarray.jl:2004
 [3] top-level scope
   @ REPL[10]:1
Some type information was truncated. Use `show(err)` to see complete types.

The issue seems related to issues #365 #216 #247 #319

Ultimately I am aiming to merge a series of monthly files to do a long time average. Found out about open_mfdataset and merge_datasets after some digging. Would advocate for exporting and documenting these functions if they worked / once they work.

@felixcremer
Copy link
Member

Yeah it is unfortunate, that this is not really documented, but you can use cat via the implementation in DimensionalData

julia> c = cat(ds1, ds2, dims=:time)

This works for the time series case. This would fail, if we would like to combine multiple cubes spatially.

@lazarusA lazarusA added the documentation Improvements or additions to documentation label Sep 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants