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

Can't save a YAXArray with Variable axes as netcdf #3

Open
felixcremer opened this issue Feb 5, 2021 · 1 comment
Open

Can't save a YAXArray with Variable axes as netcdf #3

felixcremer opened this issue Feb 5, 2021 · 1 comment

Comments

@felixcremer
Copy link
Member

When I try to save the following YAXArray

julia> imfextinds
YAXArray with the following dimensions
FrequencyStats      Axis with 6 elements: FirstLocalMax FirstLocalMin FirstZeroCrossing SecondLocMax SecondLocMin SecondZeroCross 
Y                   Axis with 5820 Elements from 561609.15 to 736179.15
X                   Axis with 7500 Elements from 9.48724066e6 to 9.26227066e6
Total size: 999.07 MB

this fails with the following error:

julia> savecube(imfextinds,"data/cubes/s1cube_jurua_vh_smallchunks_imfs_4_local_extinds_4_newesdl.nc", backend=:netcdf)
┌ Warning: There are still cache misses
└ @ YAXArrays.DAT ~/.julia/dev/YAXArrays/src/DAT/DAT.jl:697
ERROR: ArgumentError: array must be non-empty
Stacktrace:
  [1] popfirst!
    @ ./array.jl:1288 [inlined]
  [2] jl2nc(t::DataType)
    @ NetCDF ~/.julia/packages/NetCDF/0sRUL/src/NetCDF.jl:90
  [3] getNCType(t::DataType)
    @ NetCDF ~/.julia/packages/NetCDF/0sRUL/src/NetCDF.jl:100
  [4] NcVar(name::String, dimin::Vector{NcDim}; atts::Dict{String, Any}, t::DataType, compress::Int64, chunksize::Tuple{Int64})
    @ NetCDF ~/.julia/packages/NetCDF/0sRUL/src/NetCDF.jl:255
  [5] nccreate(::String, ::String, ::String, ::Vararg{Any, N} where N; atts::Dict{String, Any}, gatts::Dict{Any, Any}, compress::Int64, t::DataType, mode::UInt16, chunksize::Tuple{Int64})
    @ NetCDF ~/.julia/packages/NetCDF/0sRUL/src/NetCDF.jl:1208
  [6] #add_var#75
    @ ~/.julia/packages/YAXArrayBase/OgYsV/src/datasets/netcdf.jl:50 [inlined]
  [7] add_var
    @ ~/.julia/packages/YAXArrayBase/OgYsV/src/datasets/netcdf.jl:49 [inlined]
  [8] #add_var#2
    @ ~/.julia/packages/YAXArrayBase/OgYsV/src/datasets/datasetinterface.jl:46 [inlined]
  [9] add_var
    @ ~/.julia/packages/YAXArrayBase/OgYsV/src/datasets/datasetinterface.jl:46 [inlined]
 [10] arrayfromaxis(p::YAXArrayBase.NetCDFDataset, ax::CategoricalAxis{Zarr.MaxLengthStrings.MaxLengthString{17, UInt8}, :FrequencyStats, Vector{Zarr.MaxLengthStrings.MaxLengthString{17, UInt8}}}, offs::Int64)
    @ YAXArrays.Datasets ~/.julia/dev/YAXArrays/src/DatasetAPI/Datasets.jl:319
 [11] (::YAXArrays.Datasets.var"#60#69"{YAXArrayBase.NetCDFDataset})(ax::CategoricalAxis{Zarr.MaxLengthStrings.MaxLengthString{17, UInt8}, :FrequencyStats, Vector{Zarr.MaxLengthStrings.MaxLengthString{17, UInt8}}}, co::Int64)
    @ YAXArrays.Datasets ~/.julia/dev/YAXArrays/src/DatasetAPI/Datasets.jl:253
 [12] foreach(::Function, ::Vector{CubeAxis}, ::Tuple{Int64, Int64, Int64})
    @ Base ./abstractarray.jl:2129
 [13] createdataset(DS::Type, axlist::Vector{CubeAxis}; path::String, persist::Nothing, T::Type, chunksize::Tuple{Int64, Int64, Int64}, chunkoffset::Tuple{Int64, Int64, Int64}, overwrite::Bool, properties::Dict{String, Any}, datasetaxis::String, kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ YAXArrays.Datasets ~/.julia/dev/YAXArrays/src/DatasetAPI/Datasets.jl:252
 [14] generateOutCube(::Type{YAXArrayBase.NetCDFDataset}, eltype::Type, oc::YAXArrays.DAT.OutputCube, loopcachesize::Vector{Int64}, co::Tuple{Int64, Int64, Int64}; kwargs::Base.Iterators.Pairs{Symbol, String, Tuple{Symbol}, NamedTuple{(:path,), Tuple{String}}})
    @ YAXArrays.DAT ~/.julia/dev/YAXArrays/src/DAT/DAT.jl:515
 [15] generateOutCube(oc::YAXArrays.DAT.OutputCube, ispar::Base.RefValue{Bool}, max_cache::Float64, loopcachesize::Vector{Int64}, co::Tuple{Int64, Int64, Int64})
    @ YAXArrays.DAT ~/.julia/dev/YAXArrays/src/DAT/DAT.jl:539
 [16] (::YAXArrays.DAT.var"#106#107"{YAXArrays.DAT.DATConfig{1, 1}, Tuple{Int64}})(c::YAXArrays.DAT.OutputCube)
    @ YAXArrays.DAT ~/.julia/dev/YAXArrays/src/DAT/DAT.jl:534
 [17] foreach(f::YAXArrays.DAT.var"#106#107"{YAXArrays.DAT.DATConfig{1, 1}, Tuple{Int64}}, itr::Tuple{YAXArrays.DAT.OutputCube})
    @ Base ./abstractarray.jl:2128
 [18] generateOutCubes(dc::YAXArrays.DAT.DATConfig{1, 1})
    @ YAXArrays.DAT ~/.julia/dev/YAXArrays/src/DAT/DAT.jl:532
 [19] mapCube(::YAXArrays.DAT.var"#cop#260", ::Tuple{YAXArray{Union{Missing, Float32}, 3, Zarr.ZArray{Union{Missing, Float32}, 3, Zarr.BloscCompressor, Zarr.DirectoryStore}, Vector{CubeAxis}}}; max_cache::Float64, indims::InDims, outdims::OutDims, inplace::Bool, ispar::Bool, debug::Bool, include_loopvars::Bool, showprog::Bool, nthreads::Vector{Int64}, loopchunksize::Dict{Any, Any}, kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ YAXArrays.DAT ~/.julia/dev/YAXArrays/src/DAT/DAT.jl:276
 [20] #mapCube#34
    @ ~/.julia/dev/YAXArrays/src/DAT/DAT.jl:178 [inlined]
 [21] savecube(c::YAXArray{Union{Missing, Float32}, 3, Zarr.ZArray{Union{Missing, Float32}, 3, Zarr.BloscCompressor, Zarr.DirectoryStore}, Vector{CubeAxis}}, name::String; chunksize::Dict{Any, Any}, max_cache::Float64, backend::Symbol, backendargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ YAXArrays.DAT ~/.julia/dev/YAXArrays/src/DAT/CubeIO.jl:38
 [22] top-level scope
    @ REPL[16]:1

but when I use subsetcube to separate one of the variables I can save it.

@meggart
Copy link
Member

meggart commented Feb 9, 2021

I think the reason here is that the Element type of the Axis is a Zarr.MaxLengthString and NetCDF does not know how to deal with this Data Type when saving the axis. I am currently not sure where exactly to fix this: Inside NetCDF.jl would be a hassle. It would probably be better if we, at some point during axis construction would convert AbstractStrings to actual strings. Although this is also not very consistent. Or one modifies the way this function works to first check if the provider can deal with the element type.

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