core
py3dinterpolations.core
¶
Core data structures and grid definitions.
Grid3D(x, y, z)
¶
Bases: ABC
Abstract base class for 3D interpolation grids.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
GridAxis
|
X axis definition. |
required |
y
|
GridAxis
|
Y axis definition. |
required |
z
|
GridAxis
|
Z axis definition. |
required |
Source code in py3dinterpolations/core/grid3d.py
47 48 49 50 51 | |
grid
property
¶
1D grid arrays per axis.
normalized_grid
property
¶
Min-max normalized 1D grid arrays per axis.
gridres
property
¶
Grid resolution; scalar if uniform, dict otherwise.
mesh
property
¶
3D meshgrid arrays.
normalized_mesh
property
¶
Normalized 3D meshgrid arrays.
get_axis(axis)
¶
Get a grid axis by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
axis
|
str | Axis
|
Axis name ("X", "Y", "Z") or Axis enum. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If axis name is invalid. |
Source code in py3dinterpolations/core/grid3d.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | |
prediction_points()
abstractmethod
¶
Return (N, 3) array of points at which to predict.
Source code in py3dinterpolations/core/grid3d.py
138 139 140 141 | |
GridAxis(name, min, max, res)
dataclass
¶
IrregularGrid3D(x_min, x_max, x_res, y_min, y_max, y_res, z_min, z_max, z_res, hull=None)
¶
Bases: Grid3D
3D grid with per-axis resolution and optional convex hull filtering.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x_min
|
float
|
Minimum X value. |
required |
x_max
|
float
|
Maximum X value. |
required |
x_res
|
float
|
X axis resolution. |
required |
y_min
|
float
|
Minimum Y value. |
required |
y_max
|
float
|
Maximum Y value. |
required |
y_res
|
float
|
Y axis resolution. |
required |
z_min
|
float
|
Minimum Z value. |
required |
z_max
|
float
|
Maximum Z value. |
required |
z_res
|
float
|
Z axis resolution. |
required |
hull
|
BaseGeometry | None
|
Optional convex hull geometry for XY filtering. |
None
|
Source code in py3dinterpolations/core/grid3d.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | |
prediction_points()
¶
Return grid points filtered by convex hull if available.
Source code in py3dinterpolations/core/grid3d.py
223 224 225 226 227 228 229 230 231 232 233 | |
RegularGrid3D(x_min, x_max, y_min, y_max, z_min, z_max, gridres)
¶
Bases: Grid3D
Regular 3D grid with equal spacing in all axes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x_min
|
float
|
Minimum X value. |
required |
x_max
|
float
|
Maximum X value. |
required |
y_min
|
float
|
Minimum Y value. |
required |
y_max
|
float
|
Maximum Y value. |
required |
z_min
|
float
|
Minimum Z value. |
required |
z_max
|
float
|
Maximum Z value. |
required |
gridres
|
float
|
Uniform grid resolution. |
required |
Source code in py3dinterpolations/core/grid3d.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |
prediction_points()
¶
Return all grid points as (N, 3) array.
Source code in py3dinterpolations/core/grid3d.py
181 182 183 184 | |
GridData(data, *, ID='ID', X='X', Y='Y', Z='Z', V='V', preprocessing_params=None)
¶
Container for 3D grid data with spatial coordinates and values.
Standardizes input DataFrames into a canonical format with MultiIndex (ID, X, Y, Z) and a single column V.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
Source DataFrame with spatial data. |
required |
ID
|
str
|
Column name for point identifier. |
'ID'
|
X
|
str
|
Column name for X coordinate. |
'X'
|
Y
|
str
|
Column name for Y coordinate. |
'Y'
|
Z
|
str
|
Column name for Z coordinate. |
'Z'
|
V
|
str
|
Column name for value. |
'V'
|
preprocessing_params
|
PreprocessingParams | None
|
Parameters from preprocessing applied to this data. |
None
|
Source code in py3dinterpolations/core/griddata.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
GridDataSpecs(xmin, xmax, ymin, ymax, zmin, zmax, vmin, vmax)
dataclass
¶
Precomputed spatial and value extent statistics.
Computed once from a DataFrame rather than re-reading on every access.
from_dataframe(data)
classmethod
¶
Compute specs from a canonical GridData DataFrame.
Source code in py3dinterpolations/core/griddata.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 | |
Axis
¶
Bases: StrEnum
Spatial axis identifier.
DownsamplingParams(resolution)
dataclass
¶
Downsampling parameters.
DownsamplingStatistic
¶
Bases: StrEnum
Supported downsampling statistics.
GridResolution(x, y, z)
dataclass
¶
Grid resolution per axis.
Use uniform() for equal resolution on all axes,
or from_input() to accept either float or per-axis dict.
uniform(resolution)
classmethod
¶
Create uniform resolution across all axes.
Source code in py3dinterpolations/core/types.py
95 96 97 98 | |
from_input(resolution)
classmethod
¶
Create from either a uniform float or per-axis dict.
Source code in py3dinterpolations/core/types.py
100 101 102 103 104 105 106 107 108 109 110 111 112 | |
InterpolationResult(interpolated, variance=None, probability=None)
dataclass
¶
Result of an interpolation run.
ModelType
¶
Bases: StrEnum
Supported interpolation model types.
NormalizationParams(min, max)
dataclass
¶
Min/max normalization parameters for a single axis.
PreprocessingParams(downsampling=None, normalization=None, standardization=None)
dataclass
¶
Collected preprocessing parameters from a preprocessing run.
SklearnClassifier
¶
SklearnEstimator
¶
Bases: Protocol
Structural type for sklearn-compatible estimators.
StandardizationParams(mean, std)
dataclass
¶
Mean/std standardization parameters.
create_grid(griddata, resolution)
¶
Factory to create the appropriate Grid3D from data and resolution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
griddata
|
GridData
|
Source data to derive grid extents from. |
required |
resolution
|
float | dict[str, float]
|
Uniform float for RegularGrid3D, or per-axis dict for IrregularGrid3D. |
required |
Returns:
| Type | Description |
|---|---|
Grid3D
|
A Grid3D subclass instance. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If resolution type is unsupported. |
Source code in py3dinterpolations/core/grid3d.py
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | |