Selecting a single column out of a dfs3 requires selecting along x and then along y. Both of the obvious ways to write that fail, and the way that works reads wrongly.
da = mikeio.read("tests/testdata/dissolved_oxygen.dfs3")[0]
da.dims # ("time", "z", "y", "x")
da.isel(x=56, y=110) # NotImplementedError: Selecting on multiple
# dimensions in the same call, not yet implemented
da.isel(x=56).isel(y=110) # IndexError: index 110 is out of bounds
# for axis 0 with size 17
da.isel(x=56).isel(x=110) # works, and the values are correct
The cause is that a vertical slice is represented as a Grid2D, whose axes are named x and y by definition. After isel(x=56) the original z axis is reported as y and the original y axis as x:
s = da.isel(x=55)
s.dims # ("time", "y", "x")
s.geometry.nx, s.geometry.ny # 112, 17 -- i.e. original ny, nz
So the extents are right and the data is right — isel(x=..).isel(x=..) returns exactly the expected column — but the labels describe a horizontal grid that this object is not. A caller who trusts dims gets an IndexError, and one who works around it has to know that x means two different axes on consecutive lines.
Worth deciding whether a vertical slice should be a Grid2D at all. #1010 covers the related loss of origin/orientation/projection in the same branches; both come from reusing a horizontal grid type for a vertical slice.
Code sites:
src/mikeio/spatial/_grid_geometry.py (Grid3D.isel, the axis == 1andaxis == 2 branches)
src/mikeio/dataset/_dataarray.py (DataArray.isel, the multiple-dimension guard)
Selecting a single column out of a dfs3 requires selecting along
xand then alongy. Both of the obvious ways to write that fail, and the way that works reads wrongly.The cause is that a vertical slice is represented as a
Grid2D, whose axes are namedxandyby definition. Afterisel(x=56)the original z axis is reported asyand the original y axis asx:So the extents are right and the data is right —
isel(x=..).isel(x=..)returns exactly the expected column — but the labels describe a horizontal grid that this object is not. A caller who trustsdimsgets anIndexError, and one who works around it has to know thatxmeans two different axes on consecutive lines.Worth deciding whether a vertical slice should be a
Grid2Dat all.#1010covers the related loss oforigin/orientation/projectionin the same branches; both come from reusing a horizontal grid type for a vertical slice.Code sites:
src/mikeio/spatial/_grid_geometry.py (Grid3D.isel, theaxis == 1andaxis == 2branches)src/mikeio/dataset/_dataarray.py (DataArray.isel, the multiple-dimension guard)