Skip to content

Commit

Permalink
Add an "interpolator reference image" page to the docs
Browse files Browse the repository at this point in the history
  • Loading branch information
asinghvi17 committed Apr 23, 2024
1 parent 6c539bf commit cccf8f2
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ makedocs(;
"Home" => "index.md",
"General TopoPlots" => "general.md",
"EEG" => "eeg.md",
"Function reference" => "functions.md"
"Function reference" => "functions.md",
"Interpolator reference images" => "interpolator_reference.md"
],
)

Expand Down
101 changes: 101 additions & 0 deletions docs/src/interpolator_reference.md
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
```

0 comments on commit cccf8f2

Please sign in to comment.