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

KeyError: key :time not found #330

Closed
Balinus opened this issue Sep 15, 2023 · 2 comments
Closed

KeyError: key :time not found #330

Balinus opened this issue Sep 15, 2023 · 2 comments

Comments

@Balinus
Copy link
Contributor

Balinus commented Sep 15, 2023

Hello,

using MWE from #329, I can't save the dataset on disk due to a key error. Here's the adapted MWE:

#using NCDatasets
#using URIs
# using Dates
using YAXArrays
using NetCDF
using Zarr

# URL RDRS sur Pavics
url = "https://pavics.ouranos.ca/twitcher/ows/proxy/thredds/dodsC/datasets/reanalyses/day_RDRSv2.1_NAM.ncml"

# Lecture de la structure
ds = open_dataset(url)

filename = "day_RDRSv2.1_NAM_vDataset.zarr"
savedataset(ds, path=filename, driver = :zarr)

# Returns following error
KeyError: key :time not found

Stacktrace:
 [1] getindex(h::Dict{Symbol, Int64}, key::Symbol)
   @ Base ./dict.jl:484
 [2] #93
   @ ./none:0 [inlined]
 [3] iterate
   @ ./generator.jl:47 [inlined]
 [4] collect_to!(dest::Vector{Int64}, itr::Base.Generator{Base.KeySet{Symbol, Dict{Symbol, DimensionalData.Dimensions.Dimension}}, YAXArrays.Datasets.var"#93#99"{Dict{Symbol, Int64}}}, offs::Int64, st::Int64)
   @ Base ./array.jl:840
 [5] collect_to_with_first!
   @ ./array.jl:818 [inlined]
 [6] collect(itr::Base.Generator{Base.KeySet{Symbol, Dict{Symbol, DimensionalData.Dimensions.Dimension}}, YAXArrays.Datasets.var"#93#99"{Dict{Symbol, Int64}}})
   @ Base ./array.jl:792
 [7] savedataset(ds::YAXArrays.Datasets.Dataset; path::String, persist::Nothing, overwrite::Bool, append::Bool, skeleton::Bool, backend::Symbol, driver::Symbol, max_cache::Float64, writefac::Float64, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ YAXArrays.Datasets ~/.julia/packages/YAXArrays/lvvMa/src/DatasetAPI/Datasets.jl:562
 [8] top-level scope
   @ In[15]:2
@kongdd
Copy link
Contributor

kongdd commented Oct 1, 2023

I guess this issue is because DD.dim2key(ti) and DD.name(ti) return different value.

using DimensionalData
using DimensionalData: DimensionalData as DD
using Dates

ti = Ti(DateTime(2001):Month(1):DateTime(2002))

@show DD.dim2key(ti);
@show DD.name(ti);
DD.dim2key(ti) = :Ti
DD.name(ti) = :Time

@kongdd
Copy link
Contributor

kongdd commented Oct 1, 2023

can close now. solved by #337

@Balinus Balinus closed this as completed Oct 4, 2023
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