JuliaDataCubes / EarthDataLab.jl

Julia interface for Reading from the Earth System Datacube
http://earthsystemdatacube.net
Other
33 stars 14 forks source link

Better Error message for failed cubefromshape #240

Open felixcremer opened 3 years ago

felixcremer commented 3 years ago

When I try to make a cubefromshape on a Cube which have X and Y axes instead of "Lat" and "Lon" Axes I get the following error. I can circumvent the problem by renaming my axes before I do the cubefromshape but I think it would be nice to give the user a hint to do that and to have a more informing errror message.

ERROR: MethodError: no method matching length(::Nothing)
Closest candidates are:
  length(::DataStructures.DiBitVector) at /home/crem_fe/.julia/packages/DataStructures/DLSxi/src/dibit_vector.jl:40
  length(::IRTools.Inner.CFG) at /home/crem_fe/.julia/packages/IRTools/aSVI5/src/passes/passes.jl:18
  length(::VSCodeServer.JSON.Parser.MemoryParserState) at /home/crem_fe/.vscode/extensions/julialang.language-julia-1.0.10/scripts/packages/JSON/src/Parser.jl:29
  ...
Stacktrace:
 [1] cubefromshape_single(::String, ::Nothing, ::Nothing; labelsym::Nothing, T::Type{T} where T, kwargs::Base.Iterators.Pairs{Symbol,Nothing,Tuple{Symbol},NamedTuple{(:wrap,),Tuple{Nothing}}}) at /home/crem_fe/.julia/dev/ESDL/src/Shapes.jl:52
 [2] cubefromshape(::String, ::Vararg{Any,N} where N; samplefactor::Nothing, kwargs::Base.Iterators.Pairs{Symbol,Nothing,Tuple{Symbol},NamedTuple{(:wrap,),Tuple{Nothing}}}) at /home/crem_fe/.julia/dev/ESDL/src/Shapes.jl:77
 [3] cubefromshape(::String, ::YAXArray{Union{Missing, Float32},4,DiskArrayTools.DiskArrayStack{Union{Missing, Float32},4,Zarr.ZArray{Union{Missing, Float32},3,Zarr.BloscCompressor,Zarr.DirectoryStore},1},Array{CubeAxis,1}}; kwargs::Base.Iterators.Pairs{Symbol,Nothing,Tuple{Symbol},NamedTuple{(:wrap,),Tuple{Nothing}}}) at /home/crem_fe/.julia/dev/ESDL/src/Shapes.jl:74
 [4] randinds(::YAXArray{Union{Missing, Float32},4,DiskArrayTools.DiskArrayStack{Union{Missing, Float32},4,Zarr.ZArray{Union{Missing, Float32},3,Zarr.BloscCompressor,Zarr.DirectoryStore},1},Array{CubeAxis,1}}, ::String, ::Int64; seed::Int64, nsamples::Int64, wrap::Nothing, inner::Bool) at /home/crem_fe/.julia/dev/ESDLHelpers/src/shapesampling.jl:31
 [5] getsample(::YAXArray{Union{Missing, Float32},4,DiskArrayTools.DiskArrayStack{Union{Missing, Float32},4,Zarr.ZArray{Union{Missing, Float32},3,Zarr.BloscCompressor,Zarr.DirectoryStore},1},Array{CubeAxis,1}}, ::String, ::Int64, ::Int64; seed::Int64, nsamples::Int64, wrap::Nothing, inner::Bool) at /home/crem_fe/.julia/dev/ESDLHelpers/src/shapesampling.jl:47
 [6] get_data(::YAXArray{Union{Missing, Float32},4,DiskArrayTools.DiskArrayStack{Union{Missing, Float32},4,Zarr.ZArray{Union{Missing, Float32},3,Zarr.BloscCompressor,Zarr.DirectoryStore},1},Array{CubeAxis,1}}, ::String, ::Array{String,1}) at /home/crem_fe/Documents/papers_wip/EMDAmazonas/scripts/intro_sorted.jl:74