interp_scattered — MATH interp_poly op

資料種類:points × signal × pointstable

呼叫: import fullseye as fs; fs.ledger.interp_scattered(points, values, query, method='linear', fill_value=nan, rescale=False, neighbors=None)(要直接呼叫實作,import mathops; mathops.interp_scattered(points, values, query, method='linear', fill_value=nan, rescale=False, neighbors=None);從台帳取用則 opsmath.get("interp_scattered"))

用法

> 該運算子的說明尚無譯文,以下照原文給出。

Values at *query* from scattered samples — sensor nets, boreholes, weather.

:func:interp_linear and :func:interp_cubic need samples on a sorted 1-D

axis. A great deal of measurement does not arrive that way: temperature

sensors bolted wherever a rack allowed, boreholes drilled where access

permitted, weather stations placed by history. This is the N-D scattered

entry point (`scipy.interpolate`), and it returns **how much of the answer

was not interpolation at all**.

*method*:

`"nearest"`

the value of the closest sample. Defined everywhere, and never

overshoots, but it is a staircase: on a smooth field the step itself

becomes a false feature. Measured on a smooth 3-D field sampled at 0.60,

the nearest-neighbour reconstruction leaves a residual of 0.975 units

where the sensor noise is only 0.15 — 6.5 times the noise, and none of

it is noise.

`"linear"`

barycentric interpolation on a Delaunay triangulation. Never exceeds the

surrounding samples, and is undefined outside their convex hull.

`"rbf"`

a thin-plate radial basis function through every sample. Smooth and

defined everywhere, but it overshoots its own nodes: measured on the

same field it returns peaks 1.372 times the sampled height, which is a

37 % over-statement of a hot spot that no interpolation of the data can

justify.

**The point of the `outside` return value.** Sensors sit inside a room, a

site, a country; the corners are always outside their hull. Ask a linear

interpolator there and it returns `fill_value`, or, if a caller quietly

falls back to nearest, it returns a different method's answer under the

first method's name. Measured on a 12 x 8.4 x 3.0 m room sampled at 1.20 m

spacing, 71.2 % of the evaluation grid lay outside the hull. A number

that large has to be visible, so it is returned rather than logged.

Parameters

----------

points : (n, d) array_like

Sample coordinates. 1-D input is accepted and treated as `(n, 1)`.

values : (n,) array_like

query : (m, d) or (..., d) array_like

Where to evaluate. The leading shape is preserved in the result.

method : {"linear", "nearest", "rbf"}

fill_value : float

Returned outside the convex hull for `"linear". "nearest"` and

`"rbf"` are defined everywhere and ignore it.

rescale : bool

Normalise each axis before triangulating. Needed when the axes have very

different units (metres against millimetres); ignored by `"rbf"`.

neighbors : int or None

`"rbf"` only: solve against the *k* nearest samples instead of all of

them. The global solve is O(n^3); measured on 5000 query points in 3-D,

it costs 0.55 / 1.76 / 7.53 s at 1400 / 4000 / 8000 samples, while

`neighbors=48` costs 0.38 / 0.55 / 0.81 s. Below a few thousand

samples the global solve is fine and exact — the knob earns its place

above that. `None` keeps the exact global solution.

Returns

-------

dict

`value (query shape), outside` (bool mask, query shape, of query

points beyond the convex hull of the samples), `outside_fraction`,

`method, n_points`.

Fail-closed: fewer samples than `d + 1` cannot define a simplex, and

raises `ValueError rather than returning a field made of fill_value`.

See also

--------

interp_linear : the sorted 1-D case, which is cheaper and needs no hull.

該族通用的輸入契約(fail-closed)

mathops 的每個運算子都先檢驗輸入再計算(不讓任何東西無聲通過):

• **complex 輸入一律 ValueError** —— 強制轉成 float64 會無聲丟掉虛部(numpy 只發一個 ComplexWarning,然後回傳一個「看似合理卻是錯的」實數)。請明確寫出 .real/.imag/abs(),或改用支援複數的 complexops。

• **含被遮罩元素的 masked array 一律 ValueError** —— 拒絕「剝掉遮罩直接使用下面原值」的隱式轉換。請明確選擇填補還是丟棄。

• **所有輸入中的 NaN/Inf 一律 ValueError**(明確給出個數後拒絕 —— 它會汙染整個結果)。

形狀嚴格:不對 1-D 與 2-D 做隱式提升或廣播(向量槽位收到矩陣、矩陣槽位收到向量都是 ValueError;請明確 reshape)。

尺寸上限:接受矩陣的運算子與 stat_histogram 的 bins,超過 mathops.MAX_ELEMENTS(2^26 ≈ 6700 萬個元素)即 ValueError

詳細使用指南

math_metrology 族使用指南

參考(範例資料・文獻)

• 範例資料目錄(下載 URL / 授權) —— 2-D 用 skimage.data(BSD/公有領域)加合成圖,3-D 給出真實資料源(Stanford/PDS 等)的下載 URL。

• 運算子來歷與參考文獻 —— 該運算子族所依據的研究/方法出處。

• 演算法的正典(作者・年份)與用途見上面的族使用指南

可執行的範例(實際呼叫該運算子並已驗證的樣例)

poc_datacenter_thermal_fieldpy -3.11 examples/poc_datacenter_thermal_field.py

poc_multibeam_bathymetrypy -3.11 examples/poc_multibeam_bathymetry.py

poc_stockpile_volumepy -3.11 examples/poc_stockpile_volume.py

型別可銜接的下一個運算子(可接受 table 作為輸入)

同類別(interp_poly)

interp_linear · interp_cubic · poly_fit · poly_eval · poly_roots


*Provenance: mathops.py — MATH 運算子登記表。本條目由 tools/opdocs.py md 自動產生(請勿手動編輯)。*

© 2026 Kazufumi Furuse — Fullseye operator documentation. Licensed under Apache-2.0.