Improve interpolation of fields at receiver positions.
See original GitHub issueCurrently, the field at receiver positions is interpolated linearly. This can lead to quite large errors as we cover many orders of magnitude in EM; the problem is particularly pronounced with stretched grids. Here an example in 2D, but it applies equally for 3D:
This shows a dipole in a homogeneous fullspace, calculated with analytical solutions (hence no modelling errors); once it is calculated on a fine 5m x 5m grid (data shown on the left); and once on a stretched grid with stretching factor 1.1, having cell widths starting at 0.6 m up to 243 m. The middle figure shows the error if interpolated linearly, the right figure if interpolated with a cubic spline. Everything red means a relative error > 1%, hence not acceptable. Dark red is a relative error of 100% and more. (Notebook.)
There are various potential approaches for this, e.g.
- Implement a custom version in discretize, as is done in the case of the linear interpolation, which lives in
interputils_cython.pyx
; - Write a little wrapper using SciPy along the lines of interp_cubic_spline_3d.py.
- @banesullivan thinks that it could be possible through PyVista utilizing https://vtk.org/Wiki/VTK/Image_Interpolators;
- @leouieda thinks that it should not be too difficult to expand Verde to do that, https://github.com/fatiando/verde/issues/189.
Issue Analytics
- State:
- Created 4 years ago
- Comments:13 (13 by maintainers)
Top GitHub Comments
I’m running low on time to experiment with this - but it’s on my list!
I’m thinking this will be totally doable with VTK via PyVista, however the implementation will likely be as follows:
There will be an input dataset (the fine mesh) and a source dataset (the coarse mesh with data). Then the input dataset (triangular, octree, rectilinear, or whatever) will have a uniform mesh of equivalent/greater coverage made. It’s on this new uniform mesh that we could run a spline interpolation from the source dataset. Then the input dataset (the triangular or octree) would probe/sample the uniform mesh for data values. This is a bit cumbersome but it should have compelling (and fast) results for 2- and 3-D problems on all mesh types (regular, tree, or tetrahedral).
What I will likely end up doing is creating a new filter in PyVista called
interpolate_bspline
which will have similar usage tointerpolate
to perform exactly this. Note that theinterpolate
filter has this same workflow, but uses a radial Gaussian kernel for the interpolation - would there be interest from this community to add linear, ellipsoidal-gaussian, and/or probabilistic Voronoi kernels for interpolations?@lheagy , you said on Slack that in inversions this is a bit less of a concern, as you usually have designed the mesh so that all receivers are in the fine region. However, I think even then it could be beneficial. So if we improve the interpolation, then you would not have to put all receivers in the fine region, so you can end up with a grid with fewer cells and therefore faster inversions. I did some more testing and am convinced that for EM we should not use linear interpolation, not even with constant spacing.