[Matplotlib-users] matplotlib.tri.LinearTriInterpolator and dask

Ian Thomas ianthomas23 at gmail.com
Sat Jun 11 12:58:03 EDT 2022


Hi Jim,

No, there are no Dask versions of any Matplotlib code as far as I am aware.
The TriInterpolator and related classes in Matplotlib are only intended to
be helpers for visualisation purposes, for any serious manipulation of
unstructured grids you should probably use some appropriate domain-specific
code. I don't do much tri grid work now so I am not familiar with what is
available now. When the tri grid code was first written we would have
preferred to use a robust well-maintained library for such functionality
but we couldn't find one. There were quite a few people talking about how
good it would be for one to exist, but nobody was really prepared to make
it so. Maybe the situation has improved since then?

A couple of possibilities spring to mind:
1) scipy have similar functionality that may not require as much RAM, see
https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.griddata.html
2) The Pangeo discourse might be a good place to ask this question (
https://discourse.pangeo.io/) as there are a number of atmospheric and
oceanic scientists there who use triangular grids.

Ian

On Thu, 9 Jun 2022 at 18:59, James McManus <jmpmcmanus at gmail.com> wrote:

> Hi - I'm using matplotlib.tri.LinearTriInterpolator to regrid data from an
> unstructured 2d triangular grid, to a structured grid. It works great on
> smaller datasets, but when I try to regrid a larger dataset I get the
> following error:
>
> ---------------------------------------------------------------------------MemoryError                               Traceback (most recent call last)
> File <timed exec>:1, in <module>
>
> File ~/.conda/envs/pangeo/lib/python3.8/site-packages/matplotlib/tri/triinterpolate.py:265, in LinearTriInterpolator.__call__(self, x, y)    264 def __call__(self, x, y):--> 265     return self._interpolate_multikeys(x, y, tri_index=None,    266                                        return_keys=('z',))[0]
>
> File ~/.conda/envs/pangeo/lib/python3.8/site-packages/matplotlib/tri/triinterpolate.py:163, in TriInterpolator._interpolate_multikeys(self, x, y, tri_index, return_keys)    160 if x.shape != y.shape:    161     raise ValueError("x and y shall have same shapes."    162                      " Given: {0} and {1}".format(x.shape, y.shape))--> 163 x = np.ravel(x)    164 y = np.ravel(y)    165 x_scaled = x/self._unit_x
>
> File <__array_function__ internals>:180, in ravel(*args, **kwargs)
>
> File ~/.conda/envs/pangeo/lib/python3.8/site-packages/numpy/core/fromnumeric.py:1859, in ravel(a, order)   1857     return asarray(a).ravel(order=order)   1858 else:-> 1859     return asanyarray(a).ravel(order=order)
> MemoryError: Unable to allocate 13.2 GiB for an array with shape (1767600000,) and data type float64
>
>
> Is there a version of matplotlib.tri that uses Dask, to enable regridding of larger datasets?
>
>
> Thanks
>
> Jim
>
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users at python.org
> https://mail.python.org/mailman/listinfo/matplotlib-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/matplotlib-users/attachments/20220611/709a0591/attachment.html>


More information about the Matplotlib-users mailing list