Skip to content

Trying to plot heat map of field in halo region using Makie gives BoundsError #4999

@matt-graham

Description

@matt-graham

I am not sure if this is intended behaviour or not, but when trying to plot a heatmap of a field with indices corresponding to a slice in the halo region, I get a BoundsError due to the line

which gets nodes for field, as with_halos=true is not set.

Minimal reproducing example

using Oceananigans
using CairoMakie

grid = RectilinearGrid(size=(5, 5, 5), halo=(1, 1, 1), x=(0, 1), y=(0, 1), z=(0, 1))
field = Field{Center, Center, Center}(grid, indices=(:, :, grid.Nz + 1))
heatmap(field)

gives error / stack trace

ERROR: BoundsError: attempt to access 5-element StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64} at index [6:6]
Stacktrace:
  [1] throw_boundserror(A::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, I::Tuple{UnitRange{Int64}})
    @ Base ./essentials.jl:15
  [2] checkbounds
    @ ./abstractarray.jl:699 [inlined]
  [3] getindex(r::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, s::UnitRange{Int64})
    @ Base ./twiceprecision.jl:496
  [4] view
    @ ./subarray.jl:234 [inlined]
  [5] rnodes
    @ ~/.julia/packages/Oceananigans/VsQ7B/src/Grids/vertical_discretization.jl:201 [inlined]
  [6] rnodes
    @ ~/.julia/packages/Oceananigans/VsQ7B/src/Grids/vertical_discretization.jl:202 [inlined]
  [7] znodes
    @ ~/.julia/packages/Oceananigans/VsQ7B/src/Grids/vertical_discretization.jl:213 [inlined]
  [8] #nodes#71
    @ ~/.julia/packages/Oceananigans/VsQ7B/src/Grids/rectilinear_grid.jl:489 [inlined]
  [9] nodes
    @ ~/.julia/packages/Oceananigans/VsQ7B/src/Grids/rectilinear_grid.jl:486 [inlined]
 [10] nodes
    @ ~/.julia/packages/Oceananigans/VsQ7B/src/Fields/field.jl:863 [inlined]
 [11] convert_field_argument(f::Field{Center, Center, Center, Nothing, RectilinearGrid{…}, Tuple{…}, OffsetArrays.OffsetArray{…}, Float64, FieldBoundaryConditions{…}, Nothing, Nothing})
    @ OceananigansMakieExt ~/.julia/packages/Oceananigans/VsQ7B/ext/OceananigansMakieExt.jl:149
 [12] _create_plot(F::Function, attributes::Dict{Symbol, Any}, f::Field{Center, Center, Center, Nothing, RectilinearGrid{…}, Tuple{…}, OffsetArrays.OffsetArray{…}, Float64, FieldBoundaryConditions{…}, Nothing, Nothing})
    @ OceananigansMakieExt ~/.julia/packages/Oceananigans/VsQ7B/ext/OceananigansMakieExt.jl:55
 [13] #heatmap#49
    @ ~/.julia/packages/Makie/TOy8O/src/recipes.jl:530 [inlined]
 [14] heatmap(args::Field{Center, Center, Center, Nothing, RectilinearGrid{…}, Tuple{…}, OffsetArrays.OffsetArray{…}, Float64, FieldBoundaryConditions{…}, Nothing, Nothing})
    @ Makie ~/.julia/packages/Makie/TOy8O/src/recipes.jl:528
 [15] top-level scope
    @ REPL[41]:1
Some type information was truncated. Use `show(err)` to see complete types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐞Even a perfect program still has bugs

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions