geopfa.extrapolation.grid_from_tidy¶
- grid_from_tidy(df)[source]¶
Convert tidy (x, y, value) data into a rectangular grid and aligned meshgrids.
- Parameters:
df (pandas.DataFrame) – A tidy DataFrame with columns
'x','y', and'value'.- Returns:
grid (pandas.DataFrame) – Pivoted grid of shape
(ny, nx), with sortedyas rows and sortedxas columns.xs (numpy.ndarray) – Sorted unique
xcoordinates, shape(nx,).ys (numpy.ndarray) – Sorted unique
ycoordinates, shape(ny,).x_2d (numpy.ndarray) – 2D meshgrid of
xcoordinates, shape(ny, nx).y_2d (numpy.ndarray) – 2D meshgrid of
ycoordinates, shape(ny, nx).
Notes
This function assumes a rectangular lattice is desired, and therefore sorts x and y independently.
Unobserved (x, y) pairs appear as NaN in the returned grid.