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

Plotting heatmaps using CairoMakie fails after version 0.8.1 #492

Closed
tomchor opened this issue Aug 5, 2023 · 15 comments
Closed

Plotting heatmaps using CairoMakie fails after version 0.8.1 #492

tomchor opened this issue Aug 5, 2023 · 15 comments

Comments

@tomchor
Copy link

tomchor commented Aug 5, 2023

The following code

using Rasters
import NCDatasets
using CairoMakie

ds = RasterStack("kelvin_helmholtz.nc")
fig = Figure()
ax1 = Axis(fig[1, 1])
hm1 = heatmap!(ax1, ds.Ri[Ti=100, yC=1]; colormap = :bwr, colorrange = (-1, +1))

throws me an error:

Error showing value of type Figure:
ERROR: MethodError: Cannot `convert` an object of type 
  DimArray{ColorTypes.RGBA{Float32}, 2, Tuple{Dim{:xC, DimensionalData.Dimensions.LookupArrays.Sampled{Float64, Vector{Float64}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Regular{Float64}, DimensionalData.Dimensions.LookupArrays.Points, DimensionalData.Dimensions.LookupArrays.Metadata{Rasters.NCDsource, Dict{String, Any}}}}, Dim{:zF, DimensionalData.Dimensions.LookupArrays.Sampled{Float64, Vector{Float64}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Regular{Float64}, DimensionalData.Dimensions.LookupArrays.Points, DimensionalData.Dimensions.LookupArrays.Metadata{Rasters.NCDsource, Dict{String, Any}}}}}, Tuple{}, Matrix{ColorTypes.RGBA{Float32}}, DimensionalData.NoName, DimensionalData.Dimensions.LookupArrays.NoMetadata} to an object of type 
  Union{ColorTypes.RGBA{Float32}, Matrix{ColorTypes.RGBA{Float32}}}

Closest candidates are:
  convert(::Type{T}, ::T) where T
   @ Base Base.jl:64

Stacktrace:
  [1] numbers_to_colors(numbers::DimArray{Float32, 2, Tuple{Dim{:xC, DimensionalData.Dimensions.LookupArrays.Sampled{Float64, Vector{Float64}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Regular{Float64}, DimensionalData.Dimensions.LookupArrays.Points, DimensionalData.Dimensions.LookupArrays.Metadata{Rasters.NCDsource, Dict{String, Any}}}}, Dim{:zF, DimensionalData.Dimensions.LookupArrays.Sampled{Float64, Vector{Float64}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Regular{Float64}, DimensionalData.Dimensions.LookupArrays.Points, DimensionalData.Dimensions.LookupArrays.Metadata{Rasters.NCDsource, Dict{String, Any}}}}}, Tuple{}, Matrix{Float32}, DimensionalData.NoName, DimensionalData.Dimensions.LookupArrays.NoMetadata}, colormap::Vector{ColorTypes.RGBA{Float32}}, colorscale::Function, colorrange::Vec{2, Float32}, lowclip::ColorTypes.RGBA{Float32}, highclip::ColorTypes.RGBA{Float32}, nan_color::ColorTypes.RGBA{Float32})
    @ Makie ~/.julia/packages/Makie/uAmck/src/colorsampler.jl:163
  [2] to_color(c::Makie.ColorMap{2, DimArray{Float32, 2, Tuple{Dim{:xC, DimensionalData.Dimensions.LookupArrays.Sampled{Float64, Vector{Float64}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Regular{Float64}, DimensionalData.Dimensions.LookupArrays.Points, DimensionalData.Dimensions.LookupArrays.Metadata{Rasters.NCDsource, Dict{String, Any}}}}, Dim{:zF, DimensionalData.Dimensions.LookupArrays.Sampled{Float64, Vector{Float64}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Regular{Float64}, DimensionalData.Dimensions.LookupArrays.Points, DimensionalData.Dimensions.LookupArrays.Metadata{Rasters.NCDsource, Dict{String, Any}}}}}, Tuple{}, Matrix{Float32}, DimensionalData.NoName, DimensionalData.Dimensions.LookupArrays.NoMetadata}, DimArray{Float32, 2, Tuple{Dim{:xC, DimensionalData.Dimensions.LookupArrays.Sampled{Float64, Vector{Float64}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Regular{Float64}, DimensionalData.Dimensions.LookupArrays.Points, DimensionalData.Dimensions.LookupArrays.Metadata{Rasters.NCDsource, Dict{String, Any}}}}, Dim{:zF, DimensionalData.Dimensions.LookupArrays.Sampled{Float64, Vector{Float64}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Regular{Float64}, DimensionalData.Dimensions.LookupArrays.Points, DimensionalData.Dimensions.LookupArrays.Metadata{Rasters.NCDsource, Dict{String, Any}}}}}, Tuple{}, Matrix{Float32}, DimensionalData.NoName, DimensionalData.Dimensions.LookupArrays.NoMetadata}})
    @ Makie ~/.julia/packages/Makie/uAmck/src/colorsampler.jl:258
  [3] draw_atomic(scene::Scene, screen::CairoMakie.Screen{CairoMakie.IMAGE}, primitive::Union{Image, Heatmap})
    @ CairoMakie ~/.julia/packages/CairoMakie/Ry75I/src/primitives.jl:643
  [4] draw_plot(scene::Scene, screen::CairoMakie.Screen{CairoMakie.IMAGE}, primitive::Heatmap{Tuple{Vector{Float32}, Vector{Float32}, DimArray{Float32, 2, Tuple{Dim{:xC, DimensionalData.Dimensions.LookupArrays.Sampled{Float64, Vector{Float64}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Regular{Float64}, DimensionalData.Dimensions.LookupArrays.Points, DimensionalData.Dimensions.LookupArrays.Metadata{Rasters.NCDsource, Dict{String, Any}}}}, Dim{:zF, DimensionalData.Dimensions.LookupArrays.Sampled{Float64, Vector{Float64}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Regular{Float64}, DimensionalData.Dimensions.LookupArrays.Points, DimensionalData.Dimensions.LookupArrays.Metadata{Rasters.NCDsource, Dict{String, Any}}}}}, Tuple{}, Matrix{Float32}, DimensionalData.NoName, DimensionalData.Dimensions.LookupArrays.NoMetadata}}})
    @ CairoMakie ~/.julia/packages/CairoMakie/Ry75I/src/infrastructure.jl:131
  [5] cairo_draw(screen::CairoMakie.Screen{CairoMakie.IMAGE}, scene::Scene)
    @ CairoMakie ~/.julia/packages/CairoMakie/Ry75I/src/infrastructure.jl:51
  [6] display(screen::CairoMakie.Screen{CairoMakie.IMAGE}, scene::Scene; connect::Bool)
    @ CairoMakie ~/.julia/packages/CairoMakie/Ry75I/src/display.jl:50
  [7] display(screen::CairoMakie.Screen{CairoMakie.IMAGE}, scene::Scene)
    @ CairoMakie ~/.julia/packages/CairoMakie/Ry75I/src/display.jl:47
  [8] display(figlike::Figure; backend::Module, inline::MakieCore.Automatic, update::Bool, screen_config::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Makie ~/.julia/packages/Makie/uAmck/src/display.jl:162
  [9] display(figlike::Figure)
    @ Makie ~/.julia/packages/Makie/uAmck/src/display.jl:131
 [10] #invokelatest#2
    @ ./essentials.jl:816 [inlined]
 [11] invokelatest
    @ ./essentials.jl:813 [inlined]
 [12] print_response(errio::IO, response::Any, show_value::Bool, have_color::Bool, specialdisplay::Union{Nothing, AbstractDisplay})
    @ REPL ~/bin/julia-1.9.2/share/julia/stdlib/v1.9/REPL/src/REPL.jl:305
 [13] (::REPL.var"#57#58"{REPL.LineEditREPL, Pair{Any, Bool}, Bool, Bool})(io::Any)
    @ REPL ~/bin/julia-1.9.2/share/julia/stdlib/v1.9/REPL/src/REPL.jl:287
 [14] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL ~/bin/julia-1.9.2/share/julia/stdlib/v1.9/REPL/src/REPL.jl:557
 [15] print_response(repl::REPL.AbstractREPL, response::Any, show_value::Bool, have_color::Bool)
    @ REPL ~/bin/julia-1.9.2/share/julia/stdlib/v1.9/REPL/src/REPL.jl:285
 [16] (::REPL.var"#do_respond#80"{Bool, Bool, REPL.var"#93#103"{REPL.LineEditREPL, REPL.REPLHistoryProvider}, REPL.LineEditREPL, REPL.LineEdit.Prompt})(s::REPL.LineEdit.MIState, buf::Any, ok::Bool)
    @ REPL ~/bin/julia-1.9.2/share/julia/stdlib/v1.9/REPL/src/REPL.jl:899
 [17] #invokelatest#2
    @ ./essentials.jl:816 [inlined]
 [18] invokelatest
    @ ./essentials.jl:813 [inlined]
 [19] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
    @ REPL.LineEdit ~/bin/julia-1.9.2/share/julia/stdlib/v1.9/REPL/src/LineEdit.jl:2647
 [20] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
    @ REPL ~/bin/julia-1.9.2/share/julia/stdlib/v1.9/REPL/src/REPL.jl:1300
 [21] (::REPL.var"#62#68"{REPL.LineEditREPL, REPL.REPLBackendRef})()
    @ REPL ./task.jl:514

(The compressed version of the NetCDF file required to run the MWE above is kelvin_helmholtz.zip.)

If, however, I use GLMakie I get the expected result:

image

This fails in Rasters v0.8.1 and 0.8.2, but works well in v0.8.0. This leads me to believe that #466 is the culprit. However, I don't know enough about what changed there to be able to identify the issue myself unfortunately.

@rafaqz
Copy link
Owner

rafaqz commented Aug 5, 2023

Im going to need kelvin_helmholtz.nc ;)

Sorry missed the link below.

Weird that its a DimArray rather than a Raster in the error. I'll have a look.

@rafaqz
Copy link
Owner

rafaqz commented Aug 20, 2023

I have no ideas what the problem is, but it seems to be somewhere in CairoMakie there is dispatch on Array instead of AbstractArray.

Probably this is a CairoMakie.jl issue. If it works with GLMakie it should work there too, we cant target backends here.

Its not working for me in GLMakie.jl either, but potting this raster fixes the problem for me:

r2 = set(ds.Ri[Ti=100, yC=1], :xC => X, :zF => Y)

So this is an axis naming problem - Rasters.jl doesn't know what to do with your :xC and :zF axes as they're not explicitly spatial. This is where we do need generic DimensionalData.jl recipes that plot arbitrary data in the best known order, rather than trying to make correct maps like Rasters.jl.

@tomchor
Copy link
Author

tomchor commented Aug 20, 2023

I doubled checked and this does work for me using GLMakie. Weird that it does for me and not for you. Although you're right about the fix. The following code works for me:

using Rasters
import NCDatasets
using CairoMakie
ds = RasterStack("kelvin_helmholtz.nc")
heatmap(set(ds.Ri[Ti=100, yC=1], :xC => X, :zF => Y); colormap = :bwr, colorrange = (-1, +1))

I also agree that ideally more generic recipes in DD would be preferred. But probably there's something to be changed in Rasters too, no? Only a minority of datasets use X, Y, Z as the default name for coordinates.

@rafaqz
Copy link
Owner

rafaqz commented Aug 21, 2023

Actually with spatial data we nearly always know which are X or Y axes... E.g. everything you load with GDAL. Netcdf with x/y, lat/lon etc we rename to X and Y.

If those axis names of yours are standard x and z dimension identifyers, we can just rename them automatically.

This also helps with e.g. saving to geotiff or other formats.

@tomchor
Copy link
Author

tomchor commented Aug 21, 2023

Actually with spatial data we nearly always know which are X or Y axes... E.g. everything you load with GDAL. Netcdf with x/y, lat/lon etc we rename to X and Y.

If those axis names of yours are standard x and z dimension identifyers, we can just rename them automatically.

This also helps with e.g. saving to geotiff or other formats.

I'm not sure what spatial data you guys work with (I'm assuming satellite data?), but my field works a lot of with geophysical model data in addition to collected data. Those models always have two x axis, two y axis, and two z axis. That's because almost all of them use the C-grid, where some variables are stored in face grid points (which in the model I most often use is currently called xF, yF, zF) and some variables are stored in center grid points (xC, etc.).

So renaming them all to X would at least remove some important information from the RasterStack, but possibly wouldn't even work? If I do this with a RasterStack that has both I get two coords that are different in value but are named the same (below both are named Z):

julia> rs = RasterStack("kelvin_helmholtz.nc")
RasterStack with dimensions: 
  Dim{:xC} Sampled{Float64} Float64[-4.9609375, -4.8828125, , 4.8828125, 4.9609375] ForwardOrdered Regular Points,
  Dim{:yC} Sampled{Float64} Float64[1.0] ForwardOrdered Regular Points,
  Dim{:zC} Sampled{Float64} Float64[-4.9609375, -4.8828125, , 4.8828125, 4.9609375] ForwardOrdered Regular Points,
  Ti Sampled{Float64} Float64[0.0, 1.0, , 99.0, 100.0] ForwardOrdered Regular Points,
  Dim{:zF} Sampled{Float64} Float64[-5.0, -4.921875, , 4.921875, 5.0] ForwardOrdered Regular Points
and 5 layers:
  :Q   Float64 dims: Dim{:xC}, Dim{:yC}, Dim{:zC}, Ti (128×1×128×101)
  :∫χᴰ Float64 dims: Ti (101)
  :Ri  Float64 dims: Dim{:xC}, Dim{:yC}, Dim{:zF}, Ti (128×1×129×101)
  :b   Float64 dims: Dim{:xC}, Dim{:yC}, Dim{:zC}, Ti (128×1×128×101)
  :∫χ  Float64 dims: Ti (101)

with metadata Metadata{Rasters.NCDsource} of Dict{String, Any} with 6 entries:
  "interval"             => 1.0
  "Oceananigans"         => "This file was generated using Oceananigans v0.86.0"
  "Julia"                => "This file was generated using Julia Version 1.9.2\nCommit e4ee485e909 (2023-07-05 09:39 UTC)\nPlatform Info:\n  OS: Linux (x86_64-linux-gnu)\…
  "output time interval" => "Output was saved every 1 second."
  "date"                 => "This file was generated on 2023-08-20T12:58:11.707."
  "schedule"             => "TimeInterval"

julia> rs2 = set(rs, :zC => Z, :zF => Z)
RasterStack with dimensions: 
  Dim{:xC} Sampled{Float64} Float64[-4.9609375, -4.8828125, …, 4.8828125, 4.9609375] ForwardOrdered Regular Points,
  Dim{:yC} Sampled{Float64} Float64[1.0] ForwardOrdered Regular Points,
  Z Sampled{Float64} Float64[-4.9609375, -4.8828125, …, 4.8828125, 4.9609375] ForwardOrdered Regular Points,
  Ti Sampled{Float64} Float64[0.0, 1.0, …, 99.0, 100.0] ForwardOrdered Regular Points,
  Z Sampled{Float64} Float64[-5.0, -4.921875, …, 4.921875, 5.0] ForwardOrdered Regular Points
and 5 layers:
  :Q   Float64 dims: Dim{:xC}, Dim{:yC}, Ti (128×1×101)
  :∫χᴰ Float64 dims: Ti (101)
  :Ri  Float64 dims: Dim{:xC}, Dim{:yC}, Ti (128×1×101)
  :b   Float64 dims: Dim{:xC}, Dim{:yC}, Ti (128×1×101)
  :∫χ  Float64 dims: Ti (101)

with metadata Metadata{Rasters.NCDsource} of Dict{String, Any} with 6 entries:
  "interval"             => 1.0
  "Oceananigans"         => "This file was generated using Oceananigans v0.86.0"
  "Julia"                => "This file was generated using Julia Version 1.9.2\nCommit e4ee485e909 (2023-07-05 09:39 UTC)\nPlatform Info:\n  OS: Linux (x86_64-linux-gnu)\n
  "output time interval" => "Output was saved every 1 second."
  "date"                 => "This file was generated on 2023-08-20T12:58:11.707."
  "schedule"             => "TimeInterval"

And then each individual Raster doesn't seem to be properly accessed:

julia> rs.b # accessing `b` in the original RasterStack works
128×1×128×101 Raster{Float64,4} b with dimensions: 
  Dim{:xC} Sampled{Float64} Float64[-4.9609375, -4.8828125, , 4.8828125, 4.9609375] ForwardOrdered Regular Points,
  Dim{:yC} Sampled{Float64} Float64[1.0] ForwardOrdered Regular Points,
  Dim{:zC} Sampled{Float64} Float64[-4.9609375, -4.8828125, , 4.8828125, 4.9609375] ForwardOrdered Regular Points,
  Ti Sampled{Float64} Float64[0.0, 1.0, , 99.0, 100.0] ForwardOrdered Regular Points
extent: Extent(xC = (-4.9609375, 4.9609375), yC = (1.0, 1.0), zC = (-4.9609375, 4.9609375), Ti = (0.0, 100.0))
missingval: missing
parent:
[:, :, 1, 1]
            1.0
 -4.96094  -0.025
 -4.88281  -0.025
 -4.80469  -0.025
 -4.72656  -0.025
 -4.64844  -0.025
 -4.57031  -0.025
 -4.49219  -0.025
 -4.41406  -0.025
 -4.33594  -0.025
 -4.25781  -0.025
 -4.17969  -0.025
 -4.10156  -0.025
 -4.02344  -0.025
 -3.94531  -0.025
          
  3.94531  -0.025
  4.02344  -0.025
  4.10156  -0.025
  4.17969  -0.025
  4.25781  -0.025
  4.33594  -0.025
  4.41406  -0.025
  4.49219  -0.025
  4.57031  -0.025
  4.64844  -0.025
  4.72656  -0.025
  4.80469  -0.025
  4.88281  -0.025
  4.96094  -0.025
[and 12927 more slices...]

julia> rs2.b # accessing `b` in the new RasterStack doesn't work
128×1×128×101 Raster{Float64,4} b with dimensions: 
  Dim{:xC} Sampled{Float64} Float64[-4.9609375, -4.8828125, , 4.8828125, 4.9609375] ForwardOrdered Regular Points,
  Dim{:yC} Sampled{Float64} Float64[1.0] ForwardOrdered Regular Points,
  Ti Sampled{Float64} Float64[0.0, 1.0, , 99.0, 100.0] ForwardOrdered Regular Points
extent: Extent(xC = (-4.9609375, 4.9609375), yC = (1.0, 1.0), Ti = (0.0, 100.0))
missingval: missing
parent:
Error showing value of type Raster{Float64, 4, Tuple{Dim{:xC, DimensionalData.Dimensions.LookupArrays.Sampled{Float64, Vector{Float64}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Regular{Float64}, DimensionalData.Dimensions.LookupArrays.Points, DimensionalData.Dimensions.LookupArrays.Metadata{Rasters.NCDsource, Dict{String, Any}}}}, Dim{:yC, DimensionalData.Dimensions.LookupArrays.Sampled{Float64, Vector{Float64}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Regular{Float64}, DimensionalData.Dimensions.LookupArrays.Points, DimensionalData.Dimensions.LookupArrays.Metadata{Rasters.NCDsource, Dict{String, Any}}}}, Ti{DimensionalData.Dimensions.LookupArrays.Sampled{Float64, Vector{Float64}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Regular{Float64}, DimensionalData.Dimensions.LookupArrays.Points, DimensionalData.Dimensions.LookupArrays.Metadata{Rasters.NCDsource, Dict{String, Any}}}}}, Tuple{}, Array{Float64, 4}, Symbol, DimensionalData.Dimensions.LookupArrays.Metadata{Rasters.NCDsource, Dict{String, Any}}, Missing}:
ERROR: BoundsError: attempt to access Tuple{} at index [1]
Stacktrace:
  [1] getindex(t::Tuple, i::Int64)
    @ Base ./tuple.jl:29
  [2] map (repeats 4 times)
    @ ./tuple.jl:302 [inlined]
  [3] axes(A::Raster{Float64, 4, Tuple{Dim{:xC, DimensionalData.Dimensions.LookupArrays.Sampled{Float64, Vector{Float64}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Regular{Float64}, DimensionalData.Dimensions.LookupArrays.Points, DimensionalData.Dimensions.LookupArrays.Metadata{Rasters.NCDsource, Dict{String, Any}}}}, Dim{:yC, DimensionalData.Dimensions.LookupArrays.Sampled{Float64, Vector{Float64}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Regular{Float64}, DimensionalData.Dimensions.LookupArrays.Points, DimensionalData.Dimensions.LookupArrays.Metadata{Rasters.NCDsource, Dict{String, Any}}}}, Ti{DimensionalData.Dimensions.LookupArrays.Sampled{Float64, Vector{Float64}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Regular{Float64}, DimensionalData.Dimensions.LookupArrays.Points, DimensionalData.Dimensions.LookupArrays.Metadata{Rasters.NCDsource, Dict{String, Any}}}}}, Tuple{}, Array{Float64, 4}, Symbol, DimensionalData.Dimensions.LookupArrays.Metadata{Rasters.NCDsource, Dict{String, Any}}, Missing})
    @ DimensionalData ~/.julia/packages/DimensionalData/4TpBG/src/array/array.jl:71
  [4] axes
    @ ./abstractarray.jl:77 [inlined]
  [5] firstindex
    @ ./abstractarray.jl:443 [inlined]
  [6] (::DimensionalData.var"#139#141"{Raster{Float64, 4, Tuple{Dim{:xC, DimensionalData.Dimensions.LookupArrays.Sampled{Float64, Vector{Float64}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Regular{Float64}, DimensionalData.Dimensions.LookupArrays.Points, DimensionalData.Dimensions.LookupArrays.Metadata{Rasters.NCDsource, Dict{String, Any}}}}, Dim{:yC, DimensionalData.Dimensions.LookupArrays.Sampled{Float64, Vector{Float64}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Regular{Float64}, DimensionalData.Dimensions.LookupArrays.Points, DimensionalData.Dimensions.LookupArrays.Metadata{Rasters.NCDsource, Dict{String, Any}}}}, Ti{DimensionalData.Dimensions.LookupArrays.Sampled{Float64, Vector{Float64}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Regular{Float64}, DimensionalData.Dimensions.LookupArrays.Points, DimensionalData.Dimensions.LookupArrays.Metadata{Rasters.NCDsource, Dict{String, Any}}}}}, Tuple{}, Array{Float64, 4}, Symbol, DimensionalData.Dimensions.LookupArrays.Metadata{Rasters.NCDsource, Dict{String, Any}}, Missing}})(x::Int64)

In any case, I'm just saying that there are advantages to making the package dimension-name-agnostic, even within the spatial data niche. There are, of course, other ways to approach this like allowing "super dimensions" that are actually defined with two other dimensions and keeps track of these different grid locations (like xgcm does using xarray), but I don't want to digress.

If you don't have plans to change the currently naming behavior at all then feel free to close this issue since renaming the axis of each individual Raster right before plotting works for me :)

@rafaqz
Copy link
Owner

rafaqz commented Aug 21, 2023

Its outside my experience but I can see that in your field what you have may be normal, and we should handle that elegantly too, especially if this is what Oceananigans.jl outputs. The problem is knowing how to orient and tile the heatmap.

There are a few ways to make things easier. Or maybe do all of them. We could add a keyword that does the set trick behind the scenes, like:

Plots.plot(raster; dims=(X=:fX, Y=:fY))
Rasters.rplot(raster; dims=(X=:fX, Y=:fY))
Makie.heatmap(raster; dims=(X=:fX, Y=:fY))

Edit: we already kind of have this!! there are X and Y keywords to rplot. Not for regular Makie.heatmap though, and maybe not working everywhere.

https://github.com/rafaqz/Rasters.jl/blob/main/ext/RastersMakieExt/plotrecipes.jl#L54-L55

Or have a heuristic that looks for x/X y/Y z/Z in the string names of the dimensions to guess what they are - but that could do weird things too I guess.

There is also another way you could handle your Arakawa grids, maybe more elegantly than Xarray and with no changes needed here. You can already define your own dimension types instead of using flat symbols, and make them XDim YDim etc that are recognised in plot recipes.

using DimensionalData.Dimensions
 @dim xC XDim
 @dim yC YDim
 @dim zC ZDim
 @dim xF XDim
 @dim yF YDim
 @dim zF ZDim

Everything you are doing should just work and plot correctly after that (and reloading your netcdf data). although I fear that the Makie recipes were not written to handle this - but Plots.jl recipes will work. I'll fix the makie recipes.

It also means you can just use those types like xF directly and never need Dim{:xF} anywhere.

And of course, finally falling back to generic heatmaps that don't try to work out the permuation at all.

@rafaqz
Copy link
Owner

rafaqz commented Aug 22, 2023

@tomchor looking through the code, the last option above using @dim the recipes should work with Makie.jl already

@tomchor
Copy link
Author

tomchor commented Aug 27, 2023

There are a few ways to make things easier. Or maybe do all of them. We could add a keyword that does the set trick behind the scenes, like:

Plots.plot(raster; dims=(X=:fX, Y=:fY))
Rasters.rplot(raster; dims=(X=:fX, Y=:fY))
Makie.heatmap(raster; dims=(X=:fX, Y=:fY))

IMO this is the preferred approach. This makes plotting agnostic and really we can plot each variable in whatever direction we want, which I think is desirable (I've had to do plots in the past were the x-variable wasn't in the x-axis of a plot, for example, and this allows for the flexibility to do that).

Or have a heuristic that looks for x/X y/Y z/Z in the string names of the dimensions to guess what they are - but that could do weird things too I guess.

I'd vote against this approach. There are many ways to name dimensions that don't follow the x, y, z directive (lat, lon, depth used in oceanography, for example, or x1, x2, x3 used in engineering).

There is also another way you could handle your Arakawa grids, maybe more elegantly than Xarray and with no changes needed here. You can already define your own dimension types instead of using flat symbols, and make them XDim YDim etc that are recognised in plot recipes.

I don't understand DD enough to know the implications of this, but it does work. For future reference, here's a working MWE:

using Rasters
import NCDatasets
using CairoMakie

using DimensionalData.Dimensions
@dim xC XDim
@dim yC YDim
@dim zC ZDim
@dim xF XDim
@dim yF YDim
@dim zF ZDim

ds = RasterStack("kelvin_helmholtz.nc")
fig = Figure()
ax1 = Axis(fig[1, 1])
hm1 = heatmap!(ax1, ds.Ri[Ti=100, yC=1]; colormap = :bwr, colorrange = (-1, +1))

The downside of this solution though is the need to include this preamble before working with any data in an Arakawa grid. So I think it's nice to have this option, but the first option, IMO, would be the preferred.

Thanks @rafaqz, for looking into this.

@rafaqz
Copy link
Owner

rafaqz commented Aug 27, 2023

Thanks, I agree those two options are the best.

Its true the @dim macros may be little overpowered for everyday use. But if you use these grids all the time you could put them in your startup.jl.

@tomchor
Copy link
Author

tomchor commented Aug 27, 2023

Thanks, I agree those two options are the best.

Its true the @dim macros may be little overpowered for everyday use. But if you use these grids all the time you could put them in your startup.jl.

I occasionally plot other datasets too, plus I use these codes across 4 or 5 different machines so I prefer keeping them self-contained. But that's a good point.

Would you like me to close this issue and possibly create another one specifically for the dims keyword when plotting?

@rafaqz
Copy link
Owner

rafaqz commented Aug 27, 2023

Lets keep it open just so this conversation is visible a while.

But maybe make a DimensionalData.jl issue with a vision of how the plotting should work in future (including Makie support), including the keyword?

@tomchor
Copy link
Author

tomchor commented Oct 17, 2023

I'm still having trouble with this issue except that now the behavior is different. Now Julia just hangs after the last line of the mwe. I left my laptop on it for almost 30 min and nothing. After pressing ctrl+C repeatedly to cancel the last command, this is what I get:

julia> hm1 = heatmap!(ax1, ds.Ri[Ti=100, yC=1]; colormap = :bwr, colorrange = (-1, +1))
^C^C^C^C^C^CWARNING: Force throwing a SIGINT
^CERROR: InterruptException:
Stacktrace:
  [1] materialize
    @ ./broadcast.jl:873 [inlined]
  [2] convert_arguments(::Type{Heatmap{NTuple{16512, Float64}}}, ::Float64, ::Vararg{Float64}; kw::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Makie ~/.julia/packages/Makie/NrrbP/src/conversions.jl:17
  [3] convert_arguments(::Type{Heatmap{NTuple{16512, Float64}}}, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Vararg{Float64})
    @ Makie ~/.julia/packages/Makie/NrrbP/src/conversions.jl:7
  [4] plot!(::Scene, ::Type{Heatmap}, ::Attributes, ::Float64, ::Vararg{Float64}; kw_attributes::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Makie ~/.julia/packages/Makie/NrrbP/src/interfaces.jl:292
  [5] plot!(::Scene, ::Type{Heatmap}, ::Attributes, ::Float64, ::Float64, ::Float64, ::Vararg{Float64})
    @ Makie ~/.julia/packages/Makie/NrrbP/src/interfaces.jl:275
  [6] plot!(::Axis, ::Type{Heatmap}, ::Attributes, ::Float64, ::Vararg{Float64}; kw_attributes::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Makie ~/.julia/packages/Makie/NrrbP/src/makielayout/blocks/axis.jl:787
  [7] plot!(::Axis, ::Type{Heatmap}, ::Attributes, ::Float64, ::Float64, ::Float64, ::Vararg{Float64})
    @ Makie ~/.julia/packages/Makie/NrrbP/src/makielayout/blocks/axis.jl:775
  [8] plot!(::Type{Heatmap}, ::Axis, ::Float64, ::Vararg{Float64}; kw_attributes::Base.Pairs{Symbol, Any, Tuple{Symbol, Symbol}, NamedTuple{(:colormap, :colorrange), Tuple{Symbol, Tuple{Int64, Int64}}}})
    @ Makie ~/.julia/packages/Makie/NrrbP/src/makielayout/blocks/axis.jl:804
  [9] plot!(::Type{Heatmap}, ::Float64, ::Vararg{Float64}; kw_attributes::Base.Pairs{Symbol, Any, Tuple{Symbol, Symbol}, NamedTuple{(:colormap, :colorrange), Tuple{Symbol, Tuple{Int64, Int64}}}})
    @ Makie ~/.julia/packages/Makie/NrrbP/src/figureplotting.jl:76
 [10] heatmap!(::Float64, ::Vararg{Float64}; attributes::Base.Pairs{Symbol, Any, Tuple{Symbol, Symbol}, NamedTuple{(:colormap, :colorrange), Tuple{Symbol, Tuple{Int64, Int64}}}})
    @ MakieCore ~/.julia/packages/MakieCore/7iPhv/src/recipes.jl:39
 [11] #heatmap!#23
    @ ~/.julia/packages/DimensionalData/sX6JM/ext/DimensionalDataMakie.jl:158 [inlined]
 [12] top-level scope
    @ REPL[7]:1

caused by: MethodError: no method matching convert_arguments(::Type{Heatmap{NTuple{16512, Float64}}}, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64....

and Float64 so on, many many more times, which tells me there's a recursion somewhere when converting arguments.

I'm using

  [13f3f980] CairoMakie v0.10.11
  [0703355e] DimensionalData v0.25.3
  [e9467ef8] GLMakie v0.8.11
⌅ [85f8d34a] NCDatasets v0.12.17
  [a3a2b9e3] Rasters v0.8.4 `https://github.com/rafaqz/Rasters.jl.git#main`

One note also is that I have to use Rasters#main for this, since the last registered version still pins down DD to version 0.24 (before the Makie recipes migration there). Maybe it'd be helpful also to tag and register a new version?

Lastly, this issue seems to also happen if I transform the Raster into a DimArray, so let me know if I should open an issue on DD instead:

using Rasters
import NCDatasets
using CairoMakie
using DimensionalData

ds = RasterStack("kelvin_helmholtz.nc")
fig = Figure()
ax1 = Axis(fig[1, 1])
da = DimArray(ds.Ri[Ti=100, yC=1])
hm1 = heatmap!(ax1, da; colormap = :bwr, colorrange = (-1, +1))

With the compressed version of the NetCDF file required to run the MWE above being kelvin_helmholtz.zip.

@felixcremer
Copy link
Contributor

This will be fixed in rafaqz/DimensionalData.jl#551.

@tomchor
Copy link
Author

tomchor commented Oct 17, 2023

This will be fixed in rafaqz/DimensionalData.jl#551.

Awesome! Godspeed :)

@rafaqz
Copy link
Owner

rafaqz commented Oct 25, 2023

This should be fine now, and if not, its a DimensionalData.jl issue

@rafaqz rafaqz closed this as completed Oct 25, 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

3 participants