Skip to content

Interpolation is not implemented for Grid3D #1049

Description

@ecomodeller

Neither interpolation entry point works on dfs3 data:

da = mikeio.read("tests/testdata/dissolved_oxygen.dfs3")[0]

da.interp(x=586000, y=6143000)
# NotImplementedError: Interpolation in Grid3D(nz=17, ny=112, nx=91) is not yet implemented

da.interp_like(da.geometry)
# NotImplementedError: Currently only supports 2d flexible mesh data!

Extracting a vertical profile at a position, or resampling a dfs3 onto another grid, both need this. The current workaround is to select a layer first and interpolate the resulting 2D grid, which cannot produce a profile and cannot interpolate between layers.

The interp_like message is also misleading: it says "only supports 2d flexible mesh data", but the method does work for Grid2D. It is reporting the wrong restriction.

Related: #1023 (geometries do not share a common interpolant interface) and #1019 (DataArray.interp() signature) — this is probably best done as part of whichever of those settles the interface, rather than as a one-off Grid3D branch.


Code sites:

  • src/mikeio/dataset/_dataarray.py (DataArray.interp, DataArray.interp_like)
  • src/mikeio/spatial/_grid_geometry.py (Grid3D)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions