MakieOrg / Makie.jl

Interactive data visualizations and plotting in Julia
https://docs.makie.org/stable
MIT License
2.42k stars 313 forks source link

image! fails for MappedArray{Float32} in GLMakie but not CairoMakie #2609

Open felixcremer opened 1 year ago

felixcremer commented 1 year ago

I try to make an RGB plot of multiple Arrays and I get the error below for a MappedArray{Float32} but not for Float64. The plotting of the Float32 Array works also in CairoMakie but fails in GLMakie. I can put together an MWE next week with small example data.

This is the code I ran before getting that:

fig = Figure(fontsize=36)
axrgb = Axis(fig[1,1]; yticklabelrotation=Float32(π/2), title="RGB of S1 $(pol) data during low, median and high water", aspect=DataAspect())
rgbmap = image!(axrgb, lon, lat, rgbdata,interpolate=false)#, colorrange=meanlim)
fig

axtstats = Axis(fig[1,2]; yticklabelrotation=Float32(π/2), title="RGB of S1 $(pol) temporal mean, 5th and 95th percentile", aspect=DataAspect())
statsma = image!(axtstats, lon, lat, rgbstats,interpolate=false)#, colorrange=meanlim)
fig
GLMakie ~/.julia/packages/GLMakie/6Blp9/src/drawing_primitives.jl:482
  [3] (::GLMakie.var"#232#235"{GLMakie.Screen{GLFW.Window}, Scene, Image{Tuple{Vector{Float32}, Vector{Float32}, MappedArrays.MultiMappedArray{RGB{Float32}, 2, Tuple{Matrix{Float32}, Matrix{Float32}, Matrix{Float32}}, Type{RGB{Float32}}, typeof(ImageCore.extractchannels)}}}})(gl_attributes::Dict{Symbol, Any})
    @ GLMakie ~/.julia/packages/GLMakie/6Blp9/src/drawing_primitives.jl:456
  [4] (::GLMakie.var"#168#171"{GLMakie.var"#232#235"{GLMakie.Screen{GLFW.Window}, Scene, Image{Tuple{Vector{Float32}, Vector{Float32}, MappedArrays.MultiMappedArray{RGB{Float32}, 2, Tuple{Matrix{Float32}, Matrix{Float32}, Matrix{Float32}}, Type{RGB{Float32}}, typeof(ImageCore.extractchannels)}}}}, GLMakie.Screen{GLFW.Window}, Scene, Image{Tuple{Vector{Float32}, Vector{Float32}, MappedArrays.MultiMappedArray{RGB{Float32}, 2, Tuple{Matrix{Float32}, Matrix{Float32}, Matrix{Float32}}, Type{RGB{Float32}}, typeof(ImageCore.extractchannels)}}}})()
    @ GLMakie ~/.julia/packages/GLMakie/6Blp9/src/drawing_primitives.jl:111
  [5] get!(default::GLMakie.var"#168#171"{GLMakie.var"#232#235"{GLMakie.Screen{GLFW.Window}, Scene, Image{Tuple{Vector{Float32}, Vector{Float32}, MappedArrays.MultiMappedArray{RGB{Float32}, 2, Tuple{Matrix{Float32}, Matrix{Float32}, Matrix{Float32}}, Type{RGB{Float32}}, typeof(ImageCore.extractchannels)}}}}, GLMakie.Screen{GLFW.Window}, Scene, Image{Tuple{Vector{Float32}, Vector{Float32}, MappedArrays.MultiMappedArray{RGB{Float32}, 2, Tuple{Matrix{Float32}, Matrix{Float32}, Matrix{Float32}}, Type{RGB{Float32}}, typeof(ImageCore.extractchannels)}}}}, h::Dict{UInt64, GLMakie.GLAbstraction.RenderObject}, key::UInt64)
    @ Base ./dict.jl:481
  [6] cached_robj!(robj_func::GLMakie.var"#232#235"{GLMakie.Screen{GLFW.Window}, Scene, Image{Tuple{Vector{Float32}, Vector{Float32}, MappedArrays.MultiMappedArray{RGB{Float32}, 2, Tuple{Matrix{Float32}, Matrix{Float32}, Matrix{Float32}}, Type{RGB{Float32}}, typeof(ImageCore.extractchannels)}}}}, screen::GLMakie.Screen{GLFW.Window}, scene::Scene, x::Image{Tuple{Vector{Float32}, Vector{Float32}, MappedArrays.MultiMappedArray{RGB{Float32}, 2, Tuple{Matrix{Float32}, Matrix{Float32}, Matrix{Float32}}, Type{RGB{Float32}}, typeof(ImageCore.extractchannels)}}})
    @ GLMakie ~/.julia/packages/GLMakie/6Blp9/src/drawing_primitives.jl:84
  [7] draw_atomic
    @ ~/.julia/packages/GLMakie/6Blp9/src/drawing_primitives.jl:439 [inlined]
  [8] insert!(screen::GLMakie.Screen{GLFW.Window}, scene::Scene, x::Image{Tuple{Vector{Float32}, Vector{Float32}, MappedArrays.MultiMappedArray{RGB{Float32}, 2, Tuple{Matrix{Float32}, Matrix{Float32}, Matrix{Float32}}, Type{RGB{Float32}}, typeof(ImageCore.extractchannels)}}})
    @ GLMakie ~/.julia/packages/GLMakie/6Blp9/src/drawing_primitives.jl:126
  [9] push!(scene::Scene, plot::Image{Tuple{Vector{Float32}, Vector{Float32}, MappedArrays.MultiMappedArray{RGB{Float32}, 2, Tuple{Matrix{Float32}, Matrix{Float32}, Matrix{Float32}}, Type{RGB{Float32}}, typeof(ImageCore.extractchannels)}}})
    @ Makie ~/.julia/packages/Makie/Za3LL/src/scenes.jl:409
 [10] plot!(scene::Scene, P::Type{Image{Tuple{StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, MappedArrays.MultiMappedArray{RGB{Float32}, 2, Tuple{Matrix{Float32}, Matrix{Float32}, Matrix{Float32}}, Type{RGB{Float32}}, typeof(ImageCore.extractchannels)}}}}, attributes::Attributes, input::Tuple{Observable{StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}}, Observable{StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}}, Observable{MappedArrays.MultiMappedArray{RGB{Float32}, 2, Tuple{Matrix{Float32}, Matrix{Float32}, Matrix{Float32}}, Type{RGB{Float32}}, typeof(ImageCore.extractchannels)}}}, args::Observable{Tuple{Vector{Float32}, Vector{Float32}, MappedArrays.MultiMappedArray{RGB{Float32}, 2, Tuple{Matrix{Float32}, Matrix{Float32}, Matrix{Float32}}, Type{RGB{Float32}}, typeof(ImageCore.extractchannels)}}})
    @ Makie ~/.julia/packages/Makie/Za3LL/src/interfaces.jl:422
 [11] plot!(::Scene, ::Type{Image}, ::Attributes, ::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, ::Vararg{Any}; kw_attributes::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Makie ~/.julia/packages/Makie/Za3LL/src/interfaces.jl:336
 [12] plot!(::Scene, ::Type{Image}, ::Attributes, ::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, ::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, ::MappedArrays.MultiMappedArray{RGB{Float32}, 2, Tuple{Matrix{Float32}, Matrix{Float32}, Matrix{Float32}}, Type{RGB{Float32}}, typeof(ImageCore.extractchannels)})
    @ Makie ~/.julia/packages/Makie/Za3LL/src/interfaces.jl:303
 [13] plot!(::Axis, ::Type{Image}, ::Attributes, ::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, ::Vararg{Any}; kw_attributes::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Makie ~/.julia/packages/Makie/Za3LL/src/makielayout/blocks/axis.jl:776
 [14] plot!(::Axis, ::Type{Image}, ::Attributes, ::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, ::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, ::MappedArrays.MultiMappedArray{RGB{Float32}, 2, Tuple{Matrix{Float32}, Matrix{Float32}, Matrix{Float32}}, Type{RGB{Float32}}, typeof(ImageCore.extractchannels)})
    @ Makie ~/.julia/packages/Makie/Za3LL/src/makielayout/blocks/axis.jl:763
 [15] plot!(::Type{Image}, ::Axis, ::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, ::Vararg{Any}; kw_attributes::Base.Pairs{Symbol, Bool, Tuple{Symbol}, NamedTuple{(:interpolate,), Tuple{Bool}}})
    @ Makie ~/.julia/packages/Makie/Za3LL/src/makielayout/blocks/axis.jl:793
 [16] image!(::Axis, ::Vararg{Any}; attributes::Base.Pairs{Symbol, Bool, Tuple{Symbol}, NamedTuple{(:interpolate,), Tuple{Bool}}})
    @ MakieCore ~/.julia/packages/MakieCore/bV281/src/recipes.jl:38
 [17] top-level scope
    @ ~/Documents/papers_wip/EMDAmazonas_datalad/scripts/plotting/fig4b_zoomcomp_presentation.jl:80
ffreyer commented 2 months ago

Is this still a problem? If it is can you make your example runnable?

felixcremer commented 2 months ago

I'll have a look next week.