import mikeio
import matplotlib.pyplot as plt
Dfs2 - Slicing
= mikeio.read("../tests/testdata/waves.dfs2")
ds ds
<mikeio.Dataset>
dims: (time:3, y:31, x:31)
time: 2004-01-01 00:00:00 - 2004-01-03 00:00:00 (3 records)
geometry: Grid2D (ny=31, nx=31)
items:
0: Sign. Wave Height <Significant wave height> (meter)
1: Peak Wave Period <Wave period> (second)
2: Mean Wave Direction <Mean Wave Direction> (degree)
0].plot()
ds[=1400,color='k',linestyle='dashed', label="Transect")
plt.axvline(x; plt.legend()
- Use
Dataset/DataArray.sel
with physical coordinates.
=1400)[0].plot() ds.sel(x
<AxesSubplot: xlabel='y', ylabel='time'>
- Use grid coordinates with
Dataset/DataArray.isel
=1400) ds.geometry.find_index(x
(array([27]), None)
=27)[0].plot() ds.isel(x
<AxesSubplot: xlabel='y', ylabel='time'>
=1400).to_dfs("waves_x1400.dfs1") ds.sel(x
= mikeio.read("waves_x1400.dfs1")
dsnew dsnew
<mikeio.Dataset>
dims: (time:3, x:31)
time: 2004-01-01 00:00:00 - 2004-01-03 00:00:00 (3 records)
geometry: Grid1D (n=31, dx=50)
items:
0: Sign. Wave Height <Significant wave height> (meter)
1: Peak Wave Period <Wave period> (second)
2: Mean Wave Direction <Mean Wave Direction> (degree)
import os
"waves_x1400.dfs1") os.remove(