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.
DataArray.iselacceptslayer=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 nolayeraxis — so the call always fails: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 suggestslayer=should work on dfsu 3d, and the failure mode is a generic dim-not-found error rather than guidance towardsel.Suggestions (any one would help)
layer=fromDataArray.iselfor FM geometries (or remove it entirely if no geometry uses it viaisel).da.sel(layers=...)instead."isel(layer=...)on FM 3D to the same path assel(layers=...).Background
Surfaced while updating DHI/mikeio-explorer#2 to use the explicit layer selection recommended by #901.