+
    /iz/                     x    R t ^ RIt^RIHtHtHtHt ^ RIH	t	 . R	Ot
 ! R R]4      tR]P                  R3R ltR# )
zD
Convenience interface to N-D interpolation

.. versionadded:: 0.9

N)LinearNDInterpolatorNDInterpolatorBaseCloughTocher2DInterpolator_ndim_coords_from_arrays)cKDTreeNearestNDInterpolatorc                   4   a  ] tR t^t o RtRR ltR tRtV tR# )r   a  Nearest-neighbor interpolator in N > 1 dimensions.

Methods
-------
__call__

Parameters
----------
x : (npoints, ndims) 2-D ndarray of floats
    Data point coordinates.
y : (npoints, ...) N-D ndarray of float or complex
    Data values. The length of `y` along the first axis must be equal to
    the length of `x`.
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()

Nc           	         \         P                  ! WW#R R R7       Vf   \        4       p\        V P                  3/ VB V n        \        P                  ! V4      V n        R# )F)rescaleneed_contiguousneed_valuesN)	r   __init__dictr   pointstreenpasarrayvalues)selfxyr
   tree_optionss   &&&&&[/var/www/html/photoedit/myenv/lib/python3.14/site-packages/scipy/interpolate/_ndgriddata.pyr   NearestNDInterpolator.__init__Y   sM    ##DQ4905	7 6LDKK8<8	jjm    c                4   \        WP                  P                  ^,          R7      pV P                  V4      pV P	                  V4      pVP                  RVP                  R,          4      pVP                  pVP                  pV P                  P                  ! V3/ VB w  rx\        P                  ! V4      p	V P                  P                  ^8  d)   VRR V P                  P                  R,          ,           p
MVRR p
\        P                  ! V P                  P                  \        P                  4      '       d=   \        P                  ! V
\        P                   V P                  P                  R7      pM%\        P                  ! V
\        P                   4      pV P                  W,          R3,          W&   V P                  P                  ^8  d)   VRR V P                  P                  R,          ,           pMVRR pVP                  V4      pV# )a%  
Evaluate interpolator at given points.

Parameters
----------
x1, x2, ... xn : array-like of float
    Points where to interpolate data at.
    x1, x2, ... xn can be array-like of float with broadcastable shape.
    or x1 can be array-like of float with shape ``(..., ndim)``
**query_options
    This allows ``eps``, ``p``, ``distance_upper_bound``, and ``workers``
    being passed to the cKDTree's query function to be explicitly set.
    See `scipy.spatial.cKDTree.query` for an overview of the different options.

    .. versionadded:: 1.12.0

)ndimN:   NN)dtype.)r   r   shape_check_call_shape_scale_xreshaper   queryr   isfiniter   r   
issubdtyper   complexfloatingfullnan)r   argsquery_optionsxixi_flatoriginal_shapeflattened_shapedisti
valid_maskinterp_shapeinterp_values	new_shapes   &*,          r   __call__NearestNDInterpolator.__call__b   s   * &d1B1B11EF##B']]2 **R".!-- ))//';];[[&
 ;;a*3B/$++2C2CB2GGL*3B/L==**B,>,>??GGL"&&@Q@QRMGGL"&&9M$(KKs0B$C!;;a&s+dkk.?.?.CCI&s+I%--i8r   )r   r   )FN)	__name__
__module____qualname____firstlineno____doc__r   r6   __static_attributes____classdictcell__)__classdict__s   @r   r   r      s     BH$A Ar   linearFc           	        \        V 4      p V P                  ^8  d   V P                  pMV P                  R,          pV^8X  d   VR9   d   ^RIHp V P                  4       p \        V\        4      '       d    \        V4      ^8w  d   \        R4      hVw  p\        P                  ! V 4      pW,          p W,          pVR8X  d   RpV! WV^ RVR7      p	V	! V4      # VR8X  d   \        WVR	7      p	V	! V4      # VR8X  d   \        WVVR
7      p	V	! V4      # VR8X  d   V^8X  d   \        WVVR
7      p	V	! V4      # \        RV: RV R24      h)a
  
Convenience function for interpolating unstructured data in multiple dimensions.

Parameters
----------
points : 2-D ndarray of floats with shape (n, D), or length D tuple of 1-D ndarrays with shape (n,).
    Data point coordinates.
values : ndarray of float or complex, shape (n,)
    Data values.
xi : 2-D ndarray of floats with shape (m, D), or length D tuple of ndarrays broadcastable to the same shape.
    Points at which to interpolate data.
method : {'linear', 'nearest', 'cubic'}, optional
    Method of interpolation. One of

    ``nearest``
      return the value at the data point closest to
      the point of interpolation. See `NearestNDInterpolator` for
      more details.

    ``linear``
      tessellate the input point set to N-D
      simplices, and interpolate linearly on each simplex. See
      `LinearNDInterpolator` for more details.

    ``cubic`` (1-D)
      return the value determined from a cubic
      spline.

    ``cubic`` (2-D)
      return the value determined from a
      piecewise cubic, continuously differentiable (C1), and
      approximately curvature-minimizing polynomial surface. See
      `CloughTocher2DInterpolator` for more details.
fill_value : float, optional
    Value used to fill in for requested points outside of the
    convex hull of the input points. If not provided, then the
    default is ``nan``. This option has no effect for the
    'nearest' method.
rescale : bool, 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

Returns
-------
ndarray
    Array of interpolated values.

See Also
--------
LinearNDInterpolator :
    Piecewise linear interpolator in N dimensions.
NearestNDInterpolator :
    Nearest-neighbor 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
-----

.. versionadded:: 0.9

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

Examples
--------

Suppose we want to interpolate the 2-D function

>>> import numpy as np
>>> def func(x, y):
...     return x*(1-x)*np.cos(4*np.pi*x) * np.sin(4*np.pi*y**2)**2

on a grid in [0, 1]x[0, 1]

>>> grid_x, grid_y = np.mgrid[0:1:100j, 0:1:200j]

but we only know its values at 1000 data points:

>>> rng = np.random.default_rng()
>>> points = rng.random((1000, 2))
>>> values = func(points[:,0], points[:,1])

This can be done with `griddata` -- below we try out all of the
interpolation methods:

>>> from scipy.interpolate import griddata
>>> grid_z0 = griddata(points, values, (grid_x, grid_y), method='nearest')
>>> grid_z1 = griddata(points, values, (grid_x, grid_y), method='linear')
>>> grid_z2 = griddata(points, values, (grid_x, grid_y), method='cubic')

One can see that the exact result is reproduced by all of the
methods to some degree, but for this smooth function the piecewise
cubic interpolant gives the best results:

>>> import matplotlib.pyplot as plt
>>> plt.subplot(221)
>>> plt.imshow(func(grid_x, grid_y).T, extent=(0,1,0,1), origin='lower')
>>> plt.plot(points[:,0], points[:,1], 'k.', ms=1)
>>> plt.title('Original')
>>> plt.subplot(222)
>>> plt.imshow(grid_z0.T, extent=(0,1,0,1), origin='lower')
>>> plt.title('Nearest')
>>> plt.subplot(223)
>>> plt.imshow(grid_z1.T, extent=(0,1,0,1), origin='lower')
>>> plt.title('Linear')
>>> plt.subplot(224)
>>> plt.imshow(grid_z2.T, extent=(0,1,0,1), origin='lower')
>>> plt.title('Cubic')
>>> plt.gcf().set_size_inches(6, 6)
>>> plt.show()

nearestr@   cubic)interp1dz"invalid number of dimensions in xiextrapolateF)kindaxisbounds_error
fill_value)r
   )rI   r
   zUnknown interpolation method z for z dimensional datar   )rB   r@   rC   )r   r   r    _interpolaterD   ravel
isinstancetuplelen
ValueErrorr   argsortr   r   r   )
r   r   r,   methodrI   r
   r   rD   idxips
   &&&&&&    r   griddatarT      sG   t &f-F{{Q{{||BqyV==*b%  2w!| !EFFCBjj Y&Jf6!+-"v	9	"67C"v	8	!&Z*13"v	7	tqy':079"v+F:U4&@QR
 	
r   )rT   r   r   r   )r<   numpyr   	_interpndr   r   r   r   scipy.spatialr   __all__r   r)   rT    r   r   <module>rZ      sG    ; ; !)O. On )1RVV_
r   