Skip to content

isel(layer=...) is exposed on FM 3D DataArrays but can never work #968

@ecomodeller

Description

@ecomodeller

DataArray.isel accepts layer= as a kwarg, and the docstring states "layer index, only used in dfsu 3d". But for a 3D dfsu the array dims are (time, element) — there is no layer axis — so the call always fails:

ds = mikeio.read("oresund_sigma_z.dfsu")
da = ds[0]
da.isel(layer=0)
# ValueError: layer is not present in ('element',)

Layer selection on layered FM only works via .sel(layers=...), which resolves layer→element via the geometry. That's the right home for it semantically (label lookup, not axis indexing).

The friction is that isel's signature suggests layer= should work on dfsu 3d, and the failure mode is a generic dim-not-found error rather than guidance toward sel.

Suggestions (any one would help)

  • Drop layer= from DataArray.isel for FM geometries (or remove it entirely if no geometry uses it via isel).
  • If kept, raise a targeted error: "FM 3D data has no layer dim — use da.sel(layers=...) instead."
  • Alternatively, dispatch isel(layer=...) on FM 3D to the same path as sel(layers=...).

Background

Surfaced while updating DHI/mikeio-explorer#2 to use the explicit layer selection recommended by #901.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions