Skip to content

griddata

py3dinterpolations.core.griddata

Core data container for 3D interpolation.

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
def __init__(
    self,
    data: pd.DataFrame,
    *,
    ID: str = "ID",
    X: str = "X",
    Y: str = "Y",
    Z: str = "Z",
    V: str = "V",
    preprocessing_params: PreprocessingParams | None = None,
):
    self.preprocessing_params = preprocessing_params
    self.columns = {"ID": ID, "X": X, "Y": Y, "Z": Z, "V": V}
    self.data = self._set_data(data)

specs property

Compute spatial and value extent statistics.

numpy_data property

Return X, Y, Z, V as a numpy array.

hull property

Convex hull of XY coordinates as a shapely geometry.

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
@classmethod
def from_dataframe(cls, data: pd.DataFrame) -> "GridDataSpecs":
    """Compute specs from a canonical GridData DataFrame."""
    df = data.reset_index()
    return cls(
        xmin=float(df["X"].min()),
        xmax=float(df["X"].max()),
        ymin=float(df["Y"].min()),
        ymax=float(df["Y"].max()),
        zmin=float(df["Z"].min()),
        zmax=float(df["Z"].max()),
        vmin=float(df["V"].min()),
        vmax=float(df["V"].max()),
    )