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

Conversion of a DimArray with NoMetadata() to a YAXArray fails #16

Open
felixcremer opened this issue Nov 21, 2022 · 1 comment
Open

Comments

@felixcremer
Copy link
Member

When I try to convert a rasterisation from Rasters.jl to a YAXArray this fails, because YAXArray can't deal with the DimensionalData.Dimensions.LookupArrays.NoMetadata type.
For a MWE see rafaqz/Rasters.jl#337.

When I try to convert the raster file I get the error below, but I can circumvent it when I force a metadata entry like so:

#This works because of the metadata entry.
julia> yaxconvert(YAXArray, DimArray(shpras, metadata=Dict("freqpath"=>freqpath)))

I am not sure, whether it is worth it to fix this when we are switching to DimensionalData.

yaxconvert(YAXArray, DimArray(shpras))
ERROR: MethodError: Cannot `convert` an object of type 
  DimensionalData.Dimensions.LookupArrays.NoMetadata to an object of type 
  Dict{String}
Closest candidates are:
  convert(::Type{T}, ::T) where T<:AbstractDict at abstractdict.jl:559
  convert(::Type{T}, ::AbstractDict) where T<:AbstractDict at abstractdict.jl:561
  convert(::Type, ::GeoInterface.AbstractGeometryTrait, ::Any) at ~/.julia/packages/GeoInterface/J298z/src/fallbacks.jl:112
  ...
Stacktrace:
 [1] YAXArray(axes::Vector{RangeAxis{Float64, S, R} where {S, R<:AbstractVector{Float64}}}, data::Raster{Union{Missing, Int64}, 2, Tuple{X{Projected{Float64, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Regular{Float64}, DimensionalData.Dimensions.LookupArrays.Intervals{DimensionalData.Dimensions.LookupArrays.Start}, DimensionalData.Dimensions.LookupArrays.NoMetadata, Nothing, Nothing, X{Colon}}}, Y{Projected{Float64, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Regular{Float64}, DimensionalData.Dimensions.LookupArrays.Intervals{DimensionalData.Dimensions.LookupArrays.Start}, DimensionalData.Dimensions.LookupArrays.NoMetadata, Nothing, Nothing, Y{Colon}}}}, Tuple{}, Matrix{Union{Missing, Int64}}, Symbol, DimensionalData.Dimensions.LookupArrays.NoMetadata, Missing}, properties::DimensionalData.Dimensions.LookupArrays.NoMetadata, chunks::DiskArrays.GridChunks{2}, cleaner::Vector{YAXArrays.Cubes.CleanMe})
   @ YAXArrays.Cubes ~/.julia/dev/YAXArrays/src/Cubes/Cubes.jl:119
 [2] YAXArray(axes::Vector{RangeAxis{Float64, S, R} where {S, R<:AbstractVector{Float64}}}, data::Raster{Union{Missing, Int64}, 2, Tuple{X{Projected{Float64, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Regular{Float64}, DimensionalData.Dimensions.LookupArrays.Intervals{DimensionalData.Dimensions.LookupArrays.Start}, DimensionalData.Dimensions.LookupArrays.NoMetadata, Nothing, Nothing, X{Colon}}}, Y{Projected{Float64, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Regular{Float64}, DimensionalData.Dimensions.LookupArrays.Intervals{DimensionalData.Dimensions.LookupArrays.Start}, DimensionalData.Dimensions.LookupArrays.NoMetadata, Nothing, Nothing, Y{Colon}}}}, Tuple{}, Matrix{Union{Missing, Int64}}, Symbol, DimensionalData.Dimensions.LookupArrays.NoMetadata, Missing}, properties::DimensionalData.Dimensions.LookupArrays.NoMetadata; cleaner::Vector{YAXArrays.Cubes.CleanMe}, chunks::DiskArrays.GridChunks{2})
   @ YAXArrays.Cubes ~/.julia/dev/YAXArrays/src/Cubes/Cubes.jl:130
 [3] YAXArray(axes::Vector{RangeAxis{Float64, S, R} where {S, R<:AbstractVector{Float64}}}, data::Raster{Union{Missing, Int64}, 2, Tuple{X{Projected{Float64, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Regular{Float64}, DimensionalData.Dimensions.LookupArrays.Intervals{DimensionalData.Dimensions.LookupArrays.Start}, DimensionalData.Dimensions.LookupArrays.NoMetadata, Nothing, Nothing, X{Colon}}}, Y{Projected{Float64, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Regular{Float64}, DimensionalData.Dimensions.LookupArrays.Intervals{DimensionalData.Dimensions.LookupArrays.Start}, DimensionalData.Dimensions.LookupArrays.NoMetadata, Nothing, Nothing, Y{Colon}}}}, Tuple{}, Matrix{Union{Missing, Int64}}, Symbol, DimensionalData.Dimensions.LookupArrays.NoMetadata, Missing}, properties::DimensionalData.Dimensions.LookupArrays.NoMetadata)
   @ YAXArrays.Cubes ~/.julia/dev/YAXArrays/src/Cubes/Cubes.jl:130
 [4] yaxcreate(#unused#::Type{YAXArray}, data::Raster{Union{Missing, Int64}, 2, Tuple{X{Projected{Float64, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Regular{Float64}, DimensionalData.Dimensions.LookupArrays.Intervals{DimensionalData.Dimensions.LookupArrays.Start}, DimensionalData.Dimensions.LookupArrays.NoMetadata, Nothing, Nothing, X{Colon}}}, Y{Projected{Float64, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Regular{Float64}, DimensionalData.Dimensions.LookupArrays.Intervals{DimensionalData.Dimensions.LookupArrays.Start}, DimensionalData.Dimensions.LookupArrays.NoMetadata, Nothing, Nothing, Y{Colon}}}}, Tuple{}, Matrix{Union{Missing, Int64}}, Symbol, DimensionalData.Dimensions.LookupArrays.NoMetadata, Missing}, dimnames::Tuple{Symbol, Symbol}, dimvals::Vector{Projected{Float64, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Regular{Float64}, DimensionalData.Dimensions.LookupArrays.Intervals{DimensionalData.Dimensions.LookupArrays.Start}, DimensionalData.Dimensions.LookupArrays.NoMetadata, Nothing, Nothing}}, atts::DimensionalData.Dimensions.LookupArrays.NoMetadata)
   @ YAXArrays.Cubes ~/.julia/dev/YAXArrays/src/Cubes/Cubes.jl:322
 [5] yaxconvert(T::Type, x::DimArray{Union{Missing, Int64}, 2, Tuple{X{Projected{Float64, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Regular{Float64}, DimensionalData.Dimensions.LookupArrays.Intervals{DimensionalData.Dimensions.LookupArrays.Start}, DimensionalData.Dimensions.LookupArrays.NoMetadata, Nothing, Nothing, X{Colon}}}, Y{Projected{Float64, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Regular{Float64}, DimensionalData.Dimensions.LookupArrays.Intervals{DimensionalData.Dimensions.LookupArrays.Start}, DimensionalData.Dimensions.LookupArrays.NoMetadata, Nothing, Nothing, Y{Colon}}}}, Tuple{}, Raster{Union{Missing, Int64}, 2, Tuple{X{Projected{Float64, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Regular{Float64}, DimensionalData.Dimensions.LookupArrays.Intervals{DimensionalData.Dimensions.LookupArrays.Start}, DimensionalData.Dimensions.LookupArrays.NoMetadata, Nothing, Nothing, X{Colon}}}, Y{Projected{Float64, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Regular{Float64}, DimensionalData.Dimensions.LookupArrays.Intervals{DimensionalData.Dimensions.LookupArrays.Start}, DimensionalData.Dimensions.LookupArrays.NoMetadata, Nothing, Nothing, Y{Colon}}}}, Tuple{}, Matrix{Union{Missing, Int64}}, Symbol, DimensionalData.Dimensions.LookupArrays.NoMetadata, Missing}, Symbol, DimensionalData.Dimensions.LookupArrays.NoMetadata})
   @ YAXArrayBase ~/.julia/dev/YAXArrayBase/src/axisarrays/axisinterface.jl:82
 [6] top-level scope
   @ REPL[58]:1
@meggart
Copy link
Member

meggart commented Nov 21, 2022

This would be quite simple to fix by making sure that yaxconvert always represents its attributes as a Dict.

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