Participer au site avec un Tip
Rechercher
 

Améliorations / Corrections

Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.

Emplacement :

Description des améliorations :

Vous êtes un professionnel et vous avez besoin d'une formation ? Mise en oeuvre d'IHM
avec Qt et PySide6
Voir le programme détaillé
Module « scipy.interpolate »

Classe « NearestNDInterpolator »

Informations générales

Héritage

builtins.object
    NDInterpolatorBase
        NearestNDInterpolator

Définition

class NearestNDInterpolator(NDInterpolatorBase):

help(NearestNDInterpolator)

NearestNDInterpolator(x, y).

Nearest-neighbor interpolator in N > 1 dimensions.

.. versionadded:: 0.9

Methods
-------
__call__

Parameters
----------
x : (npoints, ndims) 2-D ndarray of floats
    Data point coordinates.
y : (npoints, ) 1-D ndarray of float or complex
    Data values.
rescale : boolean, optional
    Rescale points to unit cube before performing interpolation.
    This is useful if some of the input dimensions have
    incommensurable units and differ by many orders of magnitude.

    .. versionadded:: 0.14.0
tree_options : dict, optional
    Options passed to the underlying ``cKDTree``.

    .. versionadded:: 0.17.0

See Also
--------
griddata :
    Interpolate unstructured D-D data.
LinearNDInterpolator :
    Piecewise linear interpolator in N dimensions.
CloughTocher2DInterpolator :
    Piecewise cubic, C1 smooth, curvature-minimizing interpolator in 2D.
interpn : Interpolation on a regular grid or rectilinear grid.
RegularGridInterpolator : Interpolator on a regular or rectilinear grid
                          in arbitrary dimensions (`interpn` wraps this
                          class).

Notes
-----
Uses ``scipy.spatial.cKDTree``

.. note:: For data on a regular grid use `interpn` instead.

Examples
--------
We can interpolate values on a 2D plane:

>>> from scipy.interpolate import NearestNDInterpolator
>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> rng = np.random.default_rng()
>>> x = rng.random(10) - 0.5
>>> y = rng.random(10) - 0.5
>>> z = np.hypot(x, y)
>>> X = np.linspace(min(x), max(x))
>>> Y = np.linspace(min(y), max(y))
>>> X, Y = np.meshgrid(X, Y)  # 2D grid for interpolation
>>> interp = NearestNDInterpolator(list(zip(x, y)), z)
>>> Z = interp(X, Y)
>>> plt.pcolormesh(X, Y, Z, shading='auto')
>>> plt.plot(x, y, "ok", label="input point")
>>> plt.legend()
>>> plt.colorbar()
>>> plt.axis("equal")
>>> plt.show()

Constructeur(s)

Signature du constructeur Description
__init__(self, x, y, rescale=False, tree_options=None)

Liste des opérateurs

Opérateurs hérités de la classe object

__eq__, __ge__, __gt__, __le__, __lt__, __ne__

Liste des méthodes

Toutes les méthodes Méthodes d'instance Méthodes statiques Méthodes dépréciées
Signature de la méthodeDescription
__call__(self, *args, **query_options)

Méthodes héritées de la classe NDInterpolatorBase

__init_subclass__, __subclasshook__

Méthodes héritées de la classe object

__delattr__, __dir__, __format__, __getattribute__, __getstate__, __hash__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__

Vous êtes un professionnel et vous avez besoin d'une formation ? Mise en oeuvre d'IHM
avec Qt et PySide6
Voir le programme détaillé