MakieOrg / GeoMakie.jl

Geographical plotting utilities for Makie.jl
https://geo.makie.org
MIT License
167 stars 24 forks source link

[WIP] Improvements to GeoAxis and docs #207

Closed asinghvi17 closed 3 months ago

asinghvi17 commented 7 months ago

Updates to Makie v0.21 and adds a couple of improvements to GeoAxis. Also gets rid of PROJ_RESCALE_FACTOR since we can now use Float64 numbers.

This PR requires Makie v0.21 and is only usable with those versions of Makie.

View the docs at https://geo.makie.org/previews/PR207

Full changelog

asinghvi17 commented 6 months ago

This PR currently needs: https://github.com/JuliaGeometry/GeometryBasics.jl/pull/214 https://github.com/MakieOrg/Makie.jl/pull/3681 (and GLMakie, MakieCore on the same branch)

felixcremer commented 6 months ago

This fails to precompile for me with the following error:

ERROR: LoadError: Failed to precompile Makie [ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a] to "/home/fcremer/.julia/compiled/v1.10/Makie/jl_pajWTX".
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, keep_loaded_modules::Bool)
    @ Base ./loading.jl:2468
  [3] compilecache
    @ ./loading.jl:2340 [inlined]
  [4] (::Base.var"#968#969"{Base.PkgId})()
    @ Base ./loading.jl:1974
  [5] mkpidlock(f::Base.var"#968#969"{Base.PkgId}, at::String, pid::Int32; kwopts::@Kwargs{stale_age::Int64, wait::Bool})
    @ FileWatching.Pidfile ~/.julia/juliaup/julia-1.10.1+0.x64.linux.gnu/share/julia/stdlib/v1.10/FileWatching/src/pidfile.jl:93
  [6] #mkpidlock#6
    @ ~/.julia/juliaup/julia-1.10.1+0.x64.linux.gnu/share/julia/stdlib/v1.10/FileWatching/src/pidfile.jl:88 [inlined]
  [7] trymkpidlock(::Function, ::Vararg{Any}; kwargs::@Kwargs{stale_age::Int64})
    @ FileWatching.Pidfile ~/.julia/juliaup/julia-1.10.1+0.x64.linux.gnu/share/julia/stdlib/v1.10/FileWatching/src/pidfile.jl:111
  [8] #invokelatest#2
    @ ./essentials.jl:894 [inlined]
  [9] invokelatest
    @ ./essentials.jl:889 [inlined]
 [10] maybe_cachefile_lock(f::Base.var"#968#969"{Base.PkgId}, pkg::Base.PkgId, srcpath::String; stale_age::Int64)
    @ Base ./loading.jl:2983
 [11] maybe_cachefile_lock
    @ ./loading.jl:2980 [inlined]
 [12] _require(pkg::Base.PkgId, env::String)
    @ Base ./loading.jl:1970
 [13] __require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1812
 [14] #invoke_in_world#3
    @ ./essentials.jl:926 [inlined]
 [15] invoke_in_world
    @ ./essentials.jl:923 [inlined]
 [16] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1803
 [17] macro expansion
    @ ./loading.jl:1790 [inlined]
 [18] macro expansion
    @ ./lock.jl:267 [inlined]
 [19] __require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1753
 [20] #invoke_in_world#3
    @ ./essentials.jl:926 [inlined]
 [21] invoke_in_world
    @ ./essentials.jl:923 [inlined]
 [22] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1746
 [23] include
    @ ./Base.jl:495 [inlined]
 [24] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::Nothing)
    @ Base ./loading.jl:2222
 [25] top-level scope
    @ stdin:3
in expression starting at /home/fcremer/Documents/rqa_bonito_app/dev/GeoMakie/src/GeoMakie.jl:1
in expression starting at stdin:3
Makie [ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a]

Failed to precompile Makie [ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a] to "/home/fcremer/.julia/compiled/v1.10/Makie/jl_wR6ngy".
ERROR: LoadError: MethodError: Cannot `convert` an object of type Observables.Observable{GeometryBasics.Vec{2, Float32}} to an object of type Float32

Closest candidates are:
  convert(::Type{T}, ::DualNumbers.Dual) where T<:Union{Real, Complex}
   @ DualNumbers ~/.julia/packages/DualNumbers/5knFX/src/dual.jl:24
  convert(::Type{T}, ::T) where T
   @ Base Base.jl:84
  convert(::Type{T}, ::Polynomials.AbstractPolynomial{T, X}) where {T<:Number, X}
   @ Polynomials ~/.julia/packages/Polynomials/UpyN2/src/common.jl:476
  ...

Stacktrace:
  [1] (::GeometryBasics.var"#5#16"{Float32, Observables.Observable{GeometryBasics.Vec{2, Float32}}})(i::Int64)
    @ GeometryBasics ~/.julia/packages/GeometryBasics/7UOa3/src/fixed_arrays.jl:45
  [2] ntuple
    @ ./ntuple.jl:49 [inlined]
  [3] GeometryBasics.Point{2, Float32}(x::Observables.Observable{GeometryBasics.Vec{2, Float32}})
    @ GeometryBasics ~/.julia/packages/GeometryBasics/7UOa3/src/fixed_arrays.jl:45
  [4] to_world(scene::Makie.Scene, point::GeometryBasics.Point{2, Float32})
    @ Makie ~/Documents/rqa_bonito_app/dev/Makie/src/camera/projection_math.jl:243
  [5] mouseposition(scene::Makie.Scene)
    @ Makie ~/Documents/rqa_bonito_app/dev/Makie/src/interaction/interactive_api.jl:190
  [6] _addmouseevents!(scene::Makie.Scene, is_mouse_over_relevant_area::Makie.var"#is_mouse_over_relevant_area#1464"{Makie.Scene, Tuple{}}, priority::Int64)
    @ Makie ~/Documents/rqa_bonito_app/dev/Makie/src/makielayout/mousestatemachine.jl:197
  [7] addmouseevents!(::Makie.Scene; priority::Int64)
    @ Makie ~/Documents/rqa_bonito_app/dev/Makie/src/makielayout/mousestatemachine.jl:125
  [8] addmouseevents!(::Makie.Scene)
    @ Makie ~/Documents/rqa_bonito_app/dev/Makie/src/makielayout/mousestatemachine.jl:123
  [9] register_events!(ax::Makie.Axis, scene::Makie.Scene)
    @ Makie ~/Documents/rqa_bonito_app/dev/Makie/src/makielayout/blocks/axis.jl:35
 [10] initialize_block!(ax::Makie.Axis; palette::Nothing)
    @ Makie ~/Documents/rqa_bonito_app/dev/Makie/src/makielayout/blocks/axis.jl:501
 [11] initialize_block!(ax::Makie.Axis)
    @ Makie ~/Documents/rqa_bonito_app/dev/Makie/src/makielayout/blocks/axis.jl:163
 [12] _block(T::Type{Makie.Axis}, fig_or_scene::Makie.Figure, args::Vector{Any}, kwdict::Dict{Symbol, Any}, bbox::Nothing; kwdict_complete::Bool)
    @ Makie ~/Documents/rqa_bonito_app/dev/Makie/src/makielayout/blocks.jl:362
 [13] _block(T::Type{Makie.Axis}, fig_or_scene::Makie.Figure, args::Vector{Any}, kwdict::Dict{Symbol, Any}, bbox::Nothing)
    @ Makie ~/Documents/rqa_bonito_app/dev/Makie/src/makielayout/blocks.jl:282
 [14] _block(::Type{Makie.Axis}, ::Makie.Figure; bbox::Nothing, kwargs::@Kwargs{})
    @ Makie ~/Documents/rqa_bonito_app/dev/Makie/src/makielayout/blocks.jl:250
 [15] _block(::Type{Makie.Axis}, ::Makie.Figure)
    @ Makie ~/Documents/rqa_bonito_app/dev/Makie/src/makielayout/blocks.jl:249
 [16] _block(::Type{Makie.Axis}, ::GridLayoutBase.GridPosition; kwargs::@Kwargs{})
    @ Makie ~/Documents/rqa_bonito_app/dev/Makie/src/makielayout/blocks.jl:244
 [17] _block
    @ ~/Documents/rqa_bonito_app/dev/Makie/src/makielayout/blocks.jl:237 [inlined]
 [18] #_#1373
    @ ~/Documents/rqa_bonito_app/dev/Makie/src/makielayout/blocks.jl:228 [inlined]
 [19] Block
    @ ~/Documents/rqa_bonito_app/dev/Makie/src/makielayout/blocks.jl:227 [inlined]
 [20] macro expansion
    @ ~/Documents/rqa_bonito_app/dev/Makie/src/precompiles.jl:29 [inlined]
 [21] macro expansion
    @ ~/.julia/packages/PrecompileTools/L8A3n/src/workloads.jl:78 [inlined]
 [22] top-level scope
    @ ~/Documents/rqa_bonito_app/dev/Makie/src/precompiles.jl:27
 [23] include(mod::Module, _path::String)
    @ Base ./Base.jl:495
 [24] include(x::String)
    @ Makie ~/Documents/rqa_bonito_app/dev/Makie/src/Makie.jl:1
 [25] top-level scope
    @ ~/Documents/rqa_bonito_app/dev/Makie/src/Makie.jl:408
 [26] include
    @ ./Base.jl:495 [inlined]
 [27] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::Nothing)
    @ Base ./loading.jl:2222
 [28] top-level scope
    @ stdin:3
in expression starting at /home/fcremer/Documents/rqa_bonito_app/dev/Makie/src/precompiles.jl:26
in expression starting at /home/fcremer/Documents/rqa_bonito_app/dev/Makie/src/Makie.jl:1
in expression starting at stdin:3
Stacktrace:
  [1] pkgerror(msg::String)
    @ Pkg.Types ~/.julia/juliaup/julia-1.10.1+0.x64.linux.gnu/share/julia/stdlib/v1.10/Pkg/src/Types.jl:70
  [2] precompile(ctx::Pkg.Types.Context, pkgs::Vector{…}; internal_call::Bool, strict::Bool, warn_loaded::Bool, already_instantiated::Bool, timing::Bool, _from_loading::Bool, kwargs::@Kwargs{…})
    @ Pkg.API ~/.julia/juliaup/julia-1.10.1+0.x64.linux.gnu/share/julia/stdlib/v1.10/Pkg/src/API.jl:1659
  [3] precompile(pkgs::Vector{Pkg.Types.PackageSpec}; io::Base.TTY, kwargs::@Kwargs{_from_loading::Bool})
    @ Pkg.API ~/.julia/juliaup/julia-1.10.1+0.x64.linux.gnu/share/julia/stdlib/v1.10/Pkg/src/API.jl:159
  [4] precompile
    @ ~/.julia/juliaup/julia-1.10.1+0.x64.linux.gnu/share/julia/stdlib/v1.10/Pkg/src/API.jl:147 [inlined]
  [5] #precompile#114
    @ ~/.julia/juliaup/julia-1.10.1+0.x64.linux.gnu/share/julia/stdlib/v1.10/Pkg/src/API.jl:146 [inlined]
  [6] #invokelatest#2
    @ ./essentials.jl:894 [inlined]
  [7] invokelatest
    @ ./essentials.jl:889 [inlined]
  [8] _require(pkg::Base.PkgId, env::String)
    @ Base ./loading.jl:1963
  [9] __require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1812
 [10] #invoke_in_world#3
    @ ./essentials.jl:926 [inlined]
 [11] invoke_in_world
    @ ./essentials.jl:923 [inlined]
 [12] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1803
 [13] macro expansion
    @ ./loading.jl:1790 [inlined]
 [14] macro expansion
    @ ./lock.jl:267 [inlined]
 [15] __require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1753
 [16] #invoke_in_world#3
    @ ./essentials.jl:926 [inlined]
 [17] invoke_in_world
    @ ./essentials.jl:923 [inlined]
 [18] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1746
 [19] eval
    @ ./boot.jl:385 [inlined]
 [20] eval
    @ ./Base.jl:88 [inlined]
 [21] repleval(m::Module, code::Expr, ::String)
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.75.2/scripts/packages/VSCodeServer/src/repl.jl:229
 [22] (::VSCodeServer.var"#110#112"{Module, Expr, REPL.LineEditREPL, REPL.LineEdit.Prompt})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.75.2/scripts/packages/VSCodeServer/src/repl.jl:192
 [23] with_logstate(f::Function, logstate::Any)
    @ Base.CoreLogging ./logging.jl:515
 [24] with_logger
    @ ./logging.jl:627 [inlined]
 [25] (::VSCodeServer.var"#109#111"{Module, Expr, REPL.LineEditREPL, REPL.LineEdit.Prompt})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.75.2/scripts/packages/VSCodeServer/src/repl.jl:193
 [26] #invokelatest#2
    @ ./essentials.jl:892 [inlined]
 [27] invokelatest(::Any)
    @ Base ./essentials.jl:889
 [28] (::VSCodeServer.var"#62#63")()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.75.2/scripts/packages/VSCodeServer/src/eval.jl:34
Some type information was truncated. Use `show(err)` to see complete types.

(rqa_bonito_app) pkg> st
Status `~/Documents/rqa_bonito_app/Project.toml`
  [824d6782] Bonito v3.0.6
⌅ [0703355e] DimensionalData v0.24.13
  [411431e0] Extents v0.1.2
  [5789e2e9] FileIO v1.16.2
  [e9467ef8] GLMakie v0.10.0 `dev/Makie/GLMakie`
  [68eda718] GeoFormatTypes v0.4.2
  [db073c08] GeoMakie v0.6.3 `dev/GeoMakie`
  [5c1252a2] GeometryBasics v0.4.10 `https://github.com/JuliaGeometry/GeometryBasics.jl.git#master`
  [c27321d9] Glob v1.3.1
  [ee78f7c6] Makie v0.21.0 `dev/Makie`
  [20f20a25] MakieCore v0.8.0 `dev/Makie/MakieCore`
  [c94c279d] Proj v1.7.0
  [ec211b67] PyramidScheme v0.1.0 `~/Documents/PyramidScheme`
⌃ [a3a2b9e3] Rasters v0.5.1
  [263fe934] TileProviders v0.1.3
  [e170d443] Tyler v0.1.3 `dev/Tyler`
  [c21b50f5] YAXArrays v0.5.4
  [0a941bbe] Zarr v0.9.2
Info Packages marked with ⌃ and ⌅ have new versions available. Those with ⌃ may be upgradable, but those with ⌅ are restricted by compatibility constraints from upgrading. To see why use `status --outdated`
asinghvi17 commented 4 months ago

Commenting so I can remember when I pick this up next:

Surface bounding boxes seem to work on pre-transformed points, but not on current points. Maybe we should fix that.

asinghvi17 commented 4 months ago

MWE for the surface issue:

using GeoMakie, CairoMakie
f, ga, p = surface(-180..180, -90..90, rand(10, 10); axis = (; type = GeoAxis));
lines!(ga.scene, Makie.boundingbox(ga.scene); color = :red, xautolimits = false, yautolimits = false)
display(f; update = false)

iTerm2 jHT8b6 It looks like the rectangle is not getting transformed correctly - what happens on current master is that the "bulging" left and right sides of the surface are taken into account, which doesn't happen here.

asinghvi17 commented 4 months ago

I've somehow managed to break Makie's colorbar with the type piracy here - should extract that somehow.

lazarusA commented 4 months ago

could we merge this, and then fix all other issues on different PRs? This is already good enough for the current upgrade of makie.

asinghvi17 commented 4 months ago

I guess we could, but as it is now GeoMakie is not precompilable at all and the output is incorrect for surface plots...

lazarusA commented 4 months ago

ups... then no. It needs to precompile at least 😄 .

asinghvi17 commented 4 months ago

I mean it works but __precompile__(false) is one of the first lines in the main file, so TTFX is pretty bad :D

asinghvi17 commented 4 months ago

Todo:

asinghvi17 commented 4 months ago

It looks as though the cover images exist in assets, but they have random filenames (hashes? slugs?) and the HTML still points to the original image paths. @lazarusA have you seen this issue before?

lazarusA commented 4 months ago

yes, when I was trying to do gallery section for BMakie, I had this issue. That's why later I just copy some files to public (no issues there). But, I agree, they should come from assests. Maybe @avik-pal knows better, I don't know how it was done for Lux. Also, those slugs change in every build which makes things harder.

But, then why generated pages work when we save some images to assets and then we just included them in the normal .md file? ....

Edit: Ohh, Lux also has the images in public. :(

asinghvi17 commented 4 months ago

For pages with assets generated, my guess is that Vitepress picks them up and inlines them.

I guess I can kind of fix that in the code, but all this manual config is not fun...would probably have to save all assets to public. Maybe as a subdir?

asinghvi17 commented 4 months ago

So there's a Vitepress package which kind of semi does this? See de1b5c1 (#207). Let's see how the examples turn out!