-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an "interpolator reference image" page to the docs
- Loading branch information
1 parent
6c539bf
commit cccf8f2
Showing
2 changed files
with
103 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
# Interpolator reference | ||
|
||
This file contains reference figures showing the output of each interpolator available in TopoPlots, as well as timings for them. | ||
|
||
It is a more comprehensive version of the plot in [Interpolation](@ref). | ||
|
||
### Example data | ||
|
||
```@example 1 | ||
using TopoPlots, CairoMakie, ScatteredInterpolation, NaturalNeighbours | ||
data, positions = TopoPlots.example_data() | ||
f = Figure(size=(1000, 1500)) | ||
interpolators = [ | ||
SplineInterpolator() NullInterpolator() DelaunayMesh(); | ||
CloughTocher() ScatteredInterpolationMethod(ThinPlate()) ScatteredInterpolationMethod(Shepard(3)); | ||
ScatteredInterpolationMethod(Multiquadratic()) ScatteredInterpolationMethod(InverseMultiquadratic()) ScatteredInterpolationMethod(Gaussian()); | ||
NaturalNeighboursMethod(Hiyoshi(2)) NaturalNeighboursMethod(Sibson()) NaturalNeighboursMethod(Laplace()); | ||
NaturalNeighboursMethod(Farin()) NaturalNeighboursMethod(Sibson(1)) NaturalNeighboursMethod(Nearest()); | ||
] | ||
data_slice = data[:, 360, 1] | ||
for idx in CartesianIndices(interpolators) | ||
interpolation = interpolators[idx] | ||
# precompile to get accurate measurements | ||
TopoPlots.topoplot( | ||
data_slice, positions; | ||
contours=true, interpolation=interpolation, | ||
labels = string.(1:length(positions)), colorrange=(-1, 1), | ||
label_scatter=(markersize=10,), | ||
axis=(type=Axis, title="...", aspect=DataAspect(),)) | ||
# measure time, to give an idea of what speed to expect from the different interpolators | ||
t = @elapsed ax, pl = TopoPlots.topoplot( | ||
f[Tuple(idx)...], data_slice, positions; | ||
contours=true, | ||
interpolation=interpolation, | ||
labels = string.(1:length(positions)), colorrange=(-1, 1), | ||
label_scatter=(markersize=10,), | ||
axis=(type=Axis, title="$(typeof(interpolation))()",aspect=DataAspect(),)) | ||
ax.title = ("$(typeof(interpolation))() - $(round(t, digits=2))s") | ||
if interpolation isa Union{NaturalNeighboursMethod, ScatteredInterpolationMethod} | ||
ax.title = "$(typeof(interpolation))() - $(round(t, digits=2))s" | ||
ax.subtitle = string(typeof(interpolation.method)) | ||
end | ||
end | ||
f | ||
``` | ||
|
||
### Randomly sampled function | ||
|
||
```@example 1 | ||
data = Makie.peaks(100) | ||
sampling_points = rand(CartesianIndices(data), 100) | ||
data_slice = data[sampling_points] | ||
positions = Point2f.(Tuple.(sampling_points)) | ||
interpolators = [ | ||
SplineInterpolator(; smoothing = 5) NullInterpolator() DelaunayMesh(); | ||
CloughTocher() ScatteredInterpolationMethod(ThinPlate()) ScatteredInterpolationMethod(Shepard(3)); | ||
ScatteredInterpolationMethod(Multiquadratic()) ScatteredInterpolationMethod(InverseMultiquadratic()) ScatteredInterpolationMethod(Gaussian()); | ||
NaturalNeighboursMethod(Hiyoshi(2)) NaturalNeighboursMethod(Sibson()) NaturalNeighboursMethod(Laplace()); | ||
NaturalNeighboursMethod(Farin()) NaturalNeighboursMethod(Sibson(1)) NaturalNeighboursMethod(Nearest()); | ||
] | ||
f = Figure(; size = (1000, 1500)) | ||
for idx in CartesianIndices(interpolators) | ||
interpolation = interpolators[idx] | ||
# precompile to get accurate measurements | ||
TopoPlots.topoplot( | ||
data_slice, positions; | ||
contours=true, interpolation=interpolation, | ||
labels = string.(1:length(positions)), colorrange=(-1, 1), | ||
label_scatter=(markersize=10,), | ||
axis=(type=Axis, title="...", aspect=DataAspect(),)) | ||
# measure time, to give an idea of what speed to expect from the different interpolators | ||
t = @elapsed ax, pl = TopoPlots.topoplot( | ||
f[Tuple(idx)...], data_slice, positions; | ||
contours=true, | ||
interpolation=interpolation, | ||
labels = string.(1:length(positions)), colorrange=(-1, 1), | ||
label_scatter=(markersize=10,), | ||
axis=(type=Axis, title="$(typeof(interpolation))()",aspect=DataAspect(),)) | ||
ax.title = ("$(typeof(interpolation))() - $(round(t, digits=2))s") | ||
if interpolation isa Union{NaturalNeighboursMethod, ScatteredInterpolationMethod} | ||
ax.title = "$(typeof(interpolation))() - $(round(t, digits=2))s" | ||
ax.subtitle = string(typeof(interpolation.method)) | ||
end | ||
end | ||
f | ||
``` |