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 sorted y as rows and sorted x as columns.

  • xs (numpy.ndarray) – Sorted unique x coordinates, shape (nx,).

  • ys (numpy.ndarray) – Sorted unique y coordinates, shape (ny,).

  • x_2d (numpy.ndarray) – 2D meshgrid of x coordinates, shape (ny, nx).

  • y_2d (numpy.ndarray) – 2D meshgrid of y coordinates, 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.