-
Notifications
You must be signed in to change notification settings - Fork 8
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
[MakieCon2023] New (faster) Interpolators #31
Comments
reimplement https://github.com/scipy/scipy/blob/main/scipy/interpolate/interpnd.pyx cloughtochter2d (we are in C2) |
Regards to interpolation.jl: JuliaMath/Interpolations.jl#118 <-- seems unresolved. I'm not sure what we possibly could optimize with ScatteredInterpolation, but 7s as in the docs seems quite slow.. |
If someone wants to have a quickstart, I expose the interpolation algorithms here & run some @time |
Hi. Just finished my MakieCon 2023 project to implement Regarding the already available interpolators in Topoplots:
From what I can see at the moment most of step 1 is also done in step 2. |
Not sure I understand, but then I did not check how you use the interpolators in the rest of the package. ip = CloughTocherInterpolator(ref_xy,ref_z)
...
intrp_xy, intrp_z = zeros(2*N), zeros(N)
for i = 1:1000
# update intrp_xy
ip(intrp_z, intrp_xy) # interpolate inplace into intrp_z
end
If you mean by that that the reference grid is unchanged but the reference data changes, then we could easily add an
Ok, I see.
Yeah, the
Thanks for the snapshot, certainly useful, because I did not do any optimizations yet.
Ok interesting, I need to have a look on that too. Some more comments:
Btw: I would appreciate any feedback about the interface. In particular, the ordering of arguments for the inplace interpolation seems to be at odds with that of constructing the interpolator, e.g. ip = CloughTocherInterpolation(xy,z)
intrp_xy = randn(2,40)
intrp_z = zeros(40)
ip(intrp_z,intrp_xy) # mutate intrp_z |
Regarding
Turns out extracting the equations directly from Btw: |
Brief update: I managed to compute the hyperplane equations and, thus, also port the smart Regarding this:
I wanted to give this a shot, but failed in reproducing the problem (but I only tried on current master, perhaps its now already fixed?). Below is my benchmark using CloughTocher2DInterpolation
using BenchmarkTools
xrange = LinRange(0,1,500)
yrange = LinRange(0,1,500)
positions = rand(2,100)
data = rand(100)
@time s = CloughTocher2DInterpolation.CloughTocher2DInterpolator(positions, data)
x = (xrange)' .* ones(length(yrange))
y = ones(length(xrange))' .* (yrange)
icoords = hcat(x[:],y[:])'
icoords_flat = icoords[:]
@btime $s($icoords)
@btime $s($icoords_flat) which gives 176.671 ms (6 allocations: 1.91 MiB)
175.796 ms (8 allocations: 1.91 MiB) @behinger Could you check whether this fixed all your concerns? |
wow! indeed it is now ~10x faster, it takes 35ms on my machine now (tested with @time only) (which is slightly faster than the python version!). Wow this is really great! Also vector and non-vector are also the same speed now 🎉 |
if you register the package, I can include it in TopoPlots.jl already :) |
Registration is in progress: JuliaRegistries/General#83213 |
checkout if we can now use
Interpolators.jl
maybe optimize the use of
ScatteredInterpolators.jl
The text was updated successfully, but these errors were encountered: