-
Notifications
You must be signed in to change notification settings - Fork 6
[wip] antimeridian cutting with trees for regridding #283
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
base: as/trees
Are you sure you want to change the base?
Conversation
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
using SpeedyWeather | ||
using GeoMakie | ||
|
||
SpeedyWeatherGeoMakieExt = Base.get_extension(SpeedyWeather, :SpeedyWeatherGeoMakieExt) | ||
|
||
grid1 = rand(OctaHEALPixGrid, 5 + 100) | ||
grid2 = rand(FullGaussianGrid, 4 + 100) | ||
|
||
faces1 = SpeedyWeatherGeoMakieExt.get_faces(grid1) | ||
faces2 = SpeedyWeatherGeoMakieExt.get_faces(grid2) | ||
|
||
polys1 = GI.Polygon.(GI.LinearRing.(eachcol(faces1))) .|> GO.fix | ||
polys2 = GI.Polygon.(GI.LinearRing.(eachcol(faces2))) .|> GO.fix | ||
|
||
A = @time area_of_intersection_operator(polys1, polys2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what the method will ultimately look like...it takes me ~3.5s on my machine, single threaded, to cross reference two ~80,000 element grids.
It's possible to multithread this but not the easiest thing...might need some kind of master-worker setup. We need to multithread within the dual tree query, so maybe we let the query run on one thread and spawn nthreads()*2-2 worker threads that can consume the output from a channel. There would likely also need to be a writer task that is single-threadedly writing to A
.
I'm getting the following error when I try to install this branch julia> using GeometryOps
Precompiling GeometryOps...
Info Given GeometryOps was explicitly requested, output will be shown live
WARNING: could not import GeometryOpsCore.AutoManifold into GeometryOps
WARNING: could not import GeometryOpsCore.WrongManifoldException into GeometryOps
WARNING: could not import GeometryOpsCore.Algorithm into GeometryOps
WARNING: could not import GeometryOpsCore.AutoAlgorithm into GeometryOps
WARNING: could not import GeometryOpsCore.ManifoldIndependentAlgorithm into GeometryOps
WARNING: could not import GeometryOpsCore.SingleManifoldAlgorithm into GeometryOps
WARNING: could not import GeometryOpsCore.NoAlgorithm into GeometryOps
ERROR: LoadError: UndefVarError: `SingleManifoldAlgorithm` not defined in `GeometryOpsCore`yOps
Stacktrace:
[1] getproperty(x::Module, f::Symbol)
@ Base ./Base.jl:42
[2] top-level scope
@ ~/.julia/packages/GeometryOps/4octE/src/types.jl:34
[3] include(mod::Module, _path::String)
@ Base ./Base.jl:557
[4] include(x::String)
@ GeometryOps ~/.julia/packages/GeometryOps/4octE/src/GeometryOps.jl:3
[5] top-level scope
@ ~/.julia/packages/GeometryOps/4octE/src/GeometryOps.jl:37
[6] include
@ ./Base.jl:557 [inlined]
[7] 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:2881
[8] top-level scope
@ stdin:6
in expression starting at /Users/milan/.julia/packages/GeometryOps/4octE/src/types.jl:34
in expression starting at /Users/milan/.julia/packages/GeometryOps/4octE/src/GeometryOps.jl:3
in expression starting at stdin:6
✗ GeometryOps
0 dependencies successfully precompiled in 3 seconds. 56 already precompiled.
ERROR: The following 1 direct dependency failed to precompile:
GeometryOps |
Ah, you need to add GeometryOpsCore on this branch as well If you have it dev'ed, |
This seems to work 🥳 @simone-silvestri and quick check whether it's conserving looks pretty good I would say!!! |
With some combinations of grids and resolutions, e.g. grid1 = randn(OctaHEALPixGrid, 24)
grid2 = randn(OctaminimalGaussianGrid, 12) I'm hitting an error though ┌ Error: Intersection failed!
│ i1 = 1152
│ i2 = 289
└ @ Main In[135]:25
BoundsError: attempt to access 4-element Vector{GeometryOps.PolyNode{Float64}} at index [6]
Stacktrace:
[1] throw_boundserror(A::Vector{GeometryOps.PolyNode{Float64}}, I::Tuple{Int64})
@ Base ./essentials.jl:14
[2] getindex
@ ./essentials.jl:916 [inlined]
[3] _classify_crossing!(alg::GeometryOps.FosterHormannClipping{GeometryOpsCore.Planar, GeometryOps.AutoAccelerator}, ::Type{Float64}, a_list::Vector{GeometryOps.PolyNode{Float64}}, b_list::Vector{GeometryOps.PolyNode{Float64}}; exact::GeometryOpsCore.True)
@ GeometryOps ~/.julia/packages/GeometryOps/4octE/src/methods/clipping/clipping_processor.jl:623
[4] _classify_crossing!
@ ~/.julia/packages/GeometryOps/4octE/src/methods/clipping/clipping_processor.jl:606 [inlined]
[5] _build_ab_list(alg::GeometryOps.FosterHormannClipping{GeometryOpsCore.Planar, GeometryOps.AutoAccelerator}, ::Type{Float64}, poly_a::GeoInterface.Wrappers.LinearRing{false, false, Vector{Tuple{Float64, Float64}}, Nothing, Nothing}, poly_b::GeoInterface.Wrappers.LinearRing{false, false, Vector{Tuple{Float64, Float64}}, Nothing, Nothing}, delay_cross_f::typeof(GeometryOps._inter_delay_cross_f), delay_bounce_f::typeof(GeometryOps._inter_delay_bounce_f); exact::GeometryOpsCore.True)
@ GeometryOps ~/.julia/packages/GeometryOps/4octE/src/methods/clipping/clipping_processor.jl:149
[6] _build_ab_list
@ ~/.julia/packages/GeometryOps/4octE/src/methods/clipping/clipping_processor.jl:143 [inlined]
[7] _intersection(alg::GeometryOps.FosterHormannClipping{GeometryOpsCore.Planar, GeometryOps.AutoAccelerator}, ::GeometryOpsCore.TraitTarget{GeoInterface.PolygonTrait}, ::Type{Float64}, ::GeoInterface.PolygonTrait, poly_a::GeoInterface.Wrappers.Polygon{false, false, Vector{GeoInterface.Wrappers.LinearRing{false, false, Vector{Tuple{Float64, Float64}}, Nothing, Nothing}}, Nothing, Nothing}, ::GeoInterface.PolygonTrait, poly_b::GeoInterface.Wrappers.Polygon{false, false, Vector{GeoInterface.Wrappers.LinearRing{false, false, Vector{Tuple{Float64, Float64}}, Nothing, Nothing}}, Nothing, Nothing}; exact::GeometryOpsCore.True, kwargs::@Kwargs{})
@ GeometryOps ~/.julia/packages/GeometryOps/4octE/src/methods/clipping/intersection.jl:86
[8] _intersection
@ ~/.julia/packages/GeometryOps/4octE/src/methods/clipping/intersection.jl:76 [inlined]
[9] #intersection#102
@ ~/.julia/packages/GeometryOps/4octE/src/methods/clipping/intersection.jl:45 [inlined]
[10] intersection |
c70fe68
to
7357b0d
Compare
7357b0d
to
584f594
Compare
1f5fba2
to
f33c8e4
Compare
584f594
to
659d6b0
Compare
Hi @asinghvi17, when I try to use this branch in combination with ERROR: The following 2 direct dependencies failed to precompile:
GeometryOps
Failed to precompile GeometryOps [3251bfac-6a57-4b6d-aa61-ac1fef2975ab] to "/Users/simonesilvestri/.julia/compiled/v1.10/GeometryOps/jl_BD8CaS".
ERROR: LoadError: UndefVarError: `CutAtAntimeridianAndPoles` not defined
Stacktrace:
[1] top-level scope
@ ~/.julia/packages/GeometryOps/LoXLj/src/transformations/correction/cut_at_antimeridian.jl:80
[2] include(mod::Module, _path::String)
@ Base ./Base.jl:495
[3] include(x::String)
@ GeometryOps ~/.julia/packages/GeometryOps/LoXLj/src/GeometryOps.jl:3
[4] top-level scope
@ ~/.julia/packages/GeometryOps/LoXLj/src/GeometryOps.jl:89
[5] include
@ ./Base.jl:495 [inlined]
[6] 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:2292
[7] top-level scope
@ stdin:4
in expression starting at /Users/simonesilvestri/.julia/packages/GeometryOps/LoXLj/src/transformations/correction/cut_at_antimeridian.jl:53
in expression starting at /Users/simonesilvestri/.julia/packages/GeometryOps/LoXLj/src/GeometryOps.jl:3
in expression starting at stdin:4
ConservativeRegridding
Failed to precompile ConservativeRegridding [8e50ac2c-eb48-49bc-a402-07c87b949343] to "/Users/simonesilvestri/.julia/compiled/v1.10/ConservativeRegridding/jl_UH89QO".
ERROR: LoadError: UndefVarError: `CutAtAntimeridianAndPoles` not defined
Stacktrace:
[1] top-level scope
@ ~/.julia/packages/GeometryOps/LoXLj/src/transformations/correction/cut_at_antimeridian.jl:80
[2] include(mod::Module, _path::String)
@ Base ./Base.jl:495
[3] include(x::String)
@ GeometryOps ~/.julia/packages/GeometryOps/LoXLj/src/GeometryOps.jl:3
[4] top-level scope
@ ~/.julia/packages/GeometryOps/LoXLj/src/GeometryOps.jl:89
[5] include
@ ./Base.jl:495 [inlined] |
Ah my bad, looks like I pushed an incomplete change set. If you can go back one commit it should work, and I'll push a fix in half an hour or so. |
No problem, no rush, I imagined you guys were still working on it 😄 |
OK this should work now! |
32b860e
to
9a9eb0a
Compare
71b1953
to
a801c2c
Compare
39294cc
to
f614a9f
Compare
80fdae7
to
1f16564
Compare
5f71566
to
3b35b5c
Compare
3b35b5c
to
8c9e10f
Compare
8c9e10f
to
dc9536b
Compare
dc9536b
to
9c409c3
Compare
9c409c3
to
e54c0b4
Compare
it applies itself to planar geoms where it should not
e54c0b4
to
3d35b66
Compare
implement an antimeridian cutting fix ported from the python package
use traittarget in application_level for fix
Merge branch 'as/antimeridian' into as/trees-and-antimeridian