A dfs3 file stores gridded data with three spatial dimensions. Like dfs2, values are ‘element based’, i.e. defined in the centre of each grid cell. The layers are ordered from the bottom up, so the last layer is the top one.
The spatial information is available in the geometry attribute (accessible from Dfs3, Dataset, and DataArray), which for a dfs3 file is a Grid3D geometry.
The horizontal axes behave as they do for dfs2. The vertical one is described by z, nz and dz, and is numbered from the bottom up, so the last layer is the top one. See the API reference for the full set of properties and methods.
A dfs3 file with only one layer is read as a Grid2D rather than a Grid3D, since there is no vertical dimension left to describe.
Selecting layers while reading
A dfs3 file covering many layers and time steps can be large, and often only one layer is of interest. The layers argument selects layers during reading, so the rest of the file is never loaded into memory. It accepts "top", "bottom", or layer indices.
Note that the result is a two-dimensional dataset: selecting a single layer drops the z dimension and the geometry becomes a Grid2D, which can be plotted and written to a dfs2 file.
dst[0].plot();
Reading the bottom layer instead shows a different picture, since oxygen is consumed near the bed.
Note that "top" and "bottom" are not fixed layer numbers. A dfs3 covering a domain with varying depth has cells that hold no data, and the two keywords select the highest and lowest cell that does hold data in each column. The layer they come from therefore differs from one horizontal position to the next, which is why layers="bottom" is not the same as layers=[0]:
Selecting along x instead gives a vertical slice through the domain. Note that spatial selection on a Grid3D is by index rather than by coordinate: unlike dfs2, sel(x=..., y=...) is not available for three-dimensional grids, and isel takes one dimension at a time.
Local coordinates (“NON-UTM”) follow a different convention to projected ones: the origin sits at the bottom-left corner of the grid rather than at the centre of the first element. This applies to the x and y coordinates.