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

BoundsError: attempt to access 0-element Vector{Any} when doing Cube(path_to_zarr_file) #165

Closed
lazarusA opened this issue Aug 30, 2022 · 2 comments

Comments

@lazarusA
Copy link
Collaborator

While trying to load a Zarr file into a Cube I found the following error:
store example from docs.

using Zarr, YAXArrays
store ="gs://cmip6/CMIP6/ScenarioMIP/DKRZ/MPI-ESM1-2-HR/ssp585/r1i1p1f1/3hr/tas/gn/v20190710/"
g = zopen(store, consolidated=true) # this works 
cube = Cube(store) # this not longer works
ERROR: BoundsError: attempt to access 0-element Vector{Any} at index [1]
Stacktrace:
 [1] getindex
   @ ./array.jl:924 [inlined]
 [2] concatenatecubes(cl::Vector{Any}, cataxis::CategoricalAxis{String, :Variable, Vector{String}})
   @ YAXArrays.Cubes ~/.julia/packages/YAXArrays/p1ysR/src/Cubes/TransformedCubes.jl:30
 [3] Cube(ds::Dataset; joinname::String)
   @ YAXArrays.Datasets ~/.julia/packages/YAXArrays/p1ysR/src/DatasetAPI/Datasets.jl:312
 [4] Cube
   @ ~/.julia/packages/YAXArrays/p1ysR/src/DatasetAPI/Datasets.jl:287 [inlined]
 [5] #Cube#119
   @ ~/.julia/packages/YAXArrays/p1ysR/src/DatasetAPI/Datasets.jl:733 [inlined]
 [6] Cube(s::String)
   @ YAXArrays.Datasets ~/.julia/packages/YAXArrays/p1ysR/src/DatasetAPI/Datasets.jl:733
Status `~/Desktop/JuliaProgramming2022`
[c21b50f5] YAXArrays v0.4.0
  [0a941bbe] Zarr v0.7.3
@lazarusA
Copy link
Collaborator Author

lazarusA commented Aug 31, 2022

solution to my own question:

using Zarr, YAXArrays
import YAXArrays.Datasets: open_dataset
store ="gs://cmip6/CMIP6/ScenarioMIP/DKRZ/MPI-ESM1-2-HR/ssp585/r1i1p1f1/3hr/tas/gn/v20190710/"
g = zopen(store, consolidated=true)
dset = open_dataset(g)
cube = Cube(dset)

@danlooo
Copy link
Member

danlooo commented Dec 7, 2023

I get the same error when storing a YAXArray that has just one element in any dimension:

c = YAXArray([1])
savecube(c, "cube")
Cube("cube")
# ERROR: BoundsError: attempt to access 0-element Vector{Int64} at index [1]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants